Back out Dao's push because of build bustage

This commit is contained in:
Ehsan Akhgari 2011-06-14 00:17:10 -04:00
Родитель 9587dc4bad
Коммит 7c55737ac3
364 изменённых файлов: 61718 добавлений и 34 удалений

Просмотреть файл

@ -588,6 +588,13 @@ private:
nsresult
InitPrincipals(PRUint32 prefCount, const char** prefNames);
#ifdef XPC_IDISPATCH_SUPPORT
// While this header is included outside of caps, this class isn't
// referenced so this should be fine.
nsresult
CheckComponentPermissions(JSContext *cx, const nsCID &aCID);
#endif
#ifdef DEBUG_CAPS_HACKER
void
PrintPolicyDB();
@ -625,6 +632,10 @@ private:
PRPackedBool mIsJavaScriptEnabled;
PRPackedBool mIsWritingPrefs;
PRPackedBool mPolicyPrefsChanged;
#ifdef XPC_IDISPATCH_SUPPORT
PRPackedBool mXPCDefaultGrantAll;
static const char sXPCDefaultGrantAllName[];
#endif
static PRBool sStrictFileOriginPolicy;

Просмотреть файл

@ -58,6 +58,10 @@ CPPSRCS = \
nsSecurityManagerFactory.cpp \
$(NULL)
ifdef XPC_IDISPATCH_SUPPORT
DEFINES += -DXPC_IDISPATCH_SUPPORT
endif
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../include \

Просмотреть файл

@ -3090,6 +3090,60 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
return rv;
}
#ifdef XPC_IDISPATCH_SUPPORT
nsresult
nsScriptSecurityManager::CheckComponentPermissions(JSContext *cx,
const nsCID &aCID)
{
nsresult rv;
nsIPrincipal* subjectPrincipal = GetSubjectPrincipal(cx, &rv);
if (NS_FAILED(rv))
return rv;
// Reformat the CID string so it's suitable for prefs
nsXPIDLCString cidTemp;
cidTemp.Adopt(aCID.ToString());
nsCAutoString cid(NS_LITERAL_CSTRING("CID") +
Substring(cidTemp, 1, cidTemp.Length() - 2));
ToUpperCase(cid);
#ifdef DEBUG_CAPS_CheckComponentPermissions
printf("### CheckComponentPermissions(ClassID.%s) ",cid.get());
#endif
// Look up the policy for this class.
// while this isn't a property we'll treat it as such, using ACCESS_CALL_METHOD
JSAutoRequest ar(cx);
jsid cidId = INTERNED_STRING_TO_JSID(::JS_InternString(cx, cid.get()));
ClassInfoData nameData(nsnull, "ClassID");
SecurityLevel securityLevel;
rv = LookupPolicy(subjectPrincipal, nameData, cidId,
nsIXPCSecurityManager::ACCESS_CALL_METHOD,
nsnull, &securityLevel);
if (NS_FAILED(rv))
return rv;
// If there's no policy stored, use the "security.classID.allowByDefault" pref
if (securityLevel.level == SCRIPT_SECURITY_UNDEFINED_ACCESS)
securityLevel.level = mXPCDefaultGrantAll ? SCRIPT_SECURITY_ALL_ACCESS :
SCRIPT_SECURITY_NO_ACCESS;
if (securityLevel.level == SCRIPT_SECURITY_ALL_ACCESS)
{
#ifdef DEBUG_CAPS_CheckComponentPermissions
printf(" GRANTED.\n");
#endif
return NS_OK;
}
#ifdef DEBUG_CAPS_CheckComponentPermissions
printf(" DENIED.\n");
#endif
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
}
#endif
NS_IMETHODIMP
nsScriptSecurityManager::CanCreateInstance(JSContext *cx,
const nsCID &aCID)
@ -3102,6 +3156,12 @@ nsScriptSecurityManager::CanCreateInstance(JSContext *cx,
nsresult rv = CheckXPCPermissions(nsnull, nsnull, nsnull, nsnull, nsnull);
if (NS_FAILED(rv))
#ifdef XPC_IDISPATCH_SUPPORT
{
rv = CheckComponentPermissions(cx, aCID);
}
if (NS_FAILED(rv))
#endif
{
//-- Access denied, report an error
nsCAutoString errorMsg("Permission denied to create instance of class. CID=");
@ -3322,6 +3382,9 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
mIsJavaScriptEnabled(PR_FALSE),
mIsWritingPrefs(PR_FALSE),
mPolicyPrefsChanged(PR_TRUE)
#ifdef XPC_IDISPATCH_SUPPORT
, mXPCDefaultGrantAll(PR_FALSE)
#endif
{
NS_ASSERTION(sizeof(PRWord) == sizeof(void*),
"PRWord and void* have different lengths on this platform. "
@ -3919,6 +3982,10 @@ const char nsScriptSecurityManager::sJSEnabledPrefName[] =
"javascript.enabled";
const char nsScriptSecurityManager::sFileOriginPolicyPrefName[] =
"security.fileuri.strict_origin_policy";
#ifdef XPC_IDISPATCH_SUPPORT
const char nsScriptSecurityManager::sXPCDefaultGrantAllName[] =
"security.classID.allowByDefault";
#endif
inline void
nsScriptSecurityManager::ScriptSecurityPrefChanged()
@ -3928,6 +3995,11 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged()
sStrictFileOriginPolicy = PR_TRUE;
#ifdef XPC_IDISPATCH_SUPPORT
// Granting XPC Priveleges defaults to disabled in failure cases.
mXPCDefaultGrantAll = PR_FALSE;
#endif
nsresult rv;
if (!mPrefBranch) {
rv = InitPrefs();
@ -3943,6 +4015,12 @@ nsScriptSecurityManager::ScriptSecurityPrefChanged()
rv = mPrefBranch->GetBoolPref(sFileOriginPolicyPrefName, &temp);
if (NS_SUCCEEDED(rv))
sStrictFileOriginPolicy = NS_SUCCEEDED(rv) && temp;
#ifdef XPC_IDISPATCH_SUPPORT
rv = mPrefBranch->GetBoolPref(sXPCDefaultGrantAllName, &temp);
if (NS_SUCCEEDED(rv))
mXPCDefaultGrantAll = temp;
#endif
}
nsresult
@ -3961,6 +4039,9 @@ nsScriptSecurityManager::InitPrefs()
// set observer callbacks in case the value of the prefs change
prefBranchInternal->AddObserver(sJSEnabledPrefName, this, PR_FALSE);
prefBranchInternal->AddObserver(sFileOriginPolicyPrefName, this, PR_FALSE);
#ifdef XPC_IDISPATCH_SUPPORT
prefBranchInternal->AddObserver(sXPCDefaultGrantAllName, this, PR_FALSE);
#endif
PRUint32 prefCount;
char** prefNames;

Просмотреть файл

@ -135,7 +135,10 @@ MOZ_INSTALLER = @MOZ_INSTALLER@
MOZ_UPDATER = @MOZ_UPDATER@
MOZ_UPDATE_CHANNEL = @MOZ_UPDATE_CHANNEL@
MOZ_UPDATE_PACKAGING = @MOZ_UPDATE_PACKAGING@
MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
XPC_IDISPATCH_SUPPORT = @XPC_IDISPATCH_SUPPORT@
NS_ENABLE_TSF = @NS_ENABLE_TSF@
MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@

Просмотреть файл

@ -4755,6 +4755,7 @@ dnl ========================================================
MOZ_ARG_HEADER(Application)
ENABLE_TESTS=1
MOZ_ACTIVEX_SCRIPTING_SUPPORT=
MOZ_BRANDING_DIRECTORY=
MOZ_OFFICIAL_BRANDING=
MOZ_FEEDS=1
@ -4764,6 +4765,7 @@ MOZ_CSS_ANIMATIONS=1
MOZ_MORK=
MOZ_MORKREADER=1
MOZ_AUTH_EXTENSION=1
MOZ_NO_ACTIVEX_SUPPORT=1
MOZ_NO_FAST_LOAD=
MOZ_OGG=1
MOZ_RAW=
@ -4817,6 +4819,7 @@ NECKO_DISK_CACHE=1
NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg"
USE_ARM_KUSER=
BUILD_CTYPES=1
XPC_IDISPATCH_SUPPORT=
case "${target}" in
@ -6496,6 +6499,48 @@ MOZ_ARG_ENABLE_BOOL(update-packaging,
MOZ_UPDATE_PACKAGING= )
AC_SUBST(MOZ_UPDATE_PACKAGING)
dnl ========================================================
dnl ActiveX
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(xpconnect-idispatch,
[ --disable-xpconnect-idispatch
Disable building of xpconnect support for IDispatch
(win32 only)],
XPC_IDISPATCH_SUPPORT=,
XPC_IDISPATCH_SUPPORT=1)
AC_SUBST(XPC_IDISPATCH_SUPPORT)
MOZ_ARG_DISABLE_BOOL(activex,
[ --disable-activex Disable building of ActiveX control (win32 only)],
MOZ_NO_ACTIVEX_SUPPORT=1,
MOZ_NO_ACTIVEX_SUPPORT= )
AC_SUBST(MOZ_NO_ACTIVEX_SUPPORT)
MOZ_ARG_ENABLE_BOOL(activex-scripting,
[ --enable-activex-scripting
Enable building of ActiveX scripting support (win32)],
MOZ_ACTIVEX_SCRIPTING_SUPPORT=1,
MOZ_ACTIVEX_SCRIPTING_SUPPORT=)
AC_SUBST(MOZ_ACTIVEX_SCRIPTING_SUPPORT)
if test -n "$MOZ_NO_ACTIVEX_SUPPORT" -a -n "$MOZ_ACTIVEX_SCRIPTING_SUPPORT";
then
AC_MSG_ERROR([Cannot enable ActiveX scripting support when ActiveX support is disabled.])
fi
if test "$COMPILE_ENVIRONMENT" = "1"; then
if test -n "$XPC_IDISPATCH_SUPPORT" -o -n "$MOZ_ACTIVEX_SCRIPTING_SUPPORT" -o -z "$MOZ_NO_ACTIVEX_SUPPORT"; then
case "$target" in
*-mingw*)
if test "$ac_cv_header_atlbase_h" = "no"; then
AC_MSG_ERROR([System header atlbase.h is not available. See http://developer.mozilla.org/en/docs/atlbase.h for details on fixing this problem.])
fi
;;
esac
fi
fi
dnl ========================================================
dnl leaky
dnl ========================================================

Просмотреть файл

@ -45,4 +45,10 @@ include $(DEPTH)/config/autoconf.mk
DIRS = webBrowser build
ifeq ($(OS_ARCH),WINNT)
ifndef MOZ_NO_ACTIVEX_SUPPORT
TOOL_DIRS += activex/src
endif
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,59 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Netscape Communications, Inc.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = activex
DIRS = $(NULL)
# Common
DIRS += common
# ActiveX plugin
ifdef MOZ_ACTIVEX_SCRIPTING_SUPPORT
DIRS += plugin
endif
# The ActiveX control is now built in tier 99 from mozilla/Makefile.in
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,949 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef CPMOZILLACONTROL_H
#define CPMOZILLACONTROL_H
//////////////////////////////////////////////////////////////////////////////
// CProxyDWebBrowserEvents
template <class T>
class CProxyDWebBrowserEvents : public IConnectionPointImpl<T, &DIID_DWebBrowserEvents, CComDynamicUnkArray>
{
public:
//methods:
//DWebBrowserEvents : IDispatch
public:
void Fire_BeforeNavigate(
BSTR URL,
long Flags,
BSTR TargetFrameName,
VARIANT * PostData,
BSTR Headers,
VARIANT_BOOL * Cancel)
{
VARIANTARG* pvars = new VARIANTARG[6];
for (int i = 0; i < 6; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[5].vt = VT_BSTR;
pvars[5].bstrVal= URL;
pvars[4].vt = VT_I4;
pvars[4].lVal= Flags;
pvars[3].vt = VT_BSTR;
pvars[3].bstrVal= TargetFrameName;
pvars[2].vt = VT_VARIANT | VT_BYREF;
pvars[2].byref= PostData;
pvars[1].vt = VT_BSTR;
pvars[1].bstrVal= Headers;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Cancel;
DISPPARAMS disp = { pvars, NULL, 6, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x64, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_NavigateComplete(
BSTR URL)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= URL;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x65, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_StatusTextChange(
BSTR Text)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= Text;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x66, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_ProgressChange(
long Progress,
long ProgressMax)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_I4;
pvars[1].lVal= Progress;
pvars[0].vt = VT_I4;
pvars[0].lVal= ProgressMax;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6c, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_DownloadComplete()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x68, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_CommandStateChange(
long Command,
VARIANT_BOOL Enable)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_I4;
pvars[1].lVal= Command;
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= Enable;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x69, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_DownloadBegin()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6a, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_NewWindow(
BSTR URL,
long Flags,
BSTR TargetFrameName,
VARIANT * PostData,
BSTR Headers,
VARIANT_BOOL * Processed)
{
VARIANTARG* pvars = new VARIANTARG[6];
for (int i = 0; i < 6; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[5].vt = VT_BSTR;
pvars[5].bstrVal= URL;
pvars[4].vt = VT_I4;
pvars[4].lVal= Flags;
pvars[3].vt = VT_BSTR;
pvars[3].bstrVal= TargetFrameName;
pvars[2].vt = VT_VARIANT | VT_BYREF;
pvars[2].byref= PostData;
pvars[1].vt = VT_BSTR;
pvars[1].bstrVal= Headers;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Processed;
DISPPARAMS disp = { pvars, NULL, 6, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6b, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_TitleChange(
BSTR Text)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= Text;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x71, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_FrameBeforeNavigate(
BSTR URL,
long Flags,
BSTR TargetFrameName,
VARIANT * PostData,
BSTR Headers,
VARIANT_BOOL * Cancel)
{
VARIANTARG* pvars = new VARIANTARG[6];
for (int i = 0; i < 6; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[5].vt = VT_BSTR;
pvars[5].bstrVal= URL;
pvars[4].vt = VT_I4;
pvars[4].lVal= Flags;
pvars[3].vt = VT_BSTR;
pvars[3].bstrVal= TargetFrameName;
pvars[2].vt = VT_VARIANT | VT_BYREF;
pvars[2].byref= PostData;
pvars[1].vt = VT_BSTR;
pvars[1].bstrVal= Headers;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Cancel;
DISPPARAMS disp = { pvars, NULL, 6, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xc8, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_FrameNavigateComplete(
BSTR URL)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= URL;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xc9, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_FrameNewWindow(
BSTR URL,
long Flags,
BSTR TargetFrameName,
VARIANT * PostData,
BSTR Headers,
VARIANT_BOOL * Processed)
{
VARIANTARG* pvars = new VARIANTARG[6];
for (int i = 0; i < 6; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[5].vt = VT_BSTR;
pvars[5].bstrVal= URL;
pvars[4].vt = VT_I4;
pvars[4].lVal= Flags;
pvars[3].vt = VT_BSTR;
pvars[3].bstrVal= TargetFrameName;
pvars[2].vt = VT_VARIANT | VT_BYREF;
pvars[2].byref= PostData;
pvars[1].vt = VT_BSTR;
pvars[1].bstrVal= Headers;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Processed;
DISPPARAMS disp = { pvars, NULL, 6, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xcc, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_Quit(
VARIANT_BOOL * Cancel)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Cancel;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x67, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_WindowMove()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6d, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_WindowResize()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6e, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_WindowActivate()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6f, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_PropertyChange(
BSTR Property)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= Property;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x70, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
};
//////////////////////////////////////////////////////////////////////////////
// CProxyDWebBrowserEvents2
template <class T>
class CProxyDWebBrowserEvents2 : public IConnectionPointImpl<T, &DIID_DWebBrowserEvents2, CComDynamicUnkArray>
{
public:
//methods:
//DWebBrowserEvents2 : IDispatch
public:
void Fire_StatusTextChange(
BSTR Text)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= Text;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x66, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_ProgressChange(
long Progress,
long ProgressMax)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_I4;
pvars[1].lVal= Progress;
pvars[0].vt = VT_I4;
pvars[0].lVal= ProgressMax;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6c, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_CommandStateChange(
long Command,
VARIANT_BOOL Enable)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_I4;
pvars[1].lVal= Command;
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= Enable;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x69, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_DownloadBegin()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x6a, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_DownloadComplete()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x68, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_TitleChange(
BSTR Text)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= Text;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x71, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_PropertyChange(
BSTR szProperty)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BSTR;
pvars[0].bstrVal= szProperty;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x70, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_BeforeNavigate2(
IDispatch * pDisp,
VARIANT * URL,
VARIANT * Flags,
VARIANT * TargetFrameName,
VARIANT * PostData,
VARIANT * Headers,
VARIANT_BOOL * Cancel)
{
VARIANTARG* pvars = new VARIANTARG[7];
for (int i = 0; i < 7; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[6].vt = VT_DISPATCH;
pvars[6].pdispVal= pDisp;
pvars[5].vt = VT_VARIANT | VT_BYREF;
pvars[5].byref= URL;
pvars[4].vt = VT_VARIANT | VT_BYREF;
pvars[4].byref= Flags;
pvars[3].vt = VT_VARIANT | VT_BYREF;
pvars[3].byref= TargetFrameName;
pvars[2].vt = VT_VARIANT | VT_BYREF;
pvars[2].byref= PostData;
pvars[1].vt = VT_VARIANT | VT_BYREF;
pvars[1].byref= Headers;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Cancel;
DISPPARAMS disp = { pvars, NULL, 7, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xfa, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_NewWindow2(
IDispatch * * ppDisp,
VARIANT_BOOL * Cancel)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_DISPATCH | VT_BYREF;
pvars[1].byref= ppDisp;
pvars[0].vt = VT_BOOL | VT_BYREF;
pvars[0].byref= Cancel;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xfb, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_NavigateComplete2(
IDispatch * pDisp,
VARIANT * URL)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_DISPATCH;
pvars[1].pdispVal= pDisp;
pvars[0].vt = VT_VARIANT | VT_BYREF;
pvars[0].byref= URL;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xfc, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_DocumentComplete(
IDispatch * pDisp,
VARIANT * URL)
{
VARIANTARG* pvars = new VARIANTARG[2];
for (int i = 0; i < 2; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[1].vt = VT_DISPATCH;
pvars[1].pdispVal= pDisp;
pvars[0].vt = VT_VARIANT | VT_BYREF;
pvars[0].byref= URL;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x103, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnQuit()
{
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
DISPPARAMS disp = { NULL, NULL, 0, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xfd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
}
void Fire_OnVisible(
VARIANT_BOOL Visible)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= Visible;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xfe, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnToolBar(
VARIANT_BOOL ToolBar)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= ToolBar;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0xff, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnMenuBar(
VARIANT_BOOL MenuBar)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= MenuBar;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x100, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnStatusBar(
VARIANT_BOOL StatusBar)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= StatusBar;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x101, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnFullScreen(
VARIANT_BOOL FullScreen)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= FullScreen;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x102, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
void Fire_OnTheaterMode(
VARIANT_BOOL TheaterMode)
{
VARIANTARG* pvars = new VARIANTARG[1];
for (int i = 0; i < 1; i++)
VariantInit(&pvars[i]);
T* pT = (T*)this;
pT->Lock();
IUnknown** pp = m_vec.begin();
while (pp < m_vec.end())
{
if (*pp != NULL)
{
pvars[0].vt = VT_BOOL;
pvars[0].boolVal= TheaterMode;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
pDispatch->Invoke(0x104, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
pp++;
}
pT->Unlock();
delete[] pvars;
}
};
#endif

Просмотреть файл

@ -0,0 +1,216 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include "ControlEventSink.h"
CControlEventSink::CControlEventSink() :
m_dwEventCookie(0),
m_EventIID(GUID_NULL)
{
}
CControlEventSink::~CControlEventSink()
{
UnsubscribeFromEvents();
}
BOOL
CControlEventSink::GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo)
{
iid = GUID_NULL;
if (!pControl)
{
return E_INVALIDARG;
}
// IProvideClassInfo2 way is easiest
// CComQIPtr<IProvideClassInfo2> classInfo2 = pControl;
// if (classInfo2)
// {
// classInfo2->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid);
// if (!::IsEqualIID(iid, GUID_NULL))
// {
// return TRUE;
// }
// }
// Yuck, the hard way
CComQIPtr<IProvideClassInfo> classInfo = pControl;
if (!classInfo)
{
return FALSE;
}
// Search the class type information for the default source interface
// which is the outgoing event sink.
CComPtr<ITypeInfo> classTypeInfo;
classInfo->GetClassInfo(&classTypeInfo);
if (!classTypeInfo)
{
return FALSE;
}
TYPEATTR *classAttr = NULL;
if (FAILED(classTypeInfo->GetTypeAttr(&classAttr)))
{
return FALSE;
}
INT implFlags = 0;
for (UINT i = 0; i < classAttr->cImplTypes; i++)
{
// Search for the interface with the [default, source] attr
if (SUCCEEDED(classTypeInfo->GetImplTypeFlags(i, &implFlags)) &&
implFlags == (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE))
{
CComPtr<ITypeInfo> eventSinkTypeInfo;
HREFTYPE hRefType;
if (SUCCEEDED(classTypeInfo->GetRefTypeOfImplType(i, &hRefType)) &&
SUCCEEDED(classTypeInfo->GetRefTypeInfo(hRefType, &eventSinkTypeInfo)))
{
TYPEATTR *eventSinkAttr = NULL;
if (SUCCEEDED(eventSinkTypeInfo->GetTypeAttr(&eventSinkAttr)))
{
iid = eventSinkAttr->guid;
if (typeInfo)
{
*typeInfo = eventSinkTypeInfo.p;
(*typeInfo)->AddRef();
}
eventSinkTypeInfo->ReleaseTypeAttr(eventSinkAttr);
}
}
break;
}
}
classTypeInfo->ReleaseTypeAttr(classAttr);
return (!::IsEqualIID(iid, GUID_NULL));
}
void CControlEventSink::UnsubscribeFromEvents()
{
if (m_spEventCP)
{
// Unsubscribe and reset
m_spEventCP->Unadvise(m_dwEventCookie);
m_dwEventCookie = 0;
m_spEventCP.Release();
}
}
HRESULT CControlEventSink::SubscribeToEvents(IUnknown *pControl)
{
if (!pControl)
{
return E_INVALIDARG;
}
// Throw away any existing connections
UnsubscribeFromEvents();
// Grab the outgoing event sink IID which will be used to subscribe
// to events via the connection point container.
IID iidEventSink;
CComPtr<ITypeInfo> typeInfo;
if (!GetEventSinkIID(pControl, iidEventSink, &typeInfo))
{
return E_FAIL;
}
// Get the connection point
CComQIPtr<IConnectionPointContainer> ccp = pControl;
CComPtr<IConnectionPoint> cp;
if (!ccp)
{
return E_FAIL;
}
// Custom IID
m_EventIID = iidEventSink;
DWORD dwCookie = 0;
if (!ccp ||
FAILED(ccp->FindConnectionPoint(m_EventIID, &cp)) ||
FAILED(cp->Advise(this, &dwCookie)))
{
return E_FAIL;
}
m_spEventCP = cp;
m_dwEventCookie = dwCookie;
m_spEventSinkTypeInfo = typeInfo;
return S_OK;
}
HRESULT
CControlEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
// Override me!
return E_NOTIMPL;
}
///////////////////////////////////////////////////////////////////////////////
// IDispatch implementation
HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CControlEventSink::GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CControlEventSink::GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CControlEventSink::Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr)
{
return InternalInvoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}

Просмотреть файл

@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef CONTROLEVENTSINK_H
#define CONTROLEVENTSINK_H
// This class listens for events from the specified control
class CControlEventSink :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatch
{
public:
CControlEventSink();
// Current event connection point
CComPtr<IConnectionPoint> m_spEventCP;
CComPtr<ITypeInfo> m_spEventSinkTypeInfo;
DWORD m_dwEventCookie;
IID m_EventIID;
protected:
virtual ~CControlEventSink();
static HRESULT WINAPI SinkQI(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
{
CControlEventSink *pThis = (CControlEventSink *) pv;
if (!IsEqualIID(pThis->m_EventIID, GUID_NULL) &&
IsEqualIID(pThis->m_EventIID, riid))
{
return pThis->QueryInterface(__uuidof(IDispatch), ppv);
}
return E_NOINTERFACE;
}
public:
BEGIN_COM_MAP(CControlEventSink)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY_FUNC_BLIND(0, SinkQI)
END_COM_MAP()
virtual HRESULT SubscribeToEvents(IUnknown *pControl);
virtual void UnsubscribeFromEvents();
virtual BOOL GetEventSinkIID(IUnknown *pControl, IID &iid, ITypeInfo **typeInfo);
virtual HRESULT InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
// IDispatch
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo);
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr);
};
typedef CComObject<CControlEventSink> CControlEventSinkInstance;
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,393 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef CONTROLSITE_H
#define CONTROLSITE_H
#include "IOleCommandTargetImpl.h"
#include "PropertyList.h"
// If you created a class derived from CControlSite, use the following macro
// in the interface map of the derived class to include all the necessary
// interfaces.
#define CCONTROLSITE_INTERFACES() \
COM_INTERFACE_ENTRY(IOleWindow) \
COM_INTERFACE_ENTRY(IOleClientSite) \
COM_INTERFACE_ENTRY(IOleInPlaceSite) \
COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSite, IOleInPlaceSiteWindowless) \
COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteEx, IOleInPlaceSiteWindowless) \
COM_INTERFACE_ENTRY(IOleControlSite) \
COM_INTERFACE_ENTRY(IDispatch) \
COM_INTERFACE_ENTRY_IID(IID_IAdviseSink, IAdviseSinkEx) \
COM_INTERFACE_ENTRY_IID(IID_IAdviseSink2, IAdviseSinkEx) \
COM_INTERFACE_ENTRY_IID(IID_IAdviseSinkEx, IAdviseSinkEx) \
COM_INTERFACE_ENTRY(IOleCommandTarget) \
COM_INTERFACE_ENTRY(IServiceProvider) \
COM_INTERFACE_ENTRY(IBindStatusCallback) \
COM_INTERFACE_ENTRY(IWindowForBindingUI)
// Temoporarily removed by bug 200680. Stops controls misbehaving and calling
// windowless methods when they shouldn't.
// COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceSiteWindowless, IOleInPlaceSiteWindowless) \
// Class that defines the control's security policy with regards to
// what controls it hosts etc.
class CControlSiteSecurityPolicy
{
public:
// Test if the class is safe to host
virtual BOOL IsClassSafeToHost(const CLSID & clsid) = 0;
// Test if the specified class is marked safe for scripting
virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists) = 0;
// Test if the instantiated object is safe for scripting on the specified interface
virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid) = 0;
};
//
// Class for hosting an ActiveX control
//
// This class supports both windowed and windowless classes. The normal
// steps to hosting a control are this:
//
// CControlSiteInstance *pSite = NULL;
// CControlSiteInstance::CreateInstance(&pSite);
// pSite->AddRef();
// pSite->Create(clsidControlToCreate);
// pSite->Attach(hwndParentWindow, rcPosition);
//
// Where propertyList is a named list of values to initialise the new object
// with, hwndParentWindow is the window in which the control is being created,
// and rcPosition is the position in window coordinates where the control will
// be rendered.
//
// Destruction is this:
//
// pSite->Detach();
// pSite->Release();
// pSite = NULL;
class CControlSite : public CComObjectRootEx<CComSingleThreadModel>,
public CControlSiteSecurityPolicy,
public IOleClientSite,
public IOleInPlaceSiteWindowless,
public IOleControlSite,
public IAdviseSinkEx,
public IDispatch,
public IServiceProvider,
public IOleCommandTargetImpl<CControlSite>,
public IBindStatusCallback,
public IWindowForBindingUI
{
public:
// Site management values
// Handle to parent window
HWND m_hWndParent;
// Position of the site and the contained object
RECT m_rcObjectPos;
// Flag indicating if client site should be set early or late
unsigned m_bSetClientSiteFirst:1;
// Flag indicating whether control is visible or not
unsigned m_bVisibleAtRuntime:1;
// Flag indicating if control is in-place active
unsigned m_bInPlaceActive:1;
// Flag indicating if control is UI active
unsigned m_bUIActive:1;
// Flag indicating if control is in-place locked and cannot be deactivated
unsigned m_bInPlaceLocked:1;
// Flag indicating if the site allows windowless controls
unsigned m_bSupportWindowlessActivation:1;
// Flag indicating if control is windowless (after being created)
unsigned m_bWindowless:1;
// Flag indicating if only safely scriptable controls are allowed
unsigned m_bSafeForScriptingObjectsOnly:1;
// Pointer to an externally registered service provider
CComPtr<IServiceProvider> m_spServiceProvider;
// Pointer to the OLE container
CComPtr<IOleContainer> m_spContainer;
// Return the default security policy object
static CControlSiteSecurityPolicy *GetDefaultControlSecurityPolicy();
protected:
// Pointers to object interfaces
// Raw pointer to the object
CComPtr<IUnknown> m_spObject;
// Pointer to objects IViewObject interface
CComQIPtr<IViewObject, &IID_IViewObject> m_spIViewObject;
// Pointer to object's IOleObject interface
CComQIPtr<IOleObject, &IID_IOleObject> m_spIOleObject;
// Pointer to object's IOleInPlaceObject interface
CComQIPtr<IOleInPlaceObject, &IID_IOleInPlaceObject> m_spIOleInPlaceObject;
// Pointer to object's IOleInPlaceObjectWindowless interface
CComQIPtr<IOleInPlaceObjectWindowless, &IID_IOleInPlaceObjectWindowless> m_spIOleInPlaceObjectWindowless;
// CLSID of the control
CLSID m_CLSID;
// Parameter list
PropertyList m_ParameterList;
// Pointer to the security policy
CControlSiteSecurityPolicy *m_pSecurityPolicy;
// Binding variables
// Flag indicating whether binding is in progress
unsigned m_bBindingInProgress;
// Result from the binding operation
HRESULT m_hrBindResult;
// Double buffer drawing variables used for windowless controls
// Area of buffer
RECT m_rcBuffer;
// Bitmap to buffer
HBITMAP m_hBMBuffer;
// Bitmap to buffer
HBITMAP m_hBMBufferOld;
// Device context
HDC m_hDCBuffer;
// Clipping area of site
HRGN m_hRgnBuffer;
// Flags indicating how the buffer was painted
DWORD m_dwBufferFlags;
// Ambient properties
// Locale ID
LCID m_nAmbientLocale;
// Foreground colour
COLORREF m_clrAmbientForeColor;
// Background colour
COLORREF m_clrAmbientBackColor;
// Flag indicating if control should hatch itself
bool m_bAmbientShowHatching:1;
// Flag indicating if control should have grab handles
bool m_bAmbientShowGrabHandles:1;
// Flag indicating if control is in edit/user mode
bool m_bAmbientUserMode:1;
// Flag indicating if control has a 3d border or not
bool m_bAmbientAppearance:1;
protected:
// Notifies the attached control of a change to an ambient property
virtual void FireAmbientPropertyChange(DISPID id);
public:
// Construction and destruction
// Constructor
CControlSite();
// Destructor
virtual ~CControlSite();
BEGIN_COM_MAP(CControlSite)
CCONTROLSITE_INTERFACES()
END_COM_MAP()
BEGIN_OLECOMMAND_TABLE()
END_OLECOMMAND_TABLE()
// Returns the window used when processing ole commands
HWND GetCommandTargetWindow()
{
return NULL; // TODO
}
// Object creation and management functions
// Creates and initialises an object
virtual HRESULT Create(REFCLSID clsid, PropertyList &pl = PropertyList(),
LPCWSTR szCodebase = NULL, IBindCtx *pBindContext = NULL);
// Attaches the object to the site
virtual HRESULT Attach(HWND hwndParent, const RECT &rcPos, IUnknown *pInitStream = NULL);
// Detaches the object from the site
virtual HRESULT Detach();
// Returns the IUnknown pointer for the object
virtual HRESULT GetControlUnknown(IUnknown **ppObject);
// Sets the bounding rectangle for the object
virtual HRESULT SetPosition(const RECT &rcPos);
// Draws the object using the provided DC
virtual HRESULT Draw(HDC hdc);
// Performs the specified action on the object
virtual HRESULT DoVerb(LONG nVerb, LPMSG lpMsg = NULL);
// Sets an advise sink up for changes to the object
virtual HRESULT Advise(IUnknown *pIUnkSink, const IID &iid, DWORD *pdwCookie);
// Removes an advise sink
virtual HRESULT Unadvise(const IID &iid, DWORD dwCookie);
// Register an external service provider object
virtual void SetServiceProvider(IServiceProvider *pSP)
{
m_spServiceProvider = pSP;
}
virtual void SetContainer(IOleContainer *pContainer)
{
m_spContainer = pContainer;
}
// Set the security policy object. Ownership of this object remains with the caller and the security
// policy object is meant to exist for as long as it is set here.
virtual void SetSecurityPolicy(CControlSiteSecurityPolicy *pSecurityPolicy)
{
m_pSecurityPolicy = pSecurityPolicy;
}
virtual CControlSiteSecurityPolicy *GetSecurityPolicy() const
{
return m_pSecurityPolicy;
}
// Methods to set ambient properties
virtual void SetAmbientUserMode(BOOL bUser);
// Inline helper methods
// Returns the object's CLSID
virtual const CLSID &GetObjectCLSID() const
{
return m_CLSID;
}
// Tests if the object is valid or not
virtual BOOL IsObjectValid() const
{
return (m_spObject) ? TRUE : FALSE;
}
// Returns the parent window to this one
virtual HWND GetParentWindow() const
{
return m_hWndParent;
}
// Returns the inplace active state of the object
virtual BOOL IsInPlaceActive() const
{
return m_bInPlaceActive;
}
// CControlSiteSecurityPolicy
// Test if the class is safe to host
virtual BOOL IsClassSafeToHost(const CLSID & clsid);
// Test if the specified class is marked safe for scripting
virtual BOOL IsClassMarkedSafeForScripting(const CLSID & clsid, BOOL &bClassExists);
// Test if the instantiated object is safe for scripting on the specified interface
virtual BOOL IsObjectSafeForScripting(IUnknown *pObject, const IID &iid);
// Test if the instantiated object is safe for scripting on the specified interface
virtual BOOL IsObjectSafeForScripting(const IID &iid);
// IServiceProvider
virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void** ppv);
// IDispatch
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(/* [out] */ UINT __RPC_FAR *pctinfo);
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(/* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(/* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);
virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke(/* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, /* [out] */ VARIANT __RPC_FAR *pVarResult, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ UINT __RPC_FAR *puArgErr);
// IAdviseSink implementation
virtual /* [local] */ void STDMETHODCALLTYPE OnDataChange(/* [unique][in] */ FORMATETC __RPC_FAR *pFormatetc, /* [unique][in] */ STGMEDIUM __RPC_FAR *pStgmed);
virtual /* [local] */ void STDMETHODCALLTYPE OnViewChange(/* [in] */ DWORD dwAspect, /* [in] */ LONG lindex);
virtual /* [local] */ void STDMETHODCALLTYPE OnRename(/* [in] */ IMoniker __RPC_FAR *pmk);
virtual /* [local] */ void STDMETHODCALLTYPE OnSave(void);
virtual /* [local] */ void STDMETHODCALLTYPE OnClose(void);
// IAdviseSink2
virtual /* [local] */ void STDMETHODCALLTYPE OnLinkSrcChange(/* [unique][in] */ IMoniker __RPC_FAR *pmk);
// IAdviseSinkEx implementation
virtual /* [local] */ void STDMETHODCALLTYPE OnViewStatusChange(/* [in] */ DWORD dwViewStatus);
// IOleWindow implementation
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd);
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode);
// IOleClientSite implementation
virtual HRESULT STDMETHODCALLTYPE SaveObject(void);
virtual HRESULT STDMETHODCALLTYPE GetMoniker(/* [in] */ DWORD dwAssign, /* [in] */ DWORD dwWhichMoniker, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmk);
virtual HRESULT STDMETHODCALLTYPE GetContainer(/* [out] */ IOleContainer __RPC_FAR *__RPC_FAR *ppContainer);
virtual HRESULT STDMETHODCALLTYPE ShowObject(void);
virtual HRESULT STDMETHODCALLTYPE OnShowWindow(/* [in] */ BOOL fShow);
virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void);
// IOleInPlaceSite implementation
virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void);
virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void);
virtual HRESULT STDMETHODCALLTYPE OnUIActivate(void);
virtual HRESULT STDMETHODCALLTYPE GetWindowContext(/* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, /* [out] */ LPRECT lprcPosRect, /* [out] */ LPRECT lprcClipRect, /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo);
virtual HRESULT STDMETHODCALLTYPE Scroll(/* [in] */ SIZE scrollExtant);
virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(/* [in] */ BOOL fUndoable);
virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void);
virtual HRESULT STDMETHODCALLTYPE DiscardUndoState(void);
virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void);
virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(/* [in] */ LPCRECT lprcPosRect);
// IOleInPlaceSiteEx implementation
virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(/* [out] */ BOOL __RPC_FAR *pfNoRedraw, /* [in] */ DWORD dwFlags);
virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(/* [in] */ BOOL fNoRedraw);
virtual HRESULT STDMETHODCALLTYPE RequestUIActivate(void);
// IOleInPlaceSiteWindowless implementation
virtual HRESULT STDMETHODCALLTYPE CanWindowlessActivate(void);
virtual HRESULT STDMETHODCALLTYPE GetCapture(void);
virtual HRESULT STDMETHODCALLTYPE SetCapture(/* [in] */ BOOL fCapture);
virtual HRESULT STDMETHODCALLTYPE GetFocus(void);
virtual HRESULT STDMETHODCALLTYPE SetFocus(/* [in] */ BOOL fFocus);
virtual HRESULT STDMETHODCALLTYPE GetDC(/* [in] */ LPCRECT pRect, /* [in] */ DWORD grfFlags, /* [out] */ HDC __RPC_FAR *phDC);
virtual HRESULT STDMETHODCALLTYPE ReleaseDC(/* [in] */ HDC hDC);
virtual HRESULT STDMETHODCALLTYPE InvalidateRect(/* [in] */ LPCRECT pRect, /* [in] */ BOOL fErase);
virtual HRESULT STDMETHODCALLTYPE InvalidateRgn(/* [in] */ HRGN hRGN, /* [in] */ BOOL fErase);
virtual HRESULT STDMETHODCALLTYPE ScrollRect(/* [in] */ INT dx, /* [in] */ INT dy, /* [in] */ LPCRECT pRectScroll, /* [in] */ LPCRECT pRectClip);
virtual HRESULT STDMETHODCALLTYPE AdjustRect(/* [out][in] */ LPRECT prc);
virtual HRESULT STDMETHODCALLTYPE OnDefWindowMessage(/* [in] */ UINT msg, /* [in] */ WPARAM wParam, /* [in] */ LPARAM lParam, /* [out] */ LRESULT __RPC_FAR *plResult);
// IOleControlSite implementation
virtual HRESULT STDMETHODCALLTYPE OnControlInfoChanged(void);
virtual HRESULT STDMETHODCALLTYPE LockInPlaceActive(/* [in] */ BOOL fLock);
virtual HRESULT STDMETHODCALLTYPE GetExtendedControl(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDisp);
virtual HRESULT STDMETHODCALLTYPE TransformCoords(/* [out][in] */ POINTL __RPC_FAR *pPtlHimetric, /* [out][in] */ POINTF __RPC_FAR *pPtfContainer, /* [in] */ DWORD dwFlags);
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ MSG __RPC_FAR *pMsg, /* [in] */ DWORD grfModifiers);
virtual HRESULT STDMETHODCALLTYPE OnFocus(/* [in] */ BOOL fGotFocus);
virtual HRESULT STDMETHODCALLTYPE ShowPropertyFrame( void);
// IBindStatusCallback
virtual HRESULT STDMETHODCALLTYPE OnStartBinding(/* [in] */ DWORD dwReserved, /* [in] */ IBinding __RPC_FAR *pib);
virtual HRESULT STDMETHODCALLTYPE GetPriority(/* [out] */ LONG __RPC_FAR *pnPriority);
virtual HRESULT STDMETHODCALLTYPE OnLowResource(/* [in] */ DWORD reserved);
virtual HRESULT STDMETHODCALLTYPE OnProgress(/* [in] */ ULONG ulProgress, /* [in] */ ULONG ulProgressMax, /* [in] */ ULONG ulStatusCode, /* [in] */ LPCWSTR szStatusText);
virtual HRESULT STDMETHODCALLTYPE OnStopBinding(/* [in] */ HRESULT hresult, /* [unique][in] */ LPCWSTR szError);
virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBindInfo( /* [out] */ DWORD __RPC_FAR *grfBINDF, /* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo);
virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnDataAvailable(/* [in] */ DWORD grfBSCF, /* [in] */ DWORD dwSize, /* [in] */ FORMATETC __RPC_FAR *pformatetc, /* [in] */ STGMEDIUM __RPC_FAR *pstgmed);
virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable(/* [in] */ REFIID riid, /* [iid_is][in] */ IUnknown __RPC_FAR *punk);
// IWindowForBindingUI
virtual HRESULT STDMETHODCALLTYPE GetWindow(/* [in] */ REFGUID rguidReason, /* [out] */ HWND *phwnd);
};
typedef CComObject<CControlSite> CControlSiteInstance;
#endif

Просмотреть файл

@ -0,0 +1,136 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "ControlSiteIPFrame.h"
CControlSiteIPFrame::CControlSiteIPFrame()
{
m_hwndFrame = NULL;
}
CControlSiteIPFrame::~CControlSiteIPFrame()
{
}
///////////////////////////////////////////////////////////////////////////////
// IOleWindow implementation
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetWindow(/* [out] */ HWND __RPC_FAR *phwnd)
{
if (phwnd == NULL)
{
return E_INVALIDARG;
}
*phwnd = m_hwndFrame;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::ContextSensitiveHelp(/* [in] */ BOOL fEnterMode)
{
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IOleInPlaceUIWindow implementation
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::GetBorder(/* [out] */ LPRECT lprectBorder)
{
return INPLACE_E_NOTOOLSPACE;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths)
{
return INPLACE_E_NOTOOLSPACE;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName)
{
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IOleInPlaceFrame implementation
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::RemoveMenus(/* [in] */ HMENU hmenuShared)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::SetStatusText(/* [in] */ LPCOLESTR pszStatusText)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::EnableModeless(/* [in] */ BOOL fEnable)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CControlSiteIPFrame::TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID)
{
return E_NOTIMPL;
}

Просмотреть файл

@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef CONTROLSITEIPFRAME_H
#define CONTROLSITEIPFRAME_H
class CControlSiteIPFrame : public CComObjectRootEx<CComSingleThreadModel>,
public IOleInPlaceFrame
{
public:
CControlSiteIPFrame();
virtual ~CControlSiteIPFrame();
HWND m_hwndFrame;
BEGIN_COM_MAP(CControlSiteIPFrame)
COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleInPlaceFrame)
COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceUIWindow, IOleInPlaceFrame)
COM_INTERFACE_ENTRY(IOleInPlaceFrame)
END_COM_MAP()
// IOleWindow
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd);
virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode);
// IOleInPlaceUIWindow implementation
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetBorder(/* [out] */ LPRECT lprectBorder);
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE RequestBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths);
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetBorderSpace(/* [unique][in] */ LPCBORDERWIDTHS pborderwidths);
virtual HRESULT STDMETHODCALLTYPE SetActiveObject(/* [unique][in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [unique][string][in] */ LPCOLESTR pszObjName);
// IOleInPlaceFrame implementation
virtual HRESULT STDMETHODCALLTYPE InsertMenus(/* [in] */ HMENU hmenuShared, /* [out][in] */ LPOLEMENUGROUPWIDTHS lpMenuWidths);
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetMenu(/* [in] */ HMENU hmenuShared, /* [in] */ HOLEMENU holemenu, /* [in] */ HWND hwndActiveObject);
virtual HRESULT STDMETHODCALLTYPE RemoveMenus(/* [in] */ HMENU hmenuShared);
virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE SetStatusText(/* [in] */ LPCOLESTR pszStatusText);
virtual HRESULT STDMETHODCALLTYPE EnableModeless(/* [in] */ BOOL fEnable);
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(/* [in] */ LPMSG lpmsg, /* [in] */ WORD wID);
};
typedef CComObject<CControlSiteIPFrame> CControlSiteIPFrameInstance;
#endif

Просмотреть файл

@ -0,0 +1,155 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "IEHTMLButtonElement.h"
#include "IEHtmlElement.h"
#include "nsIDOMHTMLButtonElement.h"
HRESULT CIEHtmlButtonElement::FinalConstruct( )
{
return CComCreator<CComAggObject<CIEHtmlElement> >::CreateInstance(GetControllingUnknown(),
IID_IUnknown, reinterpret_cast<void**>(&m_pHtmlElementAgg));
}
HRESULT CIEHtmlButtonElement::GetHtmlElement(CIEHtmlElement **ppHtmlElement)
{
if (ppHtmlElement == NULL)
return E_FAIL;
*ppHtmlElement = NULL;
IHTMLElement* pHtmlElement = NULL;
// This causes an AddRef on outer unknown:
HRESULT hr = m_pHtmlElementAgg->QueryInterface(IID_IHTMLElement, (void**)&pHtmlElement);
*ppHtmlElement = (CIEHtmlElement*)pHtmlElement;
return hr;
}
HRESULT CIEHtmlButtonElement::SetDOMNode(nsIDOMNode *pDomNode)
{
mDOMNode = pDomNode;
//Forward to aggregated object:
CIEHtmlElement *pHtmlElement;
GetHtmlElement(&pHtmlElement);
HRESULT hr = pHtmlElement->SetDOMNode(pDomNode);
// Release on outer unknown because GetHtmlDomNode does AddRef on it:
GetControllingUnknown()->Release();
return hr;
}
HRESULT CIEHtmlButtonElement::SetParent(CNode *pParent)
{
CNode::SetParent(pParent);
//Forward to aggregated object:
CIEHtmlElement *pHtmlElement;
GetHtmlElement(&pHtmlElement);
HRESULT hr = pHtmlElement->SetParent(pParent);
// Release on outer unknown because GetHtmlDomNode does AddRef on it:
GetControllingUnknown()->Release();
return hr;
}
// -----------------------------------------------------------------------
// IHTMLButtonElement Implementation
// -----------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_type(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::put_value(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_value(BSTR __RPC_FAR *p)
{
if (p == NULL)
return E_INVALIDARG;
*p = NULL;
nsCOMPtr<nsIDOMHTMLButtonElement> domHtmlButtonElement = do_QueryInterface(mDOMNode);
if (!domHtmlButtonElement)
return E_UNEXPECTED;
nsAutoString strValue;
domHtmlButtonElement->GetValue(strValue);
*p = SysAllocString(strValue.get());
if (!*p)
return E_OUTOFMEMORY;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::put_name(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_name(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::put_status(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_status(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::put_disabled(VARIANT_BOOL v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_disabled(VARIANT_BOOL __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::get_form(IHTMLFormElement __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlButtonElement::createTextRange(IHTMLTxtRange __RPC_FAR *__RPC_FAR *range)
{
return E_NOTIMPL;
}

Просмотреть файл

@ -0,0 +1,139 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//
// Declaration of IHTMLButtonElement and related classes
//
#ifndef IHTMLBUTTONELEMENT_H
#define IHTMLBUTTONELEMENT_H
#include "IEHtmlNode.h"
class CIEHtmlElement;
// NOTE: Nasty hack in case arcane SDK does not define IHTMLButtonElement
#ifndef __IHTMLButtonElement_INTERFACE_DEFINED__
MIDL_INTERFACE("3050f2bb-98b5-11cf-bb82-00aa00bdce0b")
IHTMLButtonElement : public IDispatch
{
public:
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_type(
/* [out][retval] */ BSTR *p) = 0;
virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_value(
/* [in] */ BSTR v) = 0;
virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_value(
/* [out][retval] */ BSTR *p) = 0;
virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_name(
/* [in] */ BSTR v) = 0;
virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_name(
/* [out][retval] */ BSTR *p) = 0;
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_status(
/* [in] */ VARIANT v) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_status(
/* [out][retval] */ VARIANT *p) = 0;
virtual /* [bindable][displaybind][id][propput] */ HRESULT STDMETHODCALLTYPE put_disabled(
/* [in] */ VARIANT_BOOL v) = 0;
virtual /* [bindable][displaybind][id][propget] */ HRESULT STDMETHODCALLTYPE get_disabled(
/* [out][retval] */ VARIANT_BOOL *p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_form(
/* [out][retval] */ IHTMLFormElement **p) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE createTextRange(
/* [out][retval] */ IHTMLTxtRange **range) = 0;
};
#endif
class CIEHtmlButtonElement :
public CNode,
public IDispatchImpl<IHTMLButtonElement, &__uuidof(IHTMLButtonElement), &LIBID_MSHTML>
{
public:
CIEHtmlButtonElement() {
};
HRESULT FinalConstruct( );
virtual HRESULT GetHtmlElement(CIEHtmlElement **ppHtmlElement);
virtual HRESULT SetDOMNode(nsIDOMNode *pDomNode);
virtual HRESULT SetParent(CNode *pParent);
DECLARE_GET_CONTROLLING_UNKNOWN()
protected:
virtual ~CIEHtmlButtonElement() {
};
public:
BEGIN_COM_MAP(CIEHtmlButtonElement)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHTMLButtonElement)
COM_INTERFACE_ENTRY_AGGREGATE(IID_IHTMLElement, m_pHtmlElementAgg.p)
COM_INTERFACE_ENTRY_AGGREGATE(__uuidof(IHTMLDOMNode), m_pHtmlElementAgg.p)
END_COM_MAP()
// IHTMLButtonElement Implementation:
virtual HRESULT STDMETHODCALLTYPE get_type(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_value(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_value(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_name(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_name(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_status(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_status(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_disabled(VARIANT_BOOL v);
virtual HRESULT STDMETHODCALLTYPE get_disabled(VARIANT_BOOL __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_form(IHTMLFormElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE createTextRange(IHTMLTxtRange __RPC_FAR *__RPC_FAR *range);
protected:
CComPtr<IUnknown> m_pHtmlElementAgg;
};
typedef CComObject<CIEHtmlButtonElement> CIEHtmlButtonElementInstance;
#endif //IHTMLBUTTONELEMENT_H

Просмотреть файл

@ -0,0 +1,979 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "nsCOMPtr.h"
#include "nsIDOMElement.h"
#include "IEHtmlElement.h"
#include "IEHtmlElementCollection.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNSHTMLElement.h"
#include "nsIDOM3Node.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMRange.h"
#include "nsIDOMNSRange.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDocumentEncoder.h"
#include "nsContentCID.h"
CIEHtmlElement::CIEHtmlElement()
{
m_pNodeAgg = NULL;
}
HRESULT CIEHtmlElement::FinalConstruct( )
{
return CComCreator<CComAggObject<CIEHtmlDomNode> >::CreateInstance(GetControllingUnknown(),
IID_IUnknown, reinterpret_cast<void**>(&m_pNodeAgg));
}
CIEHtmlElement::~CIEHtmlElement()
{
}
void CIEHtmlElement::FinalRelease( )
{
m_pNodeAgg->Release();
}
HRESULT CIEHtmlElement::GetChildren(CIEHtmlElementCollectionInstance **ppCollection)
{
// Validate parameters
if (ppCollection == NULL)
{
return E_INVALIDARG;
}
*ppCollection = NULL;
// Create a collection representing the children of this node
CIEHtmlElementCollectionInstance *pCollection = NULL;
CIEHtmlElementCollection::CreateFromParentNode(this, FALSE, (CIEHtmlElementCollection **) &pCollection);
if (pCollection)
{
pCollection->AddRef();
*ppCollection = pCollection;
}
return S_OK;
}
HRESULT CIEHtmlElement::GetHtmlDomNode(CIEHtmlDomNode **ppHtmlDomNode)
{
if (ppHtmlDomNode == NULL)
return E_FAIL;
*ppHtmlDomNode = NULL;
IHTMLDOMNode* pHtmlNode = NULL;
// This causes an AddRef on outer unknown:
HRESULT hr = m_pNodeAgg->QueryInterface(__uuidof(IHTMLDOMNode), (void**)&pHtmlNode);
*ppHtmlDomNode = (CIEHtmlDomNode*)pHtmlNode;
return hr;
}
HRESULT CIEHtmlElement::SetDOMNode(nsIDOMNode *pDomNode)
{
mDOMNode = pDomNode;
// Forward to aggregated object:
CIEHtmlDomNode *pHtmlDomNode;
GetHtmlDomNode(&pHtmlDomNode);
HRESULT hr = pHtmlDomNode->SetDOMNode(pDomNode);
// Release on outer unknown because GetHtmlDomNode does AddRef on it:
GetControllingUnknown()->Release();
return hr;
}
HRESULT CIEHtmlElement::SetParent(CNode *pParent)
{
CNode::SetParent(pParent);
// Forward to aggregated object:
CIEHtmlDomNode *pHtmlDomNode;
GetHtmlDomNode(&pHtmlDomNode);
HRESULT hr = pHtmlDomNode->SetParent(pParent);
// Release on outer unknown because GetHtmlDomNode does AddRef on it:
GetControllingUnknown()->Release();
return hr;
}
///////////////////////////////////////////////////////////////////////////////
// IHTMLElement implementation
HRESULT STDMETHODCALLTYPE CIEHtmlElement::setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags)
{
if (strAttributeName == NULL)
{
return E_INVALIDARG;
}
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mDOMNode);
if (!element)
{
return E_UNEXPECTED;
}
// Get the name from the BSTR
USES_CONVERSION;
nsAutoString name(OLE2W(strAttributeName));
// Get the value from the variant
CComVariant vValue;
if (FAILED(vValue.ChangeType(VT_BSTR, &AttributeValue)))
{
return E_INVALIDARG;
}
// Set the attribute
nsAutoString value(OLE2W(vValue.bstrVal));
element->SetAttribute(name, value);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT __RPC_FAR *AttributeValue)
{
if (strAttributeName == NULL)
{
return E_INVALIDARG;
}
if (AttributeValue == NULL)
{
return E_INVALIDARG;
}
VariantInit(AttributeValue);
// Get the name from the BSTR
USES_CONVERSION;
nsAutoString name(OLE2W(strAttributeName));
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mDOMNode);
if (!element)
{
return E_UNEXPECTED;
}
BOOL bCaseSensitive = (lFlags == VARIANT_TRUE) ? TRUE : FALSE;
// Get the attribute
nsAutoString value;
nsresult rv = element->GetAttribute(name, value);
if (NS_SUCCEEDED(rv))
{
USES_CONVERSION;
AttributeValue->vt = VT_BSTR;
AttributeValue->bstrVal = SysAllocString(W2COLE(value.get()));
return S_OK;
}
else
{
return S_FALSE;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::removeAttribute(BSTR strAttributeName, LONG lFlags, VARIANT_BOOL __RPC_FAR *pfSuccess)
{
if (strAttributeName == NULL)
{
return E_INVALIDARG;
}
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mDOMNode);
if (!element)
{
return E_UNEXPECTED;
}
BOOL bCaseSensitive = (lFlags == VARIANT_TRUE) ? TRUE : FALSE;
// Get the name from the BSTR
USES_CONVERSION;
nsAutoString name(OLE2W(strAttributeName));
// Remove the attribute
nsresult nr = element->RemoveAttribute(name);
BOOL bRemoved = (nr == NS_OK) ? TRUE : FALSE;
if (pfSuccess)
{
*pfSuccess = (bRemoved) ? VARIANT_TRUE : VARIANT_FALSE;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_className(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_className(BSTR __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
VARIANT vValue;
VariantInit(&vValue);
BSTR bstrName = SysAllocString(OLESTR("class"));
getAttribute(bstrName, FALSE, &vValue);
SysFreeString(bstrName);
*p = vValue.bstrVal;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_id(BSTR v)
{
nsCOMPtr<nsIDOMHTMLElement> domHtmlElmt = do_QueryInterface(mDOMNode);
if (!domHtmlElmt)
return E_UNEXPECTED;
USES_CONVERSION;
nsDependentString strID(OLE2CW(v));
if (FAILED(domHtmlElmt->SetId(strID)))
return E_FAIL;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_id(BSTR __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
VARIANT vValue;
VariantInit(&vValue);
BSTR bstrName = SysAllocString(OLESTR("id"));
getAttribute(bstrName, FALSE, &vValue);
SysFreeString(bstrName);
*p = vValue.bstrVal;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_tagName(BSTR __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mDOMNode);
if (!element)
{
return E_UNEXPECTED;
}
nsAutoString tagName;
element->GetTagName(tagName);
USES_CONVERSION;
*p = SysAllocString(W2COLE(tagName.get()));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
if (mParent)
{
CIEHtmlElement *pElt = static_cast<CIEHtmlElement *>(mParent);
pElt->QueryInterface(IID_IHTMLElement, (void **) p);
}
else
{
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(parentNode);
if (domElement)
{
CComPtr<IUnknown> pNode;
HRESULT hr = CIEHtmlDomNode::FindOrCreateFromDOMNode(parentNode, &pNode);
if (FAILED(hr))
return hr;
if (FAILED(pNode->QueryInterface(IID_IHTMLElement, (void **) p)))
return E_UNEXPECTED;
}
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_style(IHTMLStyle __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onhelp(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onhelp(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onclick(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onclick(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondblclick(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondblclick(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeydown(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeydown(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeyup(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeyup(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onkeypress(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onkeypress(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseout(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseout(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseover(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseover(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmousemove(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmousemove(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmousedown(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmousedown(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onmouseup(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onmouseup(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_document(IDispatch __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_title(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_title(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_language(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_language(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onselectstart(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onselectstart(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::scrollIntoView(VARIANT varargStart)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::contains(IHTMLElement __RPC_FAR *pChild, VARIANT_BOOL __RPC_FAR *pfResult)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_sourceIndex(long __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_recordNumber(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_lang(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_lang(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetLeft(long __RPC_FAR *p)
{
nsCOMPtr<nsIDOMNSHTMLElement> nodeAsHTMLElement = do_QueryInterface(mDOMNode);
if (!nodeAsHTMLElement)
{
return E_NOINTERFACE;
}
PRInt32 nData;
nodeAsHTMLElement->GetOffsetLeft(&nData);
*p = nData;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetTop(long __RPC_FAR *p)
{
nsCOMPtr<nsIDOMNSHTMLElement> nodeAsHTMLElement = do_QueryInterface(mDOMNode);
if (!nodeAsHTMLElement)
{
return E_NOINTERFACE;
}
PRInt32 nData;
nodeAsHTMLElement->GetOffsetTop(&nData);
*p = nData;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetWidth(long __RPC_FAR *p)
{
nsCOMPtr<nsIDOMNSHTMLElement> nodeAsHTMLElement = do_QueryInterface(mDOMNode);
if (!nodeAsHTMLElement)
{
return E_NOINTERFACE;
}
PRInt32 nData;
nodeAsHTMLElement->GetOffsetWidth(&nData);
*p = nData;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetHeight(long __RPC_FAR *p)
{
nsCOMPtr<nsIDOMNSHTMLElement> nodeAsHTMLElement = do_QueryInterface(mDOMNode);
if (!nodeAsHTMLElement)
{
return E_NOINTERFACE;
}
PRInt32 nData;
nodeAsHTMLElement->GetOffsetHeight(&nData);
*p = nData;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_offsetParent(IHTMLElement __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerHTML(BSTR v)
{
nsCOMPtr<nsIDOMNSHTMLElement> elementHTML = do_QueryInterface(mDOMNode);
if (!elementHTML)
{
return E_UNEXPECTED;
}
USES_CONVERSION;
nsAutoString innerHTML(OLE2W(v));
elementHTML->SetInnerHTML(innerHTML);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerHTML(BSTR __RPC_FAR *p)
{
nsCOMPtr<nsIDOMNSHTMLElement> elementHTML = do_QueryInterface(mDOMNode);
if (!elementHTML)
{
return E_UNEXPECTED;
}
nsAutoString innerHTML;
elementHTML->GetInnerHTML(innerHTML);
USES_CONVERSION;
*p = SysAllocString(W2COLE(innerHTML.get()));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_innerText(BSTR v)
{
nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(mDOMNode);
if (!node)
{
return E_UNEXPECTED;
}
USES_CONVERSION;
nsAutoString innerText(OLE2W(v));
node->SetTextContent(innerText);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_innerText(BSTR __RPC_FAR *p)
{
nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(mDOMNode);
if (!node)
{
return E_UNEXPECTED;
}
nsAutoString innerText;
node->GetTextContent(innerText);
USES_CONVERSION;
*p = SysAllocString(W2COLE(innerText.get()));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_outerHTML(BSTR v)
{
nsresult rv;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDOMRange> domRange;
nsCOMPtr<nsIDOMDocumentFragment> domDocFragment;
mDOMNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMDocumentRange> domDocRange = do_QueryInterface(domDoc);
if (!domDocRange)
return E_FAIL;
domDocRange->CreateRange(getter_AddRefs(domRange));
if (!domRange)
return E_FAIL;
if (domRange->SetStartBefore(mDOMNode))
return E_FAIL;
if (domRange->DeleteContents())
return E_FAIL;
nsAutoString outerHTML(OLE2W(v));
nsCOMPtr<nsIDOMNSRange> domNSRange = do_QueryInterface(domRange);
rv = domNSRange->CreateContextualFragment(outerHTML, getter_AddRefs(domDocFragment));
if (!domDocFragment)
return E_FAIL;
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
nsCOMPtr<nsIDOMNode> domNode;
parentNode->ReplaceChild(domDocFragment, mDOMNode, getter_AddRefs(domNode));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_outerHTML(BSTR __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
nsresult rv;
nsAutoString outerHTML;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocumentEncoder> docEncoder;
nsCOMPtr<nsIDOMRange> domRange;
mDOMNode->GetOwnerDocument(getter_AddRefs(domDoc));
if (!domDoc)
return E_FAIL;
docEncoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/html");
NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
docEncoder->Init(domDoc, NS_LITERAL_STRING("text/html"),
nsIDocumentEncoder::OutputEncodeBasicEntities);
nsCOMPtr<nsIDOMDocumentRange> domDocRange = do_QueryInterface(domDoc);
if (!domDocRange)
return E_FAIL;
domDocRange->CreateRange(getter_AddRefs(domRange));
if (!domRange)
return E_FAIL;
rv = domRange->SelectNode(mDOMNode);
NS_ENSURE_SUCCESS(rv, rv);
docEncoder->SetRange(domRange);
docEncoder->EncodeToString(outerHTML);
USES_CONVERSION;
*p = SysAllocString(W2COLE(outerHTML.get()));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_outerText(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_outerText(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::insertAdjacentHTML(BSTR where, BSTR html)
{
nsresult rv;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDOMRange> domRange;
nsCOMPtr<nsIDOMDocumentFragment> domDocFragment;
NS_ASSERTION(mDOMNode, "");
//Create a range:
mDOMNode->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMDocumentRange> domDocRange = do_QueryInterface(domDoc);
if (!domDocRange)
return E_FAIL;
domDocRange->CreateRange(getter_AddRefs(domRange));
if (!domRange)
return E_FAIL;
// Must position range first before calling CreateContextualFragment:
if (domRange->SetStartBefore(mDOMNode))
return E_FAIL;
USES_CONVERSION;
// Create doc fragment:
nsDependentString strAdjacentHTML(OLE2CW(html));
nsCOMPtr<nsIDOMNSRange> domNSRange = do_QueryInterface(domRange);
domNSRange->CreateContextualFragment(strAdjacentHTML, getter_AddRefs(domDocFragment));
if (!domDocFragment)
return E_FAIL;
if (_wcsicmp(OLE2CW(where), L"beforeBegin") == 0)
{
// Insert fragment immediately before us:
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
nsCOMPtr<nsIDOMNode> dummyNode;
rv = parentNode->InsertBefore(domDocFragment, mDOMNode, getter_AddRefs(dummyNode));
return SUCCEEDED(rv)? S_OK: E_FAIL;
}
if (_wcsicmp(OLE2CW(where), L"afterEnd") == 0)
{
// Insert fragment immediately after us:
nsCOMPtr<nsIDOMNode> parentNode;
mDOMNode->GetParentNode(getter_AddRefs(parentNode));
nsCOMPtr<nsIDOMNode> dummyNode;
nsCOMPtr<nsIDOMNode> nextNode;
mDOMNode->GetNextSibling(getter_AddRefs(nextNode));
if (nextNode)
{
// Insert immediately before next node:
rv = parentNode->InsertBefore(domDocFragment, nextNode, getter_AddRefs(dummyNode));
}
else
{
// We are the last child, insert after us:
rv = parentNode->AppendChild(domDocFragment, getter_AddRefs(dummyNode));
}
return SUCCEEDED(rv)? S_OK: E_FAIL;
}
if (_wcsicmp(OLE2CW(where), L"afterBegin") == 0)
{
// Insert fragment immediately before first child:
nsCOMPtr<nsIDOMNode> firstChildNode;
mDOMNode->GetFirstChild(getter_AddRefs(firstChildNode));
if (!firstChildNode)
return E_FAIL; // IE fails when inserting into a tag that has no childs
nsCOMPtr<nsIDOMNode> dummyNode;
rv = mDOMNode->InsertBefore(domDocFragment, firstChildNode, getter_AddRefs(dummyNode));
return SUCCEEDED(rv)? S_OK: E_FAIL;
}
if (_wcsicmp(OLE2CW(where), L"beforeEnd") == 0)
{
// Insert fragment immediately as last child:
nsCOMPtr<nsIDOMNode> dummyNode;
rv = mDOMNode->AppendChild(domDocFragment, getter_AddRefs(dummyNode));
return SUCCEEDED(rv)? S_OK: E_FAIL;
}
return E_INVALIDARG;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::insertAdjacentText(BSTR where, BSTR text)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_parentTextEdit(IHTMLElement __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_isTextEdit(VARIANT_BOOL __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::click(void)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_filters(IHTMLFiltersCollection __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondragstart(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondragstart(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::toString(BSTR __RPC_FAR *String)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onbeforeupdate(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onbeforeupdate(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onafterupdate(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onafterupdate(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onerrorupdate(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onerrorupdate(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onrowexit(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onrowexit(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onrowenter(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onrowenter(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondatasetchanged(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondatasetchanged(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondataavailable(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondataavailable(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_ondatasetcomplete(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_ondatasetcomplete(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::put_onfilterchange(VARIANT v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_onfilterchange(VARIANT __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_children(IDispatch __RPC_FAR *__RPC_FAR *p)
{
// Validate parameters
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
// Create a collection representing the children of this node
CIEHtmlElementCollectionInstance *pCollection = NULL;
HRESULT hr = GetChildren(&pCollection);
if (SUCCEEDED(hr))
{
*p = pCollection;
}
return hr;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElement::get_all(IDispatch __RPC_FAR *__RPC_FAR *p)
{
// Validate parameters
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
// TODO get ALL contained elements, not just the immediate children
CIEHtmlElementCollectionInstance *pCollection = NULL;
CIEHtmlElementCollection::CreateFromParentNode(this, TRUE, (CIEHtmlElementCollection **) &pCollection);
if (pCollection)
{
pCollection->AddRef();
*p = pCollection;
}
return S_OK;
}

Просмотреть файл

@ -0,0 +1,173 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLELEMENT_H
#define IEHTMLELEMENT_H
#include "IEHtmlNode.h"
#include "IEHtmlElementCollection.h"
class CIEHtmlElement :
public CNode,
public IDispatchImpl<IHTMLElement, &IID_IHTMLElement, &LIBID_MSHTML>
{
public:
DECLARE_AGGREGATABLE(CIEHtmlElement)
CIEHtmlElement();
HRESULT FinalConstruct( );
void FinalRelease( );
DECLARE_GET_CONTROLLING_UNKNOWN()
protected:
virtual ~CIEHtmlElement();
public:
BEGIN_COM_MAP(CIEHtmlElement)
COM_INTERFACE_ENTRY2(IDispatch, IHTMLElement)
COM_INTERFACE_ENTRY(IHTMLElement)
COM_INTERFACE_ENTRY_AGGREGATE(__uuidof(IHTMLDOMNode), m_pNodeAgg)
END_COM_MAP()
virtual HRESULT GetChildren(CIEHtmlElementCollectionInstance **ppCollection);
virtual HRESULT GetHtmlDomNode(CIEHtmlDomNode **ppHtmlDomNode);
virtual HRESULT SetDOMNode(nsIDOMNode *pDomNode);
virtual HRESULT SetParent(CNode *pParent);
// Implementation of IHTMLElement
virtual HRESULT STDMETHODCALLTYPE setAttribute(BSTR strAttributeName, VARIANT AttributeValue, LONG lFlags);
virtual HRESULT STDMETHODCALLTYPE getAttribute(BSTR strAttributeName, LONG lFlags, VARIANT __RPC_FAR *AttributeValue);
virtual HRESULT STDMETHODCALLTYPE removeAttribute(BSTR strAttributeName, LONG lFlags, VARIANT_BOOL __RPC_FAR *pfSuccess);
virtual HRESULT STDMETHODCALLTYPE put_className(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_className(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_id(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_id(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_tagName(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_style(IHTMLStyle __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onhelp(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onhelp(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onclick(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onclick(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondblclick(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondblclick(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeydown(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeydown(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeyup(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeyup(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeypress(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeypress(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseout(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseout(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseover(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseover(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmousemove(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmousemove(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmousedown(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmousedown(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseup(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseup(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_document(IDispatch __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_title(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_title(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_language(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_language(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onselectstart(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onselectstart(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE scrollIntoView(VARIANT varargStart);
virtual HRESULT STDMETHODCALLTYPE contains(IHTMLElement __RPC_FAR *pChild, VARIANT_BOOL __RPC_FAR *pfResult);
virtual HRESULT STDMETHODCALLTYPE get_sourceIndex(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_recordNumber(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_lang(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_lang(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_offsetLeft(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_offsetTop(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_offsetWidth(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_offsetHeight(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_offsetParent(IHTMLElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_innerHTML(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_innerHTML(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_innerText(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_innerText(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_outerHTML(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_outerHTML(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_outerText(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_outerText(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE insertAdjacentHTML(BSTR where, BSTR html);
virtual HRESULT STDMETHODCALLTYPE insertAdjacentText(BSTR where, BSTR text);
virtual HRESULT STDMETHODCALLTYPE get_parentTextEdit(IHTMLElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_isTextEdit(VARIANT_BOOL __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE click(void);
virtual HRESULT STDMETHODCALLTYPE get_filters(IHTMLFiltersCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondragstart(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondragstart(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE toString(BSTR __RPC_FAR *String);
virtual HRESULT STDMETHODCALLTYPE put_onbeforeupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onbeforeupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onafterupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onafterupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onerrorupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onerrorupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onrowexit(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onrowexit(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onrowenter(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onrowenter(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondatasetchanged(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondatasetchanged(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondataavailable(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondataavailable(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondatasetcomplete(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondatasetcomplete(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onfilterchange(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onfilterchange(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_children(IDispatch __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_all(IDispatch __RPC_FAR *__RPC_FAR *p);
protected:
IUnknown* m_pNodeAgg;
};
#define CIEHTMLELEMENT_INTERFACES \
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLElement) \
COM_INTERFACE_ENTRY_IID(IID_IHTMLElement, IHTMLElement)
typedef CComObject<CIEHtmlElement> CIEHtmlElementInstance;
#endif

Просмотреть файл

@ -0,0 +1,723 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMTreeWalker.h"
#include "nsIDOMNodeFilter.h"
#include "nsIDOMDocument.h"
#include "nsIDOMHtmlElement.h"
#include "IEHtmlElement.h"
#include "IEHtmlElementCollection.h"
CIEHtmlElementCollection::CIEHtmlElementCollection()
{
mNodeList = NULL;
mNodeListCount = 0;
mNodeListCapacity = 0;
}
CIEHtmlElementCollection::~CIEHtmlElementCollection()
{
// Clean the node list
if (mNodeList)
{
for (PRUint32 i = 0; i < mNodeListCount; i++)
{
IDispatch *pDisp = mNodeList[i];
if (pDisp)
{
pDisp->Release();
}
}
free(mNodeList);
mNodeList = NULL;
mNodeListCount = 0;
mNodeListCapacity = 0;
}
}
HRESULT CIEHtmlElementCollection::FindOrCreateIEElement(nsIDOMNode* domNode, IHTMLElement** pIHtmlElement)
{
CComPtr<IUnknown> pNode;
HRESULT hr = CIEHtmlDomNode::FindOrCreateFromDOMNode(domNode, &pNode);
if (FAILED(hr))
return hr;
if (FAILED(pNode->QueryInterface(IID_IHTMLElement, (void**)pIHtmlElement)))
return E_UNEXPECTED;
return S_OK;
}
HRESULT CIEHtmlElementCollection::PopulateFromDOMHTMLCollection(nsIDOMHTMLCollection *pNodeList)
{
if (pNodeList == nsnull)
{
return S_OK;
}
// Recurse through the children of the node (and the children of that)
// to populate the collection
// Iterate through items in list
PRUint32 length = 0;
pNodeList->GetLength(&length);
for (PRUint32 i = 0; i < length; i++)
{
// Get the next item from the list
nsCOMPtr<nsIDOMNode> childNode;
pNodeList->Item(i, getter_AddRefs(childNode));
if (!childNode)
{
// Empty node (unexpected, but try and carry on anyway)
NS_ERROR("Empty node");
continue;
}
// Skip nodes representing, text, attributes etc.
PRUint16 nodeType;
childNode->GetNodeType(&nodeType);
if (nodeType != nsIDOMNode::ELEMENT_NODE)
{
continue;
}
// Create an equivalent IE element
CComQIPtr<IHTMLElement> pHtmlElement;
HRESULT hr = FindOrCreateIEElement(childNode, &pHtmlElement);
if (FAILED(hr))
return hr;
AddNode(pHtmlElement);
}
return S_OK;
}
HRESULT CIEHtmlElementCollection::PopulateFromDOMNode(nsIDOMNode *aDOMNode, BOOL bRecurseChildren)
{
if (aDOMNode == nsnull)
{
NS_ERROR("No dom node");
return E_INVALIDARG;
}
PRBool hasChildNodes = PR_FALSE;
aDOMNode->HasChildNodes(&hasChildNodes);
if (hasChildNodes)
{
if (bRecurseChildren)
{
nsresult rv;
// Search through parent nodes, looking for the DOM document
nsCOMPtr<nsIDOMNode> docAsNode = aDOMNode;
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(aDOMNode);
while (!doc) {
nsCOMPtr<nsIDOMNode> parentNode;
docAsNode->GetParentNode(getter_AddRefs(parentNode));
docAsNode = parentNode;
if (!docAsNode)
{
return E_FAIL;
}
doc = do_QueryInterface(docAsNode);
}
// Walk the DOM
nsCOMPtr<nsIDOMDocumentTraversal> trav = do_QueryInterface(doc, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMTreeWalker> walker;
rv = trav->CreateTreeWalker(aDOMNode,
nsIDOMNodeFilter::SHOW_ELEMENT,
nsnull, PR_TRUE, getter_AddRefs(walker));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
// We're not interested in the document node, so we always start
// with the next one, walking through them all to make the collection
nsCOMPtr<nsIDOMNode> currentNode;
walker->FirstChild(getter_AddRefs(currentNode));
while (currentNode)
{
// Create an equivalent IE element
CComQIPtr<IHTMLElement> pHtmlElement;
HRESULT hr = FindOrCreateIEElement(currentNode, &pHtmlElement);
if (FAILED(hr))
return hr;
AddNode(pHtmlElement);
walker->NextNode(getter_AddRefs(currentNode));
}
}
else
{
nsCOMPtr<nsIDOMNodeList> nodeList;
aDOMNode->GetChildNodes(getter_AddRefs(nodeList));
mDOMNodeList = nodeList;
}
}
return S_OK;
}
HRESULT CIEHtmlElementCollection::CreateFromDOMHTMLCollection(CNode *pParentNode, nsIDOMHTMLCollection *pNodeList, CIEHtmlElementCollection **pInstance)
{
if (pInstance == NULL || pParentNode == NULL)
{
NS_ERROR("No instance or parent node");
return E_INVALIDARG;
}
// Get the DOM node from the parent node
if (!pParentNode->mDOMNode)
{
NS_ERROR("Parent has no DOM node");
return E_INVALIDARG;
}
*pInstance = NULL;
// Create a collection object
CIEHtmlElementCollectionInstance *pCollection = NULL;
CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
if (pCollection == NULL)
{
NS_ERROR("Could not create collection");
return E_OUTOFMEMORY;
}
// Initialise and populate the collection
pCollection->SetParent(pParentNode);
pCollection->PopulateFromDOMHTMLCollection(pNodeList);
*pInstance = pCollection;
return S_OK;
}
HRESULT CIEHtmlElementCollection::CreateFromParentNode(CNode *pParentNode, BOOL bRecurseChildren, CIEHtmlElementCollection **pInstance)
{
if (pInstance == NULL || pParentNode == NULL)
{
NS_ERROR("No instance or parent node");
return E_INVALIDARG;
}
// Get the DOM node from the parent node
if (!pParentNode->mDOMNode)
{
NS_ERROR("Parent has no DOM node");
return E_INVALIDARG;
}
*pInstance = NULL;
// Create a collection object
CIEHtmlElementCollectionInstance *pCollection = NULL;
CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
if (pCollection == NULL)
{
NS_ERROR("Could not create collection");
return E_OUTOFMEMORY;
}
// Initialise and populate the collection
pCollection->SetParent(pParentNode);
pCollection->PopulateFromDOMNode(pParentNode->mDOMNode, bRecurseChildren);
*pInstance = pCollection;
return S_OK;
}
HRESULT CIEHtmlElementCollection::AddNode(IDispatch *pNode)
{
if (pNode == NULL)
{
NS_ERROR("No node");
return E_INVALIDARG;
}
const PRUint32 c_NodeListResizeBy = 100;
if (mNodeList == NULL)
{
mNodeListCapacity = c_NodeListResizeBy;
mNodeList = (IDispatch **) malloc(sizeof(IDispatch *) * mNodeListCapacity);
mNodeListCount = 0;
}
else if (mNodeListCount == mNodeListCapacity)
{
mNodeListCapacity += c_NodeListResizeBy;
mNodeList = (IDispatch **) realloc(mNodeList, sizeof(IDispatch *) * mNodeListCapacity);
}
if (mNodeList == NULL)
{
NS_ERROR("Could not realloc node list");
return E_OUTOFMEMORY;
}
pNode->AddRef();
mNodeList[mNodeListCount++] = pNode;
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IHTMLElementCollection methods
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::toString(BSTR __RPC_FAR *String)
{
if (String == NULL)
{
return E_INVALIDARG;
}
*String = SysAllocString(OLESTR("ElementCollection"));
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::put_length(long v)
{
// What is the point of this method?
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::get_length(long __RPC_FAR *p)
{
if (p == NULL)
{
return E_INVALIDARG;
}
// Return the size of the collection
if (mDOMNodeList)
{
// Count the number of elements in the list
PRUint32 elementCount = 0;
PRUint32 length = 0;
mDOMNodeList->GetLength(&length);
for (PRUint32 i = 0; i < length; i++)
{
// Get the next item from the list
nsCOMPtr<nsIDOMNode> childNode;
mDOMNodeList->Item(i, getter_AddRefs(childNode));
if (!childNode)
{
// Empty node (unexpected, but try and carry on anyway)
NS_ERROR("Empty node");
continue;
}
// Only count elements
PRUint16 nodeType;
childNode->GetNodeType(&nodeType);
if (nodeType == nsIDOMNode::ELEMENT_NODE)
{
elementCount++;
}
}
*p = elementCount;
}
else
{
*p = mNodeListCount;
}
return S_OK;
}
typedef CComObject<CComEnum<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _Copy<VARIANT> > > CComEnumVARIANT;
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::get__newEnum(IUnknown __RPC_FAR *__RPC_FAR *p)
{
TRACE_METHOD(CIEHtmlElementCollection::get__newEnum);
if (p == NULL)
{
return E_INVALIDARG;
}
*p = NULL;
// Create a new IEnumVARIANT object
CComEnumVARIANT *pEnumVARIANT = NULL;
CComEnumVARIANT::CreateInstance(&pEnumVARIANT);
if (pEnumVARIANT == NULL)
{
NS_ERROR("Could not creat Enum");
return E_OUTOFMEMORY;
}
int nObject = 0;
long nObjects = 0;
get_length(&nObjects);
// Create an array of VARIANTs
VARIANT *avObjects = new VARIANT[nObjects];
if (avObjects == NULL)
{
NS_ERROR("Could not create variant array");
return E_OUTOFMEMORY;
}
if (mDOMNodeList)
{
// Fill the variant array with elements from the DOM node list
PRUint32 length = 0;
mDOMNodeList->GetLength(&length);
for (PRUint32 i = 0; i < length; i++)
{
// Get the next item from the list
nsCOMPtr<nsIDOMNode> childNode;
mDOMNodeList->Item(i, getter_AddRefs(childNode));
if (!childNode)
{
// Empty node (unexpected, but try and carry on anyway)
NS_ERROR("Could not get node");
continue;
}
// Skip nodes representing, text, attributes etc.
PRUint16 nodeType;
childNode->GetNodeType(&nodeType);
if (nodeType != nsIDOMNode::ELEMENT_NODE)
{
continue;
}
// Store the element in the array
CComQIPtr<IHTMLElement> pHtmlElement;
HRESULT hr = FindOrCreateIEElement(childNode, &pHtmlElement);
if (FAILED(hr))
return hr;
VARIANT *pVariant = &avObjects[nObject++];
VariantInit(pVariant);
pVariant->vt = VT_DISPATCH;
pHtmlElement->QueryInterface(IID_IDispatch, (void **) &pVariant->pdispVal);
}
}
else
{
// Copy the contents of the collection to the array
for (nObject = 0; nObject < nObjects; nObject++)
{
VARIANT *pVariant = &avObjects[nObject];
IDispatch *pDispObject = mNodeList[nObject];
VariantInit(pVariant);
pVariant->vt = VT_DISPATCH;
pVariant->pdispVal = pDispObject;
pDispObject->AddRef();
}
}
// Copy the variants to the enumeration object
pEnumVARIANT->Init(&avObjects[0], &avObjects[nObjects], NULL, AtlFlagCopy);
// Cleanup the array
for (nObject = 0; nObject < nObjects; nObject++)
{
VARIANT *pVariant = &avObjects[nObject];
VariantClear(pVariant);
}
delete []avObjects;
return pEnumVARIANT->QueryInterface(IID_IUnknown, (void**) p);
}
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::item(VARIANT name, VARIANT index, IDispatch __RPC_FAR *__RPC_FAR *pdisp)
{
TRACE_METHOD(CIEHtmlElementCollection::item);
if (pdisp == NULL)
{
return E_INVALIDARG;
}
*pdisp = NULL;
// Parameter name is either a string or a number
PRBool searchForName = PR_FALSE;
nsAutoString nameToSearch;
PRInt32 idxForSearch = 0;
if (name.vt == VT_BSTR && name.bstrVal && wcslen(name.bstrVal) > 0)
{
nameToSearch.Assign(name.bstrVal);
searchForName = PR_TRUE;
}
else switch (name.vt)
{
case VT_UI1:
case VT_UI2:
case VT_UI4:
case VT_I1:
case VT_I2:
case VT_I1 | VT_BYREF:
case VT_I2 | VT_BYREF:
// Coerce the variant into a long
if (FAILED(VariantChangeType(&name, &name, 0, VT_I4)))
{
return E_INVALIDARG;
}
// Fall through
case VT_I4:
idxForSearch = name.lVal;
if (idxForSearch < 0)
return E_INVALIDARG;
break;
default:
// Unknown arg.
// As per documentation, no attempt to be lenient with crappy clients
// for the time being.
return E_INVALIDARG;
}
CIEHtmlElementCollectionInstance* pCollection = NULL;
if (mDOMNodeList)
{
CComQIPtr<IHTMLElement> pHtmlElement;
// Search for the Nth element in the list
PRUint32 elementCount = 0;
PRUint32 length = 0;
mDOMNodeList->GetLength(&length);
for (PRUint32 i = 0; i < length; i++)
{
// Get the next item from the list
nsCOMPtr<nsIDOMNode> childNode;
mDOMNodeList->Item(i, getter_AddRefs(childNode));
if (!childNode)
{
// Empty node (unexpected, but try and carry on anyway)
NS_ERROR("Could not get node");
continue;
}
// Skip nodes representing, text, attributes etc.
nsCOMPtr<nsIDOMElement> nodeAsElement = do_QueryInterface(childNode);
if (!nodeAsElement)
{
continue;
}
// Have we found the element we need?
PRBool grabThisNode = PR_FALSE;
if (searchForName)
{
nsCOMPtr<nsIDOMHTMLElement> nodeAsHtmlElement = do_QueryInterface(childNode);
if (nodeAsHtmlElement)
{
NS_NAMED_LITERAL_STRING(nameAttr, "name");
nsAutoString nodeName;
nsAutoString nodeId;
nodeAsHtmlElement->GetAttribute(nameAttr, nodeName);
nodeAsHtmlElement->GetId(nodeId);
if (nodeName.Equals(nameToSearch) || nodeId.Equals(nameToSearch))
{
grabThisNode = PR_TRUE;
}
}
}
else if (elementCount == idxForSearch)
{
grabThisNode = PR_TRUE;
}
if (grabThisNode)
{
if (pHtmlElement)
{
if (pCollection == NULL)
CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
// Add existing to collection
pCollection->AddNode(pHtmlElement);
}
// Create new element:
HRESULT hr = FindOrCreateIEElement(childNode, &pHtmlElement);
if (FAILED(hr))
return hr;
((CIEHtmlElement*)pHtmlElement.p)->SetParent(mParent);
}
elementCount++;
}
// Return the element or collection :
if (pCollection != NULL)
{
// Add last created element to collection
pCollection->AddNode(pHtmlElement);
pCollection->QueryInterface(IID_IDispatch, (void **) pdisp);
}
else if (pHtmlElement != NULL)
pHtmlElement->QueryInterface(IID_IDispatch, (void **) pdisp);
}
else
{
if (searchForName)
{
CComPtr<IHTMLElement> element = NULL;
for (PRUint32 i = 0; i < mNodeListCount; i++)
{
CComQIPtr<IHTMLElement> currElement = mNodeList[i];
if (currElement.p)
{
CComVariant elementName;
CComBSTR elementId;
currElement->get_id(&elementId);
currElement->getAttribute(L"name", 0, &elementName);
if ((elementId && wcscmp(elementId, name.bstrVal) == 0) ||
(elementName.vt == VT_BSTR && elementName.bstrVal &&
wcscmp(elementName.bstrVal, name.bstrVal) == 0))
{
if (element != NULL)
{
if (!pCollection)
CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
pCollection->AddNode(element);
}
element = currElement;
}
}
}
// Return the element or collection :
if (pCollection != NULL)
{
pCollection->AddNode(element);
pCollection->QueryInterface(IID_IDispatch, (void **) pdisp);
}
else if (element != NULL)
element->QueryInterface(IID_IDispatch, (void **) pdisp);
}
else
{
// Test for stupid values
if (idxForSearch >= mNodeListCount)
{
return E_INVALIDARG;
}
*pdisp = NULL;
IDispatch *pNode = mNodeList[idxForSearch];
if (pNode == NULL)
{
NS_ERROR("No node");
return E_UNEXPECTED;
}
pNode->QueryInterface(IID_IDispatch, (void **) pdisp);
}
}
// Note: As per docs S_OK is fine even if no node is returned
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlElementCollection::tags(VARIANT tagName, IDispatch __RPC_FAR *__RPC_FAR *pdisp)
{
if (pdisp == NULL || tagName.vt != VT_BSTR)
{
return E_INVALIDARG;
}
*pdisp = NULL;
CIEHtmlElementCollectionInstance* pCollection = NULL;
CIEHtmlElementCollectionInstance::CreateInstance(&pCollection);
if (mNodeList)
{
for (PRUint32 i = 0; i < mNodeListCount; i++)
{
CComQIPtr<IHTMLElement> element = mNodeList[i];
if (element.p)
{
CComBSTR elementTagName;
element->get_tagName(&elementTagName);
if (elementTagName && _wcsicmp(elementTagName, tagName.bstrVal) == 0)
pCollection->AddNode(element);
}
}
pCollection->QueryInterface(IID_IDispatch, (void**)pdisp);
return S_OK;
}
else if (mDOMNodeList)
{
PRUint32 length = 0;
mDOMNodeList->GetLength(&length);
for (PRUint32 i = 0; i < length; i++)
{
// Get the next item from the list
nsCOMPtr<nsIDOMNode> childNode;
mDOMNodeList->Item(i, getter_AddRefs(childNode));
if (!childNode)
{
// Empty node (unexpected, but try and carry on anyway)
NS_ERROR("Could not get node");
continue;
}
// Skip nodes representing, text, attributes etc.
nsCOMPtr<nsIDOMElement> nodeAsElement = do_QueryInterface(childNode);
if (!nodeAsElement)
{
continue;
}
nsCOMPtr<nsIDOMHTMLElement> nodeAsHtmlElement = do_QueryInterface(childNode);
if (nodeAsHtmlElement)
{
nsAutoString elementTagName;
nodeAsHtmlElement->GetTagName(elementTagName);
if (_wcsicmp(elementTagName.get(), OLE2CW(tagName.bstrVal)) == 0)
{
CComQIPtr<IHTMLElement> pHtmlElement;
HRESULT hr = FindOrCreateIEElement(childNode, &pHtmlElement);
if (FAILED(hr))
return hr;
//Add to collection :
pCollection->AddNode(pHtmlElement);
}
}
}
pCollection->QueryInterface(IID_IDispatch, (void**)pdisp);
return S_OK;
}
return E_UNEXPECTED;
}

Просмотреть файл

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLNODECOLLECTION_H
#define IEHTMLNODECOLLECTION_H
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMNodeList.h"
#include "IEHtmlNode.h"
class CIEHtmlElement;
class CIEHtmlElementCollection :
public CNode,
public IDispatchImpl<IHTMLElementCollection, &IID_IHTMLElementCollection, &LIBID_MSHTML>
{
private:
// Hold a DOM node list
nsCOMPtr<nsIDOMNodeList> mDOMNodeList;
// Or hold a static collection
IDispatch **mNodeList;
PRUint32 mNodeListCount;
PRUint32 mNodeListCapacity;
public:
CIEHtmlElementCollection();
protected:
virtual ~CIEHtmlElementCollection();
virtual HRESULT FindOrCreateIEElement(nsIDOMNode* domNode, IHTMLElement** pIHtmlElement);
public:
// Adds a node to the collection
virtual HRESULT AddNode(IDispatch *pNode);
virtual HRESULT PopulateFromDOMHTMLCollection(nsIDOMHTMLCollection *pNodeList);
// Populates the collection with items from the DOM node
virtual HRESULT PopulateFromDOMNode(nsIDOMNode *pIDOMNode, BOOL bRecurseChildren);
// Helper method creates a collection from a parent node
static HRESULT CreateFromParentNode(CNode *pParentNode, BOOL bRecurseChildren, CIEHtmlElementCollection **pInstance);
// Helper method creates a collection from the specified HTML collection
static HRESULT CreateFromDOMHTMLCollection(CNode *pParentNode, nsIDOMHTMLCollection *pNodeList, CIEHtmlElementCollection **pInstance);
BEGIN_COM_MAP(CIEHtmlElementCollection)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHTMLElementCollection)
END_COM_MAP()
// IHTMLElementCollection methods
virtual HRESULT STDMETHODCALLTYPE toString(BSTR __RPC_FAR *String);
virtual HRESULT STDMETHODCALLTYPE put_length(long v);
virtual HRESULT STDMETHODCALLTYPE get_length(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get__newEnum(IUnknown __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE item(VARIANT name, VARIANT index, IDispatch __RPC_FAR *__RPC_FAR *pdisp);
virtual HRESULT STDMETHODCALLTYPE tags(VARIANT tagName, IDispatch __RPC_FAR *__RPC_FAR *pdisp);
};
typedef CComObject<CIEHtmlElementCollection> CIEHtmlElementCollectionInstance;
#endif

Просмотреть файл

@ -0,0 +1,381 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "IEHtmlNode.h"
#include "plhash.h"
static PLHashTable *g_NodeLookupTable;
static PLHashNumber HashFunction(const void *key)
{
return (PRUint32) key;
}
PRIntn HashComparator(const void *v1, const void *v2)
{
if (v1 == v2)
{
return 1;
}
return 0;
}
CNode::CNode() :
mParent(NULL),mDOMNode(NULL)
{
}
CNode::~CNode()
{
}
HRESULT CNode::SetParent(CNode *pParent)
{
mParent = pParent;
return S_OK;
}
HRESULT CNode::FindFromDOMNode(nsIDOMNode *pIDOMNode, CNode **pNode)
{
if (pIDOMNode == nsnull)
{
return E_FAIL;
}
if (g_NodeLookupTable == NULL)
{
return E_FAIL;
}
nsCOMPtr<nsISupports> nodeAsSupports = do_QueryInterface(pIDOMNode);
*pNode = (CNode *) PL_HashTableLookup(g_NodeLookupTable, nodeAsSupports);
return S_OK;
}
HRESULT CNode::SetDOMNode(nsIDOMNode *pIDOMNode)
{
if (pIDOMNode)
{
if (g_NodeLookupTable == NULL)
{
g_NodeLookupTable = PL_NewHashTable(123, HashFunction, HashComparator, HashComparator, NULL, NULL);
}
mDOMNode = pIDOMNode;
nsCOMPtr<nsISupports> nodeAsSupports= do_QueryInterface(mDOMNode);
PL_HashTableAdd(g_NodeLookupTable, nodeAsSupports, this);
}
else if (mDOMNode)
{
// Remove the entry from the hashtable
nsCOMPtr<nsISupports> nodeAsSupports = do_QueryInterface(mDOMNode);
PL_HashTableRemove(g_NodeLookupTable, nodeAsSupports);
mDOMNode = nsnull;
if (g_NodeLookupTable->nentries == 0)
{
PL_HashTableDestroy(g_NodeLookupTable);
g_NodeLookupTable = NULL;
}
}
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// CIEHtmlDomNode methods
#include "nsIDOMHTMLButtonElement.h"
#include "nsIDOMHTMLElement.h"
#include "IEHtmlButtonElement.h"
#include "IEHtmlElement.h"
CIEHtmlDomNode::CIEHtmlDomNode()
{
}
CIEHtmlDomNode::~CIEHtmlDomNode()
{
SetDOMNode(nsnull);
}
#define CREATE_FROM_DOMNODE(nsInterface, WrapperType, errorMsg) \
nsCOMPtr<nsInterface> domNode_##nsInterface = do_QueryInterface(pIDOMNode); \
if (domNode_##nsInterface) \
{ \
WrapperType *pWrapper = NULL; \
WrapperType::CreateInstance(&pWrapper); \
if (!pWrapper) \
{ \
NS_ERROR(errorMsg); \
return E_OUTOFMEMORY; \
} \
if (FAILED(pWrapper->QueryInterface(IID_IUnknown, (void**)pNode))) \
return E_UNEXPECTED; \
pWrapper->SetDOMNode(pIDOMNode); \
return S_OK; \
}
HRESULT CIEHtmlDomNode::CreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode)
{
CREATE_FROM_DOMNODE(nsIDOMHTMLButtonElement, CIEHtmlButtonElementInstance, "")
CREATE_FROM_DOMNODE(nsIDOMHTMLElement, CIEHtmlElementInstance, "Could not create element")
CREATE_FROM_DOMNODE(nsIDOMNode, CIEHtmlDomNodeInstance, "Could not create node")
return E_FAIL;
}
HRESULT CIEHtmlDomNode::FindFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode)
{
if (pIDOMNode == nsnull)
{
return E_FAIL;
}
if (g_NodeLookupTable == NULL)
{
return E_FAIL;
}
nsCOMPtr<nsISupports> nodeAsSupports = do_QueryInterface(pIDOMNode);
*pNode = (IUnknown *) PL_HashTableLookup(g_NodeLookupTable, nodeAsSupports);
return S_OK;
}
HRESULT CIEHtmlDomNode::FindOrCreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode)
{
FindFromDOMNode(pIDOMNode,pNode);
if (*pNode)
{
(*pNode)->AddRef();
return S_OK;
}
HRESULT hr = CreateFromDOMNode(pIDOMNode, pNode);
if SUCCEEDED(hr)
return S_OK;
return hr;
}
HRESULT CIEHtmlDomNode::SetDOMNode(nsIDOMNode *pIDOMNode)
{
if (pIDOMNode)
{
if (g_NodeLookupTable == NULL)
{
g_NodeLookupTable = PL_NewHashTable(123, HashFunction, HashComparator, HashComparator, NULL, NULL);
}
mDOMNode = pIDOMNode;
nsCOMPtr<nsISupports> nodeAsSupports= do_QueryInterface(mDOMNode);
PL_HashTableAdd(g_NodeLookupTable, nodeAsSupports, (IUnknown *)this );
}
else if (mDOMNode)
{
// Remove the entry from the hashtable
nsCOMPtr<nsISupports> nodeAsSupports = do_QueryInterface(mDOMNode);
PL_HashTableRemove(g_NodeLookupTable, nodeAsSupports);
mDOMNode = nsnull;
if (g_NodeLookupTable->nentries == 0)
{
PL_HashTableDestroy(g_NodeLookupTable);
g_NodeLookupTable = NULL;
}
}
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IHTMLDOMNode methods
#define SIB_NODE_GET_NUMERIC(function,numtype) \
{ \
if (!p) return E_INVALIDARG; \
if (!mDOMNode) return E_UNEXPECTED; \
numtype nData; \
HRESULT rc = mDOMNode->function(&nData); \
*p=nData; \
return rc; \
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_nodeType(long __RPC_FAR *p)
SIB_NODE_GET_NUMERIC(GetNodeType,PRUint16)
#define SIB_NODE_GET_ELEMENT(function,fn_elt_type) \
{ \
return E_NOTIMPL; \
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_parentNode(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p)
SIB_NODE_GET_ELEMENT(GetParentNode,nsIDOMNode)
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::hasChildNodes(VARIANT_BOOL __RPC_FAR *p)
SIB_NODE_GET_NUMERIC(HasChildNodes,PRBool)
#define SIB_STD_NOTIMPL \
{ \
return E_NOTIMPL; \
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_childNodes(IDispatch __RPC_FAR *__RPC_FAR *p)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_attributes(IDispatch __RPC_FAR *__RPC_FAR *p)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::insertBefore(IHTMLDOMNode __RPC_FAR *newChild,
VARIANT refChild,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *node)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::removeChild(
IHTMLDOMNode __RPC_FAR *oldChild,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *node)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::replaceChild(
IHTMLDOMNode __RPC_FAR *newChild,
IHTMLDOMNode __RPC_FAR *oldChild,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *node)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::cloneNode(
VARIANT_BOOL fDeep,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *clonedNode)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::removeNode(
VARIANT_BOOL fDeep,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *removed)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::swapNode(
IHTMLDOMNode __RPC_FAR *otherNode,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *swappedNode)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::replaceNode(
IHTMLDOMNode __RPC_FAR *replacement,
IHTMLDOMNode __RPC_FAR *__RPC_FAR *replaced)
SIB_STD_NOTIMPL
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::appendChild(IHTMLDOMNode *newChild, IHTMLDOMNode **node)
{
if (!newChild || !node)
return E_INVALIDARG;
*node = NULL;
if (!mDOMNode)
return E_UNEXPECTED;
nsCOMPtr<nsIDOMNode> domNode;
nsresult rv = mDOMNode->AppendChild(((CIEHtmlDomNode*)newChild)->mDOMNode, getter_AddRefs(domNode));
if (NS_FAILED(rv))
return E_FAIL;
// Create com object:
CComPtr<IUnknown> pNode = NULL;
HRESULT hr = CIEHtmlDomNode::FindOrCreateFromDOMNode(domNode, &pNode);
if (FAILED(hr))
return hr;
if (FAILED(pNode->QueryInterface(__uuidof(IHTMLDOMNode), (void**)node)))
return E_UNEXPECTED;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_nodeName(BSTR __RPC_FAR *p)
{
if (!mDOMNode) return E_UNEXPECTED;
nsString szTagName;
HRESULT rc = mDOMNode->GetNodeName(szTagName);
USES_CONVERSION;
*p = SysAllocString(W2COLE(ToNewUnicode(szTagName)));
return rc;
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::put_nodeValue(VARIANT p)
{
if (!mDOMNode) return E_UNEXPECTED;
CComVariant vValue;
if (FAILED(vValue.ChangeType(VT_BSTR, &p))) {
return E_INVALIDARG;
}
nsString szValue(OLE2W(vValue.bstrVal));
if (!mDOMNode->SetNodeValue(szValue))
return E_FAIL;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_nodeValue(VARIANT __RPC_FAR *p)
{
if (p == NULL) {
return E_INVALIDARG;
}
if (!mDOMNode) return E_UNEXPECTED;
nsString szValue;
nsresult nr = mDOMNode->GetNodeValue(szValue);
if (nr == NS_OK) {
USES_CONVERSION;
p->vt = VT_BSTR;
p->bstrVal = SysAllocString(W2COLE(ToNewUnicode(szValue)));
return S_OK;
}
return E_FAIL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_firstChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p)
SIB_NODE_GET_ELEMENT(GetFirstChild,nsIDOMNode)
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_lastChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p)
SIB_NODE_GET_ELEMENT(GetLastChild,nsIDOMNode)
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_previousSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlDomNode::get_nextSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p)
{
return E_NOTIMPL;
}

Просмотреть файл

@ -0,0 +1,194 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLNODE_H
#define IEHTMLNODE_H
#include "nsCOMPtr.h"
#include "nsIDOMNode.h"
// NOTE: Nasty hack in case arcane SDK doesn't define IHTMLDOMNode
#ifndef __IHTMLDOMNode_INTERFACE_DEFINED__
#define __IHTMLDOMNode_INTERFACE_DEFINED__
MIDL_INTERFACE("3050f5da-98b5-11cf-bb82-00aa00bdce0b")
IHTMLDOMNode : public IDispatch
{
public:
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeType(
/* [out][retval] */ long *p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_parentNode(
/* [out][retval] */ IHTMLDOMNode **p) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE hasChildNodes(
/* [out][retval] */ VARIANT_BOOL *fChildren) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_childNodes(
/* [out][retval] */ IDispatch **p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
/* [out][retval] */ IDispatch **p) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE insertBefore(
/* [in] */ IHTMLDOMNode *newChild,
/* [in][optional] */ VARIANT refChild,
/* [out][retval] */ IHTMLDOMNode **node) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE removeChild(
/* [in] */ IHTMLDOMNode *oldChild,
/* [out][retval] */ IHTMLDOMNode **node) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE replaceChild(
/* [in] */ IHTMLDOMNode *newChild,
/* [in] */ IHTMLDOMNode *oldChild,
/* [out][retval] */ IHTMLDOMNode **node) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE cloneNode(
/* [in] */ VARIANT_BOOL fDeep,
/* [out][retval] */ IHTMLDOMNode **clonedNode) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE removeNode(
/* [in][defaultvalue] */ VARIANT_BOOL fDeep,
/* [out][retval] */ IHTMLDOMNode **removed) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE swapNode(
/* [in] */ IHTMLDOMNode *otherNode,
/* [out][retval] */ IHTMLDOMNode **swappedNode) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE replaceNode(
/* [in] */ IHTMLDOMNode *replacement,
/* [out][retval] */ IHTMLDOMNode **replaced) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE appendChild(
/* [in] */ IHTMLDOMNode *newChild,
/* [out][retval] */ IHTMLDOMNode **node) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeName(
/* [out][retval] */ BSTR *p) = 0;
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_nodeValue(
/* [in] */ VARIANT v) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nodeValue(
/* [out][retval] */ VARIANT *p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_firstChild(
/* [out][retval] */ IHTMLDOMNode **p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_lastChild(
/* [out][retval] */ IHTMLDOMNode **p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_previousSibling(
/* [out][retval] */ IHTMLDOMNode **p) = 0;
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_nextSibling(
/* [out][retval] */ IHTMLDOMNode **p) = 0;
};
#endif
class CNode :
public CComObjectRootEx<CComMultiThreadModel>
{
protected:
CNode();
virtual ~CNode();
public:
CNode *mParent;
nsCOMPtr<nsIDOMNode> mDOMNode;
static HRESULT FindFromDOMNode(nsIDOMNode *pIDOMNode, CNode **pNode);
virtual HRESULT SetParent(CNode *pParent);
virtual HRESULT SetDOMNode(nsIDOMNode *pIDOMNode);
};
class CIEHtmlDomNode :
public CNode,
public IDispatchImpl<IHTMLDOMNode, &__uuidof(IHTMLDOMNode), &LIBID_MSHTML>
{
public:
DECLARE_AGGREGATABLE(CIEHtmlDomNode)
CIEHtmlDomNode();
static HRESULT FindFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
static HRESULT FindOrCreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
static HRESULT CreateFromDOMNode(nsIDOMNode *pIDOMNode, IUnknown **pNode);
virtual HRESULT SetDOMNode(nsIDOMNode *pIDOMNode);
DECLARE_GET_CONTROLLING_UNKNOWN()
protected:
virtual ~CIEHtmlDomNode();
public:
BEGIN_COM_MAP(CIEHtmlDomNode)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHTMLDOMNode)
//COM_INTERFACE_ENTRY_FUNC(IID_IHTMLElement, 0, QueryInterfaceOnNode)
END_COM_MAP()
static HRESULT WINAPI QueryInterfaceOnNode(void* pv, REFIID riid, LPVOID* ppv, DWORD dw);
//IID_IHTMLDOMNode
virtual HRESULT STDMETHODCALLTYPE get_nodeType(long __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_parentNode(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE hasChildNodes(VARIANT_BOOL __RPC_FAR *fChildren);
virtual HRESULT STDMETHODCALLTYPE get_childNodes(IDispatch __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_attributes(IDispatch __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE insertBefore(IHTMLDOMNode __RPC_FAR *newChild, VARIANT refChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
virtual HRESULT STDMETHODCALLTYPE removeChild(IHTMLDOMNode __RPC_FAR *oldChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
virtual HRESULT STDMETHODCALLTYPE replaceChild(IHTMLDOMNode __RPC_FAR *newChild, IHTMLDOMNode __RPC_FAR *oldChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
virtual HRESULT STDMETHODCALLTYPE cloneNode(VARIANT_BOOL fDeep, IHTMLDOMNode __RPC_FAR *__RPC_FAR *clonedNode);
virtual HRESULT STDMETHODCALLTYPE removeNode(VARIANT_BOOL fDeep, IHTMLDOMNode __RPC_FAR *__RPC_FAR *removed);
virtual HRESULT STDMETHODCALLTYPE swapNode(IHTMLDOMNode __RPC_FAR *otherNode, IHTMLDOMNode __RPC_FAR *__RPC_FAR *swappedNode);
virtual HRESULT STDMETHODCALLTYPE replaceNode(IHTMLDOMNode __RPC_FAR *replacement, IHTMLDOMNode __RPC_FAR *__RPC_FAR *replaced);
virtual HRESULT STDMETHODCALLTYPE appendChild(IHTMLDOMNode __RPC_FAR *newChild, IHTMLDOMNode __RPC_FAR *__RPC_FAR *node);
virtual HRESULT STDMETHODCALLTYPE get_nodeName(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_nodeValue(VARIANT p);
virtual HRESULT STDMETHODCALLTYPE get_nodeValue(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_firstChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_lastChild(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_previousSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_nextSibling(IHTMLDOMNode __RPC_FAR *__RPC_FAR *p);
};
typedef CComObject<CIEHtmlDomNode> CIEHtmlDomNodeInstance;
#endif

Просмотреть файл

@ -0,0 +1,165 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "IEHtmlSelectionObject.h"
#include "IEHtmlTxtRange.h"
CIEHtmlSelectionObject::CIEHtmlSelectionObject()
{
}
CIEHtmlSelectionObject::~CIEHtmlSelectionObject()
{
}
void CIEHtmlSelectionObject::SetSelection(nsISelection *pSelection)
{
mSelection = pSelection;
}
void CIEHtmlSelectionObject::SetDOMDocumentRange(nsIDOMDocumentRange *pDOMDocumentRange) {
mDOMDocumentRange = pDOMDocumentRange;
}
HRESULT STDMETHODCALLTYPE CIEHtmlSelectionObject::createRange(IDispatch __RPC_FAR *__RPC_FAR *range)
{
if (range == NULL)
return E_INVALIDARG;
*range = NULL;
if (!mSelection)
return E_FAIL;
// get range corresponding to mSelection:
nsCOMPtr<nsIDOMRange> domRange;
int rc;
mSelection->GetRangeCount(&rc);
if (rc>0)
mSelection->GetRangeAt(0, getter_AddRefs(domRange));
else
{
// create empty range
mDOMDocumentRange->CreateRange(getter_AddRefs(domRange));
}
if (!domRange)
return E_FAIL;
// create com object:
CComBSTR strType;
get_type(&strType);
if (wcscmp(OLE2W(strType), L"Control") == 0)
{
// IHTMLControlRange:
CIEHtmlControlRangeInstance *pControlRange = NULL;
CIEHtmlControlRangeInstance::CreateInstance(&pControlRange);
if (!pControlRange)
return E_FAIL;
// gives the range to the com object:
pControlRange->SetRange(domRange);
// return com object:
pControlRange->QueryInterface(IID_IDispatch, (void **)range);
} else
{
// IHTMLTxtRange:
CIEHtmlTxtRangeInstance *pTxtRange = NULL;
CIEHtmlTxtRangeInstance::CreateInstance(&pTxtRange);
if (!pTxtRange)
return E_FAIL;
// gives the range to the com object:
pTxtRange->SetRange(domRange);
// return com object:
pTxtRange->QueryInterface(IID_IDispatch, (void **)range);
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlSelectionObject::get_type(BSTR __RPC_FAR *p)
{
static NS_NAMED_LITERAL_STRING(strText,"Text");
static NS_NAMED_LITERAL_STRING(strControl,"Control");
static NS_NAMED_LITERAL_STRING(strNone,"None");
nsCOMPtr<nsIDOMRange> domRange;
nsCOMPtr<nsIDOMNode> domNode;
if (p == NULL)
return E_INVALIDARG;
*p = NULL;
// get range corresponding to mSelection:
int rc;
mSelection->GetRangeCount(&rc);
if (rc<1) {
*p = SysAllocString(strNone.get());
return p ? S_OK : E_OUTOFMEMORY;
}
mSelection->GetRangeAt(0, getter_AddRefs(domRange));
if (!domRange)
return E_FAIL;
domRange->GetStartContainer(getter_AddRefs(domNode));
if (!domNode)
return E_FAIL;
unsigned short nodeType;
domNode->GetNodeType(&nodeType);
switch (nodeType)
{
case nsIDOMNode::ELEMENT_NODE:
*p = SysAllocString(strControl.get());
break;
case nsIDOMNode::TEXT_NODE:
*p = SysAllocString(strText.get());
break;
default:
return E_UNEXPECTED;
}
return p ? S_OK : E_OUTOFMEMORY;
}
HRESULT STDMETHODCALLTYPE CIEHtmlSelectionObject::empty()
{
if (!mSelection)
return E_FAIL;
mSelection->RemoveAllRanges();
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlSelectionObject::clear()
{
if (!mSelection)
return E_FAIL;
mSelection->DeleteFromDocument();
return S_OK;
}

Просмотреть файл

@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLSELECTIONOBJECT_H
#define IEHTMLSELECTIONOBJECT_H
#include "nsISelection.h"
#include "nsIDOMDocumentRange.h"
class CIEHtmlSelectionObject :
public IDispatchImpl<IHTMLSelectionObject, &IID_IHTMLSelectionObject, &LIBID_MSHTML>,
public CComObjectRootEx<CComMultiThreadModel>
{
public:
CIEHtmlSelectionObject();
protected:
virtual ~CIEHtmlSelectionObject();
public:
void SetSelection(nsISelection *pSelection);
void SetDOMDocumentRange(nsIDOMDocumentRange *pDOMDocumentRange);
BEGIN_COM_MAP(CIEHtmlSelectionObject)
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLSelectionObject)
COM_INTERFACE_ENTRY(IHTMLSelectionObject)
END_COM_MAP()
// Implementation of IHTMLSelectionObject
virtual HRESULT STDMETHODCALLTYPE createRange(IDispatch __RPC_FAR *__RPC_FAR *range);
virtual HRESULT STDMETHODCALLTYPE empty();
virtual HRESULT STDMETHODCALLTYPE clear();
virtual HRESULT STDMETHODCALLTYPE get_type(BSTR __RPC_FAR *p);
protected:
nsCOMPtr<nsISelection> mSelection;
// IE does not return null range when selection is empty
// so this reference allows for creating an empty range :
nsCOMPtr<nsIDOMDocumentRange> mDOMDocumentRange;
};
#define CIEHTMLSELECTIONOBJECT_INTERFACES \
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLSelectionObject \
COM_INTERFACE_ENTRY_IID(IID_IHTMLSelectionObject, IHTMLSelectionObject)
typedef CComObject<CIEHtmlSelectionObject> CIEHtmlSelectionObjectInstance;
#endif //IEHTMLSELECTIONOBJECT_H

Просмотреть файл

@ -0,0 +1,360 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "IEHtmlTxtRange.h"
#include "IEHtmlNode.h"
#include "IEHtmlElement.h"
#include "nsIDomNsRange.h"
#include "nsIDOMDocumentFragment.h"
CRange::CRange()
{
}
CRange::~CRange()
{
}
void CRange::SetRange(nsIDOMRange *pRange)
{
mRange = pRange;
}
HRESULT CRange::GetParentElement(IHTMLElement **ppParent)
{
if (ppParent == NULL)
return E_INVALIDARG;
*ppParent = NULL;
// get common ancestor property:
nsCOMPtr<nsIDOMNode> domNode;
mRange->GetCommonAncestorContainer(getter_AddRefs(domNode));
if (!domNode)
return S_OK;
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(domNode);
if (!domElement)
{
// domNode can be a nsITextNode. In this case, its parent is a nsIDOMElement:
nsCOMPtr<nsIDOMNode> parentNode;
domNode->GetParentNode(getter_AddRefs(parentNode));
domElement = do_QueryInterface(parentNode);
// Is a textrange always supposed to have a parentElement? Remove 2 lines if not:
if (!domElement)
return E_UNEXPECTED;
domNode = parentNode;
}
// get or create com object:
CComPtr<IUnknown> pNode;
HRESULT hr = CIEHtmlDomNode::FindOrCreateFromDOMNode(domNode, &pNode);
if (FAILED(hr))
return hr;
if (FAILED(pNode->QueryInterface(IID_IHTMLElement, (void **)ppParent)))
return E_UNEXPECTED;
return S_OK;
}
// CIEHtmlTxtRange
CIEHtmlTxtRange::CIEHtmlTxtRange()
{
}
CIEHtmlTxtRange::~CIEHtmlTxtRange()
{
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::pasteHTML(BSTR html)
{
nsCOMPtr<nsIDOMDocumentFragment> domDocFragment;
nsAutoString nsStrHtml(OLE2W(html));
if (NS_FAILED(mRange->DeleteContents()))
return E_FAIL;
nsCOMPtr<nsIDOMNSRange> domNSRange = do_QueryInterface(mRange);
if (!domNSRange)
return E_FAIL;
domNSRange->CreateContextualFragment(nsStrHtml, getter_AddRefs(domDocFragment));
if (!domDocFragment)
return E_FAIL;
mRange->InsertNode(domDocFragment);
mRange->Detach();
return S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::get_text(BSTR __RPC_FAR *p)
{
if (p == NULL)
return E_INVALIDARG;
*p = NULL;
nsAutoString strText;
mRange->ToString(strText);
*p = SysAllocString(strText.get());
return *p ? S_OK : E_OUTOFMEMORY;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *Parent)
{
return GetParentElement(Parent);
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::get_htmlText(BSTR __RPC_FAR *p)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::put_text(BSTR v)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::duplicate(IHTMLTxtRange __RPC_FAR *__RPC_FAR *Duplicate)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::inRange(IHTMLTxtRange __RPC_FAR *Range, VARIANT_BOOL __RPC_FAR *InRange)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::isEqual(IHTMLTxtRange __RPC_FAR *Range, VARIANT_BOOL __RPC_FAR *IsEqual)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::scrollIntoView(VARIANT_BOOL fStart/* = -1*/)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::collapse(VARIANT_BOOL Start/* = -1*/)
{
nsresult rv = mRange->Collapse(Start?PR_TRUE:PR_FALSE);
return FAILED(rv)?E_FAIL:S_OK;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::expand(BSTR Unit,VARIANT_BOOL __RPC_FAR *Success)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::move(BSTR Unit, long Count, long __RPC_FAR *ActualCount)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::moveStart(BSTR Unit, long Count, long __RPC_FAR *ActualCount)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::moveEnd(BSTR Unit, long Count, long __RPC_FAR *ActualCount)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::select( void)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::moveToElementText(IHTMLElement __RPC_FAR *element)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::setEndPoint(BSTR how, IHTMLTxtRange __RPC_FAR *SourceRange)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::compareEndPoints(BSTR how, IHTMLTxtRange __RPC_FAR *SourceRange, long __RPC_FAR *ret)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::findText(BSTR String, long count, long Flags, VARIANT_BOOL __RPC_FAR *Success)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::moveToPoint(long x, long y)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::getBookmark(BSTR __RPC_FAR *Boolmark)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::moveToBookmark(BSTR Bookmark, VARIANT_BOOL __RPC_FAR *Success)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlTxtRange::execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
// IHTMLControlRange
CIEHtmlControlRange::CIEHtmlControlRange()
{
}
CIEHtmlControlRange::~CIEHtmlControlRange()
{
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::commonParentElement(IHTMLElement __RPC_FAR *__RPC_FAR *parent)
{
return GetParentElement(parent);
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::select( void)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::add(IHTMLControlElement __RPC_FAR *item)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::remove(long index)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::item(long index, IHTMLElement __RPC_FAR *__RPC_FAR *pdisp)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::scrollIntoView(VARIANT varargStart)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CIEHtmlControlRange::get_length(long __RPC_FAR *p)
{
return E_NOTIMPL;
}

Просмотреть файл

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexandre Trémon <atremon@elansoftware.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLTXTRANGE_H
#define IEHTMLTXTRANGE_H
#include "nsIDOMRange.h"
class CRange :
public CComObjectRootEx<CComMultiThreadModel>
{
public:
CRange();
protected:
virtual ~CRange();
public:
void SetRange(nsIDOMRange *pRange);
virtual HRESULT GetParentElement(IHTMLElement **ppParent);
protected:
nsCOMPtr<nsIDOMRange> mRange;
};
class CIEHtmlTxtRange :
public CRange,
public IDispatchImpl<IHTMLTxtRange, &IID_IHTMLTxtRange, &LIBID_MSHTML>
{
public:
CIEHtmlTxtRange();
protected:
virtual ~CIEHtmlTxtRange();
public:
BEGIN_COM_MAP(CIEHtmlTxtRange)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHTMLTxtRange)
END_COM_MAP()
// Implementation of IHTMLTxtRange
virtual HRESULT STDMETHODCALLTYPE pasteHTML(BSTR html);
virtual HRESULT STDMETHODCALLTYPE get_text(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE parentElement(IHTMLElement __RPC_FAR *__RPC_FAR *Parent);
// Not yet implemented
virtual HRESULT STDMETHODCALLTYPE get_htmlText(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_text(BSTR v);
virtual HRESULT STDMETHODCALLTYPE duplicate(IHTMLTxtRange __RPC_FAR *__RPC_FAR *Duplicate);
virtual HRESULT STDMETHODCALLTYPE inRange(IHTMLTxtRange __RPC_FAR *Range, VARIANT_BOOL __RPC_FAR *InRange);
virtual HRESULT STDMETHODCALLTYPE isEqual(IHTMLTxtRange __RPC_FAR *Range, VARIANT_BOOL __RPC_FAR *IsEqual);
virtual HRESULT STDMETHODCALLTYPE scrollIntoView(VARIANT_BOOL fStart = -1);
virtual HRESULT STDMETHODCALLTYPE collapse(VARIANT_BOOL Start = -1);
virtual HRESULT STDMETHODCALLTYPE expand(BSTR Unit,VARIANT_BOOL __RPC_FAR *Success);
virtual HRESULT STDMETHODCALLTYPE move(BSTR Unit, long Count, long __RPC_FAR *ActualCount);
virtual HRESULT STDMETHODCALLTYPE moveStart(BSTR Unit, long Count, long __RPC_FAR *ActualCount);
virtual HRESULT STDMETHODCALLTYPE moveEnd(BSTR Unit, long Count, long __RPC_FAR *ActualCount);
virtual HRESULT STDMETHODCALLTYPE select( void);
virtual HRESULT STDMETHODCALLTYPE moveToElementText(IHTMLElement __RPC_FAR *element);
virtual HRESULT STDMETHODCALLTYPE setEndPoint(BSTR how, IHTMLTxtRange __RPC_FAR *SourceRange);
virtual HRESULT STDMETHODCALLTYPE compareEndPoints(BSTR how, IHTMLTxtRange __RPC_FAR *SourceRange, long __RPC_FAR *ret);
virtual HRESULT STDMETHODCALLTYPE findText(BSTR String, long count, long Flags, VARIANT_BOOL __RPC_FAR *Success);
virtual HRESULT STDMETHODCALLTYPE moveToPoint(long x, long y);
virtual HRESULT STDMETHODCALLTYPE getBookmark(BSTR __RPC_FAR *Boolmark);
virtual HRESULT STDMETHODCALLTYPE moveToBookmark(BSTR Bookmark, VARIANT_BOOL __RPC_FAR *Success);
virtual HRESULT STDMETHODCALLTYPE queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText);
virtual HRESULT STDMETHODCALLTYPE queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue);
virtual HRESULT STDMETHODCALLTYPE execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
};
#define CIEHTMLTXTRANGE_INTERFACES \
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLTxtRange \
COM_INTERFACE_ENTRY_IID(IID_IHTMLTxtRange, IHTMLTxtRange)
typedef CComObject<CIEHtmlTxtRange> CIEHtmlTxtRangeInstance;
class CIEHtmlControlRange :
public CRange,
public IDispatchImpl<IHTMLControlRange, &IID_IHTMLControlRange, &LIBID_MSHTML>
{
public:
CIEHtmlControlRange();
protected:
virtual ~CIEHtmlControlRange();
public:
BEGIN_COM_MAP(CIEHtmlControlRange)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IHTMLControlRange)
END_COM_MAP()
// Implementation of IHTMLControlRange
virtual HRESULT STDMETHODCALLTYPE commonParentElement(IHTMLElement __RPC_FAR *__RPC_FAR *parent);
// Not yet implemented
virtual HRESULT STDMETHODCALLTYPE select( void);
virtual HRESULT STDMETHODCALLTYPE add(IHTMLControlElement __RPC_FAR *item);
virtual HRESULT STDMETHODCALLTYPE remove(long index);
virtual HRESULT STDMETHODCALLTYPE item(long index, IHTMLElement __RPC_FAR *__RPC_FAR *pdisp);
virtual HRESULT STDMETHODCALLTYPE scrollIntoView(VARIANT varargStart);
virtual HRESULT STDMETHODCALLTYPE queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText);
virtual HRESULT STDMETHODCALLTYPE queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue);
virtual HRESULT STDMETHODCALLTYPE execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE get_length(long __RPC_FAR *p);
};
typedef CComObject<CIEHtmlControlRange> CIEHtmlControlRangeInstance;
#endif //IEHTMLTXTRANGE_H

Просмотреть файл

@ -0,0 +1,187 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IHTMLLOCATIONIMPL_H
#define IHTMLLOCATIONIMPL_H
#include "nsIDOMLocation.h"
#define IHTMLLOCATION_GET_IMPL(prop) \
if (!p) return E_INVALIDARG; \
nsCOMPtr<nsIDOMLocation> location; \
if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location) \
return E_UNEXPECTED; \
nsAutoString value; \
NS_ENSURE_SUCCESS(location->Get ## prop(value), E_UNEXPECTED); \
*p = ::SysAllocString(value.get()); \
return (*p) ? S_OK : E_OUTOFMEMORY;
#define IHTMLLOCATION_PUT_IMPL(prop) \
return E_NOTIMPL; // For now
template<class T>
class IHTMLLocationImpl :
public IDispatchImpl<IHTMLLocation, &__uuidof(IHTMLLocation), &LIBID_MSHTML>
{
protected:
// Methods to be implemented by the derived class
virtual nsresult GetDOMLocation(nsIDOMLocation **aLocation) = 0;
public:
// IHTMLLocation
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_href(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Href);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_href(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Href);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_protocol(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Protocol);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_protocol(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Protocol);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_host(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Host);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_host(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Host);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_hostname(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Hostname);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_hostname(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Hostname);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_port(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Port);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_port(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Port);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_pathname(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Pathname);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_pathname(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Pathname);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_search(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Search);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_search(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Search);
}
virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_hash(
/* [in] */ BSTR v)
{
IHTMLLOCATION_PUT_IMPL(Hash);
}
virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_hash(
/* [out][retval] */ BSTR *p)
{
IHTMLLOCATION_GET_IMPL(Hash);
}
virtual /* [id] */ HRESULT STDMETHODCALLTYPE reload(
/* [in][defaultvalue] */ VARIANT_BOOL flag)
{
nsCOMPtr<nsIDOMLocation> location;
if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location)
return E_UNEXPECTED;
return NS_SUCCEEDED(location->Reload(flag)) ? S_OK : E_FAIL;
}
virtual /* [id] */ HRESULT STDMETHODCALLTYPE replace(
/* [in] */ BSTR bstr)
{
nsCOMPtr<nsIDOMLocation> location;
if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location)
return E_UNEXPECTED;
nsAutoString value(bstr);
return NS_SUCCEEDED(location->Replace(value)) ? S_OK : E_FAIL;
}
virtual /* [id] */ HRESULT STDMETHODCALLTYPE assign(
/* [in] */ BSTR bstr)
{
nsCOMPtr<nsIDOMLocation> location;
if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location)
return E_UNEXPECTED;
nsAutoString value(bstr);
return NS_SUCCEEDED(location->Assign(value)) ? S_OK : E_FAIL;
}
virtual /* [id] */ HRESULT STDMETHODCALLTYPE toString(
/* [out][retval] */ BSTR *string)
{
if (!string) return E_INVALIDARG;
nsCOMPtr<nsIDOMLocation> location;
if (NS_FAILED(GetDOMLocation(getter_AddRefs(location))) || !location)
return E_UNEXPECTED;
nsAutoString value;
NS_ENSURE_SUCCESS(location->ToString(value), E_UNEXPECTED);
*string = ::SysAllocString(value.get());
return (*string) ? S_OK : E_OUTOFMEMORY;
}
};
#endif

Просмотреть файл

@ -0,0 +1,288 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IOLECOMMANDIMPL_H
#define IOLECOMMANDIMPL_H
// Implementation of the IOleCommandTarget interface. The template is
// reasonably generic and reusable which is a good thing given how needlessly
// complicated this interface is. Blame Microsoft for that and not me.
//
// To use this class, derive your class from it like this:
//
// class CComMyClass : public IOleCommandTargetImpl<CComMyClass>
// {
// ... Ensure IOleCommandTarget is listed in the interface map ...
// BEGIN_COM_MAP(CComMyClass)
// COM_INTERFACE_ENTRY(IOleCommandTarget)
// // etc.
// END_COM_MAP()
// ... And then later on define the command target table ...
// BEGIN_OLECOMMAND_TABLE()
// OLECOMMAND_MESSAGE(OLECMDID_PRINT, NULL, ID_PRINT, L"Print", L"Print the page")
// OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, 0, L"SaveAs", L"Save the page")
// OLECOMMAND_HANDLER(IDM_EDITMODE, &CGID_MSHTML, EditModeHandler, L"EditMode", L"Switch to edit mode")
// END_OLECOMMAND_TABLE()
// ... Now the window that OLECOMMAND_MESSAGE sends WM_COMMANDs to ...
// HWND GetCommandTargetWindow() const
// {
// return m_hWnd;
// }
// ... Now procedures that OLECOMMAND_HANDLER calls ...
// static HRESULT _stdcall EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
// }
//
// The command table defines which commands the object supports. Commands are
// defined by a command id and a command group plus a WM_COMMAND id or procedure,
// and a verb and short description.
//
// Notice that there are two macros for handling Ole Commands. The first,
// OLECOMMAND_MESSAGE sends a WM_COMMAND message to the window returned from
// GetCommandTargetWindow() (that the derived class must implement if it uses
// this macro).
//
// The second, OLECOMMAND_HANDLER calls a static handler procedure that
// conforms to the OleCommandProc typedef. The first parameter, pThis means
// the static handler has access to the methods and variables in the class
// instance.
//
// The OLECOMMAND_HANDLER macro is generally more useful when a command
// takes parameters or needs to return a result to the caller.
//
template< class T >
class IOleCommandTargetImpl : public IOleCommandTarget
{
struct OleExecData
{
const GUID *pguidCmdGroup;
DWORD nCmdID;
DWORD nCmdexecopt;
VARIANT *pvaIn;
VARIANT *pvaOut;
};
public:
typedef HRESULT (_stdcall *OleCommandProc)(T *pT, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
struct OleCommandInfo
{
ULONG nCmdID;
const GUID *pCmdGUID;
ULONG nWindowsCmdID;
OleCommandProc pfnCommandProc;
wchar_t *szVerbText;
wchar_t *szStatusText;
};
// Query the status of the specified commands (test if is it supported etc.)
virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID __RPC_FAR *pguidCmdGroup, ULONG cCmds, OLECMD __RPC_FAR prgCmds[], OLECMDTEXT __RPC_FAR *pCmdText)
{
T* pT = static_cast<T*>(this);
if (prgCmds == NULL)
{
return E_INVALIDARG;
}
OleCommandInfo *pCommands = pT->GetCommandTable();
ATLASSERT(pCommands);
BOOL bCmdGroupFound = FALSE;
BOOL bTextSet = FALSE;
// Iterate through list of commands and flag them as supported/unsupported
for (ULONG nCmd = 0; nCmd < cCmds; nCmd++)
{
// Unsupported by default
prgCmds[nCmd].cmdf = 0;
// Search the support command list
for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++)
{
OleCommandInfo *pCI = &pCommands[nSupported];
if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0)
{
continue;
}
bCmdGroupFound = TRUE;
if (pCI->nCmdID != prgCmds[nCmd].cmdID)
{
continue;
}
// Command is supported so flag it and possibly enable it
prgCmds[nCmd].cmdf = OLECMDF_SUPPORTED;
if (pCI->nWindowsCmdID != 0)
{
prgCmds[nCmd].cmdf |= OLECMDF_ENABLED;
}
// Copy the status/verb text for the first supported command only
if (!bTextSet && pCmdText)
{
// See what text the caller wants
wchar_t *pszTextToCopy = NULL;
if (pCmdText->cmdtextf & OLECMDTEXTF_NAME)
{
pszTextToCopy = pCI->szVerbText;
}
else if (pCmdText->cmdtextf & OLECMDTEXTF_STATUS)
{
pszTextToCopy = pCI->szStatusText;
}
// Copy the text
pCmdText->cwActual = 0;
memset(pCmdText->rgwz, 0, pCmdText->cwBuf * sizeof(wchar_t));
if (pszTextToCopy)
{
// Don't exceed the provided buffer size
size_t nTextLen = wcslen(pszTextToCopy);
if (nTextLen > pCmdText->cwBuf)
{
nTextLen = pCmdText->cwBuf;
}
wcsncpy(pCmdText->rgwz, pszTextToCopy, nTextLen);
pCmdText->cwActual = nTextLen;
}
bTextSet = TRUE;
}
break;
}
}
// Was the command group found?
if (!bCmdGroupFound)
{
OLECMDERR_E_UNKNOWNGROUP;
}
return S_OK;
}
// Execute the specified command
virtual HRESULT STDMETHODCALLTYPE Exec(const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut)
{
T* pT = static_cast<T*>(this);
BOOL bCmdGroupFound = FALSE;
OleCommandInfo *pCommands = pT->GetCommandTable();
ATLASSERT(pCommands);
// Search the support command list
for (int nSupported = 0; pCommands[nSupported].pCmdGUID != &GUID_NULL; nSupported++)
{
OleCommandInfo *pCI = &pCommands[nSupported];
if (pguidCmdGroup && pCI->pCmdGUID && memcmp(pguidCmdGroup, pCI->pCmdGUID, sizeof(GUID)) == 0)
{
continue;
}
bCmdGroupFound = TRUE;
if (pCI->nCmdID != nCmdID)
{
continue;
}
// Send ourselves a WM_COMMAND windows message with the associated
// identifier and exec data
OleExecData cData;
cData.pguidCmdGroup = pguidCmdGroup;
cData.nCmdID = nCmdID;
cData.nCmdexecopt = nCmdexecopt;
cData.pvaIn = pvaIn;
cData.pvaOut = pvaOut;
if (pCI->pfnCommandProc)
{
pCI->pfnCommandProc(pT, pCI->pCmdGUID, pCI->nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
else if (pCI->nWindowsCmdID != 0 && nCmdexecopt != OLECMDEXECOPT_SHOWHELP)
{
HWND hwndTarget = pT->GetCommandTargetWindow();
if (hwndTarget)
{
::SendMessage(hwndTarget, WM_COMMAND, LOWORD(pCI->nWindowsCmdID), (LPARAM) &cData);
}
}
else
{
// Command supported but not implemented
continue;
}
return S_OK;
}
// Was the command group found?
if (!bCmdGroupFound)
{
OLECMDERR_E_UNKNOWNGROUP;
}
return OLECMDERR_E_NOTSUPPORTED;
}
};
// Macros to be placed in any class derived from the IOleCommandTargetImpl
// class. These define what commands are exposed from the object.
#define BEGIN_OLECOMMAND_TABLE() \
OleCommandInfo *GetCommandTable() \
{ \
static OleCommandInfo s_aSupportedCommands[] = \
{
#define OLECOMMAND_MESSAGE(id, group, cmd, verb, desc) \
{ id, group, cmd, NULL, verb, desc },
#define OLECOMMAND_HANDLER(id, group, handler, verb, desc) \
{ id, group, 0, handler, verb, desc },
#define END_OLECOMMAND_TABLE() \
{ 0, &GUID_NULL, 0, NULL, NULL, NULL } \
}; \
return s_aSupportedCommands; \
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,137 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include "ItemContainer.h"
CItemContainer::CItemContainer()
{
}
CItemContainer::~CItemContainer()
{
}
///////////////////////////////////////////////////////////////////////////////
// IParseDisplayName implementation
HRESULT STDMETHODCALLTYPE CItemContainer::ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut)
{
// TODO
return E_NOTIMPL;
}
///////////////////////////////////////////////////////////////////////////////
// IOleContainer implementation
HRESULT STDMETHODCALLTYPE CItemContainer::EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum)
{
HRESULT hr = E_NOTIMPL;
/*
if (ppenum == NULL)
{
return E_POINTER;
}
*ppenum = NULL;
typedef CComObject<CComEnumOnSTL<IEnumUnknown, &IID_IEnumUnknown, IUnknown*, _CopyInterface<IUnknown>, CNamedObjectList > > enumunk;
enumunk* p = NULL;
p = new enumunk;
if(p == NULL)
{
return E_OUTOFMEMORY;
}
hr = p->Init();
if (SUCCEEDED(hr))
{
hr = p->QueryInterface(IID_IEnumUnknown, (void**) ppenum);
}
if (FAILED(hRes))
{
delete p;
}
*/
return hr;
}
HRESULT STDMETHODCALLTYPE CItemContainer::LockContainer(/* [in] */ BOOL fLock)
{
// TODO
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IOleItemContainer implementation
HRESULT STDMETHODCALLTYPE CItemContainer::GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{
if (pszItem == NULL)
{
return E_INVALIDARG;
}
if (ppvObject == NULL)
{
return E_INVALIDARG;
}
*ppvObject = NULL;
return MK_E_NOOBJECT;
}
HRESULT STDMETHODCALLTYPE CItemContainer::GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage)
{
// TODO
return MK_E_NOOBJECT;
}
HRESULT STDMETHODCALLTYPE CItemContainer::IsRunning(/* [in] */ LPOLESTR pszItem)
{
// TODO
return MK_E_NOOBJECT;
}

Просмотреть файл

@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef ITEMCONTAINER_H
#define ITEMCONTAINER_H
// typedef std::map<tstring, CIUnkPtr> CNamedObjectList;
// Class for managing a list of named objects.
class CItemContainer : public CComObjectRootEx<CComSingleThreadModel>,
public IOleItemContainer
{
// CNamedObjectList m_cNamedObjectList;
public:
CItemContainer();
virtual ~CItemContainer();
BEGIN_COM_MAP(CItemContainer)
COM_INTERFACE_ENTRY_IID(IID_IParseDisplayName, IOleItemContainer)
COM_INTERFACE_ENTRY_IID(IID_IOleContainer, IOleItemContainer)
COM_INTERFACE_ENTRY_IID(IID_IOleItemContainer, IOleItemContainer)
END_COM_MAP()
// IParseDisplayName implementation
virtual HRESULT STDMETHODCALLTYPE ParseDisplayName(/* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG __RPC_FAR *pchEaten, /* [out] */ IMoniker __RPC_FAR *__RPC_FAR *ppmkOut);
// IOleContainer implementation
virtual HRESULT STDMETHODCALLTYPE EnumObjects(/* [in] */ DWORD grfFlags, /* [out] */ IEnumUnknown __RPC_FAR *__RPC_FAR *ppenum);
virtual HRESULT STDMETHODCALLTYPE LockContainer(/* [in] */ BOOL fLock);
// IOleItemContainer implementation
virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObject(/* [in] */ LPOLESTR pszItem, /* [in] */ DWORD dwSpeedNeeded, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetObjectStorage(/* [in] */ LPOLESTR pszItem, /* [unique][in] */ IBindCtx __RPC_FAR *pbc, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvStorage);
virtual HRESULT STDMETHODCALLTYPE IsRunning(/* [in] */ LPOLESTR pszItem);
};
typedef CComObject<CItemContainer> CItemContainerInstance;
#endif

Просмотреть файл

@ -0,0 +1,88 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Christopher Blizzard.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Adam Lock <adamlock@eircom.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = ax_common
LIBRARY_NAME = ax_common_s
XPIDL_MODULE = ax_common
CPPSRCS = \
IEHtmlNode.cpp \
IEHtmlElement.cpp \
IEHtmlElementCollection.cpp \
ControlSite.cpp \
ControlSiteIPFrame.cpp \
ControlEventSink.cpp \
PropertyBag.cpp \
ItemContainer.cpp \
IEHtmlSelectionObject.cpp \
IEHtmlTxtRange.cpp \
IEHtmlButtonElement.cpp \
$(NULL)
EXPORTS = \
IEHtmlNode.h \
IEHtmlElement.h \
IEHtmlElementCollection.h \
ControlSite.h \
ControlSiteIPFrame.h \
ControlEventSink.h \
PropertyList.h \
PropertyBag.h \
ItemContainer.h \
IOleCommandTargetImpl.h \
IWebBrowserImpl.h \
IHTMLLocationImpl.h \
CPMozillaControl.h \
IEHtmlSelectionObject.h \
IEHtmlTxtRange.h
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
ENABLE_CXX_EXCEPTIONS = 1
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,113 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include "PropertyBag.h"
CPropertyBag::CPropertyBag()
{
}
CPropertyBag::~CPropertyBag()
{
}
///////////////////////////////////////////////////////////////////////////////
// IPropertyBag implementation
HRESULT STDMETHODCALLTYPE CPropertyBag::Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog)
{
if (pszPropName == NULL)
{
return E_INVALIDARG;
}
if (pVar == NULL)
{
return E_INVALIDARG;
}
VARTYPE vt = pVar->vt;
VariantInit(pVar);
for (unsigned long i = 0; i < m_PropertyList.GetSize(); i++)
{
if (wcsicmp(m_PropertyList.GetNameOf(i), pszPropName) == 0)
{
const VARIANT *pvSrc = m_PropertyList.GetValueOf(i);
if (!pvSrc)
{
return E_FAIL;
}
CComVariant vNew;
HRESULT hr = (vt == VT_EMPTY) ?
vNew.Copy(pvSrc) : vNew.ChangeType(vt, pvSrc);
if (FAILED(hr))
{
return E_FAIL;
}
// Copy the new value
vNew.Detach(pVar);
return S_OK;
}
}
// Property does not exist in the bag
return E_FAIL;
}
HRESULT STDMETHODCALLTYPE CPropertyBag::Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar)
{
if (pszPropName == NULL)
{
return E_INVALIDARG;
}
if (pVar == NULL)
{
return E_INVALIDARG;
}
CComBSTR bstrName(pszPropName);
m_PropertyList.AddOrReplaceNamedProperty(bstrName, *pVar);
return S_OK;
}

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PROPERTYBAG_H
#define PROPERTYBAG_H
#include "PropertyList.h"
// Object wrapper for property list. This class can be set up with a
// list of properties and used to initialise a control with them
class CPropertyBag : public CComObjectRootEx<CComSingleThreadModel>,
public IPropertyBag
{
// List of properties in the bag
PropertyList m_PropertyList;
public:
// Constructor
CPropertyBag();
// Destructor
virtual ~CPropertyBag();
BEGIN_COM_MAP(CPropertyBag)
COM_INTERFACE_ENTRY(IPropertyBag)
END_COM_MAP()
// IPropertyBag methods
virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(/* [in] */ LPCOLESTR pszPropName, /* [out][in] */ VARIANT __RPC_FAR *pVar, /* [in] */ IErrorLog __RPC_FAR *pErrorLog);
virtual HRESULT STDMETHODCALLTYPE Write(/* [in] */ LPCOLESTR pszPropName, /* [in] */ VARIANT __RPC_FAR *pVar);
};
typedef CComObject<CPropertyBag> CPropertyBagInstance;
#endif

Просмотреть файл

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PROPERTYLIST_H
#define PROPERTYLIST_H
// A simple array class for managing name/value pairs typically fed to controls
// during initialization by IPersistPropertyBag
class PropertyList
{
struct Property {
BSTR bstrName;
VARIANT vValue;
} *mProperties;
unsigned long mListSize;
unsigned long mMaxListSize;
bool EnsureMoreSpace()
{
// Ensure enough space exists to accomodate a new item
const unsigned long kGrowBy = 10;
if (!mProperties)
{
mProperties = (Property *) malloc(sizeof(Property) * kGrowBy);
if (!mProperties)
return false;
mMaxListSize = kGrowBy;
}
else if (mListSize == mMaxListSize)
{
Property *pNewProperties;
pNewProperties = (Property *) realloc(mProperties, sizeof(Property) * (mMaxListSize + kGrowBy));
if (!pNewProperties)
return false;
mProperties = pNewProperties;
mMaxListSize += kGrowBy;
}
return true;
}
public:
PropertyList() :
mProperties(NULL),
mListSize(0),
mMaxListSize(0)
{
}
~PropertyList()
{
}
void Clear()
{
if (mProperties)
{
for (unsigned long i = 0; i < mListSize; i++)
{
SysFreeString(mProperties[i].bstrName); // Safe even if NULL
VariantClear(&mProperties[i].vValue);
}
free(mProperties);
mProperties = NULL;
}
mListSize = 0;
mMaxListSize = 0;
}
unsigned long GetSize() const
{
return mListSize;
}
const BSTR GetNameOf(unsigned long nIndex) const
{
if (nIndex > mListSize)
{
return NULL;
}
return mProperties[nIndex].bstrName;
}
const VARIANT *GetValueOf(unsigned long nIndex) const
{
if (nIndex > mListSize)
{
return NULL;
}
return &mProperties[nIndex].vValue;
}
bool AddOrReplaceNamedProperty(const BSTR bstrName, const VARIANT &vValue)
{
if (!bstrName)
return false;
for (unsigned long i = 0; i < GetSize(); i++)
{
// Case insensitive
if (wcsicmp(mProperties[i].bstrName, bstrName) == 0)
{
return SUCCEEDED(
VariantCopy(&mProperties[i].vValue, const_cast<VARIANT *>(&vValue)));
}
}
return AddNamedProperty(bstrName, vValue);
}
bool AddNamedProperty(const BSTR bstrName, const VARIANT &vValue)
{
if (!bstrName || !EnsureMoreSpace())
return false;
Property *pProp = &mProperties[mListSize];
pProp->bstrName = ::SysAllocString(bstrName);
if (!pProp->bstrName)
{
return false;
}
VariantInit(&pProp->vValue);
if (FAILED(VariantCopy(&pProp->vValue, const_cast<VARIANT *>(&vValue))))
{
SysFreeString(pProp->bstrName);
return false;
}
mListSize++;
return true;
}
};
#endif

Просмотреть файл

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_)
#define AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// under MSVC shut off copious warnings about debug symbol too long
#ifdef _MSC_VER
#pragma warning( disable: 4786 )
#endif
#include "jstypes.h"
#include "prtypes.h"
// Mozilla headers
#include "jscompat.h"
#include "prthread.h"
#include "prprf.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsStringAPI.h"
#include "nsCOMPtr.h"
#include "nsComponentManagerUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMElement.h"
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0403
#define _ATL_APARTMENT_THREADED
#define _ATL_STATIC_REGISTRY
// #define _ATL_DEBUG_INTERFACES
// ATL headers
// The ATL headers that come with the platform SDK have bad for scoping
#if _MSC_VER >= 1400
#pragma conform(forScope, push, atlhack, off)
#endif
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <atlctl.h>
#if _MSC_VER >= 1400
#pragma conform(forScope, pop, atlhack)
#endif
#include <mshtml.h>
#include <mshtmhst.h>
#include <docobj.h>
// New winsock2.h doesn't define this anymore
typedef long int32;
// Turn off warnings about debug symbols for templates being too long
#pragma warning(disable : 4786)
#define TRACE_METHOD(fn) \
{ \
ATLTRACE(_T("0x%04x %s()\n"), (int) GetCurrentThreadId(), _T(#fn)); \
}
#define TRACE_METHOD_ARGS(fn, pattern, args) \
{ \
ATLTRACE(_T("0x%04x %s(") _T(pattern) _T(")\n"), (int) GetCurrentThreadId(), _T(#fn), args); \
}
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED)

Просмотреть файл

@ -0,0 +1,400 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include <sys/types.h>
#include <sys/stat.h>
#include "ActiveScriptSite.h"
CActiveScriptSite::CActiveScriptSite()
{
m_ssScriptState = SCRIPTSTATE_UNINITIALIZED;
}
CActiveScriptSite::~CActiveScriptSite()
{
Detach();
}
HRESULT CActiveScriptSite::Attach(CLSID clsidScriptEngine)
{
// Detach to anything already attached to
Detach();
// Create the new script engine
HRESULT hr = m_spIActiveScript.CoCreateInstance(clsidScriptEngine);
if (FAILED(hr))
{
return hr;
}
// Attach the script engine to this site
m_spIActiveScript->SetScriptSite(this);
// Initialise the script engine
CIPtr(IActiveScriptParse) spActiveScriptParse = m_spIActiveScript;
if (spActiveScriptParse)
{
spActiveScriptParse->InitNew();
}
else
{
}
return S_OK;
}
HRESULT CActiveScriptSite::Detach()
{
if (m_spIActiveScript)
{
StopScript();
m_spIActiveScript->Close();
m_spIActiveScript.Release();
}
return S_OK;
}
HRESULT CActiveScriptSite::AttachVBScript()
{
static const CLSID CLSID_VBScript =
{ 0xB54F3741, 0x5B07, 0x11CF, { 0xA4, 0xB0, 0x00, 0xAA, 0x00, 0x4A, 0x55, 0xE8} };
return Attach(CLSID_VBScript);
}
HRESULT CActiveScriptSite::AttachJScript()
{
static const CLSID CLSID_JScript =
{ 0xF414C260, 0x6AC0, 0x11CF, { 0xB6, 0xD1, 0x00, 0xAA, 0x00, 0xBB, 0xBB, 0x58} };
return Attach(CLSID_JScript);
}
HRESULT CActiveScriptSite::AddNamedObject(const TCHAR *szName, IUnknown *pObject, BOOL bGlobalMembers)
{
if (m_spIActiveScript == NULL)
{
return E_UNEXPECTED;
}
if (pObject == NULL || szName == NULL)
{
return E_INVALIDARG;
}
// Check for objects of the same name already
CNamedObjectList::iterator i = m_cObjectList.find(szName);
if (i != m_cObjectList.end())
{
return E_FAIL;
}
// Add object to the list
m_cObjectList.insert(CNamedObjectList::value_type(szName, pObject));
// Tell the script engine about the object
HRESULT hr;
USES_CONVERSION;
DWORD dwFlags = SCRIPTITEM_ISSOURCE | SCRIPTITEM_ISVISIBLE;
if (bGlobalMembers)
{
dwFlags |= SCRIPTITEM_GLOBALMEMBERS;
}
hr = m_spIActiveScript->AddNamedItem(T2OLE(szName), dwFlags);
if (FAILED(hr))
{
m_cObjectList.erase(szName);
return hr;
}
return S_OK;
}
HRESULT CActiveScriptSite::ParseScriptFile(const TCHAR *szFile)
{
USES_CONVERSION;
const char *pszFileName = T2CA(szFile);
// Stat the file and get its length;
struct _stat cStat;
_stat(pszFileName, &cStat);
// Allocate a buffer
size_t nBufSize = cStat.st_size + 1;
char *pBuffer = (char *) malloc(nBufSize);
if (pBuffer == NULL)
{
return E_OUTOFMEMORY;
}
memset(pBuffer, 0, nBufSize);
// Read the script into the buffer and parse it
HRESULT hr = E_FAIL;
FILE *f = fopen(pszFileName, "rb");
if (f)
{
fread(pBuffer, 1, nBufSize - 1, f);
hr = ParseScriptText(A2T(pBuffer));
fclose(f);
}
free(pBuffer);
return hr;
}
HRESULT CActiveScriptSite::ParseScriptText(const TCHAR *szScript)
{
if (m_spIActiveScript == NULL)
{
return E_UNEXPECTED;
}
CIPtr(IActiveScriptParse) spIActiveScriptParse = m_spIActiveScript;
if (spIActiveScriptParse)
{
USES_CONVERSION;
CComVariant vResult;
DWORD dwCookie = 0; // TODO
DWORD dwFlags = 0;
EXCEPINFO cExcepInfo;
HRESULT hr;
hr = spIActiveScriptParse->ParseScriptText(
T2OLE(szScript),
NULL, NULL, NULL, dwCookie, 0, dwFlags,
&vResult, &cExcepInfo);
if (FAILED(hr))
{
return E_FAIL;
}
}
else
{
CIPtr(IPersistStream) spPersistStream = m_spIActiveScript;
CIPtr(IStream) spStream;
// Load text into the stream IPersistStream
if (spPersistStream &&
SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &spStream)))
{
USES_CONVERSION;
LARGE_INTEGER cPos = { 0, 0 };
LPOLESTR szText = T2OLE(szScript);
spStream->Write(szText, wcslen(szText) * sizeof(WCHAR), NULL);
spStream->Seek(cPos, STREAM_SEEK_SET, NULL);
spPersistStream->Load(spStream);
}
else
{
return E_UNEXPECTED;
}
}
return S_OK;
}
HRESULT CActiveScriptSite::PlayScript()
{
if (m_spIActiveScript == NULL)
{
return E_UNEXPECTED;
}
m_spIActiveScript->SetScriptState(SCRIPTSTATE_CONNECTED);
return S_OK;
}
HRESULT CActiveScriptSite::StopScript()
{
if (m_spIActiveScript == NULL)
{
return E_UNEXPECTED;
}
m_spIActiveScript->SetScriptState(SCRIPTSTATE_DISCONNECTED);
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IActiveScriptSite implementation
HRESULT STDMETHODCALLTYPE CActiveScriptSite::GetLCID(/* [out] */ LCID __RPC_FAR *plcid)
{
// Use the system defined locale
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::GetItemInfo(/* [in] */ LPCOLESTR pstrName, /* [in] */ DWORD dwReturnMask, /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppiunkItem, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppti)
{
if (pstrName == NULL)
{
return E_INVALIDARG;
}
if (ppiunkItem)
{
*ppiunkItem = NULL;
}
if (ppti)
{
*ppti = NULL;
}
USES_CONVERSION;
// Find object in list
CIUnkPtr spUnkObject;
CNamedObjectList::iterator i = m_cObjectList.find(OLE2T(pstrName));
if (i != m_cObjectList.end())
{
spUnkObject = (*i).second;
}
// Fill in the output values
if (spUnkObject == NULL)
{
return TYPE_E_ELEMENTNOTFOUND;
}
if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
{
spUnkObject->QueryInterface(IID_IUnknown, (void **) ppiunkItem);
}
if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
{
// Return the typeinfo in ptti
CIPtr(IDispatch) spIDispatch = spUnkObject;
if (spIDispatch)
{
HRESULT hr;
hr = spIDispatch->GetTypeInfo(0, GetSystemDefaultLCID(), ppti);
if (FAILED(hr))
{
*ppti = NULL;
}
}
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::GetDocVersionString(/* [out] */ BSTR __RPC_FAR *pbstrVersion)
{
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::OnScriptTerminate(/* [in] */ const VARIANT __RPC_FAR *pvarResult, /* [in] */ const EXCEPINFO __RPC_FAR *pexcepinfo)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::OnStateChange(/* [in] */ SCRIPTSTATE ssScriptState)
{
m_ssScriptState = ssScriptState;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::OnScriptError(/* [in] */ IActiveScriptError __RPC_FAR *pscripterror)
{
BSTR bstrSourceLineText = NULL;
DWORD dwSourceContext = 0;
ULONG pulLineNumber = 0;
LONG ichCharPosition = 0;
EXCEPINFO cExcepInfo;
memset(&cExcepInfo, 0, sizeof(cExcepInfo));
// Get error information
pscripterror->GetSourcePosition(&dwSourceContext, &pulLineNumber, &ichCharPosition);
pscripterror->GetSourceLineText(&bstrSourceLineText);
pscripterror->GetExceptionInfo(&cExcepInfo);
tstring szDescription(_T("(No description)"));
if (cExcepInfo.bstrDescription)
{
// Dump info
USES_CONVERSION;
szDescription = OLE2T(cExcepInfo.bstrDescription);
}
ATLTRACE(_T("Script Error: %s, code=0x%08x\n"), szDescription.c_str(), cExcepInfo.scode);
SysFreeString(bstrSourceLineText);
return S_OK;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::OnEnterScript(void)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CActiveScriptSite::OnLeaveScript(void)
{
return S_OK;
}

Просмотреть файл

@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef ACTIVESCRIPTSITE_H
#define ACTIVESCRIPTSITE_H
class CActiveScriptSite : public CComObjectRootEx<CComSingleThreadModel>,
public IActiveScriptSite
{
// Pointer to owned script engine
CComQIPtr<IActiveScript, &IID_IActiveScript> m_spIActiveScript;
// List of registered, named objects
CNamedObjectList m_cObjectList;
// Current script state
SCRIPTSTATE m_ssScriptState;
public:
CActiveScriptSite();
virtual ~CActiveScriptSite();
BEGIN_COM_MAP(CActiveScriptSite)
COM_INTERFACE_ENTRY(IActiveScriptSite)
END_COM_MAP()
// Attach to the specified script engine
virtual HRESULT Attach(CLSID clsidScriptEngine);
// Helper to attach to the VBScript engine
virtual HRESULT AttachVBScript();
// Helper to attach to the JScript engine
virtual HRESULT AttachJScript();
// Detach from the script engine
virtual HRESULT Detach();
// Return the current state of the script engine
virtual SCRIPTSTATE GetScriptState() const
{
return m_ssScriptState;
}
// Parse the specified script
virtual HRESULT ParseScriptText(const TCHAR *szScript);
// Parse the specified script from a file
virtual HRESULT ParseScriptFile(const TCHAR *szFile);
// Add object to script address space
virtual HRESULT AddNamedObject(const TCHAR *szName, IUnknown *pObject, BOOL bGlobalMembers = FALSE);
// Play the script
virtual HRESULT PlayScript();
// Stop the script
virtual HRESULT StopScript();
public:
// IActiveScriptSite
virtual HRESULT STDMETHODCALLTYPE GetLCID(/* [out] */ LCID __RPC_FAR *plcid);
virtual HRESULT STDMETHODCALLTYPE GetItemInfo(/* [in] */ LPCOLESTR pstrName, /* [in] */ DWORD dwReturnMask, /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppiunkItem, /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppti);
virtual HRESULT STDMETHODCALLTYPE GetDocVersionString(/* [out] */ BSTR __RPC_FAR *pbstrVersion);
virtual HRESULT STDMETHODCALLTYPE OnScriptTerminate(/* [in] */ const VARIANT __RPC_FAR *pvarResult, /* [in] */ const EXCEPINFO __RPC_FAR *pexcepinfo);
virtual HRESULT STDMETHODCALLTYPE OnStateChange(/* [in] */ SCRIPTSTATE ssScriptState);
virtual HRESULT STDMETHODCALLTYPE OnScriptError(/* [in] */ IActiveScriptError __RPC_FAR *pscripterror);
virtual HRESULT STDMETHODCALLTYPE OnEnterScript(void);
virtual HRESULT STDMETHODCALLTYPE OnLeaveScript(void);
};
typedef CComObject<CActiveScriptSite> CActiveScriptSiteInstance;
#endif

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef ACTIVEXTYPES_H
#define ACTIVEXTYPES_H
#include <vector>
#include <map>
// STL based class for handling TCHAR strings
typedef std::basic_string<TCHAR> tstring;
// IUnknown smart pointer
typedef CComPtr<IUnknown> CIUnkPtr;
// Smart pointer macro for CComQIPtr
#define CIPtr(iface) CComQIPtr< iface, &IID_ ## iface >
typedef std::vector<CIUnkPtr> CObjectList;
typedef std::map<tstring, CIUnkPtr> CNamedObjectList;
#endif

Просмотреть файл

@ -0,0 +1,89 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef BROWSER_DIAGNOSTICS_H
#define BROWSER_DIAGNOSTICS_H
#ifdef _DEBUG
# include <assert.h>
# define NG_TRACE NgTrace
# define NG_TRACE_METHOD(fn) \
{ \
NG_TRACE(_T("0x%04x %s()\n"), (int) GetCurrentThreadId(), _T(#fn)); \
}
# define NG_TRACE_METHOD_ARGS(fn, pattern, args) \
{ \
NG_TRACE(_T("0x%04x %s(") _T(pattern) _T(")\n"), (int) GetCurrentThreadId(), _T(#fn), args); \
}
# define NG_ASSERT(expr) assert(expr)
# define NG_ASSERT_POINTER(p, type) \
NG_ASSERT(((p) != NULL) && NgIsValidAddress((p), sizeof(type), FALSE))
# define NG_ASSERT_NULL_OR_POINTER(p, type) \
NG_ASSERT(((p) == NULL) || NgIsValidAddress((p), sizeof(type), FALSE))
#else
# define NG_TRACE 1 ? (void)0 : NgTrace
# define NG_TRACE_METHOD(fn)
# define NG_TRACE_METHOD_ARGS(fn, pattern, args)
# define NG_ASSERT(X)
# define NG_ASSERT_POINTER(p, type)
# define NG_ASSERT_NULL_OR_POINTER(p, type)
#endif
#define NG_TRACE_ALWAYS AtlTrace
inline void _cdecl NgTrace(LPCSTR lpszFormat, ...)
{
va_list args;
va_start(args, lpszFormat);
int nBuf;
char szBuffer[512];
nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
NG_ASSERT(nBuf < sizeof(szBuffer)); //Output truncated as it was > sizeof(szBuffer)
OutputDebugStringA(szBuffer);
va_end(args);
}
inline BOOL NgIsValidAddress(const void* lp, UINT nBytes, BOOL bReadWrite = TRUE)
{
return (lp != NULL && !IsBadReadPtr(lp, nBytes) &&
(!bReadWrite || !IsBadWritePtr((LPVOID)lp, nBytes)));
}
#endif

Просмотреть файл

@ -0,0 +1,97 @@
#ifndef DHTMLCMDIDS_H
#define DHTMLCMDIDS_H
#ifndef __mshtmcid_h__
#define IDM_UNKNOWN 0
#define IDM_ALIGNBOTTOM 1
#define IDM_ALIGNHORIZONTALCENTERS 2
#define IDM_ALIGNLEFT 3
#define IDM_ALIGNRIGHT 4
#define IDM_ALIGNTOGRID 5
#define IDM_ALIGNTOP 6
#define IDM_ALIGNVERTICALCENTERS 7
#define IDM_ARRANGEBOTTOM 8
#define IDM_ARRANGERIGHT 9
#define IDM_BRINGFORWARD 10
#define IDM_BRINGTOFRONT 11
#define IDM_CENTERHORIZONTALLY 12
#define IDM_CENTERVERTICALLY 13
#define IDM_CODE 14
#define IDM_DELETE 17
#define IDM_FONTNAME 18
#define IDM_FONTSIZE 19
#define IDM_GROUP 20
#define IDM_HORIZSPACECONCATENATE 21
#define IDM_HORIZSPACEDECREASE 22
#define IDM_HORIZSPACEINCREASE 23
#define IDM_HORIZSPACEMAKEEQUAL 24
#define IDM_INSERTOBJECT 25
#define IDM_MULTILEVELREDO 30
#define IDM_SENDBACKWARD 32
#define IDM_SENDTOBACK 33
#define IDM_SHOWTABLE 34
#define IDM_SIZETOCONTROL 35
#define IDM_SIZETOCONTROLHEIGHT 36
#define IDM_SIZETOCONTROLWIDTH 37
#define IDM_SIZETOFIT 38
#define IDM_SIZETOGRID 39
#define IDM_SNAPTOGRID 40
#define IDM_TABORDER 41
#define IDM_TOOLBOX 42
#define IDM_MULTILEVELUNDO 44
#define IDM_UNGROUP 45
#define IDM_VERTSPACECONCATENATE 46
#define IDM_VERTSPACEDECREASE 47
#define IDM_VERTSPACEINCREASE 48
#define IDM_VERTSPACEMAKEEQUAL 49
#define IDM_JUSTIFYFULL 50
#define IDM_BACKCOLOR 51
#define IDM_BOLD 52
#define IDM_BORDERCOLOR 53
#define IDM_FLAT 54
#define IDM_FORECOLOR 55
#define IDM_ITALIC 56
#define IDM_JUSTIFYCENTER 57
#define IDM_JUSTIFYGENERAL 58
#define IDM_JUSTIFYLEFT 59
#define IDM_JUSTIFYRIGHT 60
#define IDM_RAISED 61
#define IDM_SUNKEN 62
#define IDM_UNDERLINE 63
#define IDM_CHISELED 64
#define IDM_ETCHED 65
#define IDM_SHADOWED 66
#define IDM_FIND 67
#define IDM_SHOWGRID 69
#define IDM_OBJECTVERBLIST0 72
#define IDM_OBJECTVERBLIST1 73
#define IDM_OBJECTVERBLIST2 74
#define IDM_OBJECTVERBLIST3 75
#define IDM_OBJECTVERBLIST4 76
#define IDM_OBJECTVERBLIST5 77
#define IDM_OBJECTVERBLIST6 78
#define IDM_OBJECTVERBLIST7 79
#define IDM_OBJECTVERBLIST8 80
#define IDM_OBJECTVERBLIST9 81
#define IDM_OBJECTVERBLISTLAST IDM_OBJECTVERBLIST9
#define IDM_CONVERTOBJECT 82
#define IDM_CUSTOMCONTROL 83
#define IDM_CUSTOMIZEITEM 84
#define IDM_RENAME 85
#define IDM_IMPORT 86
#define IDM_NEWPAGE 87
#define IDM_MOVE 88
#define IDM_CANCEL 89
#define IDM_FONT 90
#define IDM_STRIKETHROUGH 91
#define IDM_DELETEWORD 92
#define IDM_EXECPRINT 93
#define IDM_JUSTIFYNONE 94
#define IDM_BROWSEMODE 2126
#define IDM_EDITMODE 2127
#endif
#endif

Просмотреть файл

@ -0,0 +1,293 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include <intshcut.h>
#include <shlobj.h>
#include "DropTarget.h"
#ifndef CFSTR_SHELLURL
#define CFSTR_SHELLURL _T("UniformResourceLocator")
#endif
#ifndef CFSTR_FILENAME
#define CFSTR_FILENAME _T("FileName")
#endif
#ifndef CFSTR_FILENAMEW
#define CFSTR_FILENAMEW _T("FileNameW")
#endif
static const UINT g_cfURL = RegisterClipboardFormat(CFSTR_SHELLURL);
static const UINT g_cfFileName = RegisterClipboardFormat(CFSTR_FILENAME);
static const UINT g_cfFileNameW = RegisterClipboardFormat(CFSTR_FILENAMEW);
CDropTarget::CDropTarget()
{
m_pOwner = NULL;
}
CDropTarget::~CDropTarget()
{
}
void CDropTarget::SetOwner(CMozillaBrowser *pOwner)
{
m_pOwner = pOwner;
}
HRESULT CDropTarget::GetURLFromFile(const TCHAR *pszFile, tstring &szURL)
{
USES_CONVERSION;
CIPtr(IUniformResourceLocator) spUrl;
// Let's see if the file is an Internet Shortcut...
HRESULT hr = CoCreateInstance (CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, IID_IUniformResourceLocator, (void **) &spUrl);
if (spUrl == NULL)
{
return E_FAIL;
}
// Get the IPersistFile interface
CIPtr(IPersistFile) spFile = spUrl;
if (spFile == NULL)
{
return E_FAIL;
}
// Initialise the URL object from the filename
LPSTR lpTemp = NULL;
if (FAILED(spFile->Load(T2OLE(pszFile), STGM_READ)) ||
FAILED(spUrl->GetURL(&lpTemp)))
{
return E_FAIL;
}
// Free the memory
CIPtr(IMalloc) spMalloc;
if (FAILED(SHGetMalloc(&spMalloc)))
{
return E_FAIL;
}
// Copy the URL & cleanup
szURL = A2T(lpTemp);
spMalloc->Free(lpTemp);
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IDropTarget implementation
HRESULT STDMETHODCALLTYPE CDropTarget::DragEnter(/* [unique][in] */ IDataObject __RPC_FAR *pDataObj, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect)
{
if (pdwEffect == NULL || pDataObj == NULL)
{
NG_ASSERT(0);
return E_INVALIDARG;
}
if (m_spDataObject != NULL)
{
NG_ASSERT(0);
return E_UNEXPECTED;
}
// TODO process Internet Shortcuts (*.URL) files
FORMATETC formatetc;
memset(&formatetc, 0, sizeof(formatetc));
formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1;
formatetc.tymed = TYMED_HGLOBAL;
// Test if the data object contains a text URL format
formatetc.cfFormat = g_cfURL;
if (pDataObj->QueryGetData(&formatetc) == S_OK)
{
m_spDataObject = pDataObj;
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
// Test if the data object contains a file name
formatetc.cfFormat = g_cfFileName;
if (pDataObj->QueryGetData(&formatetc) == S_OK)
{
m_spDataObject = pDataObj;
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
// Test if the data object contains a wide character file name
formatetc.cfFormat = g_cfFileName;
if (pDataObj->QueryGetData(&formatetc) == S_OK)
{
m_spDataObject = pDataObj;
*pdwEffect = DROPEFFECT_LINK;
return S_OK;
}
// If we got here, then the format is not supported
*pdwEffect = DROPEFFECT_NONE;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CDropTarget::DragOver(/* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect)
{
if (pdwEffect == NULL)
{
NG_ASSERT(0);
return E_INVALIDARG;
}
*pdwEffect = m_spDataObject ? DROPEFFECT_LINK : DROPEFFECT_NONE;
return S_OK;
}
HRESULT STDMETHODCALLTYPE CDropTarget::DragLeave(void)
{
if (m_spDataObject)
{
m_spDataObject.Release();
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE CDropTarget::Drop(/* [unique][in] */ IDataObject __RPC_FAR *pDataObj, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect)
{
if (pdwEffect == NULL)
{
NG_ASSERT(0);
return E_INVALIDARG;
}
if (m_spDataObject == NULL)
{
*pdwEffect = DROPEFFECT_NONE;
return S_OK;
}
*pdwEffect = DROPEFFECT_LINK;
// Get the URL from the data object
BSTR bstrURL = NULL;
FORMATETC formatetc;
STGMEDIUM stgmedium;
memset(&formatetc, 0, sizeof(formatetc));
memset(&stgmedium, 0, sizeof(formatetc));
formatetc.dwAspect = DVASPECT_CONTENT;
formatetc.lindex = -1;
formatetc.tymed = TYMED_HGLOBAL;
// Does the data object contain a URL?
formatetc.cfFormat = g_cfURL;
if (m_spDataObject->GetData(&formatetc, &stgmedium) == S_OK)
{
NG_ASSERT(stgmedium.tymed == TYMED_HGLOBAL);
NG_ASSERT(stgmedium.hGlobal);
char *pszURL = (char *) GlobalLock(stgmedium.hGlobal);
NG_TRACE("URL \"%s\" dragged over control\n", pszURL);
// Browse to the URL
if (m_pOwner)
{
USES_CONVERSION;
bstrURL = SysAllocString(A2OLE(pszURL));
}
GlobalUnlock(stgmedium.hGlobal);
goto finish;
}
// Does the data object point to a file?
formatetc.cfFormat = g_cfFileName;
if (m_spDataObject->GetData(&formatetc, &stgmedium) == S_OK)
{
USES_CONVERSION;
NG_ASSERT(stgmedium.tymed == TYMED_HGLOBAL);
NG_ASSERT(stgmedium.hGlobal);
tstring szURL;
char *pszURLFile = (char *) GlobalLock(stgmedium.hGlobal);
NG_TRACE("File \"%s\" dragged over control\n", pszURLFile);
if (SUCCEEDED(GetURLFromFile(A2T(pszURLFile), szURL)))
{
bstrURL = SysAllocString(T2OLE(szURL.c_str()));
}
GlobalUnlock(stgmedium.hGlobal);
goto finish;
}
// Does the data object point to a wide character file?
formatetc.cfFormat = g_cfFileNameW;
if (m_spDataObject->GetData(&formatetc, &stgmedium) == S_OK)
{
USES_CONVERSION;
NG_ASSERT(stgmedium.tymed == TYMED_HGLOBAL);
NG_ASSERT(stgmedium.hGlobal);
tstring szURL;
WCHAR *pszURLFile = (WCHAR *) GlobalLock(stgmedium.hGlobal);
NG_TRACE("File \"%s\" dragged over control\n", W2A(pszURLFile));
if (SUCCEEDED(GetURLFromFile(W2T(pszURLFile), szURL)))
{
USES_CONVERSION;
bstrURL = SysAllocString(T2OLE(szURL.c_str()));
}
GlobalUnlock(stgmedium.hGlobal);
goto finish;
}
finish:
// If we got a URL, browse there!
if (bstrURL)
{
m_pOwner->Navigate(bstrURL, NULL, NULL, NULL, NULL);
SysFreeString(bstrURL);
}
ReleaseStgMedium(&stgmedium);
m_spDataObject.Release();
return S_OK;
}

Просмотреть файл

@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef DROPTARGET_H
#define DROPTARGET_H
#include "MozillaBrowser.h"
// Simple drop target implementation
class CDropTarget : public CComObjectRootEx<CComSingleThreadModel>,
public IDropTarget
{
public:
CDropTarget();
virtual ~CDropTarget();
BEGIN_COM_MAP(CDropTarget)
COM_INTERFACE_ENTRY(IDropTarget)
END_COM_MAP()
// Data object currently being dragged
CIPtr(IDataObject) m_spDataObject;
// Owner of this object
CMozillaBrowser *m_pOwner;
// Sets the owner of this object
void SetOwner(CMozillaBrowser *pOwner);
// Helper method to extract a URL from an internet shortcut file
HRESULT CDropTarget::GetURLFromFile(const TCHAR *pszFile, tstring &szURL);
// IDropTarget
virtual HRESULT STDMETHODCALLTYPE DragEnter(/* [unique][in] */ IDataObject __RPC_FAR *pDataObj, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
virtual HRESULT STDMETHODCALLTYPE DragOver(/* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
virtual HRESULT STDMETHODCALLTYPE DragLeave(void);
virtual HRESULT STDMETHODCALLTYPE Drop(/* [unique][in] */ IDataObject __RPC_FAR *pDataObj, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
};
typedef CComObject<CDropTarget> CDropTargetInstance;
#endif

Просмотреть файл

@ -0,0 +1,557 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include <commctrl.h>
// commdlg.h is needed to build with WIN32_LEAN_AND_MEAN
#include <commdlg.h>
#include "HelperAppDlg.h"
#include "nsCOMPtr.h"
#include "nsIExternalHelperAppService.h"
#include "nsILocalFile.h"
#include "nsIMIMEInfo.h"
#include "nsIHelperAppLauncherDialog.h"
#include "nsNetError.h"
///////////////////////////////////////////////////////////////////////////////
class AppLauncherDlg
{
public:
AppLauncherDlg();
virtual ~AppLauncherDlg();
int Show(nsIHelperAppLauncher* aLauncher, HWND hwndParent);
PRPackedBool mSaveToDisk;
nsCAutoString mOpenWith;
private:
static INT_PTR CALLBACK LaunchProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void OnInitDialog();
void OnOK();
void OnCancel();
void OnChooseApp();
HWND mHwndDlg;
nsCOMPtr<nsIHelperAppLauncher> mHelperAppLauncher;
};
AppLauncherDlg::AppLauncherDlg() : mHwndDlg(NULL), mSaveToDisk(TRUE)
{
}
AppLauncherDlg::~AppLauncherDlg()
{
}
int
AppLauncherDlg::Show(nsIHelperAppLauncher* aLauncher, HWND hwndParent)
{
HINSTANCE hInstResource = _Module.m_hInstResource;
mHelperAppLauncher = aLauncher;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_HELPERAPP), hwndParent, LaunchProc, (LPARAM) this);
return result;
}
void AppLauncherDlg::OnInitDialog()
{
USES_CONVERSION;
nsCOMPtr<nsIMIMEInfo> mimeInfo;
nsCAutoString url;
if (mHelperAppLauncher)
{
mHelperAppLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
nsCOMPtr<nsIURI> uri;
mHelperAppLauncher->GetSource(getter_AddRefs(uri));
uri->GetSpec(url);
}
nsHandlerInfoAction prefAction = nsIMIMEInfo::saveToDisk;
nsAutoString appName;
nsCAutoString contentType;
if (mimeInfo)
{
mimeInfo->GetPreferredAction(&prefAction);
nsCOMPtr<nsIHandlerApp> handlerApp;
mimeInfo->GetPreferredApplicationHandler(getter_AddRefs(handlerApp));
if (handlerApp)
{
handlerApp->GetName(appName);
}
mimeInfo->GetMIMEType(contentType);
}
if (prefAction == nsIMIMEInfo::saveToDisk)
{
CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_SAVETOFILE);
}
else
{
CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP);
}
SetDlgItemText(mHwndDlg, IDC_URL,
url.IsEmpty() ? _T("") : A2CT(url.get()));
SetDlgItemText(mHwndDlg, IDC_APPLICATION,
appName.IsEmpty() ? _T("<No Application>") : W2CT(appName.get()));
SetDlgItemText(mHwndDlg, IDC_CONTENTTYPE,
contentType.IsEmpty() ? _T("") : A2CT(contentType.get()));
}
void AppLauncherDlg::OnOK()
{
mSaveToDisk = IsDlgButtonChecked(mHwndDlg, IDC_SAVETOFILE) ? TRUE : FALSE;
EndDialog(mHwndDlg, IDOK);
}
void AppLauncherDlg::OnCancel()
{
EndDialog(mHwndDlg, IDCANCEL);
}
void AppLauncherDlg::OnChooseApp()
{
USES_CONVERSION;
TCHAR szPath[MAX_PATH + 1];
memset(szPath, 0, sizeof(szPath));
TCHAR *lpszFilter =
_T("EXE Files Only (*.exe)\0*.exe\0"
"All Files (*.*)\0*.*\0\0");
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
#if _WIN32_WINNT >= 0x0500
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#else
ofn.lStructSize = sizeof(ofn);
#endif
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrFilter = lpszFilter;
ofn.lpstrDefExt = _T("exe");
ofn.lpstrFile = szPath;
ofn.nMaxFile = MAX_PATH;
if (GetOpenFileName(&ofn))
{
USES_CONVERSION;
mOpenWith = T2A(szPath);
SetDlgItemText(mHwndDlg, IDC_APPLICATION, szPath);
CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP);
}
}
INT_PTR CALLBACK
AppLauncherDlg::LaunchProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
AppLauncherDlg *pThis = NULL;
if (uMsg == WM_INITDIALOG)
{
pThis = (AppLauncherDlg *) lParam;
NS_ASSERTION(pThis, "need a pointer to this!");
pThis->mHwndDlg = hwndDlg;
SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
}
else
{
pThis = (AppLauncherDlg *) GetWindowLongPtr(hwndDlg, DWLP_USER);
}
switch (uMsg)
{
case WM_INITDIALOG:
pThis->OnInitDialog();
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
NS_ASSERTION(pThis, "Should be non-null!");
switch (LOWORD(wParam))
{
case IDC_CHOOSE:
pThis->OnChooseApp();
break;
case IDOK:
pThis->OnOK();
break;
case IDCANCEL:
pThis->OnCancel();
break;
}
}
return TRUE;
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//*****************************************************************************
// ProgressDlg
//*****************************************************************************
class ProgressDlg :
public nsIWebProgressListener,
public nsSupportsWeakReference
{
public:
ProgressDlg();
void Show(nsIHelperAppLauncher *aHelperAppLauncher, HWND hwndParent);
protected:
virtual ~ProgressDlg();
void OnInitDialog();
void OnCancel();
static INT_PTR CALLBACK ProgressProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND mHwndDlg;
nsCOMPtr<nsIHelperAppLauncher> mHelperAppLauncher;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
};
ProgressDlg::ProgressDlg()
{
}
ProgressDlg::~ProgressDlg()
{
}
void
ProgressDlg::Show(nsIHelperAppLauncher *aHelperAppLauncher, HWND hwndParent)
{
HINSTANCE hInstResource = _Module.m_hInstResource;
mHelperAppLauncher = aHelperAppLauncher;
mHwndDlg = CreateDialogParam(hInstResource, MAKEINTRESOURCE(IDD_PROGRESS),
hwndParent, ProgressProc, (LPARAM) this);
}
NS_IMPL_ISUPPORTS2(ProgressDlg, nsIWebProgressListener, nsISupportsWeakReference)
NS_IMETHODIMP
ProgressDlg::OnStateChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aStateFlags,
nsresult aStatus)
{
if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_DOCUMENT))
{
// We've completed the download - close the progress window
if(mHelperAppLauncher)
mHelperAppLauncher->CloseProgressWindow();
DestroyWindow(mHwndDlg);
}
return NS_OK;
}
NS_IMETHODIMP ProgressDlg::OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
{
// Update the progress control
if (IsWindow(mHwndDlg))
{
HWND hwndProgress = GetDlgItem(mHwndDlg, IDC_PROGRESS);
SendMessage(hwndProgress, PBM_SETRANGE32, 0, aMaxTotalProgress);
SendMessage(hwndProgress, PBM_SETPOS, aCurTotalProgress, 0);
}
return NS_OK;
}
NS_IMETHODIMP ProgressDlg::OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *location)
{
return NS_OK;
}
NS_IMETHODIMP ProgressDlg::OnStatusChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
return NS_OK;
}
NS_IMETHODIMP ProgressDlg::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 state)
{
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK
ProgressDlg::ProgressProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
ProgressDlg *pThis = NULL;
if (uMsg == WM_INITDIALOG)
{
pThis = (ProgressDlg *) lParam;
SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
}
else
{
pThis = (ProgressDlg *) GetWindowLongPtr(hwndDlg, DWLP_USER);
}
switch (uMsg)
{
case WM_INITDIALOG:
NS_ASSERTION(pThis, "Should be non-null!");
pThis->OnInitDialog();
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
NS_ASSERTION(pThis, "Should be non-null!");
switch (LOWORD(wParam))
{
case IDCANCEL:
pThis->OnCancel();
break;
}
}
return TRUE;
}
return FALSE;
}
void ProgressDlg::OnInitDialog()
{
// Set the "SavingFrom" field
if (mHelperAppLauncher)
{
nsCOMPtr<nsIURI> srcUri;
nsresult rv = mHelperAppLauncher->GetSource(getter_AddRefs(srcUri));
if(NS_SUCCEEDED(rv))
{
USES_CONVERSION;
nsCAutoString uriString;
srcUri->GetSpec(uriString);
SetDlgItemText(mHwndDlg, IDC_SOURCE, A2CT(uriString.get()));
}
}
// Set the "Action" field
// if(m_HandleContentOp == CONTENT_SAVE_TO_DISK)
// m_Action.SetWindowText("[Saving file to:] " + m_FileName);
// else if(m_HandleContentOp == CONTENT_LAUNCH_WITH_APP)
// m_Action.SetWindowText("[Opening file with:] " + m_FileName);
}
void ProgressDlg::OnCancel()
{
if (mHelperAppLauncher)
mHelperAppLauncher->Cancel(NS_BINDING_ABORTED);
DestroyWindow(mHwndDlg);
}
///////////////////////////////////////////////////////////////////////////////
class CHelperAppLauncherDlgFactory : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
CHelperAppLauncherDlgFactory();
virtual ~CHelperAppLauncherDlgFactory();
};
class CHelperAppLauncherDlg :
public nsIHelperAppLauncherDialog
{
public:
CHelperAppLauncherDlg();
protected:
virtual ~CHelperAppLauncherDlg();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIHELPERAPPLAUNCHERDIALOG
friend class CHelperAppLauncherDlgFactory;
};
NS_IMPL_ISUPPORTS1(CHelperAppLauncherDlg, nsIHelperAppLauncherDialog)
CHelperAppLauncherDlg::CHelperAppLauncherDlg()
{
}
CHelperAppLauncherDlg::~CHelperAppLauncherDlg()
{
}
/* void show (in nsIHelperAppLauncher aLauncher, in nsISupports aContext, in unsigned long aReason); */
NS_IMETHODIMP
CHelperAppLauncherDlg::Show(nsIHelperAppLauncher *aLauncher, nsISupports *aContext, PRUint32 aReason)
{
NS_ENSURE_ARG_POINTER(aLauncher);
AppLauncherDlg dlg;
if (dlg.Show(aLauncher, NULL) == IDCANCEL)
{
aLauncher->Cancel(NS_BINDING_ABORTED);
return NS_OK;
}
if (dlg.mSaveToDisk)
{
return aLauncher->SaveToDisk(nsnull, PR_FALSE);
}
else
{
nsCOMPtr<nsILocalFile> openWith;
nsresult rv = NS_NewNativeLocalFile(dlg.mOpenWith, PR_FALSE, getter_AddRefs(openWith));
return aLauncher->LaunchWithApplication(openWith, PR_FALSE);
}
}
/* nsILocalFile promptForSaveToFile (in nsIHelperAppLauncher aLauncher, in nsISupports aWindowContext, in wstring aDefaultFile, in wstring aSuggestedFileExtension); */
NS_IMETHODIMP
CHelperAppLauncherDlg::PromptForSaveToFile(nsIHelperAppLauncher *aLauncher,
nsISupports *aWindowContext,
const PRUnichar *aDefaultFile,
const PRUnichar *aSuggestedFileExtension,
PRBool aForcePrompt,
nsILocalFile **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
USES_CONVERSION;
TCHAR szPath[MAX_PATH + 1];
memset(szPath, 0, sizeof(szPath));
_tcsncpy(szPath, W2T(aDefaultFile), MAX_PATH);
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
#if _WIN32_WINNT >= 0x0500
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#else
ofn.lStructSize = sizeof(ofn);
#endif
ofn.Flags = OFN_OVERWRITEPROMPT;
ofn.lpstrFilter = _T("All Files (*.*)\0*.*\0\0");
ofn.lpstrDefExt = W2T(aSuggestedFileExtension);
ofn.lpstrFile = szPath;
ofn.nMaxFile = MAX_PATH;
if (GetSaveFileName(&ofn))
{
return NS_NewNativeLocalFile(nsDependentCString(szPath), PR_FALSE, _retval);
}
return NS_ERROR_FAILURE;
}
//*****************************************************************************
// CHelperAppLauncherDlgFactory
//*****************************************************************************
NS_IMPL_ISUPPORTS1(CHelperAppLauncherDlgFactory, nsIFactory)
CHelperAppLauncherDlgFactory::CHelperAppLauncherDlgFactory()
{
}
CHelperAppLauncherDlgFactory::~CHelperAppLauncherDlgFactory()
{
}
NS_IMETHODIMP CHelperAppLauncherDlgFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = NULL;
CHelperAppLauncherDlg *inst = new CHelperAppLauncherDlg;
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = inst->QueryInterface(aIID, aResult);
if (rv != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
return rv;
}
NS_IMETHODIMP CHelperAppLauncherDlgFactory::LockFactory(PRBool lock)
{
return NS_OK;
}
nsresult NS_NewHelperAppLauncherDlgFactory(nsIFactory** aFactory)
{
NS_ENSURE_ARG_POINTER(aFactory);
*aFactory = nsnull;
CHelperAppLauncherDlgFactory *result = new CHelperAppLauncherDlgFactory;
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*aFactory = result;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef HELPERAPPDLG_H
#define HELPERAPPDLG_H
#include "nsError.h"
class nsIFactory;
extern nsresult NS_NewHelperAppLauncherDlgFactory(nsIFactory** aFactory);
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,195 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEHTMLDOCUMENT_H
#define IEHTMLDOCUMENT_H
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "IEHtmlNode.h"
class CMozillaBrowser;
class CIEHtmlDocument :
public CNode,
public IDispatchImpl<IHTMLDocument2, &IID_IHTMLDocument2, &LIBID_MSHTML, 4, 0>,
public IOleCommandTarget
{
public:
CIEHtmlDocument();
protected:
virtual ~CIEHtmlDocument();
// Pointer to browser that owns the document
CMozillaBrowser *mControl;
nsCOMPtr<nsIDOMHTMLDocument> mDOMDocument;
HRESULT WriteCommon(SAFEARRAY __RPC_FAR * psarray, int bLn);
public:
virtual void SetParent(CMozillaBrowser *parent);
virtual void SetNative(nsIDOMHTMLDocument *native);
BEGIN_COM_MAP(CIEHtmlDocument)
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IHTMLDocument2)
COM_INTERFACE_ENTRY_IID(IID_IHTMLDocument, IHTMLDocument2)
COM_INTERFACE_ENTRY_IID(IID_IHTMLDocument2, IHTMLDocument2)
COM_INTERFACE_ENTRY(IOleCommandTarget)
END_COM_MAP()
// IOleCommandTarget methods
virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID __RPC_FAR *pguidCmdGroup, ULONG cCmds, OLECMD __RPC_FAR prgCmds[], OLECMDTEXT __RPC_FAR *pCmdText);
virtual HRESULT STDMETHODCALLTYPE Exec(const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT __RPC_FAR *pvaIn, VARIANT __RPC_FAR *pvaOut);
// IHTMLDocument methods
virtual HRESULT STDMETHODCALLTYPE get_Script(IDispatch __RPC_FAR *__RPC_FAR *p);
// IHTMLDocument2 methods
virtual HRESULT STDMETHODCALLTYPE get_all(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_body(IHTMLElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_activeElement(IHTMLElement __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_images(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_applets(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_links(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_forms(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_anchors(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_title(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_title(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_scripts(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_designMode(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_designMode(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_selection(IHTMLSelectionObject __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_readyState(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_frames(IHTMLFramesCollection2 __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_embeds(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_plugins(IHTMLElementCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_alinkColor(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_alinkColor(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_bgColor(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_bgColor(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_fgColor(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_fgColor(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_linkColor(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_linkColor(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_vlinkColor(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_vlinkColor(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_referrer(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_location(IHTMLLocation __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_lastModified(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_URL(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_URL(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_domain(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_domain(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_cookie(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_cookie(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_expando(VARIANT_BOOL v);
virtual HRESULT STDMETHODCALLTYPE get_expando(VARIANT_BOOL __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_charset(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_charset(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_defaultCharset(BSTR v);
virtual HRESULT STDMETHODCALLTYPE get_defaultCharset(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_mimeType(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_fileSize(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_fileCreatedDate(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_fileModifiedDate(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_fileUpdatedDate(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_security(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_protocol(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_nameProp(BSTR __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE write(SAFEARRAY __RPC_FAR * psarray);
virtual HRESULT STDMETHODCALLTYPE writeln(SAFEARRAY __RPC_FAR * psarray);
virtual HRESULT STDMETHODCALLTYPE open(BSTR url, VARIANT name, VARIANT features, VARIANT replace, IDispatch __RPC_FAR *__RPC_FAR *pomWindowResult);
virtual HRESULT STDMETHODCALLTYPE close(void);
virtual HRESULT STDMETHODCALLTYPE clear(void);
virtual HRESULT STDMETHODCALLTYPE queryCommandSupported(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandEnabled(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandState(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandIndeterm(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE queryCommandText(BSTR cmdID, BSTR __RPC_FAR *pcmdText);
virtual HRESULT STDMETHODCALLTYPE queryCommandValue(BSTR cmdID, VARIANT __RPC_FAR *pcmdValue);
virtual HRESULT STDMETHODCALLTYPE execCommand(BSTR cmdID, VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE execCommandShowHelp(BSTR cmdID, VARIANT_BOOL __RPC_FAR *pfRet);
virtual HRESULT STDMETHODCALLTYPE createElement(BSTR eTag, IHTMLElement __RPC_FAR *__RPC_FAR *newElem);
virtual HRESULT STDMETHODCALLTYPE put_onhelp(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onhelp(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onclick(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onclick(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondblclick(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondblclick(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeyup(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeyup(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeydown(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeydown(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onkeypress(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onkeypress(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseup(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseup(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmousedown(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmousedown(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmousemove(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmousemove(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseout(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseout(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onmouseover(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onmouseover(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onreadystatechange(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onreadystatechange(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onafterupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onafterupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onrowexit(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onrowexit(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onrowenter(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onrowenter(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_ondragstart(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_ondragstart(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onselectstart(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onselectstart(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE elementFromPoint(long x, long y, IHTMLElement __RPC_FAR *__RPC_FAR *elementHit);
virtual HRESULT STDMETHODCALLTYPE get_parentWindow(IHTMLWindow2 __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE get_styleSheets(IHTMLStyleSheetsCollection __RPC_FAR *__RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onbeforeupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onbeforeupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE put_onerrorupdate(VARIANT v);
virtual HRESULT STDMETHODCALLTYPE get_onerrorupdate(VARIANT __RPC_FAR *p);
virtual HRESULT STDMETHODCALLTYPE toString(BSTR __RPC_FAR *String);
virtual HRESULT STDMETHODCALLTYPE createStyleSheet(BSTR bstrHref, long lIndex, IHTMLStyleSheet __RPC_FAR *__RPC_FAR *ppnewStyleSheet);
};
typedef CComObject<CIEHtmlDocument> CIEHtmlDocumentInstance;
#endif

Просмотреть файл

@ -0,0 +1,113 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Netscape Communications, Inc.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Adam Lock <adamlock@eircom.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = mozctl
RESFILE = MozillaControl.res
DEFFILE = L_mozctl.def
FORCE_SHARED_LIB= 1
CPPSRCS = \
StdAfx.cpp \
MozillaControl.cpp \
MozillaBrowser.cpp \
WebBrowserContainer.cpp \
IEHtmlDocument.cpp \
DropTarget.cpp \
PropertyDlg.cpp \
PromptService.cpp \
HelperAppDlg.cpp \
WindowCreator.cpp \
$(NULL)
EXTRA_DSO_LDOPTS = \
$(DEPTH)/embedding/base/$(LIB_PREFIX)embed_base_s.$(LIB_SUFFIX) \
../common/$(LIB_PREFIX)ax_common_s.$(LIB_SUFFIX) \
$(MOZ_UNICHARUTIL_LIBS) \
$(XPCOM_GLUE_LDOPTS) \
$(XPCOM_FROZEN_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
OS_LIBS += \
comdlg32.lib \
ole32.lib \
oleaut32.lib \
uuid.lib \
shell32.lib \
$(NULL)
MIDL_GENERATED_FILES = MozillaControl_i.c MozillaControl.h
GARBAGE += $(DEFFILE) $(MIDL_GENERATED_FILES) done_gen
ENABLE_CXX_EXCEPTIONS = 1
EMBED_MANIFEST_AT = 2
include $(topsrcdir)/config/rules.mk
CXXFLAGS += -D "WIN32" -U "ClientWallet"
LDFLAGS += -SUBSYSTEM:windows -DLL
ifdef MOZ_NO_DEBUG_RTL
DEFINES += -DMOZ_NO_DEBUG_RTL
endif
DEFINES += -DMOZ_ACTIVEX_CONTROL_SUPPORT
LOCAL_INCLUDES += -I.
export:: $(DEFFILE) done_gen
$(DEFFILE): mkctldef.sh
$(srcdir)/mkctldef.sh $@
done_gen: MozillaControl.idl
$(MIDL) $(MIDL_FLAGS) -Oicf -h MozillaControl.h -iid MozillaControl_i.c $(srcdir)/MozillaControl.idl
touch $@
$(MIDL_GENERATED_FILES): done_gen

Просмотреть файл

@ -0,0 +1,97 @@
# Microsoft Developer Studio Project File - Name="Master" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) External Target" 0x0106
CFG=Master - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Master.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Master.mak" CFG="Master - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Master - Win32 Release" (based on "Win32 (x86) External Target")
!MESSAGE "Master - Win32 Debug" (based on "Win32 (x86) External Target")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "Master - Win32 Release"
# PROP BASE Use_MFC
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Cmd_Line "NMAKE /f Master.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "Master.exe"
# PROP BASE Bsc_Name "Master.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Cmd_Line "nmake /f "Master.mak""
# PROP Rebuild_Opt "/a"
# PROP Target_File "Master.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "Master - Win32 Debug"
# PROP BASE Use_MFC
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Master___Win32_Debug"
# PROP BASE Intermediate_Dir "Master___Win32_Debug"
# PROP BASE Cmd_Line "NMAKE /f Master.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "Master.exe"
# PROP BASE Bsc_Name "Master.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Master___Win32_Debug"
# PROP Intermediate_Dir "Master___Win32_Debug"
# PROP Cmd_Line "nmake /f "Master.mak""
# PROP Rebuild_Opt "/a"
# PROP Target_File "Master.exe"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ENDIF
# Begin Target
# Name "Master - Win32 Release"
# Name "Master - Win32 Debug"
!IF "$(CFG)" == "Master - Win32 Release"
!ELSEIF "$(CFG)" == "Master - Win32 Debug"
!ENDIF
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

Просмотреть файл

@ -0,0 +1,92 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "IEPatcher"=..\..\tests\IEPatcher\IEPatcher.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Master"=.\Master.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name cbrowse
End Project Dependency
Begin Project Dependency
Project_Dep_Name MozillaControl
End Project Dependency
Begin Project Dependency
Project_Dep_Name IEPatcher
End Project Dependency
Begin Project Dependency
Project_Dep_Name RegMozCtl
End Project Dependency
}}}
###############################################################################
Project: "MozillaControl"=.\MozillaControl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "RegMozCtl"=..\..\tests\RegMozCtl\RegMozCtl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "cbrowse"=..\..\tests\cbrowse\cbrowse.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name MozillaControl
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,448 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// MozillaBrowser.h : Declaration of the CMozillaBrowser
#ifndef __MOZILLABROWSER_H_
#define __MOZILLABROWSER_H_
#include "IWebBrowserImpl.h"
// Commands sent via WM_COMMAND
enum {
ID_PRINT = 1,
ID_PAGESETUP,
ID_VIEWSOURCE,
ID_SAVEAS,
ID_PROPERTIES,
ID_CUT,
ID_COPY,
ID_PASTE,
ID_SELECTALL
};
// Command group and IDs exposed through IOleCommandTarget
extern GUID CGID_IWebBrowser_Moz;
extern GUID CGID_MSHTML_Moz;
enum {
HTMLID_FIND = 1,
HTMLID_VIEWSOURCE,
HTMLID_OPTIONS
};
// A list of objects
typedef CComPtr<IUnknown> CComUnkPtr;
class CWebBrowserContainer;
class CPromptService;
/////////////////////////////////////////////////////////////////////////////
// CMozillaBrowser
class ATL_NO_VTABLE CMozillaBrowser :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CMozillaBrowser, &CLSID_MozillaBrowser>,
public CComControl<CMozillaBrowser>,
public IPropertyNotifySinkCP<CMozillaBrowser>,
public IWebBrowserImpl<CMozillaBrowser, &CLSID_MozillaBrowser, &LIBID_MOZILLACONTROLLib>,
public IProvideClassInfo2Impl<&CLSID_MozillaBrowser, &DIID_DWebBrowserEvents2, &LIBID_MOZILLACONTROLLib>,
public IPersistStreamInitImpl<CMozillaBrowser>,
public IPersistStorageImpl<CMozillaBrowser>,
public IPersistPropertyBagImpl<CMozillaBrowser>,
public IQuickActivateImpl<CMozillaBrowser>,
public IOleControlImpl<CMozillaBrowser>,
public IOleObjectImpl<CMozillaBrowser>,
public IOleInPlaceActiveObjectImpl<CMozillaBrowser>,
public IViewObjectExImpl<CMozillaBrowser>,
public IOleInPlaceObjectWindowlessImpl<CMozillaBrowser>,
public IDataObjectImpl<CMozillaBrowser>,
public ISupportErrorInfo,
public IOleCommandTargetImpl<CMozillaBrowser>,
public IConnectionPointContainerImpl<CMozillaBrowser>,
public ISpecifyPropertyPagesImpl<CMozillaBrowser>,
public IObjectSafetyImpl<CMozillaBrowser, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
public IMozControlBridge
{
friend CWebBrowserContainer;
friend CPromptService;
public:
CMozillaBrowser();
virtual ~CMozillaBrowser();
DECLARE_REGISTRY_RESOURCEID(IDR_MOZILLABROWSER)
BEGIN_COM_MAP(CMozillaBrowser)
// Mozilla control interfaces
COM_INTERFACE_ENTRY(IMozControlBridge)
// IE web browser interface
COM_INTERFACE_ENTRY(IWebBrowser2)
COM_INTERFACE_ENTRY_IID(IID_IDispatch, IWebBrowser2)
COM_INTERFACE_ENTRY_IID(IID_IWebBrowser, IWebBrowser2)
COM_INTERFACE_ENTRY_IID(IID_IWebBrowserApp, IWebBrowser2)
// Outgoing IE event interfaces
COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents,
CProxyDWebBrowserEvents<CMozillaBrowser>)
COM_INTERFACE_ENTRY_IID(DIID_DWebBrowserEvents2,
CProxyDWebBrowserEvents2<CMozillaBrowser>)
// Other ActiveX/OLE interfaces
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY_IID(IID_IViewObject2, IViewObjectEx)
COM_INTERFACE_ENTRY_IID(IID_IViewObject, IViewObjectEx)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IQuickActivate) // This causes size assertion in ATL
COM_INTERFACE_ENTRY2(IPersist, IPersistPropertyBag)
COM_INTERFACE_ENTRY(IPersistPropertyBag)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IOleCommandTarget)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IObjectSafety)
END_COM_MAP()
// Properties supported by the control that map onto property
// pages that the user may be able to configure from tools like VB.
BEGIN_PROPERTY_MAP(CMozillaBrowser)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
PROP_PAGE(CLSID_StockColorPage)
PROP_DATA_ENTRY("SRC", mInitialSrc, VT_BSTR)
END_PROPERTY_MAP()
// Table of outgoing connection points. Anyone subscribing
// to events from the control should do so through one of these
// connect points.
BEGIN_CONNECTION_POINT_MAP(CMozillaBrowser)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
// Fires IE events
CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents2)
CONNECTION_POINT_ENTRY(DIID_DWebBrowserEvents)
END_CONNECTION_POINT_MAP()
// Table of window messages and their associate handlers
BEGIN_MSG_MAP(CMozillaBrowser)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode)
MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate)
COMMAND_ID_HANDLER(ID_PRINT, OnPrint)
COMMAND_ID_HANDLER(ID_PAGESETUP, OnPageSetup)
COMMAND_ID_HANDLER(ID_SAVEAS, OnSaveAs)
COMMAND_ID_HANDLER(ID_PROPERTIES, OnProperties)
COMMAND_ID_HANDLER(ID_CUT, OnCut)
COMMAND_ID_HANDLER(ID_COPY, OnCopy)
COMMAND_ID_HANDLER(ID_PASTE, OnPaste)
COMMAND_ID_HANDLER(ID_SELECTALL, OnSelectAll)
COMMAND_ID_HANDLER(ID_DOCUMENT_BACK, OnDocumentBack)
COMMAND_ID_HANDLER(ID_DOCUMENT_FORWARD, OnDocumentForward)
COMMAND_ID_HANDLER(ID_DOCUMENT_PRINT, OnDocumentPrint)
COMMAND_ID_HANDLER(ID_DOCUMENT_REFRESH, OnDocumentRefresh)
COMMAND_ID_HANDLER(ID_DOCUMENT_PROPERTIES, OnDocumentProperties)
COMMAND_ID_HANDLER(ID_DOCUMENT_VIEWSOURCE, OnViewSource)
COMMAND_ID_HANDLER(ID_LINK_OPEN, OnLinkOpen)
COMMAND_ID_HANDLER(ID_LINK_OPENINNEWWINDOW, OnLinkOpenInNewWindow)
COMMAND_ID_HANDLER(ID_LINK_COPYSHORTCUT, OnLinkCopyShortcut)
COMMAND_ID_HANDLER(ID_LINK_PROPERTIES, OnLinkProperties)
END_MSG_MAP()
static HRESULT _stdcall PrintHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
static HRESULT _stdcall EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
static HRESULT _stdcall EditCommandHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
// Table of OLE commands (invoked through IOleCommandTarget and their
// associated command groups and command handlers.
BEGIN_OLECOMMAND_TABLE()
// Standard "common" commands
OLECOMMAND_HANDLER(OLECMDID_PRINT, NULL, PrintHandler, L"Print", L"Print the page")
OLECOMMAND_MESSAGE(OLECMDID_PAGESETUP, NULL, ID_PAGESETUP, L"Page Setup", L"Page Setup")
OLECOMMAND_MESSAGE(OLECMDID_UNDO, NULL, 0, L"Undo", L"Undo")
OLECOMMAND_MESSAGE(OLECMDID_REDO, NULL, 0, L"Redo", L"Redo")
OLECOMMAND_MESSAGE(OLECMDID_REFRESH, NULL, 0, L"Refresh", L"Refresh")
OLECOMMAND_MESSAGE(OLECMDID_STOP, NULL, 0, L"Stop", L"Stop")
OLECOMMAND_MESSAGE(OLECMDID_ONUNLOAD, NULL, 0, L"OnUnload", L"OnUnload")
OLECOMMAND_MESSAGE(OLECMDID_SAVEAS, NULL, ID_SAVEAS, L"SaveAs", L"Save the page")
OLECOMMAND_MESSAGE(OLECMDID_CUT, NULL, ID_CUT, L"Cut", L"Cut selection")
OLECOMMAND_MESSAGE(OLECMDID_COPY, NULL, ID_COPY, L"Copy", L"Copy selection")
OLECOMMAND_MESSAGE(OLECMDID_PASTE, NULL, ID_PASTE, L"Paste", L"Paste as selection")
OLECOMMAND_MESSAGE(OLECMDID_SELECTALL, NULL, ID_SELECTALL, L"SelectAll", L"Select all")
OLECOMMAND_MESSAGE(OLECMDID_PROPERTIES, NULL, ID_PROPERTIES, L"Properties", L"Show page properties")
// Unsupported IE 4.x command group
OLECOMMAND_MESSAGE(HTMLID_FIND, &CGID_IWebBrowser_Moz, 0, L"Find", L"Find")
OLECOMMAND_MESSAGE(HTMLID_VIEWSOURCE, &CGID_IWebBrowser_Moz, ID_VIEWSOURCE, L"ViewSource", L"View Source")
OLECOMMAND_MESSAGE(HTMLID_OPTIONS, &CGID_IWebBrowser_Moz, 0, L"Options", L"Options")
// DHTML editor command group
OLECOMMAND_HANDLER(IDM_EDITMODE, &CGID_MSHTML_Moz, EditModeHandler, L"EditMode", L"Switch to edit mode")
OLECOMMAND_HANDLER(IDM_BROWSEMODE, &CGID_MSHTML_Moz, EditModeHandler, L"UserMode", L"Switch to user mode")
OLECOMMAND_HANDLER(IDM_BOLD, &CGID_MSHTML_Moz, EditCommandHandler, L"Bold", L"Toggle Bold")
OLECOMMAND_HANDLER(IDM_ITALIC, &CGID_MSHTML_Moz, EditCommandHandler, L"Italic", L"Toggle Italic")
OLECOMMAND_HANDLER(IDM_UNDERLINE, &CGID_MSHTML_Moz, EditCommandHandler, L"Underline", L"Toggle Underline")
OLECOMMAND_HANDLER(IDM_UNKNOWN, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNBOTTOM, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNHORIZONTALCENTERS, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNLEFT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNRIGHT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNTOGRID, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNTOP, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ALIGNVERTICALCENTERS, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ARRANGEBOTTOM, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ARRANGERIGHT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_BRINGFORWARD, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_BRINGTOFRONT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CENTERHORIZONTALLY, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CENTERVERTICALLY, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CODE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_DELETE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FONTNAME, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FONTSIZE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_GROUP, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_HORIZSPACECONCATENATE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_HORIZSPACEDECREASE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_HORIZSPACEINCREASE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_HORIZSPACEMAKEEQUAL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_INSERTOBJECT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_MULTILEVELREDO, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SENDBACKWARD, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SENDTOBACK, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SHOWTABLE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SIZETOCONTROL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SIZETOCONTROLHEIGHT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SIZETOCONTROLWIDTH, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SIZETOFIT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SIZETOGRID, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SNAPTOGRID, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_TABORDER, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_TOOLBOX, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_MULTILEVELUNDO, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_UNGROUP, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_VERTSPACECONCATENATE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_VERTSPACEDECREASE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_VERTSPACEINCREASE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_VERTSPACEMAKEEQUAL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYFULL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_BACKCOLOR, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_BORDERCOLOR, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FLAT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FORECOLOR, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYCENTER, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYGENERAL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYLEFT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYRIGHT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_RAISED, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SUNKEN, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CHISELED, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_ETCHED, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SHADOWED, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FIND, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_SHOWGRID, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST0, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST1, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST2, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST3, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST4, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST5, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST6, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST7, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST8, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLIST9, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_OBJECTVERBLISTLAST, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CONVERTOBJECT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CUSTOMCONTROL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CUSTOMIZEITEM, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_RENAME, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_IMPORT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_NEWPAGE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_MOVE, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_CANCEL, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_FONT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_STRIKETHROUGH, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_DELETEWORD, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_EXECPRINT, &CGID_MSHTML_Moz, NULL, L"", L"")
OLECOMMAND_HANDLER(IDM_JUSTIFYNONE, &CGID_MSHTML_Moz, NULL, L"", L"")
END_OLECOMMAND_TABLE()
HWND GetCommandTargetWindow() const
{
return m_hWnd;
}
// Windows message handlers
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPageSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnViewSource(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDocumentBack(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDocumentForward(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDocumentPrint(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDocumentRefresh(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDocumentProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnLinkOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnLinkOpenInNewWindow(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnLinkCopyShortcut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnLinkProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
// IViewObjectEx
STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
{
ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
*pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
return S_OK;
}
// Protected members
protected:
// List of browsers
static nsTArray<CMozillaBrowser*> sBrowserList;
// Name of profile to use
nsString mProfileName;
// Pointer to web browser manager
CWebBrowserContainer * mWebBrowserContainer;
// CComObject to IHTMLDocument implementer
CIEHtmlDocumentInstance * mIERootDocument;
// Mozilla interfaces
nsCOMPtr<nsIWebBrowser> mWebBrowser;
nsCOMPtr<nsIBaseWindow> mWebBrowserAsWin;
nsCOMPtr<nsIEditingSession> mEditingSession;
nsCOMPtr<nsICommandManager> mCommandManager;
// Context menu
nsCOMPtr<nsIDOMNode> mContextNode;
// Prefs service
nsCOMPtr<nsIPrefBranch> mPrefBranch;
// Flag to indicate if browser is created or not
BOOL mValidBrowserFlag;
// Flag to indicate if browser is in edit mode or not
BOOL mEditModeFlag;
// Flag to indicate if the browser has a drop target
BOOL mHaveDropTargetFlag;
// Contains an error message if startup went wrong
tstring mStartupErrorMessage;
// Initial source url passed in via the container
CComBSTR mInitialSrc;
// List of registered browser helper objects
CComUnkPtr *mBrowserHelperList;
ULONG mBrowserHelperListCount;
virtual HRESULT Initialize();
virtual HRESULT Terminate();
virtual HRESULT CreateBrowser();
virtual HRESULT DestroyBrowser();
virtual HRESULT SetStartupErrorMessage(UINT nStringID);
virtual HRESULT GetDOMDocument(nsIDOMDocument **pDocument);
virtual HRESULT SetEditorMode(BOOL bEnabled);
virtual HRESULT OnEditorCommand(DWORD nCmdID);
virtual HRESULT PrintDocument(BOOL promptUser);
virtual HRESULT LoadBrowserHelpers();
virtual HRESULT UnloadBrowserHelpers();
// User interface methods
virtual int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = _T(""), UINT nType = MB_OK);
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode);
virtual void ShowURIPropertyDlg(const nsAString &aURI, const nsAString &aContentType);
virtual void NextDlgControl();
virtual void PrevDlgControl();
public:
// IOleObjectImpl overrides
HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect);
// IOleObject overrides
virtual HRESULT STDMETHODCALLTYPE CMozillaBrowser::GetClientSite(IOleClientSite **ppClientSite);
// IMozControlBridge implementation
virtual HRESULT STDMETHODCALLTYPE GetWebBrowser(/* [out] */ void __RPC_FAR *__RPC_FAR *aBrowser);
// IWebBrowserImpl overrides
virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav);
virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow);
virtual nsresult GetPrefs(nsIPrefBranch **aPrefBranch);
virtual PRBool BrowserIsValid();
// IWebBrowser
virtual HRESULT STDMETHODCALLTYPE get_Parent(IDispatch __RPC_FAR *__RPC_FAR *ppDisp);
virtual HRESULT STDMETHODCALLTYPE get_Document(IDispatch __RPC_FAR *__RPC_FAR *ppDisp);
virtual HRESULT STDMETHODCALLTYPE get_RegisterAsDropTarget(VARIANT_BOOL __RPC_FAR *pbRegister);
virtual HRESULT STDMETHODCALLTYPE put_RegisterAsDropTarget(VARIANT_BOOL bRegister);
public:
HRESULT OnDraw(ATL_DRAWINFO& di);
};
#endif //__MOZILLABROWSER_H_

Двоичные данные
embedding/browser/activex/src/control/MozillaBrowser.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.6 KiB

Просмотреть файл

@ -0,0 +1,66 @@
HKCR
{
Mozilla.Browser.1 = s 'Mozilla Web Browser'
{
CLSID = s '{1339B54C-3453-11D2-93B9-000000000000}'
}
Mozilla.Browser = s 'Mozilla Web Browser'
{
CurVer = s 'Mozilla.Browser.1'
}
NoRemove CLSID
{
ForceRemove {1339B54C-3453-11D2-93B9-000000000000} = s 'MozillaBrowser Class'
{
ProgID = s 'Mozilla.Browser.1'
VersionIndependentProgID = s 'Mozilla.Browser'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
ForceRemove 'Control'
ForceRemove 'Programmable'
ForceRemove 'Insertable'
ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 1'
'MiscStatus' = s '0'
{
'1' = s '131473'
}
'TypeLib' = s '{1339B53E-3453-11D2-93B9-000000000000}'
'Version' = s '1.0'
ForceRemove 'EnableFullPage'
{
ForceRemove .xul
ForceRemove .svg
}
}
}
NoRemove MIME
{
NoRemove Database
{
NoRemove 'Content Type'
{
ForceRemove 'application/vnd.mozilla.xul+xml'
{
val Extension = s '.xul'
val CLSID = s '{1339B54C-3453-11D2-93B9-000000000000}'
}
ForceRemove 'image/svg+xml'
{
val Extension = s '.svg'
val CLSID = s '{1339B54C-3453-11D2-93B9-000000000000}'
}
}
}
}
ForceRemove .xul = s 'Mozilla.Browser'
{
ForceRemove val 'Content Type' = s 'application/vnd.mozilla.xul+xml'
}
ForceRemove .svg = s 'Mozilla.Browser'
{
ForceRemove val 'Content Type' = s 'image/svg+xml'
}
}

Просмотреть файл

@ -0,0 +1,117 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// MozillaControl.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f MozillaControlps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
#include "MozillaControl.h"
#include "MozillaControl_i.c"
#include "MozillaBrowser.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_MozillaBrowser, CMozillaBrowser)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
NG_TRACE_METHOD(DllMain);
if (dwReason == DLL_PROCESS_ATTACH)
{
NG_TRACE(_T("Mozilla ActiveX - DLL_PROCESS_ATTACH\n"));
_Module.Init(ObjectMap, hInstance);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
NG_TRACE(_T("Mozilla ActiveX - DLL_PROCESS_DETACH\n"));
_Module.Term();
}
return TRUE; // ok
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
_Module.UnregisterServer();
return S_OK;
}

Просмотреть файл

@ -0,0 +1,335 @@
# Microsoft Developer Studio Project File - Name="MozillaControl" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) External Target" 0x0106
CFG=MozillaControl - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "MozillaControl.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "MozillaControl.mak" CFG="MozillaControl - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "MozillaControl - Win32 Release" (based on "Win32 (x86) External Target")
!MESSAGE "MozillaControl - Win32 Debug" (based on "Win32 (x86) External Target")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "MozillaControl - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Cmd_Line "NMAKE /f MozillaControl.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "MozillaControl.exe"
# PROP BASE Bsc_Name "MozillaControl.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Cmd_Line "nmake /f makefile.win"
# PROP Rebuild_Opt "/a"
# PROP Target_File "win32_o.obj\mozctl.dll"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "MozillaControl - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Cmd_Line "NMAKE /f MozillaControl.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "MozillaControl.exe"
# PROP BASE Bsc_Name "MozillaControl.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Cmd_Line "nmake /f makefile.win"
# PROP Rebuild_Opt "/a"
# PROP Target_File "M:\source\mozilla\dist\WIN32_D.OBJ\bin\mozctl.dll"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ENDIF
# Begin Target
# Name "MozillaControl - Win32 Release"
# Name "MozillaControl - Win32 Debug"
!IF "$(CFG)" == "MozillaControl - Win32 Release"
!ELSEIF "$(CFG)" == "MozillaControl - Win32 Debug"
!ENDIF
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\ActiveScriptSite.cpp
# End Source File
# Begin Source File
SOURCE=.\DropTarget.cpp
# End Source File
# Begin Source File
SOURCE=.\HelperAppDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\IEHtmlDocument.cpp
# End Source File
# Begin Source File
SOURCE=.\MozillaBrowser.cpp
# End Source File
# Begin Source File
SOURCE=.\MozillaControl.cpp
# End Source File
# Begin Source File
SOURCE=.\MozillaControl.idl
# End Source File
# Begin Source File
SOURCE=.\PromptService.cpp
# End Source File
# Begin Source File
SOURCE=.\PropertyDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# Begin Source File
SOURCE=.\WebBrowserContainer.cpp
# End Source File
# Begin Source File
SOURCE=.\WindowCreator.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\ActiveScriptSite.h
# End Source File
# Begin Source File
SOURCE=.\ActiveXTypes.h
# End Source File
# Begin Source File
SOURCE=.\BrowserDiagnostics.h
# End Source File
# Begin Source File
SOURCE=.\DHTMLCmdIds.h
# End Source File
# Begin Source File
SOURCE=.\DropTarget.h
# End Source File
# Begin Source File
SOURCE=.\HelperAppDlg.h
# End Source File
# Begin Source File
SOURCE=.\IEHtmlDocument.h
# End Source File
# Begin Source File
SOURCE=.\MozillaBrowser.h
# End Source File
# Begin Source File
SOURCE=.\PromptService.h
# End Source File
# Begin Source File
SOURCE=.\PropertyDlg.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\WebBrowserContainer.h
# End Source File
# Begin Source File
SOURCE=.\WindowCreator.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\MozillaBrowser.ico
# End Source File
# Begin Source File
SOURCE=.\MozillaBrowser.rgs
# End Source File
# Begin Source File
SOURCE=.\MozillaControl.rc
# End Source File
# End Group
# Begin Group "Common Source Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\common\ControlEventSink.cpp
# End Source File
# Begin Source File
SOURCE=..\common\ControlSite.cpp
# End Source File
# Begin Source File
SOURCE=..\common\ControlSiteIPFrame.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlButtonElement.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlElement.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlElementCollection.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlNode.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlSelectionObject.cpp
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlTxtRange.cpp
# End Source File
# Begin Source File
SOURCE=..\common\ItemContainer.cpp
# End Source File
# Begin Source File
SOURCE=..\common\PropertyBag.cpp
# End Source File
# End Group
# Begin Group "Common Header Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\common\ControlEventSink.h
# End Source File
# Begin Source File
SOURCE=..\common\ControlSite.h
# End Source File
# Begin Source File
SOURCE=..\common\ControlSiteIPFrame.h
# End Source File
# Begin Source File
SOURCE=..\common\CPMozillaControl.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlButtonElement.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlElement.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlElementCollection.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlNode.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlSelectionObject.h
# End Source File
# Begin Source File
SOURCE=..\common\IEHtmlTxtRange.h
# End Source File
# Begin Source File
SOURCE=..\common\IHTMLLocationImpl.h
# End Source File
# Begin Source File
SOURCE=..\common\IOleCommandTargetImpl.h
# End Source File
# Begin Source File
SOURCE=..\common\ItemContainer.h
# End Source File
# Begin Source File
SOURCE=..\common\IWebBrowserImpl.h
# End Source File
# Begin Source File
SOURCE=..\common\PropertyBag.h
# End Source File
# Begin Source File
SOURCE=..\common\PropertyList.h
# End Source File
# Begin Source File
SOURCE=..\common\StdAfx.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\Makefile.in
# End Source File
# End Target
# End Project

Просмотреть файл

@ -0,0 +1,483 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <olectl.h>
// This file will be processed by the MIDL tool to
// produce the type library (MozillaControl.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
import "docobj.idl";
// See note below for why IWebBrowser is not imported this way
// import "exdisp.idl";
#include <exdispid.h>
[
uuid(1339B53E-3453-11D2-93B9-000000000000),
version(1.0),
helpstring("MozillaControl 1.0 Type Library")
]
library MOZILLACONTROLLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
// Stop interfaces and other bits from being redefined by the IE header file
cpp_quote("#ifndef __exdisp_h__")
cpp_quote("#define __exdisp_h__")
// NOTE: There is a very specific reason for repeating the IWebBrowser
// and other bits verbatim rather than import'ing exdisp.idl -
// MIDL fails with a MIDL2020 error if we try that!
[
uuid(EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B), // IID_IWebBrowser
helpstring("Web Browser interface"),
helpcontext(0x0000),
hidden,
dual,
oleautomation,
odl
]
interface IWebBrowser : IDispatch
{
[id(100), helpstring("Navigates to the previous item in the history list."), helpcontext(0x0000)]
HRESULT GoBack();
[id(101), helpstring("Navigates to the next item in the history list."), helpcontext(0x0000)]
HRESULT GoForward();
[id(102), helpstring("Go home/start page."), helpcontext(0x0000)]
HRESULT GoHome();
[id(103), helpstring("Go Search Page."), helpcontext(0x0000)]
HRESULT GoSearch();
[id(104), helpstring("Navigates to a URL or file."), helpcontext(0x0000)]
HRESULT Navigate([in] BSTR URL,
[in, optional] VARIANT * Flags,
[in, optional] VARIANT * TargetFrameName,
[in, optional] VARIANT * PostData,
[in, optional] VARIANT * Headers);
typedef
[
uuid(14EE5380-A378-11cf-A731-00A0C9082637),
helpstring("Constants for WebBrowser navigation flags")
]
enum BrowserNavConstants {
[helpstring("Open in new window")] navOpenInNewWindow = 0x0001,
[helpstring("Exclude from history list")] navNoHistory = 0x0002,
[helpstring("Don't read from cache")] navNoReadFromCache = 0x0004,
[helpstring("Don't write from cache")] navNoWriteToCache = 0x0008,
[helpstring("Try other sites on failure")] navAllowAutosearch = 0x0010,
[helpstring("OpenBrowserBar")] navBrowserBar = 0x0020,
} BrowserNavConstants;
[id(DISPID_REFRESH), helpstring("Refresh the currently viewed page."), helpcontext(0x0000)]
HRESULT Refresh();
// The standard Refresh takes no parameters and we need some... use a new name
[id(105), helpstring("Refresh the currently viewed page."), helpcontext(0x0000)]
HRESULT Refresh2([in,optional] VARIANT * Level);
typedef
[
uuid(C317C261-A991-11cf-A731-00A0C9082637),
helpstring("Constants for Refresh")
]
enum RefreshConstants { // must map to these in sdk\inc\docobj.h
[helpstring("Refresh normal")] REFRESH_NORMAL = 0, //== OLECMDIDF_REFRESH_NORMAL
[helpstring("Refresh if expired")] REFRESH_IFEXPIRED = 1, //== OLECMDIDF_REFRESH_IFEXPIRED
[helpstring("Refresh completely")] REFRESH_COMPLETELY = 3 //== OLECMDIDF_REFRESH_COMPLETELY
} RefreshConstants;
[id(106), helpstring("Stops opening a file."), helpcontext(0x0000)]
HRESULT Stop();
// Automation hierarchy...
[id(200), propget, helpstring("Returns the application automation object if accessible, this automation object otherwise.."), helpcontext(0x0000)]
HRESULT Application([out,retval] IDispatch** ppDisp);
[id(201), propget, helpstring("Returns the automation object of the container/parent if one exists or this automation object."), helpcontext(0x0000)]
HRESULT Parent([out,retval] IDispatch** ppDisp);
[id(202), propget, helpstring("Returns the container/parent automation object, if any."), helpcontext(0x0000)]
HRESULT Container([out,retval] IDispatch** ppDisp);
[id(203), propget, helpstring("Returns the active Document automation object, if any."), helpcontext(0x0000)]
HRESULT Document([out,retval] IDispatch** ppDisp);
[id(204), propget, helpstring("Returns True if this is the top level object."), helpcontext(0x0000)]
HRESULT TopLevelContainer([out, retval] VARIANT_BOOL* pBool);
[id(205), propget, helpstring("Returns the type of the contained document object."), helpcontext(0x0000)]
HRESULT Type([out,retval] BSTR* Type);
// Window stuff...
[id(206), propget, helpstring("The horizontal position (pixels) of the frame window relative to the screen/container."), helpcontext(0x0000)]
HRESULT Left([out, retval] long *pl);
[id(206), propput]
HRESULT Left([in] long Left);
[id(207), propget, helpstring("The vertical position (pixels) of the frame window relative to the screen/container."), helpcontext(0x0000)]
HRESULT Top([out, retval] long *pl);
[id(207), propput]
HRESULT Top([in] long Top);
[id(208), propget, helpstring("The horizontal dimension (pixels) of the frame window/object."), helpcontext(0x0000)]
HRESULT Width([out, retval] long *pl);
[id(208), propput]
HRESULT Width([in] long Width);
[id(209), propget, helpstring("The vertical dimension (pixels) of the frame window/object."), helpcontext(0x0000)]
HRESULT Height([out, retval] long *pl);
[id(209), propput]
HRESULT Height([in] long Height);
// WebBrowser stuff...
[id(210), propget, helpstring("Gets the short (UI-friendly) name of the URL/file currently viewed."), helpcontext(0x0000)]
HRESULT LocationName([out,retval] BSTR *LocationName);
[id(211), propget, helpstring("Gets the full URL/path currently viewed."), helpcontext(0x0000)]
HRESULT LocationURL([out,retval] BSTR * LocationURL);
// Added a property to see if the viewer is currenly busy or not...
[id(212), propget, helpstring("Query to see if something is still in progress."), helpcontext(0x0000)]
HRESULT Busy([out,retval] VARIANT_BOOL *pBool);
}
[
uuid(0002DF05-0000-0000-C000-000000000046), // IID_IWebBrowserApp
helpstring("Web Browser Application Interface."),
helpcontext(0x0000),
hidden,
oleautomation,
dual
]
interface IWebBrowserApp : IWebBrowser
{
[id(300), helpstring("Exits application and closes the open document."), helpcontext(0x0000)]
HRESULT Quit();
[id(301), helpstring("Converts client sizes into window sizes."), helpcontext(0x0000)]
HRESULT ClientToWindow([in,out] int* pcx, [in,out] int* pcy);
[id(302), helpstring("Associates vtValue with the name szProperty in the context of the object."), helpcontext(0x0000)]
HRESULT PutProperty([in] BSTR Property, [in] VARIANT vtValue);
[id(303), helpstring("Retrieve the Associated value for the property vtValue in the context of the object."), helpcontext(0x0000)]
HRESULT GetProperty([in] BSTR Property, [out, retval] VARIANT *pvtValue);
[id(0), propget, helpstring("Returns name of the application."), helpcontext(0x0000)]
HRESULT Name([out,retval] BSTR* Name);
[id(DISPID_HWND), propget, helpstring("Returns the HWND of the current IE window."), helpcontext(0x0000)]
HRESULT HWND([out,retval] SHANDLE_PTR *pHWND);
[id(400), propget, helpstring("Returns file specification of the application, including path."), helpcontext(0x0000)]
HRESULT FullName([out,retval] BSTR* FullName);
[id(401), propget, helpstring("Returns the path to the application."), helpcontext(0x0000)]
HRESULT Path([out,retval] BSTR* Path);
[id(402), propget, helpstring("Determines whether the application is visible or hidden."), helpcontext(0x0000)]
HRESULT Visible([out, retval] VARIANT_BOOL* pBool);
[id(402), propput, helpstring("Determines whether the application is visible or hidden."), helpcontext(0x0000)]
HRESULT Visible([in] VARIANT_BOOL Value);
[id(403), propget, helpstring("Turn on or off the statusbar."), helpcontext(0x0000)]
HRESULT StatusBar([out, retval] VARIANT_BOOL* pBool);
[id(403), propput, helpstring("Turn on or off the statusbar."), helpcontext(0x0000)]
HRESULT StatusBar([in] VARIANT_BOOL Value);
[id(404), propget, helpstring("Text of Status window."), helpcontext(0x0000)]
HRESULT StatusText([out, retval] BSTR *StatusText);
[id(404), propput, helpstring("Text of Status window."), helpcontext(0x0000)]
HRESULT StatusText([in] BSTR StatusText);
[id(405), propget, helpstring("Controls which toolbar is shown."), helpcontext(0x0000)]
HRESULT ToolBar([out, retval] int * Value);
[id(405), propput, helpstring("Controls which toolbar is shown."), helpcontext(0x0000)]
HRESULT ToolBar([in] int Value);
[id(406), propget, helpstring("Controls whether menubar is shown."), helpcontext(0x0000)]
HRESULT MenuBar([out, retval] VARIANT_BOOL * Value);
[id(406), propput, helpstring("Controls whether menubar is shown."), helpcontext(0x0000)]
HRESULT MenuBar([in] VARIANT_BOOL Value);
[id(407), propget, helpstring("Maximizes window and turns off statusbar, toolbar, menubar, and titlebar."), helpcontext(0x0000)]
HRESULT FullScreen([out, retval] VARIANT_BOOL * pbFullScreen);
[id(407), propput, helpstring("Maximizes window and turns off statusbar, toolbar, menubar, and titlebar."), helpcontext(0x0000)]
HRESULT FullScreen([in] VARIANT_BOOL bFullScreen);
}
[
uuid(D30C1661-CDAF-11d0-8A3E-00C04FC9E26E), // IID_IWebBrowser2
helpstring("Web Browser Interface for IE4."),
helpcontext(0x0000),
hidden,
oleautomation,
dual
]
interface IWebBrowser2 : IWebBrowserApp
{
[id(500), helpstring("Navigates to a URL or file or pidl."), helpcontext(0x0000)]
HRESULT Navigate2([in] VARIANT * URL,
[in, optional] VARIANT * Flags,
[in, optional] VARIANT * TargetFrameName,
[in, optional] VARIANT * PostData,
[in, optional] VARIANT * Headers);
[id(501), helpstring("IOleCommandTarget::QueryStatus"), helpcontext(0x0000)]
HRESULT QueryStatusWB([in] OLECMDID cmdID, [out, retval] OLECMDF * pcmdf);
[id(502), helpstring("IOleCommandTarget::Exec"), helpcontext(0x0000)]
HRESULT ExecWB([in] OLECMDID cmdID, [in] OLECMDEXECOPT cmdexecopt, [in, optional] VARIANT * pvaIn, [out, in, optional] VARIANT * pvaOut);
[id(503), helpstring("Set BrowserBar to Clsid"), helpcontext(0x0000)]
HRESULT ShowBrowserBar( [in] VARIANT * pvaClsid,
[in, optional] VARIANT * pvarShow,
[in, optional] VARIANT * pvarSize );
[id(DISPID_READYSTATE), propget, bindable]
HRESULT ReadyState([retval, out] READYSTATE * plReadyState);
[id(550), propget, helpstring("Controls if the frame is offline (read from cache)"), helpcontext(0x0000)]
HRESULT Offline([out, retval] VARIANT_BOOL * pbOffline);
[id(550), propput, helpstring("Controls if the frame is offline (read from cache)"), helpcontext(0x0000)]
HRESULT Offline([in] VARIANT_BOOL bOffline);
[id(551), propget, helpstring("Controls if any dialog boxes can be shown"), helpcontext(0x0000)]
HRESULT Silent([out, retval] VARIANT_BOOL * pbSilent);
[id(551), propput, helpstring("Controls if any dialog boxes can be shown"), helpcontext(0x0000)]
HRESULT Silent([in] VARIANT_BOOL bSilent);
[id(552), propget, helpstring("Registers OC as a top-level browser (for target name resolution)"), helpcontext(0x0000)]
HRESULT RegisterAsBrowser([out, retval] VARIANT_BOOL * pbRegister);
[id(552), propput, helpstring("Registers OC as a top-level browser (for target name resolution)"), helpcontext(0x0000)]
HRESULT RegisterAsBrowser([in] VARIANT_BOOL bRegister);
[id(553), propget, helpstring("Registers OC as a drop target for navigation"), helpcontext(0x0000)]
HRESULT RegisterAsDropTarget([out, retval] VARIANT_BOOL * pbRegister);
[id(553), propput, helpstring("Registers OC as a drop target for navigation"), helpcontext(0x0000)]
HRESULT RegisterAsDropTarget([in] VARIANT_BOOL bRegister);
[id(554), propget, helpstring("Controls if the browser is in theater mode"), helpcontext(0x0000)]
HRESULT TheaterMode([out, retval] VARIANT_BOOL * pbRegister);
[id(554), propput, helpstring("Controls if the browser is in theater mode"), helpcontext(0x0000)]
HRESULT TheaterMode([in] VARIANT_BOOL bRegister);
[id(555), propget, helpstring("Controls whether address bar is shown"), helpcontext(0x0000)]
HRESULT AddressBar([out, retval] VARIANT_BOOL * Value);
[id(555), propput, helpstring("Controls whether address bar is shown"), helpcontext(0x0000)]
HRESULT AddressBar([in] VARIANT_BOOL Value);
[id(556), propget, helpstring("Controls whether the window is resizable"), helpcontext(0x0000)]
HRESULT Resizable([out, retval] VARIANT_BOOL * Value);
[id(556), propput, helpstring("Controls whether the window is resizable"), helpcontext(0x0000)]
HRESULT Resizable([in] VARIANT_BOOL Value);
}
[
uuid(EAB22AC2-30C1-11CF-A7EB-0000C05BAE0B), // DIID_DWebBrowserEvents
helpstring("Web Browser Control Events (old)"),
hidden
]
dispinterface DWebBrowserEvents
{
properties:
methods:
[id(DISPID_BEFORENAVIGATE), helpstring("Fired when a new hyperlink is being navigated to."), helpcontext(0x0000)]
void BeforeNavigate([in] BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, [in, out]VARIANT_BOOL * Cancel);
[id(DISPID_NAVIGATECOMPLETE), helpstring("Fired when the document being navigated to becomes visible and enters the navigation stack."), helpcontext(0x0000)]
void NavigateComplete([in] BSTR URL );
[id(DISPID_STATUSTEXTCHANGE), helpstring("Statusbar text changed."), helpcontext(0x0000)]
void StatusTextChange([in]BSTR Text);
[id(DISPID_PROGRESSCHANGE), helpstring("Fired when download progress is updated."), helpcontext(0x0000)]
void ProgressChange([in] long Progress, [in] long ProgressMax);
[id(DISPID_DOWNLOADCOMPLETE), helpstring("Download of page complete."), helpcontext(0x0000)]
void DownloadComplete();
[id(DISPID_COMMANDSTATECHANGE), helpstring("The enabled state of a command changed"), helpcontext(0x0000)]
void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable);
[id(DISPID_DOWNLOADBEGIN), helpstring("Download of a page started."), helpcontext(0x000)]
void DownloadBegin();
[id(DISPID_NEWWINDOW), helpstring("Fired when a new window should be created."), helpcontext(0x0000)]
void NewWindow([in] BSTR URL, [in] long Flags, [in] BSTR TargetFrameName, [in] VARIANT * PostData, [in] BSTR Headers, [in,out] VARIANT_BOOL * Processed);
[id(DISPID_TITLECHANGE), helpstring("Document title changed."), helpcontext(0x0000)]
void TitleChange([in]BSTR Text);
[id(DISPID_FRAMEBEFORENAVIGATE), helpstring("Fired when a new hyperlink is being navigated to in a frame."), helpcontext(0x0000)]
void FrameBeforeNavigate([in] BSTR URL, long Flags, BSTR TargetFrameName, VARIANT * PostData, BSTR Headers, [in, out]VARIANT_BOOL * Cancel);
[id(DISPID_FRAMENAVIGATECOMPLETE), helpstring("Fired when a new hyperlink is being navigated to in a frame."), helpcontext(0x0000)]
void FrameNavigateComplete([in] BSTR URL );
[id(DISPID_FRAMENEWWINDOW), helpstring("Fired when a new window should be created."), helpcontext(0x0000)]
void FrameNewWindow([in] BSTR URL, [in] long Flags, [in] BSTR TargetFrameName, [in] VARIANT * PostData, [in] BSTR Headers, [in,out] VARIANT_BOOL * Processed);
// The following are IWebBrowserApp specific:
//
[id(DISPID_QUIT), helpstring("Fired when application is quiting."), helpcontext(0x0000)]
void Quit([in, out] VARIANT_BOOL * Cancel);
[id(DISPID_WINDOWMOVE), helpstring("Fired when window has been moved."), helpcontext(0x0000)]
void WindowMove();
[id(DISPID_WINDOWRESIZE), helpstring("Fired when window has been sized."), helpcontext(0x0000)]
void WindowResize();
[id(DISPID_WINDOWACTIVATE), helpstring("Fired when window has been activated."), helpcontext(0x0000)]
void WindowActivate();
[id(DISPID_PROPERTYCHANGE), helpstring("Fired when the PutProperty method has been called."), helpcontext(0x0000)]
void PropertyChange([in] BSTR Property);
}
[
uuid(34A715A0-6587-11D0-924A-0020AFC7AC4D), // IID_DWebBrowserEvents2
helpstring("Web Browser Control events interface"),
hidden
]
dispinterface DWebBrowserEvents2
{
properties:
methods:
[id(DISPID_STATUSTEXTCHANGE), helpstring("Statusbar text changed."), helpcontext(0x0000)]
void StatusTextChange([in]BSTR Text);
[id(DISPID_PROGRESSCHANGE), helpstring("Fired when download progress is updated."), helpcontext(0x0000)]
void ProgressChange([in] long Progress, [in] long ProgressMax);
[id(DISPID_COMMANDSTATECHANGE), helpstring("The enabled state of a command changed."), helpcontext(0x0000)]
void CommandStateChange([in] long Command, [in] VARIANT_BOOL Enable);
[id(DISPID_DOWNLOADBEGIN), helpstring("Download of a page started."), helpcontext(0x000)]
void DownloadBegin();
[id(DISPID_DOWNLOADCOMPLETE), helpstring("Download of page complete."), helpcontext(0x0000)]
void DownloadComplete();
[id(DISPID_TITLECHANGE), helpstring("Document title changed."), helpcontext(0x0000)]
void TitleChange([in] BSTR Text);
[id(DISPID_PROPERTYCHANGE), helpstring("Fired when the PutProperty method has been called."), helpcontext(0x0000)]
void PropertyChange([in] BSTR szProperty);
// New events for IE40:
//
[id(DISPID_BEFORENAVIGATE2), helpstring("Fired before navigate occurs in the given WebBrowser (window or frameset element). The processing of this navigation may be modified."), helpcontext(0x0000)]
void BeforeNavigate2([in] IDispatch* pDisp,
[in] VARIANT * URL, [in] VARIANT * Flags, [in] VARIANT * TargetFrameName, [in] VARIANT * PostData, [in] VARIANT * Headers,
[in,out] VARIANT_BOOL * Cancel);
[id(DISPID_NEWWINDOW2), helpstring("A new, hidden, non-navigated WebBrowser window is needed."), helpcontext(0x0000)]
void NewWindow2([in, out] IDispatch** ppDisp, [in, out] VARIANT_BOOL * Cancel);
[id(DISPID_NAVIGATECOMPLETE2), helpstring("Fired when the document being navigated to becomes visible and enters the navigation stack."), helpcontext(0x0000)]
void NavigateComplete2([in] IDispatch* pDisp, [in] VARIANT * URL );
[id(DISPID_DOCUMENTCOMPLETE), helpstring("Fired when the document being navigated to reaches ReadyState_Complete."), helpcontext(0x0000)]
void DocumentComplete([in] IDispatch* pDisp, [in] VARIANT * URL );
[id(DISPID_ONQUIT), helpstring("Fired when application is quiting."), helpcontext(0x0000)]
void OnQuit();
[id(DISPID_ONVISIBLE), helpstring("Fired when the window should be shown/hidden"), helpcontext(0x0000)]
void OnVisible([in] VARIANT_BOOL Visible);
[id(DISPID_ONTOOLBAR), helpstring("Fired when the toolbar should be shown/hidden"), helpcontext(0x0000)]
void OnToolBar([in] VARIANT_BOOL ToolBar);
[id(DISPID_ONMENUBAR), helpstring("Fired when the menubar should be shown/hidden"), helpcontext(0x0000)]
void OnMenuBar([in] VARIANT_BOOL MenuBar);
[id(DISPID_ONSTATUSBAR), helpstring("Fired when the statusbar should be shown/hidden"), helpcontext(0x0000)]
void OnStatusBar([in] VARIANT_BOOL StatusBar);
[id(DISPID_ONFULLSCREEN), helpstring("Fired when fullscreen mode should be on/off"), helpcontext(0x0000)]
void OnFullScreen([in] VARIANT_BOOL FullScreen);
[id(DISPID_ONTHEATERMODE), helpstring("Fired when theater mode should be on/off"), helpcontext(0x0000)]
void OnTheaterMode([in] VARIANT_BOOL TheaterMode);
}
// Now a private interface for those ActiveX programmers who want to get
// their hands on the Mozilla internal interfaces. Note that XPCOM
// interfaces are cast into void * parameters but they follow
// the normal COM refcounting rules for in, in-out & out parameters.
[
uuid(D6131E69-4A89-4ab5-B916-5A581D66C84F),
]
interface IMozControlBridge : IUnknown
{
// Method to get the nsIWebBrowser interface (refcounted but cast into a void)
HRESULT GetWebBrowser([out] void **aBrowser);
}
typedef
[
uuid(34A226E0-DF30-11CF-89A9-00A0C9054129),
helpstring("Constants for WebBrowser CommandStateChange")
]
enum CommandStateChangeConstants {
[helpstring("Command Change")] CSC_UPDATECOMMANDS = 0xFFFFFFFF,
[helpstring("Navigate Forward")] CSC_NAVIGATEFORWARD = 0x00000001,
[helpstring("Navigate Back")] CSC_NAVIGATEBACK = 0x00000002,
} CommandStateChangeConstants;
[
uuid(1339B54C-3453-11D2-93B9-000000000000),
helpstring("MozillaBrowser Class")
]
coclass MozillaBrowser
{
[default] interface IWebBrowser2;
interface IWebBrowser;
interface IWebBrowserApp;
interface IDispatch;
[source] dispinterface DWebBrowserEvents;
[default, source] dispinterface DWebBrowserEvents2;
};
cpp_quote("#endif")
};

Просмотреть файл

@ -0,0 +1,553 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"1 TYPELIB ""MozillaControl.tlb""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "FileDescription", "Mozilla ActiveX control and plugin module"
VALUE "FileExtents", "*|*|*.axs"
VALUE "FileOpenName", "ActiveX (*.*)|ActiveX (*.*)|ActiveScript(*.axs)"
VALUE "FileVersion", "1, 0, 0, 1"
VALUE "InternalName", "MOZCTL"
VALUE "LegalCopyright", "Copyright 1999"
VALUE "MIMEType", "application/x-oleobject|application/oleobject|text/x-activescript"
VALUE "OriginalFilename", "MOZCTL.DLL"
VALUE "ProductName", "Mozilla ActiveX control and plugin support"
VALUE "ProductVersion", "1, 0, 0, 1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_MOZILLABROWSER REGISTRY "MozillaBrowser.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MOZILLABROWSER ICON "MozillaBrowser.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_POPUP_DOCUMENT MENU
BEGIN
POPUP "Page Popup"
BEGIN
MENUITEM "&Back", ID_DOCUMENT_BACK
MENUITEM "&Forward", ID_DOCUMENT_FORWARD
MENUITEM SEPARATOR
MENUITEM "Select &All", ID_DOCUMENT_SELECTALL
MENUITEM "&Paste", ID_DOCUMENT_PASTE
MENUITEM SEPARATOR
MENUITEM "&View Source", ID_DOCUMENT_VIEWSOURCE
, GRAYED
MENUITEM SEPARATOR
MENUITEM "Pr&int", ID_DOCUMENT_PRINT
MENUITEM "&Refresh", ID_DOCUMENT_REFRESH
MENUITEM SEPARATOR
MENUITEM "&Properties", ID_DOCUMENT_PROPERTIES
END
END
IDR_POPUP_LINK MENU
BEGIN
POPUP "Link Popup"
BEGIN
MENUITEM "&Open", ID_LINK_OPEN
MENUITEM "Open in &New Window", ID_LINK_OPENINNEWWINDOW
MENUITEM SEPARATOR
MENUITEM "Copy Shor&tcut", ID_LINK_COPYSHORTCUT
MENUITEM SEPARATOR
MENUITEM "&Properties", ID_LINK_PROPERTIES
END
END
IDR_POPUP_TEXT MENU
BEGIN
POPUP "Selection Popup"
BEGIN
MENUITEM "Cu&t", ID_TEXT_CUT, GRAYED
MENUITEM "&Copy", ID_TEXT_COPY
MENUITEM "&Paste", ID_TEXT_PASTE, GRAYED
MENUITEM "Select &All", ID_TEXT_SELECTALL
MENUITEM "Print", ID_TEXT_PRINT
END
END
IDR_POPUP_IMAGE MENU
BEGIN
POPUP "Image Popup"
BEGIN
MENUITEM "Cu&t", ID_EDIT_CUT, GRAYED
MENUITEM "&Copy", ID_EDIT_COPY, GRAYED
MENUITEM "&Paste", ID_EDIT_PASTE, GRAYED
MENUITEM "Select &All", ID_EDIT_SELECTALL
MENUITEM "Print", ID_SELECTIONPOPUP_PRINT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROMPT DIALOG 0, 0, 263, 113
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Enter Value"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Value:",IDC_STATIC,7,71,21,8
EDITTEXT IDC_VALUE,32,71,224,14,ES_AUTOHSCROLL
CONTROL "Check msg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,50,249,19
DEFPUSHBUTTON "OK",IDOK,152,92,50,14
PUSHBUTTON "Cancel",IDCANCEL,206,92,50,14
LTEXT "Message",IDC_MESSAGE,36,7,220,41
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
END
IDD_PROMPTUSERPASS DIALOG 0, 0, 263, 135
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Authentication Required"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Username:",IDC_STATIC,7,71,35,8
EDITTEXT IDC_USERNAME,44,71,212,14,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,7,92,34,8
EDITTEXT IDC_PASSWORD,44,92,212,14,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "CheckMsg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,50,249,19
PUSHBUTTON "OK",IDOK,153,114,50,14
PUSHBUTTON "Cancel",IDCANCEL,206,114,50,14
LTEXT "Message",IDC_MESSAGE,36,7,220,41
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
END
IDD_CONFIRMEX DIALOG 0, 0, 263, 95
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Confirmation"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "0",IDC_BUTTON0,195,75,65,14
PUSHBUTTON "2",IDC_BUTTON2,55,75,65,14
PUSHBUTTON "1",IDC_BUTTON1,125,75,65,14
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,20,20
LTEXT "Message",IDC_MESSAGE,36,7,220,41
CONTROL "Check Msg",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,52,249,19
END
IDD_PPAGE_LINK DIALOG 0, 0, 185, 170
STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Address: (URL)",IDC_STATIC,0,68,27,20
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,32,185,1
LTEXT "type",IDC_TYPE,35,53,149,8
LTEXT "Type:",IDC_STATIC,0,38,19,8
LTEXT "protocol",IDC_PROTOCOL,35,38,149,8
EDITTEXT IDC_ADDRESS,35,68,149,61,ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY
ICON IDI_MOZILLABROWSER,IDC_STATIC,5,6,20,20
END
IDD_PAGESETUP DIALOGEX 0, 0, 276, 221
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Page Setup"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,167,200,50,14
PUSHBUTTON "Cancel",IDCANCEL,219,200,50,14
CONTROL "",IDC_TAB,"SysTabControl32",TCS_TOOLTIPS,7,7,262,191
CONTROL "",IDC_PAGE_MARKER,"Static",SS_BLACKFRAME | NOT
WS_VISIBLE,10,23,255,170
END
IDD_PPAGE_MARGINS DIALOGEX 0, 0, 255, 170
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Margins (in millimeters)",IDC_STATIC,0,0,255,104
GROUPBOX "Headers && Footers",IDC_STATIC,0,105,255,59
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,101,30,51,51
RTEXT "Top:",IDC_STATIC,84,16,16,8
EDITTEXT IDC_MARGIN_TOP,107,13,40,14,ES_AUTOHSCROLL
LTEXT "Left:",IDC_STATIC,56,36,16,8
EDITTEXT IDC_MARGIN_LEFT,56,48,40,14,ES_AUTOHSCROLL
EDITTEXT IDC_MARGIN_BOTTOM,107,84,40,14,ES_AUTOHSCROLL
RTEXT "Bottom:",IDC_STATIC,74,87,26,8
LTEXT "Right:",IDC_STATIC,157,36,20,8
EDITTEXT IDC_MARGIN_RIGHT,157,48,40,14,ES_AUTOHSCROLL
COMBOBOX IDC_HDR_LEFT,26,117,61,126,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
COMBOBOX IDC_HDR_MIDDLE,96,117,61,155,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_HDR_RIGHT,164,117,61,157,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_FTR_LEFT,26,144,61,99,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
COMBOBOX IDC_FTR_MIDDLE,96,144,61,104,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_FTR_RIGHT,164,144,61,138,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "Left:",IDC_STATIC,48,133,16,8
LTEXT "Center:",IDC_STATIC,113,133,26,8
LTEXT "Right:",IDC_STATIC,184,133,20,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_PROMPT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 106
END
IDD_PROMPTUSERPASS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 128
END
IDD_CONFIRMEX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 256
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_PAGESETUP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 269
TOPMARGIN, 7
BOTTOMMARGIN, 214
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "MozillaControl"
IDS_HEADERFOOTER_OPTIONS
"-- Blank --|Title|URL|Date/Time|Page #|Page # of #||Custom..."
END
STRINGTABLE
BEGIN
IDS_LOCATEMOZILLA "The browser control does not know where Mozilla is installed and may not function correctly.\nDo you want to locate Mozilla now?"
IDS_LOCATEMOZILLATITLE "Cannot locate Mozilla bin directory"
IDS_CANNOTCREATEPREFS "The Mozilla control cannot create a critical component. This prevents the control from functioning correctly. Possible reasons for the problem are:\n\n1. The PATH environment variable does not point to the Mozilla bin directory.\n2. The registry key HKEY_LOCAL_MACHINE\\Software\\Mozilla\\BinDirectoryPath registry key has not been set or is incorrect\n3. The file component.reg has not been generated or is empty.\n\nPlease refer to http://www.iol.ie/~locka/mozilla/mozilla.htm for guidance on how to resolve these problems."
END
STRINGTABLE
BEGIN
IDS_CONFIRMEX_OK "OK"
IDS_CONFIRMEX_CANCEL "Cancel"
IDS_CONFIRMEX_YES "Yes"
IDS_CONFIRMEX_NO "No"
IDS_CONFIRMEX_SAVE "Save"
IDS_CONFIRMEX_DONTSAVE "Don't Save"
IDS_CONFIRMEX_REVERT "Revert"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROPERTIES DIALOG 0, 0, 199, 204
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Properties"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,88,183,50,14
PUSHBUTTON "Close",IDCLOSE,142,183,50,14
CONTROL "",IDC_PPAGE_MARKER,"Static",SS_BLACKFRAME | NOT
WS_VISIBLE,7,7,185,170
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_PROPERTIES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 192
TOPMARGIN, 7
BOTTOMMARGIN, 197
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (Ireland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENI)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_EIRE
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_HELPERAPP DIALOG 0, 0, 285, 161
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Downloading"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDI_MOZILLABROWSER,IDC_STATIC,7,7,21,20
LTEXT "You have chosen to download a file that requires special handling. What would you like to do with this file?",
IDC_MESSAGE,34,7,244,21
CONTROL "Open with the specified application",IDC_OPENWITHAPP,
"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,7,40,
219,10
PUSHBUTTON "&Choose...",IDC_CHOOSE,228,38,50,14
CONTROL "Save to file",IDC_SAVETOFILE,"Button",
BS_AUTORADIOBUTTON,7,53,51,10
GROUPBOX "Details",IDC_STATIC,7,68,271,67
DEFPUSHBUTTON "OK",IDOK,173,139,50,14
PUSHBUTTON "Cancel",IDCANCEL,228,139,50,14
LTEXT "Location:",IDC_STATIC,13,82,30,8
EDITTEXT IDC_URL,63,79,208,14,ES_AUTOHSCROLL | ES_READONLY
LTEXT "Content Type:",IDC_STATIC,13,99,46,8
EDITTEXT IDC_CONTENTTYPE,63,96,208,14,ES_AUTOHSCROLL |
ES_READONLY
LTEXT "Application:",IDC_STATIC,13,116,38,8
EDITTEXT IDC_APPLICATION,63,113,208,14,ES_AUTOHSCROLL |
ES_READONLY
END
IDD_PROGRESS DIALOG 0, 0, 244, 102
STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Download progress:",IDC_STATIC,7,7,150,8
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,
23,230,10
LTEXT "Source:",IDC_STATIC,7,44,26,8
EDITTEXT IDC_SOURCE,50,42,187,14,ES_AUTOHSCROLL | ES_READONLY
LTEXT "Destination:",IDC_STATIC,7,64,38,8
EDITTEXT IDC_DESTINATION,50,62,187,14,ES_AUTOHSCROLL |
ES_READONLY
PUSHBUTTON "Cancel",IDCANCEL,96,81,50,14
END
IDD_PPAGE_FORMAT DIALOGEX 0, 0, 255, 170
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Format",IDC_STATIC,0,0,255,91
GROUPBOX "Options",IDC_STATIC,0,95,255,35
CONTROL "Print Background (colors && images)",
IDC_PRINTBACKGROUND,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,109,127,10
LTEXT "Orientation:",IDC_STATIC,7,13,40,8
CONTROL "Portrait",IDC_PORTRAIT,"Button",BS_AUTORADIOBUTTON,91,
13,40,10
CONTROL "Landscape",IDC_LANDSCAPE,"Button",BS_AUTORADIOBUTTON,91,
30,50,10
LTEXT "Scale:",IDC_STATIC,7,67,20,8
EDITTEXT IDC_SCALE,37,64,30,14,ES_AUTOHSCROLL
LTEXT "%",IDC_STATIC,73,67,8,8
CONTROL "Shrink to fit page width",IDC_SHRINKTOFIT,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,87,67,90,10
END
IDD_CUSTOM_FIELD DIALOGEX 0, 0, 262, 96
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Custom Value"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Value:",IDC_STATIC,7,37,21,8
EDITTEXT IDC_VALUE,7,48,248,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,151,75,50,14
PUSHBUTTON "Cancel",IDCANCEL,205,75,50,14
LTEXT "Type the value you wish to show in the page.",
IDC_MESSAGE,35,7,220,35
ICON IDI_MOZILLABROWSER,IDC_QUESTION,7,7,21,20
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_HELPERAPP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 278
TOPMARGIN, 7
BOTTOMMARGIN, 153
END
IDD_PROGRESS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 237
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
IDD_CUSTOM_FIELD, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 255
TOPMARGIN, 7
BOTTOMMARGIN, 89
END
END
#endif // APSTUDIO_INVOKED
#endif // English (Ireland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "MozillaControl.tlb"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Просмотреть файл

@ -0,0 +1,503 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PAGESETUPDLG_H
#define PAGESETUPDLG_H
#include "resource.h"
#include "nsIPrintSettings.h"
/* VC98 doesn't define _tstof() */
#if defined(_MSC_VER) && _MSC_VER < 1300
#ifndef UNICODE
#define _tstof atof
#else
inline double _wtof(const wchar_t *string)
{
USES_CONVERSION;
return atof(W2CA(string));
}
#define _tstof _wtof
#endif
#endif
class CCustomFieldDlg : public CDialogImpl<CCustomFieldDlg>
{
public:
enum { IDD = IDD_CUSTOM_FIELD };
BEGIN_MSG_MAP(CCustomFieldDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
END_MSG_MAP()
nsString m_field;
CCustomFieldDlg(const nsAString &str) :
m_field(str)
{
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
USES_CONVERSION;
SetDlgItemText(IDC_VALUE, W2CT(m_field.get()));
return 0;
}
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
TCHAR szBuf[128];
GetDlgItemText(IDC_VALUE, szBuf, sizeof(szBuf) / sizeof(szBuf[0]));
USES_CONVERSION;
m_field = T2CW(szBuf);
EndDialog(IDOK);
return 0;
}
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
EndDialog(IDCANCEL);
return 0;
}
};
class CPageSetupFormatDlg : public CDialogImpl<CPageSetupFormatDlg>
{
public:
enum { IDD = IDD_PPAGE_FORMAT };
BEGIN_MSG_MAP(CPageSetupFormatDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDC_SHRINKTOFIT, OnClickShrinkToFit)
END_MSG_MAP()
CPageSetupFormatDlg()
{
}
void Init(nsIPrintSettings *aPrintSettings)
{
// Set landscape / portrait mode
PRInt32 orientation = nsIPrintSettings::kPortraitOrientation;
aPrintSettings->GetOrientation(&orientation);
SendDlgItemMessage(
(orientation == nsIPrintSettings::kPortraitOrientation)
? IDC_PORTRAIT : IDC_LANDSCAPE,
BM_SETCHECK,
BST_CHECKED, 0);
// Set scaling
TCHAR szBuf[10];
double scaling = 1.0;
aPrintSettings->GetScaling(&scaling);
_stprintf(szBuf, _T("%.1f"), scaling * 100.0);
SetDlgItemText(IDC_SCALE, szBuf);
// Set shrink to fit (& disable scale field)
PRBool shrinkToFit = PR_FALSE;
aPrintSettings->GetShrinkToFit(&shrinkToFit);
CheckDlgButton(IDC_SHRINKTOFIT, shrinkToFit ? BST_CHECKED : BST_UNCHECKED);
::EnableWindow(GetDlgItem(IDC_SCALE), shrinkToFit ? FALSE : TRUE);
// Print background - we use PrintBGColors to control both images & colours
PRBool printBGColors = PR_TRUE;
aPrintSettings->GetPrintBGColors(&printBGColors);
CheckDlgButton(IDC_PRINTBACKGROUND, printBGColors ? BST_CHECKED : BST_UNCHECKED);
}
void Apply(nsIPrintSettings *aPrintSettings)
{
// Background options are tied to a single checkbox
PRBool boolVal =
(SendDlgItemMessage(IDC_PRINTBACKGROUND, BM_GETCHECK) == BST_CHECKED) ?
PR_TRUE : PR_FALSE;
aPrintSettings->SetPrintBGColors(boolVal);
aPrintSettings->SetPrintBGImages(boolVal);
// Print scale
TCHAR szBuf[128];
GetDlgItemText(IDC_SCALE, szBuf, sizeof(szBuf) / sizeof(szBuf[0]));
double scale = _tstof(szBuf) / 100.0;
aPrintSettings->SetScaling(scale);
// Shrink to fit
PRBool shrinkToFit =
(IsDlgButtonChecked(IDC_SHRINKTOFIT) == BST_CHECKED) ? PR_TRUE : PR_FALSE;
aPrintSettings->SetShrinkToFit(shrinkToFit);
// Landscape or portrait
PRInt32 orientation = nsIPrintSettings::kLandscapeOrientation;
if (SendDlgItemMessage(IDC_PORTRAIT, BM_GETCHECK) == BST_CHECKED)
{
orientation = nsIPrintSettings::kPortraitOrientation;
}
aPrintSettings->SetOrientation(orientation);
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 0;
}
LRESULT OnClickShrinkToFit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
BOOL bEnableScale = TRUE;
if (IsDlgButtonChecked(IDC_SHRINKTOFIT) == BST_CHECKED)
bEnableScale = FALSE;
::EnableWindow(GetDlgItem(IDC_SCALE), bEnableScale);
return 0;
}
};
class CPageSetupMarginsDlg : public CDialogImpl<CPageSetupMarginsDlg>
{
public:
nsString mHdrLeft;
nsString mHdrCenter;
nsString mHdrRight;
nsString mFtrLeft;
nsString mFtrCenter;
nsString mFtrRight;
enum { IDD = IDD_PPAGE_MARGINS };
BEGIN_MSG_MAP(CPageSetupMarginsDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_RANGE_HANDLER(IDC_HDR_LEFT, IDC_FTR_RIGHT, OnHeaderFooterChange)
END_MSG_MAP()
CPageSetupMarginsDlg()
{
}
const wchar_t * const * GetHeaderFooterValues(size_t &aNumValues) const
{
static const wchar_t *szValues[] = {
L"",
L"&T",
L"&U",
L"&D",
L"&P",
L"&PT"
};
aNumValues = sizeof(szValues) / sizeof(szValues[0]);
return szValues;
}
const TCHAR * const * GetHeaderFooterOptions(size_t &aNumOptions) const
{
static const TCHAR *szOptions[] =
{
_T("-- Blank --"),
_T("Title"),
_T("URL"),
_T("Date/Time"),
_T("Page #"),
_T("Page # of #"),
_T("Custom...")
};
aNumOptions = sizeof(szOptions) / sizeof(szOptions[0]);
return szOptions;
}
void Init(nsIPrintSettings *aPrintSettings)
{
double top = 0.0;
double left = 0.0;
double right = 0.0;
double bottom = 0.0;
aPrintSettings->GetMarginTop(&top);
aPrintSettings->GetMarginLeft(&left);
aPrintSettings->GetMarginRight(&right);
aPrintSettings->GetMarginBottom(&bottom);
// Get the margins
TCHAR szBuf[16];
_stprintf(szBuf, _T("%5.2f"), top);
SetDlgItemText(IDC_MARGIN_TOP, szBuf);
_stprintf(szBuf, _T("%5.2f"), left);
SetDlgItemText(IDC_MARGIN_LEFT, szBuf);
_stprintf(szBuf, _T("%5.2f"), right);
SetDlgItemText(IDC_MARGIN_RIGHT, szBuf);
_stprintf(szBuf, _T("%5.2f"), bottom);
SetDlgItemText(IDC_MARGIN_BOTTOM, szBuf);
// Get the header & footer settings
PRUnichar* uStr = nsnull;
aPrintSettings->GetHeaderStrLeft(&uStr);
mHdrLeft = uStr;
SetComboIndex(IDC_HDR_LEFT, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
aPrintSettings->GetHeaderStrCenter(&uStr);
mHdrCenter = uStr;
SetComboIndex(IDC_HDR_MIDDLE, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
aPrintSettings->GetHeaderStrRight(&uStr);
mHdrRight = uStr;
SetComboIndex(IDC_HDR_RIGHT, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
aPrintSettings->GetFooterStrLeft(&uStr);
mFtrLeft = uStr;
SetComboIndex(IDC_FTR_LEFT, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
aPrintSettings->GetFooterStrCenter(&uStr);
mFtrCenter = uStr;
SetComboIndex(IDC_FTR_MIDDLE, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
aPrintSettings->GetFooterStrRight(&uStr);
mFtrRight = uStr;
SetComboIndex(IDC_FTR_RIGHT, uStr);
if (uStr != nsnull) nsMemory::Free(uStr);
}
void SetComboIndex(int aID, const wchar_t *szValue)
{
size_t nValues;
const wchar_t * const * szValues = GetHeaderFooterValues(nValues);
int nCurSel = 0;
if (szValue[0] != L'\0')
{
while (nCurSel < nValues)
{
if (wcscmp(szValue, szValues[nCurSel]) == 0)
{
break;
}
++nCurSel;
}
// nCurSel might contain nValues but that just means the
// Custom... field gets selected.
}
SendDlgItemMessage(aID, CB_SETCURSEL, nCurSel);
}
void Apply(nsIPrintSettings *aPrintSettings)
{
TCHAR szBuf[128];
const size_t kBufSize = sizeof(szBuf) / sizeof(szBuf[0]);
GetDlgItemText(IDC_MARGIN_TOP, szBuf, kBufSize);
aPrintSettings->SetMarginTop(_tstof(szBuf));
GetDlgItemText(IDC_MARGIN_LEFT, szBuf, kBufSize);
aPrintSettings->SetMarginLeft(_tstof(szBuf));
GetDlgItemText(IDC_MARGIN_BOTTOM, szBuf, kBufSize);
aPrintSettings->SetMarginBottom(_tstof(szBuf));
GetDlgItemText(IDC_MARGIN_RIGHT, szBuf, kBufSize);
aPrintSettings->SetMarginRight(_tstof(szBuf));
aPrintSettings->SetHeaderStrLeft(mHdrLeft.get());
aPrintSettings->SetHeaderStrCenter(mHdrCenter.get());
aPrintSettings->SetHeaderStrRight(mHdrRight.get());
aPrintSettings->SetFooterStrLeft(mFtrLeft.get());
aPrintSettings->SetFooterStrCenter(mFtrCenter.get());
aPrintSettings->SetFooterStrRight(mFtrRight.get());
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
size_t nOptions;
const TCHAR * const *szOptions = GetHeaderFooterOptions(nOptions);
// Fill out the drop down choices
for (size_t i = 0; i < nOptions; ++i)
{
const TCHAR *szOption = szOptions[i];
SendDlgItemMessage(IDC_HDR_LEFT, CB_ADDSTRING, 0, LPARAM(szOption));
SendDlgItemMessage(IDC_HDR_MIDDLE, CB_ADDSTRING, 0, LPARAM(szOption));
SendDlgItemMessage(IDC_HDR_RIGHT, CB_ADDSTRING, 0, LPARAM(szOption));
SendDlgItemMessage(IDC_FTR_LEFT, CB_ADDSTRING, 0, LPARAM(szOption));
SendDlgItemMessage(IDC_FTR_MIDDLE, CB_ADDSTRING, 0, LPARAM(szOption));
SendDlgItemMessage(IDC_FTR_RIGHT, CB_ADDSTRING, 0, LPARAM(szOption));
}
return 0;
}
LRESULT OnHeaderFooterChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (wNotifyCode != CBN_SELCHANGE)
{
bHandled = FALSE;
return 0;
}
// One of the header / footer combos has changed, so set the string
// to the updated value.
nsString *pStr = nsnull;
switch (wID)
{
case IDC_HDR_LEFT: pStr = &mHdrLeft; break;
case IDC_HDR_MIDDLE: pStr = &mHdrCenter; break;
case IDC_HDR_RIGHT: pStr = &mHdrRight; break;
case IDC_FTR_LEFT: pStr = &mFtrLeft; break;
case IDC_FTR_MIDDLE: pStr = &mFtrCenter; break;
case IDC_FTR_RIGHT: pStr = &mFtrRight; break;
}
if (!pStr)
{
return 0;
}
size_t nValues;
const wchar_t * const * szValues = GetHeaderFooterValues(nValues);
int nCurSel = SendDlgItemMessage(wID, CB_GETCURSEL);
if (nCurSel == nValues) // Custom...
{
CCustomFieldDlg dlg(*pStr);
if (dlg.DoModal() == IDOK)
{
*pStr = dlg.m_field;
}
// Update combo in case their custom value is not custom at all
// For example, if someone opens the custom dlg and types "&P"
// (i.e. "Page #"), we should select that since it is already a
// choice in the combo.
SetComboIndex(wID, pStr->get());
}
else
{
*pStr = szValues[nCurSel];
}
return 0;
}
};
class CPageSetupDlg : public CDialogImpl<CPageSetupDlg>
{
public:
enum { IDD = IDD_PAGESETUP };
CPPageDlg *mPPage;
BEGIN_MSG_MAP(CPageSetupDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
NOTIFY_HANDLER(IDC_TAB, TCN_SELCHANGE, OnTabSelChange)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
END_MSG_MAP()
nsCOMPtr<nsIPrintSettings> mPrintSettings;
CPageSetupFormatDlg mFormatDlg;
CPageSetupMarginsDlg mMarginsDlg;
CPageSetupDlg(nsIPrintSettings *aPrintSettings) :
mPrintSettings(aPrintSettings)
{
}
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// The marker tells us where to stick the pages
RECT rcMarker;
::GetWindowRect(GetDlgItem(IDC_PAGE_MARKER), &rcMarker);
ScreenToClient(&rcMarker);
// Create the two pages, the first is shown, the second is not
mFormatDlg.Create(m_hWnd);
mFormatDlg.Init(mPrintSettings);
mFormatDlg.SetWindowPos(HWND_TOP, &rcMarker, SWP_SHOWWINDOW);
mMarginsDlg.Create(m_hWnd);
mMarginsDlg.Init(mPrintSettings);
mMarginsDlg.SetWindowPos(HWND_TOP, &rcMarker, SWP_HIDEWINDOW);
// Get the tab control
HWND hwndTab = GetDlgItem(IDC_TAB);
TCITEM tcItem;
memset(&tcItem, 0, sizeof(tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.pszText = _T("Format && Options");
TabCtrl_InsertItem(hwndTab, 0, &tcItem);
tcItem.pszText = _T("Margins && Header / Footer");
TabCtrl_InsertItem(hwndTab, 1, &tcItem);
TabCtrl_SetCurSel(hwndTab, 0);
return 0;
}
LRESULT OnTabSelChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
HWND hwndTab = GetDlgItem(IDC_TAB);
if (TabCtrl_GetCurSel(hwndTab) == 0)
{
mFormatDlg.SetWindowPos(HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
mMarginsDlg.ShowWindow(SW_HIDE);
}
else
{
mMarginsDlg.SetWindowPos(HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
mFormatDlg.ShowWindow(SW_HIDE);
}
return 0;
}
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
mFormatDlg.Apply(mPrintSettings);
mMarginsDlg.Apply(mPrintSettings);
EndDialog(IDOK);
return 0;
}
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
EndDialog(IDCANCEL);
return 0;
}
};
#endif

Просмотреть файл

@ -0,0 +1,899 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include "MozillaBrowser.h"
#include "PromptService.h"
#include "nsCOMPtr.h"
#include "nsIPromptService.h"
#include "nsIFactory.h"
#include "nsIDOMWindow.h"
class PromptDlg
{
public:
PromptDlg();
virtual ~PromptDlg();
nsresult ConfirmCheck(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult ConfirmEx(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed);
nsresult Prompt(HWND hwndParent, const PRUnichar *dialogTitle,
const PRUnichar *text, PRUnichar **value,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult PromptUsernameAndPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
nsresult PromptPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval);
protected:
static INT_PTR CALLBACK ConfirmProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK PromptProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
TCHAR *mTitle;
TCHAR *mMessage;
TCHAR *mCheckMessage;
BOOL mCheckValue;
TCHAR *mButtonTitles[3];
TCHAR *mUsername;
TCHAR *mPassword;
TCHAR *mValue;
enum {
PROMPT_USERPASS,
PROMPT_PASS,
PROMPT_VALUE
} mPromptMode;
};
PromptDlg::PromptDlg() :
mMessage(NULL),
mCheckMessage(NULL),
mCheckValue(FALSE),
mUsername(NULL),
mPassword(NULL),
mValue(NULL),
mTitle(NULL),
mPromptMode(PROMPT_USERPASS)
{
for (int i = 0; i < 3; i++)
{
mButtonTitles[i] = NULL;
}
}
PromptDlg::~PromptDlg()
{
if (mTitle)
free(mTitle);
if (mMessage)
free(mMessage);
if (mCheckMessage)
free(mCheckMessage);
if (mUsername)
free(mUsername);
if (mPassword)
free(mPassword);
if (mValue)
free(mValue);
for (int i = 0; i < 3; i++)
{
if (mButtonTitles[i])
{
free(mButtonTitles[i]);
}
}
}
nsresult PromptDlg::ConfirmCheck(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRInt32 buttonPressed = 0;
PRUint32 buttonFlags = nsIPromptService::BUTTON_TITLE_YES +
(nsIPromptService::BUTTON_TITLE_NO << 8);
// Use the extended confirmation dialog with Yes & No buttons
nsresult rv = ConfirmEx(hwndParent, dialogTitle, text,
buttonFlags, NULL, NULL, NULL,
checkMsg, checkValue, &buttonPressed);
if (NS_SUCCEEDED(rv))
{
*_retval = (buttonPressed == 0) ? PR_TRUE : PR_FALSE;
}
return rv;
}
nsresult PromptDlg::ConfirmEx(
HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
NS_ENSURE_ARG_POINTER(dialogTitle);
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(buttonPressed);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = *checkValue ? TRUE : FALSE;
}
// Turn the button flags into strings. The nsIPromptService flags
// are scary bit shifted values which explains the masks and bit
// shifting happening in this loop.
for (int i = 0; i < 3; i++)
{
PRUint32 titleId = buttonFlags & 255;
TCHAR **title = &mButtonTitles[i];
switch (titleId)
{
case nsIPromptService::BUTTON_TITLE_OK:
case nsIPromptService::BUTTON_TITLE_CANCEL:
case nsIPromptService::BUTTON_TITLE_YES:
case nsIPromptService::BUTTON_TITLE_NO:
case nsIPromptService::BUTTON_TITLE_SAVE:
case nsIPromptService::BUTTON_TITLE_DONT_SAVE:
case nsIPromptService::BUTTON_TITLE_REVERT:
{
const int kTitleSize = 256;
int stringId = IDS_CONFIRMEX_OK + titleId - nsIPromptService::BUTTON_TITLE_OK;
*title = (TCHAR *) malloc(sizeof(TCHAR) * kTitleSize);
::LoadString(hInstResource, stringId, *title, kTitleSize - 1);
break;
}
case nsIPromptService::BUTTON_TITLE_IS_STRING:
{
const PRUnichar *srcTitle =
(i == 0) ? button0Title :
(i == 1) ? button1Title : button2Title;
if (srcTitle)
{
*title = _tcsdup(W2T(srcTitle));
}
break;
}
default:
// ANYTHING ELSE GETS IGNORED
break;
}
buttonFlags >>= 8;
}
// Must have at least one button the user can click on!
NS_ENSURE_ARG_POINTER(mButtonTitles[0]);
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_CONFIRMEX), hwndParent, ConfirmProc, (LPARAM) this);
if (checkValue)
*checkValue = mCheckValue;
if (buttonPressed)
*buttonPressed = result;
return NS_OK;
}
nsresult
PromptDlg::Prompt(HWND hwndParent, const PRUnichar *dialogTitle,
const PRUnichar *text, PRUnichar **value,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = *checkValue ? TRUE : FALSE;
}
if (value)
{
mValue = _tcsdup(W2T(*value));
}
mPromptMode = PROMPT_VALUE;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPT), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (value)
{
if (*value)
nsMemory::Free(*value);
nsAutoString v(T2W(mValue));
*value = ToNewUnicode(v);
}
if (checkValue)
*checkValue = mCheckValue;
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;
}
nsresult
PromptDlg::PromptUsernameAndPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = *checkValue ? TRUE : FALSE;
}
if (username)
{
mUsername = _tcsdup(W2T(*username));
}
if (password)
{
mPassword = _tcsdup(W2T(*password));
}
mPromptMode = PROMPT_USERPASS;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPTUSERPASS), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (username)
{
if (*username)
nsMemory::Free(*username);
nsAutoString user(T2W(mUsername));
*username = ToNewUnicode(user);
}
if (password)
{
if (*password)
nsMemory::Free(*password);
nsAutoString pass(T2W(mPassword));
*password = ToNewUnicode(pass);
}
if (checkValue)
*checkValue = mCheckValue;
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;
}
nsresult
PromptDlg::PromptPassword(HWND hwndParent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(text);
NS_ENSURE_ARG_POINTER(_retval);
HINSTANCE hInstResource = _Module.m_hInstResource;
USES_CONVERSION;
// Duplicate all strings, turning them into TCHARs
if (dialogTitle)
mTitle = _tcsdup(W2T(dialogTitle));
mMessage = _tcsdup(W2T(text));
if (checkMsg)
{
NS_ENSURE_ARG_POINTER(checkValue);
mCheckMessage = _tcsdup(W2T(checkMsg));
mCheckValue = *checkValue ? TRUE : FALSE;
}
if (password)
{
mPassword = _tcsdup(W2T(*password));
}
mPromptMode = PROMPT_PASS;
INT result = DialogBoxParam(hInstResource,
MAKEINTRESOURCE(IDD_PROMPTUSERPASS), hwndParent, PromptProc, (LPARAM) this);
if (result == IDOK)
{
if (password)
{
if (*password)
nsMemory::Free(*password);
nsAutoString pass(T2W(mPassword));
*password = ToNewUnicode(pass);
}
if (checkValue)
*checkValue = mCheckValue;
*_retval = TRUE;
}
else
{
*_retval = FALSE;
}
return NS_OK;
}
INT_PTR CALLBACK
PromptDlg::PromptProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PromptDlg *pThis = (PromptDlg *) GetWindowLongPtr(hwndDlg, DWLP_USER);
switch (uMsg)
{
case WM_INITDIALOG:
// Initialise pThis
SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
pThis = (PromptDlg *) lParam;
// Set dialog title & message text
if (pThis->mTitle)
SetWindowText(hwndDlg, pThis->mTitle);
SetDlgItemText(hwndDlg, IDC_MESSAGE, pThis->mMessage);
// Set check message text
if (pThis->mCheckMessage)
{
SetDlgItemText(hwndDlg, IDC_CHECKMSG, pThis->mCheckMessage);
CheckDlgButton(hwndDlg, IDC_CHECKMSG, pThis->mCheckValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, IDC_CHECKMSG), SW_HIDE);
}
switch (pThis->mPromptMode)
{
case PROMPT_PASS:
EnableWindow(GetDlgItem(hwndDlg, IDC_USERNAME), FALSE);
if (pThis->mPassword)
{
SetDlgItemText(hwndDlg, IDC_PASSWORD, pThis->mPassword);
}
break;
case PROMPT_USERPASS:
if (pThis->mUsername)
{
SetDlgItemText(hwndDlg, IDC_USERNAME, pThis->mUsername);
}
if (pThis->mPassword)
{
SetDlgItemText(hwndDlg, IDC_PASSWORD, pThis->mPassword);
}
break;
case PROMPT_VALUE:
if (pThis->mValue)
{
SetDlgItemText(hwndDlg, IDC_VALUE, pThis->mValue);
}
break;
}
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
int id = LOWORD(wParam);
if (id == IDOK)
{
if (pThis->mCheckMessage)
{
pThis->mCheckValue =
(IsDlgButtonChecked(hwndDlg, IDC_CHECKMSG) == BST_CHECKED) ?
TRUE : FALSE;
}
const int bufferSize = 256;
TCHAR buffer[bufferSize];
switch (pThis->mPromptMode)
{
case PROMPT_USERPASS:
if (pThis->mUsername)
{
free(pThis->mUsername);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_USERNAME, buffer, bufferSize);
pThis->mUsername = _tcsdup(buffer);
// DROP THROUGH !!!!
case PROMPT_PASS:
if (pThis->mPassword)
{
free(pThis->mPassword);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_PASSWORD, buffer, bufferSize);
pThis->mPassword = _tcsdup(buffer);
break;
case PROMPT_VALUE:
if (pThis->mValue)
{
free(pThis->mValue);
}
memset(buffer, 0, sizeof(buffer));
GetDlgItemText(hwndDlg, IDC_VALUE, buffer, bufferSize);
pThis->mValue = _tcsdup(buffer);
break;
}
EndDialog(hwndDlg, IDOK);
}
else if (id == IDCANCEL)
{
EndDialog(hwndDlg, IDCANCEL);
}
}
return TRUE;
}
return FALSE;
}
INT_PTR CALLBACK
PromptDlg::ConfirmProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PromptDlg *pThis = (PromptDlg *) GetWindowLongPtr(hwndDlg, DWLP_USER);
int i;
switch (uMsg)
{
case WM_INITDIALOG:
// Initialise pThis
SetWindowLongPtr(hwndDlg, DWLP_USER, lParam);
pThis = (PromptDlg *) lParam;
// Set dialog title & message text
SetWindowText(hwndDlg, pThis->mTitle);
SetDlgItemText(hwndDlg, IDC_MESSAGE, pThis->mMessage);
// Set check message text
if (pThis->mCheckMessage)
{
SetDlgItemText(hwndDlg, IDC_CHECKMSG, pThis->mCheckMessage);
CheckDlgButton(hwndDlg, IDC_CHECKMSG, pThis->mCheckValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, IDC_CHECKMSG), SW_HIDE);
}
// Set the button text or hide them
for (i = 0; i < 3; i++)
{
int id = IDC_BUTTON0 + i;
if (pThis->mButtonTitles[i])
{
SetDlgItemText(hwndDlg, id, pThis->mButtonTitles[i]);
}
else
{
ShowWindow(GetDlgItem(hwndDlg, id), SW_HIDE);
}
}
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
int id = LOWORD(wParam);
if (id == IDC_BUTTON0 ||
id == IDC_BUTTON1 ||
id == IDC_BUTTON2)
{
if (pThis->mCheckMessage)
{
pThis->mCheckValue =
(IsDlgButtonChecked(hwndDlg, IDC_CHECKMSG) == BST_CHECKED) ?
TRUE : FALSE;
}
EndDialog(hwndDlg, id - IDC_BUTTON0);
}
}
return FALSE;
}
return FALSE;
}
//*****************************************************************************
// CPromptService
//*****************************************************************************
class CPromptService: public nsIPromptService
{
public:
CPromptService();
virtual ~CPromptService();
CMozillaBrowser *GetOwningBrowser(nsIDOMWindow *parent);
NS_DECL_ISUPPORTS
NS_DECL_NSIPROMPTSERVICE
};
//*****************************************************************************
NS_IMPL_ISUPPORTS1(CPromptService, nsIPromptService)
CPromptService::CPromptService()
{
}
CPromptService::~CPromptService()
{
}
CMozillaBrowser *CPromptService::GetOwningBrowser(nsIDOMWindow *parent)
{
if (parent == nsnull)
{
// return the first element from the list if there is one
if (CMozillaBrowser::sBrowserList.Length() > 0)
{
return CMozillaBrowser::sBrowserList[0];
}
return NULL;
}
// Search for the browser with a content window matching the one provided
PRUint32 i;
for (i = 0; i < CMozillaBrowser::sBrowserList.Length(); i++)
{
CMozillaBrowser *p = CMozillaBrowser::sBrowserList[i];
if (p->mWebBrowser)
{
nsCOMPtr<nsIDOMWindow> domWindow;
p->mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if (domWindow.get() == parent)
{
return p;
}
}
}
return NULL;
}
///////////////////////////////////////////////////////////////////////////////
// nsIPrompt
NS_IMETHODIMP CPromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
USES_CONVERSION;
pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
}
return NS_OK;
}
NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
// TODO show dialog with check box
USES_CONVERSION;
pOwner->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
}
return NS_OK;
}
NS_IMETHODIMP CPromptService::Confirm(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text,
PRBool *_retval)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
USES_CONVERSION;
int nAnswer = pOwner->MessageBox(W2T(text), W2T(dialogTitle),
MB_YESNO | MB_ICONQUESTION);
*_retval = (nAnswer == IDYES) ? PR_TRUE : PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.ConfirmCheck(pOwner->m_hWnd, dialogTitle,
text, checkMsg, checkValue, _retval);
}
return NS_OK;
}
NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUint32 buttonFlags,
const PRUnichar *button0Title,
const PRUnichar *button1Title,
const PRUnichar *button2Title,
const PRUnichar *checkMsg, PRBool *checkValue,
PRInt32 *buttonPressed)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.ConfirmEx(pOwner->m_hWnd, dialogTitle,
text, buttonFlags, button0Title, button1Title, button2Title,
checkMsg, checkValue, buttonPressed);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dialogTitle,
const PRUnichar *text, PRUnichar **value,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.Prompt(pOwner->m_hWnd,
dialogTitle, text, value, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.PromptUsernameAndPassword(pOwner->m_hWnd,
dialogTitle, text, username, password, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
CMozillaBrowser *pOwner = GetOwningBrowser(parent);
if (pOwner)
{
PromptDlg dlg;
return dlg.PromptPassword(pOwner->m_hWnd,
dialogTitle, text, password, checkMsg, checkValue, _retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP CPromptService::Select(nsIDOMWindow *parent,
const PRUnichar *dialogTitle,
const PRUnichar *text, PRUint32 count,
const PRUnichar **selectList, PRInt32 *outSelection,
PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//*****************************************************************************
// CPromptServiceFactory
//*****************************************************************************
class CPromptServiceFactory : public nsIFactory
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIFACTORY
CPromptServiceFactory();
virtual ~CPromptServiceFactory();
};
//*****************************************************************************
NS_IMPL_ISUPPORTS1(CPromptServiceFactory, nsIFactory)
CPromptServiceFactory::CPromptServiceFactory()
{
}
CPromptServiceFactory::~CPromptServiceFactory()
{
}
NS_IMETHODIMP CPromptServiceFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = NULL;
CPromptService *inst = new CPromptService;
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = inst->QueryInterface(aIID, aResult);
if (rv != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
return rv;
}
NS_IMETHODIMP CPromptServiceFactory::LockFactory(PRBool lock)
{
return NS_OK;
}
//*****************************************************************************
nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory)
{
NS_ENSURE_ARG_POINTER(aFactory);
*aFactory = nsnull;
CPromptServiceFactory *result = new CPromptServiceFactory;
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result);
*aFactory = result;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PromptService_h
#define __PromptService_h
#include "nsError.h"
class nsIFactory;
extern nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory);
#endif

Просмотреть файл

@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "PropertyDlg.h"
#include "resource.h"
#include "nsIMIMEInfo.h"
#include "nsIMIMEService.h"
CPropertyDlg::CPropertyDlg() :
mPPage(NULL)
{
}
HRESULT CPropertyDlg::AddPage(CPPageDlg *pPage)
{
mPPage = pPage;
return S_OK;
}
LRESULT CPropertyDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (mPPage)
{
// Create property page over the marker
RECT rc;
::GetWindowRect(GetDlgItem(IDC_PPAGE_MARKER), &rc);
ScreenToClient(&rc);
mPPage->Create(m_hWnd, rc);
mPPage->SetWindowPos(HWND_TOP, &rc, SWP_SHOWWINDOW);
}
return 1;
}
LRESULT CPropertyDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (mPPage)
{
mPPage->DestroyWindow();
}
EndDialog(IDOK);
return 1;
}
LRESULT CPropertyDlg::OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
if (mPPage)
{
mPPage->DestroyWindow();
}
EndDialog(IDCLOSE);
return 1;
}
///////////////////////////////////////////////////////////////////////////////
LRESULT CPPageDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
nsAutoString desc;
if (!mType.IsEmpty())
{
nsresult rv;
nsCOMPtr<nsIMIMEService> mimeService;
mimeService = do_GetService("@mozilla.org/mime;1", &rv);
NS_ENSURE_TRUE(mimeService, NS_ERROR_FAILURE);
nsCOMPtr<nsIMIMEInfo> mimeInfo;
nsCAutoString contentType;
// MIME Types are ASCII.
LossyCopyUTF16toASCII(mType, contentType);
mimeService->GetFromTypeAndExtension(contentType, EmptyCString(), getter_AddRefs(mimeInfo));
if (mimeInfo)
{
mimeInfo->GetDescription(desc);
}
}
USES_CONVERSION;
SetDlgItemText(IDC_PROTOCOL, W2T(desc.get()));
SetDlgItemText(IDC_TYPE, W2T(mType.get()));
SetDlgItemText(IDC_ADDRESS, W2T(mURL.get()));
return 1;
}

Просмотреть файл

@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef PROPERTYDLG_H
#define PROPERTYDLG_H
class CPPageDlg : public CDialogImpl<CPPageDlg>
{
public:
enum { IDD = IDD_PPAGE_LINK };
nsString mType;
nsString mURL;
BEGIN_MSG_MAP(CPPageLinkDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
class CPropertyDlg : public CDialogImpl<CPropertyDlg>
{
public:
enum { IDD = IDD_PROPERTIES };
CPPageDlg *mPPage;
BEGIN_MSG_MAP(CPropertyDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCLOSE, OnClose)
END_MSG_MAP()
CPropertyDlg();
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
HRESULT AddPage(CPPageDlg *pPage);
};
#endif

Просмотреть файл

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.cpp : source file that includes just the standard includes
// stdafx.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif
#include <atlimpl.cpp>
#include <atlctl.cpp>
#include <atlwin.cpp>

Просмотреть файл

@ -0,0 +1,166 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_)
#define AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// under MSVC shut off copious warnings about debug symbol too long
#ifdef _MSC_VER
#pragma warning( disable: 4786 )
#endif
#include "jstypes.h"
#include "prtypes.h"
// Mozilla headers
#include "jscompat.h"
#include "prthread.h"
#include "prprf.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "nsViewsCID.h"
#include "nsStringAPI.h"
#include "nsCOMPtr.h"
#include "nsIHTTPChannel.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIURL.h"
#include "nsIBaseWindow.h"
#include "nsIWebBrowser.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebBrowserSetup.h"
#include "nsIWebNavigation.h"
#include "nsIWebProgress.h"
#include "nsIWebProgressListener.h"
#include "nsIDocumentLoader.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerEdit.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCOMPtr.h"
#include "nsISelection.h"
#include "nsIPrompt.h"
#include "nsIEditor.h"
#include "nsIEditingSession.h"
#include "nsICommandManager.h"
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIStreamListener.h"
#include "nsTArray.h"
#include "nsIDocumentViewer.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMElement.h"
#include "nsIDOMEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMEventTarget.h"
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0403
#define _ATL_APARTMENT_THREADED
#define _ATL_STATIC_REGISTRY
// #define _ATL_DEBUG_INTERFACES
// ATL headers
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <atlctl.h>
#include <mshtml.h>
#include <mshtmhst.h>
#include <docobj.h>
// STL headers
#include <vector>
#include <list>
#include <string>
// New winsock2.h doesn't define this anymore
typedef long int32;
// Turn off warnings about debug symbols for templates being too long
#pragma warning(disable : 4786)
// Mozilla control headers
#include "resource.h"
#include "ActiveXTypes.h"
#include "BrowserDiagnostics.h"
#include "IOleCommandTargetImpl.h"
#include "DHTMLCmdIds.h"
#include "MozillaControl.h"
#include "PropertyList.h"
#include "PropertyBag.h"
#include "ItemContainer.h"
#include "IEHtmlDocument.h"
#include "CPMozillaControl.h"
#include "MozillaBrowser.h"
#include "WindowCreator.h"
#include "WebBrowserContainer.h"
#include "DropTarget.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED)

Просмотреть файл

@ -0,0 +1,710 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include <limits.h>
#include <shlobj.h>
#include "WebBrowserContainer.h"
#include "nsServiceManagerUtils.h"
#include "nsIWebNavigationInfo.h"
CWebBrowserContainer::CWebBrowserContainer(CMozillaBrowser *pOwner) :
mOwner(pOwner),
mEvents1(mOwner),
mEvents2(mOwner),
mVisible(PR_TRUE)
{
}
CWebBrowserContainer::~CWebBrowserContainer()
{
}
///////////////////////////////////////////////////////////////////////////////
// nsISupports implementation
NS_IMPL_ADDREF(CWebBrowserContainer)
NS_IMPL_RELEASE(CWebBrowserContainer)
NS_INTERFACE_MAP_BEGIN(CWebBrowserContainer)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow2)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
// NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
///////////////////////////////////////////////////////////////////////////////
// nsIInterfaceRequestor
NS_IMETHODIMP CWebBrowserContainer::GetInterface(const nsIID & aIID, void * *result)
{
*result = 0;
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
{
if (mOwner && mOwner->mWebBrowser)
{
return mOwner->mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) result);
}
return NS_ERROR_NOT_INITIALIZED;
}
return QueryInterface(aIID, result);
}
///////////////////////////////////////////////////////////////////////////////
// nsIContextMenuListener
NS_IMETHODIMP CWebBrowserContainer::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
{
mOwner->ShowContextMenu(aContextFlags, aEvent, aNode);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener
/* void onProgressChange (in nsIWebProgress aProgress, in nsIRequest aRequest, in long curSelfProgress, in long maxSelfProgress, in long curTotalProgress, in long maxTotalProgress); */
NS_IMETHODIMP CWebBrowserContainer::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress)
{
NG_TRACE(_T("CWebBrowserContainer::OnProgressChange(...)\n"));
long nProgress = curTotalProgress;
long nProgressMax = maxTotalProgress;
if (nProgress == 0)
{
}
if (nProgressMax == 0)
{
nProgressMax = LONG_MAX;
}
if (nProgress > nProgressMax)
{
nProgress = nProgressMax; // Progress complete
}
mEvents1->Fire_ProgressChange(nProgress, nProgressMax);
mEvents2->Fire_ProgressChange(nProgress, nProgressMax);
return NS_OK;
}
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest request, in unsigned long progressStateFlags, in unsinged long aStatus); */
NS_IMETHODIMP CWebBrowserContainer::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest *aRequest, PRUint32 progressStateFlags, nsresult aStatus)
{
nsresult rv = NS_OK;
NG_TRACE(_T("CWebBrowserContainer::OnStateChange(...)\n"));
BOOL doFireCommandStateChange = FALSE;
// determine whether or not the document load has started or stopped.
if (progressStateFlags & STATE_IS_DOCUMENT)
{
if (progressStateFlags & STATE_START)
{
NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Start(..., \"\")\n"));
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel)
{
nsCOMPtr<nsIURI> uri;
rv = channel->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(rv))
{
nsCAutoString aURI;
uri->GetAsciiSpec(aURI);
NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Start(..., %s, \"\")\n"), A2CT(aURI.get()));
}
}
//Fire a DownloadBegin
mEvents1->Fire_DownloadBegin();
mEvents2->Fire_DownloadBegin();
}
else if (progressStateFlags & STATE_STOP)
{
NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Stop(..., \"\")\n"));
if (mOwner->mIERootDocument)
{
// allow to keep old document around
mOwner->mIERootDocument->Release();
mOwner->mIERootDocument = NULL;
}
//Fire a DownloadComplete
mEvents1->Fire_DownloadComplete();
mEvents2->Fire_DownloadComplete();
nsCOMPtr<nsIURI> pURI;
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(aRequest);
if (!aChannel) return NS_ERROR_NULL_POINTER;
rv = aChannel->GetURI(getter_AddRefs(pURI));
if (NS_FAILED(rv)) return NS_OK;
nsCAutoString aURI;
rv = pURI->GetAsciiSpec(aURI);
if (NS_FAILED(rv)) return NS_OK;
USES_CONVERSION;
BSTR bstrURI = SysAllocString(A2OLE(aURI.get()));
// Fire a DocumentComplete event
CComVariant vURI(bstrURI);
mEvents2->Fire_DocumentComplete(mOwner, &vURI);
SysFreeString(bstrURI);
//Fire a StatusTextChange event
BSTR bstrStatus = SysAllocString(A2OLE((CHAR *) "Done"));
mEvents1->Fire_StatusTextChange(bstrStatus);
mEvents2->Fire_StatusTextChange(bstrStatus);
SysFreeString(bstrStatus);
}
// state change notifications
doFireCommandStateChange = TRUE;
}
if (progressStateFlags & STATE_IS_NETWORK)
{
if (progressStateFlags & STATE_START)
{
}
if (progressStateFlags & STATE_STOP)
{
nsCAutoString aURI;
if (mCurrentURI)
{
mCurrentURI->GetAsciiSpec(aURI);
}
// Fire a NavigateComplete event
USES_CONVERSION;
BSTR bstrURI = SysAllocString(A2OLE(aURI.get()));
mEvents1->Fire_NavigateComplete(bstrURI);
// Fire a NavigateComplete2 event
CComVariant vURI(bstrURI);
mEvents2->Fire_NavigateComplete2(mOwner, &vURI);
// Cleanup
SysFreeString(bstrURI);
mOwner->mBusyFlag = FALSE;
mCurrentURI = nsnull;
}
}
if (doFireCommandStateChange)
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mOwner->mWebBrowser));
// Fire the new NavigateForward state
VARIANT_BOOL bEnableForward = VARIANT_FALSE;
PRBool aCanGoForward = PR_FALSE;
webNav->GetCanGoForward(&aCanGoForward);
if (aCanGoForward)
{
bEnableForward = VARIANT_TRUE;
}
mEvents2->Fire_CommandStateChange(CSC_NAVIGATEFORWARD, bEnableForward);
// Fire the new NavigateBack state
VARIANT_BOOL bEnableBack = VARIANT_FALSE;
PRBool aCanGoBack = PR_FALSE;
webNav->GetCanGoBack(&aCanGoBack);
if (aCanGoBack)
{
bEnableBack = VARIANT_TRUE;
}
mEvents2->Fire_CommandStateChange(CSC_NAVIGATEBACK, bEnableBack);
}
return NS_OK;
}
/* void onLocationChange (in nsIURI location); */
NS_IMETHODIMP CWebBrowserContainer::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI *location)
{
// nsCString aPath;
// location->GetPath(getter_Copies(aPath));
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const PRUnichar* aMessage)
{
NG_TRACE(_T("CWebBrowserContainer::OnStatusChange(..., \"\")\n"));
BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aMessage));
mEvents1->Fire_StatusTextChange(bstrStatus);
mEvents2->Fire_StatusTextChange(bstrStatus);
SysFreeString(bstrStatus);
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRUint32 state)
{
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIURIContentListener
/* 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;
}
/* void doContent (in string aContentType, in boolean aIsContentPreferred, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean isPreferred (in string aContentType, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
{
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType, _retval);
}
/* boolean canHandleContent (in string aContentType, in PRBool aIsContentPreferred, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
*_retval = PR_FALSE;
*aDesiredContentType = nsnull;
if (aContentType)
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mOwner->mWebBrowser));
nsCOMPtr<nsIWebNavigationInfo> webNavInfo(
do_GetService("@mozilla.org/webnavigation-info;1"));
if (webNavInfo)
{
PRUint32 canHandle;
nsresult rv =
webNavInfo->IsTypeSupported(nsDependentCString(aContentType),
webNav,
&canHandle);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
}
}
return NS_OK;
}
/* attribute nsISupports loadCookie; */
NS_IMETHODIMP CWebBrowserContainer::GetLoadCookie(nsISupports * *aLoadCookie)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CWebBrowserContainer::SetLoadCookie(nsISupports * aLoadCookie)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsIURIContentListener parentContentListener; */
NS_IMETHODIMP CWebBrowserContainer::GetParentContentListener(nsIURIContentListener * *aParentContentListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP CWebBrowserContainer::SetParentContentListener(nsIURIContentListener * aParentContentListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
// nsIEmbeddingSiteWindow
NS_IMETHODIMP
CWebBrowserContainer::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
{
RECT rc = { 0, 0, 1, 1 };
mOwner->GetClientRect(&rc);
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION)
{
if (*x)
*x = rc.left;
if (*y)
*y = rc.top;
}
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER ||
aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)
{
if (*cx)
*cx = rc.right - rc.left;
if (*cy)
*cy = rc.bottom - rc.top;
}
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
// Ignore
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::GetSiteWindow(void **aParentNativeWindow)
{
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
HWND *hwndDest = (HWND *) aParentNativeWindow;
*hwndDest = mOwner->m_hWnd;
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::SetFocus(void)
{
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::GetTitle(PRUnichar * *aTitle)
{
NG_ASSERT_POINTER(aTitle, PRUnichar **);
if (!aTitle)
return E_INVALIDARG;
*aTitle = ToNewUnicode(mTitle);
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::SetTitle(const PRUnichar * aTitle)
{
NG_ASSERT_POINTER(aTitle, PRUnichar *);
if (!aTitle)
return E_INVALIDARG;
mTitle = aTitle;
// Fire a TitleChange event
BSTR bstrTitle = SysAllocString(aTitle);
mEvents1->Fire_TitleChange(bstrTitle);
mEvents2->Fire_TitleChange(bstrTitle);
SysFreeString(bstrTitle);
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::GetVisibility(PRBool *aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
*aVisibility = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::SetVisibility(PRBool aVisibility)
{
VARIANT_BOOL visible = aVisibility ? VARIANT_TRUE : VARIANT_FALSE;
mVisible = aVisibility;
// Fire an OnVisible event
mEvents2->Fire_OnVisible(visible);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIEmbeddingSiteWindow2
NS_IMETHODIMP
CWebBrowserContainer::Blur()
{
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebBrowserChromeFocus implementation
NS_IMETHODIMP
CWebBrowserContainer::FocusNextElement()
{
ATLTRACE(_T("CWebBrowserContainer::FocusNextElement()\n"));
mOwner->NextDlgControl();
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::FocusPrevElement()
{
ATLTRACE(_T("CWebBrowserContainer::FocusPrevElement()\n"));
mOwner->PrevDlgControl();
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIWebBrowserChrome implementation
NS_IMETHODIMP
CWebBrowserContainer::SetStatus(PRUint32 statusType, const PRUnichar *status)
{
//Fire a StatusTextChange event
BSTR bstrStatus = SysAllocString(status);
mEvents1->Fire_StatusTextChange(bstrStatus);
mEvents2->Fire_StatusTextChange(bstrStatus);
SysFreeString(bstrStatus);
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::GetWebBrowser(nsIWebBrowser * *aWebBrowser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::SetWebBrowser(nsIWebBrowser * aWebBrowser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::GetChromeFlags(PRUint32 *aChromeFlags)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::SetChromeFlags(PRUint32 aChromeFlags)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::DestroyBrowserWindow(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::ShowAsModal(void)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
CWebBrowserContainer::IsWindowModal(PRBool *_retval)
{
// we're not
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::ExitModalEventLoop(nsresult aStatus)
{
// Ignore request to exit modal loop
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIRequestObserver implementation
NS_IMETHODIMP
CWebBrowserContainer::OnStartRequest(nsIRequest *request, nsISupports* aContext)
{
USES_CONVERSION;
NG_TRACE(_T("CWebBrowserContainer::OnStartRequest(...)\n"));
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::OnStopRequest(nsIRequest *request, nsISupports* aContext, nsresult aStatus)
{
USES_CONVERSION;
NG_TRACE(_T("CWebBrowserContainer::OnStopRequest(..., %d)\n"), (int) aStatus);
// Fire a DownloadComplete event
mEvents1->Fire_DownloadComplete();
mEvents2->Fire_DownloadComplete();
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsICommandHandler implementation
/* void do (in string aCommand, in string aStatus); */
NS_IMETHODIMP CWebBrowserContainer::Exec(const char *aCommand, const char *aStatus, char **aResult)
{
return NS_OK;
}
/* void query (in string aCommand, in string aStatus); */
NS_IMETHODIMP CWebBrowserContainer::Query(const char *aCommand, const char *aStatus, char **aResult)
{
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,98 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef WEBBROWSERCONTAINER_H
#define WEBBROWSERCONTAINER_H
#include "nsIContextMenuListener.h"
#include "nsITooltipListener.h"
#include "nsICommandHandler.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIEmbeddingSiteWindow2.h"
#include "nsIURIContentListener.h"
#include "nsIWebBrowserChromeFocus.h"
#include "nsWeakReference.h"
// This is the class that handles the XPCOM side of things, callback
// interfaces into the web shell and so forth.
class CWebBrowserContainer :
public nsIEmbeddingSiteWindow2,
public nsIWebBrowserChrome,
public nsIWebProgressListener,
public nsIRequestObserver,
public nsIURIContentListener,
public nsIInterfaceRequestor,
public nsIContextMenuListener,
public nsICommandHandler,
public nsIWebBrowserChromeFocus,
public nsSupportsWeakReference
{
public:
CWebBrowserContainer(CMozillaBrowser *pOwner);
friend CMozillaBrowser;
friend CWindowCreator;
protected:
virtual ~CWebBrowserContainer();
// Protected members
protected:
CMozillaBrowser *mOwner;
nsCOMPtr<nsIURI> mCurrentURI;
CProxyDWebBrowserEvents<CMozillaBrowser> *mEvents1;
CProxyDWebBrowserEvents2<CMozillaBrowser> *mEvents2;
nsString mTitle;
PRPackedBool mVisible;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIEMBEDDINGSITEWINDOW2
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
NS_DECL_NSICOMMANDHANDLER
};
#endif

Просмотреть файл

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "WindowCreator.h"
NS_IMPL_ISUPPORTS1(CWindowCreator, nsIWindowCreator)
CWindowCreator::CWindowCreator(void)
{
}
CWindowCreator::~CWindowCreator()
{
}
NS_IMETHODIMP
CWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent, PRUint32 aChromeFlags, nsIWebBrowserChrome **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nsnull;
// NOTE:
//
// The nsIWindowCreator::CreateChromeWindow is REQUIRED to handle a nsnull
// parent window but this implementation must have one in order to fire
// events to the ActiveX container. Therefore we treat a nsnull aParent
// as an error and return.
if (aParent == nsnull)
{
return NS_ERROR_FAILURE;
}
CWebBrowserContainer *pContainer = static_cast<CWebBrowserContainer *>(aParent);
CComQIPtr<IDispatch> dispNew;
VARIANT_BOOL bCancel = VARIANT_FALSE;
// Test if the event sink can give us a new window to navigate into
if (pContainer->mEvents2)
{
pContainer->mEvents2->Fire_NewWindow2(&dispNew, &bCancel);
if ((bCancel == VARIANT_FALSE) && dispNew)
{
CComQIPtr<IMozControlBridge> cpBridge = dispNew;
if (cpBridge)
{
nsIWebBrowser *browser = nsnull;
cpBridge->GetWebBrowser((void **) &browser);
if (browser)
{
nsresult rv = browser->GetContainerWindow(_retval);
NS_RELEASE(browser);
return rv;
}
}
}
}
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -0,0 +1,57 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef WINDOWCREATOR_H
#define WINDOWCREATOR_H
#include "nsIWindowCreator.h"
#include "nsIWebBrowserChrome.h"
class CWindowCreator : public nsIWindowCreator
{
public:
CWindowCreator();
protected:
virtual ~CWindowCreator();
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWINDOWCREATOR
};
#endif

Просмотреть файл

@ -0,0 +1,16 @@
@echo off
REM This script generates the DEF file for the control DLL depending on
REM what has been set to go into it
echo ; mozctl.def : Declares the module parameters. > %1
echo ; This file was autogenerated by mkctldef.bat! >> %1
echo. >> %1
echo LIBRARY "mozctl.DLL" >> %1
echo EXPORTS >> %1
echo ; ActiveX exports >> %1
echo DllCanUnloadNow @100 PRIVATE >> %1
echo DllGetClassObject @101 PRIVATE >> %1
echo DllRegisterServer @102 PRIVATE >> %1
echo DllUnregisterServer @103 PRIVATE >> %1
echo. >> %1

Просмотреть файл

@ -0,0 +1,16 @@
#!/bin/sh
# This script generates the DEF file for the control DLL depending on
# what has been set to go into it
echo '; mozctl.def : Declares the module parameters.' > $1
echo '; This file was autogenerated by mkctldef.sh! ' >> $1
echo '' >> $1
echo 'LIBRARY "mozctl.DLL"' >> $1
echo 'EXPORTS' >> $1
echo ' ; ActiveX exports' >> $1
echo ' DllCanUnloadNow @100 PRIVATE' >> $1
echo ' DllGetClassObject @101 PRIVATE' >> $1
echo ' DllRegisterServer @102 PRIVATE' >> $1
echo ' DllUnregisterServer @103 PRIVATE' >> $1
echo '' >> $1

Просмотреть файл

@ -0,0 +1,119 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by MozillaControl.rc
//
#define IDS_PROJNAME 100
#define IDR_MOZILLABROWSER 101
#define IDS_HEADERFOOTER_OPTIONS 101
#define IDI_MOZILLABROWSER 201
#define IDC_CHECKMSG 201
#define IDR_POPUP_PAGE 202
#define IDR_POPUP_DOCUMENT 202
#define IDR_POPUP_LINK 203
#define IDR_POPUP_CLIPBOARD 204
#define IDC_QUESTION 204
#define IDR_POPUP_TEXT 204
#define IDD_CONFIRMCHECK 205
#define IDC_MESSAGE 205
#define IDD_PROMPT 206
#define IDR_POPUP_IMAGE 206
#define IDC_PPAGE_MARKER 206
#define IDD_PROMPTUSERNAMEANDPASSWORD 207
#define IDD_PROMPTUSERPASS 207
#define IDD_PROMPTPASSWORD 208
#define IDC_TYPE 208
#define IDD_PROPERTIES 209
#define IDC_PROTOCOL 209
#define IDD_PPAGE_LINK 210
#define IDC_ADDRESS 210
#define IDD_CONFIRMEX 211
#define IDD_HELPERAPP 212
#define IDC_VALUE 213
#define IDD_PROGRESS 213
#define IDC_USERNAME 214
#define IDD_PAGESETUP 214
#define IDC_PASSWORD 215
#define IDD_PPAGE_FORMAT 215
#define IDD_PPAGE_MARGINS 216
#define IDD_CUSTOM_FIELD 217
#define IDC_CHOOSE 218
#define IDC_URL 222
#define IDC_CONTENTTYPE 223
#define IDC_APPLICATION 224
#define IDC_SOURCE 225
#define IDC_DESTINATION 226
#define IDC_PROGRESS 227
#define IDC_TAB 229
#define IDC_PAGE_MARKER 230
#define IDC_PRINTBACKGROUND 231
#define IDC_PORTRAIT 232
#define IDC_LANDSCAPE 233
#define IDC_SCALE 234
#define IDC_SHRINKTOFIT 235
#define IDC_MARGIN_TOP 236
#define IDC_MARGIN_LEFT 237
#define IDC_MARGIN_BOTTOM 238
#define IDC_MARGIN_RIGHT 239
#define IDC_HDR_LEFT 240
#define IDC_HDR_MIDDLE 241
#define IDC_HDR_RIGHT 242
#define IDC_FTR_LEFT 243
#define IDC_FTR_MIDDLE 244
#define IDC_FTR_RIGHT 245
#define IDC_OPENWITHAPP 300
#define IDC_SAVETOFILE 301
#define IDS_LOCATEMOZILLA 1000
#define IDS_LOCATEMOZILLATITLE 1001
#define IDS_CANNOTCREATEPREFS 1002
#define IDS_CONFIRMEX_OK 2000
#define IDS_CONFIRMEX_CANCEL 2001
#define IDS_CONFIRMEX_YES 2002
#define IDS_CONFIRMEX_NO 2003
#define IDS_CONFIRMEX_SAVE 2004
#define IDS_CONFIRMEX_DONTSAVE 2005
#define IDS_CONFIRMEX_REVERT 2006
#define IDC_BUTTON0 2200
#define IDC_BUTTON1 2201
#define IDC_BUTTON2 2202
#define ID_BROWSE_BACK 32768
#define ID_DOCUMENT_BACK 32768
#define ID_BROWSE_FORWARD 32769
#define ID_DOCUMENT_FORWARD 32769
#define ID_FILE_REFRESH 32772
#define ID_DOCUMENT_REFRESH 32772
#define ID_FILE_PRINT 32773
#define ID_DOCUMENT_PRINT 32773
#define ID_PAGE_PROPERTIES 32774
#define ID_DOCUMENT_PROPERTIES 32774
#define ID_FILE_VIEWSOURCE 32775
#define ID_DOCUMENT_VIEWSOURCE 32775
#define ID_FILE_OPEN 32776
#define ID_LINK_OPEN 32776
#define ID_FILE_OPENINNEWWINDOW 32777
#define ID_LINK_OPENINNEWWINDOW 32777
#define ID_EDIT_COPYSHORTCUT 32778
#define ID_LINK_COPYSHORTCUT 32778
#define ID_LINK_PROPERTIES 32779
#define ID_EDIT_CUT 32780
#define ID_EDIT_COPY 32781
#define ID_EDIT_PASTE 32782
#define ID_EDIT_SELECTALL 32783
#define ID_SELECTIONPOPUP_PRINT 32784
#define ID_DOCUMENT_SELECTALL 32785
#define ID_DOCUMENT_PASTE 32786
#define ID_TEXT_CUT 32787
#define ID_TEXT_COPY 32788
#define ID_TEXT_PASTE 32789
#define ID_TEXT_SELECTALL 32790
#define ID_TEXT_PRINT 32791
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 218
#define _APS_NEXT_COMMAND_VALUE 32792
#define _APS_NEXT_CONTROL_VALUE 246
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

Просмотреть файл

@ -0,0 +1,83 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Netscape Communications, Inc.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Adam Lock <adamlock@eircom.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = mozctlx
DEFFILE = $(win_srcdir)/mozctlx.def
FORCE_SHARED_LIB= 1
GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
CPPSRCS = \
StdAfx.cpp \
control_kicker.cpp \
$(NULL)
OS_LIBS += \
comdlg32.lib \
ole32.lib \
oleaut32.lib \
uuid.lib \
shell32.lib \
$(NULL)
ENABLE_CXX_EXCEPTIONS = 1
EMBED_MANIFEST_AT = 2
include $(topsrcdir)/config/rules.mk
CXXFLAGS += -D "WIN32" -GF -MT -O1
libs::
ifdef MOZ_ACTIVEX_REGISTRATION
ifneq ($(OS_TARGET),WIN98)
-regsvr32 -s -c $(DIST)/bin/$(SHARED_LIBRARY)
endif
endif
clean clobber clobber_all realclean distclean::
-regsvr32 -s -c -u $(DIST)/bin/$(SHARED_LIBRARY)
control_kicker.cpp StdAfx.cpp: StdAfx.h

Просмотреть файл

@ -0,0 +1,37 @@
========================================================================
DYNAMIC LINK LIBRARY : control_kicker
========================================================================
AppWizard has created this control_kicker DLL for you.
This file contains a summary of what you will find in each of the files that
make up your control_kicker application.
control_kicker.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
control_kicker.cpp
This is the main DLL source file.
control_kicker.h
This file contains your DLL exports.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named control_kicker.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.cpp : source file that includes just the standard includes
// control_kicker.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_)
#define AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <tchar.h>
#include <wtypes.h>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__7F2751C5_DFC7_4E43_BE16_785116B26B4A__INCLUDED_)

Просмотреть файл

@ -0,0 +1,415 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include <sys/types.h>
#include <sys/stat.h>
#include "shlobj.h"
static BOOL LoadMozLibraryFromCurrentDir();
static BOOL LoadMozLibraryFromRegistry(BOOL bAskUserToSetPath);
static BOOL LoadLibraryWithPATHFixup(const TCHAR *szBinDirPath);
static HMODULE ghMozCtlX = NULL;
static HMODULE ghMozCtl = NULL;
static LPCTSTR c_szMozCtlDll = _T("mozctl.dll");
static LPCTSTR c_szMozillaControlKey = _T("Software\\Mozilla\\");
static LPCTSTR c_szMozillaBinDirPathValue = _T("BinDirectoryPath");
static LPCTSTR c_szMozCtlInProcServerKey =
_T("CLSID\\{1339B54C-3453-11D2-93B9-000000000000}\\InProcServer32");
// Message strings - should come from a resource file
static LPCTSTR c_szWarningTitle =
_T("Mozilla Control Warning");
static LPCTSTR c_szErrorTitle =
_T("Mozilla Control Error");
static LPCTSTR c_szPrePickFolderMsg =
_T("The Mozilla control was unable to detect where your Mozilla "
"layout libraries may be found. You will now be shown a directory "
"picker for you to locate them.");
static LPCTSTR c_szPickFolderDlgTitle =
_T("Pick where the Mozilla bin directory is located, "
"e.g. (c:\\mozilla\\bin)");
static LPCTSTR c_szRegistryErrorMsg =
_T("The Mozilla control was unable to store the location of the Mozilla"
"layout libraries in the registry. This may be due to the host "
"program running with insufficient permissions to write there.\n\n"
"You should consider running the control once as Administrator "
"to enable this entry to added or alternatively move the "
"control files mozctlx.dll and mozctl.dll into the same folder as "
"the other libraries.");
static LPCTSTR c_szLoadErrorMsg =
_T("The Mozilla control could not be loaded correctly. This is could "
"be due to an invalid location being specified for the Mozilla "
"layout libraries or missing files from your installation.\n\n"
"Visit http://www.iol.ie/~locka/mozilla/mozilla.htm for in-depth"
"troubleshooting advice.");
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
ghMozCtlX = (HMODULE) hModule;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
if (ghMozCtl)
{
FreeLibrary(ghMozCtl);
ghMozCtl = NULL;
}
break;
}
return TRUE;
}
static BOOL LoadMozLibrary(BOOL bAskUserToSetPath = TRUE)
{
if (ghMozCtl)
{
return TRUE;
}
ghMozCtl = LoadLibrary(c_szMozCtlDll);
if (ghMozCtl)
{
return TRUE;
}
if (LoadMozLibraryFromCurrentDir())
{
return TRUE;
}
if (LoadMozLibraryFromRegistry(bAskUserToSetPath))
{
return TRUE;
}
::MessageBox(NULL, c_szLoadErrorMsg, c_szErrorTitle, MB_OK);
return FALSE;
}
static BOOL LoadMozLibraryFromCurrentDir()
{
TCHAR szMozCtlXPath[MAX_PATH + 1];
// Get this module's path
ZeroMemory(szMozCtlXPath, sizeof(szMozCtlXPath));
GetModuleFileName(ghMozCtlX, szMozCtlXPath,
sizeof(szMozCtlXPath) / sizeof(szMozCtlXPath[0]));
// Make the control path
TCHAR szTmpDrive[_MAX_DRIVE];
TCHAR szTmpDir[_MAX_DIR];
TCHAR szTmpFname[_MAX_FNAME];
TCHAR szTmpExt[_MAX_EXT];
_tsplitpath(szMozCtlXPath, szTmpDrive, szTmpDir, szTmpFname, szTmpExt);
TCHAR szMozCtlPath[MAX_PATH + 1];
ZeroMemory(szMozCtlPath, sizeof(szMozCtlPath));
_tmakepath(szMozCtlPath, szTmpDrive, szTmpDir, c_szMozCtlDll, NULL);
// Stat to see if the control exists
struct _stat dirStat;
if (_tstat(szMozCtlPath, &dirStat) == 0)
{
TCHAR szBinDirPath[MAX_PATH + 1];
ZeroMemory(szBinDirPath, sizeof(szBinDirPath));
_tmakepath(szBinDirPath, szTmpDrive, szTmpDir, NULL, NULL);
if (LoadLibraryWithPATHFixup(szBinDirPath))
{
return TRUE;
}
}
return FALSE;
}
static BOOL LoadMozLibraryFromRegistry(BOOL bAskUserToSetPath)
{
//
HKEY hkey = NULL;
TCHAR szBinDirPath[MAX_PATH + 1];
DWORD dwBufSize = sizeof(szBinDirPath);
ZeroMemory(szBinDirPath, dwBufSize);
// First try and read the path from the registry
RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_szMozillaControlKey, 0, KEY_READ, &hkey);
if (hkey)
{
DWORD dwType = REG_SZ;
RegQueryValueEx(hkey, c_szMozillaBinDirPathValue, NULL, &dwType,
(LPBYTE) szBinDirPath, &dwBufSize);
RegCloseKey(hkey);
hkey = NULL;
if (lstrlen(szBinDirPath) > 0 && LoadLibraryWithPATHFixup(szBinDirPath))
{
return TRUE;
}
// NOTE: We will drop through here if the registry key existed
// but didn't lead to the control being loaded.
}
// Ask the user to pick to pick the path?
if (bAskUserToSetPath)
{
// Tell the user that they have to pick the bin dir path
::MessageBox(NULL, c_szPrePickFolderMsg, c_szWarningTitle, MB_OK);
// Show a folder picker for the user to choose the bin directory
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = szBinDirPath;
bi.lpszTitle = c_szPickFolderDlgTitle;
LPITEMIDLIST pItemList = SHBrowseForFolder(&bi);
if (pItemList)
{
// Get the path from the user selection
IMalloc *pShellAllocator = NULL;
SHGetMalloc(&pShellAllocator);
if (pShellAllocator)
{
char szPath[MAX_PATH + 1];
if (SHGetPathFromIDList(pItemList, szPath))
{
// Chop off the end path separator
int nPathSize = strlen(szPath);
if (nPathSize > 0)
{
if (szPath[nPathSize - 1] == '\\')
{
szPath[nPathSize - 1] = '\0';
}
}
// Form the file pattern
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, szPath, szBinDirPath, -1,
sizeof(szBinDirPath) / sizeof(TCHAR));
#else
lstrcpy(szBinDirPath, szPath);
#endif
}
pShellAllocator->Free(pItemList);
pShellAllocator->Release();
}
}
// Store the new path if we can
if (lstrlen(szBinDirPath) > 0)
{
RegCreateKeyEx(HKEY_LOCAL_MACHINE, c_szMozillaControlKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL);
if (hkey)
{
RegSetValueEx(hkey, c_szMozillaBinDirPathValue, 0, REG_SZ,
(LPBYTE) szBinDirPath, lstrlen(szBinDirPath) * sizeof(TCHAR));
RegCloseKey(hkey);
}
else
{
// Tell the user the key can't be stored but the path they
// chose will be used for this session
::MessageBox(NULL, c_szRegistryErrorMsg, c_szErrorTitle, MB_OK);
}
}
}
if (lstrlen(szBinDirPath) > 0 && LoadLibraryWithPATHFixup(szBinDirPath))
{
return TRUE;
}
return FALSE;
}
static BOOL LoadLibraryWithPATHFixup(const TCHAR *szBinDirPath)
{
TCHAR szOldPath[8192];
TCHAR szNewPath[8192];
ZeroMemory(szOldPath, sizeof(szOldPath));
ZeroMemory(szNewPath, sizeof(szNewPath));
// Append path to front of PATH
GetEnvironmentVariable("PATH", szOldPath, sizeof(szOldPath) / sizeof(TCHAR));
lstrcat(szNewPath, szBinDirPath);
lstrcat(szNewPath, _T(";"));
lstrcat(szNewPath, szOldPath);
SetEnvironmentVariable("PATH", szNewPath);
// Attempt load
ghMozCtl = LoadLibrary(c_szMozCtlDll);
if (ghMozCtl)
{
return TRUE;
}
// Restore old PATH
SetEnvironmentVariable("PATH", szOldPath);
return FALSE;
}
static BOOL FixupInProcRegistryEntry()
{
TCHAR szMozCtlXLongPath[MAX_PATH+1];
ZeroMemory(szMozCtlXLongPath, sizeof(szMozCtlXLongPath));
GetModuleFileName(ghMozCtlX, szMozCtlXLongPath,
sizeof(szMozCtlXLongPath) * sizeof(TCHAR));
TCHAR szMozCtlXPath[MAX_PATH+1];
ZeroMemory(szMozCtlXPath, sizeof(szMozCtlXPath));
GetShortPathName(szMozCtlXLongPath, szMozCtlXPath,
sizeof(szMozCtlXPath) * sizeof(TCHAR));
HKEY hkey = NULL;
RegOpenKeyEx(HKEY_CLASSES_ROOT, c_szMozCtlInProcServerKey, 0, KEY_ALL_ACCESS, &hkey);
if (hkey)
{
RegSetValueEx(hkey, NULL, 0, REG_SZ, (LPBYTE) szMozCtlXPath,
lstrlen(szMozCtlXPath) * sizeof(TCHAR));
RegCloseKey(hkey);
return TRUE;
}
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
typedef HRESULT (STDAPICALLTYPE *DllCanUnloadNowFn)(void);
STDAPI DllCanUnloadNow(void)
{
if (LoadMozLibrary())
{
DllCanUnloadNowFn pfn = (DllCanUnloadNowFn)
GetProcAddress(ghMozCtl, _T("DllCanUnloadNow"));
if (pfn)
{
return pfn();
}
}
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
typedef HRESULT (STDAPICALLTYPE *DllGetClassObjectFn)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
if (LoadMozLibrary())
{
DllGetClassObjectFn pfn = (DllGetClassObjectFn)
GetProcAddress(ghMozCtl, _T("DllGetClassObject"));
if (pfn)
{
return pfn(rclsid, riid, ppv);
}
}
return E_FAIL;
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
typedef HRESULT (STDAPICALLTYPE *DllRegisterServerFn)(void);
STDAPI DllRegisterServer(void)
{
if (LoadMozLibrary())
{
DllRegisterServerFn pfn = (DllRegisterServerFn)
GetProcAddress(ghMozCtl, _T("DllRegisterServer"));
if (pfn)
{
HRESULT hr = pfn();
if (SUCCEEDED(hr))
{
FixupInProcRegistryEntry();
}
return hr;
}
}
return E_FAIL;
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
typedef HRESULT (STDAPICALLTYPE *DllUnregisterServerFn)(void);
STDAPI DllUnregisterServer(void)
{
if (LoadMozLibrary())
{
DllUnregisterServerFn pfn = (DllUnregisterServerFn)
GetProcAddress(ghMozCtl, _T("DllUnregisterServer"));
if (pfn)
{
return pfn();
}
}
return E_FAIL;
}

Просмотреть файл

@ -0,0 +1,109 @@
# Microsoft Developer Studio Project File - Name="control_kicker" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) External Target" 0x0106
CFG=control_kicker - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "control_kicker.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "control_kicker.mak" CFG="control_kicker - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "control_kicker - Win32 Release" (based on "Win32 (x86) External Target")
!MESSAGE "control_kicker - Win32 Debug" (based on "Win32 (x86) External Target")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "control_kicker - Win32 Release"
# PROP BASE Use_MFC
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Cmd_Line "NMAKE /f control_kicker.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "control_kicker.exe"
# PROP BASE Bsc_Name "control_kicker.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Cmd_Line "nmake /f makefile.win"
# PROP Rebuild_Opt "/a"
# PROP Target_File "WIN32_O.OBJ\mozctlx.dll"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "control_kicker - Win32 Debug"
# PROP BASE Use_MFC
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Cmd_Line "NMAKE /f control_kicker.mak"
# PROP BASE Rebuild_Opt "/a"
# PROP BASE Target_File "control_kicker.exe"
# PROP BASE Bsc_Name "control_kicker.bsc"
# PROP BASE Target_Dir ""
# PROP Use_MFC
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Cmd_Line "nmake /f makefile.win"
# PROP Rebuild_Opt "/a"
# PROP Target_File "WIN32_D.OBJ\mozctlx.dll"
# PROP Bsc_Name ""
# PROP Target_Dir ""
!ENDIF
# Begin Target
# Name "control_kicker - Win32 Release"
# Name "control_kicker - Win32 Debug"
!IF "$(CFG)" == "control_kicker - Win32 Release"
!ELSEIF "$(CFG)" == "control_kicker - Win32 Debug"
!ENDIF
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\control_kicker.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\control_kicker.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# End Target
# End Project

Просмотреть файл

@ -0,0 +1,35 @@
#ifde
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
_Module.UnregisterServer();
return S_OK;
}

Просмотреть файл

@ -0,0 +1,10 @@
; mozctlx.def : Declares the module parameters.
LIBRARY "mozctlx.dll"
EXPORTS
; ActiveX exports
DllCanUnloadNow @100 PRIVATE
DllGetClassObject @101 PRIVATE
DllRegisterServer @102 PRIVATE
DllUnregisterServer @103 PRIVATE

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
* Paul Oswald <paul.oswald@isinet.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef LEGACYPLUGIN_H
#define LEGACYPLUGIN_H
#include "npapi.h"
#include "nsISupports.h"
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
#include "XPConnect.h"
#endif
// Plugin types supported
enum PluginInstanceType
{
itScript,
itControl
};
// Data associated with a plugin instance
struct PluginInstanceData {
NPP pPluginInstance;
PluginInstanceType nType;
CControlSiteInstance *pControlSite;
#ifdef XPC_IDISPATCH_SUPPORT
nsEventSinkInstance *pControlEventSink;
#endif
char *szUrl;
char *szContentType;
CLSID clsid;
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
nsISupports *pScriptingPeer;
#endif
};
#endif

Просмотреть файл

@ -0,0 +1,241 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Adam Lock <adamlock@netscape.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
###############################################################################
# CUSTOMISE SETTINGS IN THIS SECTION AS APPROPRIATE FOR YOUR BUILD SYSTEM!
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = npmozax
LIBRARY_NAME = npmozax
RESFILE = MozActiveX.res
DEFFILE = npmozax.def
GRE_MODULE = 1
XPIFILE = mozactivex.xpi
FORCE_SHARED_LIB = 1
NO_DIST_INSTALL = 1
NO_INSTALL = 1
# Path to the Mozilla ActiveX common dir (some files are copied from there)
AXCOMMONSRC=$(srcdir)/../common
############
# XPConnect settings
MOZ_ACTIVEX_PLUGIN_XPCONNECT = 1
# XPConnect support in (Netscape 6.1+/Mozilla)
# Uncomment this line to install the plugin & policy
MOZ_USE_ACTIVEX_PLUGIN = 1
# Settings will also be read from this supplemental file if it exists
-include $(srcdir)/plugin.mk
###############################################################################
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
XPIDLSRCS = \
./nsIMozAxPlugin.idl \
$(NULL)
endif
GARBAGE += $(DEFFILE)
CPPSRCS = \
StdAfx.cpp \
LegacyPlugin.cpp \
MozActiveX.cpp \
npwin.cpp \
$(NULL)
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
CPPSRCS += XPConnect.cpp XPCDocument.cpp XPCBrowser.cpp
endif
ifdef MOZ_ACTIVEX_PLUGIN_LIVECONNECT
_AXCOMMON_CPPSRCS = \
ActiveScriptSite.cpp \
ControlEventSink.cpp \
ControlSite.cpp \
ControlSiteIPFrame.cpp \
ItemContainer.cpp \
PropertyBag.cpp \
$(NULL)
CPPSRCS += $(_AXCOMMON_CPPSRCS)
CSRCS += javastubs.c
endif
ifdef XPC_IDISPATCH_SUPPORT
CPPSRCS += PrefObserver.cpp
endif
LOCAL_INCLUDES = -I$(srcdir) -I$(AXCOMMONSRC)
ifdef MOZ_ACTIVEX_PLUGIN_LIVECONNECT
LOCAL_INCLUDES += -I./_java
endif
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
LOCAL_INCLUDES += -I$(XPIDL_GEN_DIR)
endif
OS_LIBS += \
comdlg32.lib \
ole32.lib \
oleaut32.lib \
uuid.lib \
shell32.lib \
$(NULL)
ifdef MOZ_ACTIVEX_PLUGIN_LIVECONNECT
DEFINES += -DMOZ_ACTIVEX_PLUGIN_LIVECONNECT -DXPCOM_GLUE
endif
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
DEFINES += -DMOZ_ACTIVEX_PLUGIN_XPCONNECT
endif
ifdef XPC_IDISPATCH_SUPPORT
DEFINES += -DXPC_IDISPATCH_SUPPORT
endif
EXTRA_DSO_LDOPTS = \
$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \
$(NSPR_LIBS) \
$(NULL)
LIBS = \
$(NSPR_LIBS) \
$(NULL)
# XPConnect links to XPCOM and the shared activex lib
ifdef XPC_IDISPATCH_SUPPORT
EXTRA_DSO_LDOPTS += \
../common/$(LIB_PREFIX)ax_common_s.$(LIB_SUFFIX) \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(NULL)
endif
SRCS_IN_OBJDIR = 1
ENABLE_CXX_EXCEPTIONS = 1
include $(topsrcdir)/config/rules.mk
ifdef MOZ_ACTIVEX_PLUGIN_LIVCONNECT
copy-sources: $(addprefix $(MOZCTLSRC)/,$(_CONTROL_CPPSRCS))
$(INSTALL) $^ .
export:: copy-sources
endif
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(INSTALL) $< $(DIST)/bin/plugins
endif
install-class: MozAxPlugin.class
$(INSTALL) $< $(DIST)/bin/plugins
install-typelib: $(XPIDL_GEN_DIR)/nsIMozAxPlugin.xpt
$(INSTALL) $< $(DIST)/bin/plugins
install-securitypolicy: nsAxSecurityPolicy.js
$(INSTALL) $< $(DIST)/bin/components
install-prefs: activex.js $(FLASHLITE_PREFS_JS)
$(INSTALL) $^ $(DIST)/bin/defaults/pref
ifdef MOZ_USE_ACTIVEX_PLUGIN
libs:: install-plugin install-prefs
ifdef MOZ_ACTIVEX_PLUGIN_LIVECONNECT
libs:: install-class
endif
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
libs:: install-typelib
endif
ifdef XPC_IDISPATCH_SUPPORT
libs:: install-securitypolicy
endif
endif
## Note: Ensure you create the redist dir containing the correct runtime dlls
xpi:: install.js $(SHARED_LIBRARY)
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) $<
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) $(SHARED_LIBRARY)
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) $(topsrcdir)/../redist/microsoft/system/msvcrt.dll
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) $(topsrcdir)/../redist/microsoft/system/msvcp60.dll
ifdef MOZ_ACTIVEX_PLUGIN_LIVECONNECT
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) MozAxPlugin.class
endif
ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) $(XPIDL_GEN_DIR)/nsIMozAxPlugin.xpt
endif
ifdef XPC_IDISPATCH_SUPPORT
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) activex.js
$(ZIP) -9 -j $(DIST)/bin/$(XPIFILE) nsAxSecurityPolicy.js
endif
$(SHARED_LIBRARY) : $(DEFFILE)
$(DEFFILE):
-rm -f $@
@echo "; npmozax.def : Declares the module parameters." >> $@
@echo "; This file was autogenerated by mkctldef.bat!" >> $@
@echo "" >> $@
@echo "LIBRARY "npmozax.DLL"" >> $@
@echo "EXPORTS" >> $@
@echo "; Plugin exports" >> $@
@echo "NP_GetEntryPoints @1" >> $@
@echo "NP_Initialize @2" >> $@
@echo "NP_Shutdown @3" >> $@

Просмотреть файл

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// npmozax.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f MozillaControlps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include "initguid.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
END_OBJECT_MAP()
#if 0
BOOL WINAPI
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_ATLLib);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
_Module.Term();
}
return TRUE; // ok
}
#endif

Просмотреть файл

@ -0,0 +1,124 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#include "winresrc.h"
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,4
PRODUCTVERSION 1,0,0,4
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Mozilla ActiveX control and plugin module\0"
VALUE "FileExtents", "*.ocx|*.ocx\0"
VALUE "FileOpenName", "ActiveX (*.ocx)|ActiveX (*.ocx)|Adobe Flash Movie (*.swf)|Adobe Flash Movie (*.swf)\0"
VALUE "FileVersion", "1, 0, 0, 4\0"
VALUE "InternalName", "NPMOZAX\0"
VALUE "LegalCopyright", "Copyright 1999\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "application/x-oleobject|application/oleobject|application/x-shockwave-flash|application/x-shockwave-flash\0"
VALUE "OriginalFilename", "NPMOZAX.DLL\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Mozilla ActiveX control and plugin support\0"
VALUE "ProductVersion", "1, 0, 0, 4\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Просмотреть файл

@ -0,0 +1,62 @@
import netscape.plugin.Plugin;
public class MozAxPlugin extends Plugin
{
///////////////////////////////////////////////////////////////////////////
// Public methods that are exposed through LiveConnect
public Object getProperty(String dispid)
{
return xgetProperty(dispid);
}
public void setProperty(String dispid, String property)
{
xsetProperty1(dispid, property);
}
public void setProperty(String dispid, Object property)
{
xsetProperty2(dispid, property);
}
public Object invoke(String dispid)
{
return xinvoke(dispid);
}
public Object invoke(String dispid, Object p1)
{
return xinvoke1(dispid, p1);
}
public Object invoke(String dispid, Object p1, Object p2)
{
return xinvoke2(dispid, p1, p2);
}
public Object invoke(String dispid, Object p1, Object p2, Object p3)
{
return xinvoke3(dispid, p1, p2, p3);
}
public Object invoke(String dispid, Object p1, Object p2, Object p3, Object p4)
{
return xinvoke4(dispid, p1, p2, p3, p4);
}
public Object invoke(String dispid, Object params[])
{
return xinvokeX(dispid, params);
}
///////////////////////////////////////////////////////////////////////////
// Native implementations of the above methods.
//
// Note: These methods are not overloaded like the public versions above
// because javah generates bad code which doesn't compile if you try.
private native Object xgetProperty(String dispid);
private native void xsetProperty1(String dispid, String property);
private native void xsetProperty2(String dispid, Object property);
private native Object xinvoke(String dispid);
private native Object xinvoke1(String dispid, Object p1);
private native Object xinvoke2(String dispid, Object p1, Object p2);
private native Object xinvoke3(String dispid, Object p1, Object p2, Object p3);
private native Object xinvoke4(String dispid, Object p1, Object p2, Object p3, Object p4);
private native Object xinvokeX(String dispid, Object params[]);
};

Просмотреть файл

@ -0,0 +1,218 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include <Wininet.h>
#include "npapi.h"
#include "nsServiceManagerUtils.h"
#include "nsISupportsUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch2.h"
#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsStringAPI.h"
#include "XPConnect.h"
// These are the default hosting flags in the absence of a pref.
const PRUint32 kDefaultHostingFlags =
#ifdef XPC_IDISPATCH_SUPPORT
nsIActiveXSecurityPolicy::HOSTING_FLAGS_HOST_NOTHING;
#else
nsIActiveXSecurityPolicy::HOSTING_FLAGS_HOST_SAFE_OBJECTS |
nsIActiveXSecurityPolicy::HOSTING_FLAGS_DOWNLOAD_CONTROLS |
nsIActiveXSecurityPolicy::HOSTING_FLAGS_SCRIPT_SAFE_OBJECTS;
#endif
class PrefObserver :
public nsSupportsWeakReference,
public nsIObserver
{
public:
PrefObserver();
protected:
virtual ~PrefObserver();
void Sync(nsIPrefBranch *aPrefBranch);
PRUint32 mHostingFlags;
nsCOMPtr<nsIPrefBranch2> mPrefBranch;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
static PrefObserver *sPrefObserver;
nsresult Subscribe();
nsresult Unsubscribe();
PRUint32 GetHostingFlags() const;
};
const char *kActiveXHostingFlags = "security.xpconnect.activex.";
const char *kUserAgentPref = "general.useragent.";
const char *kProxyPref = "network.http.";
PrefObserver *PrefObserver::sPrefObserver = nsnull;
PrefObserver::PrefObserver() :
mHostingFlags(kDefaultHostingFlags)
{
nsresult rv = NS_OK;
mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ASSERTION(mPrefBranch, "where is the pref service?");
}
PrefObserver::~PrefObserver()
{
}
NS_IMPL_ADDREF(PrefObserver)
NS_IMPL_RELEASE(PrefObserver)
NS_INTERFACE_MAP_BEGIN(PrefObserver)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
/* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */
NS_IMETHODIMP PrefObserver::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
if (strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic) != 0)
{
return S_OK;
}
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(aSubject, &rv);
if (NS_FAILED(rv))
return rv;
NS_ConvertUTF16toUTF8 pref(aData);
if (strcmp(kActiveXHostingFlags, pref.get()) == 0 ||
strcmp(kUserAgentPref, pref.get()) == 0 ||
strcmp(kProxyPref, pref.get()) == 0)
{
Sync(prefBranch);
}
return NS_OK;
}
void PrefObserver::Sync(nsIPrefBranch *aPrefBranch)
{
NS_ASSERTION(aPrefBranch, "no pref branch");
if (!aPrefBranch)
{
return;
}
// TODO
// const char *userAgent = NPN_UserAgent(mData->pPluginInstance);
// ::UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, userAgent, strlen(userAgent), 0);
// TODO
// INTERNET_PROXY_INFO ipi;
// ::UrlMkSetSessionOption(INTERNET_OPTION_PROXY, ....);
nsCOMPtr<nsIDispatchSupport> dispSupport = do_GetService(NS_IDISPATCH_SUPPORT_CONTRACTID);
if (!dispSupport)
mHostingFlags = kDefaultHostingFlags;
else
dispSupport->GetHostingFlags(nsnull, &mHostingFlags);
}
nsresult
PrefObserver::Subscribe()
{
NS_ENSURE_TRUE(mPrefBranch, NS_ERROR_FAILURE);
mPrefBranch->AddObserver(kProxyPref, this, PR_TRUE);
mPrefBranch->AddObserver(kUserAgentPref, this, PR_TRUE);
mPrefBranch->AddObserver(kActiveXHostingFlags, this, PR_TRUE);
Sync(mPrefBranch);
return S_OK;
}
nsresult
PrefObserver::Unsubscribe()
{
NS_ENSURE_TRUE(mPrefBranch, NS_ERROR_FAILURE);
mPrefBranch->RemoveObserver(kProxyPref, this);
mPrefBranch->RemoveObserver(kUserAgentPref, this);
mPrefBranch->RemoveObserver(kActiveXHostingFlags, this);
return NS_OK;
}
PRUint32 PrefObserver::GetHostingFlags() const
{
return mHostingFlags;
}
///////////////////////////////////////////////////////////////////////////////
PRUint32 MozAxPlugin::PrefGetHostingFlags()
{
if (!PrefObserver::sPrefObserver)
{
PrefObserver::sPrefObserver = new PrefObserver();
if (!PrefObserver::sPrefObserver)
{
return nsIActiveXSecurityPolicy::HOSTING_FLAGS_HOST_NOTHING;
}
PrefObserver::sPrefObserver->AddRef();
PrefObserver::sPrefObserver->Subscribe();
}
return PrefObserver::sPrefObserver->GetHostingFlags();
}
void MozAxPlugin::ReleasePrefObserver()
{
if (PrefObserver::sPrefObserver)
{
PrefObserver::sPrefObserver->Unsubscribe();
PrefObserver::sPrefObserver->Release();
PrefObserver::sPrefObserver = nsnull;
}
}

Просмотреть файл

@ -0,0 +1 @@
#include "StdAfx.h"

Просмотреть файл

@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_)
#define AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define STRICT
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0403
#define _ATL_APARTMENT_THREADED
#define _ATL_STATIC_REGISTRY
#define USE_PLUGIN
// Uncomment if you want to say what is QI'ing for what
//#define _ATL_DEBUG_QI
// ATL headers
// The ATL headers that come with the platform SDK have bad for scoping
#if _MSC_VER >= 1400
#pragma conform(forScope, push, atlhack, off)
#endif
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <atlctl.h>
#if _MSC_VER >= 1400
#pragma conform(forScope, pop, atlhack)
#endif
#include <mshtml.h>
#include <mshtmhst.h>
#include <docobj.h>
#include <winsock2.h>
#include <comdef.h>
#ifdef USE_PLUGIN
#include <activscp.h>
#endif
// STL headers
#include <vector>
#include <list>
#include <string>
// New winsock2.h doesn't define this anymore
typedef long int32;
#include "PropertyList.h"
#include "PropertyBag.h"
#include "ItemContainer.h"
#include "ControlSite.h"
#include "ControlSiteIPFrame.h"
#include "ControlEventSink.h"
#include "npapi.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__1339B542_3453_11D2_93B9_000000000000__INCLUDED)

Просмотреть файл

@ -0,0 +1,105 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StdAfx.h"
#include "npapi.h"
#include "nsCOMPtr.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsStringAPI.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsMemory.h"
#include "XPCBrowser.h"
IEBrowser::IEBrowser()
{
}
IEBrowser::~IEBrowser()
{
}
HRESULT IEBrowser::Init(PluginInstanceData *pData)
{
mData = pData;
// Get the location URL
NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow,
static_cast<nsIDOMWindow **>(getter_AddRefs(mDOMWindow)));
if (mDOMWindow)
{
mWebNavigation = do_GetInterface(mDOMWindow);
}
return S_OK;
}
nsresult IEBrowser::GetWebNavigation(nsIWebNavigation **aWebNav)
{
NS_ENSURE_ARG_POINTER(aWebNav);
*aWebNav = mWebNavigation;
NS_IF_ADDREF(*aWebNav);
return (*aWebNav) ? NS_OK : NS_ERROR_FAILURE;
}
// Return the nsIDOMWindow object
nsresult IEBrowser::GetDOMWindow(nsIDOMWindow **aDOMWindow)
{
NS_ENSURE_ARG_POINTER(aDOMWindow);
*aDOMWindow = mDOMWindow;
NS_IF_ADDREF(*aDOMWindow);
return (*aDOMWindow) ? NS_OK : NS_ERROR_FAILURE;
}
// Return the nsIPrefBranch object
nsresult IEBrowser::GetPrefs(nsIPrefBranch **aPrefBranch)
{
return CallGetService(NS_PREFSERVICE_CONTRACTID, aPrefBranch);
}
// Return the valid state of the browser
PRBool IEBrowser::BrowserIsValid()
{
return mWebNavigation ? PR_TRUE : PR_FALSE;
}

Просмотреть файл

@ -0,0 +1,86 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef IEBrowser_H
#define IEBrowser_H
#include <docobj.h>
#include <ExDisp.h>
#include "nsCOMPtr.h"
#include "nsIWebNavigation.h"
#include "LegacyPlugin.h"
#include "IWebBrowserImpl.h"
class IEBrowser :
public CComObjectRootEx<CComSingleThreadModel>,
public IWebBrowserImpl<IEBrowser, &CLSID_NULL>
{
public:
BEGIN_COM_MAP(IEBrowser)
COM_INTERFACE_ENTRY(IWebBrowser)
COM_INTERFACE_ENTRY(IWebBrowser2)
COM_INTERFACE_ENTRY(IWebBrowserApp)
END_COM_MAP()
PluginInstanceData *mData;
nsCOMPtr<nsIWebNavigation> mWebNavigation;
nsCOMPtr<nsIDOMWindow> mDOMWindow;
IEBrowser();
HRESULT Init(PluginInstanceData *pData);
protected:
virtual ~IEBrowser();
public:
// IWebBrowserImpl overrides
// Return the nsIWebNavigation object
virtual nsresult GetWebNavigation(nsIWebNavigation **aWebNav);
// Return the nsIDOMWindow object
virtual nsresult GetDOMWindow(nsIDOMWindow **aDOMWindow);
// Return the nsIPrefBranch object
virtual nsresult GetPrefs(nsIPrefBranch **aPrefBranch);
// Return the valid state of the browser
virtual PRBool BrowserIsValid();
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,161 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
* Paul Oswald <paul.oswald@isinet.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef XPCONNECT_H
#define XPCONNECT_H
#include <servprov.h>
#ifdef XPC_IDISPATCH_SUPPORT
#include "nsIDispatchSupport.h"
#include "nsIActiveXSecurityPolicy.h"
#endif
#include "nsID.h"
#include "nsCOMPtr.h"
#include "nsIClassInfo.h"
#include "nsIProgrammingLanguage.h"
#include "nsIMozAxPlugin.h"
#include "nsServiceManagerUtils.h"
#include "nsIURI.h"
#include "ControlEventSink.h"
struct PluginInstanceData;
template <class T> class nsIClassInfoImpl : public nsIClassInfo
{
NS_IMETHODIMP GetFlags(PRUint32 *aFlags)
{
*aFlags = nsIClassInfo::PLUGIN_OBJECT | nsIClassInfo::DOM_OBJECT;
return NS_OK;
}
NS_IMETHODIMP GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{
*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;
}
// The rest of the methods can safely return error codes...
NS_IMETHODIMP GetInterfaces(PRUint32 *count, nsIID * **array)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP GetContractID(char * *aContractID)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP GetClassDescription(char * *aClassDescription)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP GetClassID(nsCID * *aClassID)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{ return NS_ERROR_NOT_IMPLEMENTED; }
};
class nsScriptablePeerTearOff;
class nsScriptablePeer :
public nsIClassInfoImpl<nsScriptablePeer>,
public nsIMozAxPlugin
{
friend nsScriptablePeerTearOff;
protected:
virtual ~nsScriptablePeer();
public:
nsScriptablePeer();
nsScriptablePeerTearOff *mTearOff;
PluginInstanceData* mPlugin;
NS_DECL_ISUPPORTS
NS_DECL_NSIMOZAXPLUGIN
protected:
HRESULT GetIDispatch(IDispatch **pdisp);
HRESULT ConvertVariants(nsIVariant *aIn, VARIANT *aOut);
HRESULT ConvertVariants(VARIANT *aIn, nsIVariant **aOut);
nsresult HR2NS(HRESULT hr) const;
NS_IMETHOD InternalInvoke(const char *aMethod, unsigned int aNumArgs, nsIVariant *aArgs[]);
};
class nsScriptablePeerTearOff :
public IDispatch
{
public:
nsScriptablePeerTearOff(nsScriptablePeer *pOwner);
nsScriptablePeer *mOwner;
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release( void);
// IDispatch
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT __RPC_FAR *pctinfo);
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR __RPC_FAR *rgszNames, UINT cNames, LCID lcid, DISPID __RPC_FAR *rgDispId);
virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
};
#ifdef XPC_IDISPATCH_SUPPORT
class nsEventSink : public CControlEventSink
{
public:
PluginInstanceData* mPlugin;
virtual HRESULT InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
};
typedef CComObject<nsEventSink> nsEventSinkInstance;
#endif
namespace MozAxPlugin {
extern void AddRef();
extern void Release();
extern CLSID GetCLSIDForType(const char *mimeType);
extern NPError GetValue(NPP instance, NPPVariable variable, void *value);
extern nsScriptablePeer *GetPeerForCLSID(const CLSID &clsid);
extern void GetIIDForCLSID(const CLSID &clsid, nsIID &iid);
extern HRESULT GetServiceProvider(PluginInstanceData *pData, IServiceProvider **pSP);
#ifdef XPC_IDISPATCH_SUPPORT
extern PRUint32 PrefGetHostingFlags();
extern void ReleasePrefObserver();
extern nsresult GetCurrentLocation(NPP instance, nsIURI **aLocation);
#endif
}
#endif

Просмотреть файл

@ -0,0 +1,124 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
///////////////////////////////////////////////////////////////////////////////
// This is the default preferences file defining the behavior for hosting
// ActiveX controls in Gecko embedded applications. Embedders should override
// this file to set their own policy.
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// General hosting flags settings. Read nsIActiveXSecurityPolicy.idl in
// http://lxr.mozilla.org/seamonkey/find?string=nsIActiveXSecurityPolicy.idl
// for more combinations.
//
// Briefly,
//
// 0 means no hosting of activex controls whatsoever
// 13 means medium settings (safe for scripting controls and download / install)
// 31 means host anything (extremely dangerous!)
//
pref("security.xpconnect.activex.global.hosting_flags", 13);
///////////////////////////////////////////////////////////////////////////////
// Whitelist / Blacklist capabilities
//
// The whitelist and blacklist settings define what controls Gecko will host
// and the default allow / deny behavior.
//
// Note 1:
//
// The hosting flags pref value above takes priority over settings below.
// Therefore if the hosting flags are set to 0 (i.e. host nothing) then
// no control will be hosted no matter what controls are enabled. Likewise,
// If safe for scripting checks are (wisely) enabled, no unsafe control
// will be hosted even if it is explicitly enabled below.
//
//
// Note 2:
//
// Gecko always reads the IE browser's control blacklist if one is defined
// in the registry. This is to ensure any control identified by Microsoft
// or others as unsafe is not hosted without requiring it to be explicitly
// listed here also.
//
///////////////////////////////////////////////////////////////////////////////
// This pref sets the default policy to allow all controls or deny them all
// default. If the value is false, only controls explicitly enabled by their
// classid will be allowed. Otherwise all controls are allowed except those
// explicitly disabled by their classid.
//
// If you are writing an embedding application that only needs to run
// certain known controls, (e.g. an intranet control of some kind) you are
// advised to use the false value and enable the control explicitly.
pref("security.classID.allowByDefault", true);
///////////////////////////////////////////////////////////////////////////////
// Specify below the controls that should be explicitly enabled or disabled.
// This is achieved by writing a policy rule, specifiying the classid of the
// control and giving the control "AllAccess" or "NoAccess".
//
// CIDaaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
//
// You could explicitly ban a control (using the appropriate classid) like this
//
// pref("capability.policy.default.ClassID.CID039ef260-2a0d-11d5-90a7-0010a4e73d9a", "NoAccess");
//
// If you want to explicity enable a control then do this:
//
// pref("capability.policy.default.ClassID.CID039ef260-2a0d-11d5-90a7-0010a4e73d9a", "AllAccess");
//
// If you want to explicitly ban or allow a control for one or more sites then
// you can create a policy for those sites. This example creates a domain
// called 'trustable' containing sites where you allow an additional control
// to be hosted.:
//
// user_pref("capability.policy.policynames", "trustable");
// user_pref("capability.policy.trustable.sites", "http://www.site1.net http://www.site2.net");
// user_pref("capability.policy.trustable.ClassID.CID039ef260-2a0d-11d5-90a7-0010a4e73d9a", "AllAccess");
//

Просмотреть файл

@ -0,0 +1,161 @@
///////////////////////////////////////////////////////////////////////////////
// Settings!
var SOFTWARE_NAME = "ActiveX Plugin";
var VERSION = "1.0.0.3";
var PLID_BASE = "@mozilla.org/ActiveXPlugin";
var PLID = PLID_BASE + ",version=" + VERSION;
var FLDR_COMPONENTS = getFolder("Components");
var FLDR_PLUGINS = getFolder("Plugins");
var FLDR_PREFS = getFolder("Program","defaults/pref");
var FLDR_WINSYS = getFolder("Win System");
var PLUGIN = new FileToInstall("npmozax.dll", 300, FLDR_PLUGINS);
var XPT = new FileToInstall("nsIMozAxPlugin.xpt", 2, FLDR_COMPONENTS);
var SECURITYPOLICY = new FileToInstall("nsAxSecurityPolicy.js", 9, FLDR_COMPONENTS);
var PREFS = new FileToInstall("activex.js", 5, FLDR_PREFS);
var MSVCRT = new FileToInstall("msvcrt.dll", 400, FLDR_WINSYS);
var MSSTL60 = new FileToInstall("msvcp60.dll", 300, FLDR_WINSYS);
var MSSTL70 = new FileToInstall("msvcp70.dll", 300, FLDR_WINSYS);
var filesToAdd = new Array(PLUGIN, XPT, SECURITYPOLICY, PREFS);
var sysFilesToAdd = new Array(MSVCRT, MSSTL60, MSSTL70);
///////////////////////////////////////////////////////////////////////////////
// Invoke initInstall to start the installation
err = initInstall(SOFTWARE_NAME, PLID, VERSION);
if (err == BAD_PACKAGE_NAME)
{
// HACK: Mozilla 1.1 has a busted PLID parser which doesn't like the equals sign
PLID = PLID_BASE;
err = initInstall(SOFTWARE_NAME, PLID, VERSION);
}
if (err == SUCCESS)
{
// Install plugin files
err = verifyDiskSpace(FLDR_PLUGINS, calcSpaceRequired(filesToAdd));
if (err == SUCCESS)
{
for (i = 0; i < filesToAdd.length; i++)
{
err = addFile(PLID, VERSION, filesToAdd[i].name, filesToAdd[i].path, null);
if (err != SUCCESS)
{
alert("Installation of " + filesToAdd[i].name + " failed. Error code " + err);
logComment("adding file " + filesToAdd[i].name + " failed. Errror code: " + err);
break;
}
}
}
else
{
logComment("Cancelling current browser install due to lack of space...");
}
// Install C runtime files
if (err == SUCCESS)
{
if (verifyDiskSpace(FLDR_WINSYS, calcSpaceRequired(sysFilesToAdd)) == SUCCESS)
{
// Install system dlls *only* if they do not exist.
//
// NOTE: Ignore problems installing these files, since all kinds
// of stuff could cause this to fail and I really don't care
// about dealing with email describing failed permissions,
// locked files or whatnot.
for (i = 0; i < sysFilesToAdd.length; i++)
{
fileTemp = sysFilesToAdd[i].path + sysFilesToAdd[i].name;
fileUrl = getFolder("file:///", fileTemp);
if (File.exists(fileUrl) == false)
{
logComment("File not found: " + fileTemp);
addFile("/Microsoft/Shared",
VERSION,
sysFilesToAdd[i].name, // dir name in jar to extract
sysFilesToAdd[i].path, // Where to put this file (Returned from getFolder)
"", // subdir name to create relative to fProgram
WIN_SHARED_FILE);
logComment("addFile() of " + sysFilesToAdd[i].name + " returned: " + err);
}
else
{
logComment("File found: " + sysFilesToAdd[i].name );
}
}
}
else
{
logComment("Cancelling current browser install due to lack of space...");
}
}
}
else
{
logComment("Install failed at initInstall level with " + err);
}
if (err == SUCCESS)
{
err = performInstall();
if (err == SUCCESS)
{
alert("Installation performed successfully, you must restart the browser for the changes to take effect");
}
}
else
cancelInstall();
/**
* Function for preinstallation of plugin (FirstInstall).
* You should not stop the install process because the function failed,
* you still have a chance to install the plugin for the already
* installed gecko browsers.
*
* @param dirPath directory path from getFolder
* @param spaceRequired required space in kilobytes
*
**/
function verifyDiskSpace(dirPath, spaceRequired)
{
var spaceAvailable;
// Get the available disk space on the given path
spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
// Convert the available disk space into kilobytes
spaceAvailable = parseInt(spaceAvailable / 1024);
// do the verification
if(spaceAvailable < spaceRequired)
{
logComment("Insufficient disk space: " + dirPath);
logComment(" required : " + spaceRequired + " K");
logComment(" available: " + spaceAvailable + " K");
return INSUFFICIENT_DISK_SPACE;
}
return SUCCESS;
}
function calcSpaceRequired(fileArray)
{
var spaceRqd = 0;
for (i = 0; i < fileArray.length; i++)
{
spaceRqd += fileArray[i].size;
}
return spaceRqd;
}
function FileToInstall(fileName, fileSize, dirPath)
{
this.name = fileName;
this.size = fileSize;
this.path = dirPath;
}

Просмотреть файл

@ -0,0 +1,285 @@
/* IMPORTANT NOTE - This file has been hacked to add support for NPP_GetValue & NPP_SetValue! */
/* npwin.cpp */
//\\// INCLUDE
//#include "StdAfx.h"
#include "npapi.h"
#include "npfunctions.h"
//\\// DEFINE
#ifdef WIN32
#define NP_EXPORT
#else
#define NP_EXPORT _export
#endif
//\\// GLOBAL DATA
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// PLUGIN DLL entry points
//
// These are the Windows specific DLL entry points. They must be exoprted
//
// we need these to be global since we have to fill one of its field
// with a data (class) which requires knowlwdge of the navigator
// jump-table. This jump table is known at Initialize time (NP_Initialize)
// which is called after NP_GetEntryPoint
static NPPluginFuncs* g_pluginFuncs;
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_GetEntryPoints
//
// fills in the func table used by Navigator to call entry points in
// plugin DLL.
//
NPError WINAPI NP_EXPORT
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
// if the plugin's function table is smaller than the plugin expects,
// then they are incompatible, and should return an error
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
pFuncs->newp = NPP_New;
pFuncs->destroy = NPP_Destroy;
pFuncs->setwindow = NPP_SetWindow;
pFuncs->newstream = NPP_NewStream;
pFuncs->destroystream = NPP_DestroyStream;
pFuncs->asfile = NPP_StreamAsFile;
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
pFuncs->event = 0; /// reserved
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
pFuncs->getvalue = NPP_GetValue;
pFuncs->setvalue = NPP_SetValue;
#endif
g_pluginFuncs = pFuncs;
return NPERR_NO_ERROR;
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Initialize
//
// called immediately after the plugin DLL is loaded
//
NPError WINAPI NP_EXPORT
NP_Initialize(NPNetscapeFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
g_pNavigatorFuncs = pFuncs; // save it for future reference
// if the plugin's major ver level is lower than the Navigator's,
// then they are incompatible, and should return an error
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
// We have to defer these assignments until g_pNavigatorFuncs is set
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
g_pluginFuncs->urlnotify = NPP_URLNotify;
}
// NPP_Initialize is a standard (cross-platform) initialize function.
return NPP_Initialize();
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Shutdown
//
// called immediately before the plugin DLL is unloaded.
// This function should check for some ref count on the dll to see if it is
// unloadable or it needs to stay in memory.
//
NPError WINAPI NP_EXPORT
NP_Shutdown()
{
NPP_Shutdown();
g_pNavigatorFuncs = NULL;
return NPERR_NO_ERROR;
}
// END - PLUGIN DLL entry points
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
/* NAVIGATOR Entry points */
/* These entry points expect to be called from within the plugin. The
noteworthy assumption is that DS has already been set to point to the
plugin's DLL data segment. Don't call these functions from outside
the plugin without ensuring DS is set to the DLLs data segment first.
*/
/* returns the major/minor version numbers of the Plugin API for the plugin
and the Navigator
*/
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
}
/* causes the specified URL to be fetched and streamed in
*/
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
return g_pNavigatorFuncs->geturl(instance, url, target);
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file)
{
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
}
/* Requests that a number of bytes be provided on a stream. Typically
this would be used if a stream was in "pull" mode. An optional
position can be provided for streams which are seekable.
*/
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return g_pNavigatorFuncs->requestread(stream, rangeList);
}
/* Creates a new stream of data from the plug-in to be interpreted
by Netscape in the current window.
*/
NPError NPN_NewStream(NPP instance, NPMIMEType type,
const char* target, NPStream** stream)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides len bytes of data.
*/
int32_t NPN_Write(NPP instance, NPStream *stream,
int32_t len, void *buffer)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
int32_t result;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
}
else {
result = -1;
}
return result;
}
/* Closes a stream object.
reason indicates why the stream was closed.
*/
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides a text status message in the Netscape client user interface
*/
void NPN_Status(NPP instance, const char *message)
{
g_pNavigatorFuncs->status(instance, message);
}
/* returns the user agent string of Navigator, which contains version info
*/
const char* NPN_UserAgent(NPP instance)
{
return g_pNavigatorFuncs->uagent(instance);
}
/* allocates memory from the Navigator's memory space. Necessary so that
saved instance data may be freed by Navigator when exiting.
*/
void* NPN_MemAlloc(uint32_t size)
{
return g_pNavigatorFuncs->memalloc(size);
}
/* reciprocal of MemAlloc() above
*/
void NPN_MemFree(void* ptr)
{
g_pNavigatorFuncs->memfree(ptr);
}
/* private function to Netscape. do not use!
*/
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
{
return g_pNavigatorFuncs->getvalue(instance, variable, result);
}

Просмотреть файл

@ -0,0 +1,232 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const NS_IACTIVEXSECURITYPOLICY_CONTRACTID =
"@mozilla.org/nsactivexsecuritypolicy;1";
const NS_IACTIVEXSECURITYPOLICY_CID =
Components.ID("{B9BDB43B-109E-44b8-858C-B68C6C3DF86F}");
const nsISupports = Components.interfaces.nsISupports;
const nsIObserver = Components.interfaces.nsIObserver;
const nsIActiveXSecurityPolicy = Components.interfaces.nsIActiveXSecurityPolicy;
///////////////////////////////////////////////////////////////////////////////
// Constants representing some default flag combinations of varying degrees
// of safety.
// No controls at all
const kTotalSecurityHostingFlags =
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_NOTHING;
// Host only safe controls, no downloading or scripting
const kHighSecurityHostingFlags =
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_SAFE_OBJECTS;
// Host and script safe controls and allow downloads
const kMediumSecurityGlobalHostingFlags =
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_SAFE_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_DOWNLOAD_CONTROLS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_SCRIPT_SAFE_OBJECTS;
// Host any control and script safe controls
const kLowSecurityHostFlags =
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_SAFE_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_DOWNLOAD_CONTROLS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_SCRIPT_SAFE_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_ALL_OBJECTS;
// Goodbye cruel world
const kNoSecurityHostingFlags =
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_SAFE_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_DOWNLOAD_CONTROLS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_SCRIPT_SAFE_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_SCRIPT_ALL_OBJECTS |
nsIActiveXSecurityPolicy.HOSTING_FLAGS_HOST_ALL_OBJECTS;
///////////////////////////////////////////////////////////////////////////////
// Constants representing the default hosting flag values when there is
// no pref value. Note that these should be as tight as possible except for
// testing purposes.
const kDefaultGlobalHostingFlags = kMediumSecurityGlobalHostingFlags;
const kDefaultOtherHostingFlags = kMediumSecurityGlobalHostingFlags;
// Preferences security policy reads from
const kHostingPrefPart1 = "security.xpconnect.activex.";
const kHostingPrefPart2 = ".hosting_flags";
const kGlobalHostingFlagsPref = kHostingPrefPart1 + "global" + kHostingPrefPart2;
var gPref = null;
function addPrefListener(observer, prefStr)
{
try {
if (gPref == null) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
gPref = prefService.getBranch(null);
}
var pbi = gPref.QueryInterface(Components.interfaces.nsIPrefBranch2);
pbi.addObserver(prefStr, observer, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
}
function AxSecurityPolicy()
{
addPrefListener(this, kGlobalHostingFlagsPref);
this.syncPrefs();
this.globalHostingFlags = kDefaultGlobalHostingFlags;
}
AxSecurityPolicy.prototype = {
syncPrefs: function()
{
var hostingFlags = this.globalHostingFlags;
try {
if (gPref == null) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
gPref = prefService.getBranch(null);
}
hostingFlags = gPref.getIntPref(kGlobalHostingFlagsPref);
}
catch (ex) {
dump("Failed to read control hosting flags from \"" + kGlobalHostingFlagsPref + "\"\n");
hostingFlags = kDefaultGlobalHostingFlags;
}
if (hostingFlags != this.globalHostingFlags)
{
dump("Global activex hosting flags have changed value to " + hostingFlags + "\n");
this.globalHostingFlags = hostingFlags
}
},
// nsIActiveXSecurityPolicy
getHostingFlags: function(context)
{
var hostingFlags;
if (context == null || context == "global") {
hostingFlags = this.globalHostingFlags;
}
else {
try {
var prefName = kHostingPrefPart1 + context + kHostingPrefPart2;
hostingFlags = gPref.getIntPref(prefName);
}
catch (ex) {
dump("Failed to read control hosting prefs for \"" + context + "\" from \"" + prefName + "\" pref\n");
hostingFlags = kDefaultOtherHostingFlags;
}
hostingFlags = kDefaultOtherHostingFlags;
}
return hostingFlags;
},
// nsIObserver
observe: function(subject, topic, prefName)
{
if (topic != "nsPref:changed")
return;
this.syncPrefs();
},
// nsISupports
QueryInterface: function(iid) {
if (iid.equals(nsISupports) ||
iid.equals(nsIActiveXSecurityPolicy) ||
iid.equals(nsIObserver))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
/* factory for AxSecurityPolicy */
var AxSecurityPolicyFactory = {
createInstance: function (outer, iid)
{
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!iid.equals(nsISupports) &&
!iid.equals(nsIActiveXSecurityPolicy) &&
!iid.equals(nsIObserver))
throw Components.results.NS_ERROR_INVALID_ARG;
return new AxSecurityPolicy();
}
};
var AxSecurityPolicyModule = {
registerSelf: function (compMgr, fileSpec, location, type)
{
debug("*** Registering axsecurity policy.\n");
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(
NS_IACTIVEXSECURITYPOLICY_CID ,
"ActiveX Security Policy Service",
NS_IACTIVEXSECURITYPOLICY_CONTRACTID,
fileSpec,
location,
type);
},
unregisterSelf: function(compMgr, fileSpec, location)
{
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(NS_IACTIVEXSECURITYPOLICY_CID, fileSpec);
},
getClassObject: function(compMgr, cid, iid)
{
if (cid.equals(NS_IACTIVEXSECURITYPOLICY_CID))
return AxSecurityPolicyFactory;
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
canUnload: function(compMgr)
{
return true;
}
};
/* entrypoint */
function NSGetModule(compMgr, fileSpec) {
return AxSecurityPolicyModule;
}

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIVariant;
[scriptable, uuid(b30c2717-2bbf-4475-9ddf-9e26f893f32a)]
interface nsIMozAxPlugin : nsISupports
{
void invoke(in string str);
void invoke1(in string str, in nsIVariant a);
void invoke2(in string str, in nsIVariant a, in nsIVariant b);
void invoke3(in string str, in nsIVariant a, in nsIVariant b, in nsIVariant c);
void invoke4(in string str, in nsIVariant a, in nsIVariant b, in nsIVariant c, in nsIVariant d);
/* Set and get values */
nsIVariant getProperty(in string propertyName);
void setProperty(in string propertyName, in nsIVariant propertyValue);
};

Просмотреть файл

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin", "plugin.vcproj", "{E992202E-EF6C-48DC-96F4-9522F09411EE}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{E992202E-EF6C-48DC-96F4-9522F09411EE}.Debug.ActiveCfg = Debug|Win32
{E992202E-EF6C-48DC-96F4-9522F09411EE}.Debug.Build.0 = Debug|Win32
{E992202E-EF6C-48DC-96F4-9522F09411EE}.Release.ActiveCfg = Release|Win32
{E992202E-EF6C-48DC-96F4-9522F09411EE}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше