Re: CVS: commit uwog abiword-plugins/tools/abimathview/xp

From: J.M. Maurer <j.m.maurer_at_student.utwente.nl>
Date: Thu Aug 18 2005 - 02:39:07 CEST

On Thu, 2005-08-18 at 09:20 +1000, msevior@physics.unimelb.edu.au wrote:
> >
>
> Please check that you can now drag and drop (and copy and paste) a MathML
> file into abiword.

This doesn't even work with the graphics mess in place... Or i'm missing
something really obvious.

If you cvs upped already, you can revert it with a simple

  cvs update -j1.26 -j1.24 AbiMathview.cpp

to test the old behavior

> You should have asked before doing this. There was a reason it was
> imported as a graphics type. Graphics get inserted at the caret. Files
> fill the document.

Then we should add an Object Type that behaves the same. Insert ->
Equation -> From File gives me the option of a ".png" file, or "all
supported graphics formats". This is so wrong, I'm not even going to
discuss it.

Marc

> Martin
>
> > Update of /cvsroot/abiword-plugins/tools/abimathview/xp
> > In directory abiword.snt.utwente.nl:/tmp/cvs-serv4840
> >
> > Modified Files:
> > AbiMathView.cpp
> > Log Message:
> > More indentation/Abi coding style fixes
> >
> >
> >
> > Index: AbiMathView.cpp
> > ===================================================================
> > RCS file: /cvsroot/abiword-plugins/tools/abimathview/xp/AbiMathView.cpp,v
> > retrieving revision 1.25
> > retrieving revision 1.26
> > diff -u -d -r1.25 -r1.26
> > --- AbiMathView.cpp 17 Aug 2005 22:27:27 -0000 1.25
> > +++ AbiMathView.cpp 17 Aug 2005 22:33:52 -0000 1.26
> > @@ -110,16 +110,17 @@
> >
> > static int sortEntities(const void * pEnt1, const void * pEnt2)
> > {
> > - const char * sz1 =NULL;
> > - const char * sz2 = NULL;
> > - AbiMathViewEntityMapItem ** pE1 =NULL;
> > - AbiMathViewEntityMapItem ** pE2 =NULL;
> > - pE1 = reinterpret_cast<AbiMathViewEntityMapItem
> > **>(reinterpret_cast<void ** >(const_cast<void *>(pEnt1)));
> > - pE2 = reinterpret_cast<AbiMathViewEntityMapItem
> > **>(reinterpret_cast<void ** >(const_cast<void *>(pEnt2)));
> > - sz1 = (*pE1)->szEntity;
> > - sz2 = (*pE2)->szEntity;
> > - //printf("Compare sz1 %s to sz2 %s \n",sz1,sz2);
> > - return UT_strcmp(sz1,sz2);
> > + const char * sz1 = NULL;
> > + const char * sz2 = NULL;
> > + AbiMathViewEntityMapItem ** pE1 = NULL;
> > + AbiMathViewEntityMapItem ** pE2 = NULL;
> > +
> > + pE1 = reinterpret_cast<AbiMathViewEntityMapItem
> > **>(reinterpret_cast<void ** >(const_cast<void *>(pEnt1)));
> > + pE2 = reinterpret_cast<AbiMathViewEntityMapItem
> > **>(reinterpret_cast<void ** >(const_cast<void *>(pEnt2)));
> > + sz1 = (*pE1)->szEntity;
> > + sz2 = (*pE2)->szEntity;
> > +
> > + return UT_strcmp(sz1,sz2);
> > }
> >
> > //
> > @@ -307,28 +308,29 @@
> > static void
> > AbiMathView_removeFromMenus ()
> > {
> > - // First we need to get a pointer to the application itself.
> > - XAP_App *pApp = XAP_App::getApp();
> > + // 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 ( "AbiMathView_FileInsert" )
> > ;
> > - pEMC->removeEditMethod ( pEM ) ;
> > - DELETEP( pEM ) ;
> > + // remove the edit method
> > + EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer() ;
> > + EV_EditMethod * pEM = ev_EditMethod_lookup ( "AbiMathView_FileInsert" )
> > ;
> > + pEMC->removeEditMethod ( pEM ) ;
> > + DELETEP( pEM ) ;
> >
> > - // now remove crap from the menus
> > - int frameCount = pApp->getFrameCount();
> > - XAP_Menu_Factory * pFact = pApp->getMenuFactory();
> > + // now remove crap from the menus
> > + int frameCount = pApp->getFrameCount();
> > + XAP_Menu_Factory * pFact = pApp->getMenuFactory();
> >
> > - pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelEquation);
> > - pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelFileInsert);
> > - pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelLatexInsert);
> > - for(int i = 0;i < frameCount;++i)
> > - {
> > - // Get the current frame that we're iterating through.
> > - XAP_Frame* pFrame = pApp->getFrame(i);
> > - pFrame->rebuildMenus();
> > - }
> > + pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelEquation);
> > + pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelFileInsert);
> > + pFact->removeMenuItem("Main",NULL,AbiMathView_MenuLabelLatexInsert);
> > +
> > + for (int i = 0; i < frameCount; ++i)
> > + {
> > + // Get the current frame that we're iterating through.
> > + XAP_Frame* pFrame = pApp->getFrame(i);
> > + pFrame->rebuildMenus();
> > + }
> > }
> >
> >
> > @@ -337,48 +339,48 @@
> > XAP_String_Id String_id;
> >
> > switch (errorCode)
> > - {
> > - case -301:
> > - String_id = AP_STRING_ID_MSG_IE_FileNotFound;
> > - break;
> > + {
> > + case -301:
> > + String_id = AP_STRING_ID_MSG_IE_FileNotFound;
> > + break;
> >
> > - case -302:
> > - String_id = AP_STRING_ID_MSG_IE_NoMemory;
> > - 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 -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 -304:
> > + String_id = AP_STRING_ID_MSG_IE_BogusDocument;
> > + break;
> >
> > - case -305:
> > - String_id = AP_STRING_ID_MSG_IE_CouldNotOpen;
> > - break;
> > + case -305:
> > + String_id = AP_STRING_ID_MSG_IE_CouldNotOpen;
> > + break;
> >
> > - case -306:
> > - String_id = AP_STRING_ID_MSG_IE_CouldNotWrite;
> > - break;
> > + case -306:
> > + String_id = AP_STRING_ID_MSG_IE_CouldNotWrite;
> > + break;
> >
> > - case -307:
> > - String_id = AP_STRING_ID_MSG_IE_FakeType;
> > - break;
> > + case -307:
> > + String_id = AP_STRING_ID_MSG_IE_FakeType;
> > + break;
> >
> > - case -311:
> > - String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
> > - break;
> > + case -311:
> > + String_id = AP_STRING_ID_MSG_IE_UnsupportedType;
> > + break;
> >
> > - default:
> > - String_id = AP_STRING_ID_MSG_ImportError;
> > - }
> > + default:
> > + String_id = AP_STRING_ID_MSG_ImportError;
> > + }
> >
> > return pFrame->showMessageBox(String_id,
> > - XAP_Dialog_MessageBox::b_O,
> > - XAP_Dialog_MessageBox::a_OK,
> > - pNewFile);
> > + XAP_Dialog_MessageBox::b_O,
> > + XAP_Dialog_MessageBox::a_OK,
> > + pNewFile);
> > }
> >
> > static bool s_AskForMathMLPathname(XAP_Frame * pFrame,
> > @@ -463,57 +465,52 @@
> > 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;
> > + // 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);
> > + bool bOK = s_AskForMathMLPathname(pFrame,&pNewFile);
> >
> > - if (!bOK || !pNewFile)
> > - {
> > - UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %x \n",bOK,pNewFile));
> > - return false;
> > - }
> > - UT_UTF8String sNewFile = pNewFile;
> > -
> > - // we own storage for pNewFile and must free it.
> > - FREEP(pNewFile);
> > + if (!bOK || !pNewFile)
> > + {
> > + UT_DEBUGMSG(("ARRG! bOK = %d pNewFile = %x \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()));
> > + UT_DEBUGMSG(("fileInsertMathML: loading [%s]\n",sNewFile.utf8_str()));
> >
> > - IE_Imp_MathML * pImpMathML = new IE_Imp_MathML(pDoc);
> > - UT_Error errorCode = pImpMathML->importFile(sNewFile.utf8_str());
> > -
> > - if(errorCode != UT_OK)
> > - {
> > - s_CouldNotLoadFileMessage(pFrame, sNewFile.utf8_str(), errorCode);
> > - DELETEP(pImpMathML);
> > - return false;
> > - }
> > + IE_Imp_MathML * pImpMathML = new IE_Imp_MathML(pDoc);
> > + 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
> > - */
> > - const char* mimetypeMATHML = NULL;
> > - mimetypeMATHML = UT_strdup("application/mathml+xml");
> > - 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(), static_cast<void *>(const_cast<char
> > *>(mimetypeMATHML)), NULL);
> > + /* Create the data item */
> > + const char* mimetypeMATHML = NULL;
> > + mimetypeMATHML = UT_strdup("application/mathml+xml");
> > + 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(),
> > static_cast<void *>(const_cast<char *>(mimetypeMATHML)), NULL);
> >
> > -// Insert the MathML Object
> > - PT_DocPosition pos = pView->getPoint();
> > - // printf("Insert Object at %d \n",pos);
> > - pView->cmdInsertMathML(sUID.utf8_str(),pos);
> > + /* Insert the MathML Object */
> > + PT_DocPosition pos = pView->getPoint();
> > + pView->cmdInsertMathML(sUID.utf8_str(),pos);
> >
> > - DELETEP(pImpMathML);
> > + DELETEP(pImpMathML);
> >
> > - return true;
> > + return true;
> > }
> >
> >
> > @@ -550,8 +547,8 @@
> > }
> >
> > GR_AbiMathItems::GR_AbiMathItems(void):
> > - m_iAPI(0),
> > - m_bHasSnapshot(false)
> > + m_iAPI(0),
> > + m_bHasSnapshot(false)
> > {
> > }
> >
> > @@ -559,14 +556,14 @@
> > {
> > }
> >
> > -GR_MathManager::GR_MathManager(GR_Graphics* pG)
> > - : GR_EmbedManager(pG),
> > - m_CurrentUID(-1),
> > - m_pLogger(NULL),
> > - m_pMathGraphicDevice(NULL),
> > - m_pAbiContext(NULL),
> > - m_pOperatorDictionary(NULL),
> > - m_pDoc(NULL)
> > +GR_MathManager::GR_MathManager(GR_Graphics* pG) :
> > + GR_EmbedManager(pG),
> > + m_CurrentUID(-1),
> > + m_pLogger(NULL),
> > + m_pMathGraphicDevice(NULL),
> > + m_pAbiContext(NULL),
> > + m_pOperatorDictionary(NULL),
> > + m_pDoc(NULL)
> > {
> > m_vecMathView.clear();
> > m_vecItems.clear();
> >
> > -----------------------------------------------
> > To unsubscribe from this list, send a message to
> > abisource-cvs-commit-request@abisource.com with the word
> > unsubscribe in the message body.
> >
>
>
Received on Thu Aug 18 02:37:44 2005

This archive was generated by hypermail 2.1.8 : Thu Aug 18 2005 - 02:37:45 CEST