Bugs numbers 78936,78922,78925,78926,78934,78939,105689,139286,139301,139359

This commit is contained in:
mjudge 1998-06-19 04:00:49 +00:00
parent ec3f238ac8
commit 158908fb19
5 changed files with 131 additions and 40 deletions

View File

@ -3159,6 +3159,7 @@ public:
void RepairAndSet(CEditSelection& selection);
XP_Bool Reduce( CEditElement* pRoot );
void Protect( CEditElement *pRoot ); //protect certain things from reduction.
void NormalizeTree( );
// Change Table and alls cell width data to match

View File

@ -9834,6 +9834,34 @@ XP_Bool CEditBuffer::Reduce( CEditElement *pRoot ){
return pRoot->Reduce( this );
}
void
CEditBuffer::Protect( CEditElement *pRoot )
{
// work backwards so when children go away, we don't have
// lossage.
CEditElement *pChild, *pNext;
pChild = pRoot->GetChild();
if (!pChild) //maybe we need to protect this?
{
//if isContainer and parent and parent->islist protect!!
if (pRoot->IsContainer() && pRoot->GetParent() && pRoot->GetParent()->IsList())
{
//add new text element
CEditTextElement *t_ele=new CEditTextElement(pRoot, NULL);
}
}
while( pChild )
{
pNext = pChild->GetNextSibling();
Protect( pChild );
pChild = pNext;
}
}
//
//
//
@ -9915,6 +9943,8 @@ void CEditBuffer::FinishedLoad2()
m_pCreationCursor = NULL;
// protect empty SOME empty lines! //i.e. list items with nothing in their containers
Protect( m_pRoot );
// Get rid of empty items.
Reduce( m_pRoot );

View File

