void CSubtractiveInstrument::SetNote(CNote *note)
{
	// Get a list of all attribute nodes and the
	// length of that list
	CComPtr<IXMLDOMNamedNodeMap> attributes;
	note->Node()->get_attributes(&attributes);
	long len;
	attributes->get_length(&len);

	StringToWaveform(note->Waveform());

	// Loop over the list of attributes
	for (int i = 0; i < len; i++)
	{
		// Get attribute i
		CComPtr<IXMLDOMNode> attrib;
		attributes->get_item(i, &attrib);

		// Get the name of the attribute
		CComBSTR name;
		attrib->get_nodeName(&name);

		// Get the value of the attribute.  A CComVariant is a variable
		// that can have any type. It loads the attribute value as a
		// string (UNICODE), but we can then change it to an integer 
		// (VT_I4) or double (VT_R8) using the ChangeType function 
		// and then read its integer or double value from a member variable.
		CComVariant value;
		attrib->get_nodeValue(&value);

		if (name == "duration")
		{
			value.ChangeType(VT_R8);
			// number of beats * seconds per beat = seconds for note
			SetDuration(value.dblVal);
		}
		else if (name == "note")
		{
			SetFreq(NoteToFrequency(value.bstrVal));
		}

		if (name == "resonfrequency")
		{
			mResonFilter = true;
			value.ChangeType(VT_R8);
			mResonFrequency = value.dblVal;
		}

//		if (name == "resonbandwidth")
//		{
//			value.ChangeType(VT_R8);
//			mResonBandwidth = value.dblVal;
//		}
//
//		if (name == "filter-envelope")
//		{
//			mFilterEnvelope = true;
//		}
	}
}
Example #2
0
STDMETHODIMP CToolBarButton::AttachImage (VARIANT vPicture, VARIANT vIndex, VARIANT vSizeX)
{
HRESULT hr = RetrieveBitmap (vPicture);

	if (FAILED(hr)) return hr;

// Argumente konvertieren
CComVariant vArg;
long lIndex = -1;
long lSizeX = 0;

	hr = vArg.ChangeType (VT_I4, &vIndex);
	if (SUCCEEDED(hr)) lIndex = V_I4(&vArg);

	hr = vArg.ChangeType (VT_I4, &vSizeX);
	if (SUCCEEDED(hr)) lSizeX = V_I4(&vArg);

	if (lIndex >= 0 && 0 == lSizeX)
		return E_INVALIDARG;	// Größe muß gegeben sein

// wenn kein Index gegeben ist, dann die Bitmap direkt verwenden
	if (lIndex < 0) return S_OK;

// ansonsten generieren des gewünschten Ausschnittes
// ...
	m_PictDisp.Assign(NULL);		// wieder freigeben
	return E_NOTIMPL;
}
Example #3
0
////////////////////////////////////////////////////////////////////////////
// Helper function: Walk all the Elements at a particular node
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(int iLevel, MSXML2::IXMLDOMNode* pNode)
{
	HRESULT hr = S_OK;

	CComBSTR bstrNodeName;
	pNode->get_nodeName(&bstrNodeName);

	CComVariant vNodeValue;
	pNode->get_nodeValue(&vNodeValue);
	vNodeValue.ChangeType(VT_BSTR);
	CString strValueString = V_BSTR(&vNodeValue);

	if (m_pCallbackFunction)
		m_pCallbackFunction(iLevel, CString(bstrNodeName), (LPCSTR)NULL, strValueString, m_pCallbackParam);

	MSXML2::IXMLDOMNamedNodeMapPtr pAttributes = NULL;
	if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
	{
		MSXML2::IXMLDOMNodePtr pAttribute = NULL;
		pAttributes->nextNode(&pAttribute);
		bool bRetVal = true;
		while (pAttribute)
		{
			CComBSTR bstrAttribName;
			pAttribute->get_nodeName(&bstrAttribName);

			CComVariant vNodeValue;
			pAttribute->get_nodeValue(&vNodeValue);
			vNodeValue.ChangeType(VT_BSTR);
			CString strValueString = V_BSTR(&vNodeValue);

			if (m_pCallbackFunction)
				bRetVal = m_pCallbackFunction(iLevel+1, CString(bstrNodeName), CString(bstrAttribName), strValueString, m_pCallbackParam);

			if (!bRetVal)
			{
				// set complete error message with node name and all attribute values
				m_strErrorNode = bstrNodeName;
				return S_FALSE;
			}

			pAttributes->nextNode(&pAttribute);
		}
	}

	MSXML2::IXMLDOMNodePtr pChild = NULL;
	pNode->get_firstChild(&pChild);
	while (pChild)
	{
		if (WalkTree(iLevel+1, pChild) != S_OK)
			return S_FALSE;

		MSXML2::IXMLDOMNode* pNext = NULL;
		pChild->get_nextSibling(&pNext);
		pChild = pNext;
	}

	return S_OK;
}
void CWaveInstrument::SetNote(CNote *note)
{
    // Get a list of all attribute nodes and the
    // length of that list
    CComPtr<IXMLDOMNamedNodeMap> attributes;
    note->Node()->get_attributes(&attributes);
    long len;
    attributes->get_length(&len);

    // Loop over the list of attributes
    for(int i=0;  i<len;  i++)
    {
        // Get attribute i
        CComPtr<IXMLDOMNode> attrib;
        attributes->get_item(i, &attrib);

        // Get the name of the attribute
        CComBSTR name;
        attrib->get_nodeName(&name);

        // Get the value of the attribute.  A CComVariant is a variable
        // that can have any type. It loads the attribute value as a
        // string (UNICODE), but we can then change it to an integer 
        // (VT_I4) or double (VT_R8) using the ChangeType function 
        // and then read its integer or double value from a member variable.
        CComVariant value;
        attrib->get_nodeValue(&value);

        if(name == "duration")
        {
            value.ChangeType(VT_R8);
            SetDuration(value.dblVal);
        }
		else if(name == "note")
        {
            m_freq = NoteToFrequency(L"C5") - NoteToFrequency(value.bstrVal);
        }
		else if(name == "measure")
		{
            value.ChangeType(VT_R8);
            if(value.dblVal == 1.0)
			{
				m_attack = 0.04;
				m_release = 0.06;
			}
			else if((value.dblVal - int(value.dblVal)) >= 0)
			{
				m_attack = 0.04;
				m_release = 0.04;
			}
		}
    }
}
void CWaveInstrumentB::SetNote(CNote *note)
{
	// Get a list of all attribute nodes and the
    // length of that list
    CComPtr<IXMLDOMNamedNodeMap> attributes;
    note->Node()->get_attributes(&attributes);
    long len;
    attributes->get_length(&len);

    // Loop over the list of attributes
    for(int i=0;  i<len;  i++)
    {
        // Get attribute i
        CComPtr<IXMLDOMNode> attrib;
        attributes->get_item(i, &attrib);

        // Get the name of the attribute
        CComBSTR name;
        attrib->get_nodeName(&name);

        CComVariant value;
        attrib->get_nodeValue(&value);

        if(name == "duration")
        {
            value.ChangeType(VT_R8);
            SetDuration(value.dblVal);
        }

        else if(name == "attack")
        {
            value.ChangeType(VT_R8);
            m_ar.SetAttack(value.dblVal);
        }
        else if(name == "release")
        {
            value.ChangeType(VT_R8);
            m_ar.SetRelease(value.dblVal);
        }
	    else if(name == "decay")
        {
            value.ChangeType(VT_R8);
            m_ar.SetDecay(value.dblVal);
        }
        else if(name == "sustain")
        {
            value.ChangeType(VT_R8);
            m_ar.SetSustain(value.dblVal);
        }
    }

}
HRESULT CPageEvents::GetElementID(IXMLDOMElement* pElem, int* pID)
{
  // Get the id or LowerBound attribute, in that order
  CComVariant var;
  if (FAILED(pElem->getAttribute(m_bstrID, &var)) ||
    FAILED(var.ChangeType(VT_I4)))
  {
    RETURN_FAILED(pElem->getAttribute(m_bstrLowerBound, &var));
    RETURN_FAILED(var.ChangeType(VT_I4));
  }
  *pID = V_I4(&var);
  return S_OK;
}
Example #7
0
	tstring CCliMgr::_getWmiInfo(IWbemClassObject *pClassObject,LPCTSTR lpszField)
	{
		SAFEARRAY *pvNames = NULL;
		tstring lpszText2;
		CComVariant varValue ;
		_bstr_t bstrName(lpszField);
		if( pClassObject->Get( bstrName , 0 , &varValue , NULL , 0 ) == S_OK )
		{
			if(varValue.vt   ==   VT_NULL   ||   varValue.vt   ==   VT_EMPTY   ||   varValue.vt   ==   VT_ERROR)   
				return lpszText2;
			_bstr_t b;
			if( varValue.vt & VT_BSTR )
			{
				b = &varValue;
				lpszText2 = tstring(b);
			}
			else if( varValue.vt & VT_ARRAY )
			{
				long iLowBound = 0 , iUpBound = 0 ;
				SafeArrayGetLBound( varValue.parray , 1 , &iLowBound ) ;
				SafeArrayGetUBound( varValue.parray , 1 , &iUpBound ) ;
				for( long j = iLowBound ; j <= iUpBound ; j ++ )
				{
					VARIANT *pvar = NULL ;
					long temp = j ;
					if( SafeArrayGetElement( varValue.parray , &temp , pvar ) == S_OK &&
						pvar )
					{
						CComVariant varTemp ;
						if( varTemp.ChangeType( VT_BSTR , pvar ) == S_OK )
						{
							if( !lpszText2.empty() )
								lpszText2 += _T(",") ;
							b = &varTemp;
							lpszText2 += tstring(b) ;
						}                                                                
					}
				}
			}
			else
			{
				if( varValue.ChangeType( VT_BSTR ) == S_OK )
				{
					b = &varValue;
					lpszText2 += tstring(b) ;
				}					
			}
		}                            
		return lpszText2 ;
	}
