[Libreoffice] making binfilter aka StarOffice FileFormat read-only

Pierre-André Jacquod pjacquod at alumni.ethz.ch
Fri Jan 7 15:15:46 PST 2011


Hi Jan / Hi Michael,

some more testing and code reading. Here some answers.
[I was writing this mail while testing, mostly written before Michael's
mail. Hence this will answers both mails. ]

> This is a good point - as you say, I agree we can omit the creation of
> the lock file.  It would be good to double-check how it behaves when you
> have a format where you have one filter for reading, and other one for
> writing ;-)  

The behaviour here is quite straight forward:

   * at opening the import only filter in rw, it set the
lock-file for this file (e.g. a swd file)
   * if changes have been done but not yet saved, the backup file in
"current format" is created as back-up
   * when clicking save, it opens the "save as" pop-up. You have to
choose an EXPORT format. On saving, the lock on the previous (let's say
swd file) is released and a new lock on the new file (let's say odf) is
created. From now one you work with / within the new file/ file format.

> But either way, I don't think that actually creating the
> lock even though the filter is import-only is that serious issue, ie.
> you can remove the locking of the file later, it is not blocking your
> work.
Right, seems fair. But I have detected some write function(s) deep in
binfilter (since linked to sw function code, not the generic
binfilter/sfx2 layer) that are called at *opening* when this is not done
in read-only modus....  Then I think this is called to set the lock
file. (not yet followed the whole) This is while I directed me towards
read-only mode.

I guess the process should change and do not set a lock-file if this is
opened read-only OR with a filter without export capability.


>> investigate): with opening in read/write and without EXPORT filter, what
>> happens with the auto-save option, after some changes have been done?
> No idea, without testing myself.  I think we could fallback to
> autosaving in ODF format, if we do not do it yet ;-)
Finally, that's OK. See above. And Michael's mail

>> The filter, despite write is not usable (no export). ...
>> So ideally could it be: not export, READONLY and pop-up ?? :- /
> I'd still prefer not to set the read-only flag if possible, it is a
After playing a bit, I agree, and I think it will be possible to handle
that in a proper way.

Just stupid question: should a warning pop-up really be set ?

Finally, making the binfilter import only (i.e without export / write
functionality) is a shared property of ALL file formats which (would not
have) / have not the EXPORT flag set. Nothing to do with legacy or not...

This is why, if a pop-up is still / really wanted, I think this should
be a generic pop-up like:

if ! FLAG_FILTER_EXPORT
 pop-up: this file format is supported only in read modus. If you modify
the document, you will have to save it using another format, which you
may not be able to open with the program that initially created this file
(text should be improved :-)....

I found a place to put such a pop-up (but I think this is quite a dirty
place):
in libs-core/sfx2/source/doc/sfxbasemodel.cxx
within SfxBaseModel::load

 	 // load document
        sal_uInt32 nError = ERRCODE_NONE;
        if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
            nError=ERRCODE_IO_GENERAL;
+        else
+        {
+          if( !( pMedium->GetFilter()->GetFilterFlags()
+                 &  SFX_FILTER_EXPORT ) )
+          {
+               // here pop-up: this is import only filer
+               // you won't be able to save it within this format
+          }

just after loading the file, but long before being back at the top
level... horrible.

Have someone a better idea where to put it ?
	
regards
Pierre-André

ps: since Christmas holidays are behind, I will need more time for each
step... doing it during free time:- ).


More information about the LibreOffice mailing list