예제 #1
1
/* void setProperty (in string propertyName, in string propertyValue); */
NS_IMETHODIMP
nsScriptablePeer::SetProperty(const char *propertyName, nsIVariant *propertyValue)
{
    HRESULT hr;
    DISPID dispid;
    IDispatchPtr disp;
    if (FAILED(GetIDispatch(&disp)))
    {
        return NPERR_GENERIC_ERROR; 
    }
    USES_CONVERSION;
    OLECHAR* szMember = A2OLE(propertyName);
    hr = disp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &dispid);
    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR;
    }

    _variant_t v;
    ConvertVariants(propertyValue, &v);
    
    DISPID dispIdPut = DISPID_PROPERTYPUT;
    DISPPARAMS functionArgs;
    _variant_t vResult;
    
    functionArgs.rgdispidNamedArgs = &dispIdPut;
    functionArgs.rgvarg = &v;
    functionArgs.cArgs = 1;
    functionArgs.cNamedArgs = 1;

    hr = disp->Invoke(
        dispid,
        IID_NULL,
        LOCALE_USER_DEFAULT,
        DISPATCH_PROPERTYPUT,
        &functionArgs, &vResult, NULL, NULL);
    
    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR;
    }

    return NS_OK;
}
예제 #2
1
NS_IMETHODIMP 
nsScriptablePeer::GetProperty(const char *propertyName, nsIVariant **_retval)
{
    HRESULT hr;
    DISPID dispid;
    IDispatchPtr disp;
    if (FAILED(GetIDispatch(&disp)))
    {
        return NPERR_GENERIC_ERROR; 
    }
    USES_CONVERSION;
    OLECHAR* szMember = A2OLE(propertyName);
    hr = disp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &dispid);
    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR;
    }

    _variant_t vResult;
    
    DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
    hr = disp->Invoke(
        dispid,
        IID_NULL,
        LOCALE_USER_DEFAULT,
        DISPATCH_PROPERTYGET,
        &dispparamsNoArgs, &vResult, NULL, NULL);
    
    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR;
    }

    nsCOMPtr<nsIVariant> propertyValue;
    ConvertVariants(&vResult, getter_AddRefs(propertyValue));
    *_retval = propertyValue;
    NS_IF_ADDREF(*_retval);

    return NS_OK;
}
예제 #3
1
NS_IMETHODIMP
nsScriptablePeer::InternalInvoke(const char *aMethod, unsigned int aNumArgs, nsIVariant *aArgs[])
{
    HRESULT hr;
    DISPID dispid;

    IDispatchPtr disp;
    if (FAILED(GetIDispatch(&disp)))
    {
        return NPERR_GENERIC_ERROR; 
    }

    USES_CONVERSION;
    OLECHAR* szMember = A2OLE(aMethod);
    hr = disp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &dispid);
    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR; 
    }
    
    _variant_t *pArgs = NULL;
    if (aNumArgs > 0)
    {
        pArgs = new _variant_t[aNumArgs];
        if (pArgs == NULL)
        {
            return NS_ERROR_OUT_OF_MEMORY;
        }
        for (unsigned int i = 0; i < aNumArgs; i++)
        {
            hr = ConvertVariants(aArgs[i], &pArgs[i]);
            if (FAILED(hr))
            {
                delete []pArgs;
                return NS_ERROR_INVALID_ARG;
            }
        }
    }

    DISPPARAMS dispparams = {NULL, NULL, 0, 0};
    _variant_t vResult;

    dispparams.cArgs = aNumArgs;
    dispparams.rgvarg = pArgs;

    hr = disp->Invoke(
        dispid,
        IID_NULL,
        LOCALE_USER_DEFAULT,
        DISPATCH_METHOD,
        &dispparams, &vResult, NULL, NULL);

    if (pArgs)
    {
        delete []pArgs;
    }

    if (FAILED(hr))
    { 
        return NPERR_GENERIC_ERROR; 
    }

    return NS_OK;
}
예제 #4
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
HRESULT CIMacroScriptImp :: DestroyStorage()
{

CEnumMacroScripts *pEn = NULL;
HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr;	
	
CObArray *pA = pEn -> GetArray ();	
	pEn -> Release();

    if (0 != ULONG(pA -> GetSize())) return hr; 

	USES_CONVERSION;

LPSTORAGE pIStorage = NULL;
	
	if (NULL == DEX_GetProjectStorage (pIStorage)) {
		if (m_pIRootStorage) {
			hr = m_pIRootStorage -> DestroyElement(A2OLE("MacroScripts"));
			if (FAILED(hr) && GetScode(hr) != STG_E_FILENOTFOUND) return hr;

			hr = m_pIRootStorage -> Commit(STGC_DEFAULT);
			if (FAILED(hr)) return hr;
		}
	}
	else {
		hr = m_pMacroScripts -> GetIPersistStorage() -> HandsOffStorage();
		if (FAILED(hr)) { pIStorage -> Release(); return hr; }

		hr = pIStorage -> DestroyElement(A2OLE("MacroScripts"));
		pIStorage -> Release();
	}

return hr;
}
예제 #5
0
void PropertySequence_cmd_AddAction (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
	BASIC_OP_TRACE(PropertySequence_cmd_AddAction);

WPropertyActionSequence Seq ((IPropertyActionSequence *)ebGetObject (lpArgs, 1));
ebHSUB hStr = ebGetString (lpArgs, 2);

	if (NULL != hStr) {
		USES_CONVERSION;

	LPSTR lpstr = ebLockString (hThread, hStr);

		BASIC_OP_TRACE2(lpstr);

	CLSID clsID;
	HRESULT hr = CLSIDFromString (A2OLE(lpstr), &clsID);

		if (FAILED(hr))
			hr = CLSIDFromProgID (A2OLE(lpstr), &clsID);

		if (SUCCEEDED(hr)) {
		CComVariant v2 (MakeVARIANT (hThread, iNumArgs, lpArgs, 3));

			if (VT_ERROR == V_VT(&v2)) {
			// nur ein Parameter gegeben
			CALPCLSID cal;
			const CLSID *pClsID = &clsID;

				memset(&cal, '\0', sizeof(CALPCLSID));
				cal.cElems = 1;
				cal.ppElems = &pClsID;
				Seq -> AddActionsByCLSID (&cal);
			
			} else {
			// 2. Parameter auswerten
				try {
				WPropertyAction WAct (clsID);	// throws hr

					if (FAILED(InitFromData (WAct, v2))) {
					// kann nicht mit Daten initialisiert werden, also normales Init
					WPersistStreamInit Init (WAct);			// throws hr

						THROW_FAILED_HRESULT(Init -> InitNew());
					}

					THROW_FAILED_HRESULT(Seq -> AddAction (WAct));

				} catch (_com_error&) {
					;
				}
			}
		}
		ebUnlockString (hThread, hStr);
	}
}
예제 #6
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
HRESULT MakeRootStorage(LPSTORAGE *ppIStorage, LPCSTR pPathName)
{           
HRESULT hr = NOERROR;

DWORD dwMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE | 
				STGM_TRANSACTED ;

char *pNameToUse = new char [_MAX_PATH];

LPSTORAGE pIStorage = *ppIStorage;
	
	if (NULL == pNameToUse || NULL == pPathName)
		return ResultFromScode(E_FAIL);
	
	// alte ProjektStruktur, eigenes DocFile erzeugen/öffnen  
	// erstellt Pfadnamen
	hr = MakeFileName (pPathName, pNameToUse, "str");
	if (FAILED(hr))			
		return hr;
		
// Funktionen machen Addref(), Release() im Destruktor (Memberpointer Rootstorage)
	USES_CONVERSION;
	hr = StgOpenStorage (A2OLE(pNameToUse), NULL, dwMode, 0, 0, &pIStorage);
	if (FAILED(hr)) {
		if (GetScode(hr) == STG_E_FILENOTFOUND) {
		// neu anlegen
			dwMode |= STGM_CREATE;

			hr = StgCreateDocfile (A2OLE(pNameToUse), dwMode, 0, &pIStorage);
			delete (pNameToUse);
			if (FAILED(hr)) return hr;
				
			// GUID reinschreiben (Kontrollmöglichkeit)
			hr = WriteClassStg (pIStorage, CLSID_ScriptContainer);				
			if (FAILED(hr)) {
				pIStorage -> Release();
				return hr;
		    }
		}
		else {
		    delete (pNameToUse);
		    return hr;
		}
	} else delete (pNameToUse);

	hr = TestclsID (pIStorage, CLSID_ScriptContainer);
	if (FAILED(hr)) { pIStorage -> Release(); return hr; }

	*ppIStorage = pIStorage;

	return NOERROR;
}
예제 #7
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
HRESULT MakeSubStorage(LPSTORAGE pIRootStorage, 
						LPSTORAGE *ppISubStorage,
						const CString &strStorName, 
						bool &fNew, bool fDirect, CLSID clsID)
{       
LPSTORAGE pIStorage;
HRESULT hr;                                                     

DWORD dw = 0;

DWORD dwMode =	STGM_READWRITE | 
				STGM_SHARE_EXCLUSIVE ;	

	if (fDirect) dwMode = dwMode | STGM_DIRECT;
	else dwMode = dwMode | STGM_TRANSACTED;

	if (NULL == pIRootStorage) 	                   
		return ResultFromScode(STG_E_INVALIDPOINTER);

	USES_CONVERSION;
	hr = pIRootStorage -> OpenStorage (	A2OLE(strStorName), 
										NULL, dwMode, NULL,
										0, &pIStorage);
	if (FAILED(hr)) {
		if (STG_E_FILENOTFOUND == GetScode(hr)) {
			hr = pIRootStorage -> CreateStorage (	A2OLE(strStorName), 
													dwMode, 0, 0, &pIStorage);
			if (SUCCEEDED(hr)) {
				hr = WriteClassStg (pIStorage, clsID);
				fNew = true;
			}
			else {
				*ppISubStorage = NULL;
				return hr;
			}
		}
		else {
			*ppISubStorage = NULL;
			return hr;
		}
	}
						
	hr = TestclsID (pIStorage, clsID);
	if (FAILED(hr)) { pIStorage -> Release(); return hr; }
	
	*ppISubStorage = pIStorage;
	
return NOERROR;
} 
예제 #8
0
static HRESULT SavePropSeq (
	LPCSTR pcDesc, IPropertyActionSequence *pISeq, IStorage *pIStg)
{
HRESULT hr = E_FAIL;
WStorage IStg (pIStg);

	USES_CONVERSION;
	if (NULL == pIStg) {	// SubStorage anlegen, da es noch nicht existiert
	WStorage IRootStg;

		if (!DEX_GetProjectStorage(*IRootStg.ppv()))
			return E_FAIL;

		hr = IRootStg -> CreateStorage (A2OLE(g_cbPropertyChoices), 
						STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, 
						0L, 0L, IStg.ppi());
		if (FAILED(hr)) return hr;

		hr = WriteClassStg (IStg, CLSID_PropertyChoice);
		if (FAILED(hr)) return hr;
	}

	try {
	WStream IStm;
	WPersistStream IPersistStm (pISeq);		// throws hr
	string strName = MakeStreamName(pcDesc);

	// Stream erzeugen
		hr = IStg -> CreateStream (A2OLE(strName.c_str()), 
						STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE, 
						0L, 0L, IStm.ppi());
		if (FAILED(hr)) _com_issue_error(hr);

		hr = OleSaveToStream (IPersistStm, IStm);	// und wegschreiben
		if (FAILED(hr)) _com_issue_error(hr);

		hr = IStm -> Commit (STGC_DEFAULT);
		if (FAILED(hr)) _com_issue_error(hr);

	} catch (_com_error& hr) {
		return _COM_ERROR(hr);
	}

	hr = IStg -> Commit (STGC_DEFAULT);
	if (SUCCEEDED(hr))
		DEX_SetDirtyGeoDB(true);

return hr;
}
예제 #9
0
///////////////////////////////////////////////////////////////////////////////
// component categories verwalten
HRESULT CreateComponentCategory (CATID catid, LPCSTR pcCatDescription)
{
ICatRegister *pcr = NULL;
HRESULT hr = S_OK;

	hr = CoCreateInstance (CLSID_StdComponentCategoriesMgr, 
			NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (LPVOID *)&pcr);
	if (FAILED(hr))	return hr;

// Make sure the HKCR\Component Categories\{..catid...}
// key is registered
CATEGORYINFO catinfo;

	catinfo.catid = catid;
	catinfo.lcid = GetUserDefaultLCID();

// Make sure the provided description is not too long.
// Only copy the first 127 characters if it is
	USES_CONVERSION;

WCHAR *catDescription = A2OLE(pcCatDescription);
int len = wcslen(catDescription);

	if (len > 127) len = 127;
    wcsncpy (catinfo.szDescription, catDescription, len);

// Make sure the description is null terminated
	catinfo.szDescription[len] = '\0';
    hr = pcr -> RegisterCategories (1, &catinfo);
	pcr -> Release();
	return hr;
}
예제 #10
0
STDMETHODIMP CComDigiDocLib::getSupportedFormats(VARIANT *ret)
{
  const char** pArr = ::getSupportedFormats();
  unsigned int nElems = 0;
  SAFEARRAY* pSArr;
  BSTR HUGEP* pData;

  // detect number of elements
  for(; *pArr != NULL; pArr++, nElems++);

  // initialize SAFEARRAY
  pSArr = SafeArrayCreateVector(VT_BSTR, 0, nElems);
  if (pSArr == NULL) {
    return E_OUTOFMEMORY;
  }

  // init variant
  V_ARRAY(ret) = pSArr;
  V_VT(ret) = (VT_ARRAY | VT_BSTR);

  // copy data to variant
  pArr = ::getSupportedFormats();
  SafeArrayAccessData(pSArr, (void HUGEP**)&pData);
  long lArr[1];
  USES_CONVERSION;
  ddocDebug(1, "getSupportedFormats", "num formats: %d", nElems);
  for(lArr[0] = 0; lArr[0] < (long)nElems; lArr[0]++) {
	  ddocDebug(1, "getSupportedFormats", "format: %d - %s", lArr[0], pArr[lArr[0]]);
    pData[lArr[0]] = SysAllocString(A2OLE(pArr[lArr[0]]));
  }
  SafeArrayUnaccessData(pSArr);

	return S_OK;
}
예제 #11
0
HRESULT CBlobService::MakeTextGeometryBlob (
	unsigned long ulCnt, double_i itx, double_i ity, POINTBASE *pNormal, void *pData, BYTE *pBlob)
{
#if defined(_DEBUG)
BYTE *pBlobOrigin = pBlob;
unsigned long ulSize = 0;

	_ASSERTE(1 == ulCnt);
	GetTextGeometrySize (ulCnt, pData, &ulSize);
	_ASSERTE(!IsBadWritePtr(pBlob, ulSize));
#endif // _DEBUG
TEXTBLOBDATA *pTBD = (TEXTBLOBDATA *)pData;
size_t uiTextSize = (pTBD -> strText.size() + 1) * sizeof(wchar_t);

	USES_CONVERSION;
	AssignAndAdvance(pBlob, CLSID_TRiASCSTextPointGeometry);

	((POINTBASE *)pBlob) -> X = *itx;
	((POINTBASE *)pBlob) -> Y = *ity;
	((POINTBASE *)pBlob) -> Z = 0.0;
	pBlob += sizeof(POINTBASE);

	AssignAndAdvance(pBlob, pTBD -> dRotation);
	AssignAndAdvance(pBlob, *pNormal);
	AssignAndAdvance(pBlob, pTBD -> lFlags);
	AssignAndAdvance(pBlob, uiTextSize);
	AssignAndAdvance(pBlob, A2OLE(pTBD -> strText.c_str()), uiTextSize);

	_ASSERTE(pBlob-pBlobOrigin == ulSize);
	return S_OK;
}
예제 #12
0
STDMETHODIMP CPigMissionParams::get_CoreName(BSTR* bstrCoreName)
{
  XLock lock(this);
  USES_CONVERSION;
  CLEAROUT(bstrCoreName, A2OLE(m_mp.szIGCStaticFile));
  return S_OK;
}
예제 #13
0
STDMETHODIMP CToolBarButton::GetDescription (int, BSTR *pbstrDesc)
{
	if (NULL == (IUnknown *)m_EvtSink) return E_UNEXPECTED;

// nur einmal gleichzeitig barbeiten
CInterlockedSync Sync (&m_lMutex);

	if (!Sync.IsFirst()) return E_FAIL;

// durchzuführende Aktion
ebPARAM Pars[1];
LPVOID cbParam[1];
LPSTR pStr = NULL;

	Pars[0].wType = TYP_STRING; //|TYP_MODSPARM;
	Pars[0].szExtType[0] = '\0';
	cbParam[0] = &pStr;

BSPARAM bs = { Pars, cbParam };
string str = m_strName + TEXT("_Select");
HRESULT hr = m_EvtSink -> FireEvent (str.c_str(), 0, &bs);

	USES_CONVERSION;
	if (S_OK == hr) {
		if (NULL != pStr) {
			*pbstrDesc = SysAllocString (A2OLE(pStr));
			CoTaskMemFree (pStr);
			if (NULL == *pbstrDesc)
				hr = E_OUTOFMEMORY;
		} else
			hr = E_OUTOFMEMORY;
	}

	if (S_OK != hr)	{	// vordefinierten Text liefern
		if (NPOS != m_strDesc.find('\n'))
			*pbstrDesc = SysAllocString (A2OLE(m_strDesc.c_str()));
		else {
		string str = m_strDesc + "\n" + m_strDesc;

			*pbstrDesc = SysAllocString (A2OLE(str.c_str()));
		}
		if (NULL != *pbstrDesc)
			hr = NOERROR;
	}

return hr;
}
예제 #14
0
HRESULT CCoordTransService::FindCTF (void)
{
	USES_CONVERSION;

char cbCTFName[_MAX_PATH];
CComBSTR bstr (GetProperty (m_Props, g_cbCoordTransform, A2OLE(g_cbDefault)));

	strcpy (cbCTFName, OLE2A(bstr));
	if (!stricmp (cbCTFName, g_cbDefault)) 
		m_fIsDefault = true;

// CTFService's über CATID enumerieren, CTFService wiederfinden
	try {
	WEnumGUID EnumGuids;		// Enumerator der CTFService-Objekte
	WCatInformation CatInfo (CLSID_StdComponentCategoriesMgr);	// throws hr
	GUID guidImpl[1]; 

		guidImpl[0] = CATID_TRiASCoordsystem;
		THROW_FAILED_HRESULT(CatInfo -> EnumClassesOfCategories (1, guidImpl, 0, NULL, EnumGuids.ppi()));

	GUID guid;
	LPOLESTR lpGuid = NULL;
	bool fFoundGuid = false;

		for (EnumGuids -> Reset(); S_OK == EnumGuids -> Next (1, &guid, NULL); /**/)
		{
			THROW_FAILED_HRESULT(StringFromCLSID (guid, &lpGuid));

		CClassesRoot regClsID (OLE2A(lpGuid));
		char cbBuffer[_MAX_PATH];
		LONG lSize = sizeof(cbBuffer);

			if (NULL != lpGuid) {
				CoTaskMemFree (lpGuid);
				lpGuid = NULL;
			}
			if (regClsID.isValid() && regClsID.GetSZ (g_cbOldName, cbBuffer, lSize))
			{
				if (!stricmp (cbBuffer, cbCTFName)) {
					fFoundGuid = true;
					m_strCTF = cbBuffer;
					break;
				}
			}

		}
		if (!fFoundGuid) {
			TX_ASSERT(fFoundGuid);
			return E_FAIL;					// snh!
		}

	} catch (_com_error &e) {
		TX_ASSERT(S_OK == _COM_ERROR(e));
		return _COM_ERROR(e);
	}
	return S_OK;
}
예제 #15
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
HRESULT CIMacroScriptImp :: OpenOrCreateStream(const CString & strMacroName, LPSTREAM *ppIStream)
{
LPSTORAGE pISubStorage = NULL;

HRESULT	hr = m_pMacroScripts -> GetIPersistStorage() -> GetStorage (&pISubStorage);
	if (FAILED(hr)) return hr;

DWORD dwMode = STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE; 
// vorhandenen Stream öffnen
	USES_CONVERSION;
	hr = pISubStorage -> OpenStream (A2OLE(strMacroName), 0, dwMode, 0, ppIStream);
	if (FAILED(hr)) {
		hr = pISubStorage -> CreateStream (A2OLE(strMacroName), dwMode, 0, 0, ppIStream);
	}

	pISubStorage -> Release();

return hr;
}
예제 #16
0
STDMETHODIMP CToolBarButton::get_Name (BSTR *pbstrName)
{
	USES_CONVERSION;
	if (NULL == pbstrName)	return E_POINTER;
	
	*pbstrName = SysAllocString (A2OLE(m_strName.c_str()));
	if (NULL == *pbstrName)	return E_OUTOFMEMORY;
	
	return NOERROR;
}
예제 #17
0
STDMETHODIMP CToolBarButton::get_HelpText (BSTR *pbstrHelpText)
{
	USES_CONVERSION;
	if (NULL == pbstrHelpText)	return E_POINTER;
	
	*pbstrHelpText = SysAllocString (A2OLE(m_strDesc.c_str()));
	if (NULL == *pbstrHelpText)	return E_OUTOFMEMORY;
	
	return NOERROR;
}
예제 #18
0
// Erzeugen und initialisieren eines PropertyActionChoice-Objektes, welches die
// vorgegebenen PropertyActions enthält
HRESULT InitPropertyActionChoice (
	LPCSTR pcDesc, CALPCLSID *pcaClsIds, IPropertyActionSequence **ppISeq)
{
	USES_CONVERSION;

	if (NULL == ppISeq) return E_POINTER;
	*ppISeq = NULL;		// für alle Fälle

WPropertyActionSequence ISeq;
HRESULT hr = E_FAIL;
WStorage IStg;

	GetSubPropSeqStorage (IStg.ppi());
	if (NULL != (IStorage *)IStg) {	// evtl. gespeicherten Status laden
	WStream IStm;
	string strName = MakeStreamName(pcDesc);

	// Stream erzeugen
		hr = IStg -> OpenStream (A2OLE(strName.c_str()), NULL, 
						STGM_READ|STGM_SHARE_EXCLUSIVE, 0L, IStm.ppi());

		if (SUCCEEDED(hr)) {
			hr = OleLoadFromStream (IStm, IID_IPropertyActionSequence, ISeq.ppv());
			if (SUCCEEDED(hr)) {
				*ppISeq = ISeq.detach();
				return S_OK;
			}
		}
	}
	
// wenn Status nicht geladen werden kann, dann neu initialisieren
	try {
	// Objekt erzeugen
		ISeq = WPropertyActionSequence (CLSID_PropertyChoice);		// throws hr
		ISeq -> SetDescription (pcDesc);

	// Rücksetzen der AktionsFolge
	WPersistStreamInit Init = ISeq;		// throws hr

		hr = Init -> InitNew();
		if (FAILED(hr)) _com_issue_error(hr);
	
	} catch (_com_error& hr) {
		return _COM_ERROR(hr);
	}

// hinzufügen der einzelnen Aktionen
	hr = ISeq -> AddActionsByCLSID (pcaClsIds);
	if (FAILED(hr)) return hr;

	*ppISeq = ISeq.detach();

return NOERROR;
}
예제 #19
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
STDMETHODIMP CIMacroScriptImp :: DelScript (LPCSTR pcName)
{                             
	ASSERT(pcName);

CMacro *pM = NULL;		
CString strMacroName = pcName;
CEnumMacroScripts *pEn = NULL;

HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr; 		

// alten schon geöffneten Stream schliessen,
// Objekte aus dem Enumerator loeschen
bool fNew = false;
	hr = pEn -> DelItem (strMacroName, &fNew);
	if (FAILED(hr)) {
		pEn -> Release(); return hr;
	}
	
bool fNotCommit = false;

	//  für COMMIT(), wenigstens einen mit Commit() finden	
	while (S_OK == pEn -> Next (1, &pM, NULL) && fNotCommit == false) {
			fNotCommit = pM -> GetIMacros() -> GetNotCommit();
			if (fNotCommit) break;
	}

	pEn -> Release();

// bei neuem Macro UND kein anderer gespeicherter vorhanden, Commit() nicht nötig
// Commit wurde gesetzt, als der jetzt zu löschende gespeichert wurde

	if (fNew == true && fNotCommit == false) 
		m_fNotCommit = false;			
	else {
		// Löschen beendet, aber noch COMMIT()
		DEX_SetDirtyGeoDB(1);
		m_fNotCommit = true;
	}

LPSTORAGE pIStorage;
	hr = m_pMacroScripts -> GetIPersistStorage() -> GetStorage(&pIStorage);
	if (FAILED(hr)) return hr;	

// Stream vom Storage loeschen, wenn vorhanden
	USES_CONVERSION;
	hr = pIStorage -> DestroyElement (A2OLE(strMacroName));
	pIStorage -> Release();
	if (FAILED(hr) && GetScode(hr) != STG_E_FILENOTFOUND)
		return hr;

return NOERROR;
}
예제 #20
0
STDMETHODIMP CComDigiDocLib::unicode2utf8(BSTR szUnicode, BSTR* pVal) 
{
	USES_CONVERSION;
	char *psBuf = NULL;
	int   iLen;
	int   iErr;
    if(szUnicode && *szUnicode) {
	_bstr_t bsTemp(szUnicode);

	
	wchar_t *pswVal = (wchar_t *)bsTemp;
	iErr = ::unicode2utf8((char *)pswVal, &psBuf,&iLen);
	if (!iErr) {
		*pVal = SysAllocString(A2OLE(psBuf));
	} else {
		*pVal = SysAllocString(A2OLE(""));
	}
	if (psBuf != NULL) 
		freeLibMem(psBuf);
	}
	return S_OK;
}
예제 #21
0
void PropertySequence_cmd_Save (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
	BASIC_OP_TRACE(PropertySequence_cmd_Save);

	if (NULL != lpArgs[0]) // als Funktion gerufen
		ebSetBool (lpArgs, 0, 0);		// für alle Fälle

WPropertyActionSequence ISeq ((IPropertyActionSequence *)ebGetObject (lpArgs, 1));
HRESULT hr = E_FAIL;

// Versuchen aus SubStream einzulesen
	try {
	// SubStorage eröffnen/erzeugen
	WStorage IStg;

		hr = GetSubPropSeqStorage (IStg.ppi(), true);
		if (FAILED(hr)) _com_issue_error(hr);

	// Description geben lassen
	char cbBuffer[_MAX_PATH];

		hr = ISeq -> GetDescription (cbBuffer, _MAX_PATH, NULL);
		if (FAILED(hr)) _com_issue_error(hr);

	WStream IStm;
	WPersistStream IPersistStm (ISeq);		// throw hr
	string strName = MakeStreamName(cbBuffer);

	// Stream erzeugen
		USES_CONVERSION;
		hr = IStg -> CreateStream (A2OLE(strName.c_str()), 
						STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE, 
						0L, 0L, IStm.ppi());
		if (FAILED(hr)) _com_issue_error(hr);
		
		hr = OleSaveToStream (IPersistStm, IStm);
		if (FAILED(hr)) _com_issue_error(hr);
			
		hr = IStg -> Commit (STGC_DEFAULT);
		if (FAILED(hr)) _com_issue_error(hr);
		
		DEX_SetDirtyGeoDB(true);

	} catch (...) {
		TRACE("Couldn't OleSaveToStream for IPropertyActionSequence\n");
		return;			// Fehler
	}

	if (NULL != lpArgs[0]) // als Funktion gerufen
		ebSetBool (lpArgs, 0, -1);
}
예제 #22
0
STDMETHODIMP CComCertificate::get_nPropSerialNumber(BSTR *pVal)
{
  char buf[X509_NAME_BUF_LEN];
	//AA-Viimase minuti jama
	::ReadCertSerialNumber(buf,sizeof(buf),m_pX509);
    USES_CONVERSION;
	*pVal = SysAllocString(A2OLE(buf));
	//*pVal = atol(buf);
	//if (::getCertSerialNumber((void*)m_pX509, (int*)pVal) != 0) {
    //*pVal = 0;
    //}

	return S_OK;
}
예제 #23
0
STDMETHODIMP CComDigiDocLib::getCertSerialNumber(long hCert, BSTR *pCopyTo, long *nRetResult)
{
  char buf[X509_NAME_BUF_LEN];
  //AA-Viimase minuti jama
  *nRetResult = ::ReadCertSerialNumber(buf,sizeof(buf),(X509 *)hCert);
  USES_CONVERSION;
  if (*nRetResult == 0)
    *pCopyTo = SysAllocString(A2OLE(buf));
  
//	*nRetResult = ::getCertSerialNumber((void*)hCert, &nTmp);
//  if (*nRetResult == 0)
//    *nCopyTo = nTmp;

	return S_OK;
}
예제 #24
0
// Öffnen des PropertySequenceSubStorages
static HRESULT GetSubPropSeqStorage (IStorage **ppIStg)
{
	if (NULL == ppIStg) return E_POINTER;

WStorage IRootStg;

	if (!DEX_GetProjectStorage(*IRootStg.ppv()))
		return E_FAIL;

	USES_CONVERSION;

WStorage IStg;
HRESULT hr = IRootStg -> OpenStorage (A2OLE(g_cbPropertyChoices), NULL, 
					STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, 
					NULL, 0L, IStg.ppi());
	
	if (FAILED(hr)) {
	// mit Schreibschutz versuchen
		hr = IRootStg -> OpenStorage (A2OLE(g_cbPropertyChoices), NULL, 
						STGM_READ|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, 
						NULL, 0L, IStg.ppi());
		if (FAILED(hr)) return hr;
	}

CLSID clsId;

	hr = ReadClassStg (IStg, &clsId);
	if (FAILED(hr)) return hr;

	if (!IsEqualCLSID (clsId, CLSID_PropertyChoice))
		return E_FAIL;

	*ppIStg = IStg.detach();

return hr;
}
예제 #25
0
bool CCoordTransService::Reload (bool fRefresh)
{
	USES_CONVERSION;

CComBSTR bstr (GetProperty (m_Props, g_cbCoordTransform, A2OLE(g_cbDefault)));

	if (!stricmp(OLE2A(bstr), m_strCTF.c_str())) {
		return true;		// muß neu initialisiert werden
	} else if (!m_fIsDefault) {
		m_fIsDefault = true;
		return true;		// war nicht DEFAULT und ist jetzt nichts mehr
	}

	if (fRefresh) 
		Refresh();
	return false;	// muß nicht neu geladen werden
}
예제 #26
0
// ----------------------------------------------------------------------------
// Helptext_ToolBarButton_propset
// ----------------------------------------------------------------------------
void Helptext_ToolBarButton_propset (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
	BASIC_OP_TRACE(Helptext_ToolBarButton_propset);

// Test for typemismatch
	if (g_fDebugScript && isTypeMismatch (hThread, lpArgs, RTTI_ToolBarButton))
		return;

	USES_CONVERSION;

ebHSUB hStr = ebGetString (lpArgs, 2);

	if (NULL != hStr) {
	LPSTR lpstr = ebLockString (hThread, hStr);
	 
		((DControlToolBarButton *)ebGetObject (lpArgs, 1)) -> put_HelpText (A2OLE(lpstr));
		ebUnlockString (hThread, hStr);
	}
}
예제 #27
0
void NP_EXPORT
NPN_Status(NPP npp, const char *message)
{
    if (!npp)
    {
        return;
    }

    nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
    ATLASSERT(pWnd);

    // Update the status bar in the browser
    CComPtr<IWebBrowserApp> cpBrowser;
    pWnd->GetWebBrowserApp(&cpBrowser);
    if (cpBrowser)
    {
        USES_CONVERSION;
        cpBrowser->put_StatusText(A2OLE(message));
    }
}
예제 #28
0
/**
 * Setup Com objects
 * Use comObjectScripRTD->QueryInterface( IID , LPVOID*  ) to get another interface of same classid    if needed
**/
RTDClient::RTDClient( const std::string &server_prog_id ) : is_NOW(false) {
    
    is_NOW  =  MiscUtil::isStringEqualIC( server_prog_id, "NOW.ScripRTD" ) ;

    USES_CONVERSION;
    LPOLESTR   progid  =  A2OLE( server_prog_id.c_str() );
    CLSID      classid;    
    HRESULT    hr;
    
    hr = CoInitializeEx(NULL,COINIT_MULTITHREADED);                         // Initialize the COM library for this thread. This make Windows load the DLLs
                                                                            // COINIT_MULTITHREADED needed for callback to work.
    hr = CLSIDFromProgID(progid, &classid);                                 // Else need a message loop for STA - Single Thread Apartment
    hr = CoCreateInstance(classid, NULL, CLSCTX_LOCAL_SERVER, __uuidof(IScripRTD), (LPVOID*) &comObjectScripRTD );
                                                                            // Get COM Object for IScripRTD interface
    if ( FAILED( hr ) ){        
        throw( server_prog_id + " - IScripRTD object creation error. Nest down?"  );
    }
    
    CComObject<CallbackImpl>::CreateInstance(&callback);                    // Create Callback Object
}
예제 #29
0
// ----------------------------------------------------------------------------
// refcnt_ToolBar
// ----------------------------------------------------------------------------
void refcnt_ToolBar (ebHTHREAD hThread, int iNumArgs, ebARGS lpArgs)
{
	BASIC_OP_TRACE_SYS(refcnt_ToolBar);

	switch (iNumArgs) {
	case OBJECT_REFNEW:
		{
			ebSetObject (lpArgs, 0, NULL);		// für alle Fälle

		// in TRiAS-Objekthierarchie einbinden
			try {
			WDControlToolBar ToolBar;
			CString strName;

				USES_CONVERSION;
				strName.Format (IDS_NEWTOOLBARNAME, g_lTBCnt);
				InterlockedIncrement (&g_lTBCnt);

			CComVariant vStyle (DISP_E_PARAMNOTFOUND, VT_ERROR);

				THROW_FAILED_HRESULT(((OLE2AutoExtension *)g_pTE) -> AppDisp() -> AddToolBar (A2OLE(strName), vStyle, ToolBar.ppi()));
				ebSetObject (lpArgs, 0, (DWORD)ToolBar.detach());

			} catch (_com_error&) {
				return;
			}
		}
		break;
		
	case OBJECT_REFINC:
		((IUnknown *)ebGetObject (lpArgs, 1)) -> AddRef();
		break;
		
	case OBJECT_REFDEC:
		((IUnknown *)ebGetObject (lpArgs, 1)) -> Release();
		break;
	}
}
예제 #30
0
/* void onStartURIOpen (in nsIURI aURI, out boolean aAbortOpen); */
NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, PRBool *aAbortOpen)
{
    USES_CONVERSION;
    NG_TRACE(_T("CWebBrowserContainer::OnStartURIOpen(...)\n"));

    mCurrentURI = pURI;
    NG_ASSERT(mCurrentURI);

    nsCAutoString aURI;
    mCurrentURI->GetSpec(aURI);

    // Setup the post data
    CComVariant vPostDataRef;
    CComVariant vPostData;
    vPostDataRef.vt = VT_BYREF | VT_VARIANT;
    vPostDataRef.pvarVal = &vPostData;
    // TODO get the post data passed in via the original call to Navigate()


    // Fire a BeforeNavigate event
    BSTR bstrURI = SysAllocString(A2OLE(aURI.get()));
    BSTR bstrTargetFrameName = NULL;
    BSTR bstrHeaders = NULL;
    VARIANT_BOOL bCancel = VARIANT_FALSE;
    long lFlags = 0;

    mEvents1->Fire_BeforeNavigate(bstrURI, lFlags, bstrTargetFrameName, &vPostDataRef, bstrHeaders, &bCancel);

    // Fire a BeforeNavigate2 event
    CComVariant vURI(bstrURI);
    CComVariant vFlags(lFlags);
    CComVariant vTargetFrameName(bstrTargetFrameName);
    CComVariant vHeaders(bstrHeaders);

    mEvents2->Fire_BeforeNavigate2(mOwner, &vURI, &vFlags, &vTargetFrameName, &vPostDataRef, &vHeaders, &bCancel);

    // Cleanup
    SysFreeString(bstrURI);
    SysFreeString(bstrTargetFrameName);
    SysFreeString(bstrHeaders);

    if (bCancel != VARIANT_FALSE)
    {
        *aAbortOpen = PR_TRUE;
        return NS_ERROR_ABORT;
    }
    else
    {
        mOwner->mBusyFlag = TRUE;
    }

    //NOTE:  The IE control fires a DownloadBegin after the first BeforeNavigate.
    //      It then fires a DownloadComplete after the engine has made its
    //      initial connection to the server.  It then fires a second
    //      DownloadBegin/DownloadComplete pair around the loading of
    //      everything on the page.  These events get fired out of
    //      CWebBrowserContainer::StartDocumentLoad() and
    //      CWebBrowserContainer::EndDocumentLoad().
    //        We don't appear to distinguish between the initial connection to
    //      the server and the actual transfer of data.  Firing these events
    //      here simulates, appeasing applications that are expecting that
    //      initial pair.

    mEvents1->Fire_DownloadBegin();
    mEvents2->Fire_DownloadBegin();
    mEvents1->Fire_DownloadComplete();
    mEvents2->Fire_DownloadComplete();

    return NS_OK;
}