Пример #1
0
void  AP_Win32Dialog_Stylist::setStyleInGUI(void)
{
	UT_sint32 row,col;
	UT_UTF8String sCurStyle = *getCurStyle();

	if((getStyleTree() == NULL) || (sCurStyle.size() == 0))
		updateDialog();

	if(isStyleTreeChanged())
		_fillTree();

	getStyleTree()->findStyle(sCurStyle,row,col);
	UT_DEBUGMSG(("After findStyle row %d col %d col \n",row,col));
	UT_UTF8String sPathFull = UT_UTF8String_sprintf("%d:%d",row,col);
	UT_UTF8String sPathRow = UT_UTF8String_sprintf("%d",row);
	UT_DEBUGMSG(("Full Path string is %s \n",sPathFull.utf8_str()));

	HWND hTree = GetDlgItem(m_hWnd, AP_RID_DIALOG_STYLIST_TREE_STYLIST);
	HTREEITEM hitem = NULL;

	hitem = TreeView_GetRoot(hTree);
	UT_sint32 i;
	// Go through each row until we've found ours
	for (i = 0; i < row; i++)
		hitem = TreeView_GetNextItem(hTree, hitem, TVGN_NEXT);

	hitem = TreeView_GetNextItem(hTree, hitem, TVGN_CHILD);
	for (i = 0; i < col; i++)
		hitem = TreeView_GetNextItem(hTree, hitem, TVGN_NEXT);

	TreeView_SelectItem(hTree, hitem);

	setStyleChanged(false);
}
void AP_UnixDialog_Stylist::setStyleInGUI(void)
{
	UT_sint32 row,col;
	UT_UTF8String sCurStyle = *getCurStyle();

	if((getStyleTree() == NULL) || (sCurStyle.size() == 0))
		updateDialog();

	if(m_wStyleList == NULL)
		return;

	if(isStyleTreeChanged())
		_fillTree();

	getStyleTree()->findStyle(sCurStyle,row,col);
	UT_DEBUGMSG(("After findStyle row %d col %d col \n",row,col));
	UT_UTF8String sPathFull = UT_UTF8String_sprintf("%d:%d",row,col);
	UT_UTF8String sPathRow = UT_UTF8String_sprintf("%d",row);
	UT_DEBUGMSG(("Full Path string is %s \n",sPathFull.utf8_str()));
	GtkTreePath * gPathRow = gtk_tree_path_new_from_string (sPathRow.utf8_str());
	GtkTreePath * gPathFull = gtk_tree_path_new_from_string (sPathFull.utf8_str());
	gtk_tree_view_expand_row( GTK_TREE_VIEW(m_wStyleList),gPathRow,TRUE);
	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(m_wStyleList),gPathFull,NULL,TRUE,0.5,0.5);
	gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_wStyleList),gPathFull,NULL,TRUE);
	setStyleChanged(false);
	gtk_tree_path_free(gPathRow);
	gtk_tree_path_free(gPathFull);
}
Пример #3
0
void s_XSL_FO_Listener::_openCell(PT_AttrPropIndex /*api*/)
{
	if (!m_bInSection)
	{
		return;
	}

	_popListToDepth(0);
	_closeCell();
	_openRow();

	UT_sint32 rowspan = 1, colspan = 1;

	rowspan = mTableHelper.getBot() - mTableHelper.getTop();
	colspan = mTableHelper.getRight() - mTableHelper.getLeft();

	UT_UTF8String td ("table-cell");

	if (rowspan > 1)
		td += UT_UTF8String_sprintf(" number-rows-spanned=\"%d\"", rowspan);

	if (colspan > 1)
		td += UT_UTF8String_sprintf(" number-columns-spanned=\"%d\"", colspan);

	td += _getCellThicknesses();
	td += _getCellColors();

	_tagOpen(TT_TABLECELL, td);
}
Пример #4
0
UT_UTF8String s_XSL_FO_Listener::_getTableThicknesses(void)
{
	UT_UTF8String tableSpec;
	double val = 0;
	const char *prop = NULL;

	UT_LocaleTransactor t(LC_NUMERIC, "C");

	tableSpec = " border=\"solid\"";
	prop = mTableHelper.getTableProp("left-thickness");
	val = prop ? atof(prop) : 1;
	tableSpec += UT_UTF8String_sprintf(" border-left-width=\"%1.2fpt\"", val);

	prop = mTableHelper.getTableProp("right-thickness");
	val = prop ? atof(prop) : 1;
	tableSpec += UT_UTF8String_sprintf(" border-right-width=\"%1.2fpt\"", val);

	prop = mTableHelper.getTableProp("top-thickness");
	val = prop ? atof(prop) : 1;
	tableSpec += UT_UTF8String_sprintf(" border-top-width=\"%1.2fpt\"", val);

	prop = mTableHelper.getTableProp("bot-thickness");
	val = prop ? atof(prop) : 1;
	tableSpec += UT_UTF8String_sprintf(" border-bottom-width=\"%1.2fpt\"", val);

	return tableSpec;
}
Пример #5
0
void ODe_Note_Listener::_openNote(const gchar* pNoteClass,
                                  const gchar* pNoteId,
                                  ODe_ListenerAction& /*rAction*/) {
    UT_uint32 noteCitation;
    UT_UTF8String str;
    UT_UTF8String output;

    UT_return_if_fail(pNoteId);
    
    // The note citation will be id+1
    // So id=0 will have a citation "1", and so on.
    noteCitation = atoi(pNoteId) + 1;
    
    output += "<text:note text:id=\"note";
    
    UT_UTF8String_sprintf(str, "%u", m_rAuxiliaryData.m_noteCount+1);
    output += str;
    
    output += "\" text:note-class=\"";
    output += pNoteClass;
    output += "\"><text:note-citation>";
    
    UT_UTF8String_sprintf(str, "%u", noteCitation);
    output += str;
    
    output += "</text:note-citation><text:note-body>";                                    
    
    ODe_writeUTF8String(m_pTextOutput, output);
    
    m_rAuxiliaryData.m_noteCount++;
}
Пример #6
0
/**
 * Write the <text:list-style> element.
 */
