https://issues.apache.org/ooo/show_bug.cgi?id=121665

--- Comment #5 from Ariel Constenla-Haile <[email protected]> ---
(In reply to comment #4)
> Did you look at my program, or did I post it too late for you?

I don't understand your example, and what it is trying to proof. In which line
is supposed to be the error while performing what action?

> I might be misunderstanding the documentation here: does the OVERWRITE
> parameter live with the document and mark it as not overwriteable? Isn't
> this the same as read-only? It's certainly not how I read the documentation
> of MediaDescriptor, which says "overwrite any existing file".

The following statement is not true:

> When storing a document with a null parameter list for the IArguments
> parameter it overwrites an existing document.

If you store a document to an URL where *another* document exists, and
"Overwrite" is not set in the MediaDescriptor (not set at all, nor true, nor
false), then trying to store it produces an error and does *not* overwrite the
existing document.

This is what my macro tries to show you.


If you load a document from an URL, and then try to store it to the same URL,
obviously not setting Overwrite at all will overwrite the document: storing a
document to the same URL from where it was loaded is *overwriting* the state
before the last save operation. Setting Overwrite to true is the same as not
setting at all.

But setting Overwrite to false must produce an error: storing a document to the
same URL from where it was loaded *must* overwrite it, it's something logical.

> The definition in 
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/document/MediaDescriptor.html
>  
> says that the default value is FALSE, implying that this should give an error.

The meaning of this sentence:

"overwrite any existing file 
For storing only: overwrite any existing file, default is false, so an error
occurs if the target file already exists."


is that when you try to store a document to an URL, and this URL points to
*another* document, then the application will not try to overwrite the existing
file, it will throw an exception.

When you store the document to the same URL where it was loaded, storeAsURL()
is the same as store(), and obviously saving the document overwrites it. If you
set Overwrite to False an exception will be thrown. Setting Overwrite to True
is redundant.

http://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Storing_Documents

"The XStorable offers the methods store(), storeAsURL() and storeToURL() for
storing. The latter two methods are called with a media descriptor.

The method store() overwrites an existing file. Calling this method on a
document that was created from scratch using a private:factory/... URL leads to
an exception.

The other two methods storeAsURL() and storeToURL() leave the original file
untouched and differ after the storing procedure. The storeToURL() method saves
the current document to the desired location without touching the internal
state of the document. The method storeAsURL sets the Modified attribute of the
document, accessible through its com.sun.star.util.XModifiable interface, to
false and updates the internal media descriptor of the document with the
parameters passed in the call. This changes the document URL."


The documentation doesn't explain that

oDoc.storeAsURL( oDoc.getLocation(), Array() )

is the same as oDoc.store()

precondition: oDoc.hasLocation() returns true.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.

Reply via email to