コード例 #1
0
/*
** Free up quantizer information attached to ic. If this is the last
** quantizer then free up the sample range limit table.
*/
void
il_free_quantize(il_container *ic)
{
    my_cquantize_ptr cquantize = (my_cquantize_ptr) ic->quantize;
    int i;

    if (cquantize) 
    {
#ifdef DEBUG
		if (il_debug > 5) 
			XP_TRACE(("il: 0x%x: free quantize", ic));
#endif
		for (i = 0; i < 3; i++) 
		{
			if (cquantize->fserrors[i]) 
			{
				XP_FREE(cquantize->fserrors[i]);
				cquantize->fserrors[i] = 0;
			}
		}

		XP_FREE(cquantize);
		ic->quantize = 0;
    }
}
コード例 #2
0
NET_StreamClass *
OLE_ViewStream(int format_out, void *pDataObj, URL_Struct *urls,
              MWContext *pContext)
{
    NET_StreamClass *stream = nil, *viewstream;
	char *org_content_type;
    
    if (!(stream = XP_NEW_ZAP(NET_StreamClass))) {
		XP_TRACE(("OLE_ViewStream memory lossage"));
		return 0;
	}
	
    stream->name           = "ole viewer";
    stream->complete       = ole_view_complete;
    stream->abort          = ole_view_abort;
    stream->is_write_ready = ole_view_write_ready;
    stream->data_object    = NULL;
    stream->window_id      = pContext;
    stream->put_block      = (MKStreamWriteFunc)ole_view_write;

	org_content_type = urls->content_type; 
	urls->content_type = 0;
	StrAllocCopy(urls->content_type, TEXT_HTML);
	urls->is_binary = 1;	/* secret flag for mail-to save as */

	if((viewstream=NET_StreamBuilder(format_out, urls, pContext)) != 0)
	{
        char *buffer = (char*)
            XP_ALLOC(XP_STRLEN(fakehtml) + XP_STRLEN(urls->address) + 1);

        if (buffer)
        {
            XP_SPRINTF(buffer, fakehtml, urls->address);
            (*viewstream->put_block)(viewstream,
                                     buffer, XP_STRLEN(buffer));
            (*viewstream->complete)(viewstream);
            XP_FREE(buffer);
        }
	}

	/* XXX hack alert - this has to be set back for abort to work
       correctly */
	XP_FREE(urls->content_type);
	urls->content_type = org_content_type;

    return stream;
}
コード例 #3
0
METHODDEF void
output_message (j_common_ptr cinfo)
{
#ifdef DEBUG
  char buffer[JMSG_LENGTH_MAX];
  /* Create the message */
  (*cinfo->err->format_message) (cinfo, buffer);

 /* Send it to stderr, adding a newline */

#if defined(_WINDOWS) && !defined(_WIN32)
  printf("%s\n", buffer); 
#elif __MWERKS__ 
  XP_TRACE(("%s\n", buffer)); 
#else
  fprintf(stderr, "%s\n", buffer); 
#endif 
#endif 
}
コード例 #4
0
/* allocate and fill in the sample_range_limit table */
int
il_setup_quantize(void)
{
	JSAMPLE *table;
	int i;

	if(the_sample_range_limit)
		return TRUE;

	/* lost for ever */
	table = (JSAMPLE *)XP_ALLOC((5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
	if (!table) 
	{
		XP_TRACE(("il: range limit table lossage"));
		return FALSE;
	}

	table += (MAXJSAMPLE+1);	/* allow negative subscripts of simple table */
	the_sample_range_limit = table;

	/* First segment of "simple" table: limit[x] = 0 for x < 0 */
	MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));

	/* Main part of "simple" table: limit[x] = x */
	for (i = 0; i <= MAXJSAMPLE; i++)
		table[i] = (JSAMPLE) i;

	table += CENTERJSAMPLE;	/* Point to where post-IDCT table starts */

	/* End of simple table, rest of first half of post-IDCT table */
	for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
		table[i] = MAXJSAMPLE;

	/* Second half of post-IDCT table */
	MEMZERO(table + (2 * (MAXJSAMPLE+1)),
			(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
	MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
			the_sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));

	return TRUE;
}
コード例 #5
0
static void
lo_next_character(MWContext *context, lo_DocState *state, LO_Element **ele_loc,
	int32 *pos, Bool forward)
{
	INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(context);
	int16 win_csid = INTL_GetCSIWinCSID(c);
	LO_Element *eptr;
	int32 position;

	eptr = *ele_loc;
	position = *pos;

	/*
	 * If our current element is text, we may be able to just
	 * move inside of it.
	 */
	if (eptr->type == LO_TEXT)
	{
		if ((forward != FALSE)&&
			(position < (eptr->lo_text.text_len - 1)))
		{
#ifdef INTL_FIND	
			/*	Add by ftang to provide international find */
			position = INTL_NextCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, position );
#else
			position++;
#endif
			*ele_loc = eptr;
			*pos = position;
			return;
		}
		else if ((forward == FALSE)&&(position > 0))
		{
#ifdef INTL_FIND
			/*	Add by ftang to provide international find */
			position = INTL_PrevCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, position );
#else
			position--;
#endif
			*ele_loc = eptr;
			*pos = position;
			return;
		}
	}

	/*
	 * If we didn't return above, we need to move to a new element.
	 */
	if (forward != FALSE)
	{
		/*
		 * If no next element, see if this is a CELL we can
		 * hop out of.
		 */
		if (eptr->lo_any.next == NULL)
		{
			int32 no_loop_id;

			no_loop_id = eptr->lo_any.ele_id;

			/*
			 * Jump cell boundries if there is one
			 * between here and the next element.
			 */
			eptr = lo_JumpCellWall(context, state, eptr);

			/*
			 * If non-null eptr is the cell we were in, move
			 * to the next cell/element.
			 */
			if (eptr != NULL)
			{
				eptr = eptr->lo_any.next;
			}

			/*
			 * infinite loop prevention
			 */
			if ((eptr != NULL)&&(eptr->lo_any.ele_id <= no_loop_id))
			{
#ifdef DEBUG
XP_TRACE(("Find loop avoidance 1\n"));
#endif /* DEBUG */
				eptr = NULL;
			}
		}
		else
		{
			eptr = eptr->lo_any.next;
		}
	}
	else
	{
		/*
		 * If no previous element, see if this is a CELL we can
		 * hop out of.
		 */
		if (eptr->lo_any.prev == NULL)
		{
			int32 no_loop_id;

			no_loop_id = eptr->lo_any.ele_id;

			/*
			 * Jump cell boundries if there is one
			 * between here and the previous element.
			 */
			eptr = lo_JumpCellWall(context, state, eptr);

			/*
			 * If non-null eptr is the cell we were in, move
			 * to the previous cell/element.
			 */
			if (eptr != NULL)
			{
				eptr = eptr->lo_any.prev;
			}

			/*
			 * infinite loop prevention
			 */
			if ((eptr != NULL)&&(eptr->lo_any.ele_id >= no_loop_id))
			{
#ifdef DEBUG
XP_TRACE(("Find loop avoidance 2\n"));
#endif /* DEBUG */
				eptr = NULL;
			}
		}
		else
		{
			eptr = eptr->lo_any.prev;
		}
	}

	while (eptr != NULL)
	{
		if (eptr->type == LO_LINEFEED)
		{
			break;
		}
		else if ((eptr->type == LO_TEXT)&&(eptr->lo_text.text != NULL))
		{
			break;
		}
		else if (eptr->type == LO_CELL)
		{
			/*
			 * When we walk onto a cell, we need
			 * to walk into it if it isn't empty.
			 */
			if ((forward != FALSE)&&
			    (eptr->lo_cell.cell_list != NULL))
			{
				eptr = eptr->lo_cell.cell_list;
				continue;
			}
			else if ((forward == FALSE)&&
			         (eptr->lo_cell.cell_list_end != NULL))
			{
				eptr = eptr->lo_cell.cell_list_end;
				continue;
			}
		}

		/*
		 * Move forward or back to the next element
		 */
		if (forward != FALSE)
		{
			/*
			 * If no next element, see if this is a CELL we can
			 * hop out of.
			 */
			if (eptr->lo_any.next == NULL)
			{
				int32 no_loop_id;

				no_loop_id = eptr->lo_any.ele_id;

				/*
				 * Jump cell boundries if there is one
				 * between here and the next element.
				 */
				eptr = lo_JumpCellWall(context, state, eptr);

				/*
				 * If non-null eptr is the cell we were in, move
				 * to the next cell/element.
				 */
				if (eptr != NULL)
				{
					eptr = eptr->lo_any.next;
				}

				/*
				 * infinite loop prevention
				 */
				if ((eptr != NULL)&&(
					eptr->lo_any.ele_id <= no_loop_id))
				{
#ifdef DEBUG
XP_TRACE(("Find loop avoidance 3\n"));
#endif /* DEBUG */
					eptr = NULL;
				}
			}
			else
			{
				eptr = eptr->lo_any.next;
			}
		}
		else
		{
			/*
			 * If no previous element, see if this is a CELL we can
			 * hop out of.
			 */
			if (eptr->lo_any.prev == NULL)
			{
				int32 no_loop_id;

				no_loop_id = eptr->lo_any.ele_id;

				/*
				 * Jump cell boundries if there is one
				 * between here and the previous element.
				 */
				eptr = lo_JumpCellWall(context, state, eptr);

				/*
				 * If non-null eptr is the cell we were in, move
				 * to the previous cell/element.
				 */
				if (eptr != NULL)
				{
					eptr = eptr->lo_any.prev;
				}

				/*
				 * infinite loop prevention
				 */
				if ((eptr != NULL)&&
					(eptr->lo_any.ele_id >= no_loop_id))
				{
#ifdef DEBUG
XP_TRACE(("Find loop avoidance 4\n"));
#endif /* DEBUG */
					eptr = NULL;
				}
			}
			else
			{
				eptr = eptr->lo_any.prev;
			}
		}
	}
	if (eptr == NULL)
	{
		*ele_loc = NULL;
		*pos = 0;
	}
	else if (eptr->type == LO_TEXT)
	{
		*ele_loc = eptr;
		if (forward != FALSE)
		{
			*pos = 0;
		}
		else
		{
#ifdef INTL_FIND
			/*	Add by ftang to provide international find */
			if(eptr->lo_text.text_len == 0)
				position = 0;
			else
				position = INTL_PrevCharIdxInText(win_csid, (unsigned char*)eptr->lo_text.text, eptr->lo_text.text_len );
#else
			position = eptr->lo_text.text_len - 1;
			if (position < 0)
			{
				position = 0;
			}
#endif
			*pos = position;
		}
	}
	else if (eptr->type == LO_LINEFEED)
	{
		*ele_loc = eptr;
		*pos = 0;
	}
}
コード例 #6
0
NET_StreamClass *
IL_ViewStream(FO_Present_Types format_out, void *newshack, URL_Struct *urls,
              OPAQUE_CONTEXT *cx)
{
    IL_Stream *stream = nil, *viewstream;
	il_container *ic = nil;
	char *org_content_type;
    char *image_url;

	/* multi-part reconnect hack */

	ic = (il_container*)urls->fe_data;
	if(ic && ic->multi)
	{
		return IL_NewStream(format_out, IL_UNKNOWN, urls, cx);
	}

	/* Create stream object */
    if (!(stream = XP_NEW_ZAP(NET_StreamClass))) {
		XP_TRACE(("il: IL_ViewStream memory lossage"));
		return 0;
	}
	
    stream->name           = "image view";
    stream->complete       = il_view_complete;
    stream->abort          = il_view_abort;
    stream->is_write_ready = il_view_write_ready;
    stream->data_object    = NULL;
    stream->window_id      = cx;
    stream->put_block      = (MKStreamWriteFunc)il_view_write;

	ILTRACE(0,("il: new view stream, %s", urls->address));

	XP_ASSERT(!unconnected_stream);
	unconnected_stream = stream;
	unconnected_urls = urls;

	if(!newshack)
	{
        char *buffer;

		org_content_type = urls->content_type; 
		urls->content_type = 0;
		StrAllocCopy(urls->content_type, TEXT_HTML);
		urls->is_binary = 1;	/* secret flag for mail-to save as */

		/* Force layout to discard the old document and start a new one.
		   We do this so that the pre-fetched image request won't be
		   destroyed by a layout call to IL_DestroyImageGroup. */

		viewstream = NET_StreamBuilder(format_out, urls, cx);
		if (!viewstream) {
			XP_FREE(stream);
			return NULL;
		}
        buffer = XP_STRDUP("<HTML>");
        if (!buffer) {
            XP_FREE(stream);
            XP_FREE(viewstream);
            return NULL;
        }
		(*viewstream->put_block)(viewstream, buffer,
                                 XP_STRLEN(buffer)+1);
        XP_FREE(buffer);

	} /* !newshack */

	/* Prefetch the image.  We do this so that the image library can
	   process image data even if the parser is blocked on the fake IMG
	   tag that we send.  Note that this image request will persist until
	   the document is destroyed (when IL_DestroyImageGroup will be called.) */
    image_url = (char*) XP_ALLOC(XP_STRLEN(urls->address) + 29);
    if (!image_url) {
        XP_FREE(stream);
        XP_FREE(viewstream);
        return NULL;
    }
    XP_SPRINTF(image_url, "internal-external-reconnect:%s", urls->address);
    if (!il_load_image(cx, image_url, urls->force_reload)) {
        XP_FREE(stream);
        XP_FREE(viewstream);
        return NULL;
    }
    XP_FREE(image_url);

	if (!newshack) {
	    if (viewstream) {
            	char *buffer = (char*)
                XP_ALLOC(XP_STRLEN(fakehtml) + XP_STRLEN(urls->address) + 1);

            if (buffer)
            {
                XP_SPRINTF(buffer, fakehtml, urls->address);
                (*viewstream->put_block)(viewstream,
                                         buffer, XP_STRLEN(buffer));
                XP_FREE(buffer);
            }
			(*viewstream->complete)(viewstream);
		}

		/* this has to be set back for abort to work correctly */
		XP_FREE(urls->content_type);
		urls->content_type = org_content_type;
	} /* !newshack */

    return stream;
}
コード例 #7
0
PUBLIC NET_StreamClass *
CRAWL_CrawlerConverter(int format_out,
						void *data_object,
						URL_Struct *URL_s,
						MWContext  *window_id)
{
#if defined(XP_MAC)
#pragma unused(format_out, data_object)
#endif
	NET_StreamClass *stream = NULL;

	crawl_page_scan_stream *obj;

	TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));

	XP_TRACE(("CRAWL_CrawlerConverter: %d %s", URL_s->server_status, URL_s->address));

	if (URL_s->SARCache != NULL) {
		/* if the content length would exceed the cache limit, don't convert this */
		if (((uint32)URL_s->content_length >= (URL_s->SARCache->MaxSize - URL_s->SARCache->DiskCacheSize)) &&
			((uint32)URL_s->content_length < BOGUS_CONTENT_LENGTH)) {
			CRAWL_PageInfo page = URL_s->owner_data;
			XP_TRACE(("not converting %s", URL_s->address));
			if ((page->scan_complete_func != NULL) && (page->page_owner != NULL)) {
				page->scan_complete_func(page->page_owner, page);
				return(NULL);
			}
		}
	}

	stream = XP_NEW(NET_StreamClass);
	if(stream == NULL)
		return(NULL);

	obj = XP_NEW(crawl_page_scan_stream);
	if (obj == NULL)
	  {
		XP_FREE(stream);
		return(NULL);
	  }
	obj->parse_obj = CRAWL_MakeParseObj();			/* this object used to parse the page and destroyed 
												in completion or abort function */
	if (obj->parse_obj == NULL) return(NULL);
	obj->page = URL_s->owner_data;				/* this data was set in crawl_makePage */
	obj->page->lastModified = URL_s->last_modified;
	/* if there was a server error, read but don't parse the document */
	if ((URL_s->server_status >= 400) ||
		/* don't attempt to parse non-html */
		((XP_STRSTR(URL_s->content_type, TEXT_HTML) == NULL) &&
		 (XP_STRSTR(URL_s->content_type, INTERNAL_PARSER) == NULL))) {
		/* URL_s->dont_cache = PR_FALSE; */
		obj->page->dontFollow = PR_TRUE;
	}

	stream->name           = "Crawler Converter";
	stream->complete       = (MKStreamCompleteFunc) crawl_PageScanConvComplete;
	stream->abort          = (MKStreamAbortFunc) crawl_PageScanConvAbort;
	stream->put_block      = (MKStreamWriteFunc) crawl_PageScanConvPut;
	stream->is_write_ready = (MKStreamWriteReadyFunc) crawl_PageScanConvWriteReady;
	stream->data_object    = obj;  /* document info object */
	stream->window_id      = window_id;
	return(stream);
}
コード例 #8
0
void
lo_DisplayElement(MWContext *context, LO_Element *tptr,
				  int32 base_x, int32 base_y,
				  int32 x, int32 y,
				  uint32 width, uint32 height)
{
    LO_Any *any = &tptr->lo_any;
    XP_Rect bbox;
    
    lo_GetElementBbox(tptr, &bbox);
    XP_OffsetRect(&bbox, base_x, base_y);

    if (bbox.top >= (int32)(y + height))
		return;

    if (bbox.bottom <= y )
        return;

    if (bbox.left >= (int32)(x + width))
        return;

    if (bbox.right <= x )
		return;

    /* Temporarily translate to new coordinate system */
    any->x += base_x;
    any->y += base_y;

    switch (tptr->type)
    {
    case LO_TEXT:
		if (tptr->lo_text.text != NULL)
			lo_DisplayText(context, (LO_TextStruct *)tptr, FALSE);
		break;

    case LO_LINEFEED:
		lo_DisplayLineFeed(context, (LO_LinefeedStruct *)tptr, FALSE);
		break;

    case LO_HRULE:
		lo_DisplayHR(context, (LO_HorizRuleStruct *)tptr);
		break;

    case LO_FORM_ELE:
		lo_DisplayFormElement(context, (LO_FormElementStruct *)tptr);
		break;

    case LO_BULLET:
		lo_DisplayBullet(context, (LO_BulletStruct *)tptr);
		break;

    case LO_IMAGE:
        if (context->compositor) {
            /* Allow the compositor to start drawing the image. */
            lo_DisplayImage(context, (LO_ImageStruct *)tptr);
        }
        else {
            /* There is no compositor, so draw the image directly, with the
               appropriate clip. */
            lo_ClipImage(context,
                         (LO_ImageStruct *)tptr,
                         (x + base_x),
                         (y + base_y), width, height);
        }
		break;

    case LO_TABLE:
		lo_DisplayTable(context, (LO_TableStruct *)tptr);
		break;

    case LO_EMBED:
		lo_DisplayEmbed(context, (LO_EmbedStruct *)tptr);
		break;

#ifdef JAVA
    case LO_JAVA:
		lo_DisplayJavaApp(context, (LO_JavaAppStruct *)tptr);
		break;
#endif

    case LO_EDGE:
		lo_DisplayEdge(context, (LO_EdgeStruct *)tptr);
		break;

    case LO_CELL:
        /* If this cell is a container for an inflow layer (and
           therefore not a table cell), don't descend into the cell
           because the layer's painter function will handle its
           display. */
        if (((LO_CellStruct*)tptr)->cell_inflow_layer)
            break;

        /* cmanske: Order changed - display cell contents FIRST
         * so selection feedback near cell border is not wiped out
         * TODO: This doesn't work for images, which are display
         *  asynchronously. Need to add "observer" to image display
        */
		lo_DisplayCellContents(context, (LO_CellStruct *)tptr,
			    			   base_x, base_y, x, y, width, height);
		lo_DisplayCell(context, (LO_CellStruct *)tptr);
		break;

    case LO_SUBDOC:
    {
		LO_SubDocStruct *subdoc;
		int32 new_x, new_y;
		uint32 new_width, new_height;
		lo_DocState *sub_state;

		subdoc = (LO_SubDocStruct *)tptr;
		sub_state = (lo_DocState *)subdoc->state;

		if (sub_state == NULL)
		{
			break;
		}

		lo_DisplaySubDoc(context, subdoc);

		new_x = subdoc->x;
		new_y = subdoc->y;
		new_width = subdoc->x_offset + subdoc->width;
		new_height = subdoc->y_offset + subdoc->height;

		new_x = new_x - subdoc->x;
		new_y = new_y - subdoc->y;
		sub_state->base_x = subdoc->x +
			subdoc->x_offset + subdoc->border_width;
		sub_state->base_y = subdoc->y +
			subdoc->y_offset + subdoc->border_width;
		lo_RefreshDocumentArea(context, sub_state,
							   new_x, new_y, new_width, new_height);
    }
    break;

    case LO_PARAGRAPH:
    case LO_CENTER:
    case LO_MULTICOLUMN:
    case LO_LIST:
    case LO_DESCTITLE:
    case LO_DESCTEXT:
    case LO_BLOCKQUOTE:
    case LO_HEADING:
	case LO_SPAN:
      /* all non-display, doc-state mutating elements. */
      break;
    case LO_TEXTBLOCK:
      break;
    case LO_FLOAT:
    case LO_LAYER:
      break;
    default:
		XP_TRACE(("lo_DisplayElement(%p) skip element type = %d\n", tptr, tptr->type));
		break;
    }

    /* Restore original element's coordinates */
    any->x -= base_x;
    any->y -= base_y;
}
コード例 #9
0
void
LO_DUMP_RECT(XP_Rect *rect)
{
    XP_TRACE(("Compositing rectangle: [%3d,%3d]  %d x %d\n", rect->left, rect->top,
              rect->right - rect->left, rect->bottom - rect->top));
}