зеркало из https://github.com/mozilla/pjs.git
Fixed table editing bugs. Ctrl key now needed to size table with mouse
This commit is contained in:
Родитель
5aff25e99d
Коммит
cdc430043f
|
@ -2988,10 +2988,10 @@ public:
|
|||
LO_Element *pLoElement,
|
||||
int iSizingStyle,
|
||||
int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect);
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect);
|
||||
|
||||
|
||||
XP_Bool GetSizingRect(int32 xVal, int32 yVal, XP_Bool bLockAspect, XP_Rect *pRect);
|
||||
XP_Bool GetSizingRect(int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed, XP_Rect *pRect);
|
||||
void ResizeObject();
|
||||
void EraseAddRowsOrCols();
|
||||
|
||||
|
@ -3499,7 +3499,7 @@ public:
|
|||
void PrintMetaData( CPrintState *pPrintState );
|
||||
void PrintMetaData( CPrintState *pPrintState, int index );
|
||||
// Return FALSE only if we are closing down
|
||||
XP_Bool CheckCharset( EDT_MetaData *pData,int16 win_csid );
|
||||
XP_Bool CheckCharset( PA_Tag *pTag, EDT_MetaData *pData,int16 win_csid );
|
||||
|
||||
EDT_HorizRuleData* GetHorizRuleData();
|
||||
void SetHorizRuleData( EDT_HorizRuleData* pData );
|
||||
|
@ -3832,7 +3832,8 @@ public:
|
|||
// If TRUE, returns ED_HIT_SEL_ALL_CELLS instead of ED_HIT_SEL_TABLE
|
||||
ED_HitType GetTableHitRegion(int32 xVal, int32 yVal, LO_Element **ppElement, XP_Bool bModifierKeyPressed = FALSE);
|
||||
|
||||
// Tells us where to insert or replace cell (cell we are over is in *ppElement)
|
||||
// Tells us where to insert or replace cell
|
||||
// (LO_Cell we are over is returned in *ppElement)
|
||||
ED_DropType GetTableDropRegion(int32 *pX, int32 *pY, int32 *pWidth, int32 *pHeight, LO_Element **ppElement);
|
||||
|
||||
// Used within editor - use supplied cell's X and Y and get LO_CellStruct from it
|
||||
|
@ -3965,9 +3966,9 @@ public:
|
|||
|
||||
// Dynamic object sizing interface
|
||||
XP_Bool IsSizing() { return (m_pSizingObject != 0); }
|
||||
ED_SizeStyle CanSizeObject(LO_Element *pLoElement, int32 xVal, int32 yVal);
|
||||
ED_SizeStyle StartSizing(LO_Element *pLoElement, int32 xVal, int32 yVal, XP_Bool bLockAspect, XP_Rect *pRect);
|
||||
XP_Bool GetSizingRect(int32 xVal, int32 yVal, XP_Bool bLockAspect, XP_Rect *pRect);
|
||||
ED_SizeStyle CanSizeObject(LO_Element *pLoElement, int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed = FALSE);
|
||||
ED_SizeStyle StartSizing(LO_Element *pLoElement, int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed, XP_Rect *pRect);
|
||||
XP_Bool GetSizingRect(int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed, XP_Rect *pRect);
|
||||
void EndSizing();
|
||||
void CancelSizing();
|
||||
|
||||
|
@ -3984,11 +3985,19 @@ public:
|
|||
|
||||
LO_Element* FirstElementOnLine(LO_Element* pTarget, int32* pLineNum);
|
||||
|
||||
// Return TRUE if delete the buffer by calling ChangeEncoding
|
||||
XP_Bool SetEncoding(int16 csid);
|
||||
// Change encoding and translate current doc
|
||||
void ChangeEncoding(int16 csid);
|
||||
void SetEncoding(int16 csid);
|
||||
void SetEncoding(char *pCharset);
|
||||
// Change just the metatag charset value
|
||||
void SetEncodingTag(int16 csid);
|
||||
void SetEncodingTag(char *pCharset);
|
||||
|
||||
XP_Bool HasEncoding();
|
||||
|
||||
// This signals replacing the charset string in metatag
|
||||
// after reloading URL when we are fixing a bad original charset
|
||||
int16 m_iReplaceCSID;
|
||||
|
||||
// Used for QA only - Ctrl+Alt+Shift+N accelerator for automated testing
|
||||
void SelectNextNonTextObject();
|
||||
|
|
|
@ -1593,7 +1593,8 @@ CEditBuffer::CEditBuffer(MWContext *pContext, XP_Bool bImportText):
|
|||
m_bEncrypt(PR_FALSE),
|
||||
m_pNonTextSelectedTable(0),
|
||||
m_bImportText(bImportText),
|
||||
m_bFillNewCellWithSpace(FALSE)
|
||||
m_bFillNewCellWithSpace(FALSE),
|
||||
m_iReplaceCSID(0)
|
||||
{
|
||||
INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(m_pContext);
|
||||
m_originalWinCSID = INTL_GetCSIWinCSID(c);
|
||||
|
@ -2189,6 +2190,10 @@ void CEditBuffer::Reflow( CEditElement* pStartElement,
|
|||
}
|
||||
}
|
||||
|
||||
// This avoids crashes if end element wasn't set
|
||||
if( pStartElement == m_pRoot && pEndElement == 0)
|
||||
pEndElement = m_pRoot->GetLastMostChild();
|
||||
|
||||
// Create a new cursor and reflow
|
||||
CEditTagCursor cursor(this, pEdStart, iOffset, pEndElement);
|
||||
if( pCell )
|
||||
|
@ -2417,7 +2422,7 @@ void CEditBuffer::Relayout( CEditElement* pStartElement,
|
|||
// laying out from the beginning of the document
|
||||
if( pNewStartElement == 0 ){
|
||||
if( pEndElement == 0 ){
|
||||
pEndElement = pStartElement;
|
||||
pEndElement = pStartElement;
|
||||
}
|
||||
iLineNum = 0;
|
||||
pEdStart = m_pRoot;
|
||||
|
@ -2447,7 +2452,9 @@ void CEditBuffer::Relayout( CEditElement* pStartElement,
|
|||
pEdStart = pLoStartLine->lo_any.edit_element;
|
||||
iOffset = pLoStartLine->lo_any.edit_offset;
|
||||
}
|
||||
|
||||
// This avoids crashes if end element wasn't set
|
||||
if( pStartElement == m_pRoot && pEndElement == 0)
|
||||
pEndElement = m_pRoot->GetLastMostChild();
|
||||
|
||||
// Create a new cursor.
|
||||
CEditTagCursor cursor(this, pEdStart, iOffset, pEndElement);
|
||||
|
@ -2721,13 +2728,11 @@ void CEditBuffer::ResizeTableCell(CEditTableElement *pTable, XP_Bool bChangeWid
|
|||
// Set all cell sizes to pixel mode so each col or row are equally
|
||||
// treated by layout. This makes sure all the change is just in the desired col or row
|
||||
// NOTE: If COLS mode is used, but 1st row has any cells with COLSPAN>1,
|
||||
// the column widths "under" each spanned cell will allways be
|
||||
// the column widths "under" each spanned cell will always be
|
||||
// apportioned equally. Thus, in general, NOT using COLS results
|
||||
// in more deterministic column sizing.
|
||||
// Lets try to be smart by testing if any cell in 1st row has colspan
|
||||
// and use COLS if it doesn't
|
||||
// PROBLEM: When some cells have COLSPAN (not necessarily the first row),
|
||||
// using COLS prevents the last column to be resized
|
||||
// using COLS prevents the last column from being resized
|
||||
// (it seems to have a lower limit = width of column to the left)
|
||||
// TODO: Lets not use COLS until this is fixed
|
||||
int iMode = ED_MODE_CELL_PIXELS | ED_MODE_NO_COLS; // | (pTable->FirstRowHasColSpan() ? ED_MODE_NO_COLS : ED_MODE_USE_COLS);
|
||||
|
@ -6205,7 +6210,7 @@ void CEditBuffer::ParseMetaTag( PA_Tag *pTag, intn& retVal )
|
|||
|
||||
// Check our charset string for validity
|
||||
// (We may close done the buffer in this routine)
|
||||
if( CheckCharset(pData, win_csid) )
|
||||
if( CheckCharset(pTag, pData, win_csid) )
|
||||
{
|
||||
|
||||
// We want to allow multiple entries with the same NAME,
|
||||
|
@ -6229,160 +6234,150 @@ void CEditBuffer::ParseMetaTag( PA_Tag *pTag, intn& retVal )
|
|||
if( pContent ) XP_FREE( pContent );
|
||||
}
|
||||
|
||||
static void edt_ReplaceCharset(EDT_MetaData *pData, char *pNewCharset)
|
||||
static void edt_ReplaceCharset(PA_Tag *pTag, EDT_MetaData *pData, char *pNewCharset)
|
||||
{
|
||||
// Find the string "charset" in the content string
|
||||
char *pCharset = XP_STRSTR(pData->pContent, PARAM_CHARSET);
|
||||
if( !pCharset )
|
||||
char pContent[128];
|
||||
|
||||
if( pTag && pData && pNewCharset && *pNewCharset )
|
||||
{
|
||||
CHARSET_ERROR:
|
||||
XP_ASSERT(0);
|
||||
return;
|
||||
}
|
||||
// Find the '=' after "charset"
|
||||
char *pEqual = XP_STRCHR(pCharset, '=');
|
||||
if( !pEqual )
|
||||
goto CHARSET_ERROR;
|
||||
// Replace existing Content-Type value
|
||||
XP_SPRINTF(pContent, "text/html; charset=%.100s", pNewCharset);
|
||||
XP_FREEIF( pData->pContent );
|
||||
pData->pContent = XP_STRDUP(pContent);
|
||||
|
||||
// Example of a Content-Type meta tag:
|
||||
//<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||
|
||||
char *tptr = pEqual+1;
|
||||
|
||||
// Terminate here -- this is where we will append the new string
|
||||
*tptr = '\0';
|
||||
tptr++;
|
||||
|
||||
// Skip over whitespace before chaset name
|
||||
while (XP_IS_SPACE(*tptr))
|
||||
tptr++;
|
||||
|
||||
//Then find end of old charset string
|
||||
// This assumes charset string can have no spaces in it
|
||||
while( *tptr && !XP_IS_SPACE(*tptr) && *tptr != '\"' && *tptr != '>')
|
||||
tptr++;
|
||||
|
||||
// Copy this to append at the end,
|
||||
// (this allows other params after charset to be retained)
|
||||
char *pEnd = NULL;
|
||||
if( *tptr )
|
||||
pEnd = XP_STRDUP(tptr);
|
||||
|
||||
// Rebuild complete "Content=" string
|
||||
// This avoids realloc if new and old string are the same size
|
||||
pData->pContent = PR_sprintf_append(pData->pContent, pNewCharset);
|
||||
if( pEnd )
|
||||
{
|
||||
pData->pContent = PR_sprintf_append(pData->pContent, pEnd);
|
||||
XP_FREE(pEnd);
|
||||
// Also replace the original tag contents
|
||||
char *pTagContent = NULL;
|
||||
pTagContent = PR_sprintf_append(pTagContent, "%s=\"%s\" CONTENT=\"%s\"", PARAM_HTTP_EQUIV, CONTENT_TYPE, pContent);
|
||||
|
||||
if( pTagContent )
|
||||
{
|
||||
XP_FREEIF(pTag->data);
|
||||
pTag->data_len = XP_STRLEN(pTagContent);
|
||||
pTag->data = (PA_Block)pTagContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return FALSE only if we are closing down
|
||||
XP_Bool CEditBuffer::CheckCharset( EDT_MetaData *pData, int16 win_csid )
|
||||
XP_Bool CEditBuffer::CheckCharset( PA_Tag *pTag, EDT_MetaData *pData, int16 win_csid )
|
||||
{
|
||||
XP_Bool bRetVal = TRUE;
|
||||
int16 default_csid = FE_DefaultDocCharSetID(m_pContext);
|
||||
|
||||
if( CS_USRDEF2 != default_csid &&
|
||||
CS_USER_DEFINED_ENCODING != default_csid &&
|
||||
pData && pData->bHttpEquiv && pData->pName && pData->pContent &&
|
||||
0 == XP_STRCASECMP(pData->pName, CONTENT_TYPE) )
|
||||
// If this is not 0, then we are reloading a page
|
||||
// that we are trying to fix a bad charset
|
||||
if( m_iReplaceCSID )
|
||||
{
|
||||
// Example of a charset meta tag:
|
||||
//<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||
char *pNewCharset = (char *)INTL_CsidToCharsetNamePt(m_iReplaceCSID);
|
||||
if( pNewCharset )
|
||||
edt_ReplaceCharset(pTag, pData, pNewCharset);
|
||||
|
||||
// Create a simple tag so we can use tag-parsing to extract charset
|
||||
// PA_FetchParamValue (called from edt_FetchParamString)
|
||||
// needs a terminal '>' to work
|
||||
int iLen = XP_STRLEN(pData->pContent);
|
||||
char *pContent = (char*)XP_ALLOC(iLen+1);
|
||||
if( !pContent )
|
||||
return FALSE; //Abort if not enough memory?
|
||||
m_iReplaceCSID = 0;
|
||||
}
|
||||
else if( pData && pData->pName && *pData->pName &&
|
||||
pData->pContent && *pData->pContent )
|
||||
{
|
||||
// Normal doc-loading path
|
||||
int16 default_csid = FE_DefaultDocCharSetID(m_pContext);
|
||||
|
||||
XP_STRCPY(pContent, pData->pContent);
|
||||
pContent[iLen] = '>';
|
||||
iLen++;
|
||||
pContent[iLen] = '\0';
|
||||
|
||||
PA_Tag *pTag = XP_NEW( PA_Tag );
|
||||
XP_BZERO( pTag, sizeof( PA_Tag ) );
|
||||
pTag->data_len = iLen;
|
||||
pTag->data = (PA_Block)pContent;
|
||||
|
||||
char *pCharset = edt_FetchParamString(pTag, PARAM_CHARSET, win_csid );
|
||||
PA_FREE(pTag);
|
||||
|
||||
if( pCharset )
|
||||
if( CS_USRDEF2 != default_csid &&
|
||||
CS_USER_DEFINED_ENCODING != default_csid &&
|
||||
pData->bHttpEquiv &&
|
||||
0 == XP_STRCASECMP(pData->pName, CONTENT_TYPE) )
|
||||
{
|
||||
int iBufLen = 255;
|
||||
char buf[256];
|
||||
char *pMsg = NULL;
|
||||
// Create a simple tag so we can use tag-parsing function to extract charset
|
||||
// PA_FetchParamValue (called from edt_FetchParamString)
|
||||
// needs a terminal '>' to work
|
||||
|
||||
if(CS_UNKNOWN == INTL_CharSetNameToID(pCharset))
|
||||
int iLen = XP_STRLEN(pData->pContent);
|
||||
char *pContent = (char*)XP_ALLOC(iLen+1);
|
||||
if( !pContent )
|
||||
return FALSE; //Abort if not enough memory?
|
||||
|
||||
XP_STRCPY(pContent, pData->pContent);
|
||||
pContent[iLen] = '>';
|
||||
iLen++;
|
||||
pContent[iLen] = '\0';
|
||||
|
||||
PA_Tag *pTempTag = XP_NEW( PA_Tag );
|
||||
XP_BZERO( pTempTag, sizeof( PA_Tag ) );
|
||||
pTempTag->data_len = iLen;
|
||||
pTempTag->data = (PA_Block)pContent;
|
||||
char *pCharset = edt_FetchParamString(pTempTag, PARAM_CHARSET, win_csid );
|
||||
PA_FREE(pTempTag);
|
||||
|
||||
if( pCharset )
|
||||
{
|
||||
// Get the default charset
|
||||
//INTL_CharSetIDToName(default_csid, &pDefaultCharset);
|
||||
// Above uses presized buffer, but calls following, so this is safer:
|
||||
// (Don't free this string!)
|
||||
char *pDefaultCharset = (char *)INTL_CsidToCharsetNamePt(default_csid);
|
||||
if( pDefaultCharset )
|
||||
int iBufLen = 255;
|
||||
char buf[256];
|
||||
char *pMsg = NULL;
|
||||
|
||||
if(CS_UNKNOWN == INTL_CharSetNameToID(pCharset))
|
||||
{
|
||||
// Build a very wordy message box with the default and current
|
||||
// charset strings inserted
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_LABEL), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
pMsg = PR_sprintf_append(pMsg, XP_GetString(XP_EDT_CHARSET_CANT_EDIT));
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CURRENT_CHARSET), pDefaultCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_REPLACE), pDefaultCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
pMsg = PR_sprintf_append(pMsg, XP_GetString(XP_EDT_CHARSET_EDIT_CANCEL));
|
||||
// If user chooses "Cancel", then we should abort editing
|
||||
bRetVal = FE_Confirm(m_pContext, pMsg);
|
||||
if( bRetVal )
|
||||
// Get the default charset
|
||||
//INTL_CharSetIDToName(default_csid, &pDefaultCharset);
|
||||
// Above uses presized buffer, but calls following, so this is safer:
|
||||
// (Don't free this string!)
|
||||
char *pDefaultCharset = (char *)INTL_CsidToCharsetNamePt(default_csid);
|
||||
if( pDefaultCharset )
|
||||
{
|
||||
// Change to the default charset
|
||||
edt_ReplaceCharset(pData, pDefaultCharset);
|
||||
// Build a very wordy message box with the default and current
|
||||
// charset strings inserted
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_LABEL), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
pMsg = PR_sprintf_append(pMsg, XP_GetString(XP_EDT_CHARSET_CANT_EDIT));
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CURRENT_CHARSET), pDefaultCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_REPLACE), pDefaultCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
pMsg = PR_sprintf_append(pMsg, XP_GetString(XP_EDT_CHARSET_EDIT_CANCEL));
|
||||
// If user chooses "Cancel", then we should abort editing
|
||||
bRetVal = FE_Confirm(m_pContext, pMsg);
|
||||
if( bRetVal )
|
||||
{
|
||||
// Change to the default charset
|
||||
edt_ReplaceCharset(pTag, pData, pDefaultCharset);
|
||||
}
|
||||
}
|
||||
else
|
||||
bRetVal = FALSE; //Abort if no default charset?
|
||||
}
|
||||
else
|
||||
bRetVal = FALSE; //Abort if no default charset?
|
||||
}
|
||||
else
|
||||
{
|
||||
//ftang: Implement this! If this should NOT be freed,
|
||||
// then please remove the XP_FREEIF below
|
||||
//pNewCharset = INTL_CharsetCorrection(pCharset);
|
||||
char *pCorrectCharset = XP_STRDUP(pCharset);
|
||||
// ftang: If this should be XP_STRCMP instead, please change it
|
||||
if( pCorrectCharset && 0 != XP_STRCASECMP(pCorrectCharset, pCharset) )
|
||||
{
|
||||
// See if user wants to replace charset with the "correct" string
|
||||
// In either case, we continue editing
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_LABEL), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_SUGGESTED), pCorrectCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_REPLACE), pCorrectCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_NOREPLACE), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
|
||||
if( FE_Confirm(m_pContext, pMsg) )
|
||||
//TODO: ftang needs to implement this!
|
||||
// Note: Don't free this string!
|
||||
//pCorrectCharset = INTL_CharsetCorrection(pCharset);
|
||||
char *pCorrectCharset = pCharset;
|
||||
if( pCorrectCharset && 0 != XP_STRCASECMP(pCorrectCharset, pCharset) )
|
||||
{
|
||||
// Change to the "correct" charset
|
||||
edt_ReplaceCharset(pData, pCorrectCharset);
|
||||
// See if user wants to replace charset with the "correct" string
|
||||
// In either case, we continue editing
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_LABEL), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_SUGGESTED), pCorrectCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_REPLACE), pCorrectCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
PR_snprintf(buf, iBufLen, XP_GetString(XP_EDT_CHARSET_EDIT_NOREPLACE), pCharset);
|
||||
pMsg = PR_sprintf_append(pMsg, buf);
|
||||
|
||||
if( FE_Confirm(m_pContext, pMsg) )
|
||||
{
|
||||
// Change to the "correct" charset
|
||||
edt_ReplaceCharset(pTag, pData, pCorrectCharset);
|
||||
}
|
||||
}
|
||||
}
|
||||
XP_FREEIF(pCorrectCharset);
|
||||
XP_FREE(pCharset);
|
||||
}
|
||||
XP_FREE(pCharset);
|
||||
}
|
||||
}
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
||||
// Image
|
||||
|
||||
// Image
|
||||
EDT_ImageData* CEditBuffer::GetImageData(){
|
||||
CEditLeafElement *pInsertPoint;
|
||||
ElementOffset iOffset;
|
||||
|
@ -9786,7 +9781,7 @@ void CEditBuffer::SaveFileReal(CEditSaveData *pData) {
|
|||
}
|
||||
|
||||
// Stamp the document character set into the document.
|
||||
SetEncoding(GetDocCharSetID());
|
||||
SetEncodingTag(GetDocCharSetID());
|
||||
|
||||
// tapeFS freed by CEditSaveObject (actually CFileSaveObject::~CFileSaveObject).
|
||||
m_pSaveObject =
|
||||
|
@ -11222,9 +11217,6 @@ XP_Bool CEditBuffer::StartDragTable(int32 /*x*/, int32 /*y*/)
|
|||
if( !pCell )
|
||||
return FALSE;
|
||||
|
||||
// Source table we are dragging from
|
||||
m_pDragTableData->pSourceTable = (void*)pCell->GetTable();
|
||||
|
||||
// Get first layout cell of selection
|
||||
if( m_pSelectedLoTable )
|
||||
{
|
||||
|
@ -11240,6 +11232,8 @@ XP_Bool CEditBuffer::StartDragTable(int32 /*x*/, int32 /*y*/)
|
|||
XP_ASSERT(m_SelectedEdCells.Size() > 0 && m_SelectedLoCells.Size() > 0);
|
||||
m_pDragTableData->pFirstSelectedCell = (LO_Element*)m_SelectedLoCells[0];
|
||||
}
|
||||
// Source table we are dragging from
|
||||
m_pDragTableData->pSourceTable = lo_GetParentTable(m_pContext, m_pDragTableData->pFirstSelectedCell);
|
||||
|
||||
intn iPrevCounter = 0;
|
||||
intn iRowCounter = 0;
|
||||
|
@ -11357,64 +11351,74 @@ XP_Bool CEditBuffer::PositionDropCaret(int32 x, int32 y)
|
|||
// If we are dragging a table selection,
|
||||
// get feedback data, except when entire table selected
|
||||
// (use normal caret placement for that)
|
||||
if( m_pDragTableData && m_pDragTableData->iSourceType > ED_HIT_SEL_TABLE )
|
||||
if( m_pDragTableData )
|
||||
{
|
||||
// Get where we currently are
|
||||
LO_Element *pLoCell = NULL;
|
||||
int32 iWidth = 0;
|
||||
int32 iHeight = 0;
|
||||
|
||||
// Get where user is currently dragging over
|
||||
ED_DropType iDropType = GetTableDropRegion(&x, &y, &iWidth, &iHeight, &pLoCell);
|
||||
|
||||
// No point in dropping exactly on top of selection being dragged
|
||||
if( iDropType == ED_DROP_NONE )
|
||||
// We can't drop inside the table being dragged
|
||||
if( m_pDragTableData->iSourceType == ED_HIT_SEL_TABLE &&
|
||||
m_pDragTableData->pSourceTable == lo_GetParentTable(m_pContext, m_pDragTableData->pDragOverCell) )
|
||||
{
|
||||
NO_DROP_ALLOWED:
|
||||
FE_DestroyCaret(m_pContext);
|
||||
// Be sure there's no special selection
|
||||
if( edt_pPrevReplaceCellSelected )
|
||||
ClearSpecialCellSelection(edt_pPrevReplaceCellSelected);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( m_pDragTableData->iSourceType > ED_HIT_SEL_TABLE )
|
||||
{
|
||||
// Get where we currently are
|
||||
LO_Element *pLoCell = NULL;
|
||||
int32 iWidth = 0;
|
||||
int32 iHeight = 0;
|
||||
|
||||
// Get where user is currently dragging over
|
||||
|
||||
ED_DropType iDropType = GetTableDropRegion(&x, &y, &iWidth, &iHeight, &pLoCell);
|
||||
|
||||
if( iDropType == ED_DROP_NORMAL )
|
||||
{
|
||||
// Be sure there's no special selection
|
||||
// when we move off of the table
|
||||
if( edt_pPrevReplaceCellSelected )
|
||||
ClearSpecialCellSelection(edt_pPrevReplaceCellSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call Front end to display drop feedback only if
|
||||
// different from previous condition
|
||||
//if( pLoCell != m_pDragTableData->pDragOverCell ||
|
||||
// iDropType != m_pDragTableData->iDropType )
|
||||
// No point in dropping exactly on top of selection being dragged
|
||||
if( iDropType == ED_DROP_NONE )
|
||||
goto NO_DROP_ALLOWED;
|
||||
|
||||
if( iDropType == ED_DROP_NORMAL )
|
||||
{
|
||||
m_pDragTableData->iDropType = iDropType;
|
||||
m_pDragTableData->pDragOverCell = pLoCell;
|
||||
m_pDragTableData->X = x;
|
||||
m_pDragTableData->Y = y;
|
||||
m_pDragTableData->iWidth = iWidth;
|
||||
m_pDragTableData->iHeight = iHeight;
|
||||
|
||||
FE_DestroyCaret(m_pContext);
|
||||
if( m_pDragTableData->iDropType == ED_DROP_REPLACE_CELLS )
|
||||
{
|
||||
SetReplaceCellSelection();
|
||||
|
||||
// Should we do this as well?
|
||||
//lo_PositionDropCaret(m_pContext, x, y, NULL);
|
||||
} else {
|
||||
// Clear replace selection
|
||||
if( edt_pPrevReplaceCellSelected )
|
||||
ClearSpecialCellSelection(edt_pPrevReplaceCellSelected);
|
||||
|
||||
// Set the caret to show inserting between rows, colomns, or entire table
|
||||
FE_DisplayDropTableFeedback(m_pContext, m_pDragTableData);
|
||||
}
|
||||
// Be sure there's no special selection
|
||||
// when we move off of the table
|
||||
if( edt_pPrevReplaceCellSelected )
|
||||
ClearSpecialCellSelection(edt_pPrevReplaceCellSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call Front end to display drop feedback only if
|
||||
// different from previous condition
|
||||
//if( pLoCell != m_pDragTableData->pDragOverCell ||
|
||||
// iDropType != m_pDragTableData->iDropType )
|
||||
{
|
||||
m_pDragTableData->iDropType = iDropType;
|
||||
m_pDragTableData->pDragOverCell = pLoCell;
|
||||
m_pDragTableData->X = x;
|
||||
m_pDragTableData->Y = y;
|
||||
m_pDragTableData->iWidth = iWidth;
|
||||
m_pDragTableData->iHeight = iHeight;
|
||||
|
||||
FE_DestroyCaret(m_pContext);
|
||||
if( m_pDragTableData->iDropType == ED_DROP_REPLACE_CELLS )
|
||||
{
|
||||
SetReplaceCellSelection();
|
||||
|
||||
// Should we do this as well?
|
||||
//lo_PositionDropCaret(m_pContext, x, y, NULL);
|
||||
} else {
|
||||
// Clear replace selection
|
||||
if( edt_pPrevReplaceCellSelected )
|
||||
ClearSpecialCellSelection(edt_pPrevReplaceCellSelected);
|
||||
|
||||
// Set the caret to show inserting between rows, colomns, or entire table
|
||||
FE_DisplayDropTableFeedback(m_pContext, m_pDragTableData);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -11681,49 +11685,6 @@ void CEditBuffer::SelectAll(){
|
|||
RevealSelection();
|
||||
}
|
||||
|
||||
|
||||
// This is the old version
|
||||
void CEditBuffer::SelectTable(){
|
||||
VALIDATE_TREE(this);
|
||||
ClearPhantomInsertPoint();
|
||||
ClearMove();
|
||||
DoneTyping();
|
||||
CEditSelection selection;
|
||||
GetSelection(selection);
|
||||
CEditTableElement* pStartTable = selection.m_start.m_pElement->GetTableIgnoreSubdoc();
|
||||
CEditSelection startAll;
|
||||
if ( pStartTable ) {
|
||||
pStartTable->GetAll(startAll);
|
||||
}
|
||||
CEditTableElement* pEndTable = selection.m_end.m_pElement->GetTableIgnoreSubdoc();
|
||||
CEditSelection endAll;
|
||||
if ( pEndTable ) {
|
||||
pEndTable->GetAll(endAll);
|
||||
}
|
||||
if ( pStartTable ) {
|
||||
if ( pEndTable ) {
|
||||
// Both a start table and an end table.
|
||||
selection.m_start = startAll.m_start;
|
||||
selection.m_end = endAll.m_end;
|
||||
}
|
||||
else {
|
||||
// Just a start table.
|
||||
selection = startAll;
|
||||
}
|
||||
} else {
|
||||
if ( pEndTable ) {
|
||||
// Just an end table.
|
||||
selection = endAll;
|
||||
}
|
||||
else {
|
||||
// No table. Don't change selection.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetSelection(selection);
|
||||
}
|
||||
|
||||
// Select the cell boundary of cell containing the current edit element
|
||||
void CEditBuffer::SelectTableCell()
|
||||
{
|
||||
|
@ -13393,12 +13354,12 @@ BAD_CLIPBOARD:
|
|||
// Returns TRUE if there is another row to process
|
||||
// (pLoEle points to first cell on next row, and iRowY is updated)
|
||||
static XP_Bool edt_SetSpecialSelectRow(MWContext *pMWContext, LO_Element*& pLoEle, int32 iCellsInRow,
|
||||
int32 iFirstColX, int32& iRowY )
|
||||
int32 iStartColX, int32& iRowY )
|
||||
{
|
||||
// Find first LO cell at appropriate column in each row to be marked
|
||||
while(TRUE)
|
||||
{
|
||||
if( pLoEle && pLoEle->type == LO_CELL && pLoEle->lo_cell.x >= iFirstColX )
|
||||
if( pLoEle && pLoEle->type == LO_CELL && pLoEle->lo_cell.x >= iStartColX )
|
||||
break;
|
||||
pLoEle = pLoEle->lo_any.next;
|
||||
}
|
||||
|
@ -13533,10 +13494,11 @@ void CEditBuffer::PasteTable( CEditTableCellElement *pCell, CEditTableElement *p
|
|||
iCellsInRow++;
|
||||
pSourceCell = pSourceCell->GetNextSibling();
|
||||
}
|
||||
// This code is shared with SetReplaceCellSelection(),
|
||||
int32 iStartColX = pLoEle->lo_cell.x;
|
||||
|
||||
// This code is shared with SetReplaceCellSelection(),
|
||||
if( !edt_SetSpecialSelectRow(m_pContext, pLoEle, iCellsInRow,
|
||||
pLoEle->lo_cell.x, iRowY) )
|
||||
iStartColX, iRowY) )
|
||||
break;
|
||||
|
||||
pSourceRow = pSourceRow->GetNextRow();
|
||||
|
@ -14847,10 +14809,11 @@ ED_HitType CEditBuffer::GetTableHitRegion(int32 x, int32 y, LO_Element **ppEleme
|
|||
|
||||
if( x >= right_limit )
|
||||
{
|
||||
if( x >= right_limit || // Anywhere in inter-cell space to the right of the cell
|
||||
(y >= top_limit && y <= bottom_limit) ) // Inside cell, near right edge, excluding corners
|
||||
if( !bModifierKeyPressed &&
|
||||
(x >= right_limit || // Anywhere in inter-cell space to the right of the cell
|
||||
(y >= top_limit && y <= bottom_limit)) ) // Inside cell, near right edge, excluding corners
|
||||
{
|
||||
// Modifier key pressed an near right edge, excluding corners
|
||||
// Modifier key pressed and near right edge, excluding corners
|
||||
return ED_HIT_SIZE_COL;
|
||||
}
|
||||
|
||||
|
@ -14890,7 +14853,7 @@ ED_HitType CEditBuffer::GetTableHitRegion(int32 x, int32 y, LO_Element **ppEleme
|
|||
return ED_HIT_NONE;
|
||||
}
|
||||
|
||||
if( y >= bottom_limit ) // Along bottom edge (including intercell region)
|
||||
if( y >= bottom_limit && !bModifierKeyPressed ) // Along bottom edge (including intercell region)
|
||||
{
|
||||
// Size the row
|
||||
return ED_HIT_SIZE_ROW;
|
||||
|
@ -14926,7 +14889,7 @@ ED_HitType CEditBuffer::GetTableHitRegion(int32 x, int32 y, LO_Element **ppEleme
|
|||
|
||||
return ED_HIT_SEL_TABLE;
|
||||
}
|
||||
if( y >= bottom_limit )
|
||||
if( y >= bottom_limit && !bModifierKeyPressed )
|
||||
// Lower left corner
|
||||
return ED_HIT_ADD_ROWS;
|
||||
|
||||
|
@ -14939,14 +14902,15 @@ ED_HitType CEditBuffer::GetTableHitRegion(int32 x, int32 y, LO_Element **ppEleme
|
|||
}
|
||||
else if( x >= right_limit )
|
||||
{
|
||||
if( y >= bottom_limit )
|
||||
// Along right edge - size table
|
||||
if( bModifierKeyPressed )
|
||||
return ED_HIT_SIZE_TABLE_WIDTH;
|
||||
|
||||
if( y >= bottom_limit && !bModifierKeyPressed )
|
||||
// Lower right corner
|
||||
return ED_HIT_ADD_COLS;
|
||||
|
||||
// Along right edge
|
||||
return ED_HIT_SIZE_TABLE_WIDTH;
|
||||
}
|
||||
else if( y >= bottom_limit )
|
||||
else if( y >= bottom_limit && bModifierKeyPressed )
|
||||
{
|
||||
// Below bottom, excluding corners
|
||||
return ED_HIT_SIZE_TABLE_HEIGHT;
|
||||
|
@ -15735,6 +15699,13 @@ LO_CellStruct* CEditBuffer::GetLoCell(CEditElement *pEdElement)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void CEditBuffer::SelectTable()
|
||||
{
|
||||
CEditTableElement* pTable = m_pCurrent->GetTableIgnoreSubdoc();
|
||||
if( pTable )
|
||||
SelectTable(TRUE, 0, pTable);
|
||||
}
|
||||
|
||||
CEditTableElement* CEditBuffer::SelectTable(XP_Bool bSelect, LO_TableStruct *pLoTable,
|
||||
CEditTableElement *pEdTable)
|
||||
{
|
||||
|
@ -16003,12 +15974,13 @@ void CEditBuffer::SetReplaceCellSelection()
|
|||
LO_Element *pLoEle = m_pDragTableData->pDragOverCell;
|
||||
// This will get updated by edt_SetSpecialSelectRow for each row
|
||||
int32 iRowY = pLoEle->lo_cell.y;
|
||||
int32 iStartColX = pLoEle->lo_cell.x;
|
||||
|
||||
for( intn iRow = 0; iRow < m_pDragTableData->iRows; iRow++ )
|
||||
{
|
||||
// Most of the code is shared with section in PasteTable() for replace cell logic
|
||||
if( !edt_SetSpecialSelectRow(m_pContext, pLoEle, m_pDragTableData->pCellsPerRow[iRow],
|
||||
pLoEle->lo_cell.x, iRowY) )
|
||||
iStartColX, iRowY) )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -16381,12 +16353,12 @@ CEditTableCellElement *CEditBuffer::GetNextSelectedCell(intn* pRowCounter)
|
|||
|
||||
// Dynamic object sizing
|
||||
|
||||
ED_SizeStyle CEditBuffer::CanSizeObject(LO_Element *pLoElement, int32 xVal, int32 yVal)
|
||||
ED_SizeStyle CEditBuffer::CanSizeObject(LO_Element *pLoElement, int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed)
|
||||
{
|
||||
// Table and Cells are special case - use more complicated hit testing
|
||||
if( pLoElement && (pLoElement->type == LO_TABLE || pLoElement->type == LO_CELL) )
|
||||
{
|
||||
ED_HitType iHitType = GetTableHitRegion(xVal, yVal, &pLoElement, FALSE);
|
||||
ED_HitType iHitType = GetTableHitRegion(xVal, yVal, &pLoElement, bModifierKeyPressed);
|
||||
switch( iHitType )
|
||||
{
|
||||
case ED_HIT_SIZE_COL:
|
||||
|
@ -16508,7 +16480,7 @@ ED_SizeStyle CEditBuffer::CanSizeObject(LO_Element *pLoElement, int32 xVal, int3
|
|||
}
|
||||
|
||||
ED_SizeStyle CEditBuffer::StartSizing(LO_Element *pLoElement, int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect){
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect){
|
||||
XP_ASSERT(pRect);
|
||||
|
||||
if( m_pSizingObject ){
|
||||
|
@ -16518,14 +16490,16 @@ ED_SizeStyle CEditBuffer::StartSizing(LO_Element *pLoElement, int32 xVal, int32
|
|||
// Unselect table or cell(s)
|
||||
ClearTableAndCellSelection();
|
||||
|
||||
// Shouldn't be here without this, but check anyway
|
||||
int iStyle = CanSizeObject(pLoElement, xVal, yVal);
|
||||
// We are using the "ModifierKeyPressed" (last param)
|
||||
// for 2 purposes: To lock the aspect ratio for non-table objects,
|
||||
// and for
|
||||
int iStyle = CanSizeObject(pLoElement, xVal, yVal, bModifierKeyPressed);
|
||||
|
||||
if( iStyle ){
|
||||
m_pSizingObject = new CSizingObject();
|
||||
if( m_pSizingObject ){
|
||||
if( m_pSizingObject->Create(this, pLoElement, iStyle,
|
||||
xVal, yVal, bLockAspect, pRect) ){
|
||||
xVal, yVal, bModifierKeyPressed, pRect) ){
|
||||
return iStyle;
|
||||
} else {
|
||||
delete m_pSizingObject;
|
||||
|
@ -16537,10 +16511,10 @@ ED_SizeStyle CEditBuffer::StartSizing(LO_Element *pLoElement, int32 xVal, int32
|
|||
}
|
||||
|
||||
XP_Bool CEditBuffer::GetSizingRect(int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect){
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect){
|
||||
XP_ASSERT(pRect);
|
||||
if( m_pSizingObject && pRect ){
|
||||
return m_pSizingObject->GetSizingRect(xVal, yVal, bLockAspect, pRect);
|
||||
return m_pSizingObject->GetSizingRect(xVal, yVal, bModifierKeyPressed, pRect);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -17231,7 +17205,7 @@ void CEditBuffer::ChangeEncoding(int16 csid) {
|
|||
ForceDocCharSetID(csid); // Will be translated to this id when saved
|
||||
// Note: Why doesn't this allow Undo to work?
|
||||
BeginBatchChanges(0); // Marks document as dirty.
|
||||
SetEncoding(csid); // Will claim to be this id when saved.
|
||||
SetEncodingTag(csid); // Will claim to be this id when saved.
|
||||
EndBatchChanges();
|
||||
CEditDocState *pState = RecordState(); // Actually translates.
|
||||
if (pState) {
|
||||
|
@ -17244,20 +17218,54 @@ void CEditBuffer::ChangeEncoding(int16 csid) {
|
|||
}
|
||||
}
|
||||
|
||||
XP_Bool CEditBuffer::SetEncoding(int16 csid)
|
||||
{
|
||||
ED_CharsetEncode result = FE_EncodingDialog(m_pContext, (char*)INTL_CsidToCharsetNamePt(csid));
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ED_ENCODE_CHANGE_CHARSET:
|
||||
// Change encoding and translate document
|
||||
ChangeEncoding(csid);
|
||||
return TRUE;
|
||||
|
||||
case ED_ENCODE_CHANGE_METATAG:
|
||||
{
|
||||
// Set charset param in Content-Type metatag, but don't translate document
|
||||
SetEncodingTag(csid);
|
||||
INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(m_pContext);
|
||||
INTL_SetCSIWinCSID(csi, csid);
|
||||
// This will be used to replace the charset in the metatag
|
||||
// after the reload
|
||||
m_iReplaceCSID = csid;
|
||||
INTL_Relayout(m_pContext);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case ED_ENCODE_CANCEL:
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE; // shouldn't get here
|
||||
}
|
||||
|
||||
// Add content-type meta-data. This tells the reader which character set was used to create the document.
|
||||
// See RFC 2070, "Internationalization of the Hypertext Markup Language"
|
||||
// http://ds.internic.net/rfc/rfc2070.txt
|
||||
// <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-2022-JP">
|
||||
void CEditBuffer::SetEncoding(int16 csid)
|
||||
void CEditBuffer::SetEncodingTag(int16 csid)
|
||||
{
|
||||
int16 plainCSID = csid & ~CS_AUTO;
|
||||
// This is better than INTL_CharSetIDToName, which needs presized buffer;
|
||||
// (Don't free this string!)
|
||||
char *charSet = (char *)INTL_CsidToCharsetNamePt(plainCSID);
|
||||
SetEncoding(charSet);
|
||||
SetEncodingTag(charSet);
|
||||
}
|
||||
|
||||
void CEditBuffer::SetEncoding(char *pCharset)
|
||||
void CEditBuffer::SetEncodingTag(char *pCharset)
|
||||
{
|
||||
char pContent[128];
|
||||
if( pCharset && *pCharset )
|
||||
|
|
|
@ -2196,17 +2196,24 @@ CEditTableRowElement* CEditTableElement::GetFirstRow()
|
|||
CEditTableCellElement* CEditTableElement::GetFirstCell()
|
||||
{
|
||||
CEditElement *pChild = GetChild();
|
||||
if( pChild && pChild->IsTableRow() )
|
||||
if( pChild )
|
||||
{
|
||||
pChild = pChild->GetChild();
|
||||
if( pChild && pChild->IsTableCell() )
|
||||
// Skip over caption
|
||||
if( pChild->IsCaption() )
|
||||
pChild = pChild->GetNextSibling();
|
||||
|
||||
if( pChild && pChild->IsTableRow() )
|
||||
{
|
||||
// Initialize these also so we can follow
|
||||
// this call with GetNextCellInRow(), GetNextCellInColumn(),
|
||||
// or GetNextCellInTable()
|
||||
m_pCurrentCell = pChild->TableCell();
|
||||
m_pFirstCellInColumnOrRow = m_pNextCellInColumnOrRow = m_pCurrentCell;
|
||||
return m_pCurrentCell;
|
||||
pChild = pChild->GetChild();
|
||||
if( pChild && pChild->IsTableCell() )
|
||||
{
|
||||
// Initialize these also so we can follow
|
||||
// this call with GetNextCellInRow(), GetNextCellInColumn(),
|
||||
// or GetNextCellInTable()
|
||||
m_pCurrentCell = pChild->TableCell();
|
||||
m_pFirstCellInColumnOrRow = m_pNextCellInColumnOrRow = m_pCurrentCell;
|
||||
return m_pCurrentCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -2219,7 +2226,7 @@ CEditTableCellElement* CEditTableElement::GetNextCellInTable(intn *pRowCounter)
|
|||
return m_pCurrentCell;
|
||||
}
|
||||
|
||||
// The numbe of rows can simply be counted
|
||||
// The number of rows can simply be counted
|
||||
intn CEditTableElement::CountRows()
|
||||
{
|
||||
m_iRows = 0;
|
||||
|
@ -2322,6 +2329,12 @@ CEditTableCellElement* CEditTableElement::GetFirstCellInRow(CEditTableCellElemen
|
|||
// Get first cell of a "real" (geometric) row, based on location
|
||||
// If bSpan == TRUE , this will also get a cell that spans given Y,
|
||||
// even if top of cell != Y
|
||||
// Note: When bSpan is TRUE, we will find a cell in row above if it spans the
|
||||
// given Y. This is OK for current uses, but it really doesn't return
|
||||
// the "first" cell. (See comment below)
|
||||
// If we don't return the spanned cell as "first", GetNextCellInRow would have
|
||||
// to be much more complicated, as it would have to scan rows above to
|
||||
// detect cells spanning the current row
|
||||
CEditTableCellElement* CEditTableElement::GetFirstCellInRow(int32 Y, XP_Bool bSpan)
|
||||
{
|
||||
|
||||
|
@ -2331,7 +2344,11 @@ CEditTableCellElement* CEditTableElement::GetFirstCellInRow(int32 Y, XP_Bool bSp
|
|||
while( pCell )
|
||||
{
|
||||
int32 iCellY = pCell->GetY();
|
||||
if( (bSpan && (Y >= iCellY) && (Y <= (iCellY + pCell->GetHeight()))) ||
|
||||
// Note that a cell can really be FIRST in a spanned row only if it is
|
||||
// really the first cell in logical row (check for previous sibling)
|
||||
// but if we do that, we won't hit the cell at all later.
|
||||
if( (bSpan && Y >= iCellY && Y <= (iCellY + pCell->GetHeight()) /*&&
|
||||
pCell->GetPreviousSibling() == NULL*/ ) ||
|
||||
(!bSpan && ( Y == iCellY)) )
|
||||
{
|
||||
m_pFirstCellInColumnOrRow = m_pNextCellInColumnOrRow = pCell;
|
||||
|
@ -2850,19 +2867,10 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number,
|
|||
CEditBuffer *pBuffer = GetEditBuffer();
|
||||
XP_ASSERT(pBuffer);
|
||||
CEditTableCellElement *pCellForInsertPoint = NULL;
|
||||
int32 iCurrentColumns = GetColumns();
|
||||
int32 iTotalColumns = iCurrentColumns;
|
||||
// Set to the total to simplify test padding the rows near end of function
|
||||
int32 iSourceColumns = iTotalColumns;
|
||||
|
||||
if( pSourceTable )
|
||||
{
|
||||
iSourceColumns = pSourceTable->CountColumns();
|
||||
CEditTableRowElement *pSourceRow;
|
||||
// If inserted rows will require new columns,
|
||||
// figure that out now and add the necessary columns
|
||||
// Figure the total number of columns in table after inserting
|
||||
iTotalColumns = max(iCurrentColumns, iStartColumn + pSourceTable->CountColumns());
|
||||
|
||||
if( iStartColumn > 0 )
|
||||
{
|
||||
|
@ -2892,10 +2900,9 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number,
|
|||
// from the paste source
|
||||
pBuffer->ClearFillNewCellWithSpace();
|
||||
}
|
||||
iSourceColumns += iStartColumn;
|
||||
}
|
||||
|
||||
CEditTableCellElement *pCell = GetFirstCellInRow(Y, FALSE );
|
||||
CEditTableCellElement *pCell = GetFirstCellInRow(Y, TRUE );
|
||||
while( pCell )
|
||||
{
|
||||
int32 iCellY = pCell->GetY();
|
||||
|
@ -2904,7 +2911,7 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number,
|
|||
if( Y == iNewY )
|
||||
{
|
||||
// Inserting above
|
||||
|
||||
|
||||
if( iCellY == Y )
|
||||
{
|
||||
// We will be inserting cells above this one
|
||||
|
@ -2928,8 +2935,6 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number,
|
|||
pCell = GetNextCellInRow();
|
||||
}
|
||||
|
||||
XP_ASSERT(iColumns == iCurrentColumns);
|
||||
|
||||
// Now insert the new rows (including iColumns new cells in each)
|
||||
for ( intn row = 0; row < number; row++ )
|
||||
{
|
||||
|
@ -2960,10 +2965,8 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number,
|
|||
pNewRow->FinishedLoad(pBuffer);
|
||||
}
|
||||
|
||||
// if( (iSourceColumns < iTotalColumns) ||
|
||||
// (iCurrentColumns < iTotalColumns) )
|
||||
|
||||
// Do this all the time?
|
||||
// Pad the inserted rows or the table with extra cells
|
||||
// to keep rectangular geometry
|
||||
NormalizeCellsPerRow();
|
||||
|
||||
if( ppCellForInsertPoint && *ppCellForInsertPoint == NULL )
|
||||
|
@ -3046,7 +3049,6 @@ void CEditTableElement::InsertColumns(int32 X, int32 iNewX, intn number,
|
|||
// need to add rows at bottom of table
|
||||
// so overflow from inserted columns line up
|
||||
intn iColumnsBefore = GetColumnsSpanned(GetColumnX(0), iNewX);
|
||||
intn iTotalColumns = pSourceTable->GetColumns() + pSourceTable->CountColumns();
|
||||
|
||||
while(pSourceRow)
|
||||
{
|
||||
|
@ -3172,7 +3174,14 @@ XP_Bool CEditTableElement::ReplaceSpecialCells(CEditTableElement *pSourceTable,
|
|||
{
|
||||
// Skip to the next replace row (skip replacing rest on this row)
|
||||
while( pReplaceCell && iReplaceRow == iPrevReplaceRow )
|
||||
{
|
||||
// Delete contents in the extra replace cells
|
||||
if( pReplaceCell->IsSpecialSelected() )
|
||||
pReplaceCell->DeleteContents();
|
||||
|
||||
pReplaceCell = pReplaceCell->GetNextCellInTable(&iReplaceRow);
|
||||
}
|
||||
|
||||
// then find the next special selected cell
|
||||
while( pReplaceCell && !pReplaceCell->IsSpecialSelected() )
|
||||
pReplaceCell = pReplaceCell->GetNextCellInTable(&iReplaceRow);
|
||||
|
@ -3215,6 +3224,16 @@ XP_Bool CEditTableElement::ReplaceSpecialCells(CEditTableElement *pSourceTable,
|
|||
}
|
||||
while( pReplaceCell && pSourceCell );
|
||||
|
||||
|
||||
// Delete contents in the remaining replace cells
|
||||
while( pReplaceCell )
|
||||
{
|
||||
if( pReplaceCell->IsSpecialSelected() )
|
||||
pReplaceCell->DeleteContents();
|
||||
|
||||
pReplaceCell = pReplaceCell->GetNextCellInTable(&iReplaceRow);
|
||||
}
|
||||
|
||||
// Check if we still have cells in last source row,
|
||||
if( bAllSourceCellsPasted && pSourceCell )
|
||||
bAllSourceCellsPasted = FALSE;
|
||||
|
@ -3281,18 +3300,18 @@ void CEditTableElement::DeleteRows(int32 Y, intn number,
|
|||
|
||||
// Restrict number of rows we can delete
|
||||
intn iLastIndex = min(iRowIndex + number - 1, m_iRows-1);
|
||||
CEditTableRowElement *pFirstRow = NULL;
|
||||
CEditTableRowElement *pLastRow = NULL;
|
||||
CEditTableRowElement *pRowAbove = NULL;
|
||||
CEditTableRowElement *pRowBelow = NULL;
|
||||
if( iRowIndex > 0 )
|
||||
pRowAbove = GetRow(GetRowY(iRowIndex-1));
|
||||
|
||||
for( ; iRowIndex <= iLastIndex; iRowIndex++ )
|
||||
{
|
||||
Y = GetRowY(iRowIndex);
|
||||
CEditTableRowElement *pRow = GetRow(Y);
|
||||
pLastRow = pRow;
|
||||
|
||||
// Get first cell starting at or spanning the Y value (TRUE)
|
||||
CEditTableCellElement *pCell = GetFirstCellInRow(Y, TRUE);
|
||||
pFirstRow = GetRow(Y);
|
||||
|
||||
while( pCell )
|
||||
{
|
||||
|
@ -3334,20 +3353,20 @@ void CEditTableElement::DeleteRows(int32 Y, intn number,
|
|||
if( pRow && pRow->GetChild() == NULL )
|
||||
{
|
||||
// Get the next row if available before deleting this one
|
||||
pLastRow = pRow->GetNextRow();
|
||||
pRowBelow = pRow->GetNextRow();
|
||||
#ifdef DEBUG
|
||||
if( pLastRow )
|
||||
XP_ASSERT(pLastRow->IsTableRow());
|
||||
if( pRowBelow )
|
||||
XP_ASSERT(pRowBelow->IsTableRow());
|
||||
#endif
|
||||
delete pRow;
|
||||
}
|
||||
}
|
||||
// Get first cell in the next row after deleted rows,
|
||||
// or row before if we deleted to the end of the table
|
||||
if( pLastRow )
|
||||
pCellForInsertPoint = pLastRow->GetFirstCell();
|
||||
else if( pFirstRow )
|
||||
pCellForInsertPoint = pLastRow->GetFirstCell();
|
||||
if( pRowBelow )
|
||||
pCellForInsertPoint = pRowBelow->GetFirstCell();
|
||||
else if( pRowAbove )
|
||||
pCellForInsertPoint = pRowAbove->GetFirstCell();
|
||||
|
||||
if( ppCellForInsertPoint && *ppCellForInsertPoint == NULL )
|
||||
*ppCellForInsertPoint = pCellForInsertPoint;
|
||||
|
@ -5414,6 +5433,7 @@ void CEditTableCellElement::SetSizeData(EDT_TableCellData * pData)
|
|||
if( pData && pCurrentData )
|
||||
{
|
||||
pCurrentData->X = pData->X;
|
||||
pCurrentData->Y = pData->Y;
|
||||
pCurrentData->iRow = pData->iRow;
|
||||
pCurrentData->bWidthDefined = pData->bWidthDefined;
|
||||
pCurrentData->bWidthPercent = pData->bWidthPercent;
|
||||
|
@ -5493,6 +5513,20 @@ void CEditTableCellElement::SetColumnWidthRight(CEditTableElement *pTable, LO_El
|
|||
}
|
||||
pLoElement = pLoElement->lo_any.next;
|
||||
}
|
||||
EDT_TableData *pTableData = pTable->GetData();
|
||||
if( pTableData )
|
||||
{
|
||||
if( pTableData->bWidthDefined )
|
||||
{
|
||||
// Force pixel mode and adjust the width of parent table
|
||||
// If we don't, a table width in Percent mode will fight column size change
|
||||
pTableData->iWidthPixels = max(1,pTableData->iWidthPixels + iDeltaWidth);
|
||||
pTableData->bWidthPercent = FALSE;
|
||||
pTableData->iWidth = pTableData->iWidthPixels;
|
||||
pTable->SetData(pTableData);
|
||||
}
|
||||
EDT_FreeTableData(pTableData);
|
||||
}
|
||||
}
|
||||
|
||||
// Set height of all cells sharing or spanning the bottom edge
|
||||
|
@ -6180,6 +6214,12 @@ CEditTableCellElement* CEditTableCellElement::GetNextCellInColumn(CEditTableCell
|
|||
XP_Bool CEditTableCellElement::AllCellsInColumnAreSelected()
|
||||
{
|
||||
CEditTableCellElement *pCell = GetFirstCellInColumn();
|
||||
if( !pCell ) // Unlikely
|
||||
{
|
||||
XP_ASSERT(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while( pCell )
|
||||
{
|
||||
if( !pCell->IsSelected() )
|
||||
|
@ -6193,6 +6233,12 @@ XP_Bool CEditTableCellElement::AllCellsInColumnAreSelected()
|
|||
XP_Bool CEditTableCellElement::AllCellsInRowAreSelected()
|
||||
{
|
||||
CEditTableCellElement *pCell = GetFirstCellInRow();
|
||||
if( !pCell ) // Unlikely
|
||||
{
|
||||
XP_ASSERT(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while( pCell )
|
||||
{
|
||||
if( !pCell->IsSelected() )
|
||||
|
@ -8391,8 +8437,9 @@ void CEditTextElement::SetLayoutElement( intn iEditOffset, intn lo_type,
|
|||
iEditOffset, lo_type, pLoElement);
|
||||
}
|
||||
|
||||
LO_Element* CEditTextElement::GetLayoutElement(){
|
||||
return m_pFirstLayoutElement;
|
||||
LO_Element* CEditTextElement::GetLayoutElement()
|
||||
{
|
||||
return m_pFirstLayoutElement;
|
||||
}
|
||||
|
||||
void CEditTextElement::ResetLayoutElement( intn iEditOffset,
|
||||
|
|
|
@ -4237,7 +4237,7 @@ XP_Bool CSizingObject::Create(CEditBuffer *pBuffer,
|
|||
LO_Element *pLoElement,
|
||||
int iSizingStyle,
|
||||
int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect){
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect){
|
||||
XP_ASSERT(pBuffer);
|
||||
XP_ASSERT(pRect);
|
||||
XP_ASSERT(iSizingStyle);
|
||||
|
@ -4589,7 +4589,7 @@ XP_Bool CSizingObject::Create(CEditBuffer *pBuffer,
|
|||
|
||||
// Call this now primarily to start the
|
||||
// status line display of sizing information
|
||||
GetSizingRect(xVal, yVal, bLockAspect, &m_Rect);
|
||||
GetSizingRect(xVal, yVal, bModifierKeyPressed, &m_Rect);
|
||||
|
||||
if( pRect )
|
||||
*pRect = m_Rect;
|
||||
|
@ -4624,11 +4624,15 @@ void CalcAddColRect(int32 iCols, XP_Rect *pTableRect, XP_Rect *pRect)
|
|||
style == ED_SIZE_BOTTOM_LEFT || \
|
||||
style == ED_SIZE_BOTTOM_RIGHT )
|
||||
|
||||
XP_Bool CSizingObject::GetSizingRect(int32 xVal, int32 yVal, XP_Bool bLockAspect, XP_Rect *pRect)
|
||||
XP_Bool CSizingObject::GetSizingRect(int32 xVal, int32 yVal, XP_Bool bModifierKeyPressed, XP_Rect *pRect)
|
||||
{
|
||||
XP_ASSERT(pRect);
|
||||
int i;
|
||||
XP_Bool bLockAspectRatio = EDT_IS_SIZING_CORNER(m_iStyle) && bLockAspect;
|
||||
// We never allow lock aspect for table sizing
|
||||
// Instead, modifier is used to distinguish between sizing the last column or row
|
||||
// and sizing the whole table
|
||||
XP_Bool bLockAspectRatio = m_pLoElement->type != LO_TABLE && m_pLoElement->type != LO_CELL &&
|
||||
EDT_IS_SIZING_CORNER(m_iStyle) && bModifierKeyPressed;
|
||||
|
||||
int32 iViewX = xVal - m_iXOrigin;
|
||||
int32 iViewY = yVal - m_iYOrigin;
|
||||
|
@ -6052,15 +6056,15 @@ XP_Bool EDT_IsSizing(MWContext *pContext){
|
|||
}
|
||||
|
||||
ED_SizeStyle EDT_StartSizing(MWContext *pContext, LO_Element *pElement, int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect){
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer) 0;
|
||||
return pEditBuffer->StartSizing(pElement, xVal, yVal, bLockAspect, pRect);
|
||||
return pEditBuffer->StartSizing(pElement, xVal, yVal, bModifierKeyPressed, pRect);
|
||||
}
|
||||
|
||||
XP_Bool EDT_GetSizingRect(MWContext *pContext, int32 xVal, int32 yVal,
|
||||
XP_Bool bLockAspect, XP_Rect *pRect){
|
||||
XP_Bool bModifierKeyPressed, XP_Rect *pRect){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer) FALSE;
|
||||
return pEditBuffer->GetSizingRect(xVal, yVal, bLockAspect, pRect);
|
||||
return pEditBuffer->GetSizingRect(xVal, yVal, bModifierKeyPressed, pRect);
|
||||
}
|
||||
|
||||
void EDT_EndSizing(MWContext *pContext){
|
||||
|
@ -6196,32 +6200,8 @@ void EDT_SetRefresh( MWContext* pContext, XP_Bool bRefreshOn ){
|
|||
// Warning this deletes (and recreates) the CEditBuffer if we ChangeEncoding
|
||||
XP_Bool EDT_SetEncoding(MWContext* pContext, int16 csid){
|
||||
GET_EDIT_BUF_OR_RETURN(pContext, pEditBuffer) FALSE;
|
||||
ED_CharsetEncode result;
|
||||
|
||||
result = FE_EncodingDialog(pContext, (char*)INTL_CsidToCharsetNamePt(csid));
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ED_ENCODE_CHANGE_CHARSET:
|
||||
// Change encoding and translate document
|
||||
pEditBuffer->ChangeEncoding(csid);
|
||||
return TRUE;
|
||||
|
||||
case ED_ENCODE_CHANGE_METATAG:
|
||||
// Set charset param in Content-Type metatag, but don't translate document
|
||||
pEditBuffer->SetEncoding(csid);
|
||||
return FALSE;
|
||||
|
||||
case ED_ENCODE_CANCEL:
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE; // shouldn't get here
|
||||
return pEditBuffer->SetEncoding(csid);
|
||||
}
|
||||
// End of Block of functions moved from EDITOR.CPP for Win16 Build
|
||||
|
||||
/*
|
||||
* Extract the Extra HTML string from the ED_Element pointer in an image struct
|
||||
|
|
Загрузка…
Ссылка в новой задаче