home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / edt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  54.9 KB  |  1,379 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. #ifndef _edt_h_
  21. #define _edt_h_
  22.  
  23. #ifdef EDITOR
  24.  
  25. #ifndef _XP_Core_
  26. #include "xp_core.h"
  27. #endif
  28.  
  29. #ifndef _edttypes_h_
  30. #include "edttypes.h"
  31. #endif
  32.  
  33. XP_BEGIN_PROTOS
  34.  
  35. struct java_lang_Object;
  36.  
  37. /*****************************************************************************
  38.  * Layout Interface
  39.  *****************************************************************************/
  40.  
  41. /*
  42.  *  Create an edit buffer, ready to be pared into.
  43.  */
  44. ED_Buffer* EDT_MakeEditBuffer(MWContext *pContext);
  45.  
  46. /*
  47.  *  Destroy an edit buffer.
  48.  */
  49. void EDT_DestroyEditBuffer(MWContext * pContext);
  50.  
  51. /* CLM:
  52.  * Front end can call this to prevent doing
  53.  * bad stuff when we failed to load URL
  54.  * and don't have a buffer
  55.  */
  56. XP_Bool EDT_HaveEditBuffer(MWContext * pContext);
  57.  
  58. /*
  59.  * Call this to get a special string to feed the editor when you're
  60.  * creating an empty document.
  61.  * Returns an alias to a special empty document string.
  62.  * (You don't own the storage, so don't free it.)
  63.  */
  64.  
  65. char* EDT_GetEmptyDocumentString(void);
  66.  
  67. /*
  68.  *  Parse a tag into an edit buffer.
  69.  */
  70. ED_Element* EDT_ParseTag(ED_Buffer* pEditBuffer, PA_Tag* pTag);
  71.  
  72. /*
  73.  * Called instead of LO_ProcessTag.  This routine allows the Edit enginge to
  74.  *  build up an HTML tree.  Inputs and outputs are the same as LO_ProcessTag.
  75. */
  76. intn EDT_ProcessTag(void *data_object, PA_Tag *tag, intn status);
  77.  
  78. /*
  79.  * Tells the edit engine to position the insert point.
  80. */
  81. void EDT_SetInsertPoint( ED_Buffer *pBuffer, ED_Element* pElement, int iPosition, XP_Bool bStickyAfter );
  82.  
  83. /*
  84.  * Assocates the layout element with a given edit element.  Called from by the
  85.  *  layout engine onces a layout element has been has been created.
  86. */
  87. void EDT_SetLayoutElement( ED_Element* pElement, intn iEditOffset, intn lo_type,
  88.             LO_Element *pLayoutElement );
  89.  
  90. /* Breaks the association between a layout element and a given edit element.
  91.  * Called by the layout engine when a layout element is being destroyed.
  92.  */
  93.  
  94. void EDT_ResetLayoutElement( ED_Element* pElement, intn iEditOffset,
  95.                             LO_Element* pLayoutElement);
  96.  
  97. /*
  98.  * Delete all tags in the chain beginning with pTag.
  99. */
  100. void EDT_DeleteTagChain( PA_Tag* pTag );
  101.  
  102. /*
  103.  * Retrieve the next tag element from the editor.  Returns NULL when there are
  104.  *  no more tags.
  105. */
  106. PA_Tag* EDT_TagCursorGetNext( ED_TagCursor* pCursor );
  107.  
  108. /*
  109.  * enclosing html for a given point in the document
  110. */
  111. PA_Tag* EDT_TagCursorGetNextState( ED_TagCursor* pCursor );
  112.  
  113. /*
  114.  * returns true if at the beginning of a paragraph or break.
  115. */
  116. XP_Bool EDT_TagCursorAtBreak( ED_TagCursor *pCursor, XP_Bool* pEndTag );
  117.  
  118. /*
  119.  * Get the current line number for the cursor
  120. */
  121. int32 EDT_TagCursorCurrentLine( ED_TagCursor* pCursor );
  122.  
  123. /*
  124.  * Get the current line number for the cursor
  125. */
  126. XP_Bool EDT_TagCursorClearRelayoutState( ED_TagCursor* pCursor );
  127.  
  128.  
  129. /*
  130.  * Clone a cursor.  Used to save position state.
  131. */
  132. ED_TagCursor* EDT_TagCursorClone( ED_TagCursor *pCursor );
  133.  
  134. /*
  135.  * Delete a cloned (or otherwise) cursor
  136. */
  137. void EDT_TagCursorDelete( ED_TagCursor* pCursor );
  138.  
  139. /*
  140.  * called when LO finishes (only the first time)
  141. */
  142. void EDT_FinishedLayout( MWContext *pContext );
  143.  
  144. /*
  145.  * Call back from image library giving the height and width of an image.
  146. */
  147. void EDT_SetImageInfo(MWContext *context, int32 ele_id, int32 width, int32 height);
  148.  
  149. /*
  150.  * Test to see if the editor is currently loading a file.
  151. */
  152. XP_Bool EDT_IsBlocked( MWContext *pContext );
  153.  
  154. /*****************************************************************************
  155.  * FE Interface
  156.  *****************************************************************************/
  157.  
  158. void EDT_SaveToBuffer ( MWContext * pContext, XP_HUGE_CHAR_PTR* pBuffer );
  159.  
  160. void EDT_ReadFromBuffer ( MWContext * pContext, XP_HUGE_CHAR_PTR pBuffer );
  161.  
  162. /*
  163.  * Returns ED_ERROR_NONE if files saved OK, else returns error code.
  164. */
  165. ED_FileError EDT_SaveFile( MWContext * pContext,
  166.                            char * pSourceURL,
  167.                            char * pDestURL,
  168.                            XP_Bool   bSaveAs,
  169.                            XP_Bool   bKeepImagesWithDoc,
  170.                            XP_Bool   bAutoAdjustLinks );
  171. /*
  172.  * Returns ED_ERROR_NONE if files saved OK, else returns error code.
  173.  */
  174. ED_FileError EDT_PublishFile( MWContext * pContext,
  175.                            ED_SaveFinishedOption finishedOpt,
  176.                            char * pSourceURL,
  177.                            char **pIncludedFiles, /* list of files to publish */
  178.                            char * pDestURL, /* Should be http:// or ftp:// */
  179.                            XP_Bool   bKeepImagesWithDoc,
  180.                            XP_Bool   bAutoAdjustLinks,
  181.                            XP_Bool   bSavePassword);  /* Tied to user checkbox in dialog */
  182.  
  183. /* 
  184.  * Check the URL that will be passed into EDT_PublishFile. 
  185.  * TRUE if pURL should be used, or FALSE if the user should
  186.  * make another choice. 
  187.  */
  188. XP_Bool EDT_CheckPublishURL( MWContext * pContext, char * pURL);
  189.  
  190. /*
  191.  * Save editor and images to an abstract file system.
  192.  * Used by libmsg to write MHTML mail messages.
  193.  */
  194. ED_FileError EDT_SaveFileTo( MWContext * pContext,
  195.                            ED_SaveFinishedOption finishedOpt,
  196.                            char * pSourceURL,
  197.                            void *tapeFS,    /* Really a (ITapeFileSystem *) */
  198.                            XP_Bool   bKeepImagesWithDoc,
  199.                            XP_Bool   bAutoAdjustLinks );
  200.  
  201. /*
  202.  * Create a temporary file with the contents of the edit buffer, images and links
  203.  * will be adjusted to work from the new location.  Call doneFn with the file:// URL
  204.  * of the temp file or NULL if failure.  doneFn may be called before EDT_SaveToTempFile
  205.  * returns.  Use EDT_RemoveTempFile when file is no longer needed.
  206.  */
  207. typedef void (*EDT_SaveToTempCallbackFn)(char *pFileURL,void *hook);
  208. void EDT_SaveToTempFile(MWContext *pContext,EDT_SaveToTempCallbackFn doneFn, void *hook);
  209. void EDT_RemoveTempFile(MWContext *pContext,char *pFileURL);
  210.  
  211. #if defined(MOZ_MAIL_COMPOSE) || defined(MOZ_MAIL_NEWS)
  212. /*
  213.  * Like MSG_MailDocument, but will deal properly with dirty or unsaved documents.
  214.  * I.e. May save document to a temp file before attaching it to the new mail 
  215.  * message. 
  216.  */
  217. void EDT_MailDocument(MWContext *pContext);
  218. #endif
  219.  
  220. /*
  221.  * Returns the temporary directory (in xpURL format) for all files associated with this document.
  222.  * Contents of this directory will be deleted when this edit buffer is destroyed.
  223.  */
  224. char *EDT_GetDocTempDir(MWContext *pContext);
  225.  
  226. /* 
  227.  * Return a unique filename (in xpURL format) for a potential file in the documents temp directory.  Does not actually 
  228.  * create the file. 
  229.  * If prefix is non-NULL, it will give the first few characters of the temp filename.
  230.  * Only the first three characters of prefix will be used.
  231.  * If extension is non-NULL, it will be the file extension, keep it <= 3 characters for windows,
  232.  * default is "TMP".
  233.  */
  234. char *EDT_CreateDocTempFilename(MWContext *pContext,char *prefix,char *extension);
  235.  
  236.  
  237. /*
  238.  * cancel a load in progress
  239. */
  240. void EDT_SaveCancel( MWContext *pContext );
  241.  
  242. /*
  243.  * Enable and disable autosave. A value of zero disables autosave.
  244.  * AutoSave doesn't start until the document has a file.
  245.  */
  246.  
  247. void EDT_SetAutoSavePeriod(MWContext *pContext, int32 minutes);
  248. int32 EDT_GetAutoSavePeriod(MWContext *pContext);
  249.  
  250. void EDT_DisplaySource( MWContext *pContext );
  251.  
  252. /*
  253.  * Edit Navagation prototypes
  254. */
  255. void EDT_PreviousChar( MWContext *context, XP_Bool bSelect );
  256. void EDT_NextChar( MWContext *context, XP_Bool bSelect );
  257. void EDT_BeginOfLine( MWContext *context, XP_Bool bSelect );
  258. void EDT_EndOfLine( MWContext *context, XP_Bool bSelect );
  259. void EDT_BeginOfDocument( MWContext *context, XP_Bool bSelect );
  260. void EDT_EndOfDocument( MWContext *context, XP_Bool bSelect );
  261. void EDT_Up( MWContext *context, XP_Bool bSelect );
  262. void EDT_Down( MWContext *context, XP_Bool bSelect );
  263. void EDT_PageUp( MWContext *context, XP_Bool bSelect );
  264. void EDT_PageDown( MWContext *context, XP_Bool bSelect );
  265. void EDT_PreviousWord( MWContext *context, XP_Bool bSelect );
  266. void EDT_NextWord( MWContext *context, XP_Bool bSelect );
  267. void EDT_NextTableCell( MWContext *context, XP_Bool bSelect );
  268. void EDT_PreviousTableCell( MWContext *context, XP_Bool bSelect );
  269.  
  270. void EDT_WindowScrolled( MWContext *context );
  271.  
  272. /*
  273.  * Edit functional stuff...
  274. */
  275. EDT_ClipboardResult EDT_DeletePreviousChar( MWContext *context );
  276. EDT_ClipboardResult EDT_DeleteChar( MWContext *context );
  277. void EDT_PositionCaret( MWContext *context, int32 x, int32 y );
  278.  
  279. /* Delete current selection and move caret to the insert point 
  280.  *  closest to supplied doc coordinates.
  281.  *  Use when moving dragged data within the same window.
  282. */
  283. void EDT_DeleteSelectionAndPositionCaret( MWContext *pContext, int32 x, int32 y );
  284.  
  285. /* Converts ("snaps") input X, Y (doc coordinates) to X, Y needed for drop caret 
  286.  *  and calls appropriate front-end FE_Display<Text|Generic|Image>Caret to use show where
  287.  *  a drop would occur. It does NOT change current selection or internal caret position
  288.  * Also handles dragging table/cells and will return FALSE if mouse is
  289.  *  not over a good drop location within a target table
  290.  * (Always returns TRUE if not dragging table or cells since
  291.  *   cursor is always snapped to a valid position)
  292.  * Call during mouse moving over a window where drop can occur
  293. */
  294. XP_Bool EDT_PositionDropCaret( MWContext *pContext, int32 x, int32 y );
  295.  
  296. /* Call to initialize global static data used for pasting table cells into existing table 
  297.  * Returns TRUE if we are dragging table or table cells
  298. */
  299. XP_Bool EDT_StartDragTable( MWContext *pContext,  int32 x, int32 y );
  300.  
  301. /* Clear the XP data for dragging tables and cells */
  302. void EDT_StopDragTable( MWContext *pContext );
  303. XP_Bool EDT_IsDraggingTable( MWContext *pContext );
  304.  
  305. void EDT_DoubleClick( MWContext *context, int32 x, int32 y );
  306. void EDT_SelectObject( MWContext *context, int32 x, int32 y);
  307. EDT_ClipboardResult EDT_ReturnKey( MWContext *context );
  308.  
  309. /* Do what the TAB key should do
  310.  * Moves from cell to cell in Tables (in direction given by bForward)
  311.  *  unless 3rd param is TRUE, which forces regular tab insert in table text
  312. */
  313. EDT_ClipboardResult EDT_TabKey( MWContext *context, XP_Bool bForward, XP_Bool bForceTabChar );
  314.  
  315. void EDT_Indent( MWContext *context );
  316. void EDT_Outdent( MWContext *context );
  317. void EDT_RemoveList( MWContext *context );
  318.  
  319. void EDT_Reload( MWContext *pContext );
  320.  
  321. /*
  322.  * Kludge, supports only the windows front end now.
  323. */
  324. EDT_ClipboardResult EDT_KeyDown( MWContext *context, uint16 nChar, uint16 b, uint16 c );
  325.  
  326. /*
  327.  * Insert a nonbreaking space character.  Usually wired to shift spacebar
  328. */
  329. EDT_ClipboardResult EDT_InsertNonbreakingSpace( MWContext *context );
  330.  
  331. /*
  332.  * Undo/Redo. Usage:
  333.  * To tell if there's a command to undo:
  334.  *  if ( EDT_GetUndoCommandID(context, 0 ) != CEDITCOMMAND_ID_NULL )
  335.  *
  336.  * To undo the most recent command:
  337.  *  EDT_Undo( context );
  338.  *
  339.  * (Similarly for redo.)
  340.  *
  341.  * Use the CommandID to look up a string for saying "Undo <type of command>..."
  342.  * on the menu.
  343.  */
  344.  
  345. #define CEDITCOMMAND_ID_NULL 0
  346. #define CEDITCOMMAND_ID_GENERICCOMMAND 1
  347.  
  348. void EDT_Undo( MWContext *pContext );
  349. void EDT_Redo( MWContext *pContext );
  350. intn EDT_GetUndoCommandID( MWContext *pContext, intn index );
  351. intn EDT_GetRedoCommandID( MWContext *pContext, intn index );
  352.  
  353. /* Lets the front end specify the command history limit. This is used to limit the total of commands on
  354.  * both the undo and the redo lists.
  355.  */
  356.  
  357. intn EDT_GetCommandHistoryLimit(void);
  358. void EDT_SetCommandHistoryLimit(intn limit); /* Must be greater than or equal to zero. Ignored if less than zero. */
  359.  
  360. /* Call from dialogs to batch changes for undo.  To use, call EDT_BeginBatchChanges,
  361.  * make the changes you want, and then call EDT_EndBatchChanges. It's OK to
  362.  * not make any changes -- in that case the undo history won't be affected.
  363.  */
  364.  
  365. void EDT_BeginBatchChanges(MWContext *pContext);
  366. void EDT_EndBatchChanges(MWContext *pContext);
  367.  
  368. /*
  369.  * Used to control display of paragraph marks.
  370.  */
  371.  
  372. void EDT_SetDisplayParagraphMarks(MWContext *pContext, XP_Bool display);
  373. XP_Bool EDT_GetDisplayParagraphMarks(MWContext *pContext);
  374.  
  375. /*
  376.  * Used to control display of tables in either wysiwyg or flat mode.
  377.  */
  378.  
  379. void EDT_SetDisplayTables(MWContext *pContext, XP_Bool display);
  380. XP_Bool EDT_GetDisplayTables(MWContext *pContext);
  381.  
  382. /*
  383.  * need to figure out how to handle tags and parameters.
  384. */
  385. void EDT_MorphContainer( MWContext *pContext, TagType t );
  386. TagType EDT_GetParagraphFormatting( MWContext *pContext );
  387. ED_Alignment EDT_GetParagraphAlign( MWContext *pContext);
  388. void EDT_SetParagraphAlign( MWContext* pContext, ED_Alignment eAlign );
  389.  
  390. /* Set Table alignment if caret is inside table or table is selected
  391.  * EDT_SetParagraphAlign will also to table if it is selected,
  392.  * so use this to force table alignment even if its not selected
  393. */
  394. void EDT_SetTableAlign( MWContext* pContext, ED_Alignment eAlign );
  395.  
  396.  
  397. /*
  398.  * Find out what's under the cursor
  399. */
  400. ED_ElementType EDT_GetCurrentElementType( MWContext *pContext );
  401.  
  402. /*
  403.  * Character Formatting (DEPRECIATED)
  404.  * Routines should only be called when EDT_GetCurrentElementType() returns
  405.  *  ED_ELEMENT_TEXT.
  406. */
  407. ED_TextFormat EDT_GetCharacterFormatting( MWContext *pContext );
  408. void EDT_FormatCharacter( MWContext *pContext, ED_TextFormat p);
  409. /* These use the older "relative" scale of 1 to 7 */
  410. int EDT_GetFontSize( MWContext *pContext );
  411. void EDT_SetFontSize( MWContext *pContext, int );
  412.  
  413. /* These use the new absolute point size*/
  414. void EDT_SetFontPointSize( MWContext *pContext, int iPoints );
  415. int EDT_GetFontPointSize( MWContext *pContext );
  416.  
  417. /* List of Font faces - concatenated strings ending in '\0\0'
  418.  * Note: First 2 strings are for Default Proportional and Default Fixed width,
  419.  *       the rest are the "NS Fonts" used to set the FONT FACE tag
  420.  * Use these to construct a list of fonts for the user
  421.  * We cache 1 static list of faces (implemented in EDTUTIL.CPP)
  422. */
  423. char *EDT_GetFontFaces(void);
  424.  
  425. /* Similar to above, but gets a list of the Tag strings
  426.  *  (what is written in FONT FACE tag that corresponds to a NS Font face name)
  427. */
  428. char *EDT_GetFontFaceTags(void);
  429.  
  430. /* Set the Font Face - encapsulates complexity of EDT_CharacterData mangling
  431.  * If pCharacterData is suppled, then it is used to set fontface data
  432.  *    (Note: pCharacterData is not freed).
  433.  * If pCharacterData is NULL, then data is obtained from current selection or at caret
  434.  * If pMWContext is supplied, then EDT_SetCharacterData() will be called
  435.  *    with either the supplied struct or the internally-obtained data
  436.  *
  437.  * Supply either iFontIndex or pFontFace:
  438.  *  iFontIndex is index within the font list returned by EDT_GetFontFaces(),
  439.  *      (we will lookup the appropriate string to use for Font Face Tag)
  440.  *  If pFontFace is supplied, use it exactly as is (iFontIndex is ignored)
  441. */
  442. void EDT_SetFontFace(MWContext * pMWContext, EDT_CharacterData * pCharacterData,
  443.                      int iFontIndex, char * pFontFace );
  444.  
  445. /* Get the index into the FontFace list for the current caret location or selection
  446.  * Returns 0 (ED_FONT_VARIABLE), 1 (ED_FONT_FIXED), or 2 (ED_FONT_LOCAL)
  447. */
  448. int EDT_GetFontFaceIndex(MWContext *pContext);
  449.  
  450. /* Get the current font face for current selection or insert point
  451.  * If the current font matches an XP font 'group', 
  452.  *   this is the platform-specific font matching the group,
  453.  *   else it is the font face string from EDT_CharacterData or
  454.  *   the appropriate XP string for the Variable and Fixed Width states.
  455.  *   Use this to search your local font list in menu or listbox.
  456.  *
  457.      An empty string is returned when selection is mixed (> 1 face in selection)
  458.  *   DO NOT FREE RETURN VALUE (it is a static string), but use it quickly, 
  459.  *      because it will change as caret moves throught text
  460. */
  461. char * EDT_GetFontFace(MWContext *pContext);
  462.  
  463. /* Find the pFontFace within each set of comma-delimeted FontFace groups
  464.  * Return pointer to entire group if pFontFace matches any single font in the group
  465.  * If not found, return pFontFace, thus the
  466.  * result can be passed directly as the last param of EDT_SetFontFace()
  467.  * Comparing pFontFace to result pointer can be used as test that XP font was found
  468.  * DO NOT free the resulting string pointer
  469. */
  470. char * EDT_TranslateToXPFontFace( char * pFontFace );
  471.  
  472. XP_Bool EDT_GetFontColor( MWContext *pContext, LO_Color *pDestColor );
  473. void EDT_SetFontColor( MWContext *pContext, LO_Color *pColor);
  474.  
  475. /* Parse a font colors string in the format: "r,g,b,ColorName" where colors for r,g,b
  476.  *  are decimal strings in range 0-255
  477.  * Returns pointer (within supplied string) to the Color Name 
  478.  *   and converts color strings into integers in supplied the LO_Color struct
  479. */
  480. char * EDT_ParseColorString(LO_Color * pLoColor, char * pColorString);
  481.  
  482. /* Get the Netscape solid color. This replaces EDT_GetFontColorFromList */
  483. void EDT_GetNSColor(intn iIndex, LO_Color * pLoColor);
  484.  
  485. /* Scan our list of colors and return index of matching color
  486.  *   or -1 if no match found. We NEVER return 0 (default color)
  487. */
  488. int EDT_GetMatchingFontColorIndex(LO_Color * pLOColor);
  489.  
  490. /*
  491.  * Get and set character formatting.
  492. */
  493.  
  494. /*
  495.  * EDT_GetCharacterData
  496.  *      returns the current character formatting for the current selection
  497.  *      or insert point.  Should only be called when GetCurrentElementType is
  498.  *      ED_ELEMENT_TEXT or ED_ELEMENT_SELECTION.
  499.  *
  500.  *  returns and EDT_CharacterData structure.  Caller is responsible for
  501.  *      destroying the structure by calling EDT_FreeCharacterData().
  502.  *
  503.  *  CharacterData contain on return
  504.  *      pRet->mask      // the that were deterministic (all in insertpoint case
  505.  *                      //      and those that were consistant across the selection
  506.  *      pRet->values    // if in the mask, 0 means clear across the selection
  507.  *                      //                 1 means set across the selection
  508. */
  509. EDT_CharacterData* EDT_GetCharacterData( MWContext *pContext );
  510.  
  511. /*
  512.  * EDT_SetCharacterData
  513.  *      sets the character charistics for the current insert point.
  514.  *
  515.  *  the mask contains the bits to set
  516.  *      values contains the values to set them to
  517.  *
  518.  *  for example if you wanted to just change the font size to 10 and leave
  519.  *      the rest alone:
  520.  *
  521.  *      pData = EDT_NewCharacterData();
  522.  *      pData->mask = TF_FONT_SIZE
  523.  *      pData->value = TF_FONT_SIZE
  524.  *      pData->iSize = 5;
  525.  *      EDT_SetCharacterData( context ,pData );
  526.  *      EDT_FreeCharacterData(pData);
  527.  *
  528. */
  529. void EDT_SetCharacterData( MWContext *pContext, EDT_CharacterData *pData );
  530. EDT_CharacterData* EDT_NewCharacterData(void);
  531. void EDT_FreeCharacterData( EDT_CharacterData *pData );
  532.  
  533. /*
  534.  * Set character data for a given offset in the buffer.
  535. */
  536. void EDT_SetCharacterDataAtOffset( MWContext *pContext, EDT_CharacterData *pData,
  537.         ED_BufferOffset iBufOffset, int32 iLen );
  538.  
  539. /*
  540.  * Returns colors of all the different fonts.
  541.  * Must call XP_FREE( pDest ) after use.
  542. */
  543. int EDT_GetExtraColors( MWContext *pContext, LO_Color **pDest );
  544.  
  545. /*
  546.  * Selection
  547. */
  548. void EDT_StartSelection(MWContext *context, int32 x, int32 y);
  549. void EDT_ExtendSelection(MWContext *context, int32 x, int32 y);
  550. void EDT_EndSelection(MWContext *context, int32 x, int32 y);    /* cm */
  551. void EDT_ClearSelection(MWContext *context);
  552.  
  553. void EDT_SelectAll(MWContext *context);
  554. void EDT_SelectTable(MWContext *context);
  555. void EDT_SelectTableCell(MWContext *context);
  556.  
  557. XP_Block EDT_GetSelectionText(MWContext *context);
  558. XP_Bool EDT_IsSelected( MWContext *pContext );
  559. XP_Bool EDT_SelectionContainsLink( MWContext *pContext );
  560.  
  561. /* Format all text contents into tab-delimited cells,
  562. **  with CR at end of each row.
  563. ** Use result to paste into Excell spreadsheets
  564. */
  565. char *EDT_GetTabDelimitedTextFromSelectedCells( MWContext *pContext );
  566.  
  567. /* Convert Selected text into a table (put each paragraph in separate cell)
  568.  * Number of rows is automatic - creates as many as needed
  569. */
  570. void EDT_ConvertTextToTable(MWContext *pMWContext, intn iColumns);
  571.  
  572. /* Convert the table into text - unravel existing paragraphs in cells */
  573. void EDT_ConvertTableToText(MWContext *pMWContext);
  574.  
  575. /* Save the character and paragraph style of selection or at caret */
  576. void EDT_CopyStyle(MWContext *pMWContext);
  577.  
  578. /* This is TRUE after EDT_CopyStyle is called, until the next left mouse up call 
  579.  *  or user cancels with ESC key, or ??? (any suggestions?)
  580. */
  581. XP_Bool EDT_CanPasteStyle(MWContext *pMWContext);
  582.  
  583. /* Apply the style to selection or at caret. Use bApplyStyle = FALSE to cancel */
  584. void EDT_PasteStyle(MWContext *pMWContext, XP_Bool bApplyStyle);
  585.  
  586.  
  587. XP_Bool EDT_DirtyFlag( MWContext *pContext );
  588. void EDT_SetDirtyFlag( MWContext *pContext, XP_Bool bValue );
  589.  
  590. /*
  591.  * Clipboard stuff
  592. */
  593.  
  594. #define EDT_COP_OK 0
  595. #define EDT_COP_DOCUMENT_BUSY 1
  596. #define EDT_COP_SELECTION_EMPTY 2
  597. #define EDT_COP_SELECTION_CROSSES_TABLE_DATA_CELL 3
  598.  
  599. EDT_ClipboardResult EDT_InsertText( MWContext *pContext, char *pText );
  600. EDT_ClipboardResult EDT_PasteText( MWContext *pContext, char *pText );
  601. EDT_ClipboardResult EDT_PasteHTML( MWContext *pContext, char *pHtml );
  602.  
  603. /** API for pasting quoted text into the editor.
  604.  * Call EDT_PasteQuoteBegin, then call EDT_PasteQuoteINTL zero or more times,
  605.  * then call EDT_PasteQuoteEnd.
  606.  * If EDT_PasteQuoteBegin returns EDT_COP_OK then you must eventually call EDT_PasteQuoteEnd.
  607.  * If EDT_PasteQuoteBegin returns an error condition, then you must not call EDT_PasteQuoteEnd.
  608.  *
  609.  * The "quote" is something of a misnomer. The text isn't quoted. If you want it to be
  610.  * quoted, then you have to quote it yourself, before calling EDT_PasteQuoteINTL.
  611.  */
  612.  
  613. EDT_ClipboardResult EDT_PasteQuoteBegin( MWContext *pContext, XP_Bool isHTML );
  614.  
  615. /* Pass in the csid of the pasted text. The editor will transcode
  616.  * the pasted text to the document's wincsid if nescessary. */
  617. EDT_ClipboardResult EDT_PasteQuoteINTL( MWContext *pContext, char *pText, int16 csid );
  618. /* The non-INTL version is only around for backwards compatability. */
  619. EDT_ClipboardResult EDT_PasteQuote( MWContext *pContext, char *pText );
  620.  
  621. EDT_ClipboardResult EDT_PasteQuoteEnd(MWContext *pContext);
  622.  
  623. /*
  624.  * Can paste a singe or multiple HREFs.  Pointer to array of HREF pointers and
  625.  *  title pointers.
  626.  * Title pointers can be NULL
  627. */
  628. EDT_ClipboardResult EDT_PasteHREF( MWContext *pContext, char **ppHref, char **ppTitle, int iCount);
  629.  
  630. /* Depreciated */
  631. void EDT_DropHREF( MWContext *pContext, char *pHref, char* pTitle, int32 x,
  632.             int32 y );
  633.  
  634. /* Depreciated */
  635. XP_Bool EDT_CanDropHREF( MWContext *pContext, int32 x, int32 y );
  636.  
  637.  
  638. /*
  639.  * The text buffer should also be huge, it isn't
  640. */
  641. EDT_ClipboardResult EDT_CopySelection( MWContext *pContext, char** ppText,
  642.             int32* pTextLen, XP_HUGE_CHAR_PTR* ppHtml, int32* pHtmlLen);
  643.  
  644. EDT_ClipboardResult EDT_CutSelection( MWContext *pContext,
  645.         char** ppText, int32* pTextLen,
  646.         XP_HUGE_CHAR_PTR* ppHtml, int32* pHtmlLen);
  647.  
  648. /*
  649.  * Use to enable or disable the UI for cut/copy/paste.
  650.  * If bStrictChecking is true, will check for all conditions,
  651.  * Otherwise, will just check if the selection is empty.
  652.  */
  653.  
  654. EDT_ClipboardResult EDT_CanCut(MWContext *pContext, XP_Bool bStrictChecking);
  655. EDT_ClipboardResult EDT_CanCopy(MWContext *pContext, XP_Bool bStrictChecking);
  656. EDT_ClipboardResult EDT_CanPaste(MWContext *pContext, XP_Bool bStrictChecking);
  657.  
  658. /*
  659.  * returns true if we can set an HREF
  660.  */
  661. XP_Bool EDT_CanSetHREF( MWContext *pContext );
  662.  
  663. /*
  664.  * Get the current link under the cursor or inside the current selection.
  665.  */
  666. char *EDT_GetHREF( MWContext *pContext );
  667.  
  668. /*
  669.  * Get the anchor text of the current link under the cursor
  670.  */
  671. char *EDT_GetHREFText( MWContext *pContext );
  672.  
  673. /*
  674.  * Use HREF structure
  675. */
  676. EDT_HREFData *EDT_GetHREFData( MWContext *pContext );
  677. void EDT_SetHREFData( MWContext *pContext, EDT_HREFData *pData );
  678. EDT_HREFData *EDT_NewHREFData( void );
  679. EDT_HREFData *EDT_DupHREFData( EDT_HREFData *pData );
  680. void EDT_FreeHREFData(  EDT_HREFData *pData );
  681.  
  682. /*
  683.  * This routine can only be called when 'EDT_CanSetHREF()'
  684.  */
  685. void EDT_SetHREF(MWContext *pContext, char *pHREF );
  686.  
  687. /*
  688.  * Refresh the entire document.
  689. */
  690. void EDT_RefreshLayout( MWContext *pContext );
  691.  
  692. /*
  693.  * Getting and setting properties of images.  After Getting an image's properties
  694.  *  the EDT_ImageData must be freed with EDT_FreeImageData().  Routines should
  695.  *  only be called when EDT_GetCurrentElementType() returns ED_ELEMENT_IMAGE.
  696. */
  697. EDT_ImageData *EDT_GetImageData( MWContext *pContext );
  698. void EDT_SetImageData( MWContext *pContext, EDT_ImageData *pData, XP_Bool bKeepImagesWithDoc );
  699. EDT_ImageData *EDT_NewImageData(void);
  700. void EDT_FreeImageData(  EDT_ImageData *pData );
  701. void EDT_InsertImage( MWContext *pContext, EDT_ImageData *pData, XP_Bool bKeepImageWithdoc );
  702. /* Value to display if EDT_ImageData::iBorder == -1. Different depending on whether the
  703.    image has a link or not. */
  704. int32 EDT_GetDefaultBorderWidth( MWContext *pContext );
  705.  
  706. EDT_HorizRuleData *EDT_GetHorizRuleData( MWContext *pContext );
  707. void EDT_SetHorizRuleData( MWContext *pContext, EDT_HorizRuleData *pData );
  708. EDT_HorizRuleData *EDT_NewHorizRuleData( void );
  709. void EDT_FreeHorizRuleData(  EDT_HorizRuleData *pData );
  710. void EDT_InsertHorizRule( MWContext *pContext, EDT_HorizRuleData *pData );
  711.  
  712. void EDT_ToggleList( MWContext *pContext, intn iTagType); /* All-in-one-call to create numbered or unnumbered lists. */
  713. XP_Bool EDT_GetToggleListState( MWContext *pContext, intn iTagType);
  714.  
  715. EDT_ListData *EDT_GetListData( MWContext *pContext );
  716. void EDT_SetListData( MWContext *pContext, EDT_ListData *pData );
  717. void EDT_FreeListData(  EDT_ListData *pData );
  718.  
  719. void EDT_InsertBreak( MWContext *pContext, ED_BreakType eBreak );
  720.  
  721. XP_Bool EDT_IsInsertPointInTable(MWContext *pContext );
  722. XP_Bool EDT_IsInsertPointInNestedTable(MWContext *pContext );
  723. EDT_TableData* EDT_GetTableData( MWContext *pContext );
  724.  
  725. /*  If bCellParent = TRUE:
  726.  *     Get width and height table enclosing current cell, 
  727.  *     (minus border and cell spacing)
  728.  * If bCell = FALSE: 
  729.  *     Get the width/height of current page or 
  730.  *     size the parent cell if insert point is in a nested table,
  731.  */
  732. void EDT_GetTableParentSize( MWContext *pContext, XP_Bool bCell, int32 *pWidth, int32 *pHeight );
  733. void EDT_SetTableData( MWContext *pContext, EDT_TableData *pData );
  734. EDT_TableData* EDT_NewTableData( void );
  735. void EDT_FreeTableData(  EDT_TableData *pData );
  736. void EDT_InsertTable( MWContext *pContext, EDT_TableData *pData);
  737. void EDT_DeleteTable( MWContext *pContext);
  738.  
  739. XP_Bool EDT_IsInsertPointInTableCaption(MWContext *pContext );
  740. EDT_TableCaptionData* EDT_GetTableCaptionData( MWContext *pContext );
  741. void EDT_SetTableCaptionData( MWContext *pContext, EDT_TableCaptionData *pData );
  742. EDT_TableCaptionData* EDT_NewTableCaptionData( void );
  743. void EDT_FreeTableCaptionData(  EDT_TableCaptionData *pData );
  744. void EDT_InsertTableCaption( MWContext *pContext, EDT_TableCaptionData *pData);
  745. void EDT_DeleteTableCaption( MWContext *pContext);
  746.  
  747. XP_Bool EDT_IsInsertPointInTableRow(MWContext *pContext );
  748. EDT_TableRowData* EDT_GetTableRowData( MWContext *pContext );
  749. void EDT_SetTableRowData( MWContext *pContext, EDT_TableRowData *pData );
  750. EDT_TableRowData* EDT_NewTableRowData(void);
  751. void EDT_FreeTableRowData(  EDT_TableRowData *pData );
  752. void EDT_InsertTableRows( MWContext *pContext, EDT_TableRowData *pData, XP_Bool bAfterCurrentRow, intn number);
  753. void EDT_DeleteTableRows( MWContext *pContext, intn number);
  754.  
  755. XP_Bool EDT_IsInsertPointInTableCell(MWContext *pContext );
  756. EDT_TableCellData* EDT_GetTableCellData( MWContext *pContext );
  757.  
  758. /* Change the table selection and/or move to previous/next cell, row, or column
  759.  *   depending on iMoveType. 
  760.  * To just change the selection, set the iHitType to new type 
  761.  *  (ED_HIT_SEL_ROW,  ED_HIT_SEL_COL, or ED_HIT_SEL_CELL) and set iMoveType to ED_MOVE_NONE
  762.  * To change to another row, col, or cell, set iHitType to same as that in pData or ED_HIT_NONE,
  763.  *  and set iMoveType to ED_MOVE_PREV or ED_MOVE_NEXT
  764.  * If pData is not NULL, it is filled with data for the selected cells
  765.  * This will wrap around appropriately when end of selection or table is reached
  766. */
  767. void EDT_ChangeTableSelection(MWContext *pContext, ED_HitType iHitType, ED_MoveSelType iMoveType, EDT_TableCellData *pData);
  768.  
  769. void EDT_SetTableCellData( MWContext *pContext, EDT_TableCellData *pData );
  770. EDT_TableCellData* EDT_NewTableCellData( void );
  771.  
  772. void EDT_FreeTableCellData(  EDT_TableCellData *pData );
  773. void EDT_InsertTableCells( MWContext *pContext, EDT_TableCellData *pData, XP_Bool bAfterCurrentCell, intn number);
  774. void EDT_DeleteTableCells( MWContext *pContext, intn number);
  775. void EDT_InsertTableColumns( MWContext *pContext, EDT_TableCellData *pData, XP_Bool bAfterCurrentCell, intn number);
  776. void EDT_DeleteTableColumns( MWContext *pContext, intn number);
  777.  
  778. XP_Bool EDT_IsInsertPointInLayer(MWContext *pContext );
  779. EDT_LayerData* EDT_GetLayerData( MWContext *pContext );
  780. void EDT_SetLayerData( MWContext *pContext, EDT_LayerData *pData );
  781. EDT_LayerData* EDT_NewLayerData(void);
  782. void EDT_FreeLayerData(  EDT_LayerData *pData );
  783. void EDT_InsertLayer( MWContext *pContext, EDT_LayerData *pData);
  784. void EDT_DeleteLayer( MWContext *pContext);
  785.  
  786. EDT_PageData *EDT_GetPageData( MWContext *pContext );
  787. EDT_PageData *EDT_NewPageData(void);
  788. void EDT_SetPageData( MWContext *pContext, EDT_PageData *pData );
  789. void EDT_FreePageData(  EDT_PageData *pData );
  790.  
  791. /* Use to enable/disable Merge Cells feature. 
  792.  * Selected cells can be merged only if in a continuous set
  793.  * within the same row or column.
  794.  * A single cell can be merged with cell to the right
  795.  * Returns 0 if neither conditions holds
  796. */
  797. ED_MergeType EDT_GetMergeTableCellsType( MWContext *pContext );
  798.  
  799. /* Use to enable/disable Split Cell feature. 
  800.  * Current cell (containing caret) can be split 
  801.  * only if it has COLSPAN or ROWSPAN
  802. */
  803. XP_Bool EDT_CanSplitTableCell( MWContext *pContext );
  804.  
  805. /* Set appropriate COLSPAN or ROWSPAN and move all
  806.  * cell contents into first cell of set
  807.  */
  808. void EDT_MergeTableCells( MWContext *pContext );
  809.  
  810. /* Separate paragraphs into sepaparate cells,
  811.  * removing COLSPAN or ROWSPAN
  812. */
  813. void EDT_SplitTableCell( MWContext *pContext );
  814.  
  815. /* Take a single, selected image and turn it into the
  816.  *  background image of page, deleting it from the page
  817.  */
  818. void EDT_SetImageAsBackground( MWContext *pContext );
  819.  
  820. /* Get and Set MetaData.
  821.  *  Get the count of meta data objects.
  822.  *  enumerate through them (0 based).
  823.  *  If the name changes, a new meta data is created or may overwrite a different
  824.  *     name value pair.
  825.  */
  826. intn EDT_MetaDataCount( MWContext *pContext );
  827. EDT_MetaData* EDT_GetMetaData( MWContext *pContext, intn n );
  828. EDT_MetaData* EDT_NewMetaData( void );
  829. void EDT_SetMetaData( MWContext *pContext, EDT_MetaData *pMetaData );
  830. void EDT_DeleteMetaData( MWContext *pContext, EDT_MetaData *pMetaData );
  831. void EDT_FreeMetaData( EDT_MetaData *pMetaData );
  832.  
  833. /*******************************************************
  834.  * CLM: JAVA, PLUG-IN interface
  835. */
  836.  
  837. EDT_JavaData *EDT_GetJavaData( MWContext *pContext );
  838. EDT_JavaData *EDT_NewJavaData(void);
  839. void EDT_SetJavaData( MWContext *pContext, EDT_JavaData *pData );
  840. void EDT_FreeJavaData(  EDT_JavaData *pData );
  841.  
  842. EDT_PlugInData *EDT_GetPlugInData( MWContext *pContext );
  843. EDT_PlugInData *EDT_NewPlugInData(void);
  844. void EDT_SetPlugInData( MWContext *pContext, EDT_PlugInData *pData );
  845. void EDT_FreePlugInData(  EDT_PlugInData *pData );
  846.  
  847. /* Parameters: NAME=VALUE pairs used by both Java and PlugIns */
  848. EDT_ParamData* EDT_GetParamData( MWContext *pContext, intn n );
  849. EDT_ParamData* EDT_NewParamData(void);
  850. void EDT_SetParamData( MWContext *pContext, EDT_ParamData *pParamData );
  851. void EDT_DeleteParamData( MWContext *pContext, EDT_ParamData *pParamData );
  852. void EDT_FreeParamData( EDT_ParamData *pParamData );
  853.  
  854. /*
  855.  * Get and Set Named Anchors (Targets)
  856. */
  857. char *EDT_GetTargetData( MWContext *pContext );
  858. void EDT_SetTargetData( MWContext *pContext, char *pTargetName );
  859. void EDT_InsertTarget( MWContext *pContext, char* pTargetName );
  860. char *EDT_GetAllDocumentTargets( MWContext *pContext );
  861.  
  862. /*CLM: Check current file-update time and
  863.  *     return TRUE if it is different
  864.  *     Save the newly-found time in edit buffer class
  865. */
  866. XP_Bool EDT_IsFileModified( MWContext* pContext );
  867.  
  868. /* CLM: Read a file and build a targets list just like the current doc list */
  869. char *EDT_GetAllDocumentTargetsInFile( MWContext *pContext, char *pHref);
  870.  
  871. /*
  872.  * Returns a list of all local documents associated with
  873.  *  the current buffer.
  874. */
  875. char* EDT_GetAllDocumentFiles( MWContext *pContext );
  876. /*
  877.  * Also sets ppSelected to be a list of whether each local document should be 
  878.  * saved/published/sent by default.  Must pass in the preference for whether images
  879.  * are sent along with the document. 
  880.  */
  881. char* EDT_GetAllDocumentFilesSelected( MWContext *pContext, XP_Bool **ppSelected, 
  882.       XP_Bool bKeepImagesWithDoc );
  883.  
  884. /*
  885.  * Get and Set UnknownTags
  886. */
  887. char *EDT_GetUnknownTagData( MWContext *pContext );
  888. void EDT_SetUnknownTagData( MWContext *pContext, char *pUnknownTagData );
  889. void EDT_InsertUnknownTag( MWContext *pContext, char* pUnknownTagData );
  890. /* CLM: Validate: check for matching quotes, "<" and ">" if bNoBrackets is FALSE
  891.  *      Skip (and strip out) <> if bNoBrackets is TRUE,
  892.  *      used for Attributes-only, such as MOCHA string in HREF
  893. */
  894. ED_TagValidateResult EDT_ValidateTag( char *pData, XP_Bool bNoBrackets );
  895.  
  896. /*
  897.  * Called by the front end when the user presses the cancel button on the
  898.  *  Modal dialog
  899. */
  900. void EDT_ImageLoadCancel( MWContext *pContext );
  901.  
  902. /*****************************************************************************
  903.  * Property Dialogs
  904.  *****************************************************************************/
  905.  
  906. #if 0
  907. /*
  908.  * String allocation functions for parameters passed to EDT_Property functions
  909. */
  910. char *EDT_StringDup(char *pDupString);
  911. void EDT_StringFree(char* pString);
  912.  
  913.  
  914. void EDT_GetPageProperties( ED_PageProperties *pProps );
  915. void EDT_SetPageProperties( ED_PageProperties *pProps );
  916.  
  917. void EDT_GetParagraphProperties( ED_ParagraphProperties *pProps );
  918. void EDT_SetParagraphProperties( ED_ParagraphProperties *pProps );
  919.  
  920. #endif
  921.  
  922. /*****************************************************************************
  923.  * Utility stuff.
  924.  *****************************************************************************/
  925.  
  926. /* for debug purposes. */
  927. char *EDT_TagString(int32 tagType);
  928.  
  929. #ifdef DEBUG
  930. void EDT_VerifyLayoutElement( MWContext *pContext, LO_Element *pLoElement,
  931.         XP_Bool bPrint );
  932. #endif
  933.  
  934. /* Cross platform macros */
  935. /* we may changed how we define editor status */
  936. #define EDT_IS_NEW_DOCUMENT(context) (context != NULL && context->is_editor && context->is_new_document)
  937. #define EDT_NEW_DOCUMENT(context,b)  if(context != NULL) context->is_new_document=(context->is_editor&&b)
  938.  
  939. /* Helper to gray UI items not allowed when inside Java Script
  940.  * Note that the return value is TRUE if mixed selection,
  941.  *   allowing the non-script text to be changed.
  942.  * Current Font Size, Color, and Character attributes will suppress
  943.  *   setting other attributes, so it is OK to call these when mixed
  944. */
  945. XP_Bool EDT_IsJavaScript(MWContext *pContext);
  946.  
  947. /* Helper to use for enabling Character properties
  948.  * (Bold, Italic, etc., but DONT use for clearing (TF_NONE)
  949.  *  or setting Java Script (Server or Client)
  950.  * Tests for:
  951.  *   1. Good edit buffer and not blocked because of some action,
  952.  *   2. Caret or selection is NOT entirely within Java Script,
  953.  *   3. Caret or selection has some text or is mixed selection
  954.  *      (thus FALSE if single non-text object is selected)
  955. */
  956. XP_Bool EDT_CanSetCharacterAttribute(MWContext *pContext);
  957.  
  958. /* Replace the current selection with supplied text */
  959. /* if bReplaceAll is true then pTextToLookFor and the 3 subsequent Boolean need to be set */
  960. void EDT_ReplaceText(MWContext *pContext, char * pReplaceText, XP_Bool bReplaceAll,
  961.                     char *pTextToLookFor, XP_Bool bCaseless, XP_Bool bBackward, XP_Bool bDoWrap);
  962.  
  963. #ifdef FIND_REPLACE
  964. /* Currently (12/3/97) not used */
  965. XP_Bool EDT_FindAndReplace(MWContext *pContext, EDT_FindAndReplaceData *pData );
  966.  
  967. #endif
  968. /* Dynamic Object Sizing
  969.  * Note:xVal and yVal for all functions are in Document coordinates
  970.  * After calling EDT_StartSizing, either EDT_EndSizing or EDT_CancelSizing
  971.  *  must be called.
  972. */
  973.  
  974. /* How close cursor must be to border to start sizing  */
  975. #define ED_SIZING_BORDER 6
  976.  
  977. /* Get the sizing, selection, or add row/column type define (0 if not at a hit region)
  978.  *  where xVal, yVal is Cursor position we are over 
  979.  * This ignores anything inside of tables or cells, so don't call it
  980.  *   if you want to size an image contained within a cell (use EDT_CanSizeObject instead)
  981.  * ppElement is optional: If supplied, the relevant table or cell element is returned
  982.  *   (a cell ptr is returned for the row/col operations - use this to get col. or row members)
  983.  * bModifierKeyPressed is applicable if selecting table (upper left corner)
  984.  *    or extending selection to multiple cells
  985.  * If TRUE (Ctrl key is pressed in Windows), returns 
  986.  *    ED_HIT_SEL_ALL_CELLS instead of ED_HIT_SEL_TABLE
  987. */
  988. ED_HitType EDT_GetTableHitRegion(MWContext *pContext, int32 xVal, int32 yVal, 
  989.                                  LO_Element **ppElement, XP_Bool bModifierKeyPressed);
  990.  
  991. /* Wrapper for ease of use -- gets last-selected table object's hit type and element */
  992. ED_HitType EDT_GetSelectedTableElement(MWContext *pContext, LO_Element **ppElement);
  993.  
  994. /* Select a Table, Row, Column, or Cell 
  995.  * iHitType is a define returned by EDT_GetTableHitRegion()
  996.  * Returns TRUE if selection was done - it will fail if
  997.  *   missing pointers or iHitType doesn't match pLoElement type or 
  998.  *   is not an allowable type for doing selection.
  999.  * Selection rules:
  1000.  *   Table:  Any corner is OK (ED_HIT_SEL_TABLE, ED_HIT_SIZE_TABLE, ED_HIT_ADD_ROWS, or ED_HIT_ADD_COLS)
  1001.  *   Column: Top of table above desired column (ED_HIT_SEL_COL)
  1002.  *   Row:    Left edge of table next to desired row (ED_HIT_SEL_ROW)
  1003.  *   Cell:   Left or top edge of cell, including upper right corner (ED_HIT_SEL_CELL)
  1004.  *  
  1005.  *   x and y values are used only when selecting rows or columns
  1006.  *
  1007.  *   if pLoElement == NULL, we find it from current edit element
  1008.  *     (use it this way to select items from a menu when caret is inside a table)
  1009.  *
  1010.  *   If bAppendSelection is TRUE, new cells will be added to current selection
  1011.  *    (ignored if selecting a table - all cell selection is cleared for that)
  1012.  *
  1013.  *   If bExtendSelection is TRUE (Shift key is pressed),
  1014.  *    select all cells withing smallest rect from first-selected to supplied cell
  1015. */
  1016. XP_Bool EDT_SelectTableElement(MWContext *pMWContext, int32 x, int32 y,
  1017.                                LO_Element *pLoElement, 
  1018.                                ED_HitType iHitType, 
  1019.                                XP_Bool bModifierKeyPressed, XP_Bool bExtendSelection);
  1020.  
  1021. /* Called on mouse-move message after selection was started
  1022.  * on a row, column, or cell element
  1023.  * Returns the hit type: ED_HIT_SEL_ROW, ED_HIT_SEL_COL, ED_HIT_SEL_CELL, or ED_HIT_NONE
  1024.  *   reflecting what type of block we are extended,
  1025.  *     or ED_HIT_NONE if mouse is outside of the table
  1026.  *   Use this to set the type of cursor by the FEs
  1027. */
  1028. ED_HitType EDT_ExtendTableCellSelection(MWContext *pMWContext,  int32 x, int32 y);
  1029.  
  1030. /* Clear the all selected table or cells */
  1031. void EDT_ClearTableAndCellSelection(MWContext *pMWContext);
  1032.  
  1033. XP_Bool EDT_IsTableSelected(MWContext *pMWContext);
  1034. int     EDT_GetSelectedCellCount(MWContext *pMWContext);
  1035.  
  1036. /* Clear any existing cells selected if current edit element is not inside selection
  1037.  * Call before poping up context menu inside table
  1038. */
  1039. void EDT_ClearCellSelectionIfNotInside(MWContext *pMWContext);
  1040.  
  1041. /* Call just before bringing up the Table Properties dialog 
  1042.  * Supply cell data struct so the iSelectionType and iSelectedCount are filled-in
  1043. */
  1044. void EDT_StartSpecialCellSelection(MWContext *pMWContext, EDT_TableCellData *pCellData);
  1045. /* Call after closing the Table Properties dialog */
  1046. void EDT_ClearSpecialCellSelection(MWContext *pMWContext);
  1047.  
  1048. /* Called from lo_EndTable (laytable.c) to build list of tables being redrawn */
  1049. void EDT_AddToRelayoutTables(MWContext *pMWContext, LO_TableStruct *pLoTable );
  1050.  
  1051. /* Called after every table layout so editor size data is accurate */
  1052. void EDT_FixupTableData(MWContext *pMWContext);
  1053.  
  1054. /* Get the sizing type define (0 if not at a sizing location)
  1055.  *  where xVal, yVal is Cursor position and pElement is the element
  1056.  *  we are over -- if NULL, we will find it (param used for efficiency)
  1057. */
  1058. ED_SizeStyle EDT_CanSizeObject(MWContext *pContext, LO_Element *pLoElement, int32 xVal, int32 yVal);
  1059.  
  1060. /* Return TRUE if we are currently sizing
  1061. */
  1062. XP_Bool EDT_IsSizing(MWContext *pContext);
  1063.  
  1064. /*  If bLockAspect is TRUE, constrain rect to keep original aspect ratio
  1065.  *  This returns the rect to draw sizing feedback in View's coordinate system
  1066.  *  Returns sizing style if sizing was started OK
  1067. */
  1068. ED_SizeStyle EDT_StartSizing(MWContext *pContext, LO_Element *pLoElement, int32 xVal, int32 yVal,
  1069.                              XP_Bool bLockAspect, XP_Rect *pRect);
  1070.  
  1071. /* Get the rect in View coordinates, so you can use it
  1072.  * directly for drawing "selection feedback"
  1073.  * Returns TRUE if this rect is different from the last
  1074.  *  one calculated by EDT_StartSizing or EDT_GetSizingRect,
  1075.  *  so you need to do sizing feedback only if we return TRUE;
  1076. */
  1077. XP_Bool EDT_GetSizingRect(MWContext *pContext, int32 xVal, int32 yVal,
  1078.                           XP_Bool bLockAspect, XP_Rect *pRect);
  1079.  
  1080. /* Uses rect (xVal and yVal) from last mouse move to
  1081.  * get new width and height and change current object size
  1082. */
  1083. void EDT_EndSizing(MWContext *pContext);
  1084.  
  1085. /* Call this to abort sizing
  1086. */
  1087. void EDT_CancelSizing(MWContext *pContext);
  1088.  
  1089. /*
  1090.  * Editor plugin interface
  1091.  * The strings returned by this interface are from the Java heap. This means that
  1092.  * they will automaticly be garbage collected once there is no thread that
  1093.  * is refering to them. So XP_STRDUP them if you want to hold onto them.
  1094.  */
  1095. void EDT_RegisterPlugin(char* csFileSpec); /* Called by front end to register a plugin file. */
  1096.  
  1097. /* The following calls are cheap enough to be called as often as you like. */
  1098. int32 EDT_NumberOfPluginCategories(void);
  1099. int32 EDT_NumberOfPlugins(int32 category);
  1100.  
  1101. /* The result strings are garbage collected by the Java runtime. They are in UTF8 encoding. */
  1102. char* EDT_GetPluginCategoryName(int32 category);
  1103. char* EDT_GetPluginName(int32 category, int32 index);
  1104. char* EDT_GetPluginMenuHelp(int32 category, int32 index);
  1105.  
  1106. /*
  1107.  * Perform a Composer Plugin by category and index. Returns TRUE if the Plug-in was launched
  1108.  * successfully. Returns FALSE if the Plug-in failed to run. If this method returns true, then
  1109.  * the actual Plug-in runs asynchronously. When the plugin completes, doneFunction is called
  1110.  * in the main UI thread. Alternatively, you can poll EDT_IsPluginActive to find out when the
  1111.  * Plug-in is done.
  1112.  * If you don't want to be called back when the plugin completes, pass NULL for doneFunction.
  1113.  * "hook" is a variable for you to use any way you want. It is passed back to your doneFunction.
  1114.  */
  1115.  
  1116. XP_Bool EDT_PerformPlugin(MWContext *pContext, int32 category, int32 index, EDT_ImageEncoderCallbackFn doneFunction, void* hook);
  1117.  
  1118. /*
  1119.  * Just like EDT_PerformPlugin, except that the Plugin is identified by className rather than by
  1120.  * category and index. The className is a fully qualified Java class name in UTF8 encoding.
  1121.  * doneFunction can be NULL, in which case it won't be called.
  1122.  * Under some circumstances, the doneFunction may be called immediately.
  1123.  */
  1124.  
  1125. XP_Bool EDT_PerformPluginByClassName(MWContext *pContext, char* className, EDT_ImageEncoderCallbackFn doneFunction, void* hook);
  1126.  
  1127. /*
  1128.  * Just like EDT_PerformPlugin, except that all event handlers are called for
  1129.  * a particular event.
  1130.  * doneFunction can be NULL, in which case it won't be called.
  1131.  * Under some circumstances, the doneFunction may be called immediately.
  1132.  * pDocURL can be null, or empty
  1133.  */
  1134.  
  1135. void EDT_PerformEvent(MWContext *pContext, char* pEvent, char* pDocURL, XP_Bool bCanChangeDocument, XP_Bool bCanCancel,
  1136.                       EDT_ImageEncoderCallbackFn doneFunction, void* hook);
  1137.  
  1138. XP_Bool EDT_IsPluginActive(MWContext* pContext);
  1139. void EDT_StopPlugin(MWContext* pContext);
  1140.  
  1141. /* Used internally by the Composer Plug-in implementation.
  1142.  */
  1143. void EDT_ComposerPluginCallback(MWContext* pContext, int32 action,
  1144.     struct java_lang_Object* pArg);
  1145.  
  1146. /* Image encoder interface.
  1147.  * The strings returned by this interface are from the Java heap. This means that
  1148.  * they will automaticly be garbage collected once there is no thread that
  1149.  * is refering to them. So XP_STRDUP them if you want to hold onto them.
  1150.  */
  1151. int32 EDT_NumberOfEncoders(void);
  1152. char* EDT_GetEncoderName(int32 index); /* The human name of the encoding. e.g. JPEG */
  1153. char* EDT_GetEncoderFileExtension(int32 index); /* The file extension, without the period. e.g. jpg */
  1154. char* EDT_GetEncoderFileType(int32 index); /* The Macintosh FileType field. An array of 4 characters. */
  1155. char* EDT_GetEncoderMenuHelp(int32 index);  /* A sentence describing the encoding. e.g. Joint Picture Encoding Group */
  1156. XP_Bool EDT_GetEncoderNeedsQuantizedSource(int32 index); /* TRUE if the encoder needs 256 distinct colors or less. */
  1157. /* Returns FALSE if there was a problem, or TRUE if the encoder was started successfully.
  1158.  * The pixels are copied -- you can dispose of the pixels as soon as EDT_StartEncoder returns.
  1159.  *
  1160.  */
  1161. XP_Bool EDT_StartEncoder(MWContext* pContext, int32 index, int32 width, int32 height, char** pixels,
  1162.     char* csFileName, EDT_ImageEncoderCallbackFn doneFunction, void* hook);
  1163.  
  1164. /* Will stop the encoder, and will cause the doneFunction to be called. */
  1165. void EDT_StopEncoder(MWContext* pContext);
  1166.  
  1167. /* Save and restore the cursor position or selection
  1168. */
  1169. ED_BufferOffset EDT_GetInsertPointOffset( MWContext *pContext );
  1170. void EDT_SetInsertPointToOffset( MWContext *pContext, ED_BufferOffset i,
  1171.             int32 iLen );
  1172.  
  1173. /* Given a character offset, return the layout element and offset for that character
  1174.  */
  1175.  
  1176. void EDT_OffsetToLayoutElement( MWContext *pContext, ED_BufferOffset i,
  1177.         LO_Element * *element, int32 *caretPos);
  1178. ED_BufferOffset EDT_LayoutElementToOffset( MWContext *pContext,
  1179.         LO_Element *element, int32 caretPos);
  1180.  
  1181. /* Return the layout textblock for a text element
  1182.  */
  1183. LO_TextBlock* EDT_GetTextBlock(MWContext *pContext, LO_Element *le);
  1184.  
  1185. /* Spell check API
  1186. */
  1187. XP_Bool EDT_SelectFirstMisspelledWord( MWContext *pContext );
  1188. XP_Bool EDT_SelectNextMisspelledWord( MWContext *pContext );
  1189. XP_HUGE_CHAR_PTR EDT_GetPositionalText( MWContext* pContext );
  1190. void EDT_SetRefresh( MWContext *pContext, XP_Bool bRefreshOn );
  1191. void EDT_ReplaceMisspelledWord( MWContext *pContext, char* pOldWord, 
  1192.         char*pNewWord, XP_Bool bAll );
  1193. /* Ignore a misspelled word. 
  1194.  * If pWord != NULL and bAll == TRUE. ignore all instances of the specified word
  1195.  * If pWord == NULL, ignore all misspelled words 
  1196.  */
  1197. void EDT_IgnoreMisspelledWord( MWContext *pContext, char* pWord, 
  1198.         XP_Bool bAll );
  1199.  
  1200. /* The selection is 1/2 open -- if the start and end are the same value, then
  1201.  * the selection is an insertion point.
  1202.  */
  1203. void EDT_GetSelectionOffsets(MWContext *pContext, ED_BufferOffset* pStart, ED_BufferOffset* pEnd);
  1204.  
  1205. /*
  1206.  * Set the document encoding. Returns TRUE if the encoding
  1207.  * was changed, or FALSE if it was not. (An encoding change
  1208.  * may require a save of the current document. The user may
  1209.  * cancel the save.)
  1210.  *
  1211.  */
  1212.  
  1213. XP_Bool EDT_SetEncoding(MWContext* pContext, int16 csid);
  1214.  
  1215. /* Take the document for current contextand change appropriate
  1216.  *   params to make it look like a "Untitled" new document
  1217.  * Allows loading any document as a "Template"
  1218.  */
  1219. void EDT_ConvertCurrentDocToNewDoc(MWContext * pMWContext);
  1220.  
  1221. /* Assemble the filename part from supplied URL to
  1222.  * the base URL, replacing any filename in the latter
  1223.  * pURL can be most anything, full URL or local filename
  1224.  * If NULL, pBaseURL is returned without its filename
  1225.  *   (Use this to strip off filename from a base URL);
  1226.  * Caller must free returned string
  1227.  */
  1228. char * EDT_ReplaceFilename(char * pBaseURL, char * pURL, XP_Bool bMustHaveExtension);
  1229.  
  1230. /* Simply returns the filename part of a URL or local filespec
  1231.  * Stuff starting with "#" or "?" is ommited
  1232.  * Used with EDT_ReplaceFilenam(pURL, NULL) parse out a URL
  1233.  *   into separate "directory" and "filename" parts
  1234.  * If bMustHaveExtension is TRUE, then name after last "/" or "\"
  1235.  *   must have a period indicating it has an extension
  1236.  * Note: Assumes bMustHaveExtension = TRUE when getting filename
  1237.  * Caller must free returned string
  1238.  */
  1239. char * EDT_GetFilename(char * pURL, XP_Bool bMustHaveExtension);
  1240.  
  1241.  
  1242. /* Return a destination URL for publishing:
  1243.  * If last-failed-published URL (saved globally) is same as URL about to be published,
  1244.  *    then always returns the location, Username, and password last attempted,
  1245.  *    obtained from prefs: "editor.publish_last_loc" and "editor.publish_last_password"
  1246.  * else: 
  1247.  * If current page URL is
  1248.  * 1. Remote URL: Return current page name as is, with anything after filename stripped
  1249.  * 2. Local File: Return last-good location (from pref: "editor.publish_history_0")
  1250.  *                or default (if no last-location) from "editor.publish_location"
  1251.  *                *ppFilename is set to filename portion of current page
  1252.  *                and UserName is parsed out the pref string and returned in ppUsername
  1253.  * 3. New (unsaved) page: Return pref URL as above, but *ppFilename is set to NULL
  1254.  *
  1255.  * Note: Assumes bMustHaveExtension = TRUE when getting filename
  1256.  * If available, the last-used password is also supplied
  1257.  * Caller must free returned strings
  1258.  */
  1259. char * EDT_GetDefaultPublishURL(MWContext * pMWContext, char **ppFilename, char **ppUserName, char **ppPassword);
  1260.  
  1261. /* The maximum number of history items shown */
  1262. #define MAX_EDIT_HISTORY_LOCATIONS 10 
  1263.  
  1264. /*
  1265.  *    Get the location, username, and password (plain text) for the Nth
  1266.  *    publish history location. Caller must XP_FREE the returned location,
  1267.  *    username, passwd.
  1268.  */
  1269. XP_Bool EDT_GetPublishingHistory(unsigned n, char** loc, char** u, char** p);
  1270.  
  1271. /*
  1272.  *    Copy the last publish location to the 0th history, move everyone up one.
  1273.  */
  1274. void   EDT_SyncPublishingHistory(void);
  1275.  
  1276. /* Get URL and TITLE from the recently-edited history list kept in preferences
  1277.  * Similar to Publish history list, except caller should NOT XP_FREE the returned strings
  1278.  *   because they are cached in local string arrays for quicker access
  1279.  *
  1280.  * Supply MWContext pointer to check if the current document is
  1281.  *   in the list before or at the requested URL.
  1282.  *   If it is, the next item is returned instead, thus the current doc
  1283.  *     never shows up in the list
  1284.  *     Because of this behavior, this function should be used with MWContext*
  1285.  *        both to build the menu items and also to get the URL when the menu item is executed
  1286.  *
  1287.  * Note: If there is no Title, *pTitle is set to NULL
  1288.  * (Front ends should use a compressed version of pUrl instead)
  1289. */
  1290. XP_Bool EDT_GetEditHistory(MWContext * pMWContext, unsigned n, char** pUrl, char** pTitle);
  1291.  
  1292. /* Call this after opening a file or URL to make it
  1293.  *   the most-recently-edited document in the URL history in preferences
  1294.  */
  1295. void EDT_SyncEditHistory(MWContext * pMWContext);
  1296.  
  1297. /* Construct a page title from supplied filename,
  1298.  * Extracts the filename part WITHOUT extension
  1299.  * Stuff starting with "#" or "?" is ommited
  1300.  * Caller must free returned string
  1301.  */
  1302. char * EDT_GetPageTitleFromFilename(char * pFilename);
  1303.  
  1304. /*
  1305.  * Call EDT_PreOpen when the user requests that you open an existing HTML document.
  1306.  * You will get called back with status that indicates whether or not to open the
  1307.  * document. You can pass anything you want as the hook argument -- it will be
  1308.  * passed back to you.
  1309.  * 
  1310.  * The MWContext passed to EDT_PreOpen is only used for reporting errors.
  1311.  *
  1312.  * Use the pURL that's passed back to you as the URL to open -- it may be different
  1313.  * than the URL you passed in.
  1314.  *
  1315.  * Note: Unlike other similar calls, in EDT_PreOpen the doneFunction will always be
  1316.  * called. Under certain circumstances, however, the doneFunction will be called
  1317.  * immediately, before EDT_PreOpen even returns.
  1318.  *
  1319.  */
  1320.  
  1321. typedef void (*EDT_PreOpenCallbackFn)(XP_Bool bUserCancled, char* pURL, void* hook);
  1322. void EDT_PreOpen(MWContext *pErrorContext,char* pURL, EDT_PreOpenCallbackFn doneFunction, void* hook);
  1323.  
  1324. /*
  1325.  * Call EDT_PreClose when an editor context is about to be closed.  Don't actually 
  1326.  * close the window until the passed in callback function is called.
  1327.  *
  1328.  * Similar to EDT_PreOpen, the doneFunction will always be called, and may be called
  1329.  * befre EDT_PreClose returns.
  1330.  *
  1331.  */
  1332.  
  1333. typedef void (*EDT_PreCloseCallbackFn)(void* hook);
  1334. void EDT_PreClose(MWContext * pMWContext,char* pURL, EDT_PreCloseCallbackFn doneFunction, void* hook);
  1335.  
  1336. /*
  1337.  * True if both urls are the same, ignores any username/password
  1338.  * information.  Does caseless comparison for file:// URLs 
  1339.  * on windows and mac.
  1340.  * url1 and url2 are relative to base1 and base2, respectively.
  1341.  * If url1 or url2 is already absolute, base1 or base2 can 
  1342.  * be passed in as NULL.
  1343.  */
  1344. XP_Bool EDT_IsSameURL(char *url1,char *url2,char *base1,char *base2);
  1345.  
  1346. /*
  1347.  * Extract the Extra HTML string from the ED_Element pointer in an image struct
  1348.  * (ED_Element is a void* to external users
  1349.  * Implemented in edtutil.cpp
  1350.  * Caller must XP_FREE result
  1351.  */
  1352. char * EDT_GetExtraHTML_FromImage(LO_ImageStruct *pImage);
  1353.  
  1354. XP_Bool EDT_IsWritableBuffer(MWContext *pContext);
  1355.  
  1356. /*
  1357.  * Hack in pre-encrypted files into the editor. This function lets us
  1358.  * treat the editor's TapeFS as a net stream without all the baggage associated
  1359.  * with the regular edt_Stream functions.
  1360.  */
  1361. NET_StreamClass *EDT_NetToTape(void *);
  1362.  
  1363. /*
  1364.  * Several functions to handle the encrypt/no-encrypt flag
  1365.  */
  1366. void EDT_EncryptToggle(MWContext *pContext);
  1367. void EDT_EncryptSet(MWContext *pContext);
  1368. void EDT_EncryptReset(MWContext *pContext);
  1369. PRBool EDT_EncryptState(MWContext *pContext);
  1370.  
  1371. /* Used for QA only - Ctrl+Alt+Shift+N accelerator for automated testing */
  1372. void EDT_SelectNextNonTextObject(MWContext *pContext);
  1373.  
  1374. XP_END_PROTOS
  1375.  
  1376. #endif  /* EDITOR   */
  1377. #endif  /* _edt_h_  */
  1378.  
  1379.