@ -658,6 +658,8 @@ 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 (pPrevious && pPrevious->GetType() == P_DIVISION)
pPrevious = pPrevious->GetChild();
#if 0
if ( ! pPrevious ) {
#else
@ -672,6 +674,8 @@ void CEditElement::EnsureSelectableSiblings(CEditBuffer* pBuffer)
{
// Make sure the next sibling exists and is container
CEditElement* pNext = GetNextSibling();
if (pNext && pNext->GetType() == P_DIVISION)
pNext = pNext->GetChild();
#if 0
if ( ! pNext || pNext->IsEndContainer() ) {
#else
@ -6527,6 +6531,27 @@ XP_Bool CEditContainerElement::ForcesDoubleSpacedNextLine() {
return BitSet( edt_setContainerHasLineAfter, GetType() );
}
//helper function
//default == left!
PRIVATE XP_Bool CompareAlignments(ED_Alignment x, ED_Alignment y)
{
if (x == y)
return TRUE;
if ( ((x == ED_ALIGN_ABSCENTER) || (x == ED_ALIGN_CENTER))
&& ((y == ED_ALIGN_ABSCENTER) || (y == ED_ALIGN_CENTER)) )
return TRUE;
if ( ((x == ED_ALIGN_DEFAULT) || (x == ED_ALIGN_LEFT))
&& ((y == ED_ALIGN_DEFAULT) || (y == ED_ALIGN_LEFT)) )
return TRUE;
if ( ((x == ED_ALIGN_ABSBOTTOM) || (x == ED_ALIGN_BOTTOM))
&& ((y == ED_ALIGN_ABSBOTTOM) || (y == ED_ALIGN_BOTTOM)) )
return TRUE;
if ( ((x == ED_ALIGN_ABSTOP) || (x == ED_ALIGN_TOP))
&& ((y == ED_ALIGN_ABSTOP) || (y == ED_ALIGN_TOP)) )
return TRUE;
return FALSE;
}
void CEditContainerElement::AdjustContainers( CEditBuffer *pBuffer ){
if( GetType() == P_PARAGRAPH
@ -6537,18 +6562,34 @@ void CEditContainerElement::AdjustContainers( CEditBuffer *pBuffer ){
// Convert to internal paragraph type
//
SetType( P_NSDT );
CEditContainerElement *pPrev = (CEditContainerElement*) GetPreviousSibling();
CEditElement *pPreviousSibling = (CEditElement*) GetPreviousSibling();
CEditContainerElement *pPrev = 0;
CEditContainerElement *pNext = (CEditContainerElement*) GetNextSibling();
//
// Just some paranoia
//
if ( pPrev && !pPrev->IsContainer() ) pPrev = 0;
if ( pPreviousSibling && pPreviousSibling->IsContainer() )
pPrev = (CEditContainerElement*) pPreviousSibling;
if ( pNext && !pNext->IsContainer() ) pNext = 0;
if ( !pNext || !CompareAlignments(GetAlignment(), pNext->GetAlignment())){
CEditContainerElement *pNew;
pNew = CEditContainerElement::NewDefaultContainer( 0,
GetAlignment() );
// g++ thinks the following value is not used, but it's mistaken.
// The constructor auto-inserts the element into the tree.
(void) new CEditBreakElement(pNew, 0);
pNew->InsertAfter( this );
}
//
// If there is a previous container, append an empty single spaced
// paragraph before this one.
// paragraph before this one. also append an empty single spaced paragraph if it was a table.
//
if( pPrev && !pPrev->ForcesDoubleSpacedNextLine() ){
if ((pPreviousSibling && pPreviousSibling->GetType() == P_TABLE) ||
(pPreviousSibling && pPreviousSibling->GetType() == P_DIVISION) ||
( pPrev && !pPrev->ForcesDoubleSpacedNextLine()) )
{
CEditContainerElement *pNew;
pNew = CEditContainerElement::NewDefaultContainer( 0,
GetAlignment() );
@ -6712,43 +6753,27 @@ XP_Bool CEditContainerElement::SupportsAlign(){
return BitSet( edt_setContainerSupportsAlign, GetType() );
}
XP_Bool CEditContainerElement::IsImplicitBreak() {
XP_ASSERT( GetType() == P_NSDT );
CEditElement *pPrev;
return ( (pPrev = GetPreviousSibling()) == 0
|| !pPrev->IsContainer()
|| pPrev->Container()->ForcesDoubleSpacedNextLine()
// || ((pPrev->Container()->GetAlignment() == ED_ALIGN_RIGHT) && (GetAlignment() != ED_ALIGN_RIGHT) )
// || ((pPrev->Container()->GetAlignment() != ED_ALIGN_RIGHT) && (GetAlignment() == ED_ALIGN_RIGHT) )
#if 0
|| ((pPrev->Container()->GetAlignment() == ED_ALIGN_RIGHT) && (GetAlignment() != ED_ALIGN_RIGHT) )
|| ((pPrev->Container()->GetAlignment() != ED_ALIGN_RIGHT) && (GetAlignment() == ED_ALIGN_RIGHT) )
#endif
);
}
//helper function
//default == left!
PRIVATE XP_Bool CompareAlignments(ED_Alignment x, ED_Alignment y)
{
if (x == y)
return TRUE;
if ( ((x == ED_ALIGN_ABSCENTER) || (x == ED_ALIGN_CENTER))
&& ((y == ED_ALIGN_ABSCENTER) || (y == ED_ALIGN_CENTER)) )
return TRUE;
if ( ((x == ED_ALIGN_DEFAULT) || (x == ED_ALIGN_LEFT))
&& ((y == ED_ALIGN_DEFAULT) || (y == ED_ALIGN_LEFT)) )
return TRUE;
if ( ((x == ED_ALIGN_ABSBOTTOM) || (x == ED_ALIGN_BOTTOM))
&& ((y == ED_ALIGN_ABSBOTTOM) || (y == ED_ALIGN_BOTTOM)) )
return TRUE;
if ( ((x == ED_ALIGN_ABSTOP) || (x == ED_ALIGN_TOP))
&& ((y == ED_ALIGN_ABSTOP) || (y == ED_ALIGN_TOP)) )
return TRUE;
return FALSE;
}
// 0..2, where 0 = not in pseudo paragraph.
// 1 = first container of pseudo paragraph.
// 2 = second container of pseudo paragraph.
// 3 = after list, <P> does NOT cause a blank line to be drawn above paragraph. we need <P><BR>
int16 CEditContainerElement::GetPseudoParagraphState(){
if( GetType() != P_NSDT ){
return 0;
@ -6783,12 +6808,14 @@ int16 CEditContainerElement::GetPseudoParagraphState(){
return 4;
}
if ( !IsEmpty() && pPrevContainer->GetType() == P_NSDT && pPrevContainer->IsEmpty()
&& (!pPrevPrev || pPrevPrev->GetType()!= P_TABLE)//tables do not enforce a break! <P> is sufficient for 1 break!
&& (!pPrevPrevContainer || pPrevPrevContainer->GetType() != P_NSDT) )
{
return 3;
}
if ( ! IsEmpty() && pPrevContainer->GetType() == P_NSDT
&& pPrevContainer->IsEmpty() ) {
if ( ! IsEmpty() && ((pPrevContainer->GetType() == P_NSDT
&& pPrevContainer->IsEmpty())|| pPrevPrev && pPrevPrev->GetType() == P_TABLE) )
{
return 2;
}
// Check for state 1
@ -6802,13 +6829,6 @@ int16 CEditContainerElement::GetPseudoParagraphState(){
pPrevContainer= GetPreviousNonEmptyContainer(); //check nonempty!
if ( !IsEmpty() && pPrevContainer && !CompareAlignments(pPrevContainer->GetAlignment(),GetAlignment()) )
return 1;
/* if ( IsEmpty() && pNext && pNext->IsContainer()
&& pNext->Container()->GetType() == P_NSDT
&& pNext->Container()->IsEmpty()
&& pPrevContainer->IsEmpty()
) {
return 4;
}*/
return 0;
}
@ -6828,6 +6848,8 @@ void CEditContainerElement::PrintOpen( CPrintState *pPrintState ){
if( GetType() == P_NSDT ){
int16 ppState = GetPseudoParagraphState();
CEditContainerElement* pPrevContainer=GetPreviousNonEmptyContainer();
if (pPrevContainer && pPrevContainer->GetType()!=P_NSDT)
pPrevContainer=NULL;//all bets are off
if (( GetAlignment() == ED_ALIGN_RIGHT && ! IsEmpty()) && ( !pPrevContainer || (pPrevContainer->GetAlignment() != ED_ALIGN_RIGHT ) )){
pPrintState->m_pOut->Printf( "\n");
pPrintState->m_iCharPos = pPrintState->m_pOut->Printf( "<DIV ALIGN=right>");
@ -9396,8 +9418,9 @@ void CEditImageElement::PrintOpen( CPrintState *pPrintState ){
pS1 = " ";
pS2 = m_href->pExtra;
}
//added '\n' to HREF for visual purposes
pPrintState->m_iCharPos += pPrintState->m_pOut->Printf(
"<A HREF=%s%s%s>", edt_MakeParamString(m_href->hrefStr), pS1, pS2 );
"<A HREF=%s%s%s>\n", edt_MakeParamString(m_href->hrefStr), pS1, pS2 );
}
// Use special versions of params which has BORDER removed if it's the default

View File

@ -1226,8 +1226,9 @@ PRIVATE
Bool lo_ValidEditableElementIncludingParagraphMarks(MWContext *context, LO_Element* pElement)
{
return lo_ValidEditableElement(context, pElement)
|| (pElement->type== LO_LINEFEED
&& pElement->lo_linefeed.break_type == LO_LINEFEED_BREAK_PARAGRAPH);
|| (pElement->type== LO_LINEFEED)
&& (pElement->lo_linefeed.break_type == LO_LINEFEED_BREAK_PARAGRAPH ||
pElement->lo_linefeed.break_type == LO_LINEFEED_BREAK_HARD);
}
/* Moves by one editable position forward or backward. Returns FALSE if it couldn't.

View File

@ -955,7 +955,7 @@ lo_ProcessDescTitleElement(MWContext *context,
else
{
lo_SetLineBreakState(context, state, LO_LINEFEED_BREAK_SOFT,
LO_CLEAR_NONE, 1, !in_relayout);
LO_CLEAR_NONE, 1, in_relayout);
}
state->x = state->left_margin;
}
@ -4413,6 +4413,42 @@ XP_TRACE(("lo_LayoutTag(%d)\n", tag->type));
* the width of one list indention.
*/
case P_NSDT:
/*
* The start of a list infers the end of
* the HEAD section of the HTML and starts the BODY
*/
state->top_state->in_head = FALSE;
state->top_state->in_body = TRUE;
if (state->in_paragraph != FALSE)
{
lo_CloseParagraph(context, &state, tag, 2);
}
if (tag->is_end == FALSE)
{
/*
* Undent to the left for a title if necessary.
*/
if ((state->list_stack->level != 0)&&
(state->list_stack->type == P_DESC_LIST)&&
(state->list_stack->value > 1))
{
state->list_stack->old_left_margin -=
LIST_MARGIN_INC;
state->list_stack->value = 1;
}
if (state->linefeed_state >= 1)
{
lo_FindLineMargins(context, state,FALSE);
}
else
{
lo_SetSoftLineBreakState(context,state,FALSE,1);
}
state->x = state->left_margin;
}
break;
case P_DESC_TITLE:
/*
* The start of a list infers the end of