void AbiCollab::_setDocument(PD_Document* pDoc)
{
    UT_DEBUGMSG(("AbiCollab::setDocument()\n"));
    UT_return_if_fail(pDoc);

    AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
    UT_return_if_fail(pManager);

    // assume clean state
    UT_return_if_fail(m_iDocListenerId==0);
    m_pDoc = pDoc;

    // register ourselves as a mouse listener to all frames showing this document
    for (UT_sint32 i = 0; i < XAP_App::getApp()->getFrameCount(); i++)
    {
        XAP_Frame* pFrame = XAP_App::getApp()->getFrame(i);
        UT_continue_if_fail(pFrame);

        if (pFrame->getCurrentDoc() == m_pDoc)
        {
            // this frame is showing our document, attach a mouse listener to it
            EV_Mouse* pMouse = pFrame->getMouse();
            if (pMouse)
                m_mMouseListenerIds[pMouse] = pMouse->registerListener(this);
        }
    }

    // add the new export listeners
    UT_uint32 lid = 0;
    pDoc->addListener(static_cast<PL_Listener *>(&m_Export), &lid);
    _setDocListenerId(lid);
    UT_DEBUGMSG(("Added document listener %d\n", lid));
}
Ejemplo n.º 2
0
static void
AbiGOffice_removeFromMenus ()
{
	// First we need to get a pointer to the application itself.
	XAP_App *pApp = XAP_App::getApp();
	XAP_Menu_Factory * pFact = pApp->getMenuFactory();

	// remove the edit method
	EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer() ;
	EV_EditMethod * pEM = ev_EditMethod_lookup ( "AbiGOChart_Create" ) ;
	pEMC->removeEditMethod ( pEM ) ;
	DELETEP( pEM ) ;
	pFact->removeMenuItem("Main",NULL,InsertGOChartID);
	if (g_slist_length (mime_types) > 0) {
		pEM = ev_EditMethod_lookup ( "AbiGOComponent_FileInsert" ) ;
		pEMC->removeEditMethod ( pEM ) ;
		DELETEP( pEM ) ;
		pEM = ev_EditMethod_lookup ( "AbiGOComponent_Create" ) ;
		pEMC->removeEditMethod ( pEM ) ;
		DELETEP( pEM ) ;
		pFact->removeMenuItem("Main",NULL,InsertGOComponentFromFileID);
		pFact->removeMenuItem("Main",NULL,CreateGOComponentID);
	}
	pFact->removeMenuItem("Main",NULL,newObjectID);
	
	int frameCount = pApp->getFrameCount();
	for(int i = 0;i < frameCount;++i)
	{
	  // Get the current frame that we're iterating through.
	  XAP_Frame* pFrame = pApp->getFrame(i);
	  pFrame->rebuildMenus();
	}
}
Ejemplo n.º 3
0
static gboolean focus_out_event_Modeless(GtkWidget *widget,GdkEvent */*event*/,gpointer /*user_data*/)
{
      XAP_App *pApp = static_cast<XAP_App *>(g_object_get_data(G_OBJECT(widget), "pApp"));
      XAP_Frame *pFrame = pApp->getLastFocussedFrame();
      if(pFrame ==static_cast<XAP_Frame *>(NULL)) 
      {
             UT_uint32 nframes =  pApp->getFrameCount();
             if(nframes > 0 && nframes < 10)
	     {     
	            pFrame = pApp->getFrame(0);
	     }
             else
	     {
	            return FALSE;
	     }
      }
      if(pFrame == static_cast<XAP_Frame *>(NULL)) return FALSE;
      AV_View * pView = pFrame->getCurrentView();
      UT_ASSERT_HARMLESS(pView);
      if(pView!= NULL)
      {
	     pView->focusChange(AV_FOCUS_NONE);
      }
      return FALSE;
}
Ejemplo n.º 4
0
//
// URLDict_invoke
// -------------------
//   This is the function that we actually call to invoke the on-line dictionary.
//   It should be called when the user selects from the context menu
//
static bool 
URLDict_invoke(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());
  
  // If the user is on a word, but does not have it selected, we need
  // to go ahead and select that word so that the search/replace goes
  // correctly.
  pView->moveInsPtTo(FV_DOCPOS_EOW_MOVE);
  pView->moveInsPtTo(FV_DOCPOS_BOW);
  pView->extSelTo(FV_DOCPOS_EOW_SELECT);   
  
  // Now we will figure out what word to look up when we open our dialog.
  UT_String url ("http://www.dict.org/bin/Dict?Form=Dict1&Database=*&Strategy=*&Query=");
  if (!pView->isSelectionEmpty())
    {
      // We need to get the Ascii version of the current word.
      UT_UCS4Char *ucs4ST;
      pView->getSelectionText(*&ucs4ST);
      char* search = _ucsToAscii(
				 ucs4ST
				 );
      
      url += search;
      DELETEPV(search);
      FREEP(ucs4ST);
    }

  XAP_App::getApp()->openURL( url.c_str() ); 

  return true;
}
Ejemplo n.º 5
0
static void
AikSaurusABI_RemoveFromMenus ()
{
  // First we need to get a pointer to the application itself.
  XAP_App *pApp = XAP_App::getApp();

  // remove the edit method
  EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer() ;
  EV_EditMethod * pEM = ev_EditMethod_lookup ( "AiksaurusABI_invoke" ) ;
  pEMC->removeEditMethod ( pEM ) ;
  DELETEP( pEM ) ;

  // now remove crap from the menus
  int frameCount = pApp->getFrameCount();
  XAP_Menu_Factory * pFact = pApp->getMenuFactory();

  pFact->removeMenuItem("Main",NULL,AiksaurusABI_MenuLabel);
  pFact->removeMenuItem("contextText",NULL,AiksaurusABI_MenuLabel);
  for(int i = 0;i < frameCount;++i)
    {
      // Get the current frame that we're iterating through.
      XAP_Frame* pFrame = pApp->getFrame(i);
      pFrame->rebuildMenus();
    }
}
bool XAP_App::updateClones(XAP_Frame * pFrame)
{
	UT_return_val_if_fail(pFrame,false);
	UT_ASSERT(pFrame->getViewNumber() > 0);

	// locate vector of this frame's clones
	UT_GenericVector<XAP_Frame*>* pEntry = m_hashClones.pick(pFrame->getViewKey());
	UT_ASSERT_HARMLESS(pEntry);

	if (pEntry)
	{
		UT_GenericVector<XAP_Frame*>* pvClones = pEntry;
		UT_return_val_if_fail(pvClones,false);

		UT_uint32 count = pvClones->getItemCount();
		UT_ASSERT(count > 0);
		XAP_Frame * f = NULL;

		for (UT_uint32 j=0; j<count; j++)
		{
			f = pvClones->getNthItem(j);
			UT_continue_if_fail(f);

			f->updateTitle();
		}
	}

	return true;
}
Ejemplo n.º 7
0
bool Presentation::end(void)
{
  if(m_sPrevBindings.size() == 0)
    return false;
  EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer();
  g_return_val_if_fail (pEMC != 0, FALSE);
  UT_sint32 i = m_pApp->setInputMode(m_sPrevBindings.c_str());
  if(i <=0 )
    return false;

  // get a handle to the actual EditMethod

  EV_EditMethod * pFullScreen = pEMC->findEditMethodByName ("viewFullScreen");
  g_return_val_if_fail (pFullScreen != 0, false);
  const char * sz ="";
  EV_EditMethodCallData calldata(sz,0);
  calldata.m_xPos = 0;
  calldata.m_yPos = 0;
  XAP_Frame * pFrame = static_cast<XAP_Frame*>(m_pView->getParentData());
  pFrame->hideMenuScroll(false);
  bool b= (pFullScreen->Fn(static_cast<AV_View *>(m_pView),&calldata) ? TRUE : FALSE);
  pFrame->setZoomType(m_OldZoomType);
  pFrame->setZoomPercentage(m_iOldZoom);
  pFrame->quickZoom(m_iOldZoom);
  return b;
}
Ejemplo n.º 8
0
//
// AbiMathView_LatexInsert
// -------------------
//   This is the function that we actually call to insert the MathML from
//   a Latex expression.
//
bool 
AbiMathView_LatexInsert(AV_View* v, EV_EditMethodCallData* /*d*/)
{
	FV_View * pView = static_cast<FV_View *>(v);
	XAP_Frame * pFrame = static_cast<XAP_Frame *> ( pView->getParentData());
	pFrame->raise();

	XAP_DialogFactory * pDialogFactory
	  = static_cast<XAP_DialogFactory *>(XAP_App::getApp()->getDialogFactory());

	AP_Dialog_Latex * pDialog 
		= static_cast<AP_Dialog_Latex *>(pDialogFactory->requestDialog(AP_DIALOG_ID_LATEX));
	UT_return_val_if_fail(pDialog, false);

	if (pDialog->isRunning())
	{
		pDialog->activate();
	}
	else
	{
		pDialog->runModeless(pFrame);
	}

	return true;
}
Ejemplo n.º 9
0
//
// GDict_invoke
// -------------------
//   This is the function that we actually call to invoke the thesaurus.
//   It should be called when the user hits the thesaurus key (shift+f7?)
//   or chooses "thesaurus" from a menu.
//
static bool 
GDict_invoke(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());
  
  // If the user is on a word, but does not have it selected, we need
  // to go ahead and select that word so that the search/replace goes
  // correctly.
  pView->moveInsPtTo(FV_DOCPOS_EOW_MOVE);
  pView->moveInsPtTo(FV_DOCPOS_BOW);
  pView->extSelTo(FV_DOCPOS_EOW_SELECT);   
  
  // We need to get the utf-8 version of the current word.
  UT_UCS4Char *ucs4ST = NULL;
  pView->getSelectionText(*&ucs4ST);
  if (ucs4ST) {
    UT_UTF8String search(ucs4ST);
    GDict_exec (search.utf8_str());
    FREEP(ucs4ST);
  }
    
  return true;
}
Ejemplo n.º 10
0
bool AbiCollabSessionManager::_setupFrame(XAP_Frame** pFrame, PD_Document* pDoc)
{
	UT_return_val_if_fail(pFrame, false);
	
	if (*pFrame)
	{
		UT_DEBUGMSG(("Frame is non-NULL, NOT loading document in the frame\n"));
		return true;
	}
	
	// if the document doesn't belong to a frame already, then create a 
	// new frame for this session (except when the document in the current 
	// frame is not dirty, doesn't have a filename yet (which means it 
	// is a brand new empty document), and isn't being shared at the moment)
	XAP_Frame* pCurFrame = XAP_App::getApp()->getLastFocussedFrame();
	UT_return_val_if_fail(pCurFrame, false);

	bool isNewFrame = false;
	PD_Document * pFrameDoc = static_cast<PD_Document *>(pCurFrame->getCurrentDoc());
	if (pFrameDoc != pDoc)
	{
		if (!pFrameDoc || (pFrameDoc->getFilename().empty() && !pFrameDoc->isDirty() && !isInSession(pFrameDoc)))
		{
			// we can replace the document in this frame safely, as it is 
			// brand new, and doesn't have any contents yet
		}
		else
		{
			// the current frame has already a document loaded, let's create
			// a new frame
			pCurFrame = XAP_App::getApp()->newFrame();
			isNewFrame = true;
		}

	}
	else
    {
		UT_DEBUGMSG(("This document is already in the current frame; using this frame\n"));
    }
	
	UT_return_val_if_fail(pCurFrame, false);
	*pFrame = pCurFrame;
		
	// load the document in the frame; this will also delete the old document (or at least, it should)
	if (static_cast<PD_Document *>((*pFrame)->getCurrentDoc()) != pDoc)
	{
		UT_DEBUGMSG(("Loading the document in the frame\n"));
		(*pFrame)->loadDocument(pDoc);
	}
	else
    {
		UT_DEBUGMSG(("Not loading the document in the frame, as the frame already has it\n"));
    }
	
	if (isNewFrame)
		(*pFrame)->show();
	
	return true;
}
Ejemplo n.º 11
0
ConnectResult XMPPAccountHandler::connect()
{
	UT_DEBUGMSG(("XMPPAccountHandler::connect()\n"));

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

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

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

	lm_connection_set_jid(m_pConnection, jid.c_str());

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

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

	return CONNECT_IN_PROGRESS;
}
// Does the initial show/hide of statusbar (based on the user prefs).
// Idem.
void AP_UnixFrameImpl::_showOrHideStatusbar()
{
#ifdef ENABLE_STATUSBAR
	XAP_Frame* pFrame = getFrame();
	bool bShowStatusBar = static_cast<AP_FrameData*> (pFrame->getFrameData())->m_bShowStatusBar;
	static_cast<AP_UnixFrame *>(pFrame)->toggleStatusBar(bShowStatusBar);
#endif
}
Ejemplo n.º 13
0
//
// AbiGOComponent_Create
// -------------------
//   This is the function that we actually call to insert a new intially empty component.
bool 
AbiGOComponent_Create (G_GNUC_UNUSED AV_View* v, G_GNUC_UNUSED EV_EditMethodCallData *d)
{
    XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
	XAP_UnixFrameImpl *pFrameImpl = static_cast<XAP_UnixFrameImpl*>(pFrame->getFrameImpl());
	std::string cancel, ok;
	const XAP_StringSet *pSS = XAP_App::getApp()->getStringSet();
	pSS->getValueUTF8(XAP_STRING_ID_DLG_Cancel, cancel);
	pSS->getValueUTF8(XAP_STRING_ID_DLG_OK, ok);
	GtkDialog *dialog = GTK_DIALOG (gtk_dialog_new_with_buttons ("New Object",
		GTK_WINDOW(pFrameImpl->getTopLevelWindow()),
		(GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		convertMnemonics(cancel).c_str(), GTK_RESPONSE_CANCEL,
		convertMnemonics(ok).c_str(), GTK_RESPONSE_OK, NULL));
	GtkListStore *list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
	GtkWidget *w = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list));
	g_signal_connect_swapped(w, "button-press-event", G_CALLBACK(button_press_cb), dialog);
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Object type:", renderer, "text", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
	GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW (w));
	gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
	GtkTreeIter iter;
	GSList *l = mime_types;
	gchar const *mime_type;
	while (l) {
		mime_type = (gchar const *) l->data;
		if (strcmp(mime_type, "application/mathml+xml")
		    && go_components_get_priority(mime_type) >= GO_MIME_PRIORITY_PARTIAL)
		{
			gtk_list_store_append (list, &iter);
			gtk_list_store_set (list, &iter,
					  0, go_mime_type_get_description (mime_type),
					  1, mime_type,
					  -1);
		}
		l = l->next;
	}
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(dialog)), w, false, false, 0);
	gtk_widget_show_all (GTK_WIDGET(dialog));
	gint result = gtk_dialog_run (dialog);
	if (result == GTK_RESPONSE_OK &&
		gtk_tree_selection_get_selected (sel, NULL, &iter)) {
		gtk_tree_model_get (GTK_TREE_MODEL (list), &iter, 1, &mime_type, -1);
		GOComponent *component = go_component_new_by_mime_type (mime_type);
		go_component_set_inline (component, true);
		go_component_set_use_font_from_app (component, true);
		g_signal_connect (G_OBJECT (component), "changed",
								G_CALLBACK (changed_cb), NULL);
		GtkWindow *win = go_component_edit(component);
		gtk_window_set_transient_for(win, GTK_WINDOW(pFrameImpl->getTopLevelWindow()));
	}
	gtk_widget_destroy (GTK_WIDGET (dialog));
	return result == GTK_RESPONSE_OK;
}
Ejemplo n.º 14
0
FV_View * AP_Dialog_Modeless::getView(void) const
{
	XAP_Frame * pFrame = getActiveFrame();

	if (pFrame)
		return (FV_View *) pFrame->getCurrentView();
	else
		return NULL;
}
Ejemplo n.º 15
0
// 
// FreeTranslate_invoke
// -------------------
//   This is the function that we actually call to invoke the 
//   online freetranslation translation
//   It should be called when the user selects from the context menu
// 
static
bool FreeTranslation_invoke(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());

	std::string url("http://www.freetranslation.com");

	if (!pView->isSelectionEmpty())
   	{
		std::string langCode;
		if (_getTranslationCode(pView, langCode))
	   	{
			// Now we will figure out what words to translate
			// We need to get the Latin1 version of the current word.
			UT_UCS4Char *ucs4ST;
			pView->getSelectionText(*&ucs4ST);
			char * translate = _ucs4ToLatin1(ucs4ST);

			// URL encode the string (' ' -> %20, ...)
			// TODO this is not complete
			std::string srcText;

			for (char *p = translate; p && *p; ++p)
			{
				if (*p == ' ' || *p == '%' || *p == '&' || *p == '?' 
					|| (*p & 128)) // sometime char is signed. 
					               // do bitwise comparison for portability
				{
					char temp[4] = "";
					sprintf(&temp[0], "%%%x", *p);
					srcText += temp;
				} else
					srcText += *p;
			}

			url = "http://ets.freetranslation.com/?Sequence=core";
			url += "&Language=";
			url += langCode;
			url += "&SrcText=";
			url += srcText;

			DELETEPV(translate);
			FREEP(ucs4ST);

			XAP_App::getApp()->openURL(url.c_str());
		}
		// else didn't get the translation code. don't show anything
	} else {
		XAP_App::getApp()->openURL(url.c_str());
	}

	return true;
}
Ejemplo n.º 16
0
GR_Graphics * AP_Win32App::newDefaultScreenGraphics() const
{
	XAP_Frame * pFrame = findValidFrame();
	UT_return_val_if_fail( pFrame, NULL );
	
	AP_Win32FrameImpl * pFI = (AP_Win32FrameImpl *) pFrame->getFrameImpl();
	UT_return_val_if_fail( pFI, NULL );

	return pFI->createDocWndGraphics();
}
Ejemplo n.º 17
0
UT_Error IE_Exp_EPUB::doOptions()
{    
    XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame();

    if (!pFrame || isCopying()) return UT_OK;
    if (pFrame)
    {
        AV_View * pView = pFrame->getCurrentView();
        if (pView)
        {
            GR_Graphics * pG = pView->getGraphics();
            if (pG && pG->queryProperties(GR_Graphics::DGP_PAPER))
            {
                return UT_OK;
            }
        }
    }

//FIXME:FIDENCIO: Remove this clause when Cocoa's dialog is implemented
#ifdef TOOLKIT_COCOA
    return UT_OK;
#else
    /* run the dialog
     */

    XAP_Dialog_Id id = m_iDialogExport;

    XAP_DialogFactory * pDialogFactory
            = static_cast<XAP_DialogFactory *> (XAP_App::getApp()->getDialogFactory());

    AP_Dialog_EpubExportOptions* pDialog
            = static_cast<AP_Dialog_EpubExportOptions*> (pDialogFactory->requestDialog(id));

    if (pDialog == NULL)
    {
        return UT_OK;
    }

    pDialog->setEpubExportOptions(&m_exp_opt, XAP_App::getApp());

    pDialog->runModal(pFrame);

    /* extract what they did
     */
    bool bSave = pDialog->shouldSave();

    pDialogFactory->releaseDialog(pDialog);

    if (!bSave)
    {
        return UT_SAVE_CANCELLED;
    }
    return UT_OK;
#endif
}
Ejemplo n.º 18
0
/*!
 Sets the sensitivity of the radio buttons to top/bottom/left/right line buttons
 Call this right after contructing the widget and before dropping into the main loop.
 */
