当前位置: 首页>>代码示例>>C++>>正文


C++ UT_ByteBuf::append方法代码示例

本文整理汇总了C++中UT_ByteBuf::append方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_ByteBuf::append方法的具体用法?C++ UT_ByteBuf::append怎么用?C++ UT_ByteBuf::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UT_ByteBuf的用法示例。


在下文中一共展示了UT_ByteBuf::append方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write_png_data

/*! Write data to the PNG stream
 *
 * This is a callback function for the PNG library. It is called when 
 * some data needs to writting to the PNG file. We have implemented it as
 * writing to a ByteBuf.
 */
static void write_png_data(png_structp png_ptr, png_bytep data, 
                           png_size_t length) 
{
	UT_ByteBuf* bb = (UT_ByteBuf*) (png_get_io_ptr(png_ptr));
    UT_DEBUGMSG(("PSION: write_png_data: %d bytes\n",length));
	bb->append(data,length);
}
开发者ID:hfiguiere,项目名称:abiword,代码行数:13,代码来源:ie_imp_Psion.cpp

示例2: _write_png

static void _write_png( png_structp png_ptr, 
		        png_bytep data, 
		        png_size_t length )
{
  UT_ByteBuf* bb = static_cast<UT_ByteBuf*>(png_get_io_ptr(png_ptr));
  bb->append(data, length);
}
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:7,代码来源:ie_impGraphic_Win32Native.cpp

示例3: _loadStream

/**
 * Code from Dom Lachowicz and/or Robert Staudinger.
 */
UT_Error ODi_Abi_Data::_loadStream (GsfInfile* oo,
                                   const char* stream,
                                   UT_ByteBuf& buf ) {
    guint8 const *data = NULL;
    size_t len = 0;
    static const size_t BUF_SZ = 4096;
  
    buf.truncate (0);
    GsfInput * input = gsf_infile_child_by_name(oo, stream);

    if (!input)
        return UT_ERROR;
  
    if (gsf_input_size (input) > 0) {
        while ((len = gsf_input_remaining (input)) > 0) {
            len = UT_MIN (len, BUF_SZ);
            if (NULL == (data = gsf_input_read (input, len, NULL))) {
                g_object_unref (G_OBJECT (input));
                return UT_ERROR;
            }
            buf.append ((const UT_Byte *)data, len);
        }
    }
  
    g_object_unref (G_OBJECT (input));
    return UT_OK;
}
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:30,代码来源:ODi_Abi_Data.cpp

示例4: _outputData

/*!
  Output text buffer to stream
 \param data Buffer to output
 \param length Size of buffer
 */
void Text_Listener::_outputData(const UT_UCSChar * data, UT_uint32 length)
{
	UT_ByteBuf bBuf;
	const UT_UCSChar * pData;

	int mbLen;
	char pC[MY_MB_LEN_MAX];

	if (m_bFirstWrite)
	{
		if (m_szEncoding)
			m_wctomb.setOutCharset(m_szEncoding);

		_genLineBreak();

		if (m_bUseBOM)
		{
			_genBOM();
			m_pie->write(static_cast<const char *>(m_mbBOM),m_iBOMLen);
		}

		m_bFirstWrite = false;
	}

	for (pData=data; (pData<data+length); ++pData)
	{
		// We let any UCS_LF's (forced line breaks) go out as is.
		if (*pData==UCS_LF)
			bBuf.append(reinterpret_cast<UT_Byte *>(m_mbLineBreak),m_iLineBreakLen);
		else
		{
			if (!_wctomb(pC,mbLen,*pData))
			{
				UT_ASSERT_HARMLESS(!m_bIs16Bit);
				mbLen=1;
				pC[0]='?';
				m_wctomb.initialize();
			}
			UT_ASSERT_HARMLESS(mbLen>=1);
			bBuf.append(reinterpret_cast<const UT_Byte *>(pC),mbLen);
		}
	}

	m_pie->write(reinterpret_cast<const char *>(bBuf.getPointer(0)),bBuf.getLength());
}
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:50,代码来源:ie_exp_Text.cpp

示例5: convCallback

static gboolean convCallback(const gchar *buf,
			     gsize count,
				 GError ** /*error*/,
			     gpointer byteBuf)
{
  UT_ByteBuf * pBB = reinterpret_cast<UT_ByteBuf *>(byteBuf);
  pBB->append(reinterpret_cast<const UT_Byte *>(buf),count);
  return TRUE;
}
开发者ID:Distrotech,项目名称:abiword,代码行数:9,代码来源:gr_UnixImage.cpp

