// // AbiGOComponent_FileInsert // ------------------- // This is the function that we actually call to insert a component using // data from a file. // bool AbiGOComponent_FileInsert(G_GNUC_UNUSED AV_View* v, G_GNUC_UNUSED EV_EditMethodCallData *d) { // Get the current view that the user is in. XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame(); PD_Document * pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc()); char* pNewFile = NULL; IEGraphicFileType iegft = IEGFT_Unknown; bool bOK = s_AskForGOComponentPathname(pFrame,&pNewFile,&iegft); 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(("fileInsertObject: loading [%s]\n",sNewFile.utf8_str())); char *mime_type = go_get_mime_type(sNewFile.utf8_str()); IE_Imp_Component * pImpComponent = new IE_Imp_Component(pDoc, mime_type); g_free(mime_type); UT_Error errorCode = pImpComponent->importFile(sNewFile.utf8_str()); DELETEP(pImpComponent); if(errorCode != UT_OK) { s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode); return false; } return true; }
void s_XSL_FO_Listener::_tagOpen(UT_uint32 tagID, const UT_UTF8String & content, bool newline) { m_pie->write("<"); m_pie->write("fo:"); //this might be unnecessary one day, so keep this here for easier removal (see bug 4355, comment 6) m_pie->write(content.utf8_str()); m_pie->write(">"); if(newline) m_pie->write("\n"); m_utnsTagStack.push(tagID); xxx_UT_DEBUGMSG(("XSL-FO export: Pushing %d onto stack\n",tagID)); }
UT_UTF8String IE_Exp_HTML_NavigationHelper::getBookmarkFilename( const UT_UTF8String& id) const { std::map<UT_UTF8String, UT_UTF8String>::const_iterator bookmarkIter = m_bookmarks.find(id); if (bookmarkIter != m_bookmarks.end()) { UT_DEBUGMSG(("Found bookmark %s at file %s", id.utf8_str(), bookmarkIter->second.utf8_str())); return bookmarkIter->second; } else { return UT_UTF8String(); } }
/** 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)) { if(!gtk_label_get_use_markup(GTK_LABEL(m_widget))) { gtk_label_set_text(GTK_LABEL(m_widget), val.utf8_str()); } else { std::string markup = UT_std_string_sprintf(m_data.c_str(), val.utf8_str()); gtk_label_set_label(GTK_LABEL(m_widget), markup.c_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); } }
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); }
/*! * Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in" * Add the property sProp with value sVal to the string of properties. If the property is already present, replace the * old value with the new value. */ void UT_UTF8String_setProperty(UT_UTF8String & sPropertyString, const UT_UTF8String & sProp, const UT_UTF8String & sVal) { // // Remove the old value if it exists and tack the new property on the end. // UT_UTF8String_removeProperty(sPropertyString, sProp); if(sPropertyString.size() > 0) { sPropertyString += "; "; } sPropertyString += sProp; sPropertyString += ":"; sPropertyString += sVal; }
const char * AP_UnixDialog_Styles::getCurrentStyle (void) const { static UT_UTF8String sStyleBuf; UT_ASSERT(m_tvStyles); if (!m_selectedStyle) return NULL; gchar * style = NULL; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_tvStyles)); GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, m_selectedStyle); gtk_tree_model_get(model, &iter, 0, &style, -1); if (!style) return NULL; sStyleBuf = style; g_free(style); return sStyleBuf.utf8_str(); }
void AP_UnixDialog_Styles::event_DeleteClicked(void) { if (m_selectedStyle) { m_sNewStyleName = ""; gchar * style = NULL; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_tvStyles)); GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, m_selectedStyle); gtk_tree_model_get(model, &iter, 0, &style, -1); if (!style) return; // ok, nothing's selected. that's fine UT_DEBUGMSG(("DOM: attempting to delete style %s\n", style)); if (!getDoc()->removeStyle(style)) // actually remove the style { const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete,s); const gchar * msg = s.utf8_str(); getFrame()->showMessageBox (static_cast<const char *>(msg), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return; } g_free(style); getFrame()->repopulateCombos(); _populateWindowData(); // force a refresh getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); } }
void ODe_DocumentData::handleDefaultTabInterval(ODe_Style_Style* pStyle) { UT_return_if_fail(pStyle); UT_UTF8String defaultTabInterval = pStyle->getDefaultTabInterval(); if (defaultTabInterval.empty()) return; // remove the default tab interval property from the style pStyle->setDefaultTabInterval(""); // ... and create a default style to hold the default tab interval property ODe_Style_Style* pDefaultStyle = m_styles.getDefaultStyles().getStyle("paragraph"); if (!pDefaultStyle) { pDefaultStyle = new ODe_Style_Style(); pDefaultStyle->setFamily("paragraph"); pDefaultStyle->makeDefaultStyle(); m_styles.getDefaultStyles().storeStyle("paragraph", pDefaultStyle); } // NOTE: if a paragraph default style already exists with a default tab interval // property set, then we'll just overwrite it. This can happen because AbiWord // supports such a property on every paragraph and paragraph style, but ODT only // supports one on the default paragraph style. pDefaultStyle->setDefaultTabInterval(defaultTabInterval); }
void AP_UnixDialog_FormatTOC::setMainLevel(UT_sint32 iLevel) { AP_Dialog_FormatTOC::setMainLevel(iLevel); UT_UTF8String sVal; sVal = getTOCPropVal("toc-dest-style",getMainLevel()); GtkWidget * pW= _getWidget("wDispStyle"); gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str()); sVal = getTOCPropVal("toc-has-label",getMainLevel()); pW = _getWidget("wHasLabel"); if(g_ascii_strcasecmp(sVal.utf8_str(),"1") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),FALSE); } sVal = getTOCPropVal("toc-source-style",getMainLevel()); pW = _getWidget("wFillStyle"); gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str()); }
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; }
bool AP_UnixDialog_Styles::event_Modify_OK(void) { const char * text = gtk_entry_get_text (GTK_ENTRY (m_wStyleNameEntry)); if (!text || !strlen (text)) { // error message! const XAP_StringSet * pSS = m_pApp->getStringSet (); UT_UTF8String s; pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrBlankName,s); const char * msg = s.utf8_str(); getFrame()->showMessageBox (static_cast<const char *>(msg), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return false; } // TODO save out state of radio items m_answer = AP_Dialog_Styles::a_OK; return true; }
bool GR_EmbedView::getSnapShots(void) { UT_UTF8String sName = "snapshot-png-"; sName += m_sDataID; bool bFound = false; PD_DataItemHandle pHandle = NULL; UT_ConstByteBufPtr pPNG; UT_ConstByteBufPtr pSVG; bFound = m_pDoc->getDataItemDataByName(sName.utf8_str(), pPNG, NULL, &pHandle); if(!bFound) { m_bHasPNGSnapshot = false; } else { auto buf = UT_ByteBufPtr(new UT_ByteBuf); buf->ins(0, pPNG->getPointer(0), pPNG->getLength()); m_PNGBuf = buf; m_bHasPNGSnapshot = true; } sName = "snapshot-svg-"; sName += m_sDataID; bFound = m_pDoc->getDataItemDataByName(sName.utf8_str(), pSVG, NULL, &pHandle); if(!bFound) { m_bHasSVGSnapshot = false; } else { auto buf = UT_ByteBufPtr(new UT_ByteBuf); buf->ins(0, pSVG->getPointer(0), pSVG->getLength()); m_SVGBuf = buf; m_bHasSVGSnapshot = true; } return true; }
// // 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 ABI_Collab_Export::slaveInit(const UT_UTF8String& docUUID, UT_sint32 iRemoteRev) { UT_DEBUGMSG(("ABI_Collab_Export::slaveInit() - docUUID: %s, iRev: %d\n", docUUID.utf8_str(), iRemoteRev)); // NOTE: it's important that this function resets all state, as it can be // called in the middle of an already running collaboration session // (eg. when a session takeover happens) _cleanup(); _init(); // initialize the adjustment stack ChangeRecordSessionPacket voidPacket; voidPacket.setDocUUID(docUUID); voidPacket.setRev(iRemoteRev); m_pAbiCollab->addChangeAdjust(new ChangeAdjust(voidPacket, static_cast<PT_DocPosition>(0), docUUID)); }
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(); }
void AP_UnixDialog_FormatFrame::setBorderThicknessInGUI(UT_UTF8String & sThick) { double thickness = UT_convertToInches(sThick.utf8_str()); guint i =0; guint closest = 0; double dClose = 100000000.; for(i=0; i<FORMAT_FRAME_NUMTHICKNESS; i++) { double diff = thickness - m_dThickness[i]; if(diff < 0) diff = -diff; if(diff < dClose) { closest = i; dClose = diff; } } XAP_GtkSignalBlocker b(G_OBJECT(m_wBorderThickness),m_iBorderThicknessConnect); gtk_combo_box_set_active(GTK_COMBO_BOX(m_wBorderThickness), closest); }
void s_XSL_FO_Listener::_tagClose(UT_uint32 tagID, const UT_UTF8String & content, bool newline) { UT_uint32 i = 0; m_pie->write("</"); m_pie->write("fo:"); //this might be unnecessary one day, so keep this here for easier removal (see bug 4355, comment 6) m_pie->write(content.utf8_str()); m_pie->write(">"); if(newline) m_pie->write("\n"); m_utnsTagStack.pop((UT_sint32*)&i); m_iLastClosed = i; xxx_UT_DEBUGMSG(("XSL-FO export: Popping %d off of stack\n",i)); if(i != tagID) { UT_DEBUGMSG(("XSL-FO export: possible mismatched tag. Requested: %d, Popped: %d\n",tagID,i)); } }
static UT_UTF8String s_canonical_thickness (const UT_UTF8String & sThickness, float & thickness) { thickness = static_cast<float>(UT_convertToPoints(sThickness.utf8_str())); UT_UTF8String sThick; if (thickness < 0.01) { thickness = 0.01f; sThick = "0.01pt"; } else if (thickness > 99.99) { thickness = 99.99f; sThick = "99.99pt"; } else { char buf[16]; UT_LocaleTransactor t(LC_NUMERIC, "C"); sprintf(buf, "%.2fpt", thickness); sThick = buf; } return sThick; }
bool GR_MathManager::convert(UT_uint32 iConType, UT_ByteBuf & From, UT_ByteBuf & To) { XAP_App * pApp = XAP_App::getApp(); XAP_Frame * pFrame = pApp->getLastFocussedFrame(); if (iConType != 0) { return false; } /* add a pair of enclosing brackets \[ \] */ UT_UTF8String sLatex; UT_UCS4_mbtowc myWC; sLatex += "\\["; sLatex.appendBuf(From, myWC); sLatex += "\\]"; char * mathml = itex2MML_parse(sLatex.utf8_str(), sLatex.size()); if (!mathml) { pFrame->showMessageBox("itex2MML failed to convert the LaTeX equation into MathML, sorry!\n", // TODO: fix message XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return false; } UT_UTF8String sMathML(mathml); itex2MML_free_string(mathml); if (sMathML.size() == 0) { UT_UTF8String sErrMessage = "itex2MML conversion from LaTex equation resulted in zero-length MathML!\n"; // TODO: fix message //sErrMessage += sLatex; sErrMessage += "\n"; // sErrMessage += FullLine; pFrame->showMessageBox(sErrMessage.utf8_str(), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return false; } UT_DEBUGMSG(("Input MathML %s \n", sMathML.utf8_str())); return EntityTable().convert(sMathML.utf8_str(), sMathML.size(), To); }
void AP_UnixDialog_Spell::_updateWindow (void) { GtkTextBuffer * buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(m_txWrong)); GtkTextIter iter2; // Empty buffer gtk_text_buffer_set_text(buffer, "", -1); const UT_UCSChar *p; UT_sint32 iLength; // insert start of sentence p = m_pWordIterator->getPreWord(iLength); if (0 < iLength) { gchar * preword = (gchar*) _convertToMB(p, iLength); gtk_text_buffer_set_text(buffer, preword, -1); FREEP(preword); } // insert misspelled word (in highlight color) p = m_pWordIterator->getCurrentWord(iLength); gchar * word = (gchar*) _convertToMB(p, iLength); GtkTextTag * txt_tag = gtk_text_buffer_create_tag(buffer, NULL, "foreground-gdk", &m_highlight, NULL); gtk_text_buffer_get_end_iter(buffer, &iter2); gtk_text_buffer_insert_with_tags(buffer, &iter2, word, -1, txt_tag, NULL); // word is freed at the end of the method... // insert end of sentence p = m_pWordIterator->getPostWord(iLength); if (0 < iLength) { gchar * postword = (gchar*) _convertToMB(p, iLength); gtk_text_buffer_get_end_iter(buffer, &iter2); gtk_text_buffer_insert(buffer, &iter2, postword, -1); FREEP(postword); } else { // Insert space to make gtk_text_buffer understand that it // really should highlight the selected word. This is a // workaround for bug 5459. It really should be fixed in GTK. gtk_text_buffer_get_end_iter(buffer, &iter2); gtk_text_buffer_insert(buffer, &iter2, " ", -1); } // TODO: set scroll position so misspelled word is centered GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvSuggestions)); // Detach model for faster updates g_object_ref (G_OBJECT (model)); gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), NULL); gtk_list_store_clear (GTK_LIST_STORE (model)); GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions)); UT_DEBUGMSG (("ROB: AP_UnixDialog_Spell::_updateWindow() itemcount=%d\n", m_Suggestions->getItemCount ())); if (m_Suggestions->getItemCount () == 0) { GtkTreeIter iter; gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE); const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; pSS->getValueUTF8(AP_STRING_ID_DLG_Spell_NoSuggestions,s); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_SUGGESTION, s.utf8_str (), COLUMN_NUMBER, -1, -1); g_signal_handler_block(G_OBJECT(m_eChange), m_replaceHandlerID); gtk_entry_set_text(GTK_ENTRY(m_eChange), word); g_signal_handler_unblock(G_OBJECT(m_eChange), m_replaceHandlerID); } else { GtkTreeIter iter; gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); gchar * suggest = NULL; for (UT_sint32 i = 0; i < m_Suggestions->getItemCount(); i++) { suggest = (gchar*) _convertToMB((UT_UCSChar*)m_Suggestions->getNthItem(i)); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_SUGGESTION, suggest, COLUMN_NUMBER, i, -1); } // put the first suggestion in the entry suggest = (gchar*) _convertToMB((UT_UCSChar*)m_Suggestions->getNthItem(0)); g_signal_handler_block(G_OBJECT(m_eChange), m_replaceHandlerID); gtk_entry_set_text(GTK_ENTRY(m_eChange), suggest); g_signal_handler_unblock(G_OBJECT(m_eChange), m_replaceHandlerID); } gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), model); g_object_unref (G_OBJECT (model)); // select first if (m_Suggestions->getItemCount () > 0) { GtkTreePath *path = gtk_tree_path_new_first (); gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); } FREEP (word); }
/*! * Set up the dialog. */ GtkWidget * AP_UnixDialog_Spell::_constructWindow (void) { // get the path where our UI file is located std::string ui_path = static_cast<XAP_UnixApp*>(XAP_App::getApp())->getAbiSuiteAppUIDir() + "/ap_UnixDialog_Spell.xml"; // load the dialog from the UI file GtkBuilder* builder = gtk_builder_new(); gtk_builder_add_from_file(builder, ui_path.c_str(), NULL); m_wDialog = GTK_WIDGET(gtk_builder_get_object(builder, "ap_UnixDialog_Spell")); const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; pSS->getValueUTF8(AP_STRING_ID_DLG_Spell_SpellTitle,s); gtk_window_set_title (GTK_WINDOW( m_wDialog), s.utf8_str()); localizeLabelUnderline(GTK_WIDGET(gtk_builder_get_object(builder, "lbNotInDict")), pSS, AP_STRING_ID_DLG_Spell_UnknownWord); localizeLabelUnderline(GTK_WIDGET(gtk_builder_get_object(builder, "lbChangeTo")), pSS, AP_STRING_ID_DLG_Spell_ChangeTo); m_txWrong = GTK_WIDGET(gtk_builder_get_object(builder, "txWrong")); m_eChange = GTK_WIDGET(gtk_builder_get_object(builder, "eChange")); m_lvSuggestions = GTK_WIDGET(gtk_builder_get_object(builder, "tvSuggestions")); // localise localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnore")), pSS, AP_STRING_ID_DLG_Spell_Ignore); localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnoreAll")), pSS, AP_STRING_ID_DLG_Spell_IgnoreAll); localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btChange")), pSS, AP_STRING_ID_DLG_Spell_Change); localizeButtonUnderline (GTK_WIDGET(gtk_builder_get_object(builder, "btChangeAll")), pSS, AP_STRING_ID_DLG_Spell_ChangeAll); // attach signals g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btAdd")), "clicked", G_CALLBACK (AP_UnixDialog_Spell__onAddClicked), (gpointer)this); g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnore")), "clicked", G_CALLBACK (AP_UnixDialog_Spell__onIgnoreClicked), (gpointer)this); g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btIgnoreAll")), "clicked", G_CALLBACK (AP_UnixDialog_Spell__onIgnoreAllClicked), (gpointer)this); g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btChange")), "clicked", G_CALLBACK (AP_UnixDialog_Spell__onChangeClicked), (gpointer)this); g_signal_connect (GTK_WIDGET(gtk_builder_get_object(builder, "btChangeAll")), "clicked", G_CALLBACK (AP_UnixDialog_Spell__onChangeAllClicked), (gpointer)this); g_signal_connect (GTK_TREE_VIEW (m_lvSuggestions), "row-activated", G_CALLBACK (AP_UnixDialog_Spell__onSuggestionDblClicked), (gpointer)this); m_replaceHandlerID = g_signal_connect (G_OBJECT(m_eChange), "changed", G_CALLBACK (AP_UnixDialog_Spell__onSuggestionChanged), (gpointer)this); // highlight our misspelled word in red GdkColormap * cm = gdk_colormap_get_system(); m_highlight.red = 0xffff; m_highlight.green = 0x0000; m_highlight.blue = 0x0000; gdk_colormap_alloc_color(cm, &m_highlight, FALSE, TRUE); // Liststore and -view GtkListStore *store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_UINT); gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), GTK_TREE_MODEL (store)); g_object_unref (G_OBJECT (store)); // Column Suggestion GtkCellRenderer *renderer = NULL; renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (m_lvSuggestions), -1, "Name", renderer, "text", COLUMN_SUGGESTION, NULL); GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (m_lvSuggestions), 0); gtk_tree_view_column_set_sort_column_id (column, COLUMN_SUGGESTION); m_listHandlerID = g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions)), "changed", G_CALLBACK (AP_UnixDialog_Spell__onSuggestionSelected), (gpointer)this); gtk_widget_show_all (m_wDialog); g_object_unref(G_OBJECT(builder)); return m_wDialog; }
bool IE_Exp_OpenXML_Listener::populate(fl_ContainerLayout* /* sfh */, const PX_ChangeRecord* pcr) { switch (pcr->getType()) { case PX_ChangeRecord::PXT_InsertSpan: { const PX_ChangeRecord_Span* pcrs = static_cast<const PX_ChangeRecord_Span*>(pcr); PT_BufIndex buffer = pcrs->getBufIndex(); const UT_UCSChar* pData = pdoc->getPointer(buffer); if(*pData == UCS_FF) { paragraph->setPageBreak(); return true; } UT_UCS4String str(pData, pcrs->getLength()); OXML_SharedElement shared_element_text(new OXML_Element_Text(str.utf8_str(), str.length())); OXML_Element_Run* element_run = new OXML_Element_Run(getNextId()); OXML_SharedElement shared_element_run(static_cast<OXML_Element*>(element_run)); //add run properties PT_AttrPropIndex api = pcr->getIndexAP(); const PP_AttrProp* pAP = NULL; bool bHaveProp = pdoc->getAttrProp(api,&pAP); if(bHaveProp && pAP) { const gchar* szValue; const gchar* szName; size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { if(element_run->setProperty(szName, szValue) != UT_OK) return false; } } } if(bInHyperlink) { //make sure hyperlinks are blue and underlined if(element_run->setProperty("text-decoration", "underline") != UT_OK) return false; if(element_run->setProperty("color", "0000FF") != UT_OK) return false; if(hyperlink->appendElement(shared_element_run) != UT_OK) return false; } else { if(paragraph->appendElement(shared_element_run) != UT_OK) return false; } return element_run->appendElement(shared_element_text) == UT_OK; } case PX_ChangeRecord::PXT_InsertObject: { const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr); PT_AttrPropIndex api = pcr->getIndexAP(); const PP_AttrProp* pAP = NULL; bool bHaveProp = pdoc->getAttrProp(api,&pAP); const gchar* szValue; const gchar* szName; switch (pcro->getObjectType()) { case PTO_Field: { fd_Field* field = pcro->getField(); switch(field->getFieldType()) { case fd_Field::FD_ListLabel: { OXML_Element_List* element_list = new OXML_Element_List(getNextId(), paragraph); OXML_SharedElement shared_element_list(static_cast<OXML_Element*>(element_list)); if(bHaveProp && pAP) { size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("List Property %s=%s\n", szName, szValue)); if(element_list->setProperty(szName, szValue) != UT_OK) return false; } } size_t attrCount = pAP->getAttributeCount(); for(i=0; i<attrCount; i++) { if(pAP->getNthAttribute(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("List Attribute: %s=%s\n", szName, szValue)); if(element_list->setAttribute(szName, szValue) != UT_OK) return false; } } } return paragraph->appendElement(shared_element_list) == UT_OK; } default: { UT_UTF8String value = field->getValue(); // getValue() can return NULL OXML_Element_Field* element_field = new OXML_Element_Field(getNextId(), field->getFieldType(), value.utf8_str()); OXML_SharedElement shared_element_field(static_cast<OXML_Element*>(element_field)); if(bHaveProp && pAP) { size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Field Property %s=%s\n", szName, szValue)); if(element_field->setProperty(szName, szValue) != UT_OK) return false; } } size_t attrCount = pAP->getAttributeCount(); for(i=0; i<attrCount; i++) { if(pAP->getNthAttribute(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Field Attribute: %s=%s\n", szName, szValue)); if(element_field->setAttribute(szName, szValue) != UT_OK) return false; } } } return paragraph->appendElement(shared_element_field) == UT_OK; } } } case PTO_Hyperlink: { if(bInHyperlink) { bInHyperlink = false; return true; } bInHyperlink = true; hyperlink = new OXML_Element_Hyperlink(getNextId()); OXML_SharedElement shared_element_hyperlink(static_cast<OXML_Element*>(hyperlink)); if(bHaveProp && pAP) { size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Hyperlink Property %s=%s\n", szName, szValue)); if(hyperlink->setProperty(szName, szValue) != UT_OK) return false; } } size_t attrCount = pAP->getAttributeCount(); for(i=0; i<attrCount; i++) { if(pAP->getNthAttribute(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Hyperlink Attribute: %s=%s\n", szName, szValue)); if(hyperlink->setAttribute(szName, szValue) != UT_OK) return false; } } } return paragraph->appendElement(shared_element_hyperlink) == UT_OK; } case PTO_Image: { OXML_Element_Run* element_run = new OXML_Element_Run(getNextId()); OXML_SharedElement shared_element_run(static_cast<OXML_Element*>(element_run)); if(paragraph->appendElement(shared_element_run) != UT_OK) return false; OXML_Element_Image* element_image = new OXML_Element_Image(getNextId()); OXML_SharedElement shared_element_image(static_cast<OXML_Element*>(element_image)); if(bHaveProp && pAP) { size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Image Property %s=%s\n", szName, szValue)); if(element_image->setProperty(szName, szValue) != UT_OK) return false; } } size_t attrCount = pAP->getAttributeCount(); for(i=0; i<attrCount; i++) { if(pAP->getNthAttribute(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Image Attribute: %s=%s\n", szName, szValue)); if(element_image->setAttribute(szName, szValue) != UT_OK) return false; } } } return element_run->appendElement(shared_element_image) == UT_OK; } case PTO_Bookmark: { if(bHaveProp && pAP) { if(!pAP->getAttribute("name", szValue)) { UT_DEBUGMSG(("FRT:OpenXML exporter bookmark without name attribute\n")); return true; } std::string bookmarkName(szValue); if(!pAP->getAttribute("type", szValue)) { UT_DEBUGMSG(("FRT:OpenXML exporter bookmark without type attribute\n")); return true; } std::string bookmarkType(szValue); std::string bookmarkId(""); if(!bookmarkType.compare("start")) { bookmarkId = getNextId(); document->setBookmarkName(bookmarkId, bookmarkName); } else if(!bookmarkType.compare("end")) { bookmarkId = document->getBookmarkId(bookmarkName); } else { UT_DEBUGMSG(("FRT:OpenXML exporter bookmark with invalid type attribute=%s\n", bookmarkType.c_str())); return true; } OXML_Element_Bookmark* bookmark = new OXML_Element_Bookmark(bookmarkId); bookmark->setName(bookmarkId); OXML_SharedElement shared_element_bookmark(static_cast<OXML_Element*>(bookmark)); size_t propCount = pAP->getPropertyCount(); size_t i; for(i=0; i<propCount; i++) { if(pAP->getNthProperty(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Bookmark Property %s=%s\n", szName, szValue)); if(bookmark->setProperty(szName, szValue) != UT_OK) return false; } } size_t attrCount = pAP->getAttributeCount(); for(i=0; i<attrCount; i++) { if(pAP->getNthAttribute(i, szName, szValue)) { //TODO: Take the debug message out when we are done UT_DEBUGMSG(("Bookmark Attribute: %s=%s\n", szName, szValue)); if(bookmark->setAttribute(szName, szValue) != UT_OK) return false; } } return paragraph->appendElement(shared_element_bookmark) == UT_OK; } return true; } default: return true; } } case PX_ChangeRecord::PXT_InsertFmtMark: default: return true; } return true; }
/*! * Get all character-related attributes and append them to props. * * If props is not empty, we start with '; ', else we do not. */ UT_Error IE_Imp_Psion::getCharacterAttributes(const psiconv_character_layout layout, UT_UTF8String &props) { UT_return_val_if_fail(layout != NULL, true /* perhaps should be false, but we want loading to proceed */); UT_UTF8String buffer; int fontsize; UT_UCS4Char ucs4char; int i; // Append a semicolon if there is already text in the props if (props.length()) props += "; "; // font family // BUG: No checking is done yet whether this family is known to AbiWord. // We need to sanitize the font name first, or we could confuse the // properties parser. props += "font-family:"; for (i = 0; i < psiconv_unicode_strlen(layout->font->name); i++) { ucs4char = layout->font->name[i]; if ((ucs4char < 0x20) || (ucs4char == ';') || (ucs4char == ':')) ucs4char = '?'; props.appendUCS4(&ucs4char,1); } // font size. // This should be moved to some general-purpose function. // At the moment, only the following font-sizes seem to be supported // by the GUI: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, // 36, 48 and 72. Others give GTK errors. This should be changed I think. fontsize = (int) layout->font_size; if (fontsize < 8) fontsize = 8; if ((fontsize % 2) && (fontsize > 11)) fontsize -=1; if (fontsize > 28) { if (fontsize < 32) fontsize = 28; else if (fontsize < 42) fontsize = 36; else if (fontsize < 60) fontsize = 48; else fontsize = 72; } UT_UTF8String_sprintf(buffer,"; font-size:%dpt",fontsize); props += buffer; // bold UT_UTF8String_sprintf(buffer, "; font-weight:%s", layout->bold ? "bold" : "normal"); props += buffer; // italic UT_UTF8String_sprintf(buffer, "; font-style:%s",layout->italic ? "italic" : "normal"); props += buffer; // underline and strike-through UT_UTF8String_sprintf(buffer, "; text-decoration:%s", layout->underline && layout->strikethrough?"underline line-through": layout->underline && !layout->strikethrough?"underline": !layout->underline && layout->strikethrough?"line-through": "none"); props += buffer; // superscript and subscript UT_UTF8String_sprintf(buffer, "; text-position:%s", layout->super_sub == psiconv_superscript?"superscript": layout->super_sub == psiconv_subscript ?"subscript": "normal"); props += buffer; // text color UT_UTF8String_sprintf(buffer, "; color:%02x%02x%02x", (layout->color->red), (layout->color->green), (layout->color->blue)); props += buffer; // background color UT_UTF8String_sprintf(buffer, "; bgcolor:%02x%02x%02x", layout->back_color->red, layout->back_color->green, layout->back_color->blue); props += buffer; return UT_OK; }
/*! * Get all paragraph-related attributes and add them to the document. * * It does an appendStrux setting the current paragraph attributes and opening * a new paragraph. Several special cases are handled here too, mostly for * bullets. */ UT_Error IE_Imp_Psion::applyParagraphAttributes(const psiconv_paragraph_layout layout, const gchar *stylename) { UT_return_val_if_fail(layout != NULL, true /* perhaps should be false, but we want loading to proceed */); UT_UTF8String props; UT_Error res; // Get all attributes into prop if ((res = getParagraphAttributes(layout,props))) return UT_IE_IMPORTERROR; // HACK: Handle bullets // This is really, really ugly. // We can not really select the bullet symbol to use, so we do not even // try and just use always the plain round bullet. // Indent magic is done in getParagraphAttributes. if (layout->bullet->on) { props += ";list-style:Bullet List;field-font:Symbol"; // We need to generate the list once, but only if we actually // have a bullet somewhere. Nasty. The attributes are mostly // black magickish... if (!list) { list = true; const PP_PropertyVector propsArray = { "id", global_listid, "parentid", "0", "type", "5", "start-value", "0", "list-delim", "%L", "list-decimal", "NULL" }; getDoc()->appendList(propsArray); } } // Prepare the properties for this paragraph strux UT_DEBUGMSG(("PSION: Paragraph: %s\n",props.utf8_str())); PP_PropertyVector propsArray = { "props", props.utf8_str(), "style", stylename }; // Bullets need the listid too. if (layout->bullet->on) { propsArray.push_back("listid"); propsArray.push_back(global_listid); } if (!(appendStrux(PTX_Block, propsArray))) { return UT_IE_IMPORTERROR; } // HACK: there is no real setting to do this. Yet. if (layout->on_next_page) { UT_UCSChar ucs = UCS_FF; if (!(appendSpan(&ucs,1))) return UT_IE_IMPORTERROR; } // We need to append a field and some other stuff... if (layout->bullet->on) { propsArray.resize(2); propsArray.push_back("type"); propsArray.push_back("list_label"); if (!(appendObject(PTO_Field,propsArray))) return UT_IE_IMPORTERROR; // In some cases, but not in all, we need a tab after the bullet. // See the Psiconv docs for the (ugly) details. if ((!layout->bullet->indent && (layout->indent_first > 0)) || layout->bullet->indent) { UT_UCSChar uc = (UT_UCSChar) UCS_TAB; if (!(appendSpan(&uc,1))) return UT_IE_IMPORTERROR; } } return UT_OK; }
/*! * Get all paragraph-related attributes and append them to props. * * If props is not empty, we start with '; ', else we do not. */ UT_Error IE_Imp_Psion::getParagraphAttributes(const psiconv_paragraph_layout layout, UT_UTF8String &props) { UT_return_val_if_fail(layout != NULL, true /* perhaps should be false, but we want loading to proceed */); UT_UTF8String buffer; psiconv_length_t indent_left,indent_first; int i; psiconv_tab tab; // Compute the indent_left and indent_first settings. Note that // indent_first is always relative to indent_left. There are a few // special cases related to bullets; see the psiconv docs for details. if (layout->bullet && layout->bullet->on && layout->bullet->indent && (layout->indent_first > 0)) indent_left = layout->indent_left + layout->indent_first; else indent_left = layout->indent_left; if (layout->bullet && layout->bullet->on && (layout->indent_first > 0)) if (layout->bullet->indent) indent_first = -layout->indent_first; else indent_first = 0; else indent_first = layout->indent_first; // Append a semicolon if there is already text in the props if (props.length()) props += ";"; // Left indent UT_UTF8String_sprintf(buffer,"margin-left:%6.3fcm",indent_left); props += buffer; // Right indent UT_UTF8String_sprintf(buffer,"; margin-right:%6.3fcm",layout->indent_right); props += buffer; // First line indent UT_UTF8String_sprintf(buffer,"; text-indent:%6.3fcm",indent_first); props += buffer; // Horizontal justify UT_UTF8String_sprintf(buffer,"; text-align:%s", layout->justify_hor==psiconv_justify_left ? "left" : layout->justify_hor==psiconv_justify_right ? "right": layout->justify_hor==psiconv_justify_centre? "center": "justify"); props += buffer; // Vertical justify: ignored (never used in Word documents) // Background color UT_UTF8String_sprintf(buffer, "; bgcolor: %02x%02x%02x", layout->back_color->red, layout->back_color->green, layout->back_color->blue); props += buffer; #if 0 // Linespacing (gives trouble at the moment, so we disable it) UT_UTF8String_sprintf(buffer, "; line-height: %dpt",(int) layout->linespacing); props += buffer; if (! layout->linespacing_exact) props += "+"; #endif // Space above UT_UTF8String_sprintf(buffer,"; margin-top:%dpt",(int) layout->space_above); props += buffer; // Space below UT_UTF8String_sprintf(buffer,"; margin-bottom:%dpt",(int) layout->space_below); props += buffer; // Keep together UT_UTF8String_sprintf(buffer,"; keep-together:%s",layout->keep_together?"yes":"no"); props += buffer; // Keep with next UT_UTF8String_sprintf(buffer,"; keep-with-next:%s",layout->keep_with_next?"yes":"no"); props += buffer; // On next page // This is not yet implemented in AbiWord. We use a hack in // applyParagraphAttributes; styles are out of luck in this. // Last checked 20040229: Dialog is available, but no property yet. // Widow control // I'm not quite sure about the difference between setting widows and // orphans?!? UT_UTF8String_sprintf(buffer,"; widows:%d; orphans:%d", layout->no_widow_protection?0:2, layout->no_widow_protection?0:2); props += buffer; // Default tab interval. UT_UTF8String_sprintf(buffer,"; default-tab-interval:%6.3fcm",layout->tabs->normal); props += buffer; // Other tabs if (psiconv_list_length(layout->tabs->extras)) { props += "; tabstops:"; for (i = 0; i < (int) psiconv_list_length(layout->tabs->extras); i++) { if (!(tab = (psiconv_tab) psiconv_list_get(layout->tabs->extras, i))) { UT_ASSERT(tab != NULL); return(UT_IE_IMPORTERROR); } UT_UTF8String_sprintf(buffer, "%s%6.3fcm/%c", i==0?"":",", tab->location, tab->kind == psiconv_tab_centre?'C': tab->kind == psiconv_tab_right? 'R': 'L'); props += buffer; } } // Bullets. I don't think there is a general way to do this yet. // For now, we will hardcode all bullets to type 'Bullet List', // because we might get into real trouble. Note that we hack // this together in applyParagraphAttributes. // Not yet implemented: borders // These are not yet available in AbiWord. return UT_OK; }
void s_XSL_FO_Listener::_outputData(const UT_UCSChar * data, UT_uint32 length) { UT_UTF8String sBuf; const UT_UCSChar * pData; UT_ASSERT(sizeof(UT_Byte) == sizeof(char)); sBuf.reserve(length); for (pData=data; (pData<data+length); /**/) { switch (*pData) { case '<': { sBuf += "<"; pData++; break; } case '>': { sBuf += ">"; pData++; break; } case '&': { sBuf += "&"; pData++; break; } case UCS_LF: // LF -- representing a Forced-Line-Break { UT_ASSERT(UT_TODO); pData++; break; } case UCS_VTAB: // VTAB -- representing a Forced-Column-Break { UT_ASSERT(UT_TODO); pData++; break; } case UCS_FF: // FF -- representing a Forced-Page-Break { UT_ASSERT(UT_TODO); pData++; break; } default: { if(*pData < 0x20) //invalid xml chars { pData++; } else { sBuf.appendUCS4(pData, 1); pData++; } break; } } } m_pie->write(sBuf.utf8_str(), sBuf.byteLength()); }
GtkWidget *AP_UnixDialog_Lists::_constructWindowContents (void) { GtkWidget *vbox2; GtkWidget *hbox2; GtkWidget *vbox4; GtkWidget *table1; GtkWidget *style_om; GtkWidget *type_om; GtkWidget *type_lb; GtkWidget *style_lb; GtkWidget *customized_cb; GtkWidget *frame1; GtkWidget *table2; GtkComboBox *font_om; GtkListStore *font_om_menu; GtkWidget *format_en; GtkWidget *decimal_en; GtkAdjustment *start_sb_adj; GtkWidget *start_sb; GtkAdjustment *text_align_sb_adj; GtkWidget *text_align_sb; GtkAdjustment *label_align_sb_adj; GtkWidget *label_align_sb; GtkWidget *format_lb; GtkWidget *font_lb; GtkWidget *delimiter_lb; GtkWidget *start_at_lb; GtkWidget *text_align_lb; GtkWidget *label_align_lb; GtkWidget *vbox3; GtkWidget *preview_lb; GtkWidget *hbox1; GSList *action_group = NULL; GtkWidget *start_list_rb; GtkWidget *apply_list_rb; GtkWidget *resume_list_rb; GtkWidget *preview_area; GtkWidget *preview_frame; const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; GtkWidget * wNoteBook = NULL; vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_widget_show (vbox2); if(!isModal()) { // Note Book creation wNoteBook = gtk_notebook_new (); gtk_widget_show(wNoteBook); // Container for the lists pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_PageProperties,s); GtkWidget * lbPageLists = gtk_label_new(s.utf8_str()); gtk_widget_show(lbPageLists); gtk_notebook_append_page(GTK_NOTEBOOK(wNoteBook),vbox2,lbPageLists); m_iPageLists = gtk_notebook_page_num(GTK_NOTEBOOK(wNoteBook),vbox2); // Container for Text Folding pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_PageFolding,s); GtkWidget * lbPageFolding = gtk_label_new(s.utf8_str()); GtkWidget * wFoldingTable = gtk_table_new(6,3,FALSE); gtk_widget_show(lbPageFolding); gtk_widget_show(wFoldingTable); gtk_notebook_append_page(GTK_NOTEBOOK(wNoteBook),wFoldingTable,lbPageFolding); m_iPageFold = gtk_notebook_page_num(GTK_NOTEBOOK(wNoteBook),wFoldingTable); // Left Spacing Here GtkWidget * lbLeftSpacer = gtk_label_new(""); gtk_misc_set_padding(GTK_MISC(lbLeftSpacer),8,0); gtk_table_attach(GTK_TABLE(wFoldingTable),lbLeftSpacer,0,1,0,6,GTK_SHRINK,GTK_FILL,0,0); gtk_widget_show(lbLeftSpacer); // Bold markup GtkWidget * lbFoldHeading = gtk_label_new("<b>%s</b>"); gtk_label_set_use_markup(GTK_LABEL(lbFoldHeading),TRUE); localizeLabelMarkup(lbFoldHeading,pSS,AP_STRING_ID_DLG_Lists_FoldingLevelexp); gtk_table_attach(GTK_TABLE(wFoldingTable),lbFoldHeading,1,3,0,1,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(lbFoldHeading); // Mid Left Spacing Here GtkWidget * lbMidLeftSpacer = gtk_label_new(""); gtk_misc_set_padding(GTK_MISC(lbMidLeftSpacer),8,0); gtk_table_attach(GTK_TABLE(wFoldingTable),lbMidLeftSpacer,1,2,1,6,GTK_SHRINK,GTK_FILL,0,0); gtk_widget_show(lbMidLeftSpacer); m_vecFoldCheck.clear(); m_vecFoldID.clear(); UT_uint32 ID =0; // RadioButtons pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_FoldingLevel0,s); GtkWidget * wF = gtk_radio_button_new_with_label(NULL, s.utf8_str()); GSList *wG = gtk_radio_button_get_group(GTK_RADIO_BUTTON(wF)); g_object_set_data(G_OBJECT(wF),"level",(gpointer)"0"); ID = g_signal_connect(G_OBJECT(wF), "toggled", G_CALLBACK(s_FoldCheck_changed), (gpointer) this); gtk_table_attach(GTK_TABLE(wFoldingTable),wF,2,3,1,2,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(wF); m_vecFoldCheck.addItem(wF); m_vecFoldID.addItem(ID); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_FoldingLevel1,s); wF = gtk_radio_button_new_with_label(wG, s.utf8_str()); wG = gtk_radio_button_get_group(GTK_RADIO_BUTTON(wF)); g_object_set_data(G_OBJECT(wF),"level",(gpointer)"1"); ID = g_signal_connect(G_OBJECT(wF), "toggled", G_CALLBACK(s_FoldCheck_changed), (gpointer) this); gtk_table_attach(GTK_TABLE(wFoldingTable),wF,2,3,2,3,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(wF); m_vecFoldCheck.addItem(wF); m_vecFoldID.addItem(ID); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_FoldingLevel2,s); wF = gtk_radio_button_new_with_label(wG, s.utf8_str()); wG = gtk_radio_button_get_group(GTK_RADIO_BUTTON(wF)); g_object_set_data(G_OBJECT(wF),"level",(gpointer)"2"); ID = g_signal_connect(G_OBJECT(wF), "toggled", G_CALLBACK(s_FoldCheck_changed), (gpointer) this); gtk_table_attach(GTK_TABLE(wFoldingTable),wF,2,3,3,4,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(wF); m_vecFoldCheck.addItem(wF); m_vecFoldID.addItem(ID); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_FoldingLevel3,s); wF = gtk_radio_button_new_with_label(wG, s.utf8_str()); wG = gtk_radio_button_get_group(GTK_RADIO_BUTTON(wF)); g_object_set_data(G_OBJECT(wF),"level",(gpointer)"3"); ID = g_signal_connect(G_OBJECT(wF), "toggled", G_CALLBACK(s_FoldCheck_changed), (gpointer) this); gtk_table_attach(GTK_TABLE(wFoldingTable),wF,2,3,4,5,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(wF); m_vecFoldCheck.addItem(wF); m_vecFoldID.addItem(ID); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_FoldingLevel4,s); wF = gtk_radio_button_new_with_label(wG, s.utf8_str()); g_object_set_data(G_OBJECT(wF),"level",(gpointer)"4"); ID = g_signal_connect(G_OBJECT(wF), "toggled", G_CALLBACK(s_FoldCheck_changed), (gpointer) this); gtk_table_attach(GTK_TABLE(wFoldingTable),wF,2,3,5,6,GTK_FILL,GTK_EXPAND,0,0); gtk_widget_show(wF); m_vecFoldCheck.addItem(wF); m_vecFoldID.addItem(ID); gtk_widget_show(wFoldingTable); gtk_notebook_set_current_page(GTK_NOTEBOOK(wNoteBook),m_iPageLists); } // List Page gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8); gtk_widget_show (hbox2); gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0); vbox4 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_widget_show (vbox4); gtk_box_pack_start (GTK_BOX (hbox2), vbox4, FALSE, TRUE, 0); table1 = gtk_table_new (3, 2, FALSE); gtk_widget_show (table1); gtk_box_pack_start (GTK_BOX (vbox4), table1, FALSE, TRUE, 0); gtk_table_set_row_spacings (GTK_TABLE (table1), 4); style_om = gtk_combo_box_text_new(); gtk_widget_show (style_om); gtk_table_attach (GTK_TABLE (table1), style_om, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); m_wListStyleNone_menu = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); _fillNoneStyleMenu(m_wListStyleNone_menu.obj()); m_wListStyleNumbered_menu = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); _fillNumberedStyleMenu(m_wListStyleNumbered_menu.obj()); m_wListStyleBulleted_menu = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); _fillBulletedStyleMenu(m_wListStyleBulleted_menu.obj()); // This is the default list. Change if the list style changes // m_wListStyle_menu = m_wListStyleNumbered_menu; gtk_combo_box_set_model(GTK_COMBO_BOX (style_om), GTK_TREE_MODEL(m_wListStyleNumbered_menu.obj())); type_om = gtk_combo_box_text_new(); gtk_widget_show (type_om); gtk_table_attach (GTK_TABLE (table1), type_om, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_none,s); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str()); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_bullet,s); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str()); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type_numbered,s); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(type_om), s.utf8_str()); gtk_combo_box_set_active(GTK_COMBO_BOX(type_om), 0); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Type,s); type_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (type_lb); gtk_table_attach (GTK_TABLE (table1), type_lb, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (type_lb), 0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Style,s); style_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (style_lb); gtk_table_attach (GTK_TABLE (table1), style_lb, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (style_lb), 0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_SetDefault,s); customized_cb = gtk_dialog_add_button (GTK_DIALOG(m_wMainWindow), s.utf8_str(), BUTTON_RESET); gtk_widget_show (customized_cb); /* todo gtk_table_attach (GTK_TABLE (table1), customized_cb, 0, 2, 2, 3, (GtkAttachOptions) (GTK_SHRINK), (GtkAttachOptions) (0), 0, 0); */ frame1 = gtk_frame_new (NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_NONE); //gtk_widget_show (frame1); gtk_box_pack_start (GTK_BOX (vbox4), frame1, TRUE, TRUE, 0); table2 = gtk_table_new (6, 2, FALSE); gtk_widget_show (table2); gtk_container_add (GTK_CONTAINER (frame1), table2); gtk_container_set_border_width (GTK_CONTAINER (table2), 4); gtk_widget_set_sensitive (table2, TRUE); gtk_table_set_row_spacings (GTK_TABLE (table2), 4); gtk_table_set_col_spacings (GTK_TABLE (table2), 4); font_om_menu = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); _fillFontMenu(font_om_menu); font_om = GTK_COMBO_BOX(gtk_combo_box_new()); gtk_combo_box_set_model(font_om, GTK_TREE_MODEL(font_om_menu)); gtk_widget_show (GTK_WIDGET(font_om)); gtk_table_attach (GTK_TABLE (table2), GTK_WIDGET(font_om), 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); format_en = gtk_entry_new (); gtk_entry_set_max_length(GTK_ENTRY(format_en), 20); gtk_widget_show (format_en); gtk_table_attach (GTK_TABLE (table2), format_en, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_entry_set_text (GTK_ENTRY (format_en), "%L"); decimal_en = gtk_entry_new (); gtk_widget_show (decimal_en); gtk_table_attach (GTK_TABLE (table2), decimal_en, 1, 2, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_entry_set_text (GTK_ENTRY (format_en), ""); start_sb_adj = (GtkAdjustment*)gtk_adjustment_new (1, 0, G_MAXINT32, 1, 10, 10); start_sb = gtk_spin_button_new (GTK_ADJUSTMENT (start_sb_adj), 1, 0); gtk_widget_show (start_sb); gtk_table_attach (GTK_TABLE (table2), start_sb, 1, 2, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); text_align_sb_adj = (GtkAdjustment*)gtk_adjustment_new (0.25, 0, 10, 0.01, 0.2, 1); text_align_sb = gtk_spin_button_new (GTK_ADJUSTMENT (text_align_sb_adj), 0.05, 2); gtk_widget_show (text_align_sb); gtk_table_attach (GTK_TABLE (table2), text_align_sb, 1, 2, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (text_align_sb), TRUE); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (text_align_sb), TRUE); label_align_sb_adj = (GtkAdjustment*)gtk_adjustment_new (0, 0, 10, 0.01, 0.2, 1); label_align_sb = gtk_spin_button_new (GTK_ADJUSTMENT (label_align_sb_adj), 0.05, 2); gtk_widget_show (label_align_sb); gtk_table_attach (GTK_TABLE (table2), label_align_sb, 1, 2, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (label_align_sb), TRUE); gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (label_align_sb), TRUE); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Format,s); format_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (format_lb); gtk_table_attach (GTK_TABLE (table2), format_lb, 0, 1, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (format_lb), 0.0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Font,s); font_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (font_lb); gtk_table_attach (GTK_TABLE (table2), font_lb, 0, 1, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (font_lb), 0.0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_DelimiterString,s); delimiter_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (delimiter_lb); gtk_table_attach (GTK_TABLE (table2), delimiter_lb, 0, 1, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (delimiter_lb), 0.0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Start,s); start_at_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (start_at_lb); gtk_table_attach (GTK_TABLE (table2), start_at_lb, 0, 1, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (start_at_lb), 0.0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Align,s); text_align_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (text_align_lb); gtk_table_attach (GTK_TABLE (table2), text_align_lb, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (text_align_lb), 0.0, 0.5); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Indent,s); label_align_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (label_align_lb); gtk_table_attach (GTK_TABLE (table2), label_align_lb, 0, 1, 5, 6, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label_align_lb), 0.0, 0.5); vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_widget_show (vbox3); gtk_box_pack_start (GTK_BOX (hbox2), vbox3, TRUE, TRUE, 0); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Preview,s); preview_lb = gtk_label_new (s.utf8_str()); gtk_widget_show (preview_lb); gtk_box_pack_start (GTK_BOX (vbox3), preview_lb, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (preview_lb), 0.0, 0.5); preview_frame = gtk_frame_new (NULL); gtk_widget_show (preview_frame); gtk_box_pack_start (GTK_BOX (vbox3), preview_frame, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (preview_frame), 3); gtk_frame_set_shadow_type (GTK_FRAME (preview_frame), GTK_SHADOW_NONE); preview_area = createDrawingArea (); gtk_widget_set_size_request (preview_area,180,225); gtk_widget_show (preview_area); gtk_container_add (GTK_CONTAINER (preview_frame), preview_area); hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); if(!isModal()) gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Start_New,s); start_list_rb = gtk_radio_button_new_with_label (action_group, s.utf8_str()); action_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (start_list_rb)); if(!isModal()) gtk_widget_show (start_list_rb); gtk_box_pack_start (GTK_BOX (hbox1), start_list_rb, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (start_list_rb), TRUE); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Apply_Current,s); apply_list_rb = gtk_radio_button_new_with_label (action_group, s.utf8_str()); action_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (apply_list_rb)); if(!isModal()) gtk_widget_show (apply_list_rb); gtk_box_pack_start (GTK_BOX (hbox1), apply_list_rb, FALSE, FALSE, 0); pSS->getValueUTF8(AP_STRING_ID_DLG_Lists_Resume,s); resume_list_rb = gtk_radio_button_new_with_label (action_group, s.utf8_str()); action_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (resume_list_rb)); if(!isModal()) gtk_widget_show (resume_list_rb); gtk_box_pack_start (GTK_BOX (hbox1), resume_list_rb, FALSE, FALSE, 0); // Save useful widgets in member variables if(isModal()) { m_wContents = vbox2; } else { m_wContents = wNoteBook; } m_wStartNewList = start_list_rb; m_wStartNew_label = gtk_bin_get_child(GTK_BIN(start_list_rb)); m_wApplyCurrent = apply_list_rb; m_wStartSubList = resume_list_rb; m_wStartSub_label = gtk_bin_get_child(GTK_BIN(resume_list_rb)); m_wRadioGroup = action_group; m_wPreviewArea = preview_area; m_wDelimEntry = format_en; m_oAlignList_adj = text_align_sb_adj; m_wAlignListSpin = text_align_sb; m_oIndentAlign_adj = label_align_sb_adj; m_wIndentAlignSpin = label_align_sb; m_wDecimalEntry = decimal_en; m_oStartSpin_adj = start_sb_adj; m_wStartSpin = start_sb; m_wFontOptions = font_om; m_wFontOptions_menu = font_om_menu; m_wCustomFrame = frame1; m_wCustomLabel = customized_cb; m_wCustomTable = table2; m_wListStyleBox = GTK_COMBO_BOX(style_om); m_wListTypeBox = GTK_COMBO_BOX(type_om); m_wListType_menu = m_wListStyleNumbered_menu; // Start by hiding the Custom frame // // gtk_widget_hide(m_wCustomFrame); gtk_widget_show(m_wCustomFrame); setbisCustomized(false); return m_wContents; }
void AccountHandler::_handlePacket(Packet* packet, BuddyPtr buddy) { // packet and buddy must always be set UT_return_if_fail(packet); UT_return_if_fail(buddy); // as must the session manager AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_if_fail(pManager); // manager didn't handle it, see what we can do switch (packet->getClassType()) { case PCT_JoinSessionRequestEvent: { JoinSessionRequestEvent* jse = static_cast<JoinSessionRequestEvent*>(packet); // lookup session AbiCollab* pSession = pManager->getSessionFromSessionId(jse->getSessionId()); UT_return_if_fail(pSession); // check if this buddy is allowed to access this document // TODO: this should be done for every session packet, not just join session packets if (!hasAccess(pSession->getAcl(), buddy)) { // we should only reach this point if someone is brute forcing trying // out session IDs while not being on the ACL. Ban this uses. UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); return; } // lookup exporter ABI_Collab_Export* pExport = pSession->getExport(); UT_return_if_fail(pExport); // lookup adjusts const UT_GenericVector<ChangeAdjust *>* pExpAdjusts = pExport->getAdjusts(); UT_return_if_fail(pExpAdjusts); PD_Document* pDoc = pSession->getDocument(); // add this author to the document if we don't recognize him UT_sint32 iAuthorId = -1; UT_UTF8String buddyDescriptor = buddy->getDescriptor(); UT_GenericVector<pp_Author*> authors = pDoc->getAuthors(); UT_DEBUGMSG(("Scanning %d authors to see if we recognize this buddy\n", authors.getItemCount())); for (UT_sint32 i = 0; i < authors.getItemCount(); i++) { pp_Author* pAuthor = authors.getNthItem(i); UT_continue_if_fail(pAuthor); const gchar* szDescriptor = NULL; pAuthor->getProperty("abicollab-descriptor", szDescriptor); if (!szDescriptor) continue; if (buddyDescriptor != szDescriptor) continue; // yay, we know this author! iAuthorId = pAuthor->getAuthorInt(); UT_DEBUGMSG(("Found known author with descriptior %s, id %d!\n", buddyDescriptor.utf8_str(), iAuthorId)); break; } if (iAuthorId == -1) { // we don't know this author yet, create a new author object for him iAuthorId = pDoc->findFirstFreeAuthorInt(); pp_Author * pA = pDoc->addAuthor(iAuthorId); PP_AttrProp * pPA = pA->getAttrProp(); pPA->setProperty("abicollab-descriptor", buddyDescriptor.utf8_str()); pDoc->sendAddAuthorCR(pA); UT_DEBUGMSG(("Added a new author to the documument with descriptor %s, id %d\n", buddyDescriptor.utf8_str(), iAuthorId)); } // serialize entire document into string JoinSessionRequestResponseEvent jsre(jse->getSessionId(), iAuthorId); if (AbiCollabSessionManager::serializeDocument(pDoc, jsre.m_sZABW, false /* no base64 */) == UT_OK) { // set more document properties jsre.m_iRev = pDoc->getCRNumber(); jsre.m_sDocumentId = pDoc->getDocUUIDString(); if (pDoc->getFilename()) jsre.m_sDocumentName = UT_go_basename_from_uri(pDoc->getFilename()); // send to buddy! send(&jsre, buddy); // add this buddy to the collaboration session pSession->addCollaborator(buddy); } break; } case PCT_JoinSessionRequestResponseEvent: { JoinSessionRequestResponseEvent* jsre = static_cast<JoinSessionRequestResponseEvent*>( packet ); PD_Document* pDoc = 0; if (AbiCollabSessionManager::deserializeDocument(&pDoc, jsre->m_sZABW, false) == UT_OK) { if (pDoc) { // NOTE: we could adopt the same document name here, but i'd // rather not at the moment - MARCM pDoc->forceDirty(); if (jsre->m_sDocumentName.size() > 0) { gchar* fname = g_strdup(jsre->m_sDocumentName.utf8_str()); pDoc->setFilename(fname); } // The default ownership when joining is FALSE, as that seems // to make sense for the generic case. The person sharing the // document by default owns the document (and is thus allowed // to modify the ACL). pManager->joinSession(jsre->getSessionId(), pDoc, jsre->m_sDocumentId, jsre->m_iRev, jsre->getAuthorId(), buddy, this, false, NULL); } else { UT_DEBUGMSG(("AccountHandler::_handlePacket() - deserializing document failed!\n")); } } break; } case PCT_GetSessionsEvent: { GetSessionsResponseEvent gsre; const UT_GenericVector<AbiCollab *> sessions = pManager->getSessions(); for (UT_sint32 i = 0; i < sessions.getItemCount(); i++) { AbiCollab* pSession = sessions.getNthItem(i); if (pSession && pSession->isLocallyControlled()) { // check if the buddy has access to this session if (!hasAccess(pSession->getAcl(), buddy)) { UT_DEBUGMSG(("Buddy %s denied access to session %s by ALC\n", buddy->getDescriptor(true).utf8_str(), pSession->getSessionId().utf8_str())); continue; } const PD_Document * pDoc = pSession->getDocument(); UT_continue_if_fail(pDoc); // determine name UT_UTF8String documentBaseName; if (pDoc->getFilename()) documentBaseName = UT_go_basename_from_uri(pDoc->getFilename()); // set session info gsre.m_Sessions[ pSession->getSessionId() ] = documentBaseName; } } send(&gsre, buddy); break; } case PCT_GetSessionsResponseEvent: { GetSessionsResponseEvent* gsre = static_cast<GetSessionsResponseEvent*>( packet ); UT_GenericVector<DocHandle*> vDocHandles; for (std::map<UT_UTF8String,UT_UTF8String>::iterator it=gsre->m_Sessions.begin(); it!=gsre->m_Sessions.end(); ++it) { DocHandle* pDocHandle = new DocHandle((*it).first, (*it).second); vDocHandles.addItem(pDocHandle); } pManager->setDocumentHandles(buddy, vDocHandles); break; } default: { UT_DEBUGMSG(("Unhandled packet class: 0x%x\n", packet->getClassType())); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); break; } } }
void s_XSL_FO_Listener::_handleField(const PX_ChangeRecord_Object * pcro, PT_AttrPropIndex api) { if(!m_iBlockDepth && !m_iListBlockDepth) return; const PP_AttrProp* pAP = NULL; bool bHaveProp = m_pDocument->getAttrProp(api, &pAP); if (bHaveProp && pAP) { const gchar* szValue = NULL; if (pAP->getAttribute("type", szValue) && szValue) { fd_Field * field = pcro->getField(); m_pie->populateFields (); if((_tagTop() == TT_LISTBLOCK) && !strcmp(static_cast<const char*>(szValue), "list_label")) { m_pie->write("\n"); _tagOpen(TT_LISTITEM, "list-item"); _tagOpen(TT_LISTITEMLABEL, "list-item-label end-indent=\"label-end()\"", false); _tagOpen(TT_BLOCK, "block", false); UT_UTF8String label = ""; for(UT_sint32 i = 0; i < m_Lists.getItemCount(); i++) { ListHelper * lh = m_Lists[i]; if(lh && ((*lh).retrieveID() == m_iListID)) { label = (*lh).getNextLabel(); break; } } if(label.length()) m_pie->write(label.utf8_str()); //write out the list label text _tagClose(TT_BLOCK, "block", false); _tagClose(TT_LISTITEMLABEL, "list-item-label"); _tagOpen(TT_LISTITEMBODY, "list-item-body start-indent=\"body-start()\"", false); _tagOpen(TT_BLOCK, "block", false); m_iBlockDepth++; m_bWroteListField = true; } else if(!strcmp(szValue, "footnote_ref")) { UT_UTF8String buf = field->getValue(); buf.escapeXML(); _tagOpen(TT_FOOTNOTE, "footnote", false); _tagOpen(TT_INLINE, "inline", false); if(buf.length()) m_pie->write(buf.utf8_str()); _tagClose(TT_INLINE, "inline", false); } else { UT_UTF8String buf = field->getValue(); buf.escapeXML(); if(buf.length()) m_pie->write(buf.utf8_str()); } } } }