📄 richtexthandling.c
字号:
const BOOL f_BUMP_FORWARD_FIRST,
CdRecordSpan *const pt_span,
const char * *const ppc_fileNm,
const char * *const ppc_objNm) {
const WORD us_FILE_HOTSPOT_WEIRD = 10;
WORD us;
if (!( pt_crsr->puc_location && pt_crsr->us_recLength && (pt_CTX ?
(BOOL) pt_CTX->pt_Actuality : TRUE)))
return FALSE;
//as applicable, default the passed-in span structure to all null and the
// file-name pointers to null
if (pt_span)
memset( pt_span, NULL, sizeof( CdRecordSpan));
if (ppc_fileNm)
*ppc_fileNm = NULL;
if (ppc_objNm)
*ppc_objNm = NULL;
//if cursor seems to already be at the end of all content, return that the
// procedure has run error free, but indicating that no attachment hotspot
// was found
if (!pt_crsr->pt_item) {
pt_crsr->puc_location = NULL;
return TRUE;
}
//If requested, do an intial advance of the cursor to the next CD record.
// If the rich-text field has been exhausted, return that the procedure
// has run error free, but flag that no file-attachment hotspot was found.
if (f_BUMP_FORWARD_FIRST) {
AdvanceCdCursor( pt_crsr, pt_CTX, NULL, NULL);
if (!pt_crsr->pt_item) {
pt_crsr->puc_location = NULL;
return TRUE;
}
}
//Loop record-by-record until the beginning of a file-attachment hotspot is
// found. The "weird" file-hotspot types occurs when an attachment is
// copied to a new document via the "inherit entire selected document into
// rich text field" form property [and maybe via @Command( [MailForward])
// too?].
while (!( LOBYTE( SIG_CD_HOTSPOTBEGIN) == *pt_crsr->puc_location &&
((us = ((CDHOTSPOTBEGIN *)
pt_crsr->puc_location)->Type) ==
HOTSPOTREC_TYPE_FILE || us ==
us_FILE_HOTSPOT_WEIRD))) {
//Advance the cursor to the next CD record. If the rich-text field has
// been exhausted, return that the procedure has run error free, but
// flag that no file-attachment hotspot was found.
AdvanceCdCursor( pt_crsr, pt_CTX, NULL, NULL);
if (!pt_crsr->pt_item) {
pt_crsr->puc_location = NULL;
return TRUE;
}
} //while (!( LOBYTE( SIG_CD_HOTSPOTBEGIN) ==
//as applicable, set the span's beginning-coordinate information and set
// the filename pointers
if (pt_span)
pt_span->t_crsrBgin = *pt_crsr;
if (ppc_fileNm)
*ppc_fileNm = pt_crsr->puc_location + sizeof( CDHOTSPOTBEGIN);
if (ppc_objNm)
*ppc_objNm = pt_crsr->puc_location + sizeof( CDHOTSPOTBEGIN) +
strlen( pt_crsr->puc_location +
sizeof( CDHOTSPOTBEGIN)) + 1;
//locate the end of the hotspot
if (!f_CursorToHotspotEnd( pt_crsr, pt_CTX, NULL, NULL))
return FALSE;
//set the span's ending-coordinate information to point to the CD record
// immediately following the end-hotspot record
if (pt_span) {
pt_span->t_crsrEnd = *pt_crsr;
AdvanceCdCursor( &pt_span->t_crsrEnd, pt_CTX, NULL, NULL);
}
return TRUE;
} //ef_CursorToAttachmentHotspot(
/** eus_ResetAttachHotspotNames( ***
Makes changes to the internal and for-external-use filenames associated with
the given rich-text attachment hotspot.
--- parameters & return ------
pc_OBJNM: Optional. Address of string telling what the internal attachment name
should become. If null, the internal name currently contained within the
specified attachment hotspot will be used.
pc_FILENM: Optional. Address of the for-external-use attachment name. If null,
the for-external-use attachment name currently contained within the
specified attachment hotspot will be used.
t_CRSR: rich-text cursor pointing to the start of the hotspot-begin CD record
associated with the attachment whose name we're resetting
pt_ctx: Input & Output. Pointer to state information about the rich-text field
whose content is to be adjusted.
RETURN:
eus_ERR_INVLD_ARG if any passed-in parameter is obviously invalid
eus_SUCCESS if no error occured
Notes API error code otherwise
--- suggested enhancement ---
5/30/00 PR: improve so PGP-development shortcuts aren't needed
--- revision history --------
9/6/02 PR: listing format adjustment, minor exception-handling adjustment,
minor documentation adjustment
5/30/00 PR: added standard documentation; token renaming; minor error-handling
improvement
12/15/98 PR: created */
STATUS eus_ResetAttachHotspotNames( const char pc_OBJNM[],
const char pc_FILENM[],
const CdRecordCursor t_CRSR,
RtfTrackingInfo *const pt_ctx) {
WORD us_lenOrigRec, us;
char * pc_objNmOrig, * pc_FileNmOrig;
UINT ui_lenAttachNm;
BYTE * puc;
CDHOTSPOTBEGIN * pt;
STATUS us_err;
if (!( (pc_OBJNM || pc_FILENM) && t_CRSR.puc_location && t_CRSR.pt_item &&
t_CRSR.us_recLength && *t_CRSR.puc_location ==
LOBYTE( SIG_CD_HOTSPOTBEGIN) && pt_ctx))
return eus_ERR_INVLD_ARG;
//PGP development shortcut: skip all the complexity of doing this with a
// virtual start point
if (t_CRSR.pt_item->i_type != mi_ACTUAL || pt_ctx->ul_ActualFrontier ==
mul_FRONTIER_NO_MORE)
return eus_ERR_INVLD_ARG;
//prep our RTF context for writing out the reset
if (us_err = us_VirtualizeThruActualLocation( t_CRSR.puc_location, pt_ctx,
NULL))
return us_err;
//note the original length of the hotspot-begin record
us_lenOrigRec = ((CDHOTSPOTBEGIN *) t_CRSR.puc_location)->Header.Length;
//get a pointer to where we can append an adjusted hotspot-begin record
pc_objNmOrig = t_CRSR.puc_location + sizeof( CDHOTSPOTBEGIN);
us = sizeof( CDHOTSPOTBEGIN) + (ui_lenAttachNm = (pc_OBJNM ? strlen(
pc_OBJNM) : strlen( pc_objNmOrig)) +
1) + (pc_FILENM ? strlen( pc_FILENM) :
strlen( pc_FileNmOrig = pc_objNmOrig +
strlen( pc_objNmOrig) + 1)) + 1;
if (us_err = us_GetVirtualCdRecAppendPointer( pt_ctx, us, &puc))
return us_err;
//copy in the existing hotspot up to where the attachment names begin
memcpy( puc, t_CRSR.puc_location, sizeof( CDHOTSPOTBEGIN));
//reset as needed member fields in the hotspot-begin CD record
(pt = (CDHOTSPOTBEGIN *) puc)->Header.Length = us;
pt->DataLength = us - sizeof( CDHOTSPOTBEGIN);
pt->Flags &= 0x0000FFFF; //relativize!!
//copy in the adjusted names
strcpy( puc += sizeof( CDHOTSPOTBEGIN), pc_OBJNM ? pc_OBJNM : pc_objNmOrig);
strcpy( puc + ui_lenAttachNm, pc_FILENM ? pc_FILENM : pc_FileNmOrig);
//update the RTF context to reflect our work
pt_ctx->pt_endVirtual->ul_length += pt_ctx->pt_endVirtual->ul_length % 2 +
us;
pt_ctx->ul_ActualFrontier += us_lenOrigRec + us_lenOrigRec % 2;
return eus_SUCCESS;
} //eus_ResetAttachHotspotNames(
/** eus_InsertTextAtHotspotEnd( ***
Insert text string provided just before the specified hotspot-end CD record,
thus making the string part of the hotspot.
--- parameters & return -----
PC: address of string to insert just before the next hotspot-end CD record
t_crsr: rich-text cursor that either already points to the hotspot-end record
or points to the corresponding, preceding hotspot-begin CD record
pt_ctx: Input & Output. Pointer to environment information about the rich-text
field being operated on. Its virtuality information may be updated by the
procedure.
RETURN:
eus_SUCCESS if no errors occurred
eus_ERR_INVLD_ARG if any passed-in parameter is obviously invalid
the Notes API error code otherwise
--- suggested enhancement ----
8/9/00 PR: improve so PGP-development shortcuts aren't needed
--- revision history ---------
9/6/02 PR: minor documentation adjustment, token renaming, listing format
adjustment
8/9/00 PR: minor exception-handling adjustment
3/20/00 PR
+ extended to allow input of the hotspot-begin CD record instead of the
hotspot-end record
+ completed standard documentation
12/15/98 PR: created */
STATUS eus_InsertTextAtHotspotEnd( const char *const PC,
CdRecordCursor t_crsr,
RtfTrackingInfo *const pt_ctx) {
DWORD ul;
BYTE * puc;
CDTEXT t = {{SIG_CD_TEXT}};
STATUS us_err;
if (!( PC && pt_ctx && t_crsr.puc_location && t_crsr.pt_item &&
t_crsr.us_recLength &&
(*t_crsr.puc_location ==
LOBYTE( SIG_CD_HOTSPOTEND) ||
*t_crsr.puc_location ==
LOBYTE( SIG_CD_HOTSPOTBEGIN))))
return eus_ERR_INVLD_ARG;
//PGP development shortcut: skip all the complexity of doing this with a
// virtual start point
if (t_crsr.pt_item->i_type != mi_ACTUAL || pt_ctx->ul_ActualFrontier ==
mul_FRONTIER_NO_MORE)
return eus_ERR_INVLD_ARG;
//if necessary, loop record-by-record until the end of the hotspot is
// found
if (*t_crsr.puc_location == LOBYTE( SIG_CD_HOTSPOTBEGIN) &&
!f_CursorToHotspotEnd(
&t_crsr, pt_ctx, NULL, NULL))
return !eus_SUCCESS;
if (us_err = us_VirtualizeThruActualLocation( t_crsr.puc_location, pt_ctx,
NULL))
return us_err;
//get a pointer at which we can virtualize the insertion CDTEXT
if (us_err = us_GetVirtualCdRecAppendPointer( pt_ctx, (ul = sizeof(
CDTEXT) + strlen( PC)), &puc))
return us_err;
t.FontID = FontSetColor( DEFAULT_SMALL_FONT_ID, NOTES_COLOR_DKRED); //should
// make adjustable by caller
t.Header.Length = (WORD) ul;
//virtualize the CDTEXT
memcpy( puc, &t, sizeof( CDTEXT));
memcpy( puc + sizeof( CDTEXT), PC, strlen( PC)); //not accounting for
// linefeed translation
//done with the virtualization of the CDTEXT, update the variable that
// tracks the length of the virtual item being written to
pt_ctx->pt_endVirtual->ul_length += pt_ctx->pt_endVirtual->ul_length % 2 +
ul;
return eus_SUCCESS;
} //eus_InsertTextAtHotspotEnd(
/** eus_StartFormulaActionHotspot( ***
Writes the opening of an @Formula action hotspot at the specified location in
the given rich-text context.
--- parameters & return -----
PC: address of the @Formula string to compile and use in the action hotspot
being constructed
t_CRSR: Rich-text cursor that points to the first CD record to be included
within the action hotspot being constructed. If cursor is null, procedure
appends the hotspot start to the provided rich-text context.
pt_ctx: Input & Output. Pointer to environment information about the rich-text
field being operated on. Its virtuality information will be
updated by the procedure.
RETURN:
eus_SUCCESS if no errors occurred
eus_ERR_INVLD_ARG if any passed-in parameter is obviously invalid
the Notes API error code otherwise
--- suggested enhancement ---
8/9/00 PR: improve so PGP-development shortcut isn't needed
--- revision history --------
9/6/02 PR
+ logic enhancement to allow appending to a rich-text context as opposed to
just insertion
+ listing format adjustment, token renaming, minor documentation adjustment,
minor exception-handling adjustment
11/14/00 PR: documentation adjustment
9/16/00 PR: completed code
8/9/00 PR: created */
STATUS eus_StartFormulaActionHotspot( char PC[],
const CdRecordCursor t_CRSR,
RtfTrackingInfo *const pt_ctx) {
static HMODULE h_dll;
static FARPROC pr_NSFBeginSignature, pr_NSFMemorySign, pr_NSFEndSignature;
FORMULAHANDLE h_frmla;
HANDLE h_preSig = NULL, h_sig;
WORD us_lenFrmla, us_lenSig, us;
BYTE * puc_frmla = NULL;
CDHOTSPOTBEGIN t_HotspotBegin = {{SIG_CD_V4HOTSPOTBEGIN},
HOTSPOTREC_TYPE_HOTREGION,
HOTSPOTREC_RUNFLAG_BEGIN |
HOTSPOTREC_RUNFLAG_BOX |
HOTSPOTREC_RUNFLAG_NOBORDER |
HOTSPOTREC_RUNFLAG_FORMULA |
HOTSPOTREC_RUNFLAG_SIGNED};
BYTE * puc;
STATUS us_err;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -