Example #1
0
void CSXSView::OnTimer(UINT_PTR nIDEvent)
{
	
	CAutoBrowser AutoBrowser((IWebBrowser2 *)GetApplication(),GetIEServerWnd());

	if (nIDEvent == TIME_ID_INPUT_LOGIN)
	{
		KillTimer(nIDEvent);

		//输入用户名
		{
			CElementInformation ElemInfo;
			ElemInfo.SetTagName(L"input");
			ElemInfo.AddElementAttribute(L"id",L"edit-name",TRUE);

			CElemRectList ElemList;
			AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo);

			if (ElemList.GetElemRectCount() == 1)
			{
				ELEM_RECT ElemRect;
				ElemList.GetElemRectByIndex(0,&ElemRect);

				CComQIPtr<IHTMLInputElement> pInput;
				ElemRect.pElem->QueryInterface(IID_IHTMLInputElement,(void **)&pInput);
				pInput->put_value(theApp.m_strUserName.AllocSysString());
			}
		}

		//输入密码
		{
			CElementInformation ElemInfo;
			ElemInfo.SetTagName(L"input");
			ElemInfo.AddElementAttribute(L"id",L"edit-pass",TRUE);


			CElemRectList ElemList;
			AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo);

			if (ElemList.GetElemRectCount() == 1)
			{
				ELEM_RECT ElemRect;
				ElemList.GetElemRectByIndex(0,&ElemRect);

				CComQIPtr<IHTMLInputElement> pInput;
				ElemRect.pElem->QueryInterface(IID_IHTMLInputElement,(void **)&pInput);
				pInput->put_value(theApp.m_strPassWord.AllocSysString());
			}
		}

		//选中验证码框
		{
			CElementInformation ElemInfo;
			ElemInfo.SetTagName(L"input");
			ElemInfo.AddElementAttribute(L"id",L"edit-captcha-response",TRUE);
			AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo);
		}

	}
	
	if (nIDEvent == TIME_ID_MOUSE_MOVE)
	{
		CRect rcClient;
		GetClientRect(&rcClient);
		AutoBrowser.SetWebPageMousePos(CAutoBrowser::GetRandValue(0,rcClient.Width()),CAutoBrowser::GetRandValue(0,rcClient.Height()));
	}


	if ( nIDEvent == TIME_ID_QUERY_USER_INFO )
	{
		KillTimer(nIDEvent);

		CString strUserRealName;


		CElementInformation ElemInfo;
		ElemInfo.SetTagName(L"a");
		ElemInfo.AddElementAttribute(L"href",L"/admin/std/info",TRUE);

		CElementInformation *pParentInfo = ElemInfo.CreateParentInfo();
		pParentInfo->SetTagName(L"span");
		pParentInfo->AddElementAttribute(L"class",L"user-title",TRUE);

		CElemRectList ElemList;
		AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo);

		if (ElemList.GetElemRectCount() == 1)
		{
			ELEM_RECT ElemRect;
			ElemList.GetElemRectByIndex(0,&ElemRect);

			CComQIPtr<IHTMLElement> pElem;
			ElemRect.pElem->QueryInterface(IID_IHTMLElement,(void **)&pElem);
			if (pElem)
			{
				CComBSTR bstrInnerText;
				pElem->get_innerText(&bstrInnerText);
				strUserRealName = bstrInnerText;
			}
		}

		CMainFrame *pParentFrame = (CMainFrame *)GetParent();
		if (pParentFrame)
		{
			pParentFrame->UpdateFrameTitle(theApp.m_strUserName+L" "+strUserRealName);
			g_loger.StatusOut(L"获取用户信息:%s %s",theApp.m_strUserName,strUserRealName);
		}

	}

	if( nIDEvent == TIME_ID_CLICK_WATCH_CONTINE )
	{
		KillTimer(nIDEvent);

		CElementInformation ElemInfo;
		ElemInfo.SetTagName(L"a");
		ElemInfo.SetTextName(L"继续观看",FALSE);
		ElemInfo.AddElementAttribute(L"href",L"/admin/std/training/",FALSE);
		AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo);

		g_loger.StatusOut(L"点击继续学习按钮");

	}

	if ( nIDEvent == TIME_ID_CLICK_RESUME )
	{
		KillTimer(nIDEvent);

		CElementInformation ElemInfo;
		CElemRectList ElemList;

		ElemInfo.SetTagName(L"object");
		ElemInfo.AddElementAttribute(L"id",L"VMSPlayer",TRUE);

		AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo);
		if ( ElemList.GetElemRectCount() == 1 )
		{
			// 51 382
			ELEM_RECT ElemRect;
			ElemList.GetElemRectByIndex(0,&ElemRect);
			AutoBrowser.ClickWebPagePoint(ElemRect.rcElem.left+51,ElemRect.rcElem.top+382);
			g_loger.StatusOut(L"点击重新观看按钮 X:%d Y:%d",ElemRect.rcElem.left+51,ElemRect.rcElem.top+382);
		}

	}
	
	if ( nIDEvent == TIME_ID_CHECK_VIDEO_PAUSE )
	{
		CElementInformation ElemInfo;
		CElemRectList ElemList;

		ElemInfo.SetTagName(L"object");
		ElemInfo.AddElementAttribute(L"id",L"VMSPlayer",TRUE);

		AutoBrowser.GetAllMatchElemRect(&ElemList,&ElemInfo);
		if ( ElemList.GetElemRectCount() == 1 )
		{
			// 51 382
			ELEM_RECT ElemRect;
			ElemList.GetElemRectByIndex(0,&ElemRect);
			
			CRect rcElem;
			rcElem = ElemRect.rcElem;
			CPoint ptCenter;
			ptCenter = rcElem.CenterPoint();

			COLORREF refColor = 0;

			HDC hDc = ::GetDC(GetIEServerWnd());
			refColor =  GetPixel(hDc,ptCenter.x,ptCenter.y);
			::ReleaseDC(GetIEServerWnd(),hDc);
			
			if ( m_refPreColor == refColor )
			{
				m_nColorSameCount++;
			}
			else
			{
				m_nColorSameCount=0;
			}

			m_refPreColor = refColor;

			if ( m_nColorSameCount > 20 )
			{
				g_loger.StatusOut(L"窗口定点颜色 %x 超过 20*5 秒没有变化",m_refPreColor);

				KillTimer(nIDEvent);

				CElementInformation ElemInfo;
				ElemInfo.SetTagName(L"input");
				ElemInfo.AddElementAttribute(L"value",L"退出学习",FALSE);
				//ElemInfo.AddElementAttribute(L"type",L"submit",TRUE);
				AutoBrowser.ClickFirstMatchWebPageElement(&ElemInfo);
			}
		
#ifdef DEBUG
			CString strMsgOut;
			strMsgOut.Format(L"0x%x\r\n",refColor);
			OutputDebugStringW(strMsgOut);
#endif
		}
	}

	CIECoreView::OnTimer(nIDEvent);
}
Example #2
0
long shape_extractor::at(size_t i, IGeometry **ppNewGeom)
{
  if (m_gt == esriGeometryNull)
    return S_FALSE;

  CComQIPtr<IGeometry> ipNewShape;
  if (m_gt == esriGeometryPoint)
  {
    HRESULT hr = newShape(m_gt, m_ipSR, m_hasZ, m_hasM, &ipNewShape);
    if (hr != S_OK)
      return showError<true>(L"create new geometry failed"), hr;
    CComQIPtr<IPoint> ipPoint(ipNewShape);

    double x, y, z, m;
    if (m_as_matrix)
    {
      ATLASSERT(Rf_isMatrix(m_shape));
      size_t r = m_len;//INTEGER(dims)[0];
      x = REAL(m_shape)[i];
      y = REAL(m_shape)[i + r];
      if (m_hasZ || m_hasM)
      {
        m = z = REAL(m_shape)[i + (r*2)];
        if (m_hasZ && m_hasM)
          m = REAL(m_shape)[i + (r*3)];
      }
    }
    else
    {
      x = REAL(m_parts[0])[i];
      y = REAL(m_parts[1])[i];
      if (m_hasZ || m_hasM)
      {
        double z, m;
        m = z = REAL(m_parts[2])[i];
        if (m_hasZ && m_hasM)
          m = REAL(m_parts[3])[i];
      }
    }
    ipPoint->PutCoords(x, y);
    if (m_hasZ) ipPoint->put_Z(z);
    if (m_hasM) ipPoint->put_M(m);

    return ipNewShape.CopyTo(ppNewGeom);
  }

  SEXP it = 0;
  tools::vectorGeneric geometry(m_shape);
  HRESULT hr = newShape(m_gt, m_ipSR, false, false, &ipNewShape);
  if (hr != S_OK)
    return showError<true>(L"create new geometry failed"), hr;

  it = geometry.at(i);
  if (Rf_isNull(it))
  {
    ipNewShape->SetEmpty();
  }
  else
  {
    HRESULT hr = S_FALSE;
    if (TYPEOF(it) == NILSXP || Rf_isNumeric(it))
      hr = ipNewShape->SetEmpty();
    else
    {
      std::vector<BYTE> buff;
      if (!tools::copy_to(it, buff))
        return showError<false>(L"unknown structure"), E_FAIL;
      CComQIPtr<IESRIShape2> ipShape(ipNewShape);
      long buffSize = (long)buff.size();
      hr = ipShape->ImportFromESRIShapeEx(esriShapeImportNoSwap | esriShapeImportNonTrusted, &buffSize, &buff[0]);
    }
    if (hr != S_OK)
      return showError<true>(L"create new geometry"), hr;
  }
  return ipNewShape.CopyTo(ppNewGeom);
}
static IOResult ImportLibrary(ILoad* iload, MtlBaseLib& lib)
{
	// Get the VIZ Importer/Exporter
	CComPtr<IVIZPointerClient> pPointerClient;
	HRESULT hr = CMaxMaterialCollection::GetXMLImpExp(&pPointerClient);
	if(hr != S_OK)
		return IO_ERROR;

	// Get the export interface
	CComQIPtr<IXmlMaterial> pIMtl = pPointerClient;
	ATLASSERT(pIMtl);
	if(!pIMtl)
		return IO_ERROR;

	// Create an XML document
	CComPtr<IXMLDOMDocument> doc;
	hr = doc.CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER);
	if (hr != S_OK || doc == NULL)
		return IO_ERROR;

	char* xmlStr = NULL;
	IOResult res = iload->ReadCStringChunk(&xmlStr);
	if (res != IO_OK)
		return res;
	if (xmlStr == NULL)
		return IO_OK;
	_bstr_t xml(xmlStr);

	VARIANT_BOOL result;
	hr = doc->loadXML(xml.GetBSTR(), &result);
	if (hr != S_OK || result == 0)
		return IO_ERROR;

	CComBSTR query = "./Materials/Material";
	CComPtr<IXMLDOMNodeList> list;
	hr = doc->selectNodes(query, &list);
	if (hr != S_OK || list == NULL)
		return IO_ERROR;

	long i, len = 0;
	hr = list->get_length(&len);
	if (hr != S_OK)
		return IO_ERROR;

	long failed = 0;
	for (i = 0; i < len ; ++i) {
		CComPtr<IXMLDOMNode> node;
		hr = list->get_item(i, &node);
		if (hr == S_OK && node != NULL) {
			VARIANT vResult;
			vResult.vt = VT_BYREF;
			vResult.byref = NULL;
			hr = pIMtl->ImportMaterial(node, &vResult);
			if(SUCCEEDED(hr) && vResult.vt == VT_BYREF && vResult.byref != NULL)
			{
				lib.Add(static_cast<Mtl*>(vResult.byref));
			}
			else
				++failed;
		}
	}
	
	return failed == 0 ? IO_OK : IO_ERROR;
}
Example #4
0
bool CFGFilterLAVAudio::Settings::SetSettings(CComQIPtr<ILAVAudioSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    pLAVFSettings->SetTrayIcon(bTrayIcon);

    pLAVFSettings->SetDRC(bDRCEnabled, iDRCLevel);

    pLAVFSettings->SetDTSHDFraming(bDTSHDFraming);

    pLAVFSettings->SetAutoAVSync(bAutoAVSync);

    pLAVFSettings->SetExpandMono(bExpandMono);

    pLAVFSettings->SetExpand61(bExpand61);

    pLAVFSettings->SetOutputStandardLayout(bOutputStandardLayout);

    pLAVFSettings->SetMixingEnabled(bMixingEnabled);

    pLAVFSettings->SetMixingLayout(dwMixingLayout);

    pLAVFSettings->SetMixingFlags(dwMixingFlags);

    pLAVFSettings->SetMixingMode((LAVAudioMixingMode)dwMixingMode);

    pLAVFSettings->SetMixingLevels(dwMixingCenterLevel, dwMixingSurroundLevel, dwMixingLFELevel);

    pLAVFSettings->SetAudioDelay(bAudioDelayEnabled, iAudioDelay);

    for (int i = 0; i < Bitstream_NB; ++i) {
        pLAVFSettings->SetBitstreamConfig((LAVBitstreamCodec)i, bBitstream[i]);
    }

    for (int i = 0; i < SampleFormat_Bitstream; ++i) {
        pLAVFSettings->SetSampleFormat((LAVAudioSampleFormat)i, bSampleFormats[i]);
    }

    pLAVFSettings->SetSampleConvertDithering(bSampleConvertDither);

    // The internal LAV Audio Decoder will not be registered to handle WMA formats
    // since the system decoder is preferred. However we can still enable those
    // formats internally so that they are used in low-merit mode.
    pLAVFSettings->SetFormatConfiguration(Codec_WMA2, TRUE);
    pLAVFSettings->SetFormatConfiguration(Codec_WMAPRO, TRUE);
    pLAVFSettings->SetFormatConfiguration(Codec_WMALL, TRUE);

    // Custom interface available only in patched build, will be removed after it's upstreamed
    if (CComQIPtr<ILAVAudioSettingsMPCHCCustom> pLAVFSettingsMPCHCCustom = pLAVFSettings) {
        pLAVFSettingsMPCHCCustom->SetPropertyPageCallback(PropertyPageCallback);
    }

    return true;
}
Example #5
0
void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
{
    CString muxer;
    muxer.Format(_T("DSM Muxer (%s)"), CString(__TIMESTAMP__));

    SetProperty(L"MUXR", CStringW(muxer));
    SetProperty(L"DATE", CStringW(CTime::GetCurrentTime().FormatGmt(_T("%Y-%m-%d %H:%M:%S"))));

    MuxFileInfo(pBS);

    POSITION pos = m_pPins.GetHeadPosition();
    while (pos) {
        CBaseMuxerInputPin* pPin = m_pPins.GetNext(pos);
        const CMediaType& mt = pPin->CurrentMediaType();

        ASSERT((mt.lSampleSize >> 30) == 0); // you don't need >1GB samples, do you?

        MuxPacketHeader(pBS, DSMP_MEDIATYPE, 5 + sizeof(GUID) * 3 + mt.FormatLength());
        pBS->BitWrite(pPin->GetID(), 8);
        pBS->ByteWrite(&mt.majortype, sizeof(mt.majortype));
        pBS->ByteWrite(&mt.subtype, sizeof(mt.subtype));
        pBS->BitWrite(mt.bFixedSizeSamples, 1);
        pBS->BitWrite(mt.bTemporalCompression, 1);
        pBS->BitWrite(mt.lSampleSize, 30);
        pBS->ByteWrite(&mt.formattype, sizeof(mt.formattype));
        pBS->ByteWrite(mt.Format(), mt.FormatLength());

        MuxStreamInfo(pBS, pPin);
    }

    // resources & chapters

    CInterfaceList<IDSMResourceBag> pRBs;
    pRBs.AddTail(this);

    CComQIPtr<IDSMChapterBag> pCB = (IUnknown*)(INonDelegatingUnknown*)this;

    pos = m_pPins.GetHeadPosition();
    while (pos) {
        for (CComPtr<IPin> pPin = m_pPins.GetNext(pos)->GetConnected(); pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
            if (m_fAutoRes) {
                CComQIPtr<IDSMResourceBag> pPB = GetFilterFromPin(pPin);
                if (pPB && !pRBs.Find(pPB)) {
                    pRBs.AddTail(pPB);
                }
            }

            if (m_fAutoChap) {
                if (!pCB || pCB->ChapGetCount() == 0) {
                    pCB = GetFilterFromPin(pPin);
                }
            }
        }
    }

    // resources

    pos = pRBs.GetHeadPosition();
    while (pos) {
        IDSMResourceBag* pRB = pRBs.GetNext(pos);

        for (DWORD i = 0, j = pRB->ResGetCount(); i < j; i++) {
            CComBSTR name, desc, mime;
            BYTE* pData = NULL;
            DWORD len = 0;
            if (SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
                CStringA utf8_name = UTF16To8(name);
                CStringA utf8_desc = UTF16To8(desc);
                CStringA utf8_mime = UTF16To8(mime);

                MuxPacketHeader(pBS, DSMP_RESOURCE,
                                1 +
                                utf8_name.GetLength() + 1 +
                                utf8_desc.GetLength() + 1 +
                                utf8_mime.GetLength() + 1 +
                                len);

                pBS->BitWrite(0, 2);
                pBS->BitWrite(0, 6); // reserved
                pBS->ByteWrite(utf8_name, utf8_name.GetLength() + 1);
                pBS->ByteWrite(utf8_desc, utf8_desc.GetLength() + 1);
                pBS->ByteWrite(utf8_mime, utf8_mime.GetLength() + 1);
                pBS->ByteWrite(pData, len);

                CoTaskMemFree(pData);
            }
        }
    }

    // chapters

    if (pCB) {
        CAtlList<CDSMChapter> chapters;
        REFERENCE_TIME rtPrev = 0;
        int len = 0;

        pCB->ChapSort();

        for (DWORD i = 0; i < pCB->ChapGetCount(); i++) {
            CDSMChapter c;
            CComBSTR name;
            if (SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
                REFERENCE_TIME rtDiff = c.rt - rtPrev;
                rtPrev = c.rt;
                c.rt = rtDiff;
                c.name = name;
                len += 1 + GetByteLength(myabs(c.rt)) + UTF16To8(c.name).GetLength() + 1;
                chapters.AddTail(c);
            }
        }

        if (chapters.GetCount()) {
            MuxPacketHeader(pBS, DSMP_CHAPTERS, len);

            pos = chapters.GetHeadPosition();
            while (pos) {
                CDSMChapter& c = chapters.GetNext(pos);
                CStringA name = UTF16To8(c.name);
                int irt = GetByteLength(myabs(c.rt));
                pBS->BitWrite(c.rt < 0, 1);
                pBS->BitWrite(irt, 3);
                pBS->BitWrite(0, 4);
                pBS->BitWrite(myabs(c.rt), irt << 3);
                pBS->ByteWrite((LPCSTR)name, name.GetLength() + 1);
            }
        }
    }
}
Example #6
0
bool CFGFilterLAVSplitterBase::Settings::SetSettings(CComQIPtr<ILAVFSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    pLAVFSettings->SetTrayIcon(bTrayIcon);

    pLAVFSettings->SetPreferredLanguages(prefAudioLangs.c_str());
    pLAVFSettings->SetPreferredSubtitleLanguages(prefSubLangs.c_str());
    pLAVFSettings->SetAdvancedSubtitleConfig(subtitleAdvanced.c_str());

    pLAVFSettings->SetSubtitleMode(subtitleMode);

    pLAVFSettings->SetPGSForcedStream(bPGSForcedStream);

    pLAVFSettings->SetPGSOnlyForced(bPGSOnlyForced);

    pLAVFSettings->SetVC1TimestampMode(iVC1Mode);

    pLAVFSettings->SetSubstreamsEnabled(bSubstreams);

    pLAVFSettings->SetLoadMatroskaExternalSegments(bMatroskaExternalSegments);

    pLAVFSettings->SetStreamSwitchRemoveAudio(bStreamSwitchRemoveAudio);

    pLAVFSettings->SetUseAudioForHearingVisuallyImpaired(bImpairedAudio);

    pLAVFSettings->SetPreferHighQualityAudioStreams(bPreferHighQualityAudio);

    pLAVFSettings->SetMaxQueueMemSize(dwQueueMaxSize);

    pLAVFSettings->SetNetworkStreamAnalysisDuration(dwNetworkAnalysisDuration);

    // Custom interface available only in patched build, will be removed after it's upstreamed
    if (CComQIPtr<ILAVFSettingsMPCHCCustom> pLAVFSettingsMPCHCCustom = pLAVFSettings) {
        pLAVFSettingsMPCHCCustom->SetPropertyPageCallback(PropertyPageCallback);
    }

    return true;
}
Example #7
0
bool CFGFilterLAVVideo::Settings::SetSettings(CComQIPtr<ILAVVideoSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    pLAVFSettings->SetTrayIcon(bTrayIcon);

    pLAVFSettings->SetStreamAR(dwStreamAR);

    pLAVFSettings->SetNumThreads(dwNumThreads);

    pLAVFSettings->SetDeintFieldOrder((LAVDeintFieldOrder)dwDeintFieldOrder);

    pLAVFSettings->SetDeinterlacingMode(deintMode);

    pLAVFSettings->SetRGBOutputRange(dwRGBRange);

    pLAVFSettings->SetSWDeintMode((LAVSWDeintModes)dwSWDeintMode);

    pLAVFSettings->SetSWDeintOutput((LAVDeintOutput)dwSWDeintOutput);

    pLAVFSettings->SetDitherMode((LAVDitherMode)dwDitherMode);

    for (int i = 0; i < LAVOutPixFmt_NB; ++i) {
        pLAVFSettings->SetPixelFormat((LAVOutPixFmts)i, bPixFmts[i]);
    }

    pLAVFSettings->SetHWAccel((LAVHWAccel)dwHWAccel);

    for (int i = 0; i < HWCodec_NB; ++i) {
        pLAVFSettings->SetHWAccelCodec((LAVVideoHWCodec)i, bHWFormats[i]);
    }

    pLAVFSettings->SetHWAccelResolutionFlags(dwHWAccelResFlags);

    pLAVFSettings->SetHWAccelDeintMode((LAVHWDeintModes)dwHWDeintMode);

    pLAVFSettings->SetHWAccelDeintOutput((LAVDeintOutput)dwHWDeintOutput);

    pLAVFSettings->SetHWAccelDeintHQ(bHWDeintHQ);

    // Force RV1/2 enabled, the user can control it from our own options
    pLAVFSettings->SetFormatConfiguration(Codec_RV12, TRUE);

    // Custom interface available only in patched build, will be removed after it's upstreamed
    if (CComQIPtr<ILAVVideoSettingsMPCHCCustom> pLAVFSettingsMPCHCCustom = pLAVFSettings) {
        pLAVFSettingsMPCHCCustom->SetPropertyPageCallback(PropertyPageCallback);
    }

    return true;
}
///////////////////////////////////////////////////////////////////////////////
// Function:
//      GetMicArrayGeometry()
//
// Description:
//      Obtains the geometry for the specified mic array.
//
// Parameters:  szDeviceId -- The requested device ID, which can be obtained
//                            from calling EnumAudioCaptureDevices()
//              
//              ppGeometry -- Address of the pointer to the mic-array gemometry.  
//                            Caller is ressponsible for calling CoTaskMemFree()
//                            if the call is successfull.
//
//              cbSize -- size of the geometry structure
//
// Returns:     S_OK on success
///////////////////////////////////////////////////////////////////////////////
HRESULT GetMicArrayGeometry(wchar_t szDeviceId[], KSAUDIO_MIC_ARRAY_GEOMETRY** ppGeometry, ULONG& cbSize)
{
    HRESULT hr = S_OK;

    if (szDeviceId == NULL)
        return E_INVALIDARG;
    if (ppGeometry == NULL)
        return E_POINTER;
   
    cbSize = 0;
    CComPtr<IMMDeviceEnumerator> spEnumerator;
    CComPtr<IMMDevice>           spDevice;
    CComQIPtr<IPart>             spPart;
    bool bIsMicArray;

    hr = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    IF_FAILED_RETURN(hr);

    hr = spEnumerator->GetDevice(szDeviceId, &spDevice);
    IF_FAILED_RETURN(hr);

    hr = EndpointIsMicArray(spDevice, bIsMicArray);
    IF_FAILED_RETURN(hr);

    if (!bIsMicArray)
        return E_FAIL;
    
    UINT nPartId = 0;
    hr = GetInputJack(spDevice, spPart);
    IF_FAILED_RETURN(hr);

    hr = spPart->GetLocalId(&nPartId);
    IF_FAILED_RETURN(hr);

    CComPtr<IDeviceTopology>     spTopology;
    CComPtr<IMMDeviceEnumerator> spEnum;
    CComPtr<IMMDevice>           spJackDevice;
    CComPtr<IKsControl>          spKsControl;
    wchar_t *                    pwstrDevice = 0;

    // Get the topology object for the part
    hr = spPart->GetTopologyObject(&spTopology);
    IF_FAILED_RETURN(hr);

    // Get the id of the IMMDevice that this topology object describes.
    hr = spTopology->GetDeviceId(&pwstrDevice);
    IF_FAILED_RETURN(hr);

    // Get an IMMDevice pointer using the ID
    hr = spEnum.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    IF_FAILED_JUMP(hr, Exit);

    hr = spEnum->GetDevice(pwstrDevice, &spJackDevice);
    IF_FAILED_JUMP(hr, Exit);

    // Activate IKsControl on the IMMDevice
    hr = spJackDevice->Activate(__uuidof(IKsControl), CLSCTX_INPROC_SERVER, 
                               NULL, reinterpret_cast<void**>(&spKsControl));
    IF_FAILED_JUMP(hr, Exit);

    // At this point we can use IKsControl just as we would use DeviceIoControl
    KSP_PIN ksp;
    ULONG   cbData     = 0;
    ULONG   cbGeometry = 0;

    // Inititialize the pin property
    ::ZeroMemory(&ksp, sizeof(ksp));
    ksp.Property.Set     = KSPROPSETID_Audio;
    ksp.Property.Id      = KSPROPERTY_AUDIO_MIC_ARRAY_GEOMETRY;
    ksp.Property.Flags   = KSPROPERTY_TYPE_GET;
    ksp.PinId            = nPartId & PARTID_MASK;  

    // Get data size by passing NULL
    hr = spKsControl->KsProperty(reinterpret_cast<PKSPROPERTY>(&ksp), 
                                sizeof(ksp), NULL, 0, &cbGeometry);
    IF_FAILED_JUMP(hr, Exit);
   
    // Allocate memory for the microphone array geometry
    *ppGeometry = reinterpret_cast<KSAUDIO_MIC_ARRAY_GEOMETRY*>
                                   (::CoTaskMemAlloc(cbGeometry));

    if(*ppGeometry == 0)
    {
        hr = E_OUTOFMEMORY;
    }
    IF_FAILED_JUMP(hr, Exit);
   
    // Now retriev the mic-array structure...
    DWORD cbOut = 0;
    hr = spKsControl->KsProperty(reinterpret_cast<PKSPROPERTY>(&ksp), 
                                sizeof(ksp), *ppGeometry, cbGeometry,
                                &cbOut);
    IF_FAILED_JUMP(hr, Exit);
    cbSize = cbGeometry;
   
Exit:
    if(pwstrDevice != 0)
    {
        ::CoTaskMemFree(pwstrDevice);
    }
    return hr;
}//GetMicArrayGeometry()
Example #9
0
	void StartClassify(const CComBSTR & scriptText)
	{
		clib::recursive_mutex::scoped_lock proc(m_mutex);
		if (m_classified)
		{
			proc.unlock();
			on_refresh(this, EVENT_CLASSIFIED);
			return;
		}
		m_classified = true;
		ClassifyStructVector request;
		
		//Process Main Frame
		InsertScript(m_doc, scriptText);
		PrepRequest(m_doc, request);
		
		//Process Child Frames
		CComQIPtr<IOleContainer> pContainer = m_doc;
		if (!pContainer)
			return;

		CComPtr<IEnumUnknown> pEnumerator;
		HRESULT hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
		if (FAILED(hr))
			return;

		CComPtr<IUnknown> pUnk;
		ULONG uFetched;
		for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
		{
			CComQIPtr<IWebBrowser2> pBrowser = pUnk;
			if (pBrowser)
			{
				CComPtr<IDispatch> spDispDoc;
				HRESULT hr = pBrowser->get_Document(&spDispDoc);
				if (SUCCEEDED(hr))
				{
					// ...and query for an HTML document.
					CComQIPtr<IHTMLDocument> spHTMLDoc = spDispDoc;
					if (spHTMLDoc)
					{
						InsertScript(spHTMLDoc, scriptText);
						PrepRequest(spHTMLDoc, request);
					}
				}
			}
			pUnk.Release();
		}

		m_classifyThreads.SetMaxThreadCount(0);
		ClassifyStructVector batchRequest;
		int textLen = 0;
		for(ClassifyStructVector::iterator itr = request.begin(); itr != request.end(); ++itr)
		{
			textLen += itr->text.length();
			batchRequest.push_back(*itr);
			if (textLen > BATCH_SIZE)
			{
				m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
				batchRequest.clear();
				textLen = 0;
			}
		}
		if (batchRequest.size())
		{
			m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
			batchRequest.clear();
		}
		m_classifyThreads.SetMaxThreadCount(THREAD_COUNT);
		//int textLen = 0;
		//BOOL finished = false;
		//HRESULT hr = S_OK;
		//while(hr == S_OK && !finished)
		//{
		//	MARKUP_CONTEXT_TYPE pContext = CONTEXT_TYPE_None;
		//	long pcch = -1;
		//	prev->MoveToPointer(finger);
		//	hr = finger->Right(true, &pContext, NULL, &pcch, NULL);
		//	if (pContext == CONTEXT_TYPE_Text && pcch > 1)
		//	{
		//		ClassifyStruct newItem;
		//		newItem.text.resize(pcch);
		//		prev->Right(false, NULL, NULL, &pcch, &newItem.text[0]);
		//		std::wstring testStr = newItem.text;
		//		boost::algorithm::trim(testStr);
		//		if (testStr.length())
		//		{
		//			markupServices->CreateMarkupPointer(&newItem.textNode);
		//			newItem.textNode->MoveToPointer(prev);
		//			request.push_back(newItem);
		//			textLen += pcch;
		//			if (textLen > 1000)
		//			{
		//				m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, request));
		//				request.clear();
		//				textLen = 0;
		//			}
		//		}
		//	}
		//	finger->IsRightOfOrEqualTo(end, &finished);
		//}
		//if (request.size())
		//{
		//	m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, request));
		//	request.clear();
		//}
		//m_classifyThreads.SetMaxThreadCount(THREAD_COUNT);
	}