示例6: CreateBMPFile

//
// Creates a BITMAP file from a handle 
//
static void CreateBMPFile(HWND hwnd, UT_ByteBuf & pBB, PBITMAPINFO pbi, 
			  HBITMAP hBMP, HDC hDC) 
{ 
  BITMAPFILEHEADER hdr;       // bitmap file-header 
  PBITMAPINFOHEADER pbih;     // bitmap info-header 
  LPBYTE lpBits;              // memory pointer 	
  
  if (!hBMP) return;
  
  pbih = (PBITMAPINFOHEADER) pbi; 
  lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);

  if (!lpBits) return;
  
  // Retrieve the color table (RGBQUAD array) and the bits 
  // (array of palette indices) from the DIB. 
  if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, 
		 DIB_RGB_COLORS)) 
    return;
  
  hdr.bfType = 0x4d42;        // 0x42 = "B" 0x4d = "M" 
  // Compute the size of the entire file. 
  hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + 
			pbih->biSize + pbih->biClrUsed 
			* sizeof(RGBQUAD) + pbih->biSizeImage); 
  hdr.bfReserved1 = 0; 
  hdr.bfReserved2 = 0; 
  
  // Compute the offset to the array of color indices. 
  hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + 
    pbih->biSize + pbih->biClrUsed 
    * sizeof (RGBQUAD); 
  
  pBB.truncate (0);
  
  // Copy the BITMAPFILEHEADER into the .BMP file. 
  pBB.append ((const UT_Byte *)&hdr, sizeof(BITMAPFILEHEADER));
  pBB.append ((const UT_Byte *)pbih, sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof (RGBQUAD));
  
  // Copy the array of color indices into the .BMP file.         
  pBB.append ((const UT_Byte *)lpBits, (int) pbih->biSizeImage);
  
  GlobalFree((HGLOBAL)lpBits);
}
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:47,代码来源:ie_impGraphic_Win32Native.cpp

示例7: convertToBuffer

bool GR_VectorImage::convertToBuffer(UT_ByteBuf** ppBB) const
{
  UT_ByteBuf* pBB = new UT_ByteBuf;

  bool bCopied = pBB->append(m_pBB_Image->getPointer(0), m_pBB_Image->getLength());

  if (!bCopied) DELETEP(pBB);

  *ppBB = pBB;

  return bCopied;
}
开发者ID:Distrotech,项目名称:abiword,代码行数:12,代码来源:gr_VectorImage.cpp

示例8: DocRange

bool AP_Win32App::_cacheClipboardDoc(PD_DocumentRange *pDocRange)
{
	UT_return_val_if_fail(m_pClipboard && pDocRange, false);

	UT_ByteBuf buf;
	UT_Error status;;
	UT_Byte b = 0;

	IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
	if (pExpRtf)
	{
		status = pExpRtf->copyToBuffer(pDocRange,&buf);

		if(status != UT_OK)
			return false;
			
		buf.append(&b,1);			// NULL terminate the string
		DELETEP(pExpRtf);
	}
	else
	{
		return false;
	}

	// now create a subdocument ...
	PD_Document * pDoc = new PD_Document();

	if(!pDoc)
		return false;
	
	pDoc->newDocument();
	
	PD_DocumentRange DocRange(pDoc, 2, 2);
	
	IE_Imp * pImp = 0;
	IE_Imp::constructImporter(pDoc, IE_Imp::fileTypeForSuffix(".rtf"),&pImp,0);

	if(pImp)
	{
		pImp->pasteFromBuffer(&DocRange,buf.getPointer(0),buf.getLength(),NULL);
		delete pImp;
	}
	else
	{
		return false;
	}
	
	m_pClipboard->setClipboardDoc(pDoc);
	return true;
}
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:50,代码来源:ap_Win32App.cpp

示例9: convertGraphicToSVG


//.........这里部分代码省略.........
	read_info.len = pBBwmf->getLength();
	read_info.pos = 0;

	err = wmf_bbuf_input (API,AbiWord_WMF_read,AbiWord_WMF_seek,AbiWord_WMF_tell,(void *) &read_info);
	if (err != wmf_E_None) {
		UT_DEBUGMSG(("IE_ImpGraphic_WMF::convertGraphic Bad input set\n"));
		goto ErrorHandler;
	}

	err = wmf_scan (API,0,&(bbox));
	status = explicit_wmf_error ("wmf_scan",err);

	if (status)
	{	
		goto ErrorHandler;
	}

/* Okay, got this far, everything seems cool.
 */
	ddata = WMF_SVG_GetData (API);

	ddata->out = wmf_stream_create(API, NULL);

	ddata->Description = (char *)Default_Description;

	ddata->bbox = bbox;

	wmf_display_size (API,&disp_width,&disp_height,72,72);

	wmf_width  = (float) disp_width;
	wmf_height = (float) disp_height;

	if ((wmf_width <= 0) || (wmf_height <= 0))
	{	fputs ("Bad image size - but this error shouldn't occur...\n",stderr);
		status = 1;
		wmf_api_destroy (API);
		return UT_ERROR;
	}

	if ((wmf_width  > (float) max_width )
	 || (wmf_height > (float) max_height))
	{	if (max_flags == 0) max_flags = WMF2SVG_MAXPECT;
	}

	if (max_flags == WMF2SVG_MAXPECT) /* scale the image */
	{	ratio_wmf = wmf_height / wmf_width;
		ratio_bounds = (float) max_height / (float) max_width;

		if (ratio_wmf > ratio_bounds)
		{	ddata->height = max_height;
			ddata->width  = (unsigned int) ((float) ddata->height / ratio_wmf);
		}
		else
		{	ddata->width  = max_width;
			ddata->height = (unsigned int) ((float) ddata->width  * ratio_wmf);
		}
	}
	else if (max_flags == WMF2SVG_MAXSIZE) /* bizarre option, really */
	{	ddata->width  = max_width;
		ddata->height = max_height;
	}
	else
	{	ddata->width  = (unsigned int) ceil ((double) wmf_width );
		ddata->height = (unsigned int) ceil ((double) wmf_height);
	}

	ddata->flags |= WMF_SVG_INLINE_IMAGES;

	ddata->flags |= WMF_GD_OUTPUT_MEMORY | WMF_GD_OWN_BUFFER;

	if (status == 0)
	{	err = wmf_play (API,0,&(bbox));
		status = explicit_wmf_error ("wmf_play",err);
	}

	wmf_stream_destroy(API, ddata->out, &stream, &stream_len);

	if (status == 0) 
	{
		UT_ByteBuf* pBB = new UT_ByteBuf;
		pBB->append((const UT_Byte*)stream, (UT_uint32)stream_len);
		*ppBB = pBB;
		DELETEP(pBBwmf);
		wmf_free(API, stream);
		wmf_api_destroy (API);
		return UT_OK;
	}

ErrorHandler:
	DELETEP(pBBwmf);
	if(API) 
	{
		if(stream) 
		{
			wmf_free(API, stream);
		}
		wmf_api_destroy (API);
	}
	return UT_ERROR;
}
开发者ID:Distrotech,项目名称:abiword,代码行数:101,代码来源:ie_impGraphic_WMF.cpp

示例10: if

/*!
    copy data in required format to the clipboard
*/
bool AP_Win32App::_copyFmtToClipboard(PD_DocumentRange * pDocRange, const char * pszFmt)
{
	UT_return_val_if_fail(m_pClipboard && pszFmt, false);
	
	UT_ByteBuf buf;
	UT_Error status;;
	UT_Byte b = 0;

	if(0 == strcmp(AP_CLIPBOARD_TEXTPLAIN_8BIT, pszFmt))
	{
		IE_Exp_Text * pExpText = new IE_Exp_Text(pDocRange->m_pDoc);
		if (pExpText)
		{
			status = pExpText->copyToBuffer(pDocRange,&buf);

			if(status != UT_OK)
				return false;
			
			buf.append(&b,1);			// NULL terminate the string
			m_pClipboard->addData(AP_CLIPBOARD_TEXTPLAIN_8BIT,
								  (UT_Byte *)buf.getPointer(0),buf.getLength());
			DELETEP(pExpText);
			UT_DEBUGMSG(("CopyToClipboard: copying %d bytes in TEXTPLAIN format.\n",
						 buf.getLength()));
		}
		else
		{
			return false;
		}
		
	}
	else if(0 == strcmp(AP_CLIPBOARD_TEXTPLAIN_UCS2, pszFmt))
	{
		const char *szEnc = XAP_EncodingManager::get_instance()->getNativeUnicodeEncodingName(); 
		IE_Exp_Text * pExpUnicodeText = new IE_Exp_Text(pDocRange->m_pDoc,szEnc);
		if (pExpUnicodeText)
		{
			status = pExpUnicodeText->copyToBuffer(pDocRange,&buf);

			if(status != UT_OK)
				return false;
			
			UT_Byte b[2] = {0,0};
			buf.append(b,2);			// NULL terminate the string
			m_pClipboard->addData(AP_CLIPBOARD_TEXTPLAIN_UCS2,
								  (UT_Byte *)buf.getPointer(0),buf.getLength());
			DELETEP(pExpUnicodeText);
			UT_DEBUGMSG(("CopyToClipboard: copying %d bytes in TEXTPLAIN UNICODE format.\n",
						 buf.getLength()*2));
		}
		else
		{
			return false;
		}
	}
	else if(0 == strcmp(AP_CLIPBOARD_RTF, pszFmt))
	{
		IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
		if (pExpRtf)
		{
			status = pExpRtf->copyToBuffer(pDocRange,&buf);

			if(status != UT_OK)
				return false;
			
			buf.append(&b,1);			// NULL terminate the string
			m_pClipboard->addData(AP_CLIPBOARD_RTF,(UT_Byte *)buf.getPointer(0),buf.getLength());
			DELETEP(pExpRtf);
			UT_DEBUGMSG(("CopyFmtToClipboard: copying %d bytes in RTF format.\n",
						 buf.getLength()));
		}
		else
		{
			return false;
		}
	}

	return true;
}
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:82,代码来源:ap_Win32App.cpp

