Exemplo n.º 1
0
bool GR_MathManager::createPNGSnapshot(AD_Document * pDoc, UT_Rect & rec,
					   const char * szDataID)
{
	if (isDefault())
	{
		return false;
	}

	if ((rec.width == 0) || (rec.height ==0))
	{
		return false;
	}

	GR_Painter painter(getGraphics());
	GR_Image * pImage = painter.genImageFromRectangle(rec);
	if(pImage == NULL)
	{
		return false;
	}
	UT_ByteBuf * pBuf = NULL;
	pImage->convertToBuffer(&pBuf);
	UT_UTF8String sID = "snapshot-png-";
	sID += szDataID;

	const std::string mimetypePNG = "image/png";
	UT_DEBUGMSG(("Making data-item of name %s \n",sID.utf8_str()));
	pDoc->createDataItem(sID.utf8_str(),false,reinterpret_cast< const UT_ByteBuf *>(pBuf),mimetypePNG,NULL);

	DELETEP(pBuf);
	DELETEP(pImage);

	return true;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
/**
 * Handle the mimetype file
 */
UT_Error IE_Imp_OpenDocument::_handleMimetype ()
{
    GsfInput* pInput = gsf_infile_child_by_name(m_pGsfInfile, "mimetype");

    if (!pInput) {
        UT_DEBUGMSG(("Error: didn't get a mimetype. Assuming that it's a"
        " application/vnd.oasis.opendocument.text document\n"));
        return UT_OK;
    }

    UT_UTF8String mimetype;
    
    if (gsf_input_size (pInput) > 0) {
        mimetype.append(
            (const char *)gsf_input_read(pInput, gsf_input_size (pInput), NULL),
            gsf_input_size (pInput));
    }

    UT_Error err = UT_OK;

    if ((strcmp("application/vnd.oasis.opendocument.text", mimetype.utf8_str()) != 0) &&
        (strcmp("application/vnd.oasis.opendocument.text-template", mimetype.utf8_str()) != 0) &&
        (strcmp("application/vnd.oasis.opendocument.text-web", mimetype.utf8_str()) != 0))
    {
        UT_DEBUGMSG(("*** Unknown mimetype '%s'\n", mimetype.utf8_str()));
        err = UT_IE_BOGUSDOCUMENT;
    }

    g_object_unref (G_OBJECT (pInput));
    return err;
}
Exemplo n.º 4
0
void GR_GOComponentManager::makeSnapShot(UT_sint32 uid, G_GNUC_UNUSED UT_Rect & rec)
{
	GR_AbiGOComponentItems * pItem = m_vecItems.getNthItem(uid);
	UT_return_if_fail(pItem);  
	GOComponentView * pGOComponentView = m_vecGOComponentView.getNthItem(uid);
	const PP_AttrProp * pSpanAP = NULL;
	PT_AttrPropIndex api = pItem->m_iAPI;
	/* bool b = */ m_pDoc->getAttrProp(api, &pSpanAP);
	const char * pszDataID = NULL;
	pSpanAP->getAttribute("dataid", pszDataID);
	UT_ConstByteBufPtr pBuf;
	std::string mime_type;
	if ((pBuf = pGOComponentView->getSnapShot (mime_type)))
	  {
		UT_UTF8String sID = (mime_type == "image/svg")? "snapshot-svg-":  "snapshot-png-";
		sID += pszDataID;
		if(pItem->m_bHasSnapshot)
		  {
			m_pDoc->replaceDataItem(sID.utf8_str(), pBuf);
		  }
		else
		  {
			m_pDoc->createDataItem(sID.utf8_str(), false, pBuf, mime_type, NULL);
			pItem->m_bHasSnapshot = true;
		  }
	  }
}
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);
}
Exemplo n.º 6
0
/*!
 * fill the properties vector with the values the given style.
 */