bool ODe_Style_List::write(GsfOutput* pODT,
                           const UT_UTF8String& rSpacesOffset) const {
                            
    UT_uint32 i, count;
    UT_UTF8String subElementSpacesOffset;
    UT_UTF8String output;
    UT_GenericVector<ODe_ListLevelStyle*>* pVector;
    bool ok;
    
    UT_UTF8String_sprintf(output, "%s<text:list-style style:name=\"%s\">\n",
                          rSpacesOffset.utf8_str(), m_name.utf8_str());
    ODe_writeUTF8String(pODT, output);
    
    subElementSpacesOffset = rSpacesOffset;
    subElementSpacesOffset += " ";
    
    pVector = m_levelStyles.enumerate();
    count = pVector->getItemCount();
    for (i=0; i<count; i++) {
        ok = (*pVector)[i]->write(pODT, subElementSpacesOffset);
        if (!ok) {
            return false;
        }
    }
    
    UT_UTF8String_sprintf(output, "%s</text:list-style>\n",
                          rSpacesOffset.utf8_str());
    ODe_writeUTF8String(pODT, output);
    
    return true;
}
void AccountHandler::_reportProtocolError(UT_sint32 remoteVersion, UT_sint32 errorEnum, BuddyPtr pBuddy)
{
#ifndef DEBUG
	UT_UNUSED(remoteVersion);
	UT_UNUSED(errorEnum);
#endif
	UT_DEBUGMSG(("_reportProtocolError: remoteVersion=%d errorEnum=%d\n", remoteVersion, errorEnum));
	UT_return_if_fail(pBuddy);

	static std::set<std::string> reportedBuddies;
	if (reportedBuddies.insert( pBuddy->getDescriptor(false).utf8_str() ).second)
	{
		UT_UTF8String msg;
		switch (errorEnum) {
			case PE_Invalid_Version:
				msg = UT_UTF8String_sprintf("Your buddy %s is using version %d of AbiCollab, while you are using version %d.\n"
											"Please make sure you are using the same AbiWord version.", 
											pBuddy->getDescription().utf8_str(),
											remoteVersion, ABICOLLAB_PROTOCOL_VERSION);
				break;
			default:
				msg = UT_UTF8String_sprintf("An unknown error code %d was reported by buddy %s.", errorEnum,
												pBuddy->getDescription().utf8_str());
				break;
		}
		XAP_App::getApp()->getLastFocussedFrame()->showMessageBox(
			msg.utf8_str(),
			XAP_Dialog_MessageBox::b_O,
			XAP_Dialog_MessageBox::a_OK);
	}
}
Пример #8
0
void s_XSL_FO_Listener::_handleDataItems(void)
{
	const char * szName = NULL;
    std::string mimeType;
	const UT_ByteBuf * pByteBuf;

	for (UT_uint32 k=0; (m_pDocument->enumDataItems(k, NULL, &szName, &pByteBuf, &mimeType)); k++)
	{	  	  
		UT_sint32 loc = -1;
		for (UT_sint32 i = 0; i < m_utvDataIDs.getItemCount(); i++)
		{
			if(strcmp(reinterpret_cast<const char*>(m_utvDataIDs[i]), szName) == 0)
			{
				loc = i;
				break;
			}
		}

		if(loc > -1)
		{
			UT_UTF8String fname;

			UT_UTF8String_sprintf(fname, "%s_data", m_pie->getFileName());
			UT_go_directory_create(fname.utf8_str(), 0750, NULL);

			if (mimeType == "image/svg+xml")
				UT_UTF8String_sprintf(fname, "%s/%d.svg", fname.utf8_str(), loc);
			else if (mimeType == "application/mathml+xml")
				UT_UTF8String_sprintf(fname, "%s/%d.mathml", fname.utf8_str(), loc);
			else // raster Image
			{  
                const char * extension = "png";
                if(mimeType == "image/jpeg") {
                    extension = "jpg";
                }
				char * temp = _stripSuffix(UT_go_basename(szName), '_');
				char * fstripped = _stripSuffix(temp, '.');
				UT_UTF8String_sprintf(fname, "%s/%s.%s", fname.utf8_str(), fstripped, extension);

				FREEP(temp);
				FREEP(fstripped);
			}
	  
			GsfOutput *fp = UT_go_file_create (fname.utf8_str(), NULL);
	  
			if(!fp)
				continue;
	  
			gsf_output_write(fp, pByteBuf->getLength(), (const guint8 *)pByteBuf->getPointer(0));
			gsf_output_close(fp);
			g_object_unref(fp);
		}
	}

	return;
}
Пример #9
0
UT_UTF8String TCPAccountHandler::getDescription()
{
	const std::string host = getProperty("server");
	const std::string port = getProperty("port");	
	
	if (host == "")
		return UT_UTF8String_sprintf("Listening on port %s", port.c_str());

	return UT_UTF8String_sprintf("Connection to %s:%s", host.c_str(), port.c_str());
}
Пример #10
0
void s_XSL_FO_Listener::_handleMath(PT_AttrPropIndex api)
{
	const PP_AttrProp * pAP = NULL;
	bool bHaveProp = m_pDocument->getAttrProp(api,&pAP);
	const gchar* szValue = NULL;

	UT_return_if_fail(bHaveProp && pAP && pAP->getAttribute("dataid", szValue) && szValue);

	//TODO: investigate mathml exporting

	UT_UTF8String buf, img, url;

	buf = "snapshot-png-";
	buf += szValue;
	buf.escapeXML();
	const gchar * dataid = g_strdup(buf.utf8_str());
	m_utvDataIDs.push_back(dataid);

	url = UT_go_basename(m_pie->getFileName());
	url.escapeXML();

	img = "external-graphic src=\"url('";
	img += url;
	img += "_data/";
	img += buf;
	img += ".png')\"";
	buf.clear();

	UT_LocaleTransactor t(LC_NUMERIC, "C");

	if(pAP->getProperty("width", szValue) && szValue)
	{
		double dInch = static_cast<double>(atoi(szValue))/UT_LAYOUT_RESOLUTION;
		UT_UTF8String_sprintf(buf,"%fin",dInch);

		img += " content-width=\"";
		img += buf;
		img += "\"";
		buf.clear();
	}
	if(pAP->getProperty("height", szValue) && szValue)
	{
		double dInch = static_cast<double>(atoi(szValue))/UT_LAYOUT_RESOLUTION;
		UT_UTF8String_sprintf(buf,"%fin",dInch);

		img += " content-height=\"";
		img += buf;
		img += "\"";
	}
	//note: language isn't a valid attribute

	_tagOpenClose(img, true, false);
}
/**
 * Sets the <pagesize> tag.
 */