示例11: LoadPictData

/*!
  Load the picture data
  \param format the Picture Format.
  \param image_name the name of the image. Must be unique.
  \param imgProps the RTF properties for the image.
  \return true if success, otherwise false.
  \desc Load the picture data from the flow. Will move the file position
  and assume proper RTF file structure. It will take care of inserting
  the picture into the document.
  \todo TODO: We assume the data comes in hex. Check this assumption
  as we might have to handle binary data as well
  \see IE_Imp_RTF::HandlePicture
*/
bool IE_Imp_RTF::LoadPictData(PictFormat format, const char * image_name,
							  struct RTFProps_ImageProps & imgProps, 
							  bool isBinary, long binaryLen)
{
	// first, we load the actual data into a buffer
	bool ok;
	bool retval = true;

	const UT_uint16 chars_per_byte = 2;
	const UT_uint16 BITS_PER_BYTE = 8;
	const UT_uint16 bits_per_char = BITS_PER_BYTE / chars_per_byte;

	UT_ByteBuf pictData;
	UT_uint16 chLeft = chars_per_byte;
	UT_Byte pic_byte = 0;
	FG_Graphic* pFG = NULL;
	UT_Error error = UT_OK;
	unsigned char ch;

	if (!isBinary) {
		if (!ReadCharFromFile(&ch)) {
			retval = false;
			goto cleanup;
		}

		while (ch != '}')
		{
			int digit;
			
			if (!hexVal(ch, digit)) {
				retval = false;
				goto cleanup;
			}
			
			pic_byte = (pic_byte << bits_per_char) + digit;
			
			// if we have a complete byte, we put it in the buffer
			if (--chLeft == 0)
			{
				pictData.append(&pic_byte, 1);
				chLeft = chars_per_byte;
				pic_byte = 0;
			}
			
			if (!ReadCharFromFile(&ch)) {
				retval = false;
				goto cleanup;
			}
		}
	} else {
		UT_ASSERT_HARMLESS(binaryLen);
		UT_DEBUGMSG(("Loading binary data image of %ld bytes\n", binaryLen));
		for (long i = 0; i < binaryLen; i++) {
			if (!ReadCharFromFileWithCRLF(&ch)) {
				retval = false;
				goto cleanup;
			}
			pictData.append(&ch, 1);
		}
	}

	// We let the caller handle this
	SkipBackChar(ch);

	error = IE_ImpGraphic::loadGraphic(pictData, iegftForRTF(format), &pFG);

	if ((error == UT_OK) && pFG)
	{
		imgProps.width = static_cast<UT_uint32>(pFG->getWidth ());
		imgProps.height = static_cast<UT_uint32>(pFG->getHeight ());
		// Not sure whether this is the right way, but first, we should
		// insert any pending chars
		if (!FlushStoredChars(true))
		{
			UT_DEBUGMSG(("Error flushing stored chars just before inserting a picture\n"));
			DELETEP(pFG);
			return false;
		}

		ok = InsertImage (pFG, image_name, imgProps);
		DELETEP(pFG);
		if (!ok)
		{
			return false;
		}
	}
	else
//.........这里部分代码省略.........
开发者ID:tanya-guza,项目名称:abiword,代码行数:101,代码来源:ie_imp_RTFObjectsAndPicts.cpp

示例12: previewPicture

gint XAP_UnixDialog_FileOpenSaveAs::previewPicture (void)
{
    UT_ASSERT (m_FC && m_preview);

    UT_ASSERT(XAP_App::getApp());

    const XAP_StringSet * pSS = m_pApp->getStringSet();
    UT_return_val_if_fail( pSS, 0 );

    // attach and clear the area immediately
    GR_UnixCairoAllocInfo ai(m_preview);
    GR_CairoGraphics* pGr =
        (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai);

    const gchar * file_name = gtk_file_chooser_get_uri (m_FC);

    GR_Font * fnt = pGr->findFont("Times New Roman",
                                  "normal", "", "normal",
                                  "", "12pt",
                                  pSS->getLanguageName());
    pGr->setFont(fnt);

    UT_UTF8String str;
    pSS->getValueUTF8(XAP_STRING_ID_DLG_IP_No_Picture_Label, str);

    int answer = 0;

    FG_Graphic * pGraphic = 0;
    GR_Image *pImage = NULL;

    double		scale_factor = 0.0;
    UT_sint32     scaled_width,scaled_height;
    UT_sint32     iImageWidth,iImageHeight;

    {
        GR_Painter painter(pGr);
        painter.clearArea(0, 0, pGr->tlu(m_preview->allocation.width), pGr->tlu(m_preview->allocation.height));

        if (!file_name)
        {
            painter.drawChars (str.ucs4_str().ucs4_str(), 0, str.size(), pGr->tlu(12), pGr->tlu(static_cast<int>(m_preview->allocation.height / 2)) - pGr->getFontHeight(fnt)/2);
            goto Cleanup;
        }

        // are we dealing with a file or directory here?
        struct stat st;
        if (!stat (file_name, &st))
        {
            if (!S_ISREG(st.st_mode))
            {
                painter.drawChars (str.ucs4_str().ucs4_str(), 0, str.size(), pGr->tlu(12), pGr->tlu(static_cast<int>(m_preview->allocation.height / 2)) - pGr->getFontHeight(fnt)/2);
                goto Cleanup;
            }
        }

        GsfInput * input = NULL;
        UT_DEBUGMSG(("file_name %s \n",file_name));
        input = UT_go_file_open (file_name, NULL);
        if (!input)
            goto Cleanup;
        char Buf[4097] = "";  // 4096+nul ought to be enough
        UT_uint32 iNumbytes = UT_MIN(4096, gsf_input_size(input));
        gsf_input_read(input, iNumbytes, (guint8 *)(Buf));
        Buf[iNumbytes] = '\0';

        IEGraphicFileType ief = IE_ImpGraphic::fileTypeForContents(Buf,4096);
        if((ief == IEGFT_Unknown) || (ief == IEGFT_Bogus))
        {
            painter.drawChars (str.ucs4_str().ucs4_str(), 0, str.size(), pGr->tlu(12), pGr->tlu(static_cast<int>(m_preview->allocation.height / 2)) - pGr->getFontHeight(fnt)/2);
            g_object_unref (G_OBJECT (input));
            goto Cleanup;
        }
        g_object_unref (G_OBJECT (input));
        input = UT_go_file_open (file_name, NULL);
        size_t num_bytes = gsf_input_size(input);
        UT_Byte * bytes = (UT_Byte *) gsf_input_read(input, num_bytes,NULL );
        if(bytes == NULL)
        {
            painter.drawChars (str.ucs4_str().ucs4_str(), 0, str.size(), pGr->tlu(12), pGr->tlu(static_cast<int>(m_preview->allocation.height / 2)) - pGr->getFontHeight(fnt)/2);
            g_object_unref (G_OBJECT (input));
            goto Cleanup;
        }
        UT_ByteBuf * pBB = new UT_ByteBuf();
        pBB->append(bytes,num_bytes);
        g_object_unref (G_OBJECT (input));
        //
        // OK load the data into a GdkPixbuf
        //
        bool bLoadFailed = false;
        //
        GdkPixbuf * pixbuf = pixbufForByteBuf ( pBB);
        delete pBB;
        if(pixbuf == NULL)
        {
            //
            // Try a fallback loader here.
            //
            painter.drawChars (str.ucs4_str().ucs4_str(), 0, str.size(), pGr->tlu(12), pGr->tlu(static_cast<int>(m_preview->allocation.height / 2)) - pGr->getFontHeight(fnt)/2);
            bLoadFailed = true;
            goto Cleanup;
//.........这里部分代码省略.........
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:101,代码来源:xap_UnixDlg_FileOpenSaveAs.cpp


注:本文中的UT_ByteBuf::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。