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


C++ PD_Document::enumStyles方法代码示例

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


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

示例1: populate

bool AP_UnixToolbar_StyleCombo::populate(void)
{
	// clear anything that's already there
	m_vecContents.clear();

	// populate the vector

#if 1
	// HACK: for now, just hardwire it
	// NB if you change the case of the labels, it will stop working
	// unless you also change all the places where the style appears!
	m_vecContents.addItem("Normal");
	m_vecContents.addItem("Heading 1");
	m_vecContents.addItem("Heading 2");
	m_vecContents.addItem("Heading 3");
	m_vecContents.addItem("Plain Text");
	m_vecContents.addItem("Block Text");
#else

	AD_Document * pAD_Doc = m_pFrame->getCurrentDoc();
	if(!pAD_Doc)
	{
		return false;
	}
	PD_Document *pDocument = static_cast<PD_Document *>(pAD_Doc);

	// TODO: need a view/doc pointer to get this right
	// ALSO: will need to repopulate as new styles added
	// HYP:  only call this method from shared code? 
	const char * szName;
	const PD_Style * pStyle;

	for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++)
	{
		if (pStyle && pStyle->isDisplayed()) {
			m_vecContents.addItem(szName);
		}
	}
#endif 

	return true;
}
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:42,代码来源:ap_UnixToolbar_StyleCombo.cpp

示例2: repopulate

bool AP_UnixToolbar_StyleCombo::repopulate(void)
{
	// repopulate the vector from the current document
    // If ithere is one present

	AD_Document * pAD_Doc = m_pFrame->getCurrentDoc();
	if(!pAD_Doc)
	{
		return false;
	}

	PD_Document *pDocument = static_cast<PD_Document *>(pAD_Doc);

	GR_GraphicsFactory * pGF = XAP_App::getApp()->getGraphicsFactory();
	if(!pGF)
	{
		return false;
	}

	// clear anything that's already there
	m_vecContents.clear();
	freeStyles();

	// defaults for style combo
	if (m_pDefaultDesc == NULL)
	{
		// for now this is hardcoded
		m_pDefaultDesc = pango_font_description_new ();
		pango_font_description_set_family (m_pDefaultDesc, "Times");
		pango_font_description_set_size (m_pDefaultDesc, 12 * PANGO_SCALE);
	}

	const char * szName;
	const PD_Style * pStyle;
	GSList *list = NULL;

	for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++)
	{
		if (!pStyle) {
			UT_DEBUGMSG(("no style instance for '%s'\n", szName));
		}

		if (!pStyle->isDisplayed() && 
		    !(dynamic_cast<const PD_BuiltinStyle *>(pStyle) && pStyle->isList() && pStyle->isUsed())) {
			continue;
		}

		list = g_slist_prepend (list, (char *)szName);

		/* wysiwyg styles are disabled for now 
		PangoFontDescription *desc = pango_font_description_copy (m_pDefaultDesc);
		getPangoAttrs(pStyle, desc);
		m_mapStyles.insert(szName, desc);
		*/
	}

	// Ok, it's a bit hackish to put them in a list for sorting first
	// but somehow the vector's qsort totally failed for me
	if (list) 
	{
		list = g_slist_sort(list, (GCompareFunc)sort_cb);		
		do 
		{
			m_vecContents.addItem((const char *)list->data);

		} while (NULL != (list = g_slist_next(list)));
		g_slist_free(list);
	}		

	return true;
}
开发者ID:monkeyiq,项目名称:odf-2011-track-changes-git-svn,代码行数:71,代码来源:ap_UnixToolbar_StyleCombo.cpp


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