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


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

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


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

示例1:

void UT_UTF8String::appendBuf (const UT_ByteBuf & buf, UT_UCS4_mbtowc & converter)
{
	UT_uint32 i;
	UT_UCS4Char wc;
	const UT_Byte *ptr = buf.getPointer(0);
	
	for (i = 0; i < buf.getLength(); i++) 
	{
	  if (converter.mbtowc(wc, static_cast<char>(ptr[i])))
	        pimpl->appendUCS4(&wc, 1);
 	}
}
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:12,代码来源:ut_string_class.cpp

示例2: 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

示例3: _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

示例4: pasteRowOrCol

void FV_Selection::pasteRowOrCol(void)
{
    pf_Frag_Strux* cellSDH, *tableSDH;
    PT_DocPosition pos = m_pView->getPoint();
    if(m_iPrevSelectionMode == FV_SelectionMode_TableColumn)
    {
//
// GLOB stuff together so it undo's in one go.
//
        getDoc()->beginUserAtomicGlob();
//
// Insert a column after the current column
//
        m_pView->cmdInsertCol(m_pView->getPoint(),false);
//
// Now do all the encapsulating stuff for piecetable manipulations.
//
        // Signal PieceTable Change
        m_pView->_saveAndNotifyPieceTableChange();

        // Turn off list updates

        getDoc()->disableListUpdates();
        if (!m_pView->isSelectionEmpty())
        {
            m_pView->_clearSelection();
        }
        getDoc()->setDontImmediatelyLayout(true);
        pos = m_pView->getPoint();
        PT_DocPosition posTable,posCell;
        UT_sint32 iLeft,iRight,iTop,iBot;
        posCell = 0;
        m_pView->getCellParams(pos, &iLeft, &iRight,&iTop,&iBot);
        bool bRes = getDoc()->getStruxOfTypeFromPosition(pos,PTX_SectionCell,&cellSDH);
        bRes = getDoc()->getStruxOfTypeFromPosition(pos,PTX_SectionTable,&tableSDH);
        UT_return_if_fail(bRes);
        posTable = getDoc()->getStruxPosition(tableSDH) + 1;
        UT_sint32 numRows = 0;
        UT_sint32 numCols = 0;
        UT_sint32 i = 0;
        getDoc()-> getRowsColsFromTableSDH(tableSDH, m_pView->isShowRevisions(), m_pView->getRevisionLevel(),
                                           &numRows, &numCols);

        PD_DocumentRange DocRange(getDoc(),posCell,posCell);
        for(i=0; i<getNumSelections(); i++)
        {
            posCell = m_pView->findCellPosAt(posTable,i,iLeft)+2;
            m_pView->setPoint(posCell);
            PD_DocumentRange * pR = getNthSelection(i);
            if(pR->m_pos1 == pR->m_pos2)
            {
//
// Dont paste empty cells
//
                continue;
            }
            UT_ByteBuf * pBuf = m_vecSelRTFBuffers.getNthItem(i);
            const unsigned char * pData = pBuf->getPointer(0);
            UT_uint32 iLen = pBuf->getLength();
            DocRange.m_pos1 = posCell;
            DocRange.m_pos2 = posCell;
            IE_Imp_RTF * pImpRTF = new IE_Imp_RTF(getDoc());
            pImpRTF->pasteFromBuffer(&DocRange,pData,iLen);
            DELETEP(pImpRTF);
            fl_SectionLayout * pSL = m_pView->getCurrentBlock()->getSectionLayout();
            pSL->checkAndAdjustCellSize();
        }
        getDoc()->endUserAtomicGlob();
        getDoc()->setDontImmediatelyLayout(false);
        m_pView->_generalUpdate();


        // restore updates and clean up dirty lists
        getDoc()->enableListUpdates();
        getDoc()->updateDirtyLists();

        // Signal PieceTable Changes have finished
        m_pView->_restorePieceTableState();
// Put the insertion point in a legal position
//
        m_pView->notifyListeners(AV_CHG_MOTION);
        m_pView->_fixInsertionPointCoords();
        m_pView->_ensureInsertionPointOnScreen();

    }
    else
    {
    }
}
开发者ID:tanya-guza,项目名称:abiword,代码行数:89,代码来源:fv_Selection.cpp

示例5: copyToClipboard

/*!
  copy the given subset of the given document to the
  system clipboard in a variety of formats.

  to minimize the effects of race-conditions, we create
  all of the buffers we need and then post them to the
  server (well sorta) all at one time.
  \param pDocRange a range of the document to be copied
*/
void AP_UnixApp::copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard)
{

    UT_ByteBuf bufRTF;
    UT_ByteBuf bufHTML4;
    UT_ByteBuf bufXHTML;
    UT_ByteBuf bufTEXT;
    UT_ByteBuf bufODT;

    // create RTF buffer to put on the clipboard
		
    IE_Exp_RTF * pExpRtf = new IE_Exp_RTF(pDocRange->m_pDoc);
    if (pExpRtf)
    {
		pExpRtf->copyToBuffer(pDocRange,&bufRTF);
		DELETEP(pExpRtf);
    }

	// create XHTML buffer to put on the clipboard

	IE_Exp_HTML * pExpHtml = new IE_Exp_HTML(pDocRange->m_pDoc);
	if (pExpHtml)
		{
			pExpHtml->set_HTML4 (false);
			pExpHtml->copyToBuffer (pDocRange, &bufXHTML);
			DELETEP(pExpHtml);
		}

	// create HTML4 buffer to put on the clipboard
	
	pExpHtml = new IE_Exp_HTML(pDocRange->m_pDoc);
	if (pExpHtml)
		{
			pExpHtml->set_HTML4 (true);
			pExpHtml->copyToBuffer(pDocRange, &bufHTML4);
			DELETEP(pExpHtml);
		}

	// Look to see if the ODT plugin is loaded

	IEFileType ftODT = IE_Exp::fileTypeForMimetype("application/vnd.oasis.opendocument.text");
	bool bExpODT = false;
	if(ftODT != IEFT_Unknown)
	{
		// ODT plugin is present construct an exporter
		//
		IE_Exp * pODT = NULL;
		IEFileType genIEFT = IEFT_Unknown;
		GsfOutput * outBuf =  gsf_output_memory_new();
		UT_Error err = IE_Exp::constructExporter(pDocRange->m_pDoc,outBuf,
												 ftODT,&pODT,& genIEFT);
		if(pODT && (genIEFT == ftODT))
		{
			//												 
			// Copy to the buffer
			//
			err = pODT->copyToBuffer(pDocRange, &bufODT);
			bExpODT = (err == UT_OK);
            UT_DEBUGMSG(("Putting ODF on the clipboard...e:%d bExpODT:%d\n", err, bExpODT ));

#ifdef DUMP_CLIPBOARD_COPY
            std::ofstream oss("/tmp/abiword-clipboard-copy.odt");
            oss.write( (const char*)bufODT.getPointer (0), bufODT.getLength () );
            oss.close();
#endif
		}
	}

    // create UTF-8 text buffer to put on the clipboard
		
    IE_Exp_Text * pExpText = new IE_Exp_Text(pDocRange->m_pDoc, "UTF-8");
    if (pExpText)
    {
		pExpText->copyToBuffer(pDocRange,&bufTEXT);
		DELETEP(pExpText);
    }

    // NOTE: this clearData() will actually release our ownership of
    // NOTE: the CLIPBOARD property in addition to clearing any
    // NOTE: stored buffers.  I'm omitting it since we seem to get
    // NOTE: clr callback after we have done some other processing
    // NOTE: (like adding the new stuff).
    // m_pClipboard->clearData(true,false);
	
    // TODO: handle CLIPBOARD vs PRIMARY
    XAP_UnixClipboard::T_AllowGet target = ((bUseClipboard)
					    ? XAP_UnixClipboard::TAG_ClipboardOnly
					    : XAP_UnixClipboard::TAG_PrimaryOnly);

	if (bufRTF.getLength () > 0)
		m_pClipboard->addRichTextData (target, bufRTF.getPointer (0), bufRTF.getLength ());
//.........这里部分代码省略.........
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:101,代码来源:ap_UnixApp.cpp

示例6: 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

示例7: _png_write

static void _png_write(png_structp png_ptr, png_bytep data, png_size_t length)
{
	UT_ByteBuf* pBB = (UT_ByteBuf*) png_get_io_ptr(png_ptr);

	pBB->ins(pBB->getLength(), data, length);
}
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:6,代码来源:gr_Win32Image.cpp


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