home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / layout / laylist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  152 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "xp.h"
  20. #include "pa_parse.h"
  21. #include "layout.h"
  22.  
  23. #ifdef PROFILE
  24. #pragma profile on
  25. #endif
  26.  
  27. lo_ListStack *
  28. lo_DefaultList(lo_DocState *state)
  29. {
  30.     lo_ListStack *lptr;
  31.  
  32.     lptr = XP_NEW(lo_ListStack);
  33.     if (lptr == NULL)
  34.     {
  35.         return(NULL);
  36.     }
  37.  
  38.     lptr->type = P_UNKNOWN;
  39.     lptr->level = 0;
  40.     lptr->value = 1;
  41.     lptr->compact = FALSE;
  42.     lptr->bullet_type = BULLET_BASIC;
  43.     lptr->quote_type = QUOTE_NONE;
  44.     lptr->old_left_margin = state->win_left;
  45.     lptr->old_right_margin = state->win_width - state->win_right;
  46.     lptr->next = NULL;
  47.  
  48.     return(lptr);
  49. }
  50.  
  51.  
  52. /* mquote means quoted mail message */
  53. void
  54. lo_PushList(lo_DocState *state, PA_Tag *tag, int8 quote_type)
  55. {
  56.     lo_ListStack *lptr;
  57.     intn bullet_type;
  58.     int32 val;
  59.     Bool no_level;
  60.     int32 mquote_line_num = 0;
  61.     int32 mquote_x = 0;
  62.  
  63.     val = 1;
  64.     no_level = FALSE;
  65.     switch (tag->type)
  66.     {
  67.         /*
  68.          * Blockquotes and multicolumns pretend to be the current
  69.          * list type, unless the current list is nothing.
  70.          * Now we have DIV tags that can act like MULTICOL tags.
  71.          */
  72.         case P_MULTICOLUMN:
  73.         case P_DIVISION:
  74.         case P_BLOCKQUOTE:
  75.             bullet_type = state->list_stack->bullet_type;
  76.             no_level = TRUE;
  77.             if (state->list_stack->type != P_UNKNOWN)
  78.             {
  79.                 tag->type = state->list_stack->type;
  80.             }
  81.             val = state->list_stack->value;
  82.             break;
  83.         case P_NUM_LIST:
  84.             bullet_type = BULLET_NUM;
  85.             break;
  86.         case P_UNUM_LIST:
  87.         case P_MENU:
  88.         case P_DIRECTORY:
  89.             bullet_type = BULLET_BASIC;
  90.             break;
  91.         default:
  92.             bullet_type = BULLET_NONE;
  93.             break;
  94.     }
  95.  
  96.     /* Support for mail compose quoting. */
  97.     if (quote_type != QUOTE_NONE) 
  98.     {
  99.         mquote_line_num = state->line_num;
  100.         mquote_x = state->left_margin;
  101.     }
  102.  
  103.     lptr = XP_NEW(lo_ListStack);
  104.     if (lptr == NULL)
  105.     {
  106.         state->top_state->out_of_memory = TRUE;
  107.         return;
  108.     }
  109.  
  110.     lptr->type = tag->type;
  111.     if (no_level != FALSE)
  112.     {
  113.         lptr->level = state->list_stack->level;
  114.     }
  115.     else
  116.     {
  117.         lptr->level = state->list_stack->level + 1;
  118.     }
  119.     lptr->compact = FALSE;
  120.     lptr->value = val;
  121.     lptr->bullet_type = bullet_type;
  122.     lptr->old_left_margin = state->left_margin;
  123.     lptr->old_right_margin = state->right_margin;
  124.     lptr->quote_type = quote_type;
  125.     lptr->mquote_line_num = mquote_line_num;
  126.     lptr->mquote_x = mquote_x;
  127.  
  128.     lptr->next = state->list_stack;
  129.     state->list_stack = lptr;
  130. }
  131.  
  132.  
  133. lo_ListStack *
  134. lo_PopList(lo_DocState *state, PA_Tag *tag)
  135. {
  136.     lo_ListStack *lptr;
  137.  
  138.     lptr = state->list_stack;
  139.     if ((lptr->type == P_UNKNOWN)||(lptr->next == NULL))
  140.     {
  141.         return(NULL);
  142.     }
  143.  
  144.     state->list_stack = lptr->next;
  145.     lptr->next = NULL;
  146.     return(lptr);
  147. }
  148.  
  149. #ifdef PROFILE
  150. #pragma profile off
  151. #endif
  152.