Example #8
0
FFCodecContext InitializeCodecContextFromHaaliInfo(CComQIPtr<IPropertyBag> pBag) {
	CComVariant pV;
	if (FAILED(pBag->Read(L"Type", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
		return FFCodecContext();

	unsigned int TT = pV.uintVal;

	FFCodecContext CodecContext(avcodec_alloc_context3(NULL), DeleteHaaliCodecContext);

	unsigned int FourCC = 0;
	if (TT == TT_VIDEO) {
		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"Video.PixelWidth", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			CodecContext->coded_width = pV.uintVal;

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"Video.PixelHeight", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			CodecContext->coded_height = pV.uintVal;

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"FOURCC", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			FourCC = pV.uintVal;

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) {
			CodecContext->extradata_size = vtSize(pV);
			CodecContext->extradata = static_cast<uint8_t*>(av_mallocz(CodecContext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE));
			vtCopy(pV, CodecContext->extradata);
		}
	}
	else if (TT == TT_AUDIO) {
		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"CodecPrivate", &pV, NULL))) {
			CodecContext->extradata_size = vtSize(pV);
			CodecContext->extradata = static_cast<uint8_t*>(av_mallocz(CodecContext->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE));
			vtCopy(pV, CodecContext->extradata);
		}

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"Audio.SamplingFreq", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			CodecContext->sample_rate = pV.uintVal;

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"Audio.BitDepth", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			CodecContext->bits_per_coded_sample = pV.uintVal;

		pV.Clear();
		if (SUCCEEDED(pBag->Read(L"Audio.Channels", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_UI4)))
			CodecContext->channels = pV.uintVal;
	}

	pV.Clear();
	if (SUCCEEDED(pBag->Read(L"CodecID", &pV, NULL)) && SUCCEEDED(pV.ChangeType(VT_BSTR))) {
		char CodecStr[2048];
		wcstombs(CodecStr, pV.bstrVal, 2000);

		CodecContext->codec = avcodec_find_decoder(MatroskaToFFCodecID(CodecStr, CodecContext->extradata, FourCC, CodecContext->bits_per_coded_sample));
	}
	return CodecContext;
}
Example #9
0
////////////////////////////////////////////////////////////////////////////
// Helper function: Walk all the Elements at a particular node
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(int iLevel, MSXML::IXMLDOMNode* pNode)
{
	HRESULT hr = S_OK;

	CComBSTR bstrNodeName;
	pNode->get_nodeName(&bstrNodeName);

	CComVariant vNodeValue;
	pNode->get_nodeValue(&vNodeValue);
	vNodeValue.ChangeType(VT_BSTR);
	CString strValueString = V_BSTR(&vNodeValue);

	if (m_pCallbackFunction)
		m_pCallbackFunction(iLevel, CString(bstrNodeName), strValueString, m_pCallbackParam);

	MSXML::IXMLDOMNamedNodeMapPtr pAttributes = NULL;
	if (SUCCEEDED(pNode->get_attributes(&pAttributes)) && (pAttributes != NULL))
	{
		MSXML::IXMLDOMNodePtr pAttribute = NULL;
		pAttributes->nextNode(&pAttribute);
		while (pAttribute)
		{
			CComBSTR bstrNodeName;
			pAttribute->get_nodeName(&bstrNodeName);

			CComVariant vNodeValue;
			pAttribute->get_nodeValue(&vNodeValue);
			vNodeValue.ChangeType(VT_BSTR);
			CString strValueString = V_BSTR(&vNodeValue);

			if (m_pCallbackFunction)
				m_pCallbackFunction(iLevel+1, CString(bstrNodeName), strValueString, m_pCallbackParam);

			pAttributes->nextNode(&pAttribute);
		}
	}

	MSXML::IXMLDOMNodePtr pChild = NULL;
	pNode->get_firstChild(&pChild);
	while (pChild)
	{
		WalkTree(iLevel+1, pChild);

		MSXML::IXMLDOMNode* pNext = NULL;
		pChild->get_nextSibling(&pNext);
		pChild = pNext;
	}

	return S_OK;
}
Example #10
0
void CNote::XmlLoad(IXMLDOMNode * xml, std::wstring & instrument, CEffectsSendTable *sendTable)
{
    // Remember the xml node and the instrument.
    m_node = xml;
    m_instrument = instrument;
	m_sendTable = *sendTable;

    // Get a list of all attribute nodes and the
    // length of that list
    CComPtr<IXMLDOMNamedNodeMap> attributes;
    xml->get_attributes(&attributes);
    long len;
    attributes->get_length(&len);

    // Loop over the list of attributes
    for(int i=0;  i<len;  i++)
    {
        // Get attribute i
        CComPtr<IXMLDOMNode> attrib;
        attributes->get_item(i, &attrib);

        // Get the name of the attribute
        CComBSTR name;
        attrib->get_nodeName(&name);

        // Get the value of the attribute.  
        CComVariant value;
        attrib->get_nodeValue(&value);

        if(name == "measure")
        {
			if(m_measure < 0)
			{
            // The file has measures that start at 1.  
            // We'll make them start at zero instead.
            value.ChangeType(VT_I4);
            m_measure = value.intVal - 1 + m_repeat;
			}
        }
        else if(name == "beat")
        {
            // Same thing for the beats.
            value.ChangeType(VT_R8);
            m_beat = value.dblVal - 1;
        }

    }
}
Example #11
0
STDMETHODIMP CXRecords::UpdateWhere(BSTR key, VARIANT newVal, BSTR whereKey, BSTR op, VARIANT v1, VARIANT v2, long* pVal)
{
	CXRSWhere where;
	HRESULT hr;

	hr = where.Prepare(m_pFields, whereKey, op, v1, v2);
	if(FAILED(hr))return hr;

	int count = m_listRecords->GetCount();
	int i, n = 0;
	int index = m_pFields->FindField(key);

	if(index < 0 || index >= (int)m_pFields->GetCount())
		return DISP_E_BADINDEX;

	VARTYPE vt = m_pFields->GetValue(index)->m_nType;
	if(vt == VT_DISPATCH)return E_INVALIDARG;

	CComVariant var;

	hr = var.ChangeType(vt, &newVal);
	if(FAILED(hr))return hr;

	for(i = 0; i < count; i ++)
		if(where.Check(m_listRecords->GetValue(i)))
		{
			*(CComVariant*)&(m_listRecords->GetValue(i)->m_arrayVariant[index]) = var;
			n ++;
		}

	*pVal = n;

	return S_OK;
}
Example #12
0
VARIANT CBoxEncoding::StrToBin(VARIANT& var, VARIANT &varCP)
{
	CBoxBinPtr varString(var, VT_BSTR);
	UINT nCodePage;

	if(varCP.vt == VT_ERROR)
		nCodePage = _AtlGetConversionACP();
	else
	{
		CComVariant varTemp;

		varTemp.ChangeType(VT_I4, &varCP);
		if(varTemp.vt == VT_I4)
			nCodePage = varTemp.lVal;
		else
			AfxThrowOleException(TYPE_E_TYPEMISMATCH);
	}

	int _nTempCount = ::WideCharToMultiByte(nCodePage, 0, LPWSTR(varString.m_pData), varString.m_nSize, NULL, 0, NULL, NULL);
	CBoxBinPtr varPtr(_nTempCount);

	::WideCharToMultiByte(nCodePage, 0, LPWSTR(varString.m_pData), varString.m_nSize, varPtr, _nTempCount, NULL, NULL);

	return varPtr;
}
Example #13
0
        std::vector<std::string> get_properties(
          const wchar_t * i_query, const std::vector<const wchar_t *> & i_property_names)
        {
            auto                     query_results = execute_query(i_query);
            std::vector<std::string> value_strs;
            value_strs.resize(i_property_names.size());
            for (size_t property_index = 0; property_index < i_property_names.size();
                 property_index++)
            {
                for (const auto & result : query_results)
                {
                    auto & value_str = value_strs[property_index];
                    if (value_str.length() > 0)
                    {
                        value_str += ", ";
                    }

                    CComVariant value;
                    CIMTYPE     value_type;
                    TESTITY_COM_CALL(
                      result->Get(i_property_names[property_index], 0, &value, &value_type, NULL));
                    value.ChangeType(VT_BSTR);
                    value_str += ConvertBSTRToMBS(value.bstrVal);
                }
            }
            return value_strs;
        }
