зеркало из https://github.com/mozilla/gecko-dev.git
Preliminary work for edit mode
This commit is contained in:
Родитель
d1d6e2ff62
Коммит
e80b31825a
|
@ -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,231 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Netscape Public License
|
||||||
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||||
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||||
|
* http://www.mozilla.org/NPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* NPL.
|
||||||
|
*
|
||||||
|
* The Initial Developer of this code under the NPL is Netscape
|
||||||
|
* Communications Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*/
|
||||||
|
#ifndef IOLECOMMANDIMPL_H
|
||||||
|
#define IOLECOMMANDIMPL_H
|
||||||
|
|
||||||
|
typedef HRESULT (_stdcall *OleCommandProc)(IOleCommandTarget *pCmdTarget, 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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; \
|
||||||
|
};
|
||||||
|
|
||||||
|
// Implementation of the IOleCommandTarget interface. The template is
|
||||||
|
// reasonably generic which is a good thing given how needlessly complicated
|
||||||
|
// this interface is. Blame Microsoft not me.
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
class IOleCommandTargetImpl : public IOleCommandTarget
|
||||||
|
{
|
||||||
|
struct OleExecData
|
||||||
|
{
|
||||||
|
const GUID *pguidCmdGroup;
|
||||||
|
DWORD nCmdID;
|
||||||
|
DWORD nCmdexecopt;
|
||||||
|
VARIANT *pvaIn;
|
||||||
|
VARIANT *pvaOut;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
NG_ASSERT(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
|
||||||
|
int 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();
|
||||||
|
NG_ASSERT(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command is supported but not implemented
|
||||||
|
if (pCI->nWindowsCmdID == 0)
|
||||||
|
{
|
||||||
|
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(this, pCI->pCmdGUID, pCI->nCmdID, nCmdexecopt, pvaIn, pvaOut);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HWND hwndTarget = pT->GetCommandTargetWindow();
|
||||||
|
if (hwndTarget)
|
||||||
|
{
|
||||||
|
::SendMessage(hwndTarget, WM_COMMAND, LOWORD(pCI->nWindowsCmdID), (LPARAM) &cData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Was the command group found?
|
||||||
|
if (!bCmdGroupFound)
|
||||||
|
{
|
||||||
|
OLECMDERR_E_UNKNOWNGROUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OLECMDERR_E_NOTSUPPORTED;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Загрузка…
Ссылка в новой задаче