void ODi_Style_PageLayout::definePageSizeTag(PD_Document* pDocument) const {
    
    UT_uint32 propCtr = 0;
    static const int MAX_PAGE_ATTS = 13; // 2*(width height orientation pagetype units page-scale) 0 
    const gchar* pageAtts[MAX_PAGE_ATTS];
    double pageWidthMmNumeric = 0.0;
    double pageHeightMmNumeric = 0.0;
    UT_UTF8String pageWidthMm;
    UT_UTF8String pageHeightMm;
    UT_LocaleTransactor lt(LC_NUMERIC, "C");
    
    // width and height are rounded to full mm because that's how they are
    // predefined in Abi and there seem to be rounding errors in oow's exporter

    if (!m_pageWidth.empty()) {
        pageAtts[propCtr++] = "width";
        
        pageWidthMmNumeric = rint(UT_convertToDimension(m_pageWidth.utf8_str(),
                                                        DIM_MM));
        UT_UTF8String_sprintf(pageWidthMm, "%f", pageWidthMmNumeric);
        pageAtts[propCtr++] = pageWidthMm.utf8_str();
    }

    if (!m_pageHeight.empty()) {
        pageAtts[propCtr++] = "height";
        
        pageHeightMmNumeric = rint(UT_convertToDimension(m_pageHeight.utf8_str(),
                                                         DIM_MM));
        UT_UTF8String_sprintf(pageHeightMm, "%f", pageHeightMmNumeric);
        pageAtts[propCtr++] = pageHeightMm.utf8_str();
    }

    pageAtts[propCtr++] = "units";
    pageAtts[propCtr++] = "mm";

    if (!m_printOrientation.empty()) {
        pageAtts[propCtr++] = "orientation";
        pageAtts[propCtr++] = m_printOrientation.utf8_str();
    }

    pageAtts[propCtr++] = "page-scale";
    pageAtts[propCtr++] = "1.0";

    fp_PageSize ps(pageWidthMmNumeric, pageHeightMmNumeric, DIM_MM);
    pageAtts[propCtr++] = "pagetype";
    pageAtts[propCtr++] = ps.getPredefinedName();

    pageAtts[propCtr] = 0; // To signal the end of the array
    
    
    pDocument->setPageSizeFromFile(pageAtts);
}
Пример #12
0
/**
 * Store the style in this automatic styles holder. As the specified
 * style get's stored here, this class takes care of freeing its memory later, so
 * you don't have to worry about freeing the memory of the stored style.
 * 
 * The style also get's it's unique name on this method.
 * 
 * After calling this method you may end up with your style pointer pointing to
 * a different style. It happens when there is already a stored style equivalent
 * to the one that you sent to be stored. The one that was passed is deleted.
 */