Example #14
0
// die folgende Funktion ist das konkrete äquivalent für 'OleLoadFromStream' --
HRESULT CreateStringFromStream (IStream *pIStream, LPSTR lpstr, int iLen)
{
	ASSERT(pIStream);
	ASSERT(lpstr);
	ASSERT(0 < iLen);
	if (NULL == lpstr) return E_POINTER;
	if (0 == iLen) return E_INVALIDARG;

	USES_CONVERSION;

	*lpstr = '\0';

	try 
	{	// Variant liest sich selbst vom Stream
		CComVariant cv;// VariantInit()
		HRESULT hr = cv.ReadFromStream (pIStream);  
		if (FAILED(hr)) _com_issue_error(hr);
		// Richtigen Typ rausholen
		hr = cv.ChangeType (VT_BSTR);
		if (FAILED(hr)) _com_issue_error(hr);
		// Wert lesen
		CComBSTR bstr = cv.bstrVal; // SysAllocString(...
		LPSTR lpstrName = OLE2A(bstr.m_str);
		if (iLen < strlen(lpstrName)) _com_issue_error(E_INVALIDARG); 
		strcpy(lpstr, lpstrName);
		// in ~CComVariant() VariantClear()
	} // in ~CComBSTR() SysFreeString(m_str)
	catch (_com_error& e) 
	{
		return _COM_ERROR(e);
	}

	return NOERROR;
}
void lvDCOMInterface::getLabviewValue(const char* param, T* value)
{
	if (value == NULL)
	{
		throw std::runtime_error("getLabviewValue failed (NULL)");
	}
	if (param == NULL || *param == '\0')
	{
		throw std::runtime_error("getLabviewValue: param is NULL");
	}
	CComVariant v;
	char vi_name_xpath[MAX_PATH_LEN], control_name_xpath[MAX_PATH_LEN];
	_snprintf(vi_name_xpath, sizeof(vi_name_xpath), "/lvinput/section[@name='%s']/vi/@path", m_configSection.c_str());
	_snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param[@name='%s']/read/@target", m_configSection.c_str(), param);
	CComBSTR vi_name(doPath(vi_name_xpath).c_str());
	CComBSTR control_name(doXPATH(control_name_xpath).c_str());
	if (vi_name.Length() == 0 || control_name.Length() == 0)
	{
		throw std::runtime_error("getLabviewValue: vi or control is NULL");
	}
	getLabviewValue(vi_name, control_name, &v);
	if ( v.ChangeType(CVarTypeInfo<T>::VT) == S_OK )
	{
		*value = v.*(CVarTypeInfo<T>::pmField);	
	}
	else
	{
		throw std::runtime_error("getLabviewValue failed (ChangeType)");
	}
}
void CPagePlayers::TeamInfoChange(IAGCEvent* pEvent)
{
  CWaitCursor wait;

  // Get the interesting properties of the event
  CComBSTR bstrTeam, bstrTeamNew;
  pEvent->get_SubjectName(&bstrTeam);
  CComVariant varTeamNew;
  pEvent->get_Property(&CComVariant(L"NewTeamName"), &varTeamNew);
  varTeamNew.ChangeType(VT_BSTR);
  CString strTeam(bstrTeam), strTeamNew(V_BSTR(&varTeamNew));

  // Name must not be empty
  _ASSERTE(!strTeam.IsEmpty());

  // Loop through each item in the list
  int cPlayers = m_listPlayers.GetItemCount();
  for (int i = 0; i < cPlayers; ++i)
  {
    // Get the list item's team name
    CString str(m_listPlayers.GetItemText(i, c_iColumnTeam));

    // Change the team name of this item, if it has the old team name
    if (str == strTeam)
      m_listPlayers.SetItemText(i, c_iColumnTeam, strTeamNew);
  }
}
void CPagePlayers::SectorOrTeamChange(IAGCEvent* pEvent, int iColumn,
  LPCOLESTR pszProperty)
{
  CWaitCursor wait;

  // Get the interesting properties of the event
  CComBSTR bstrName, bstrProperty;
  pEvent->get_SubjectName(&bstrName);
  CComVariant varNewPropertyName;
  pEvent->get_Property(&CComVariant(pszProperty), &varNewPropertyName);
  varNewPropertyName.ChangeType(VT_BSTR);
  bstrProperty = V_BSTR(&varNewPropertyName);

  // Name must not be empty
  _ASSERTE(bstrName.Length());

  // Find the list item with the specified name
  USES_CONVERSION;
  LV_FINDINFO lvfi = {LVFI_STRING, OLE2CT(bstrName)};
  int iIndex = m_listPlayers.FindItem(&lvfi);
  _ASSERTE(iIndex >= 0);

  // Change the sub-item of the list item
  m_listPlayers.SetItemText(iIndex, iColumn,
    bstrProperty.Length() ? OLE2CT(bstrProperty) : TEXT(""));
}
Example #18
0
STDMETHODIMP CLookupDynamic::Evaluation(VARIANT* pvaInValue, VARIANT* pvaOutValue)
{
	CxComVariant varTemp;
	if (pvaInValue->vt == VT_DISPATCH)
	{
		DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
		HRESULT hr = pvaInValue->pdispVal->Invoke(0, IID_NULL,
				LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
				&dispparamsNoArgs, &varTemp, NULL, NULL);
		if (FAILED(hr))
			return hr;
	}
	else
	{
		VariantCopy(&varTemp, pvaInValue);
	}
		
	if (m_bExactMatch)
	{
		for (int i = 0; i < m_Levels.m_nSize; i++)
		{
			if (varTemp == m_Levels[i].Input1)
			{
				VariantCopy(pvaOutValue, &m_Levels[i].Output);
				return S_OK;
			}
		}

		// 布尔类型的特殊处理
		if (varTemp.vt == VT_BOOL)
		{
			for (int i = 0; i < m_Levels.m_nSize; i++)
			{
				CComVariant var = m_Levels[i].Input1;
				var.ChangeType(VT_BOOL);

				if (varTemp == var)
				{
					VariantCopy(pvaOutValue, &m_Levels[i].Output);
					return S_OK;
				}
			}
		}
	}
	else
	{
		//插入法查值
		for (int i = 0; i < m_Levels.m_nSize; i++)
		{
			if (varTemp >= m_Levels[i].Input1 && 
				varTemp <= m_Levels[i].Input2)
			{
				VariantCopy(pvaOutValue, &m_Levels[i].Output);
				return S_OK;
			}
		}	
	}
		
	return S_FALSE;
}
Example #19
0
HRESULT STDMETHODCALLTYPE CIEHtmlElement::setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags)
{
    if (strAttributeName == NULL)
    {
        return E_INVALIDARG;
    }

    nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mDOMNode);
    if (!element)
    {
        return E_UNEXPECTED;
    }

    // Get the name from the BSTR
    USES_CONVERSION;
    nsAutoString name(OLE2W(strAttributeName));

    // Get the value from the variant
    CComVariant vValue;
    if (FAILED(vValue.ChangeType(VT_BSTR, &AttributeValue)))
    {
        return E_INVALIDARG;
    }

    // Set the attribute
    nsAutoString value(OLE2W(vValue.bstrVal));
    element->SetAttribute(name, value);

    return S_OK;
}
HRESULT CPageEvents::GetElementDisplayName(IXMLDOMElement* pElem, BSTR* pbstr)
{
  // Get the DisplayName or Name attribute, in that order
  CComVariant var;
  if (FAILED(pElem->getAttribute(m_bstrDisplayName, &var)) ||
    FAILED(var.ChangeType(VT_BSTR))            ||
    !V_BSTR(&var)                    ||
    !SysStringLen(V_BSTR(&var)))
  {
    RETURN_FAILED(pElem->getAttribute(m_bstrName, &var));
    RETURN_FAILED(var.ChangeType(VT_BSTR));
  }
  *pbstr = V_BSTR(&var);
  V_VT(&var) = VT_EMPTY;
  return S_OK;
}
void CRingModulationEffect::Factory::XmlLoad(IXMLDOMNode * xml)
{
	CComPtr<IXMLDOMNamedNodeMap> attributes;
	xml->get_attributes(&attributes);
	long len;
	attributes->get_length(&len);

	for (long i = 0; i < len; i++)
	{
		CComPtr<IXMLDOMNode> attrib;
		attributes->get_item(i, &attrib);

		CComBSTR name;
		attrib->get_nodeName(&name);

		CComVariant value;
		attrib->get_nodeValue(&value);

		if (name == L"frequency")
		{
			value.ChangeType(VT_R8);
			m_frequency = value.dblVal;
		}
	}
}
Example #22
0
///////////////////////////////////////////////////////////////////////////////
// IPropertyAction2 methods
STDMETHODIMP CPropertyAction::InitFromData (IDataObject *pIDO, BOOL fCreate, DWORD)
{
	if (NULL == pIDO) {
		if (fCreate)
			return S_OK;	// can attempt to initialize it self
		else
			return S_FALSE;	// can't attempt to replace internal data
	}

	COM_TRY {
	CComVariant vData;

		THROW_FAILED_HRESULT(GetVariantData (pIDO, &c_feInitPropAct, &vData));
		THROW_FAILED_HRESULT(vData.ChangeType(VT_BSTR));

	WParseStringPairs Bag (CLSID_ParseStringPairs);
	CComVariant v (DISP_E_PARAMNOTFOUND, VT_ERROR);	// no error log
	LONG lCount = 0;
	CComBSTR bstrData;

		if (*V_BSTR(&vData) != L';') 		// Data müssen mit ";PropActData" anfangen
			bstrData = L";PropActData;";

		bstrData += V_BSTR(&vData);

		THROW_FAILED_HRESULT(Bag -> put_Pattern (CComBSTR(L";%1=%2")));
		THROW_FAILED_HRESULT(Bag -> Parse (V_BSTR(&vData), &lCount));
		THROW_FAILED_HRESULT(Bag -> InitObject (GetUnknown(), v));

	} COM_CATCH;
	return S_OK;
}
Example #23
0
// --------------------------------------------------------------------------------------------
STDMETHODIMP CRegOperatPropAct::BeginAction (IProgressIndicator* pIProgInd)
{
#if _TRiAS_VER < 0x0300
	m_hPr = 0;
#else
	COM_TRY
	{
	// Zieldatenquelle aus KontextObjekt herausfinden
	WPropertyActionSequence wSeq;
	WDataObject CtxDO;
	CComVariant vData;

		m_hPr = 0;

		THROW_FAILED_HRESULT (GetSite (IID_IPropertyActionSequence, wSeq.ppv()));
		THROW_FAILED_HRESULT (wSeq->GetSequenceContext (CtxDO.ppi()));
		if (SUCCEEDED (GetVariantData (CtxDO, &c_feDataSourceHandle, &vData)) &&
			SUCCEEDED (vData.ChangeType (VT_I4))) 
		{
			m_hPr = reinterpret_cast<HPROJECT>(V_I4(&vData));
		}
	}
	COM_CATCH;
#endif // _TRiAS_VER < 0x0300

	// Zustand des Dialogs retten (für evtl. späteres Save())
	m_pRegOperDlg->GetSelectedInfo (&m_caSelInfo, m_bIsDirty);

	// Liste für Objekte, die an die PropertyPage übergeben werden, initialisieren
	m_InObjs.clear();				// Liste sicher leeren
	m_ObjsIter = m_InObjs.begin();	// auf Anfang stellen

	return S_OK;

} // BeginAction
 void GetProperty(int key, CComVariant& result) const
 {
     PropertyMap::const_iterator itr = m_graph_property.find(key);
     if (itr != m_graph_property.end())
         result = itr->second;
     else
         result.ChangeType(VT_EMPTY);
 }