void AP_UnixDialog_Styles::new_styleName(void)
{
	static char message[200];
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	const gchar * psz = gtk_entry_get_text( GTK_ENTRY( m_wStyleNameEntry));
	UT_UTF8String s;
	UT_UTF8String s1;
	pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefNone,s);
	
	if(psz && strcmp(psz,s.utf8_str())== 0)
	{
		// TODO: do a real error dialog
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrNotTitle1,s);
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrNotTitle2,s1);
		sprintf(message,"%s%s%s",s.utf8_str(),psz,s1.utf8_str());
		messageBoxOK(static_cast<const char *>(message));
		return;
	}

	pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefCurrent,s);
	if(psz && strcmp(psz,s.utf8_str())== 0)
	{
		// TODO: do a real error dialog
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrNotTitle1,s);
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrNotTitle2,s1);
		sprintf(message,"%s%s%s",s.utf8_str(),psz,s1.utf8_str());
		messageBoxOK(static_cast<const char *>(message));
		return;
	}

	g_snprintf(static_cast<gchar *>(m_newStyleName),40,"%s",psz);
	addOrReplaceVecAttribs(PT_NAME_ATTRIBUTE_NAME,getNewStyleName());
}
Exemplo n.º 7
0
/*!  
 * Append all styles from the Psion Word Styles Section.
 */
UT_Error IE_Imp_Psion::applyStyles(const psiconv_word_styles_section style_sec)
{
	UT_UTF8String props;

	int i;
	gchar *stylename;
	psiconv_word_style style;
	UT_Error res;

	// Iterate through all defined styles.
	// Index -1 is misused to represent the default "Normal" style.
	for (i = -1; i < (int) psiconv_list_length(style_sec->styles); i++) {

		if (i == -1)
			style = style_sec->normal;
		else if (!(style = (psiconv_word_style)
		                    psiconv_list_get(style_sec->styles,i)))
			return UT_IE_IMPORTERROR;

		// Get the style paragraph and character attributes.
		props.clear();
		if ((res = getParagraphAttributes(style->paragraph,props)))
			return res;

		if ((res = getCharacterAttributes(style->character,props)))
			return res;

		// Not yet implemented: hotkey
		// Not yet implemented: built_in
		// Not yet implemented: outline_level
		// The three unimplemented features above are not yet available
		// within AbiWord.

		// Get the style name.
		if (i == -1)
			stylename = (gchar *) strdup("Normal");
		else
			stylename = prepare_style_name(style->name);
		if (!stylename)
			return UT_IE_NOMEMORY;

		UT_DEBUGMSG(("PSION: Importing style %s\n",stylename));
		UT_DEBUGMSG(("PSION: Style attributes: %s\n",props.utf8_str()));

		const PP_PropertyVector propsArray = {
			"props", props.utf8_str(),
			"name", stylename,
			// All Psion styles are based upon the Normal style
			"basedon", "Normal"
		};

		if (!(getDoc()->appendStyle(propsArray))) {
			UT_DEBUGMSG(("PSION: AppendStyle failed...\n"));
			free(stylename);
			return UT_IE_IMPORTERROR;
		}
		free(stylename);
	}
	return UT_OK;
}
void AP_UnixDialog_ToggleCase::_constructWindowContents (GtkWidget *vbox1)
{
  GSList *vbox1_group = NULL;
  GtkWidget *sentenceCase;
  GtkWidget *lowerCase;
  GtkWidget *upperCase;
  GtkWidget *firstUpperCase;
  GtkWidget *toggleCase;

  const XAP_StringSet * pSS = m_pApp->getStringSet();
  UT_UTF8String s;
  pSS->getValueUTF8(AP_STRING_ID_DLG_ToggleCase_SentenceCase,s);
  sentenceCase = gtk_radio_button_new_with_label (vbox1_group,s.utf8_str());
  vbox1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (sentenceCase));
  gtk_widget_show (sentenceCase);
  gtk_box_pack_start (GTK_BOX (vbox1), sentenceCase, FALSE, FALSE, 0);

  pSS->getValueUTF8(AP_STRING_ID_DLG_ToggleCase_LowerCase,s);
  lowerCase = gtk_radio_button_new_with_label (vbox1_group,s.utf8_str());
  vbox1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (lowerCase));
  gtk_widget_show (lowerCase);
  gtk_box_pack_start (GTK_BOX (vbox1), lowerCase, FALSE, FALSE, 0);

  pSS->getValueUTF8(AP_STRING_ID_DLG_ToggleCase_UpperCase,s);
  upperCase = gtk_radio_button_new_with_label (vbox1_group,s.utf8_str());
  vbox1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (upperCase));
  gtk_widget_show (upperCase);
  gtk_box_pack_start (GTK_BOX (vbox1), upperCase, FALSE, FALSE, 0);

  pSS->getValueUTF8(AP_STRING_ID_DLG_ToggleCase_FirstUpperCase,s);
  firstUpperCase = gtk_radio_button_new_with_label (vbox1_group,s.utf8_str());
  vbox1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (firstUpperCase));
  gtk_widget_show (firstUpperCase);
  gtk_box_pack_start (GTK_BOX (vbox1), firstUpperCase, FALSE, FALSE, 0);

  pSS->getValueUTF8(AP_STRING_ID_DLG_ToggleCase_ToggleCase,s);
  toggleCase = gtk_radio_button_new_with_label (vbox1_group,s.utf8_str());
  vbox1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggleCase));
  gtk_widget_show (toggleCase);
  gtk_box_pack_start (GTK_BOX (vbox1), toggleCase, FALSE, FALSE, 0);

  g_object_set_data (G_OBJECT(sentenceCase), "user_data", GINT_TO_POINTER(CASE_SENTENCE));
  g_object_set_data (G_OBJECT(lowerCase), "user_data", GINT_TO_POINTER(CASE_LOWER));
  g_object_set_data (G_OBJECT(upperCase), "user_data", GINT_TO_POINTER(CASE_UPPER));
  g_object_set_data (G_OBJECT(firstUpperCase), "user_data", GINT_TO_POINTER(CASE_FIRST_CAPITAL));
  g_object_set_data (G_OBJECT(toggleCase), "user_data", GINT_TO_POINTER(CASE_TOGGLE));

  g_signal_connect (G_OBJECT(sentenceCase), "toggled",
		      G_CALLBACK(s_toggled), (gpointer)this);
  g_signal_connect (G_OBJECT(lowerCase), "toggled",
		      G_CALLBACK(s_toggled), (gpointer)this);
  g_signal_connect (G_OBJECT(upperCase), "toggled",
		      G_CALLBACK(s_toggled), (gpointer)this);
  g_signal_connect (G_OBJECT(firstUpperCase), "toggled",
		      G_CALLBACK(s_toggled), (gpointer)this);
  g_signal_connect (G_OBJECT(toggleCase), "toggled",
		      G_CALLBACK(s_toggled), (gpointer)this);
}
Exemplo n.º 9
0
/*!
 * Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in"
 * Add aother propety string, updating previously defined properties with
 * values in the new string.
 */