void AP_Dialog_FormatTable::setAllSensitivities(void)
{
    XAP_Frame *frame = XAP_App::getApp()->getLastFocussedFrame();
    if (frame) {
        FV_View * pView = static_cast<FV_View *>(frame->getCurrentView());
        setSensitivity(pView->isInTable());
    }
    else {
        setSensitivity(false);
    }
}
Ejemplo n.º 19
0
filter_result MenuFilter::Filter(BMessage *message, BHandler **target) 
{ 
	if (message->what != ABI_BEOS_MENU_EV) 
	{
		return(B_DISPATCH_MESSAGE);
	}
	//XAP_Menu_Id id = 0;
	BMenuItem* sourceItem;
	
	int32	id = 0;
	message->FindInt32(ABI_BEOS_MENU_EV_NAME, &id);
	message->FindPointer("source" , (void **)&sourceItem);
	//if(sourceItem->IsMarked())
	//	sourceItem->SetMarked(false);
	
	const EV_Menu_ActionSet * pMenuActionSet = m_pBeOSApp->getMenuActionSet();
	UT_ASSERT(pMenuActionSet);

	const EV_Menu_Action * pAction = pMenuActionSet->getAction(id);
	UT_ASSERT(pAction);

#if 0
	if(m_pBeOSFrame->getCurrentView() && pAction->hasGetStateFunction())
	{
		if(pAction->isCheckable() || pAction->isRadio())
		{
		
			EV_Menu_ItemState mis = pAction->getMenuItemState(m_pBeOSFrame->getCurrentView());
	    	if (mis & EV_MIS_Toggled)
        	    sourceItem->SetMarked(false);
        	else
        		sourceItem->SetMarked(true);
		}
	}
#endif
             
	const char * szMethodName = pAction->getMethodName();
	if (!szMethodName)
		return(B_SKIP_MESSAGE);
	
	const EV_EditMethodContainer * pEMC = m_pBeOSApp->getEditMethodContainer();
	UT_ASSERT(pEMC);

	EV_EditMethod * pEM = pEMC->findEditMethodByName(szMethodName);
	UT_ASSERT(pEM);						// make sure it's bound to something

	UT_String script_name(pAction->getScriptName());
	m_pEVMenu->invokeMenuMethod(m_pBeOSFrame->getCurrentView(), pEM, script_name);

	((EV_BeOSMenu *)m_pEVMenu)->synthesize();
	
	return(B_SKIP_MESSAGE);			
}
void AP_Dialog_CollaborationShare::share(AccountHandler* pAccount, const std::vector<std::string>& vAcl)
{
	UT_DEBUGMSG(("AP_Dialog_CollaborationShare::_share()\n"));

	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_if_fail(pManager);

	// determine which document to share
	XAP_Frame* pFrame = XAP_App::getApp()->getLastFocussedFrame();
	UT_return_if_fail(pFrame);

	PD_Document* pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc());
	UT_return_if_fail(pDoc);

	AbiCollab* pSession = NULL;
	if (!pManager->isInSession(pDoc))
	{
		UT_DEBUGMSG(("Sharing document...\n"));

		// FIXME: this can cause a race condition: the other side can already be
		// offered the session before we actually started it!
		
		// Tell the account handler that we start a new session, so
		// it set up things if needed. This call may just setup some stuff 
		// for a new session, or it might actually start a new session.
		bool b = pAccount->startSession(pDoc, m_vAcl, &pSession);
		if (!b)
		{
			XAP_App::getApp()->getLastFocussedFrame()->showMessageBox(
						"There was an error sharing this document!", 
						XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK);
			return;
		}
		
		// start the session ourselves when the account handler did not...
		if (!pSession)
		{
			// ... and start the session!
			UT_UTF8String sSessionId("");
			// TODO: we could use/generate a proper descriptor when there is only
			// 1 account where we share this document over
			pSession = pManager->startSession(pDoc, sSessionId, pAccount, true, NULL, "");
		}
	}
	else
	{
		pSession = pManager->getSession(pDoc);
	}

	UT_return_if_fail(pSession);
	pManager->updateAcl(pSession, pAccount, vAcl);
}
GtkWidget * AP_UnixFrameImpl::_createStatusBarWindow()
{
#ifdef ENABLE_STATUSBAR
	XAP_Frame* pFrame = getFrame();
	AP_UnixStatusBar * pUnixStatusBar = new AP_UnixStatusBar(pFrame);
	UT_ASSERT(pUnixStatusBar);

	static_cast<AP_FrameData *>(pFrame->getFrameData())->m_pStatusBar = pUnixStatusBar;
	
	return pUnixStatusBar->createWidget();
#else
	return NULL;
#endif
}
Ejemplo n.º 22
0
GR_Graphics * AP_UnixApp::newDefaultScreenGraphics() const
{
	XAP_Frame * pFrame = findValidFrame();
	UT_return_val_if_fail( pFrame, NULL );
	UT_DEBUGMSG(("AP_UnixApp::newDefaultScreenGraphics() \n"));
	AP_UnixFrameImpl * pFI = static_cast<AP_UnixFrameImpl *>(pFrame->getFrameImpl());
	UT_return_val_if_fail( pFI, NULL );

	GtkWidget * da = pFI->getDrawingArea();
	UT_return_val_if_fail( da, NULL );
	
	GR_UnixCairoAllocInfo ai(da);
	return XAP_App::getApp()->newGraphics(ai);
}
Ejemplo n.º 23
0
bool s_abicollab_join(AV_View* /*v*/, EV_EditMethodCallData* /*d*/)
{
	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_val_if_fail(pManager, false);
	
	// Get the current view that the user is in.
	XAP_Frame *pFrame = XAP_App::getApp()->getLastFocussedFrame();
	// Get an Accounts dialog instance
	XAP_DialogFactory* pFactory = static_cast<XAP_DialogFactory *>(XAP_App::getApp()->getDialogFactory());
	UT_return_val_if_fail(pFactory, false);
	AP_Dialog_CollaborationJoin* pDialog = static_cast<AP_Dialog_CollaborationJoin*>(
				pFactory->requestDialog(AbiCollabSessionManager::getManager()->getDialogJoinId())
			);
	// Run the dialog
	pDialog->runModal(pFrame);
	// Handle the dialog outcome
	AP_Dialog_CollaborationJoin::tAnswer answer = pDialog->getAnswer();
	BuddyPtr pBuddy = pDialog->getBuddy();
	DocHandle* pDocHandle = pDialog->getDocHandle();
	pFactory->releaseDialog(pDialog);
	
	switch (answer)
	{
		case AP_Dialog_CollaborationJoin::a_OPEN:
			{
				UT_return_val_if_fail(pBuddy && pDocHandle, false);
				// Check if we have already joined this session. If so, then just
				// ignore the request. Otherwise actually join the session.
				AbiCollab* pSession = pManager->getSessionFromSessionId(pDocHandle->getSessionId());
				if (pSession)
				{
					UT_DEBUGMSG(("Already connected to session, just raising the associated frame\n"));

					// Just raise a frame that contains this session, instead of
					// opening the document again
					XAP_Frame* pFrameForSession = pManager->findFrameForSession(pSession);
					UT_return_val_if_fail(pFrameForSession, false);
					pFrameForSession->raise();
				}
				else
					pManager->joinSessionInitiate(pBuddy, pDocHandle);	
			}
			break;
		case AP_Dialog_CollaborationJoin::a_CANCEL:
			break;
	}	
	
	return true;
}
Ejemplo n.º 24
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;
}
// Does the initial show/hide of toolbars (based on the user prefs).
// This is needed because toggleBar is called only when the user
// (un)checks the show {Stantandard,Format,Extra} toolbar checkbox,
// and thus we have to manually call this function at startup.
void AP_UnixFrameImpl::_showOrHideToolbars()
{
	XAP_Frame* pFrame = getFrame();
	bool *bShowBar = static_cast<AP_FrameData*>(pFrame->getFrameData())->m_bShowBar;
	UT_uint32 cnt = m_vecToolbarLayoutNames.getItemCount();

	for (UT_uint32 i = 0; i < cnt; i++)
	{
		// TODO: The two next lines are here to bind the EV_Toolbar to the
		// AP_FrameData, but their correct place are next to the toolbar creation (JCA)
		EV_UnixToolbar * pUnixToolbar = static_cast<EV_UnixToolbar *> (m_vecToolbars.getNthItem(i));
		static_cast<AP_FrameData*> (pFrame->getFrameData())->m_pToolbar[i] = pUnixToolbar;
		static_cast<AP_UnixFrame *>(pFrame)->toggleBar(i, bShowBar[i]);
	}
}
Ejemplo n.º 26
0
void AP_Dialog_FormatTable::ShowErrorBox(UT_String & sFile, UT_Error errorCode)
{
    XAP_String_Id String_id;
    XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame();
    switch (errorCode)
    {
    case -301:
        String_id = AP_STRING_ID_MSG_IE_FileNotFound;
        break;

    case -302:
        String_id = AP_STRING_ID_MSG_IE_NoMemory;
        break;

    case -303:
        String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
        //AP_STRING_ID_MSG_IE_UnknownType;
        break;

    case -304:
        String_id = AP_STRING_ID_MSG_IE_BogusDocument;
        break;

    case -305:
        String_id = AP_STRING_ID_MSG_IE_CouldNotOpen;
        break;

    case -306:
        String_id = AP_STRING_ID_MSG_IE_CouldNotWrite;
        break;

    case -307:
        String_id = AP_STRING_ID_MSG_IE_FakeType;
        break;

    case -311:
        String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
        break;

    default:
        String_id = AP_STRING_ID_MSG_ImportError;
    }

    pFrame->showMessageBox(String_id,
                           XAP_Dialog_MessageBox::b_O,
                           XAP_Dialog_MessageBox::a_OK,
                           sFile.c_str());
}
Ejemplo n.º 27
0
void AP_Dialog_FormatFrame::ShowErrorBox(const std::string & sFile, UT_Error errorCode)
{
	XAP_String_Id String_id;
	XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame();
	switch (errorCode)
	  {
	  case UT_IE_FILENOTFOUND:
		String_id = AP_STRING_ID_MSG_IE_FileNotFound;
		break;

	  case UT_IE_NOMEMORY:
		String_id = AP_STRING_ID_MSG_IE_NoMemory;
		break;

	  case UT_IE_UNKNOWNTYPE:
		String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
		//AP_STRING_ID_MSG_IE_UnknownType;
		break;

	  case UT_IE_BOGUSDOCUMENT:
		String_id = AP_STRING_ID_MSG_IE_BogusDocument;
		break;

	  case UT_IE_COULDNOTOPEN:
		String_id = AP_STRING_ID_MSG_IE_CouldNotOpen;
		break;

	  case UT_IE_COULDNOTWRITE:
		String_id = AP_STRING_ID_MSG_IE_CouldNotWrite;
		break;

	  case UT_IE_FAKETYPE:
		String_id = AP_STRING_ID_MSG_IE_FakeType;
		break;

	  case UT_IE_UNSUPTYPE:
		String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
		break;

	  default:
		String_id = AP_STRING_ID_MSG_ImportError;
	  }

	pFrame->showMessageBox(String_id,
						   XAP_Dialog_MessageBox::b_O,
						   XAP_Dialog_MessageBox::a_OK,
						   sFile.c_str());
}
Ejemplo n.º 28
0
XAP_Frame* AbiCollabSessionManager::findFrameForSession(AbiCollab* pSession)
{
	UT_return_val_if_fail(pSession, NULL);
	UT_return_val_if_fail(pSession->getDocument(), NULL);

	for (UT_sint32 i = 0; i < XAP_App::getApp()->getFrameCount(); i++)
	{
		XAP_Frame* pFrame = XAP_App::getApp()->getFrame(i);
		UT_continue_if_fail(pFrame);

		if (pSession->getDocument() == pFrame->getCurrentDoc())
			return pFrame;
	}

	return NULL;
}
AbiCollab* AP_Dialog_CollaborationShare::_getActiveSession()
{
	AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
	UT_return_val_if_fail(pManager, NULL);

	XAP_Frame* pFrame = XAP_App::getApp()->getLastFocussedFrame();
	UT_return_val_if_fail(pFrame, NULL);

	PD_Document* pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc());
	UT_return_val_if_fail(pDoc, NULL);

	if (!pManager->isInSession(pDoc))
		return NULL;

	return pManager->getSession(pDoc);
}
/*!
    translate given language tag into static UT_LangRecord stored in
    UT_Language class and set m_pKbdLang to it; do addtional
    processing to ensure the change propagates into the status bar
*/
void XAP_App::setKbdLanguage(const char * pszLang)
{
	if(!pszLang)
	{
		m_pKbdLang = NULL;
	}
	else
	{
		UT_Language Lang;
		m_pKbdLang = Lang.getLangRecordFromCode(pszLang);

		// ensure that the change is shown in our status bar
	    bool bChangeLang = false;
		getPrefsValueBool(XAP_PREF_KEY_ChangeLanguageWithKeyboard, &bChangeLang);

		if(bChangeLang && m_pKbdLang)
		{
			UT_return_if_fail(m_pKbdLang->m_szLangCode);
			
			// invoke appropriate formatting method if it exists
			const EV_EditMethodContainer * pEMC = getEditMethodContainer();

			if(pEMC)
			{
				EV_EditMethod * pEM = pEMC->findEditMethodByName("language");
			
				if (pEM)
				{
					XAP_Frame * pFrame = getLastFocussedFrame();
					
					if(pFrame)
					{
						AV_View * pView = pFrame->getCurrentView();

						if(pView)
						{
							EV_EditMethodCallData CallData(m_pKbdLang->m_szLangCode,
														   strlen(m_pKbdLang->m_szLangCode));

							pEM->Fn(pView,&CallData);
						}
					}
				}
			}
		}
	}
}