CString CAdminPageThreadWnd::GetMessage()
{
  CComVariant varMessage;
  if (FAILED(m_spEvent->get_Property(&CComVariant(L"Message"), &varMessage)))
    return CString();
  varMessage.ChangeType(VT_BSTR);
  return V_BSTR(&varMessage);
}
Example #26
0
/**
 * \brief Get the node value
 * 
 * This is most useful for text and attributes.
 * \returns The node value as a string
 */
std::wstring CXmlNode::GetValue() const
{
    CComVariant value;
    mNode->get_nodeValue(&value);

    value.ChangeType(VT_BSTR);
    return wstring(value.bstrVal);
}
Example #27
0
void CCompression::XmlLoad(IXMLDOMNode * xml)
{
	 // Get a list of all attribute nodes and the
    // length of that list
    CComPtr<IXMLDOMNamedNodeMap> attributes;
    xml->get_attributes(&attributes);
    long len;
    attributes->get_length(&len);

    // Loop over the list of attributes
    for(int i=0;  i<len;  i++)
    {
        // Get attribute i
        CComPtr<IXMLDOMNode> attrib;
        attributes->get_item(i, &attrib);

        // Get the name of the attribute
        CComBSTR name;
        attrib->get_nodeName(&name);

        // Get the value of the attribute.  
        CComVariant value;
        attrib->get_nodeValue(&value);

        if(name == "threshold")
        {
            value.ChangeType(VT_I4);
            m_threshold = value.intVal;
        }
        else if(name == "wet")
        {
            value.ChangeType(VT_R8);
            m_wet = value.dblVal;
        }
		else if(name == "dry")
		{
			value.ChangeType(VT_R8);
			m_dry = value.dblVal;
		}
		else if(name == "ratio")
		{
			value.ChangeType(VT_R8);
			m_ratio = value.dblVal;
		}
    }
}
Example #28
0
HRESULT CToolBarButton::RetrieveBitmap (VARIANT &vPicture)
{
CComVariant vArg;
HRESULT hr = vArg.ChangeType (VT_DISPATCH, &vPicture);

	if (SUCCEEDED(hr)) {
		hr = V_DISPATCH(&vArg) -> QueryInterface(IID_IPictureDisp, m_PictDisp.ppv());
		if (FAILED(hr)) return hr;

		m_iOffset = 0;
		m_iCnt = 1;
		return S_OK;
	}

	hr = vArg.ChangeType (VT_I4, &vPicture);		// BitmapHandle ?
	if (SUCCEEDED(hr)) {
		hr = CreatePicture ((HBITMAP)V_I4(&vArg), NULL, false, m_PictDisp.ppi());
		if (FAILED(hr)) return hr;

		m_iOffset = 0;
		m_iCnt = 1;
		return S_OK;
	}

	hr = vArg.ChangeType (VT_BSTR, &vPicture);	// DateiName ?
	if (SUCCEEDED(hr)) {
	CBildObjekt bmp;

		USES_CONVERSION;
	
	HBITMAP hBmp = bmp.ReadFile (OLE2A(V_BSTR(&vArg)));

		if (NULL != hBmp) {
			hr = CreatePicture (bmp.Detach(), bmp.DetachHPal(), true, m_PictDisp.ppi());
			if (FAILED(hr)) return hr;

			m_iOffset = 0;
			m_iCnt = 1;
			return S_OK;
		}
	}

	return E_INVALIDARG;
}
HRESULT CPageEvents::GetElementSeverity(IXMLDOMElement* pElem, BSTR* pbstr)
{
  // Get the Severity attribute
  CComVariant var;
  pElem->getAttribute(m_bstrSeverity, &var);
  var.ChangeType(VT_BSTR);
  *pbstr = V_BSTR(&var);
  V_VT(&var) = VT_EMPTY;
  return S_OK;
}
Example #30
0
void CLogView::LogVariant(VARIANT & value)
{
  CComVariant vt;
  vt.ChangeType(VT_BSTR, &value);
  if (vt.vt != VT_BSTR)
  {
    vt = _T("???");
  }
  AppendText(vt.bstrVal);
}