void UT_UTF8String_addPropertyString(UT_UTF8String & sPropertyString, const UT_UTF8String & sNewProp)
{
	UT_sint32 iSize = static_cast<UT_sint32>(sNewProp.size());
	UT_sint32 iBase  =0;
	UT_UTF8String sProp;
	UT_UTF8String sVal;
	UT_UTF8String sSubStr;
	const char * szWork = NULL;
	const char * szLoc = NULL;
	while(iBase < iSize)
	{
		bool bBreakAtEnd = false;
		sSubStr = sNewProp.substr(iBase, iSize-iBase);
		szWork = sSubStr.utf8_str();
		szLoc = strstr(szWork,":");
		UT_sint32 iextra = 0;
		if(szLoc)
		{
		        UT_sint32 k = iBase;
			while(*sNewProp.substr(k,k).utf8_str() == ' ')
			{
			  k++;
			  iextra++;
			}
			sProp = sNewProp.substr(k,szLoc - szWork-iextra);
		}
		else
		{
			break;
		}
		iBase += szLoc-szWork+1;
		sSubStr = sNewProp.substr(iBase, iSize-iBase);
		szWork = sSubStr.utf8_str();
		szLoc = strstr(szWork,";");
		if(szLoc)
		{
			sVal = sNewProp.substr(iBase,szLoc - szWork);
			iBase += szLoc-szWork+1;
		}
		else
		{
			sVal = sNewProp.substr(iBase,iSize-iBase);
			bBreakAtEnd = true;
		}
		if((sProp.size()>0) && (sVal.size() >0))
		{
			UT_UTF8String_setProperty(sPropertyString,sProp,sVal);
		}
		else
		{
			break;
		}
		if(bBreakAtEnd)
		{
			break;
		}
	}
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
/** set the widget value as string */
void XAP_UnixWidget::setValueString(const UT_UTF8String &val)
{
	if (GTK_IS_ENTRY(m_widget)) {
		gtk_entry_set_text(GTK_ENTRY(m_widget), val.utf8_str());
	}
	else if (GTK_IS_LABEL(m_widget)) {
		gtk_label_set_text(GTK_LABEL(m_widget), val.utf8_str());
	}
	else {
		UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
	}
}
Exemplo n.º 12
0
void AP_UnixDialog_Lists::_setRadioButtonLabels(void)
{
	//	char *tmp;
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	UT_UTF8String s;
	PopulateDialogData();
	// Button 0 is Start New List, button 2 is resume list
	pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Start_New,s);
	gtk_label_set_text( GTK_LABEL(m_wStartNew_label), s.utf8_str());
	pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Resume,s);
	gtk_label_set_text( GTK_LABEL(m_wStartSub_label), s.utf8_str());
}
Exemplo n.º 13
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);
}
/**
 * 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);
}
Exemplo n.º 15
0
void AP_UnixDialog_FormatTOC::_createLevelItems(void)
{
	const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet ();
	UT_UTF8String s;

	GtkComboBox *combo;

	combo = GTK_COMBO_BOX(_getWidget("wLevelOption"));
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level1,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 1);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level2,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 2);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level3,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 3);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level4,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 4);
	gtk_combo_box_set_active(combo, 0);

//////////////////////////////////////////////////////////////////////////////

	combo = GTK_COMBO_BOX(_getWidget("wDetailsLevel"));
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level1,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 1);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level2,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 2);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level3,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 3);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level4,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 4);
	gtk_combo_box_set_active(combo, 0);
}
Exemplo n.º 16
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();
}
Exemplo n.º 17
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_PageSetup::doHeightEntry(void)
{
    UT_UTF8String sAfter = gtk_entry_get_text(GTK_ENTRY(m_entryPageHeight));

	m_PageSize.Set(fp_PageSize::psCustom  , getPageUnits());
	_setHeight(sAfter.utf8_str());

	{
		XAP_GtkSignalBlocker b(G_OBJECT(m_entryPageHeight), m_iEntryPageHeightID);
		int pos = gtk_editable_get_position(GTK_EDITABLE(m_entryPageHeight));
		gtk_entry_set_text( GTK_ENTRY(m_entryPageHeight),sAfter.utf8_str() );
		gtk_editable_set_position(GTK_EDITABLE(m_entryPageHeight), pos);
	}
	_updatePageSizeList();
}
Exemplo n.º 19
0
void AP_UnixDialog_FormatTOC::setStyle(GtkWidget * wid)
{
	UT_UTF8String sVal;
	GtkWidget * pLabel = static_cast<GtkWidget *> (g_object_get_data(G_OBJECT(wid),"display-widget"));
	UT_UTF8String sProp = static_cast<char *> (g_object_get_data(G_OBJECT(pLabel),"toc-prop"));
	if(g_ascii_strcasecmp("toc-heading-style",sProp.utf8_str()) != 0)
	{
		UT_String sNum =  UT_String_sprintf("%d",getMainLevel());
		sProp += sNum.c_str();
	}
	sVal = getNewStyle(sProp);
	gtk_label_set_text(GTK_LABEL(pLabel),sVal.utf8_str());
	setTOCProperty(sProp,sVal);
	applyTOCPropsToDoc();
}
void AP_UnixDialog_CollaborationShare::_setAccountHint(const UT_UTF8String& sHint)
{
	UT_DEBUGMSG(("AP_UnixDialog_CollaborationShare::_setAccountHint() - sHint: %s\n", sHint.utf8_str()));
	
	// show/hide the hint widgets
	GValue val;
	val.g_type = 0;
	g_value_init (&val, G_TYPE_BOOLEAN);
	g_value_set_boolean (&val, sHint != "");
	g_object_set_property(G_OBJECT(m_wAccountHintSpacer), "visible", &val);
	g_object_set_property(G_OBJECT(m_wAccountHintHbox), "visible", &val);

	// set the hint
	gtk_label_set_text(GTK_LABEL(m_wAccountHint), sHint.utf8_str());
}
Exemplo n.º 21
0
/** set the widget label */
void XAP_UnixWidget::setLabel(const UT_UTF8String &val)
{
	if (GTK_IS_BUTTON(m_widget)) {
		gtk_button_set_label(GTK_BUTTON(m_widget), val.utf8_str());
	}
	else if (GTK_IS_LABEL(m_widget)) {
		gtk_label_set_text(GTK_LABEL(m_widget), val.utf8_str());
	}
	else if (GTK_IS_WINDOW(m_widget)) {
		gtk_window_set_title(GTK_WINDOW(m_widget), val.utf8_str());
	}
	else {
		UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
	}
}
Exemplo n.º 22
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());
}
Exemplo n.º 23
0
GtkWidget *  AP_UnixDialog_Styles::_constructModifyDialog(void)
{
	GtkWidget *modifyDialog;
	GtkWidget *dialog_action_area;
	const XAP_StringSet * pSS = m_pApp->getStringSet();

	UT_UTF8String title;

	if(!isNew())
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ModifyTitle,title);
	else
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_NewTitle,title);

	modifyDialog = abiDialogNew("modify style dialog", TRUE, title.utf8_str());
	gtk_container_set_border_width (GTK_CONTAINER (modifyDialog), 5);

	_constructModifyDialogContents(gtk_dialog_get_content_area(GTK_DIALOG (modifyDialog)));

	dialog_action_area = gtk_dialog_get_action_area(GTK_DIALOG (modifyDialog));
	gtk_widget_show (dialog_action_area);

	m_wModifyDialog = modifyDialog;

//
// Gnome buttons
//
	_constructGnomeModifyButtons(dialog_action_area);
//
// Connect signals
//

	_connectModifySignals();
	return modifyDialog;
}
Exemplo n.º 24
0
/*!
 * returns true if local UUID is the same as the document users UUID. Useful 
 * for AbiCollab
 */
bool PX_ChangeRecord::isFromThisDoc(void) const
{
  if(!m_pDoc)
    return false;
  UT_UTF8String sDoc;
  m_pDoc->getOrigDocUUID()->toString(sDoc);
  static char s[37];

  if(!UT_UUID::toStringFromBinary(s, sizeof(s), m_MyDocUUID))
		return false;
  xxx_UT_DEBUGMSG(("Orig UUID %s \n",sDoc.utf8_str()));
  xxx_UT_DEBUGMSG(("CR Doc UUID %s \n",s));
  bool b=  (strcmp(sDoc.utf8_str(),s) == 0);
  xxx_UT_DEBUGMSG((" bool %d \n",b));
  return b;
}
UT_UTF8String IE_Exp_HTML_NavigationHelper::getFilenameByPosition(
    PT_DocPosition position) const
{
    PT_DocPosition posCurrent;
	char * s = UT_go_basename_from_uri(m_baseName);
    UT_UTF8String chapterFile = s;
	g_free(s);

    if (hasTOC())
    {
        for (int i = getNumTOCEntries() - 1; i >= m_minTOCIndex; i--)
        {
            int currentLevel;
            getNthTOCEntry(i, &currentLevel);
            getNthTOCEntryPos(i, posCurrent);

            if (currentLevel == m_minTOCLevel)
            {
                if ((i != m_minTOCIndex) && (posCurrent <= position))
                {
                    chapterFile = ConvertToClean(getNthTOCEntry(i, NULL)) + m_suffix;
                    break;
                }
                else if ((i == m_minTOCIndex) && (posCurrent >= position))
                {
                    break;
                }
            }
        }
    }

    UT_DEBUGMSG(("Got filename by position: %s\n", chapterFile.utf8_str()));
    return chapterFile;
}
IE_Exp_HTML_NavigationHelper::IE_Exp_HTML_NavigationHelper(
    PD_Document* pDocument, const UT_UTF8String &baseName)
