зеркало из https://github.com/mozilla/gecko-dev.git
Composer bug fixes and more feature work
This commit is contained in:
Родитель
bea3609bc3
Коммит
22a7f83870
|
@ -505,8 +505,8 @@ char* EDT_GetEmptyDocumentString(){
|
|||
return "<html></html>";
|
||||
}
|
||||
|
||||
ED_Buffer* EDT_MakeEditBuffer(MWContext *pContext){
|
||||
return new CEditBuffer(pContext);
|
||||
ED_Buffer* EDT_MakeEditBuffer(MWContext *pContext, XP_Bool bImportText){
|
||||
return new CEditBuffer(pContext, bImportText);
|
||||
}
|
||||
|
||||
XP_Bool EDT_HaveEditBuffer(MWContext * pContext){
|
||||
|
@ -972,7 +972,14 @@ intn EDT_ProcessTag(void *data_object, PA_Tag *tag, intn status){
|
|||
}
|
||||
|
||||
if( pDocData->edit_buffer == 0 ){
|
||||
pDocData->edit_buffer = EDT_MakeEditBuffer( pDocData->window_id );
|
||||
// HACK ALERT
|
||||
// Libnet does not seem to be able to supply us with a reliable
|
||||
// "content_type" in the URL_Struct passed around to the front ends,
|
||||
// so we need to figure out when we are converting a text file into
|
||||
// HTML here.
|
||||
// Since we just created our edit buffer for the first tag encountered,
|
||||
// if it is the PLAIN_TEXT type, then we are probably importing a text file
|
||||
pDocData->edit_buffer = EDT_MakeEditBuffer( pDocData->window_id, tag->type == P_PLAIN_TEXT );
|
||||
bCreatedEditor = pDocData->edit_buffer != NULL;
|
||||
}
|
||||
|
||||
|
@ -1541,9 +1548,19 @@ int EDT_GetFontSize( MWContext *pContext ){
|
|||
return pEditBuffer->GetFontSize();
|
||||
}
|
||||
|
||||
void EDT_DecreaseFontSize( MWContext *pContext ){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer);
|
||||
// Size is a relative change, signaled by TRUE param
|
||||
pEditBuffer->SetFontSize(-1, TRUE);
|
||||
}
|
||||
void EDT_IncreaseFontSize( MWContext *pContext ){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer);
|
||||
// Size is a relative change, signalled by TRUE param
|
||||
pEditBuffer->SetFontSize(1, TRUE);
|
||||
}
|
||||
void EDT_SetFontSize( MWContext *pContext, int iSize ){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer);
|
||||
pEditBuffer->SetFontSize(iSize);
|
||||
pEditBuffer->SetFontSize(iSize, FALSE);
|
||||
}
|
||||
|
||||
int EDT_GetFontPointSize( MWContext *pContext ){
|
||||
|
@ -1594,6 +1611,16 @@ void EDT_SetFontColor( MWContext *pContext, LO_Color *pColor){
|
|||
}
|
||||
}
|
||||
|
||||
ED_ElementType EDT_GetBackgroundColor( MWContext *pContext, LO_Color *pColor ){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer) ED_ELEMENT_NONE;
|
||||
return pEditBuffer->GetBackgroundColor(pColor);
|
||||
}
|
||||
|
||||
void EDT_SetBackgroundColor( MWContext *pContext, LO_Color *pColor){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer);
|
||||
pEditBuffer->SetBackgroundColor(pColor);
|
||||
}
|
||||
|
||||
void EDT_StartSelection(MWContext *pContext, int32 x, int32 y){
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pContext, pEditBuffer);
|
||||
pEditBuffer->StartSelection(x,y, FALSE);
|
||||
|
@ -1692,12 +1719,11 @@ EDT_ClipboardResult EDT_PasteText( MWContext *pContext, char *pText ) {
|
|||
if( bEqualCols && iCols > 1 && iRows > 0 )
|
||||
{
|
||||
char *pMessage = NULL;
|
||||
pMessage = PR_sprintf_append( pMessage, "Text can be pasted as %d rows and %d columns.\n\n", iRows, iCols);
|
||||
pMessage = PR_sprintf_append( pMessage, XP_GetString(XP_EDT_CAN_PASTE_AS_TABLE), iRows, iCols);
|
||||
if( pEditBuffer->IsInsertPointInTableCell() )
|
||||
{
|
||||
// Give message about pasting into an existing table
|
||||
//TODO: MAKE XP STRINGS FOR EDT_PasteText INTO TABLES
|
||||
pMessage = PR_sprintf_append( pMessage, "Replace existing cells?");
|
||||
pMessage = PR_sprintf_append( pMessage, XP_GetString(XP_EDT_REPLACE_CELLS));
|
||||
|
||||
if( FE_Confirm(pEditBuffer->GetContext(), pMessage) )
|
||||
{
|
||||
|
@ -1711,7 +1737,7 @@ EDT_ClipboardResult EDT_PasteText( MWContext *pContext, char *pText ) {
|
|||
bPasteAsTable = TRUE;
|
||||
} else {
|
||||
// Give message about pasting as a new table
|
||||
pMessage = PR_sprintf_append( pMessage, "Paste text as a new table?");
|
||||
pMessage = PR_sprintf_append( pMessage, XP_GetString(XP_EDT_PASTE_AS_TABLE));
|
||||
if( FE_Confirm(pEditBuffer->GetContext(), pMessage) )
|
||||
{
|
||||
pEditBuffer->PasteTextAsNewTable(pText, iRows, iCols);
|
||||
|
@ -1785,10 +1811,12 @@ char *EDT_GetTabDelimitedTextFromSelectedCells( MWContext *pContext )
|
|||
return pEditBuffer->GetTabDelimitedTextFromSelectedCells();
|
||||
}
|
||||
|
||||
XP_Bool EDT_CanConvertTextToTable(MWContext *pMWContext)
|
||||
{
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pMWContext, pEditBuffer) FALSE;
|
||||
return pEditBuffer->CanConvertTextToTable();
|
||||
}
|
||||
|
||||
/* Convert Selected text into a table (put each paragraph in separate cell)
|
||||
* Number of rows is automatic - creates as many as needed
|
||||
*/
|
||||
void EDT_ConvertTextToTable(MWContext *pMWContext, intn iColumns)
|
||||
{
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pMWContext, pEditBuffer);
|
||||
|
|
|
@ -121,7 +121,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#define DEF_FONTSIZE 3
|
||||
#define MAX_FONTSIZE 7
|
||||
#define DEFAULT_HR_THICKNESS 2
|
||||
|
||||
#define EDT_IS_LIVEWIRE_MACRO(s) ( (s) && (s)[0] == '`' )
|
||||
|
@ -714,8 +713,9 @@ public:
|
|||
|
||||
virtual EEditElementType GetElementType();
|
||||
|
||||
// Get parent table of any element
|
||||
// Get parent table or cell of any element
|
||||
CEditTableElement* GetParentTable();
|
||||
CEditTableCellElement* GetParentTableCell();
|
||||
|
||||
virtual XP_Bool Reduce( CEditBuffer *pBuffer );
|
||||
|
||||
|
@ -1138,7 +1138,6 @@ private:
|
|||
// Total number of "physical" columns in row
|
||||
// (i.e., includes effect of COLSPAN and ROWSPAN)
|
||||
intn m_iColumns;
|
||||
|
||||
public:
|
||||
intn m_iBackgroundSaveIndex;
|
||||
|
||||
|
@ -1232,7 +1231,7 @@ public:
|
|||
// Test if cell contains only 1 container with
|
||||
// just the empty text field every new cell has
|
||||
XP_Bool IsEmpty();
|
||||
|
||||
|
||||
// Keep these in synch when selecting so
|
||||
// we don't always have to rely on LO_Elements
|
||||
XP_Bool IsSelected() { return m_bSelected; }
|
||||
|
@ -1703,7 +1702,9 @@ public:
|
|||
|
||||
void SetColor( ED_Color iColor );
|
||||
ED_Color GetColor(){ return m_color; }
|
||||
void SetFontSize( int iSize );
|
||||
|
||||
// If bRelative is TRUE, the iSize changes relative to existing size (usually -1 or +1)
|
||||
void SetFontSize(int iSize, XP_Bool bRelative = FALSE);
|
||||
int GetFontSize();
|
||||
void SetFontFace(char* face);
|
||||
char* GetFontFace();
|
||||
|
@ -3050,7 +3051,7 @@ public:
|
|||
CPrintState printState;
|
||||
CEditLinkManager linkManager;
|
||||
TXP_GrowableArray_EDT_MetaData m_metaData;
|
||||
|
||||
|
||||
// Get time and save in m_FileSaveTime
|
||||
// Public so CEditFileSave can call it
|
||||
void GetFileWriteTime();
|
||||
|
@ -3121,7 +3122,7 @@ private:
|
|||
#endif
|
||||
|
||||
public:
|
||||
CEditBuffer( MWContext* pContext );
|
||||
CEditBuffer( MWContext* pContext, XP_Bool bImportText );
|
||||
~CEditBuffer();
|
||||
CEditElement* CreateElement(PA_Tag* pTag, CEditElement *pParent);
|
||||
CEditElement* CreateFontElement(PA_Tag* pTag, CEditElement *pParent);
|
||||
|
@ -3139,6 +3140,7 @@ public:
|
|||
void FinishedLoad();
|
||||
void FinishedLoad2();
|
||||
void DummyCharacterAddedDuringLoad();
|
||||
void ConvertCurrentDocToNewDoc();
|
||||
|
||||
XP_Bool IsComposeWindow(){ return m_pContext->bIsComposeWindow; }
|
||||
|
||||
|
@ -3242,7 +3244,15 @@ public:
|
|||
void ClearMailQuote();
|
||||
EDT_ClipboardResult ReturnKey(XP_Bool bTyping);
|
||||
EDT_ClipboardResult TabKey(XP_Bool bForward, XP_Bool bForceTabChar);
|
||||
EDT_ClipboardResult InternalReturnKey(XP_Bool bRelayout);
|
||||
|
||||
EDT_ClipboardResult InternalReturnKey(XP_Bool bUserTyped);
|
||||
|
||||
// Similar to InternalReturnKey, but splits just below the
|
||||
// supplied common ancestor (m_pRoot if pAncestor is NULL)
|
||||
EDT_ClipboardResult SplitBelowAncestor(CEditElement *pAncestor = NULL, XP_Bool bUserTyped = TRUE);
|
||||
// Stuff common to InternalReturnKey and SplitBelowAncestor
|
||||
CEditElement* SplitAtContainer(XP_Bool bUserTyped, XP_Bool bSplitAtBeginning, CEditElement*& pRelayoutStart);
|
||||
|
||||
void Indent();
|
||||
void IndentSelection(CEditSelection& selection);
|
||||
void IndentContainer( CEditContainerElement *pContainer,
|
||||
|
@ -3295,6 +3305,9 @@ public:
|
|||
// Use result to paste into spreadsheets like Excel
|
||||
char *GetTabDelimitedTextFromSelectedCells();
|
||||
|
||||
// Test if there's a selection, and the beginning and end are not split across a cell boundary
|
||||
XP_Bool CanConvertTextToTable();
|
||||
|
||||
// Convert Selected text into a table (put each paragraph in separate cell)
|
||||
// Number of rows is automatic - creates as many as needed
|
||||
void ConvertTextToTable(intn iColumns);
|
||||
|
@ -3336,14 +3349,19 @@ public:
|
|||
ED_TextFormat GetCharacterFormatting();
|
||||
TagType GetParagraphFormatting();
|
||||
TagType GetParagraphFormattingSelection(CEditSelection& selection);
|
||||
|
||||
int GetFontSize();
|
||||
void SetFontSize(int n);
|
||||
void SetFontSizeSelection(int n, CEditSelection& selection, XP_Bool bRelayout);
|
||||
// If bRelative is TRUE, the iSize changes relative to existing size (usually -1 or +1)
|
||||
void SetFontSize(int iSize, XP_Bool bRelative);
|
||||
void SetFontSizeSelection(int n, XP_Bool bRelative, CEditSelection& selection, XP_Bool bRelayout);
|
||||
|
||||
int GetFontPointSize();
|
||||
void SetFontPointSize(int pointSize);
|
||||
ED_Color GetFontColor();
|
||||
void SetFontColor(ED_Color n);
|
||||
void SetFontColorSelection(ED_Color n, CEditSelection& selection, XP_Bool bRelayout);
|
||||
ED_ElementType GetBackgroundColor(LO_Color *pColor);
|
||||
void SetBackgroundColor(LO_Color *pColor);
|
||||
void InsertLeaf(CEditLeafElement *pLeaf);
|
||||
void InsertNonLeaf( CEditElement* pNonLeaf);
|
||||
EDT_ImageData* GetImageData();
|
||||
|
@ -3370,7 +3388,7 @@ public:
|
|||
XP_Bool IsInsertPointInNestedTable();
|
||||
EDT_TableData* GetTableData();
|
||||
void SetTableData(EDT_TableData *pData);
|
||||
void InsertTable(EDT_TableData *pData);
|
||||
CEditTableElement *InsertTable(EDT_TableData *pData);
|
||||
void DeleteTable();
|
||||
|
||||
//cmanske: new:
|
||||
|
@ -3535,7 +3553,7 @@ public:
|
|||
CEditLeafElement*& pEndElement, ElementOffset& iEndOffset, XP_Bool& bFromStart );
|
||||
|
||||
// Use data from supplied selection, or get from current selection if supplied is empty
|
||||
// Used were above used to be used -- allows using "selected" cell data
|
||||
// Used where above used to be used when you want to work on selected cell contents
|
||||
void GetSelection( CEditSelection& selection, CEditLeafElement*& pStartElement, ElementOffset& iStartOffset,
|
||||
CEditLeafElement*& pEndElement, ElementOffset& iEndOffset, XP_Bool& bFromStart );
|
||||
|
||||
|
@ -3853,7 +3871,20 @@ public:
|
|||
XP_Bool IsTableSelected() {return m_pSelectedEdTable != NULL; }
|
||||
XP_Bool IsTableOrCellSelected() { return (XP_Bool)(m_pSelectedEdTable ? TRUE : m_SelectedEdCells.Size()); }
|
||||
int GetSelectedCellCount() { return m_SelectedEdCells.Size(); }
|
||||
|
||||
|
||||
// New cell with space management.
|
||||
// This is complicated by the fact the relevant FinishedLoad() methods
|
||||
// are used by both initial loading of page and table elements
|
||||
// created internally. We should only insert extra space when creating internally
|
||||
// This is set from preferences
|
||||
XP_Bool NewCellHasSpace() { return m_bNewCellHasSpace; }
|
||||
// Before creating new cells internally, call this
|
||||
// so new cells
|
||||
void SetFillNewCellWithSpace() { m_bFillNewCellWithSpace = m_bNewCellHasSpace; }
|
||||
// Reset when done creating new cells
|
||||
void ClearFillNewCellWithSpace() { m_bFillNewCellWithSpace = FALSE; }
|
||||
// Call in FinishedLoad methods to check if we should insert the space
|
||||
XP_Bool FillNewCellWithSpace() { return m_bFillNewCellWithSpace; }
|
||||
|
||||
// For special cell highlighting during drag and drop
|
||||
// pLoElement can be the table or any cell that is starting cell,
|
||||
|
@ -3936,8 +3967,16 @@ private:
|
|||
int16 m_originalWinCSID;
|
||||
XP_Bool m_bForceDocCSID;
|
||||
int16 m_forceDocCSID;
|
||||
XP_Bool m_bImportText;
|
||||
|
||||
// Used during creation of new cells
|
||||
// This is set to the value of m_bNewCellHasSpace by SetFillNewCellWithSpace()
|
||||
XP_Bool m_bFillNewCellWithSpace;
|
||||
|
||||
//preference information
|
||||
static XP_Bool m_bNewCellHasSpace; //New cells we create have an   in them so border displays
|
||||
|
||||
|
||||
static XP_Bool m_bMoveCursor; //true = move cursor when pageup/down false, just move scrollbar
|
||||
static XP_Bool m_bEdtBufPrefInitialized; //are the preferences initialized
|
||||
static int PrefCallback(const char *,void *);//callback for preferences
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -289,6 +289,15 @@ CEditTableElement* CEditElement::GetParentTable()
|
|||
return (CEditTableElement*)pElement;
|
||||
}
|
||||
|
||||
// Get parent table cell of the element
|
||||
CEditTableCellElement* CEditElement::GetParentTableCell()
|
||||
{
|
||||
CEditElement *pElement = this;
|
||||
do { pElement = pElement->GetParent(); }
|
||||
while( pElement && !pElement->IsTableCell() );
|
||||
return (CEditTableCellElement*)pElement;
|
||||
}
|
||||
|
||||
//
|
||||
// static function calls the appropriate stream constructor
|
||||
//
|
||||
|
@ -648,7 +657,12 @@ void CEditElement::EnsureSelectableSiblings(CEditBuffer* pBuffer)
|
|||
{
|
||||
// Make sure the previous sibling exists and is a container
|
||||
CEditElement* pPrevious = GetPreviousSibling();
|
||||
// EXPERIMENTAL: Don't force another container before inserted table
|
||||
#if 0
|
||||
if ( ! pPrevious ) {
|
||||
#else
|
||||
if ( ! pPrevious || !pPrevious->IsContainer() ) {
|
||||
#endif
|
||||
pPrevious = CEditContainerElement::NewDefaultContainer( NULL,
|
||||
pParent->GetDefaultAlignment() );
|
||||
pPrevious->InsertBefore(this);
|
||||
|
@ -658,7 +672,11 @@ void CEditElement::EnsureSelectableSiblings(CEditBuffer* pBuffer)
|
|||
{
|
||||
// Make sure the next sibling exists and is container
|
||||
CEditElement* pNext = GetNextSibling();
|
||||
if ( ! pNext || pNext->IsEndContainer() || !pNext->IsContainer() ) {
|
||||
#if 0
|
||||
if ( ! pNext || pNext->IsEndContainer() ) {
|
||||
#else
|
||||
if ( ! pNext || pNext->IsEndContainer() || !pNext->IsContainer()) {
|
||||
#endif
|
||||
pNext = CEditContainerElement::NewDefaultContainer( NULL,
|
||||
pParent->GetDefaultAlignment() );
|
||||
pNext->InsertAfter(this);
|
||||
|
@ -2582,9 +2600,36 @@ void CEditTableElement::FixupColumnsAndRows()
|
|||
if( !pFirstCell )
|
||||
return;
|
||||
|
||||
CEditTableCellElement *pCell;
|
||||
intn iColumns = m_ColumnLayoutData.Size();
|
||||
intn iRows = m_RowLayoutData.Size();
|
||||
TXP_GrowableArray_int32 X_Array;
|
||||
TXP_GrowableArray_int32 Y_Array;
|
||||
CEditTableCellElement *pCell = pFirstCell;
|
||||
|
||||
while( pCell )
|
||||
{
|
||||
int32 iCellX = pCell->GetX();
|
||||
int32 iCellY = pCell->GetY();
|
||||
XP_Bool bFoundX = FALSE;
|
||||
XP_Bool bFoundY = FALSE;
|
||||
|
||||
// See if cell's X was already found
|
||||
intn iSize = X_Array.Size();
|
||||
for( intn i=0; i < iSize; i++ )
|
||||
{
|
||||
if( iCellX == X_Array[i] )
|
||||
{
|
||||
bFoundX = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !bFoundX )
|
||||
X_Array.Add(iCellX);
|
||||
|
||||
pCell = GetNextCellInTable();
|
||||
}
|
||||
m_iColumns = X_Array.Size();
|
||||
|
||||
intn iColumns = CountColumns(); //m_ColumnLayoutData.Size();
|
||||
intn iRows = CountRows(); //m_RowLayoutData.Size();
|
||||
intn i, iMinSpan, iDecrease;
|
||||
// We will find the maximum number of columns in all rows
|
||||
m_iColumns = 0;
|
||||
|
@ -2724,6 +2769,8 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number, CEditTable
|
|||
}
|
||||
pCell = GetNextCellInRow();
|
||||
}
|
||||
CEditBuffer *pBuffer = GetEditBuffer();
|
||||
|
||||
// Now insert the new rows (including iColumns new cells in each)
|
||||
for ( intn row = 0; row < number; row++ )
|
||||
{
|
||||
|
@ -2734,12 +2781,18 @@ void CEditTableElement::InsertRows(int32 Y, int32 iNewY, intn number, CEditTable
|
|||
}
|
||||
else {
|
||||
pNewRow = new CEditTableRowElement(iColumns);
|
||||
if( !pNewRow )
|
||||
return;
|
||||
pBuffer->SetFillNewCellWithSpace();
|
||||
}
|
||||
if( Y == iNewY )
|
||||
pNewRow->InsertBefore(pRow);
|
||||
else
|
||||
pNewRow->InsertAfter(pRow);
|
||||
|
||||
pNewRow->FinishedLoad(pBuffer);
|
||||
}
|
||||
pBuffer->ClearFillNewCellWithSpace();
|
||||
}
|
||||
|
||||
void CEditTableElement::InsertColumns(int32 X, int32 iNewX, intn number, CEditTableElement* pSource){
|
||||
|
@ -2938,7 +2991,10 @@ void CEditTableElement::FinishedLoad( CEditBuffer* pBuffer ){
|
|||
CEditTableRowElement* pRow = NULL;
|
||||
CEditElement* pNext = 0;
|
||||
|
||||
// For efficiency, get count rows only
|
||||
// TODO: MAKE THIS WORK BEFORE LAYOUT HAPPENS (no m_ColumnLayoutData yet)
|
||||
//FixupColumnsAndRows();
|
||||
|
||||
// For efficiency, count rows only
|
||||
// if we haven't layed out table
|
||||
if( m_iRows <= 0 )
|
||||
m_iRows = CountRows();
|
||||
|
@ -3877,7 +3933,9 @@ void CEditTableRowElement::FinishedLoad( CEditBuffer* pBuffer ){
|
|||
pChild->FinishedLoad(pBuffer);
|
||||
}
|
||||
if ( pCell ){
|
||||
// pBuffer->SetFillNewCellWithSpace();
|
||||
pCell->FinishedLoad(pBuffer);
|
||||
// pBuffer->ClearFillNewCellWithSpace();
|
||||
pCell = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -3936,8 +3994,11 @@ static void edt_InsertCells(intn number, XP_Bool bAfter, CEditTableCellElement *
|
|||
// This will add pSource cells from left to right
|
||||
pInsertCell->InsertBefore(pExisting);
|
||||
}
|
||||
// Be sure cell has the empty text element in default paragraph container
|
||||
// Be sure cell has the empty text element in default paragraph container,
|
||||
// but check if text should be a space
|
||||
pBuffer->SetFillNewCellWithSpace();
|
||||
pInsertCell->FinishedLoad(pBuffer);
|
||||
pBuffer->ClearFillNewCellWithSpace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3978,6 +4039,11 @@ void CEditTableRowElement::InsertCells(int32 X, int32 iNewX, intn number, CEditT
|
|||
if( !pInsertCell )
|
||||
{
|
||||
pInsertCell = new CEditTableCellElement();
|
||||
// Insert space into initial text
|
||||
CEditBuffer *pBuffer = GetEditBuffer();
|
||||
pBuffer->SetFillNewCellWithSpace();
|
||||
pInsertCell->FinishedLoad(pBuffer);
|
||||
pBuffer->ClearFillNewCellWithSpace();
|
||||
}
|
||||
if( pInsertCell )
|
||||
{
|
||||
|
@ -4606,6 +4672,10 @@ CEditTableCellElement::CEditTableCellElement(IStreamIn *pStreamIn, CEditBuffer *
|
|||
}
|
||||
|
||||
CEditTableCellElement::~CEditTableCellElement(){
|
||||
// Be sure any cell deleted is not selected
|
||||
if( IsSelected() && GetEditBuffer() )
|
||||
GetEditBuffer()->SelectCell(FALSE, NULL, this);
|
||||
|
||||
delete m_pBackgroundImage;
|
||||
}
|
||||
|
||||
|
@ -5600,15 +5670,20 @@ void CEditTableCellElement::DeleteContents(XP_Bool bMarkAsDeleted)
|
|||
delete pChild;
|
||||
pChild = pNext;
|
||||
}
|
||||
// Set state for new cell contents according to preference
|
||||
// (we may put a space in the blank cell)
|
||||
GetEditBuffer()->SetFillNewCellWithSpace();
|
||||
|
||||
// Create a default paragraph container,
|
||||
// this will set cell as its parent
|
||||
CEditContainerElement *pContainer = CEditContainerElement::NewDefaultContainer(this, ED_ALIGN_DEFAULT);
|
||||
|
||||
// Initialize the cell contents
|
||||
if( pContainer )
|
||||
{
|
||||
// Create empty string as only element so we have
|
||||
// a leaf element to place caret at
|
||||
CEditTextElement *pText = new CEditTextElement(pContainer,"");
|
||||
}
|
||||
pContainer->FinishedLoad(GetEditBuffer());
|
||||
|
||||
GetEditBuffer()->ClearFillNewCellWithSpace();
|
||||
|
||||
// Mark this cell as deleted so CEditBuffer::DeleteSelectedCells()
|
||||
// can skip over this during multiple deletion passes
|
||||
if( bMarkAsDeleted )
|
||||
|
@ -6337,37 +6412,81 @@ ElementIndex CEditContainerElement::GetPersistentCount(){
|
|||
|
||||
|
||||
|
||||
void CEditContainerElement::FinishedLoad( CEditBuffer *pBuffer ){
|
||||
void CEditContainerElement::FinishedLoad( CEditBuffer *pBuffer )
|
||||
{
|
||||
XP_Bool bFillNewCellWithSpace = FALSE;
|
||||
if ( GetType() != P_PREFORMAT )
|
||||
{
|
||||
if ( GetType() != P_PREFORMAT ) {
|
||||
// Don't allow more than one space before non-text elements
|
||||
CEditElement* pNext = 0;
|
||||
// Don't allow more than one space before non-text elements
|
||||
CEditElement* pNext;
|
||||
CEditElement *pChild = GetChild();
|
||||
CEditElement* pParent = GetParent();
|
||||
|
||||
// Detect the case of a single container with a single
|
||||
// text element with just a space in a table cell
|
||||
// This is OK and is needed to show cell border in browser
|
||||
XP_Bool bIsTableCellWithOneSpace = FALSE;
|
||||
|
||||
if( pParent && pParent->IsTableCell() &&
|
||||
GetNextSibling() == NULL &&
|
||||
pChild && pChild->IsText() &&
|
||||
(pChild->GetNextSibling() == NULL ||
|
||||
pChild->GetNextSibling()->GetType() == P_UNKNOWN) )
|
||||
{
|
||||
// We have a single container in a table cell with a single text child
|
||||
CEditTextElement* pTextChild = pChild->Text();
|
||||
char* pText = pTextChild->GetText();
|
||||
// If creating a new cell and preference is set,
|
||||
// the empty cell should have a space,
|
||||
// so delete this and a new one will be created below
|
||||
bFillNewCellWithSpace = GetEditBuffer() ? GetEditBuffer()->FillNewCellWithSpace() : FALSE;
|
||||
|
||||
if( pTextChild->GetLen() == 0 && bFillNewCellWithSpace )
|
||||
{
|
||||
delete pChild;
|
||||
}
|
||||
else if( pTextChild->GetLen() == 1 && pText[0] == ' ')
|
||||
{
|
||||
// We have a single space, so don't do special trimming below
|
||||
bIsTableCellWithOneSpace = TRUE;
|
||||
}
|
||||
}
|
||||
if( ! bIsTableCellWithOneSpace )
|
||||
{
|
||||
for ( CEditElement* pChild = GetChild();
|
||||
pChild;
|
||||
pChild = pNext ) {
|
||||
pChild = pNext )
|
||||
{
|
||||
pNext = pChild->GetNextSibling();
|
||||
if ( pChild->IsText() && ! (pNext && pNext->IsText()) ){
|
||||
if ( pChild->IsText() && ! (pNext && pNext->IsText()) )
|
||||
{
|
||||
CEditTextElement* pTextChild = pChild->Text();
|
||||
char* pText = pTextChild->GetText();
|
||||
int size = pTextChild->GetLen();
|
||||
XP_Bool trimming = FALSE;
|
||||
//do not allow 1 byte of space to be a child
|
||||
if (size == 1 && GetType() == P_NSDT && pText[0] == ' ') {
|
||||
if (size == 1 && GetType() == P_NSDT && pText[0] == ' ')
|
||||
{
|
||||
trimming = TRUE;
|
||||
size--;
|
||||
}
|
||||
|
||||
while ( size >0 && pText[size-1] == '\n' || (size > 1 && pText[size-1] == ' ' && pText[size-2] == ' ') ) {
|
||||
while ( size >0 && pText[size-1] == '\n' ||
|
||||
(size > 1 && pText[size-1] == ' ' && pText[size-2] == ' ') )
|
||||
{
|
||||
// More than one character of white space at the end of
|
||||
// a text element will get laid out as one character.
|
||||
trimming = TRUE;
|
||||
size--;
|
||||
}
|
||||
if ( trimming ) {
|
||||
if (size <= 0 ) {
|
||||
if ( trimming )
|
||||
{
|
||||
if (size <= 0 )
|
||||
{
|
||||
delete pChild;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
char* pCopy = XP_STRDUP(pText);
|
||||
pCopy[size] = '\0';
|
||||
pTextChild->SetText(pCopy);
|
||||
|
@ -6378,21 +6497,22 @@ void CEditContainerElement::FinishedLoad( CEditBuffer *pBuffer ){
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( GetChild() == NULL ){
|
||||
// I need a dummy child.
|
||||
CEditTextElement* pChild = new CEditTextElement(this, 0);
|
||||
|
||||
if ( GetChild() == NULL )
|
||||
{
|
||||
// I need a dummy child -- might be a space for new cell
|
||||
CEditTextElement* pChild = new CEditTextElement(this, bFillNewCellWithSpace ? " " : 0);
|
||||
// Creating it automaticly inserts it
|
||||
pChild->FinishedLoad(pBuffer);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// if the last element in a paragraph is a <br>, it is ignored by the browser.
|
||||
// So we should trim it.
|
||||
// we should do this only once!!!
|
||||
CEditElement *pChild;
|
||||
CEditElement* pPrev;
|
||||
if( (pChild = GetLastChild())!= 0 && pChild->IsBreak()) {
|
||||
if( (pChild = GetLastChild())!= 0 && pChild->IsBreak())
|
||||
{
|
||||
pPrev = pChild->GetPreviousSibling();
|
||||
if (! (pPrev && pPrev->IsBreak()) )
|
||||
delete pChild;
|
||||
|
@ -7491,15 +7611,79 @@ void CEditTextElement::SetColor( ED_Color iColor ){
|
|||
}
|
||||
}
|
||||
|
||||
void CEditTextElement::SetFontSize( int iSize ){
|
||||
m_iFontSize = iSize;
|
||||
if( m_iFontSize > 7 ) m_iFontSize = 7;
|
||||
// if( m_iFontSize < 1 ) m_iFontSize = 1;
|
||||
|
||||
// We seem to have problems when point size gets REALLY big,
|
||||
// so limit this for now
|
||||
#define ED_MAX_POINT_SIZE 104
|
||||
|
||||
// Boost the size changes when increasing or decreasing point sizes
|
||||
void static AdjustPointSizeChange( int& iChange, int iPointSize )
|
||||
{
|
||||
if( iChange == 1 )
|
||||
{
|
||||
if( iPointSize >= 10 && iPointSize <= 24 )
|
||||
iChange = 2;
|
||||
else if( iPointSize > 24 )
|
||||
iChange = 4;
|
||||
}
|
||||
else if( iChange == -1 )
|
||||
{
|
||||
if( iPointSize >= 10 && iPointSize <= 24 )
|
||||
iChange = -2;
|
||||
else if( iPointSize > 24 )
|
||||
iChange = -4;
|
||||
}
|
||||
}
|
||||
|
||||
void CEditTextElement::SetFontSize( int iSize, XP_Bool bRelative )
|
||||
{
|
||||
//Override (use default for) ALL font size requests for Java Script
|
||||
if( EDT_IS_SCRIPT(m_tf) ){
|
||||
iSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate the new size and keep within allowable range
|
||||
// bRelative = TRUE means that iSize is a change relative
|
||||
// to current size
|
||||
if( bRelative )
|
||||
{
|
||||
if( m_iPointSize != ED_FONT_POINT_SIZE_DEFAULT )
|
||||
{
|
||||
// We are already using pts, so change that instead of m_iFontSize
|
||||
AdjustPointSizeChange( iSize, m_iPointSize );
|
||||
SetFontPointSize(min(ED_MAX_POINT_SIZE, max(MIN_POINT_SIZE, m_iPointSize+iSize)));
|
||||
return;
|
||||
}
|
||||
#ifdef XP_WIN
|
||||
// EXPERIMENTAL:
|
||||
// If we are trying to increase past the highest HTML size (7),
|
||||
// we change over to POINT size instead so we can
|
||||
// continue to increase the size.
|
||||
// To do this, we need to get the point size of the "7" font,
|
||||
if( (m_iFontSize + iSize) > MAX_FONT_SIZE )
|
||||
{
|
||||
int16 iPointSize = FE_CalcFontPointSize(GetEditBuffer()->m_pContext, MAX_FONT_SIZE, m_tf & TF_FIXED);
|
||||
if( iPointSize )
|
||||
{
|
||||
AdjustPointSizeChange( iSize, iPointSize );
|
||||
SetFontPointSize(min(ED_MAX_POINT_SIZE, iPointSize+iSize));
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif //XP_WIN
|
||||
// We are using relative scale,
|
||||
// set new size relative to current
|
||||
iSize = m_iFontSize + iSize;
|
||||
}
|
||||
}
|
||||
iSize = min(MAX_FONT_SIZE, max(MIN_FONT_SIZE,(iSize)));
|
||||
|
||||
// No change from current state
|
||||
if( m_iFontSize == iSize )
|
||||
return;
|
||||
|
||||
m_iFontSize = iSize;
|
||||
|
||||
|
||||
// Use 0 (or less) to signify changing to default
|
||||
if( iSize <= 0 ){
|
||||
|
@ -7867,9 +8051,13 @@ void CEditTextElement::MaskData( EDT_CharacterData*& pData ){
|
|||
pData->mask &= ~TF_HREF;
|
||||
}
|
||||
if( (pData->mask & pData->values & m_tf & TF_FONT_SIZE)
|
||||
&& (pData->iSize != m_iFontSize ) ){
|
||||
&& (pData->iSize != m_iFontSize) ){
|
||||
pData->mask &= ~TF_FONT_SIZE;
|
||||
}
|
||||
if( (pData->mask & pData->values & m_tf & TF_FONT_POINT_SIZE)
|
||||
&& (pData->iPointSize != m_iPointSize) ){
|
||||
pData->mask &= ~TF_FONT_POINT_SIZE;
|
||||
}
|
||||
if( (pData->mask & pData->values & m_tf & TF_FONT_FACE) ){
|
||||
// Both have font face -- see if it is different
|
||||
char * pFontFace = GetFontFace();
|
||||
|
|
|
@ -2895,7 +2895,8 @@ CEditTestManager::CEditTestManager(CEditBuffer* pBuffer)
|
|||
m_pTempFileURL(0)
|
||||
{
|
||||
#ifdef XP_WIN32
|
||||
_CrtMemCheckpoint( &m_state ); // In theorey, avoid measuring the data before we were created.
|
||||
// 5/28/98 ??? This is crashing -- Why???
|
||||
// _CrtMemCheckpoint( &m_state ); // In theorey, avoid measuring the data before we were created.
|
||||
#endif
|
||||
|
||||
PowerOnTest();
|
||||
|
@ -5337,116 +5338,8 @@ void CEditDocState::Print(IStreamOut& stream) {
|
|||
*/
|
||||
void EDT_ConvertCurrentDocToNewDoc(MWContext * pMWContext)
|
||||
{
|
||||
XP_ASSERT(pMWContext);
|
||||
if( !pMWContext ){
|
||||
return;
|
||||
}
|
||||
GET_WRITABLE_EDIT_BUF_OR_RETURN(pMWContext, pEditBuffer);
|
||||
|
||||
char * pUntitled = XP_GetString(XP_EDIT_NEW_DOC_NAME);
|
||||
|
||||
// Traverse all links and images and change URLs to absolute
|
||||
// since we will be destroying our current base doc URL
|
||||
EDT_ImageData *pImageData;
|
||||
char *pAbsolute = NULL;
|
||||
EDT_PageData *pPageData = pEditBuffer->GetPageData();
|
||||
if( !pPageData){
|
||||
return;
|
||||
}
|
||||
|
||||
// Should be the same as pEntry->Address???
|
||||
char *pBaseURL = LO_GetBaseURL(pMWContext);
|
||||
|
||||
// Call Java Plugin hook for pages to be closed,
|
||||
// BUT only if it really was an lockable source
|
||||
int iType = NET_URL_Type(pBaseURL);
|
||||
if( iType == FTP_TYPE_URL ||
|
||||
iType == HTTP_TYPE_URL ||
|
||||
iType == SECURE_HTTP_TYPE_URL ||
|
||||
iType == FILE_TYPE_URL ){
|
||||
EDT_PreClose(pMWContext, pBaseURL, NULL, NULL);
|
||||
}
|
||||
|
||||
// Walk the tree and find all HREFs.
|
||||
CEditElement *pLeaf = pEditBuffer->m_pRoot->FindNextElement(
|
||||
&CEditElement::FindLeafAll,0 );
|
||||
// First sweep, mark all HREFs as not adjusted.
|
||||
while (pLeaf) {
|
||||
pEditBuffer->linkManager.SetAdjusted(pLeaf->Leaf()->GetHREF(),FALSE);
|
||||
pLeaf = pLeaf->FindNextElement(&CEditElement::FindLeafAll,0 );
|
||||
}
|
||||
// Second sweep, actually adjust the HREFs.
|
||||
pLeaf = pEditBuffer->m_pRoot->FindNextElement(
|
||||
&CEditElement::FindLeafAll,0 );
|
||||
while (pLeaf) {
|
||||
ED_LinkId linkId = pLeaf->Leaf()->GetHREF();
|
||||
if (linkId && !pEditBuffer->linkManager.GetAdjusted(linkId)) {
|
||||
pEditBuffer->linkManager.AdjustLink(linkId, pBaseURL, NULL, NULL);
|
||||
pEditBuffer->linkManager.SetAdjusted(linkId,TRUE);
|
||||
}
|
||||
pLeaf = pLeaf->FindNextElement(&CEditElement::FindLeafAll,0 );
|
||||
}
|
||||
|
||||
// Regular images.
|
||||
CEditElement *pImage = pEditBuffer->m_pRoot->FindNextElement(
|
||||
&CEditElement::FindImage, 0 );
|
||||
while( pImage ){
|
||||
pImageData = pImage->Image()->GetImageData();
|
||||
if( pImageData ){
|
||||
if( pImageData->pSrc && *pImageData->pSrc ){
|
||||
char * pOld = XP_STRDUP(pImageData->pSrc);
|
||||
pAbsolute = NET_MakeAbsoluteURL( pBaseURL, pImageData->pSrc );
|
||||
if( pAbsolute ){
|
||||
XP_FREE(pImageData->pSrc);
|
||||
pImageData->pSrc = pAbsolute;
|
||||
}
|
||||
}
|
||||
if( pImageData->pLowSrc && *pImageData->pLowSrc){
|
||||
pAbsolute = NET_MakeAbsoluteURL( pBaseURL, pImageData->pLowSrc );
|
||||
if( pAbsolute ){
|
||||
XP_FREE(pImageData->pLowSrc);
|
||||
pImageData->pLowSrc = pAbsolute;
|
||||
}
|
||||
}
|
||||
pImage->Image()->SetImageData( pImageData );
|
||||
edt_FreeImageData( pImageData );
|
||||
}
|
||||
pImage = pImage->FindNextElement( &CEditElement::FindImage, 0 );
|
||||
}
|
||||
|
||||
// If there is a background Image, make it absolute also
|
||||
if( pPageData->pBackgroundImage && *pPageData->pBackgroundImage){
|
||||
pAbsolute = NET_MakeAbsoluteURL( pBaseURL, pPageData->pBackgroundImage );
|
||||
if( pAbsolute ){
|
||||
XP_FREE(pPageData->pBackgroundImage);
|
||||
pPageData->pBackgroundImage = pAbsolute;
|
||||
}
|
||||
}
|
||||
|
||||
// Change context's "title" string
|
||||
XP_FREEIF(pMWContext->title);
|
||||
pMWContext->title = NULL;
|
||||
pMWContext->is_new_document = TRUE;
|
||||
|
||||
// Change the history entry data
|
||||
History_entry * pEntry = SHIST_GetCurrent(&(pMWContext->hist));
|
||||
if(pEntry ){
|
||||
XP_FREEIF(pEntry->address);
|
||||
pEntry->address = XP_STRDUP(pUntitled);
|
||||
XP_FREEIF(pEntry->title);
|
||||
}
|
||||
// Layout uses this as the base URL for all links and images
|
||||
LO_SetBaseURL( pMWContext, pUntitled );
|
||||
|
||||
// Cleat the old title in page data
|
||||
XP_FREEIF(pPageData->pTitle);
|
||||
|
||||
// This will set new background image,
|
||||
// call FE_SetDocTitle() with new "file://Untitled" string,
|
||||
// and refresh the layout of entire doc
|
||||
pEditBuffer->SetPageData(pPageData);
|
||||
|
||||
pEditBuffer->FreePageData(pPageData);
|
||||
pEditBuffer->ConvertCurrentDocToNewDoc();
|
||||
}
|
||||
|
||||
char * EDT_GetFilename(char * pURL, XP_Bool bMustHaveExtension)
|
||||
|
|
|
@ -74,6 +74,14 @@
|
|||
#define ICON_X_OFFSET 4
|
||||
#define ICON_Y_OFFSET 4
|
||||
|
||||
/* Moved from laytags.c so Composer can use them */
|
||||
#define MIN_FONT_SIZE 1
|
||||
#define MAX_FONT_SIZE 7
|
||||
|
||||
#define DEFAULT_BASE_POINT_SIZE 12
|
||||
#define MIN_POINT_SIZE 1
|
||||
#define MAX_POINT_SIZE 1600
|
||||
|
||||
#ifdef EDITOR
|
||||
extern char* lo_alignStrings[];
|
||||
#endif
|
||||
|
|
|
@ -59,12 +59,15 @@
|
|||
#define LIST_MARGIN_INC (FEUNITS_X(40, context))
|
||||
#define MQUOTE_MARGIN_INC (LIST_MARGIN_INC / 3)
|
||||
|
||||
#if 0
|
||||
/* cmanske: Moved to layout.h so Composer can use them */
|
||||
#define MIN_FONT_SIZE 1
|
||||
#define MAX_FONT_SIZE 7
|
||||
|
||||
#define DEFAULT_BASE_POINT_SIZE 12
|
||||
#define MIN_POINT_SIZE 1
|
||||
#define MAX_POINT_SIZE 1600
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BASE_FONT_WEIGHT 400
|
||||
#define MIN_FONT_WEIGHT 100
|
||||
|
|
Загрузка…
Ссылка в новой задаче