Fixed some bugs in the copy to clipboard operation.

Control now calls NS_ShutdownXPCOM during destruction
This commit is contained in:
locka%iol.ie 1999-10-27 23:19:27 +00:00
Родитель 179f27b2ef
Коммит 9aee0c87bb
2 изменённых файлов: 43 добавлений и 19 удалений

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

@ -43,6 +43,8 @@ extern "C" void NS_SetupRegistry();
static const std::string c_szPrefsHomePage = "browser.startup.homepage";
static const std::string c_szDefaultPage = "resource:/res/MozillaControl.html";
static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
@ -71,6 +73,7 @@ CMozillaBrowser::CMozillaBrowser()
// Initialize layout interfaces
m_pIWebShell = nsnull;
m_pIPref = nsnull;
m_pIServiceManager = nsnull;
// Ready state of control
m_nBrowserReadyState = READYSTATE_UNINITIALIZED;
@ -313,19 +316,23 @@ LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
{
nsresult res;
nsIPresShell* presShell = nsnull;
res=GetPresShell(&presShell); //Get the presentation shell for the document
if ( NS_FAILED(res) ) return NS_ERROR_NOT_INITIALIZED;
nsIPresShell* pIPresShell = nsnull;
res = GetPresShell(&pIPresShell); //Get the presentation shell for the document
if (NS_FAILED(res) || pIPresShell == nsnull)
{
return NS_ERROR_NOT_INITIALIZED;
}
nsCOMPtr<nsIDOMSelection> selection; //Get a pointer to the DOM selection
res = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
res = pIPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ( NS_FAILED(res) ) return res;
res = presShell->DoCopy(); //Copy the selection to the clipboard
res = pIPresShell->DoCopy(); //Copy the selection to the clipboard
if ( NS_SUCCEEDED(res) )
{
res = selection->DeleteFromDocument(); //Delete the selection from the document
}
}
NS_RELEASE(pIPresShell);
return res;
}
@ -334,12 +341,16 @@ LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
{
nsresult res;
nsIPresShell* presShell = nsnull;
res=GetPresShell(&presShell); //Get the presentation shell for the document
if ( NS_FAILED(res) ) return NS_ERROR_NOT_INITIALIZED;
nsIPresShell* pIPresShell = nsnull;
res = GetPresShell(&pIPresShell); //Get the presentation shell for the document
if (NS_FAILED(res) || pIPresShell == nsnull)
{
return NS_ERROR_NOT_INITIALIZED;
}
res = pIPresShell->DoCopy();
NS_RELEASE(pIPresShell);
res = presShell->DoCopy();
return res;
}
@ -436,7 +447,6 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
HRESULT CMozillaBrowser::InitWebShell()
{
// Initialise XPCOM
nsIServiceManager *pIServiceManager = nsnull;
TCHAR szComponentPath[MAX_PATH];
TCHAR szComponentFile[MAX_PATH];
DWORD dwComponentPath = sizeof(szComponentPath) / sizeof(szComponentPath[0]);
@ -452,11 +462,11 @@ HRESULT CMozillaBrowser::InitWebShell()
m_pComponentPath = new nsFileSpec(T2A(szComponentPath));
m_pComponentFile = new nsFileSpec(T2A(szComponentFile));
NS_InitXPCOM(&pIServiceManager, m_pComponentFile, m_pComponentPath);
NS_InitXPCOM(&m_pIServiceManager, m_pComponentFile, m_pComponentPath);
}
else
{
NS_InitXPCOM(&pIServiceManager, nsnull, nsnull);
NS_InitXPCOM(&m_pIServiceManager, nsnull, nsnull);
}
// Register components
@ -488,8 +498,22 @@ HRESULT CMozillaBrowser::InitWebShell()
HRESULT CMozillaBrowser::TermWebShell()
{
// XXX: Do not call DestroyThreadEventQueue(...) for now...
// TODO terminate XPCOM
// TODO delete m_pComponentFile && m_pComponentPath
// Terminate XPCOM & cleanup
NS_ShutdownXPCOM(m_pIServiceManager);
m_pIServiceManager = nsnull;
if (m_pComponentPath)
{
delete m_pComponentPath;
m_pComponentPath = NULL;
}
if (m_pComponentFile)
{
delete m_pComponentFile;
m_pComponentFile = NULL;
}
return S_OK;
}
@ -787,8 +811,6 @@ HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument)
}
static const tstring c_szHelpKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
// Load any browser helpers
HRESULT CMozillaBrowser::LoadBrowserHelpers()
{
@ -2623,6 +2645,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Resizable(VARIANT_BOOL Value)
///////////////////////////////////////////////////////////////////////////////
// Ole Command Handlers
HRESULT _stdcall CMozillaBrowser::EditModeHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
BOOL bEditorMode = (nCmdID == IDM_EDITMODE) ? TRUE : FALSE;
@ -2630,6 +2653,7 @@ HRESULT _stdcall CMozillaBrowser::EditModeHandler(CMozillaBrowser *pThis, const
return S_OK;
}
HRESULT _stdcall CMozillaBrowser::EditCommandHandler(CMozillaBrowser *pThis, const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
{
pThis->OnEditorCommand(nCmdID);

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

@ -162,7 +162,6 @@ BEGIN_OLECOMMAND_TABLE()
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, 0, L"Find", L"Find")
OLECOMMAND_MESSAGE(HTMLID_VIEWSOURCE, &CGID_IWebBrowser, 0, L"ViewSource", L"View Source")
@ -302,6 +301,7 @@ protected:
nsIWebShell * m_pIWebShell;
nsIPref * m_pIPref;
nsIEditor * m_pEditor;
nsIServiceManager * m_pIServiceManager;
// System registry key for various control settings
CRegKey m_SystemKey;