void ODe_AutomaticStyles::_storeStyle(ODe_Style_Style*& rpStyle,
                     UT_GenericStringMap<ODe_Style_Style*>& rStyles,
                     const char* pNamingPrefix) {
                        
    UT_GenericVector<ODe_Style_Style*>* pStyleVector;
    ODe_Style_Style* pStyle;
    bool isDuplicated;
    UT_uint32 i, count;
    
    pStyleVector = rStyles.enumerate();
    count = pStyleVector->getItemCount();
    
    for (i=0, isDuplicated=false; i<count && isDuplicated==false; i++) {
        
        pStyle = pStyleVector->getNthItem(i);
        if ( pStyle->isEquivalentTo(*rpStyle) ) {
            isDuplicated = true; // exit the loop
            delete rpStyle; // We don't want a duplicated style.
            rpStyle = pStyle;
        }
    }
    
    
    if (!isDuplicated) {
        // Let's name and store this style.
        UT_UTF8String styleName;
   
        UT_UTF8String_sprintf(styleName, "%s%d", pNamingPrefix, count+1);
        
        rpStyle->setStyleName(styleName);
        rStyles.insert(styleName.utf8_str(), rpStyle);
    }
}
Пример #13
0
const UT_UTF8String & UT_VersionInfo::getString() const
{
	static UT_UTF8String vers = UT_UTF8String_sprintf("%d.%d.%d.%d", 
													  m_iMajor, m_iMinor, 
													  m_iMicro, m_iNano);
	return vers;
}
Пример #14
0
const ODe_ListLevelStyle* ODe_Style_List::getLevelStyle(UT_uint8 level) const {
    UT_UTF8String levelString;
    
    UT_UTF8String_sprintf(levelString, "%u", level);
    
    return m_levelStyles.pick(levelString.utf8_str());
}
Пример #15
0
ConnectResult XMPPAccountHandler::connect()
{
	UT_DEBUGMSG(("XMPPAccountHandler::connect()\n"));

	if (m_bLoggedIn)
		return CONNECT_ALREADY_CONNECTED;
	
	if (m_pConnection)
		return CONNECT_IN_PROGRESS;

	// try to request a frame here; note that this might return 0, for example on application startup
	XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
	
	const std::string server = getProperty("server");
	const std::string username = getProperty("username");
	const std::string port = getProperty("port"); // TODO: unused atm
	const std::string resource = getProperty("resource");
	const std::string encryption = getProperty("encryption");

	std::string jid = username + "@" + server;
	
	UT_DEBUGMSG(("Connecting to server: |%s|, username: |%s|, resource: |%s|\n",
	             server.c_str(), username.c_str(), resource.c_str()));
	// NULL means perform SRV record lookup based on JID (Loudmouth 1.3.2+)
	m_pConnection = lm_connection_new(NULL);
	UT_return_val_if_fail(m_pConnection, CONNECT_INTERNAL_ERROR);

	lm_connection_set_jid(m_pConnection, jid.c_str());

	// setup SSL	
	if (lm_ssl_is_supported() && encryption == "true")
	{
		LmSSL* pSSL = lm_ssl_new(NULL, NULL, NULL, NULL); // TODO: free this
		lm_ssl_use_starttls(pSSL, TRUE, TRUE);
		lm_connection_set_ssl(m_pConnection, pSSL);
		lm_ssl_unref(pSSL);
	}

	GError* error = NULL;
	if (!lm_connection_open(m_pConnection, lm_connection_open_async_cb, this, NULL, &error)) 
	{
		UT_DEBUGMSG(("Failed to open: %s\n", error ? error->message : ""));
		lm_connection_unref(m_pConnection);
		m_pConnection = NULL;
		
		if (pFrame)
		{
			// inform the user of the connection failure
			// TODO: this shouldn't be here, the caller should handle this
			UT_UTF8String msg;
			// TODO: make this localizable
			UT_UTF8String_sprintf(msg, "Error while connecting to %s: %s\n", server.c_str(), (error ? error->message : "")); 
			pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
		}			
		return CONNECT_FAILED;
	}	

	return CONNECT_IN_PROGRESS;
}
Пример #16
0
/** set the widget value as float */
void XAP_UnixWidget::setValueFloat(float val)
{
	if (GTK_IS_ENTRY(m_widget)) {
        UT_UTF8String str;
	UT_UTF8String_sprintf(str,"%f",val);
	gtk_entry_set_text(GTK_ENTRY(m_widget), str.utf8_str());
	}
}
Пример #17
0
void IE_Exp_EPUB_EPUB3Writer::openAnnotation()
{
	m_pTagWriter->openTag("a", true);
	m_pTagWriter->addAttribute("href", 
		UT_UTF8String_sprintf("#annotation-%d",
			m_iAnnotationCount + 1).utf8_str());
	
	m_pTagWriter->addAttribute("epub:type", "annoref");
}
Пример #18
0
/** set the widget int value */
void XAP_UnixWidget::setValueInt(int val)
{
	if (GTK_IS_TOGGLE_BUTTON(m_widget)) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), (val?TRUE:FALSE));
	}
	else if (GTK_IS_LABEL(m_widget)) {
	  UT_UTF8String str;
	  UT_UTF8String_sprintf(str,"%d",val);
	  gtk_label_set_text(GTK_LABEL(m_widget), str.utf8_str());
	}
	else if (GTK_IS_ENTRY(m_widget)) {
	  UT_UTF8String str;
	  UT_UTF8String_sprintf(str,"%d",val);
	  gtk_entry_set_text(GTK_ENTRY(m_widget), str.utf8_str());
	}
	else {
		UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
	}
}
Пример #19
0
void ODe_Style_List::setLevelStyle(UT_uint8 level, const PP_AttrProp& rBlockAP) {
    
    UT_UTF8String levelString;
    ODe_ListLevelStyle* pLevelStyle;
    const gchar* pValue = NULL;
    bool ok;
    
    UT_UTF8String_sprintf(levelString, "%u", level);
    
    pLevelStyle = m_levelStyles.pick(levelString.utf8_str());
    
    if (pLevelStyle != NULL) {
        // This level style aws already set. There's nothing to be done.
        return;
    }
    
    ok = rBlockAP.getProperty("list-style", pValue);
    UT_return_if_fail(ok && pValue);
    
    if (!strcmp(pValue, "Numbered List") ||
        !strcmp(pValue, "Lower Case List") ||
        !strcmp(pValue, "Upper Case List") ||
        !strcmp(pValue, "Lower Roman List") ||
        !strcmp(pValue, "Upper Roman List") ||
        !strcmp(pValue, "Hebrew List") ||
        !strcmp(pValue, "Arabic List")) {
            
        pLevelStyle = new ODe_Numbered_ListLevelStyle();

    } else if (!strcmp(pValue, "Bullet List") ||
               !strcmp(pValue, "Dashed List") ||
               !strcmp(pValue, "Square List") ||
               !strcmp(pValue, "Triangle List") ||
               !strcmp(pValue, "Diamond List") ||
               !strcmp(pValue, "Star List") ||
               !strcmp(pValue, "Tick List") ||
               !strcmp(pValue, "Box List") ||
               !strcmp(pValue, "Hand List") ||
               !strcmp(pValue, "Heart List") ||
               !strcmp(pValue, "Implies List")) {
                
        pLevelStyle = new ODe_Bullet_ListLevelStyle();
        
        
    } else {
        UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
        return;
    }


    m_levelStyles.insert(levelString.utf8_str(), pLevelStyle);
    pLevelStyle->fetchAttributesFromAbiBlock(rBlockAP);
}
Пример #20
0
ODe_Style_List* ODe_AutomaticStyles::addListStyle() {
    ODe_Style_List* pStyle;
    UT_UTF8String styleName;
   
    UT_UTF8String_sprintf(styleName, "L%d", m_listStyles.size() + 1);
    
    pStyle = new ODe_Style_List();
    pStyle->setName(styleName);
    
    m_listStyles.insert(styleName.utf8_str(), pStyle);
    
    return pStyle;
}
Пример #21
0
ODe_Style_PageLayout* ODe_AutomaticStyles::addPageLayout() {
    ODe_Style_PageLayout* pStyle;
    UT_UTF8String styleName;
   
    UT_UTF8String_sprintf(styleName, "PLayout%d", m_pageLayouts.size() + 1);
    
    pStyle = new ODe_Style_PageLayout();
    pStyle->setName(styleName);
    
    m_pageLayouts.insert(styleName.utf8_str(), pStyle);
    
    return pStyle;
}
Пример #22
0
void IE_Exp_EPUB_EPUB3Writer::insertAnnotations(
	const std::vector<UT_UTF8String> &titles,
	const std::vector<UT_UTF8String> &authors,
	const std::vector<UT_UTF8String> &annotations)
{
	m_pTagWriter->openTag("section");
    m_pTagWriter->addAttribute("epub:type", "annotations");
    
    for(size_t i = 0; i < annotations.size(); i++)
    {
        UT_UTF8String title = titles.at(i);
        UT_UTF8String author = authors.at(i);
        UT_UTF8String annotation = annotations.at(i);
        
        m_pTagWriter->openTag("section");
        // m_pTagWriter->addAttribute("class", "annotation");
		m_pTagWriter->addAttribute("epub:type", "annotation");
        m_pTagWriter->addAttribute("id", UT_UTF8String_sprintf("annotation-%d", 
            i + 1).utf8_str());
        if (title.length())
        {
            m_pTagWriter->openTag("h4");
            m_pTagWriter->writeData(title.utf8_str());
            m_pTagWriter->closeTag();
        }
        
        /*if (author.length())
        {
            m_pTagWriter->openTag("span");
            m_pTagWriter->addAttribute("class", "annotation-author");
            m_pTagWriter->writeData(author.utf8_str());
            m_pTagWriter->closeTag();
            m_pTagWriter->openTag("br", false, true);
            m_pTagWriter->closeTag();
        }*/
        
        if (annotation.length())
        {
            m_pTagWriter->openTag("blockquote");
            // m_pTagWriter->addAttribute("class", "annotation-content");
            m_pTagWriter->writeData(annotation.utf8_str());
            m_pTagWriter->closeTag();
        }
        
        m_pTagWriter->closeTag();        
    }
    
    m_pTagWriter->closeTag();
}
Пример #23
0
//
// AbiMathView_FileInsert
// -------------------
//   This is the function that we actually call to insert the MathML.
//
bool 
AbiMathView_FileInsert(AV_View* /*v*/, EV_EditMethodCallData* /*d*/)
{
	// Get the current view that the user is in.
	XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
	FV_View* pView = static_cast<FV_View*>(pFrame->getCurrentView());
	PD_Document * pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc());
	char* pNewFile = NULL;


	bool bOK = s_AskForMathMLPathname(pFrame,&pNewFile);
	
	if (!bOK || !pNewFile)
	{
		UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %s \n",bOK,pNewFile));
		return false;
	}
	UT_UTF8String sNewFile = pNewFile;

	// we own storage for pNewFile and must free it.
	FREEP(pNewFile);

	UT_DEBUGMSG(("fileInsertMathML: loading [%s]\n",sNewFile.utf8_str()));
   
	IE_Imp_MathML * pImpMathML = new IE_Imp_MathML(pDoc, pMathManager->EntityTable());
	UT_Error errorCode = pImpMathML->importFile(sNewFile.utf8_str());

	if (errorCode != UT_OK)
	{
		s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode);
		DELETEP(pImpMathML);
		return false;
	}

	/* Create the data item */
	UT_uint32 uid = pDoc->getUID(UT_UniqueId::Image);
	UT_UTF8String sUID;
	UT_UTF8String_sprintf(sUID,"%d",uid);
	pDoc->createDataItem(sUID.utf8_str(), false, pImpMathML->getByteBuf(), 
                         "application/mathml+xml", NULL);

	/* Insert the MathML Object */
	PT_DocPosition pos = pView->getPoint();
	pView->cmdInsertMathML(sUID.utf8_str(),pos);

	DELETEP(pImpMathML);

	return true;
}
void AP_UnixDialog_FormatFrame::event_BorderThicknessChanged(void)
{
	if(m_wBorderThickness)
	{
		gint history = gtk_combo_box_get_active(GTK_COMBO_BOX(m_wBorderThickness));
		double thickness = m_dThickness[history];

		UT_UTF8String sThickness;
		{
			UT_LocaleTransactor t(LC_NUMERIC, "C");
			sThickness = UT_UTF8String_sprintf("%fin",thickness);
		}

		setBorderThicknessAll(sThickness);
		event_previewExposed();
	}
}
Пример #25
0
void fp_FrameContainer::setPreferedPageNo(UT_sint32 i)
{
     if(m_iPreferedPageNo == i)
       return;
     m_iPreferedPageNo =  i;
     fl_FrameLayout * pFL = static_cast<fl_FrameLayout *>(getSectionLayout());
     FL_DocLayout * pDL = pFL->getDocLayout();
     if(pDL->isLayoutFilling())
       return;
     PD_Document * pDoc = pDL->getDocument();
     UT_UTF8String sVal;
     UT_UTF8String_sprintf(sVal,"%d",i);
     const char * attr = PT_PROPS_ATTRIBUTE_NAME;
     UT_UTF8String sAttVal = "pref-page:";
     sAttVal += sVal.utf8_str();
     
     pDoc->changeStruxAttsNoUpdate(pFL->getStruxDocHandle(),attr,sAttVal.utf8_str());
}
Пример #26
0
void IE_Exp_EPUB_EPUB3Writer::insertFootnotes(
	const std::vector<UT_UTF8String> &footnotes)
{
	if (footnotes.size() == 0) return;
	
	m_pTagWriter->openTag("aside");
	m_pTagWriter->addAttribute("epub:type", "footnotes");
	for (size_t i = 0; i < footnotes.size(); i++) {
		m_pTagWriter->openTag("section");
		// m_pTagWriter->addAttribute("class", "footnote_anchor");
		m_pTagWriter->addAttribute("id",
								   UT_UTF8String_sprintf("footnote-%d", i + 1).utf8_str());
		m_pTagWriter->addAttribute("epub:type", "footnote");
		m_pTagWriter->writeData(footnotes.at(i).utf8_str());
		m_pTagWriter->closeTag();
	}
	m_pTagWriter->closeTag();	
}
Пример #27
0
void TCPAccountHandler::_handleAccept(IOServerHandler* pHandler, boost::shared_ptr<Session> session)
{
	UT_DEBUGMSG(("TCPAccountHandler::handleAccept\n"));
	UT_return_if_fail(pHandler);
	UT_return_if_fail(session);
	
	// store this buddy/session
	UT_UTF8String name;
	UT_UTF8String_sprintf(name, "%s:%d", session->getRemoteAddress().c_str(), session->getRemotePort());
	TCPBuddyPtr pBuddy = boost::shared_ptr<TCPBuddy>(new TCPBuddy(this, 
								session->getRemoteAddress(), 
								boost::lexical_cast<std::string>(session->getRemotePort())));
	addBuddy(pBuddy);
	m_clients.insert(std::pair<TCPBuddyPtr, boost::shared_ptr<Session> >(pBuddy, session));
	
	// accept a new buddy/session
	pHandler->asyncAccept();	
}
Пример #28
0
void AbiCollabSessionManager::closeSession(AbiCollab* pSession, bool canConfirm)
{
	UT_DEBUGMSG(("Stopping collaboration session %s\n", pSession->getSessionId().utf8_str()));
	UT_return_if_fail(pSession);
	
	// TODO: in the future, we should hand over control to someone
	// else within this session first, if possible
		
	// ask for confirmation if we are in control of this session, and people are connected to us, 
	if (pSession->isLocallyControlled() &&
		pSession->getCollaborators().size() > 0 &&
		canConfirm)
	{
		XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
		UT_return_if_fail(pFrame);
			
		UT_UTF8String msg;
		// TODO: make this localizable
		UT_UTF8String_sprintf(msg, "This document is currently being shared with %u people. Are you sure you want to stop sharing this document?", pSession->getCollaborators().size()); 
		if (pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_YN, XAP_Dialog_MessageBox::a_NO) != XAP_Dialog_MessageBox::a_YES)
			return;
	}
		
	// check who is controlling this session
	if (pSession->isLocallyControlled())
	{
		UT_UTF8String pDestroyedSession = pSession->getSessionId();
	
		// kill the session
		destroySession(pSession);
		
		// notify all that this session is closed
		CloseSessionEvent event(pDestroyedSession);
		event.setBroadcast(true);
		signal(event);
	}
	else
	{
		// we are joined to this session, so we aren't allowed to close it;
		// we should disjoin it instead
		UT_ASSERT(UT_NOT_REACHED);
	}
}
Пример #29
0
void AbiCollabSessionManager::removeBuddy(BuddyPtr pBuddy, bool graceful)
{
	UT_return_if_fail(pBuddy);
	
	UT_DEBUGMSG(("Dropping buddy '%s' from all sessions\n", pBuddy->getDescription().utf8_str()));
	// TODO: should we send out events for every buddy we drop, or session
	// we delete?
	
	for (UT_sint32 i = m_vecSessions.getItemCount() - 1; i >= 0; i--)
	{
		AbiCollab* pSession = m_vecSessions.getNthItem(i);
		UT_continue_if_fail(pSession);
		
		if (pSession->isLocallyControlled())
		{
			pSession->removeCollaborator(pBuddy);
		}
		else
		{
			// we don't control this session, meaning we can drop it completely
			// if this buddy controlled it
			// TODO: when we allow more than 1 buddy in a non-locally controlled,
			// then remove it from that list here
			if (pSession->isController(pBuddy))
			{
				UT_DEBUGMSG(("This buddy controlled a session, destroying the session...\n"));
				std::string docName = pSession->getDocument()->getFilename();
				if (docName == "")
					docName = "Untitled"; // TODO: fetch the title from the frame somehow (which frame?) - MARCM
				destroySession(pSession);
				if (!graceful)
				{
					XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
					UT_continue_if_fail(pFrame);
					// TODO: make this localizable
					UT_UTF8String msg;
					UT_UTF8String_sprintf(msg, "You've been disconnected from buddy %s. The collaboration session for document %s has been stopped.", pBuddy->getDescription().utf8_str(), docName.c_str());
					pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
				}
			}
		}
	}
}
Пример #30
0
std::string UT_createTmpFile(const std::string& prefix, const std::string& extension)
{
	const gchar *filename = g_build_filename (g_get_tmp_dir (), prefix.c_str(), NULL);
	UT_return_val_if_fail(filename, "");

	std::string sName = filename;
	FREEP(filename);

	UT_UTF8String rand = UT_UTF8String_sprintf("%X", UT_rand() * 0xFFFFFF);
	sName += rand.utf8_str();
	sName += extension;

	FILE* f = fopen (sName.c_str(), "w+b");
	if (!f)
		return "";

	fclose(f);
	return sName;
}