Example #10
0
LRESULT CSVGSymbolsDlg::OnSymbolDefineSymbol(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CComPtr<IEXMLDocument> eXMLDocument;
	m_viewGroup->get_eXMLDocument(&eXMLDocument);

	CComQIPtr<IEDocument> eDocument = eXMLDocument;

	CComPtr<ILDOMDocument> document;
	eXMLDocument->get_DOMDocument(&document);

	CSVGFilterOptionsDlg dlg;
	dlg.m_document = document;

	if (dlg.DoModal() == IDOK)
	{
		CComPtr<IOleUndoManager> undoManager;
		eDocument->get_undoManager(&undoManager);

		CComObject<CUndoParent>* pParentUndo;
		CComObject<CUndoParent>::CreateInstance(&pParentUndo);
		if (pParentUndo)
		{
			pParentUndo->AddRef();	// ???
			undoManager->Open(pParentUndo);

			CComPtr<ILSVGElement> svgDefsElement;
			eXMLDocument->FindOrCreateSVGDefs(&svgDefsElement);

			if (svgDefsElement)
			{
				CComPtr<ILSVGSymbolElement> svgFilterElement;
				document->createElementNS(L"http://www.w3.org/2000/svg", L"symbol", (ILDOMElement**)&svgFilterElement);

				if (svgFilterElement)
				{
					svgFilterElement->setAttribute(L"id", dlg.m_id);

					{
						double minx = 99999999;
						double miny = 99999999;
						double maxx = -99999999;
						double maxy = -99999999;

						for (int i = 0; i < m_viewGroup->m_targetElements.GetSize(); i++)
						{
							CComPtr<IEElement> eElement;
							m_viewGroup->m_targetElements[i]->get_eElement(&eElement);

							CComPtr<ILDOMElement> element;
							eElement->get_domElement(&element);

							CComQIPtr<ILSVGLocatable> locatable = element;
							if (locatable)
							{
								CComPtr<ILSVGRect> svgrect;
								locatable->getBBox(&svgrect);
								SVGRect rect = svgrect;

								minx = min(minx, rect.X);
								miny = min(miny, rect.Y);
								maxx = max(maxx, rect.X+rect.Width);
								maxy = max(maxy, rect.Y+rect.Height);

								CComPtr<ILDOMNode> clone;
								element->cloneNode(VARIANT_TRUE/*bDeep*/, &clone);

								svgFilterElement->appendChild(clone, NULL);
							}
						}
						WCHAR viewBox[256];
						swprintf(viewBox, L"%g %g %g %g", minx, miny, maxx-minx, maxy-miny);
						svgFilterElement->setAttribute(L"viewBox", viewBox);
					}

					//CComPtr<IOleUndoManager> undoManager;
					//m_document->get_undoManager(&undoManager);

					CComObject<CWEUndoNewElement>* pUndo;
					CComObject<CWEUndoNewElement>::CreateInstance(&pUndo);
					if (pUndo)
					{
					//	pUndo->AddRef();
						pUndo->m_pDocument = static_cast<CEXMLDocument*>(eXMLDocument.p);

						pUndo->DoInitial(undoManager, svgFilterElement, svgDefsElement, NULL);

						{
							CEXMLViewGroup* pViewGroup = static_cast<CEXMLViewGroup*>(m_viewGroup);

							CComPtr<IEElement> eElement;
							eXMLDocument->GetEElementFromDOMElement(svgFilterElement, &eElement);

							pViewGroup->m_activeReferencedElement = eElement;	// ??? reference element is still NULL
							m_viewGroup->ActivateElement(eElement, 0, NULL);
						}
					}
				}
			}

			undoManager->Close(pParentUndo, TRUE/*commit*/);
		}
	}

	return 0;
}
Example #11
0
LRESULT CSVGSymbolsDlg::OnBreakLinkToSymbol(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	if (m_viewGroup->m_pActiveElement)
	{
		CComPtr<IEElement> eElement;
		m_viewGroup->m_pActiveElement->get_eElement(&eElement);

		CComPtr<ILDOMElement> domElement;
		eElement->get_domElement(&domElement);

		CComQIPtr<ILSVGUseElement> useElement = domElement;

		if (useElement)
		{
			CComPtr<ILDOMDocument> document;
			m_viewGroup->m_pDocument->get_DOMDocument(&document);

			CComQIPtr<ILSVGURIReference> uriReference = useElement;
			CComPtr<ILSVGAnimatedString> a;
			uriReference->get_href(&a);

			CComBSTR uri;
			a->get_baseVal(&uri);

			BSTR id = &((BSTR)uri)[1];

			CComPtr<ILDOMElement> refElement;
			document->getElementById(id, &refElement);

			CComQIPtr<ILSVGSymbolElement> symbolElement = refElement;
			if (symbolElement)
			{
				CComPtr<ILDOMElement> gElement;
				document->createElementNS(L"http://www.w3.org/2000/svg", L"g", &gElement);
				if (gElement)
				{
					CComPtr<ILDOMElement> svgElement;
					document->createElementNS(L"http://www.w3.org/2000/svg", L"svg", &svgElement);
					if (svgElement)
					{
						CComBSTR viewBox;
						symbolElement->getAttribute(L"viewBox", &viewBox);
						svgElement->setAttribute(L"viewBox", viewBox);

						//symbolElement->getAttribute(L"style", &viewBox);

						CComBSTR width;
						CComBSTR height;
						useElement->getAttribute(L"width", &width);
						useElement->getAttribute(L"height", &height);

						if (width != NULL)
							svgElement->setAttribute(L"width", width);
						else
							svgElement->setAttribute(L"width", L"100%");

						if (height != NULL)
							svgElement->setAttribute(L"height", height);
						else
							svgElement->setAttribute(L"height", L"100%");

						CComPtr<ILDOMNode> node;
						symbolElement->get_firstChild(&node);
						while (node)
						{
							CComQIPtr<ILDOMElement> element = node;
							if (element)
							{
								CComPtr<ILDOMNode> clone;
								element->cloneNode(VARIANT_TRUE/*bDeep*/, &clone);

								svgElement->appendChild(clone, NULL);
							}
							CComPtr<ILDOMNode> nextSibling;
							node->get_nextSibling(&nextSibling);
							node = nextSibling;
						}

						gElement->appendChild(svgElement, NULL);
					}

					CComPtr<ILDOMNode> parentNode;
					useElement->get_parentNode(&parentNode);

					CComPtr<ILDOMNode> p;
					parentNode->replaceChild(gElement, useElement, &p);
				}
			}
		}
	}

	return 0;
}
Example #12
0
STDMETHODIMP CSVGSymbolsDlg::Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL pt, DWORD * pdwEffect)
{
	ASSERT(0);
#if 0
	POINT point;
	point.x = pt.x;
	point.y = pt.y;
	ScreenToClient(&point);

	COleDataObjectWrapper dataObject;
	dataObject.Attach(pDataObject);

	HGLOBAL hData;

#if 0
	if (hData = dataObject.GetGlobalData(CF_HDROP))
	{
		DROPFILES* dp = (DROPFILES*)GlobalLock(hData);
		if (dp)
		{
			char* p = (char*)(dp+1);

			int i = 0;
			TCHAR filename[512];
			while (*p)
			{
				filename[i++] = *p++;
			}
			filename[i] = 0;

			CHTMDesignFrame* pFrame = NULL;
			m_pFrameSet->OnButtonDown(0, point, 0, FALSE, &pFrame);
			if (pFrame)
			{
				pFrame->m_pElement->setAttribute(L"src", _bstr_t(filename));
				//m_pDocument->CreateHTMLTree();
				//m_pDocument->UpdateAllViews(NULL);
			}
		}

		GlobalUnlock(hData);

		{
			BuildFrames();

			OnSize();
			InvalidateRect(NULL, TRUE);
		}

		*pdwEffect = DROPEFFECT_COPY;
	}
	else
#endif
	if (hData = dataObject.GetGlobalData(CF_UNICODETEXT))
	{
		WCHAR* text = (WCHAR*)GlobalLock(hData);
		int len = GlobalSize(hData);

		CComPtr<ILSVGDocument> svgdocument;
		svgdocument.CoCreateInstance(CLSID_LSVGDocument);

		VARIANT_BOOL bsuccess;
		svgdocument->loadXML(_bstr_t(text), &bsuccess);

		if (bsuccess)
		{
			CComQIPtr<IEDocument> eDocument = m_viewGroup->m_pDocument;

			CComPtr<IOleUndoManager> undoManager;
			eDocument->get_undoManager(&undoManager);

			CComObject<CUndoParent>* pParentUndo;
			CComObject<CUndoParent>::CreateInstance(&pParentUndo);
			if (pParentUndo)
			{
				pParentUndo->AddRef();	// ???
				undoManager->Open(pParentUndo);

				CComPtr<ILSVGElement> svgDefsElement;
				m_viewGroup->m_pDocument->FindOrCreateSVGDefs(&svgDefsElement);

				if (svgDefsElement)
				{
					CComPtr<ILDOMElement> documentElement;
					svgdocument->get_documentElement(&documentElement);

					CComPtr<ILDOMNode> node;
					documentElement->get_firstChild(&node);
					while (node)
					{
						CComPtr<ILDOMNode> nextSibling;
						node->get_nextSibling(&nextSibling);

						CComQIPtr<ILSVGSymbolElement> svgSymbolElement = node;
						if (svgSymbolElement)
						{
							m_listView.m_xmlDocument->adoptNode(svgSymbolElement, NULL);

							CComObject<CWEUndoNewElement>* pUndo;
							CComObject<CWEUndoNewElement>::CreateInstance(&pUndo);
							if (pUndo)
							{
							//	pUndo->AddRef();
								pUndo->m_pDocument = m_viewGroup->m_pDocument;

								pUndo->DoInitial(undoManager, svgSymbolElement, svgDefsElement, NULL);
							}
						}

						node = nextSibling;
					}
				}

				undoManager->Close(pParentUndo, TRUE/*commit*/);
			}
		}

		GlobalUnlock(hData);
		//return TRUE;
	}
#endif

	return S_OK;
}
Example #13
0
IDispatch* WizardApp::GetWebBrowserDisp()
{
	CComQIPtr<IDispatch> spDisp = m_spWebDisp;

	return spDisp.Detach();
}
Example #14
0
CComPtr<IUIDlg> CEColorDlg::CreateColorPicker(int nColorPicker)
{
	CComPtr<IUIDlg> colorDlg;

	if (nColorPicker == 0)
	{
		/*
		CComObject<CColorPickerGrayscaleDlg>* p;
		CComObject<CColorPickerGrayscaleDlg>::CreateInstance(&p);
		if (p)
		{
			colorDlg = p;
		}
		*/
	}
	else if (nColorPicker == 1)
	{
		CComObject<CRGBSlidersDlg>* p;
		CComObject<CRGBSlidersDlg>::CreateInstance(&p);
		if (p)
		{
			colorDlg = p;
		}
	}
	else if (nColorPicker == 2)
	{
		CComObject<CHSLColorWheelDlg>* p;
		CComObject<CHSLColorWheelDlg>::CreateInstance(&p);
		if (p)
		{
			colorDlg = p;
		}
	}
	else if (nColorPicker == 3)
	{
		CComObject<CNamedColorsDlg>* p;
		CComObject<CNamedColorsDlg>::CreateInstance(&p);
		if (p)
		{
			colorDlg = p;
		}
	}
	else
		ASSERT(0);

	if (colorDlg)
	{
		CComQIPtr<IEColorPicker> colorpicker = colorDlg;
		if (colorpicker)
		{
			colorpicker->SetSite(this);
			colorDlg->Create(m_hWnd);

			HWND hWnd;
			colorDlg->get_hwnd(&hWnd);
			if (hWnd)
			{
				::ShowWindow(hWnd, SW_SHOW);

				return colorDlg;
			}
		}
	}

	return NULL;
}
Example #15
0
STDMETHODIMP CESVGRectElement::Move(ISVGView* view, double dx, double dy)
{
	ATLASSERT(0);
#if 0
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	CComPtr<ILHTMLWindow> window;
	view->GetHTMLWindow(&window);

	CComPtr<ILSVGElement> viewportElement;
	rect->get_viewportElement(&viewportElement);

// TODO, this can't be correct
	CComPtr<ILSVGRect> _rect;
	window->svgGetRBBox(viewportElement, &_rect);
	SVGRect viewBox = _rect;

	// x
	{
		CComPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double dx_pcnt = dx*100/viewBox.Width;

			double value;
			length->get_valueInSpecifiedUnits(&value);
			length->put_valueInSpecifiedUnits(value+dx_pcnt);
		}
		else
		{
			double value;
			length->get_value(&value);
			length->put_value(value + dx);
		}
	}

	// y
	{
		CComPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double dy_pcnt = dy*100/viewBox.Height;

			double value;
			length->get_valueInSpecifiedUnits(&value);
			length->put_valueInSpecifiedUnits(value+dy_pcnt);
		}
		else
		{
			double value;
			length->get_value(&value);
			length->put_value(value + dy);
		}
	}