: IE_TOCHelper(pDocument),
  m_suffix(""),
  m_minTOCLevel(0),
  m_minTOCIndex(0),
  m_baseName(UT_go_basename_from_uri(baseName.utf8_str()))
{
    m_suffix = strchr(m_baseName, '.');
    m_minTOCLevel = 10;
    for (int i = 0; i < getNumTOCEntries(); i++)
    {
        int currentLevel = 10;
        getNthTOCEntry(i, &currentLevel);
        if (currentLevel < m_minTOCLevel)
        {
            m_minTOCLevel = currentLevel;
            m_minTOCIndex = i;
        }
    }
            
    IE_Exp_HTML_BookmarkListener * bookmarkListener =
        new IE_Exp_HTML_BookmarkListener(pDocument, this);
    pDocument->tellListener(bookmarkListener);
    DELETEP(bookmarkListener);
}
void AP_Dialog_EpubExportOptions::saveDefaults()
{
    UT_ASSERT(m_app);
    if (m_app == NULL) return;

    XAP_Prefs * pPrefs = m_app->getPrefs();
    if (pPrefs == NULL) return;

    XAP_PrefsScheme * pPScheme = pPrefs->getCurrentScheme();
    if (pPScheme == NULL) return;

    UT_UTF8String pref;

    if (m_exp_opt->bEpub2) {
        if (pref.byteLength()) pref += ",";
        pref += "EPUB2";
    }
    if (m_exp_opt->bSplitDocument) {
        if (pref.byteLength()) pref += ",";
        pref += "split-document";
    }
    if (m_exp_opt->bRenderMathMLToPNG) {
        if (pref.byteLength()) pref += ",";
        pref += "mathml-to-png";
    }

    const gchar * szValue = (const gchar *) pref.utf8_str();

    pPScheme->setValue(EPUB_EXPORT_SCHEME_NAME, szValue);
}
Exemplo n.º 28
0
void GR_MathManager::loadEmbedData(UT_sint32 uid)
{
	SmartPtr<libxml2_MathView>  pMathView = m_vecMathView.getNthItem(uid);
	UT_return_if_fail(pMathView);

	const PP_AttrProp * pSpanAP = NULL;
	GR_AbiMathItems * pItem = m_vecItems.getNthItem(uid);
	UT_return_if_fail(pItem);  

	PT_AttrPropIndex api = pItem->m_iAPI;
	m_pDoc->getAttrProp(api, &pSpanAP);

	const char * pszDataID = NULL;
	bool bFoundDataID = pSpanAP->getAttribute("dataid", pszDataID);
	UT_DEBUGMSG(("DataID val =%s \n",pszDataID));

	UT_UTF8String sMathML;
	if (bFoundDataID && pszDataID)
	{
		const UT_ByteBuf * pByteBuf = NULL;
		bFoundDataID = m_pDoc->getDataItemDataByName(pszDataID, 
						const_cast<const UT_ByteBuf **>(&pByteBuf),
						NULL, NULL);
		UT_return_if_fail(pByteBuf && bFoundDataID);
		UT_UCS4_mbtowc myWC;
		sMathML.appendBuf( *pByteBuf, myWC);
	}

	UT_return_if_fail(bFoundDataID);
	UT_return_if_fail(pszDataID);
	UT_DEBUGMSG(("MATH ML string is... \n %s \n",sMathML.utf8_str()));
	// printf("MATH ML string is... \n %s \n",sMathML.utf8_str());
	_loadMathML(uid, sMathML);
}
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);
	}
}
Exemplo n.º 30
0
bool GR_MathManager::updatePNGSnapshot(AD_Document * pDoc, UT_Rect & rec,
					   const char * szDataID)
{
	if (isDefault())
	{
		return false;
	}

	GR_Painter painter(getGraphics());
	GR_Image * pImage = painter.genImageFromRectangle(rec);
	if(pImage == NULL)
	{
	    return false;
	}
	UT_ByteBuf * pBuf = NULL;

	pImage->convertToBuffer(&pBuf);
	UT_UTF8String sID = "snapshot-png-";
	sID += szDataID;

	pDoc->replaceDataItem(sID.utf8_str(),reinterpret_cast< const UT_ByteBuf *>(pBuf));

	DELETEP(pBuf);
	DELETEP(pImage);

	return true;
}