Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Thursday 18 of August 2011, Bjoern Michaelsen wrote: Hi Lubos, On Tue, 16 Aug 2011 12:09:19 +0200 Lubos Lunak l.lu...@suse.cz wrote: No, starmath doesn't need to call back to writer. The problem is that this is still needlessly complicated. How about the attached patch? While it works, I would prefer if the 10.000-feet-view of the project stays reasonably understandable I can't say I find the project reasonably understandable, no matter from how many feet I look. as the codebase as is is already hard enough to grok -- esp. for newcomers. One of the few sane structurings of the codebase is: http://wiki.services.openoffice.org/wiki/Build_Environment_Effort/Dependenc ies#Office_modules Is that true in practice? Sw and writerfilter have a hard depedency on filter already. I only added few more dependencies to starmath that sw already has as a dependency (sax, oox, msfilter). So I don't see how I made it any worse. which certainly could use improvement, but tearing it down without having resources and a good plan for a better structure is not a good idea IMHO. So why not go with Caolans proposal? Because, and I know I'm repeating myself, that's needlessly complicated, and the fact that everything is needlessly complicated is one of the major reasons why the codebase is hard to grok. And as long as new code is written like the old code it will stay so. Finally, one important reason I didn't go with Caolan's proposal was that I expect it probably wouldn't work, or would take a lot of time getting to work properly (I wasted several hours trying to implement a solution with UNO interfaces first). But I admit I lack the motivation to try it out for sure when I have a nice, clean and working solution in place. -- Lubos Lunak l.lu...@suse.cz ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Thursday 18 of August 2011, Lubos Lunak wrote: Is that true in practice? Sw and writerfilter have a hard depedency on Correction: Writerfilter does not. It doesn't change anything though. filter already. I only added few more dependencies to starmath that sw already has as a dependency (sax, oox, msfilter). So I don't see how I made it any worse. -- Lubos Lunak l.lu...@suse.cz ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
Hi Lubos, On Tue, 16 Aug 2011 12:09:19 +0200 Lubos Lunak l.lu...@suse.cz wrote: No, starmath doesn't need to call back to writer. The problem is that this is still needlessly complicated. How about the attached patch? While it works, I would prefer if the 10.000-feet-view of the project stays reasonably understandable as the codebase as is is already hard enough to grok -- esp. for newcomers. One of the few sane structurings of the codebase is: http://wiki.services.openoffice.org/wiki/Build_Environment_Effort/Dependencies#Office_modules which certainly could use improvement, but tearing it down without having resources and a good plan for a better structure is not a good idea IMHO. So why not go with Caolans proposal? Best, Bjoern -- https://launchpad.net/~bjoern-michaelsen ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Monday 15 of August 2011, Miklos Vajna wrote: On Mon, Aug 15, 2011 at 05:16:17PM +0200, Lubos Lunak l.lu...@suse.cz wrote: I'm implementing .docx OOXML support for writing math formulas. As this is something that could be used not only by Writer but also by other components, I want to implement the writing of the formula in Starmath. And even if I didn't want, Sm* classes (which implement and store the formulas) are in starmath/ , and sw-starmath do not link against each other. So, the question is, how do I call from sw to starmath without linking them together? I checked how the binary .doc filter does it, and it goes via ~10 calls deep [1] that call some UNO interfaces and store the result in some private stream or whatever. But I find that needlessly complicated, as I already have a pointer to SmModel and SmDocShell (I can get it the same way the .doc code does) and just need to call their method, passing the XML serializer object as an argument, that's it. The best I've come up with creating let's say offapi/com/sun/star/starmath/WriteMath.idl with the function, make SmModel inherit from that and castcall using it in sw. But I have not much idea about UNO, so I don't know what the stuff under offapi/ actually really is about. Is this a good solution or does somebody know something better? That looks fine, that's how the rest of writerfilter can live without the Sw* classes. Did you check if the existing uno api is enough for you? See the output of 'git ls-files starmath|grep uno'. If yes, then you don't have to mess with offapi. :) You missed two important parts :). I'm implementing, so this is new code and thus no existing UNO API, and more importantly, needlessly complicated, which means I'll probably still rather go with those 10 nested calls than introduce the hard-to-develop-and-debug UNO writerfilter nightmare to new code. Trying with offapi has turned out to be equally complicated, all the involved classes need to be based on UNO interfaces and then comes trouble with refcounting (no wonder some places in the codebase are such messed up hacks, when trying to do things properly makes one realize it's just not worth the effort). For now I've just linked sw to starmath locally so that I can actually develop something. If no better solution turns up, I think I'll eventually go for the simple and working way of introducing a plain C++ interface class in some library that both sw and starmath use and go with that. -- Lubos Lunak l.lu...@suse.cz ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Mon, 2011-08-15 at 17:16 +0200, Lubos Lunak wrote: Hello, I'm implementing .docx OOXML support for writing math formulas. As this is something that could be used not only by Writer but also by other components, I want to implement the writing of the formula in Starmath. And even if I didn't want, Sm* classes (which implement and store the formulas) are in starmath/ , and sw-starmath do not link against each other. So, the question is, how do I call from sw to starmath without linking them together? I checked how the binary .doc filter does it, and it goes via ~10 calls deep [1] that call some UNO interfaces and store the result in some private stream or whatever. SvxMSExportOLEObjects::ExportOLEObject seems to have blown out of control but the first and last branches are the typical ones. If it's a generic object then copy it's storage under the destination storage unchanged. If it's one of the special things that have an analogue in the destination format save it to a temporary storage in another format and copy that into the destination format instead. //export to temporary stream pStream ::uno::Reference io::XOutputStream xOut = new ::utl::OOutputStreamWrapper( *pStream ); aSeq[0].Value = xOut; xStor-storeToURL( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( private:stream )), aSeq ); //copy result to destination ole2 storage SotStorageRef xOLEStor = new SotStorage( pStream, sal_True ); xOLEStor-CopyTo( rDestStg ); I already have a pointer to SmModel and SmDocShell (I can get it the same way the .doc code does) and just need to call their method, passing the XML serializer object as an argument, that's it. Probably matters what the destination format is like ? Is it a standalone thing and/or exists in a substorage/folder of the parent format where it doesn't care about what it is inside ? i.e. I'd sort of expect to basically just add another export filter to starmath for whatever that format is, add it to SmDocShell::ConvertTo and call that directly/indirectly. And have a save as... entry for the format if it makes sense to have it standalone ? That's not going to work if the destination format needs hooks back into its surrounding container. Is that the problem ? C. ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Tuesday 16 of August 2011, Caolán McNamara wrote: On Mon, 2011-08-15 at 17:16 +0200, Lubos Lunak wrote: I already have a pointer to SmModel and SmDocShell (I can get it the same way the .doc code does) and just need to call their method, passing the XML serializer object as an argument, that's it. Probably matters what the destination format is like ? Is it a standalone thing and/or exists in a substorage/folder of the parent format where it doesn't care about what it is inside ? i.e. I'd sort of expect to basically just add another export filter to starmath for whatever that format is, add it to SmDocShell::ConvertTo and call that directly/indirectly. And have a save as... entry for the format if it makes sense to have it standalone ? The destination format is OOXML, and the formula is a part of one .xml file. It is standalone in the way that the whole formula is stored by starmath using Sm* classes and the XML subtree can be written out independently on the rest of the file. It is not standalone in the way that is it part of the .xml file and needs to be positioned inside the proper XML elements of the writer document. So using private streams is either not possible or only a complication depending on whether two sax_fastparser::FastSerializerHelper objects can be nested (I don't feel like trying, for these reasons). A standalone export file also wouldn't be right, as the formula needs to be inside a valid document. That's not going to work if the destination format needs hooks back into its surrounding container. Is that the problem ? No, starmath doesn't need to call back to writer. The problem is that this is still needlessly complicated. How about the attached patch? -- Lubos Lunak l.lu...@suse.cz diff --git a/filter/inc/filter/msfilter/ooxmlexport.hxx b/filter/inc/filter/msfilter/ooxmlexport.hxx new file mode 100644 index 000..6ec0594 --- /dev/null +++ b/filter/inc/filter/msfilter/ooxmlexport.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * http://www.openoffice.org/license.html + * for a copy of the LGPLv3 License. + * + / +#ifndef _OOXMLEXPORT_HXX +#define _OOXMLEXPORT_HXX + +#include sax/fshelper.hxx +#include filter/msfilter/msfilterdllapi.h + +/** + Interface class, StarMath will implement writeFormulaOoxml() to write out OOXML + representing the formula. + */ +class MSFILTER_DLLPUBLIC OoxmlFormulaExportBase +{ +public: +virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer ) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index 034bf60..ce22bc5 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -47,7 +47,9 @@ $(eval $(call gb_Library_add_linked_libs,sm,\ cppuhelper \ editeng \ i18npaper \ +msfilter \ sal \ +sax \ sfx \ sot \ svl \ diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx index 693ea3b..15ada7b 100644 --- a/starmath/inc/unomodel.hxx +++ b/starmath/inc/unomodel.hxx @@ -37,6 +37,7 @@ #include sfx2/sfxbasemodel.hxx #include comphelper/propertysethelper.hxx #include vcl/print.hxx +#include filter/msfilter/ooxmlexport.hxx class SmFormat; @@ -63,7 +64,8 @@ public: class SmModel : public SfxBaseModel, public comphelper::PropertySetHelper, public com::sun::star::lang::XServiceInfo, -public com::sun::star::view::XRenderable +public com::sun::star::view::XRenderable, +public OoxmlFormulaExportBase { SmPrintUIOptions* m_pPrintUIOptions; protected: @@ -100,6 +102,9 @@ public: virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference ::com::sun::star::uno::XInterface xParent ) throw(
Re: [Libreoffice] How to call from one component to another (sw-starmath)
Hi Lubos, On Tue, 2011-08-16 at 12:09 +0200, Lubos Lunak wrote: No, starmath doesn't need to call back to writer. The problem is that this is still needlessly complicated. How about the attached patch? I like it's simplicity personally :-) though of course we should use core/TEMPLATE.SOURCECODE.HEADER in new files, and I'm not the world's biggest fan of dynamic_cast but ... Go for it, if someone wants to overcomplicate and slow it down later, they can always do that ;-) ATB, Michael. -- michael.me...@novell.com , Pseudo Engineer, itinerant idiot ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] How to call from one component to another (sw-starmath)
On Mon, Aug 15, 2011 at 05:16:17PM +0200, Lubos Lunak l.lu...@suse.cz wrote: I'm implementing .docx OOXML support for writing math formulas. As this is something that could be used not only by Writer but also by other components, I want to implement the writing of the formula in Starmath. And even if I didn't want, Sm* classes (which implement and store the formulas) are in starmath/ , and sw-starmath do not link against each other. So, the question is, how do I call from sw to starmath without linking them together? I checked how the binary .doc filter does it, and it goes via ~10 calls deep [1] that call some UNO interfaces and store the result in some private stream or whatever. But I find that needlessly complicated, as I already have a pointer to SmModel and SmDocShell (I can get it the same way the .doc code does) and just need to call their method, passing the XML serializer object as an argument, that's it. The best I've come up with creating let's say offapi/com/sun/star/starmath/WriteMath.idl with the function, make SmModel inherit from that and castcall using it in sw. But I have not much idea about UNO, so I don't know what the stuff under offapi/ actually really is about. Is this a good solution or does somebody know something better? That looks fine, that's how the rest of writerfilter can live without the Sw* classes. Did you check if the existing uno api is enough for you? See the output of 'git ls-files starmath|grep uno'. If yes, then you don't have to mess with offapi. :) pgpuapeVQJGqT.pgp Description: PGP signature ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice