[Libreoffice] making binfilter aka StarOffice FileFormat read-only

Regina Henschel rb.henschel at t-online.de
Fri Jan 14 10:33:32 PST 2011


Hi all,

there is something wrong actually. Removing *Export*-filter is 
reasonable, but now in LibO RC3 I cannot *read* my SO5 files.

Kind regards
Regina



Pierre-André Jacquod schrieb:
> Hello,
> these days, I have tried (and not really with full success) to
> understand how binfilter works...
>
> My goal: since it is an old legacy format, make StarOffice formats
> read-only, and clean binfilter component of all code used for writing files.
>
> Reason: with read-only, you will still be able to read your old files /
> archive, but his will push the users to use a current / supported format
> in case of change. So a less heavy software, use of well-maintained (see
> minutes of tech steering call ... 2010.12.09)
>
> After some code reading here a resume of my understanding. Thanks for
> correcting, asking, challenging me. I hope I did not understand it too
> wrongly.
>
> An easy (and clean) possibility would be to change the filters defined
> in binfilter as read-only filters (using as filter flag
> SFX_FILTER_OPENREADONLY defined as 0x00010000L) This will make the
> opening read-only. By this way, this is not possible any more to save
> using these file formats.
> (I have not yet found where this is set, but still searching)
>
> Currently, I have simulated it locally adding in
> libs-core/sfx2/source/bastyp/fltfnc.cxx: (almost at the end of the
> function SfxFilterContainer::ReadSingleFilter_Impl )
>
> if (nFormatVersion<  SOFFICE_FILEFORMAT_60)
> {
>      pFilter->nFormatType = ( nFlags | SFX_FILTER_OPENREADONLY);
> }
>
> this is not a nice hack, but it demonstrates me that it works / how it
> works.
>
> This shows me:
> a) it works. Yesss : -)
>
> b) there are functions defined in libs-core and binfilter (sfx2 of
> libs-core and sfx2 in binfilters) that are redundant. e.g
> SFX_FILTER_OPENREADONLY (and other constant values) are defined in both
> filters/binfilter/inc/bf_sfx2/docfilt.hxx
> libs-core/sfx2/inc/sfx2/docfilt.hxx
>
> c) it seems there are elements in the sfx2 of binfilter that are still
> called, generated, but have no impact on the running system. For exemple
> function SfxFilterContainer::ReadExternalFilters (in
> binfilter/bf_sfx2/source/bastyp/sfx2_fltfnc.cxx) is still called,
> produced me a lot of debug text, but the above mentionned code inserted
> at the same place (as in libs-core but within his function) did not
> produced any effect. So this function is still called, but its effects
> are not taken into account.
>
> d) So binfilter could be simplified if I take out all wrinting stuff,
> and not needed section of code still called...
>
> I noticed the following at SaveAs: all StarOffice format were still
> available, but were producing an error at saving, since they are now by
> me read-only... I did not find the place, but could someone hint me
> where this is? Actually, I think the list of format displayed at Save or
> SaveAs should contain only "not read-only" filters, something like this
> in pseudo-code:
>
> (if (filter.getFlags()&&  SFX_FILTER_OPENREADONLY) !=
> SFX_FILTER_OPENREADONLY)
> { display this filter in save / saveas dialog}
> (note: I also saw a function isReadOnly() or something like this that
> could be called on filter objects, returning true / false. Is probably
> even better...)
>
> I do not think there are currently READONLY filters, but basically, I
> think this is a bug not taking this flag into account. And so in one go
> all problem solved in switching the binfilter to READ-ONLY. If someone
> could help me for this part...
>
> Finaly, at saving, this work like this:
> (valid for StarOffice format... beware, other format, other paths)
>
> SfxObjectShell::PreDoSaveAs_Impl(param) in libs-core
> SfxObjectShell::SaveTo_Impl(param) for ExporTo in libs-core
> SfxObjectShell::PreDoSaveAs_Impl(param)
> SfxObjectShell::SaveTo_Impl(param) 2  in sfx2_objstor.cxx
> SfxObjectShell::SaveAsOwnFormat( param) in sfx2_objstor.cxx
> SfxObjectShell::SaveAs(param) in sfx2_objstor.cxx
> SfxObjectShell::SaveInfoAndConfig_Impl(param2)
> BasicManager::Store(param)
> BasicManager::Store(param2)
> BasicLibInfo::Store(param)
> StgWriter::Write (param)
> Sw3Writer::WriteStorage()
> Sw3IO::SaveAs
> Sw3IO::Save
> ExportTo is finished and has returned
>
> with the ExportTo function going "magically" to the binfilter module. I
> did not understood what I read there, with the uno part...
>
> Until (and with) the function BasicLibInfo::Store(param), this the
> common part of binfilter for all modules. Then it splits to writer,
> calc,...
>
> At opening with read-write filter, some of these write functions are
> called (for the lock file). With a read-only filter, this does not
> happens. At opening, there is also the dark magic call (:- (  through
> uno to go through the different filters one by one for generating them....
>
>
> So how to go ahead?
>
> Here I am asking you:
> - is it OK to go ahead with this idea?
> - should I make a feature/StarOffice-read-only branch ?
> - could someone (help me) implement the sorting in order to ensure that
> read-only filters are not available for Save / Save As?
>
> Of course, if going ahead on this way, I will search the code in order
> to find the right place for activating the SFX_FILTER_OPENREADONLY flag
> as property for the filter, not using this hack....hopefully
>
> Thanks for your feed-backs
> Regards
> Pierre-André
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>



More information about the LibreOffice mailing list