#endif

	return S_OK;
}
Example #16
0
LPCTSTR CBaseSplitterFilter::GetPartFilename(IAsyncReader* pAsyncReader)
{
	CComQIPtr<IFileHandle>	pFH = pAsyncReader;
	return pFH ? pFH->GetFileName() : m_fn;
}
Example #17
0
bool CFGFilterLAVSplitterBase::Settings::GetSettings(CComQIPtr<ILAVFSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    bTrayIcon = pLAVFSettings->GetTrayIcon();

    HRESULT hr;
    LPWSTR lpwstr = nullptr;
    hr = pLAVFSettings->GetPreferredLanguages(&lpwstr);
    if (SUCCEEDED(hr) && lpwstr) {
        prefAudioLangs = lpwstr;
        CoTaskMemFree(lpwstr);
    }
    lpwstr = nullptr;
    hr = pLAVFSettings->GetPreferredSubtitleLanguages(&lpwstr);
    if (SUCCEEDED(hr) && lpwstr) {
        prefSubLangs = lpwstr;
        CoTaskMemFree(lpwstr);
    }
    lpwstr = nullptr;
    hr = pLAVFSettings->GetAdvancedSubtitleConfig(&lpwstr);
    if (SUCCEEDED(hr) && lpwstr) {
        subtitleAdvanced = lpwstr;
        CoTaskMemFree(lpwstr);
    }

    subtitleMode = pLAVFSettings->GetSubtitleMode();

    bPGSForcedStream = pLAVFSettings->GetPGSForcedStream();

    bPGSOnlyForced = pLAVFSettings->GetPGSOnlyForced();

    iVC1Mode = pLAVFSettings->GetVC1TimestampMode();

    bSubstreams = pLAVFSettings->GetSubstreamsEnabled();

    bMatroskaExternalSegments = pLAVFSettings->GetLoadMatroskaExternalSegments();

    bStreamSwitchRemoveAudio = pLAVFSettings->GetStreamSwitchRemoveAudio();

    bImpairedAudio = pLAVFSettings->GetUseAudioForHearingVisuallyImpaired();

    bPreferHighQualityAudio = pLAVFSettings->GetPreferHighQualityAudioStreams();

    dwQueueMaxSize = pLAVFSettings->GetMaxQueueMemSize();

    dwNetworkAnalysisDuration = pLAVFSettings->GetNetworkStreamAnalysisDuration();

    return true;
}
// Attach the created control to a window and activate it
HRESULT CControlSite::Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream)
{
    TRACE_METHOD(CControlSite::Attach);

    if (hwndParent == NULL)
    {
        NS_ASSERTION(0, "No parent hwnd");
        return E_INVALIDARG;
    }

    m_hWndParent = hwndParent;
    m_rcObjectPos = rcPos;

    // Object must have been created
    if (m_spObject == NULL)
    {
        return E_UNEXPECTED;
    }

    m_spIViewObject = m_spObject;
    m_spIOleObject = m_spObject;
    
    if (m_spIOleObject == NULL)
    {
        return E_FAIL;
    }
    
    DWORD dwMiscStatus;
    m_spIOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);

    if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
    {
        m_bSetClientSiteFirst = TRUE;
    }
    if (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME)
    {
        m_bVisibleAtRuntime = FALSE;
    }

    // Some objects like to have the client site as the first thing
    // to be initialised (for ambient properties and so forth)
    if (m_bSetClientSiteFirst)
    {
        m_spIOleObject->SetClientSite(this);
    }

    // If there is a parameter list for the object and no init stream then
    // create one here.
    CPropertyBagInstance *pPropertyBag = NULL;
    if (pInitStream == NULL && m_ParameterList.GetSize() > 0)
    {
        CPropertyBagInstance::CreateInstance(&pPropertyBag);
        pPropertyBag->AddRef();
        for (unsigned long i = 0; i < m_ParameterList.GetSize(); i++)
        {
            pPropertyBag->Write(m_ParameterList.GetNameOf(i),
                const_cast<VARIANT *>(m_ParameterList.GetValueOf(i)));
        }
        pInitStream = (IPersistPropertyBag *) pPropertyBag;
    }

    // Initialise the control from store if one is provided
    if (pInitStream)
    {
        CComQIPtr<IPropertyBag, &IID_IPropertyBag> spPropertyBag = pInitStream;
        CComQIPtr<IStream, &IID_IStream> spStream = pInitStream;
        CComQIPtr<IPersistStream, &IID_IPersistStream> spIPersistStream = m_spIOleObject;
        CComQIPtr<IPersistPropertyBag, &IID_IPersistPropertyBag> spIPersistPropertyBag = m_spIOleObject;

        if (spIPersistPropertyBag && spPropertyBag)
        {
            spIPersistPropertyBag->Load(spPropertyBag, NULL);
        }
        else if (spIPersistStream && spStream)
        {
            spIPersistStream->Load(spStream);
        }
    }
    else
    {
        // Initialise the object if possible
        CComQIPtr<IPersistStreamInit, &IID_IPersistStreamInit> spIPersistStreamInit = m_spIOleObject;
        if (spIPersistStreamInit)
        {
            spIPersistStreamInit->InitNew();
        }
    }

    m_spIOleInPlaceObject = m_spObject;
    m_spIOleInPlaceObjectWindowless = m_spObject;

    m_spIOleInPlaceObject->SetObjectRects(&m_rcObjectPos, &m_rcObjectPos);

    // In-place activate the object
    if (m_bVisibleAtRuntime)
    {
        DoVerb(OLEIVERB_INPLACEACTIVATE);
    }

    // For those objects which haven't had their client site set yet,
    // it's done here.
    if (!m_bSetClientSiteFirst)
    {
        m_spIOleObject->SetClientSite(this);
    }

    return S_OK;
}
Example #19
0
bool CFGFilterLAVVideo::Settings::GetSettings(CComQIPtr<ILAVVideoSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    bTrayIcon = pLAVFSettings->GetTrayIcon();

    dwStreamAR = pLAVFSettings->GetStreamAR();

    dwNumThreads = pLAVFSettings->GetNumThreads();

    dwDeintFieldOrder = pLAVFSettings->GetDeintFieldOrder();

    deintMode = pLAVFSettings->GetDeinterlacingMode();

    dwRGBRange = pLAVFSettings->GetRGBOutputRange();

    dwSWDeintMode = pLAVFSettings->GetSWDeintMode();

    dwSWDeintOutput = pLAVFSettings->GetSWDeintOutput();

    dwDitherMode = pLAVFSettings->GetDitherMode();

    for (int i = 0; i < LAVOutPixFmt_NB; ++i) {
        bPixFmts[i] = pLAVFSettings->GetPixelFormat((LAVOutPixFmts)i);
    }

    dwHWAccel = pLAVFSettings->GetHWAccel();

    for (int i = 0; i < HWCodec_NB; ++i) {
        bHWFormats[i] = pLAVFSettings->GetHWAccelCodec((LAVVideoHWCodec)i);
    }

    dwHWAccelResFlags = pLAVFSettings->GetHWAccelResolutionFlags();

    dwHWDeintMode = pLAVFSettings->GetHWAccelDeintMode();

    dwHWDeintOutput = pLAVFSettings->GetHWAccelDeintOutput();

    bHWDeintHQ = pLAVFSettings->GetHWAccelDeintHQ();

    return true;
}
BOOL
CDefaultControlSiteSecurityPolicy::ClassImplementsCategory(const CLSID &clsid, const CATID &catid, BOOL &bClassExists)
{
    bClassExists = FALSE;

    // Test if there is a CLSID entry. If there isn't then obviously
    // the object doesn't exist and therefore doesn't implement any category.
    // In this situation, the function returns REGDB_E_CLASSNOTREG.

    CRegKey key;
    if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) != ERROR_SUCCESS)
    {
        // Must fail if we can't even open this!
        return FALSE;
    }
    LPOLESTR szCLSID = NULL;
    if (FAILED(StringFromCLSID(clsid, &szCLSID)))
    {
        return FALSE;
    }
    USES_CONVERSION;
    CRegKey keyCLSID;
    LONG lResult = keyCLSID.Open(key, W2CT(szCLSID), KEY_READ);
    CoTaskMemFree(szCLSID);
    if (lResult != ERROR_SUCCESS)
    {
        // Class doesn't exist
        return FALSE;
    }
    keyCLSID.Close();

    // CLSID exists, so try checking what categories it implements
    bClassExists = TRUE;
    CComQIPtr<ICatInformation> spCatInfo;
    HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatInformation, (LPVOID*) &spCatInfo);
    if (spCatInfo == NULL)
    {
        // Must fail if we can't open the category manager
        return FALSE;
    }
    
    // See what categories the class implements
    CComQIPtr<IEnumCATID> spEnumCATID;
    if (FAILED(spCatInfo->EnumImplCategoriesOfClass(clsid, &spEnumCATID)))
    {
        // Can't enumerate classes in category so fail
        return FALSE;
    }

    // Search for matching categories
    BOOL bFound = FALSE;
    CATID catidNext = GUID_NULL;
    while (spEnumCATID->Next(1, &catidNext, NULL) == S_OK)
    {
        if (::IsEqualCATID(catid, catidNext))
        {
            return TRUE;
        }
    }
    return FALSE;
}
Example #21
0
bool CFGFilterLAVAudio::Settings::GetSettings(CComQIPtr<ILAVAudioSettings> pLAVFSettings)
{
    if (!pLAVFSettings) {
        return false;
    }

    bTrayIcon = pLAVFSettings->GetTrayIcon();

    pLAVFSettings->GetDRC(&bDRCEnabled, &iDRCLevel);

    bDTSHDFraming = pLAVFSettings->GetDTSHDFraming();

    bAutoAVSync = pLAVFSettings->GetAutoAVSync();

    bExpandMono = pLAVFSettings->GetExpandMono();

    bExpand61 = pLAVFSettings->GetExpand61();

    bOutputStandardLayout = pLAVFSettings->GetOutputStandardLayout();

    bMixingEnabled = pLAVFSettings->GetMixingEnabled();

    dwMixingLayout = pLAVFSettings->GetMixingLayout();

    dwMixingFlags = pLAVFSettings->GetMixingFlags();

    dwMixingMode = pLAVFSettings->GetMixingMode();

    pLAVFSettings->GetMixingLevels(&dwMixingCenterLevel, &dwMixingSurroundLevel, &dwMixingLFELevel);

    pLAVFSettings->GetAudioDelay(&bAudioDelayEnabled, &iAudioDelay);

    for (int i = 0; i < Bitstream_NB; ++i) {
        bBitstream[i] = pLAVFSettings->GetBitstreamConfig((LAVBitstreamCodec)i);
    }

    for (int i = 0; i < SampleFormat_Bitstream; ++i) {
        bSampleFormats[i] = pLAVFSettings->GetSampleFormat((LAVAudioSampleFormat)i);
    }

    bSampleConvertDither = pLAVFSettings->GetSampleConvertDithering();

    return true;
}
bool	CCustomBindStatusCallBack::_GetFileName()
{
	HRESULT hr = S_OK;
	CComQIPtr<IWinInetHttpInfo> spInfo = m_spBinding;
	if (spInfo) {
		char buff[1024];
		DWORD dwBuffSize = 1024;
		hr = spInfo->QueryInfo(HTTP_QUERY_CONTENT_DISPOSITION, (LPVOID)buff, &dwBuffSize, 0, NULL);
		if (hr == S_OK) {	// CONTENT_DISPOSITIONからファイル名を取得する
			std::string	strbuff = buff;
			std::regex rx("filename\\*=(?: |)UTF-8''(.+)");
			std::regex rx1("filename=(?:\"|)([^\";]+)");
			std::smatch result;
			if (std::regex_search(strbuff, result, rx)) {
				CString strtemp = result.str(1).c_str();
				vector<char> strurldecoded = Misc::urlstr_decode(strtemp);
				m_pDLItem->strFileName = Misc::utf8_to_CString(strurldecoded);	//
			} else if (std::regex_search(strbuff, result, rx1))  {
				std::string strtemp1 = result.str(1);

				int nPerCount = 0;
				std::for_each(strtemp1.begin(), strtemp1.end(), [&nPerCount](char c) {
					if (c == '%')
						++nPerCount;
				});
				vector<char> strUrlDecoded;
				bool	bShiftJis = false;
				if (nPerCount != 0) {
					double dRate = double(strtemp1.length()) / double(nPerCount);
					if (dRate >= 2.4) {	// '%'が多いならURLDecode
						char tempdecoded[INTERNET_MAX_PATH_LENGTH] = "\0";
						DWORD dwBufferLength = INTERNET_MAX_PATH_LENGTH;
						hr = ::UrlUnescapeA(const_cast<LPSTR>(strtemp1.c_str()), tempdecoded, &dwBufferLength, 0);
						if (FAILED(hr)) {
							TRACEIN(_T("UrlUnescapeA 失敗 : Error「%s」\n (%s)"), (LPCTSTR)GetLastErrorString(hr), (LPCTSTR)CString(strtemp1.c_str()));
							::strcpy_s(tempdecoded, strtemp1.c_str());	// 失敗したので元に戻しておく
						} else {
							strtemp1 = tempdecoded;
							for (auto it = strtemp1.begin(); it != strtemp1.end(); ++it) {	// '+'を空白に置換する
								if (*it == '+')
									*it = ' ';
							}
						}
					} 
				} else {
					if (Misc::IsShiftJIS(strtemp1.c_str(), (int)strtemp1.length())) {
						bShiftJis = true;
						m_pDLItem->strFileName = strtemp1.c_str();
						TRACEIN(_T("Shift-JIS文字列でした : %s"), (LPCTSTR)m_pDLItem->strFileName);
					}
				}
				if (bShiftJis == false) {
					strUrlDecoded.resize(strtemp1.length() + 1, '\0');
					::strcpy_s(strUrlDecoded.data(), strtemp1.length() + 1, strtemp1.c_str());
					m_pDLItem->strFileName = Misc::utf8_to_CString(strUrlDecoded);
				}
			} else {
				TRACEIN(_T("CONTENT_DISPOSITIONが見つからない? 内容: %s"), (LPCTSTR)CString(buff));
			}
		}
		if (m_pDLItem->strFileName.IsEmpty()) {
			dwBuffSize = 1024;
			hr = spInfo->QueryOption(INTERNET_OPTION_DATAFILE_NAME, (LPVOID)buff, &dwBuffSize);
			if (hr == S_OK) {
				// ファイル名の部分を取得する([?]部分を除く)
				CString strBaseName = Misc::GetFileBaseName(buff);
				int nIndex = strBaseName.ReverseFind(_T('['));
				if (nIndex != -1) {
					m_pDLItem->strFileName = strBaseName.Left(nIndex);
					CString strExt = Misc::GetFileExt(strBaseName);
					if (strExt.IsEmpty() == FALSE) {
						m_pDLItem->strFileName += _T('.') + strExt;
					}
				} else {
					m_pDLItem->strFileName = strBaseName;
				}
			}
		}
	} else {
		ATLASSERT(m_strDLFolder.IsEmpty() == FALSE);	// これ以外で失敗すると困る
		m_pDLItem->strFileName = Misc::GetFileBaseName(m_pDLItem->strURL);	// [?]がつくかも
		int nQIndex = m_pDLItem->strFileName.ReverseFind(_T('?'));
		if (nQIndex != -1) {
			m_pDLItem->strFileName = m_pDLItem->strFileName.Left(nQIndex);
		}
		if (m_pDLItem->strFileName.IsEmpty())
			m_pDLItem->strFileName = _T("index");	// めったにないと思うけど一応

		if (m_pDLItem->strFileName.Find(_T('%')) != -1) {	// URLデコードする
			//vector<char> filename = Misc::urlstr_decode(m_pDLItem->strFileName);
			m_pDLItem->strFileName = Misc::urlstr_decodeJpn(m_pDLItem->strFileName, 3);//Misc::UnknownToCString(filename);
		}
	}

	// リンク抽出ダイアログより(画像を保存も)
	if (m_strDLFolder.IsEmpty() == FALSE) {
		// 拡張子がなければ Content-Type から拡張子を得る
		if (Misc::GetFileExt(m_pDLItem->strFileName).IsEmpty() && m_pDLItem->strExtention.GetLength() > 0)
			m_pDLItem->strFileName += _T(".") + m_pDLItem->strExtention;

		m_pDLItem->strFilePath = m_strDLFolder + m_pDLItem->strFileName;
		if (::PathFileExists(m_pDLItem->strFilePath)) {
			if (m_dwDLOption & DLO_OVERWRITEPROMPT) {
				CString strMessage;
				strMessage.Format(_T("%s は既に存在します。\n上書きしますか?\n"), (LPCTSTR)m_pDLItem->strFileName);;
				if (MessageBox(NULL, strMessage, _T("確認"), MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL) {
					return false;
				}
			} else if (m_dwDLOption & DLO_USEUNIQUENUMBER) {	// 連番を付ける
				int nCount = 0;
				CString strOriginalFileName = m_pDLItem->strFileName;
				while (TRUE) {
					CString strAppend;
					strAppend.Format(_T("_[%d]"), nCount);
					int nExt = m_pDLItem->strFileName.Find(_T('.'));
					if (nExt != -1) {
						m_pDLItem->strFileName.Insert(nExt, strAppend);
					} else {
						m_pDLItem->strFileName += strAppend;
					}
					m_pDLItem->strFilePath = m_strDLFolder + m_pDLItem->strFileName;
					if (::PathFileExists(m_pDLItem->strFilePath) == FALSE)
						break;

					m_pDLItem->strFileName = strOriginalFileName;
					++nCount;
				}
			}
		}
		m_pDLItem->strIncompleteFilePath = m_pDLItem->strFilePath + _T(".incomplete");
		return true;
	}
	return GetFileName(m_pDLItem);
}
Example #23
0
// Make the volumes in this list read-write using VDS API
void VssClient::MakeVolumesReadWrite(vector<wstring> snapshotVolumes)
{
    FunctionTracer ft(DBG_INFO);

    ft.Trace(DBG_INFO, L"Clearing read-only on %d volumes ... ", snapshotVolumes.size());

    // Get the VDS loader
    CComPtr<IVdsServiceLoader> pLoader;
    CHECK_COM(CoCreateInstance(CLSID_VdsLoader,
        NULL,
        CLSCTX_LOCAL_SERVER,
        __uuidof(IVdsServiceLoader),
        (void **)&pLoader));

    // Get the service interface pointer
    CComPtr<IVdsService> pService;
    CHECK_COM(pLoader->LoadService(NULL, &pService));

    CHECK_COM(pService->WaitForServiceReady());

    vector<wstring> clearedVolumes;

    // Get the unique volume names for the cached snapshot volume names 
    // which might change after the break
    vector<wstring> snapshotVolumeUniqueNames;
    for (unsigned i = 0; i < snapshotVolumes.size( ); i++)
        snapshotVolumeUniqueNames.push_back(GetUniqueVolumeNameForMountPoint(snapshotVolumes[i]));


    // Enumerate the Software providers
    HRESULT hr;
    CComPtr<IEnumVdsObject> pEnumProvider;
    CHECK_COM(pService->QueryProviders(VDS_QUERY_SOFTWARE_PROVIDERS,&pEnumProvider));
    vector< CComPtr<IUnknown> > providers = EnumerateVdsObjects(pEnumProvider);
    for(unsigned iProvider = 0; iProvider < providers.size(); iProvider++)
    {
        // QueryInterface for IVdsSwProvider
        CComQIPtr<IVdsSwProvider> pSwProvider = providers[iProvider];

        ft.Trace(DBG_INFO, L"- Provider %d", iProvider);

        // Enumerate packs for this provider
        CComPtr<IEnumVdsObject> pEnumPack;
        CHECK_COM(pSwProvider->QueryPacks(&pEnumPack));
        vector< CComPtr<IUnknown> > packs = EnumerateVdsObjects(pEnumPack);
        for(unsigned iPack = 0; iPack < packs.size(); iPack++)
        {
            // QueryInterface for IVdsPack
            CComQIPtr<IVdsPack> pPack = packs[iPack];

            ft.Trace(DBG_INFO, L"- Pack %d/%d", iPack, iProvider);

            // Enumerate volumes
            CComPtr<IEnumVdsObject> pEnumVolumes;
            hr = pPack->QueryVolumes(&pEnumVolumes);
            if (FAILED(hr)) {
                if (hr == VDS_E_INVALID_PACK) {
                    hr = S_OK;
                } else ft.Trace( DBG_INFO, L"COM Error: GetProperties for VDS pack failed. hr = 0x%08lx", hr);
                continue;
            }

            vector< CComPtr<IUnknown> > volumes = EnumerateVdsObjects(pEnumVolumes);
            for(unsigned iVol = 0; iVol < volumes.size(); iVol++)
            {
                // QueryInterface for IVdsVolumeMF and IVdsVolume
                CComQIPtr<IVdsVolume> pVolume = volumes[iVol];

                // Get volume properties. Ignore deleted volumes
                VDS_VOLUME_PROP volProp;
                HRESULT innerHR = pVolume->GetProperties(&volProp);
                if (innerHR == VDS_E_OBJECT_DELETED )
                    continue;

                CHECK_COM_ERROR(innerHR, L"pVolume->GetProperties(&volProp)");

                // Skip failed volumes
                if ( (volProp.status == VDS_VS_FAILED) && (volProp.health == VDS_H_FAILED) || !volProp.pwszName)
                    continue;

                // Skip hidden volumes (it fails GetVolumeNameForMountPoint)
                if (volProp.ulFlags & VDS_VF_HIDDEN)
                    continue;

                // Automatically call CoTaskMemFree on this pointer at the end of scope
                CAutoComPointer ptrAutoCleanup(volProp.pwszName);

                // Get the initial device name (normally with the format \\?\GLOBALROOT\Device\HarddiskVolumeXX)
                wstring name = volProp.pwszName;

                // Get the unique volume guid name for this device name.
                wstring uniqueVolumeName = GetUniqueVolumeNameForMountPoint(name);

                ft.Trace(DBG_INFO, L"- Found volume %s [device = %s] in %d/%d", 
                    uniqueVolumeName.c_str(), name.c_str(), iPack, iProvider);

                // Check to see if this is one of our volumes. If not, continue
                if (!FindStringInList(uniqueVolumeName, snapshotVolumeUniqueNames))
                    continue;

                // Clear the read-only flag
                ft.WriteLine(L"- Clearing read-only flag for volume %s [%s] ...", uniqueVolumeName.c_str(), name.c_str());

                CHECK_COM(pVolume->ClearFlags(VDS_VF_READONLY));

                // Force-dismounts the volume 
                // since we want to re-mount the file system as read-write
                CComQIPtr<IVdsVolumeMF> pVolumeMF = pVolume;
                ft.WriteLine(L"- Dismounting volume %s ...", name.c_str());
                CHECK_COM(pVolumeMF->Dismount(TRUE, FALSE));

                clearedVolumes.push_back(uniqueVolumeName);
            }
        }
    }

    // Check that all volumes have been cleared ...
    if (clearedVolumes.size() != snapshotVolumeUniqueNames.size())
    {
        ft.WriteLine(L"WARNING: some volumes were not succesfully converted to read-write!");

        for (unsigned i = 0; i < snapshotVolumeUniqueNames.size(); i++)
            if (!FindStringInList(snapshotVolumeUniqueNames[i], clearedVolumes))
                ft.WriteLine(L"- Volume %s not found on the system. Clearing the read-only flag failed on it.",
                    snapshotVolumeUniqueNames[i].c_str());
    }
}
Example #24
0
STDMETHODIMP CESVGRectElement::Resize(ISVGView* view, double x, double y, double width, double height)
{
	ATLASSERT(0);
#if 0
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	CComPtr<ILHTMLWindow> window;
	view->GetHTMLWindow(&window);

	CComPtr<ILSVGElement> viewportElement;
	rect->get_viewportElement(&viewportElement);

// TODO, this can't be correct
	CComPtr<ILSVGRect> _rect;
	window->svgGetRBBox(viewportElement, &_rect);
	SVGRect viewBox = _rect;

	// x
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double x_pcnt = x*100/viewBox.Width;
			length->set_valueInSpecifiedUnits(x_pcnt);
		}
		else
		{
			length->put_value(x);
		}
	}

	// y
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double y_pcnt = y*100/viewBox.Height;
			length->set_valueInSpecifiedUnits(y_pcnt);
		}
		else
		{
			length->put_value(y);
		}
	}

	// width
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_width(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double width_pcnt = width*100/viewBox.Width;
			length->set_valueInSpecifiedUnits(width_pcnt);
		}
		else
		{
			length->put_value(width);
		}
	}

	// height
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_height(&alength);

		SVGLength length;
		alength->get_baseVal(&length);

		if (length.GetUnitType() == SVG_LENGTHTYPE_PERCENTAGE)
		{
			double height_pcnt = height*100/viewBox.Height;
			length->set_valueInSpecifiedUnits(height_pcnt);
		}
		else
		{
			length->put_value(height);
		}
	}
#endif

	return S_OK;
}
Example #25
0
STDMETHODIMP CESceneDocument::ShowViews(IEFrame* pFrame)
{
#if 0
	CComPtr<ILXFrameworkFrame> frame;
	static_cast<CLXMLEditorApp*>(m_app.p)->m_spAddinSite->GetFrame(&frame);

	CComPtr<ILXFrameworkApp> app;
	frame->GetApp(&app);

	CComPtr<ILXUIMDIFrameElement> frameelement;
	frame->get_Element(&frameelement);

	CComPtr<ILXUIDocument> appdocument;
	app->get_Document(&appdocument);

//	CComPtr<ILXUIElement> mdiclient;
//	frameelement->getMDIClientElement(&mdiclient);

#if 0
	CComPtr<ILDOMElement> mdiclient = GetElementByTagNameNS(frameelement, L"http://www.lerstad.com/2004/lxui", L"mdiclient", FALSE);

	if (mdiclient)
	{
		CComPtr<ILXUIElement> mdichild;
		appdocument->createElementNS(L"http://www.lerstad.com/2004/lxui", L"mdichild", (ILDOMElement**)&mdichild);

		mdiclient->appendChild(mdichild, NULL);
	}
#endif

	CDocumentWorkspace* pWorkspace = &static_cast<CLXMLEditorApp*>(m_app.p)->m_sceneDocumentWorkspace;

	CComQIPtr<ILXAddin> addin = m_app;
	CComPtr<ILXAddinSite> addinSite;
	addin->GetSite(&addinSite);

	CComPtr<IUIManager> uiManager;
	addinSite->GetUIManager((IUnknown**)&uiManager);

	CComQIPtr<IUIMDIFrame> mdiframe = pFrame;

	/*
	CComObject<CEXMLViewGroup>* viewGroup;
	CComObject<CEXMLViewGroup>::CreateInstance(&viewGroup);
	if (viewGroup)
	{
		viewGroup->AddRef();
		viewGroup->SetDocument(this);
		*/

	// Create all views

	// 3DView(s)
		{
			CComPtr<ILDOMElement> e;
			appdocument->createElementNS(NULL, L"content", &e);

			CComPtr<IUnknown> old;
			e->setUserData(L"n", /*viewGroup->*/GetUnknown(), NULL, &old);

			VARIANT vFactory;
			V_VT(&vFactory) = VT_UNKNOWN;
			V_UNKNOWN(&vFactory) = static_cast<CLXMLEditorApp*>(m_app.p)->m_pElementBehaviorFactory;
			V_UNKNOWN(&vFactory)->AddRef();

			long cookie;
			e->addBehavior(L"#factory#scene_3dview", &vFactory, &cookie);

			m_views.Add(e.Detach());
		}

	// SceneGraphDlg
		{
			CComPtr<ILDOMElement> e;
			appdocument->createElementNS(NULL, L"content", &e);

			CComPtr<IUnknown> old;
			e->setUserData(L"n", /*viewGroup->*/GetUnknown(), NULL, &old);

			VARIANT vFactory;
			V_VT(&vFactory) = VT_UNKNOWN;
			V_UNKNOWN(&vFactory) = static_cast<CLXMLEditorApp*>(m_app.p)->m_pElementBehaviorFactory;
			V_UNKNOWN(&vFactory)->AddRef();

			long cookie;
			e->addBehavior(L"#factory#scene_graph", &vFactory, &cookie);

			m_views.Add(e.Detach());
		}

		pWorkspace->Create(pFrame, static_cast<CLXMLEditorApp*>(m_app.p), this/*viewGroup*/);
	//}

//	UpdateTitles();
#endif

	return S_OK;
}
Example #26
0
STDMETHODIMP CESVGRectElement::SetRoundRectShape(/*[in]*/ double x, /*[in]*/ double y, /*[in]*/ double width, /*[in]*/ double height, /*[in]*/ double rx, /*[in]*/ double ry)
{
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	// x
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(x);
	}

	// y
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(y);
	}

	// width
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_width(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(width);
	}

	// height
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_height(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(height);
	}

	// rx
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_rx(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(rx);
	}

	// ry
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_ry(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->put_value(ry);
	}

	return S_OK;
}
Example #27
0
STDMETHODIMP CTabsDlg::handleActivateObjectEvent(IUnknown* object, long* cookie)
{
	CComQIPtr<IPDDocumentView> view = object;
	if (view)
	{
		m_view = static_cast<CComObject<CPDDocumentView>*>(view.p);
		m_view->AddRef();

		*cookie = 1;
	}
	else
	{
		CComQIPtr<IPDTextRange> range = object;
		if (range)
		{
			ATLASSERT(m_range == NULL);	// Only one range can be active at a time

			m_range = range;	// Remember it

			CComPtr<IPDStory> story;
			m_range->GetStory(&story);

			ATLASSERT(m_textPara == NULL);
			story->GetTextPara(m_range, &m_textPara);

			{
				CComPtr<ILDOMRange> domrange;
				m_range->GetDOMRange(&domrange);

				CComPtr<ILDOMNode> startContainer;
				long startOffset;
				domrange->get_startContainer(&startContainer);
				domrange->get_startOffset(&startOffset);

				CComPtr<IPDObjectText> objectText;
				story->GetObjectTextFromRangePosition(startContainer, startOffset, &objectText);
				if (objectText)
				{
					CComQIPtr<IPDTextFrameOptions> textFrameOptions = objectText;

					double columnsWidth;
					textFrameOptions->get_columnsWidth(&columnsWidth);

					/*
					CComQIPtr<IPDObjectLocatable> locatable = objectText;

					RectD bounds;
					locatable->get_bounds(&bounds);
					*/

					m_tabsCtl->put_pageWidth(columnsWidth/*bounds.Width*/);
				}
			}

			m_tabsCtl->put_textPara(m_textPara);
			m_tabsCtl->put_Enabled(TRUE);

			*cookie = 1;
		}
	}

	if (m_hWnd)
	{
		Invalidate();
		OnSize();
	}

	return S_OK;
}
Example #28
0
// IESVGSimpleShapeElement
STDMETHODIMP CESVGRectElement::DrawPathSegList(/*[in]*/ ILSVGPathElement* pathElement, /*[in]*/ ILSVGPathSegList* seglist)
{
	CComQIPtr<ILSVGRectElement> rect = m_domElement;

	double x, y, width, height, rx, ry;

	// x
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_x(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&x);
	}

	// y
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_y(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&y);
	}

	// width
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_width(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&width);
	}

	// height
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_height(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&height);
	}

	// rx
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_rx(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&rx);
	}

	// ry
	{
		CComQIPtr<ILSVGAnimatedLength> alength;
		rect->get_ry(&alength);
		CComQIPtr<ILSVGLength> length;
		alength->get_baseVal(&length);
		length->get_value(&ry);
	}

	seglist->AddRoundRect(x, y, width, height, rx, ry);

	return S_OK;
}
Example #29
0
// Creates an ATSC Tune Request
HRESULT
CBDAFilterGraph::CreateATSCTuneRequest(
        LONG lPhysicalChannel,
        LONG lMajorChannel, 
        LONG lMinorChannel,
        IATSCChannelTuneRequest**   pTuneRequest
    )
{
    HRESULT hr = S_OK;

    if (pTuneRequest == NULL)
    {
        ErrorMessageBox (TEXT("Invalid pointer\n"));
        return E_POINTER;
    }

    // Making sure we have a valid tuning space
    if (m_pITuningSpace == NULL)
    {
        ErrorMessageBox(TEXT("Tuning Space is NULL\n"));
        return E_FAIL;
    }

    //  Create an instance of the ATSC tuning space
    CComQIPtr <IATSCTuningSpace> pATSCTuningSpace (m_pITuningSpace);
    if (!pATSCTuningSpace)
    {
        ErrorMessageBox(TEXT("Cannot QI for an IATSCTuningSpace\n"));
        return E_FAIL;
    }

    //  Create an empty tune request.
    CComPtr <ITuneRequest> pNewTuneRequest;
    hr = pATSCTuningSpace->CreateTuneRequest(&pNewTuneRequest);

    if (FAILED (hr))
    {
        ErrorMessageBox(TEXT("CreateTuneRequest: Can't create tune request.\n"));
        return hr;
    }

    //query for an IATSCChannelTuneRequest interface pointer
    CComQIPtr <IATSCChannelTuneRequest> pATSCTuneRequest (pNewTuneRequest);
    if (!pATSCTuneRequest)
    {
        ErrorMessageBox(TEXT("CreateATSCTuneRequest: Can't QI for IATSCChannelTuneRequest.\n"));
        return E_FAIL;
    }

    //  Set the initial major and minor channels
    hr = pATSCTuneRequest->put_Channel(lMajorChannel);
    if(FAILED(hr))
    {
        ErrorMessageBox(TEXT("put_Channel failed\n"));
        return hr;
    }

    hr = pATSCTuneRequest->put_MinorChannel(lMinorChannel);
    if(FAILED(hr))
    {
        ErrorMessageBox(TEXT("put_MinorChannel failed\n"));
        return hr;
    }

    CComPtr <IATSCLocator> pATSCLocator;
    hr = pATSCLocator.CoCreateInstance (CLSID_ATSCLocator);
    if (FAILED( hr))
    {
        ErrorMessageBox(TEXT("Cannot create the ATSC locator failed\n"));
        return hr;
    }

    //  Set the initial physical channel.
    //
    hr = pATSCLocator->put_PhysicalChannel (lPhysicalChannel);
    if (FAILED( hr))
    {
        ErrorMessageBox(TEXT("Cannot put the physical channel\n"));
        return hr;
    }

    hr = pATSCTuneRequest->put_Locator (pATSCLocator);
    if (FAILED (hr))
    {
        ErrorMessageBox(TEXT("Cannot put the locator\n"));
        return hr;
    }

    hr = pATSCTuneRequest.QueryInterface (pTuneRequest);

    return hr;
}
CComQIPtr<IHTMLElement> WebHandler::GetElement(
    CComQIPtr<IHTMLElementCollection> spElementCollection,
    const std::wstring& attrName, const std::wstring& attrValue,
    const std::wstring& textValue)
{
    long nItemCount = 0;				//取得表单数目
    HRESULT hr = spElementCollection->get_length(&nItemCount);
    if (FAILED(hr))
        return CComQIPtr<IHTMLElement>();

    for (long i = 0; i < nItemCount; i++)
    {
        CComDispatchDriver spDisp;	//取得第 j 项表单域
        hr = spElementCollection->item(CComVariant(i), CComVariant(), &spDisp);
        if (FAILED(hr))
            continue;

        CComQIPtr<IHTMLElement> spElement = spDisp;
        if (!spElement)
            break;

        bool bFind = false;
        std::wstring compareStr;

        if (attrName == L"class")
        {
            CComBSTR className;
            hr = spElement->get_className(&className);
            if (!FAILED(hr) && className)
            {
                compareStr = (LPCTSTR)className;
            }
         }   
         else
         {
             CComVariant vtAttr;
             hr = spDisp.GetPropertyByName(attrName.c_str(), &vtAttr);
             if (!FAILED(hr) && (vtAttr.vt == VT_BSTR) && (NULL != vtAttr.bstrVal))
             {
                 compareStr = (LPCTSTR)vtAttr.bstrVal;
             }
         }

        if (!compareStr.empty() && (compareStr.compare(attrValue) == 0))
        {
            if (textValue.empty())
            {
                bFind = true;
            }
            else
            {
                CComBSTR innerText;
                hr = spElement->get_innerText(&innerText);
                if (!FAILED(hr) && innerText)
                {
                    if ((textValue.compare((LPCTSTR)innerText) == 0))
                    {
                        bFind = true;
                    }
                }
            }
        }
        else
        {
            continue;
        }

        if (bFind)
        {
            return spElement;
        }
    }

    return CComQIPtr<IHTMLElement>();
}