[Solved] How to insert comments to document?

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
sinxxx
Posts: 20
Joined: Mon Jun 07, 2010 4:01 am

[Solved] How to insert comments to document?

Post by sinxxx »

How to insert the Comments as the desription to document?

what my code is like below is only can insert the "DocumentTitle" to documents, but can't insert the "Comment" , I don't know why.

Code: Select all


// get storable interface 
XStorable xStorable = (XStorable)xDoc; 

// set properties 
unoidl.com.sun.star.beans.PropertyValue[] propValsStore = new unoidl.com.sun.star.beans.PropertyValue[3]; 
propValsStore[0] = new unoidl.com.sun.star.beans.PropertyValue(); 
propValsStore[0].Name = "Overwrite"; 
propValsStore[0].Value = new uno.Any(true); 
propValsStore[1] = new unoidl.com.sun.star.beans.PropertyValue(); 
propValsStore[1].Name = "DocumentTitle"; 
propValsStore[1].Value = new uno.Any("MyDocumentTitle" 
propValsStore[2] = new unoidl.com.sun.star.beans.PropertyValue(); 
propValsStore[2].Name = "Comment"; 
propValsStore[2].Value = new uno.Any("MyComment"); 

// save document 
xStorable.storeToURL(strSaveToURL, propValsStore); 

Last edited by Hagar Delest on Mon Jul 19, 2010 2:58 pm, edited 1 time in total.
Reason: tagged [Solved].
openoffice 3.2 for windows
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to insert comments to document?

Post by Zizi64 »

Wich type of "Comments" want you insert a document?

Is it analog with manually inserted comment into text "Edit -> Insert Comment"?
Or you tought "File -> Properties -> Description -> Comments" option?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
sinxxx
Posts: 20
Joined: Mon Jun 07, 2010 4:01 am

Re: How to insert comments to document?

Post by sinxxx »

Zizi64 wrote:Wich type of "Comments" want you insert a document?

Is it analog with manually inserted comment into text "Edit -> Insert Comment"?
Or you tought "File -> Properties -> Description -> Comments" option?
what I mean is "File -> Properties -> Description -> Comments".
And I want to add it by OOo api.
openoffice 3.2 for windows
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to insert comments to document?

Post by Zizi64 »

I recorded a Basic macro:

I filled in the Comments "label" manually when recorded the macro. See the highlited lines under code:

Code: Select all

sub comment
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(9) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Properties.UseUserData"
args1(0).Value = true
args1(1).Name = "Properties.DeleteUserData"
args1(1).Value = false
args1(2).Name = "Properties.Title"
args1(2).Value = ""
args1(3).Name = "Properties.Subject"
args1(3).Value = ""
args1(4).Name = "Properties.KeyWords"
args1(4).Value = ""
args1(5).Name = "Properties.Description"
args1(5).Value = "It is named DESCRIPTION, not COMMENT"
args1(6).Name = "Properties.AutoReload"
args1(6).Value = false
args1(7).Name = "Properties.AutoReloadTime"
args1(7).Value = 0
args1(8).Name = "Properties.AutoReloadURL"
args1(8).Value = ""
args1(9).Name = "Properties.AutoReloadFrame"
args1(9).Value = ""

dispatcher.executeDispatch(document, ".uno:SetDocumentProperties", "", 0, args1())


end sub


args1(5).Name = "Properties.Description"
args1(5).Value = "It is named DESCRIPTION, not COMMENT"
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
sinxxx
Posts: 20
Joined: Mon Jun 07, 2010 4:01 am

Re: How to insert comments to document?

Post by sinxxx »

args1(5).Name = "Properties.Description"
args1(5).Value = "It is named DESCRIPTION, not COMMENT"
I try it by c# links the code below, but it's not works, and I can't crate the "dispatcher " by C#

Code: Select all

propValsStore[2].Name = "Properties.Description"; 
propValsStore[2].Value = new uno.Any("MyComment"); 
openoffice 3.2 for windows
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to insert comments to document?

Post by Zizi64 »

Your new syntax:
propValsStore[2].Name = "Properties.Description";
propValsStore[2].Value = new uno.Any("MyComment");
Your previous syntax:
propValsStore[2].Name = "Comment";
propValsStore[2].Value = new uno.Any("MyComment");
Why not you still your previous syntax?


If another properties seems work with your syntax, then try it:
propValsStore[2].Name = "Description";
propValsStore[2].Value = new uno.Any("MyComment");
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
sinxxx
Posts: 20
Joined: Mon Jun 07, 2010 4:01 am

Re: How to insert comments to document?

Post by sinxxx »

Zizi64 wrote: If another properties seems work with your syntax, then try it:
propValsStore[2].Name = "Description";
propValsStore[2].Value = new uno.Any("MyComment");
I had been try:

Code: Select all

propValsStore[2].Name = "Description";
propValsStore[2].Value = new uno.Any("MyComment");

Code: Select all

propValsStore[2].Name = "Properties.Description";
propValsStore[2].Value = new uno.Any("MyComment");

Code: Select all

propValsStore[2].Name = "DocumentDescription";
propValsStore[2].Value = new uno.Any("MyComment");

Code: Select all

propValsStore[2].Name = "DocumentComments";
propValsStore[2].Value = new uno.Any("MyComment");

Code: Select all

propValsStore[2].Name = "Properties.DocumentComments";
propValsStore[2].Value = new uno.Any("MyComment");
and so on...

but they were not works
openoffice 3.2 for windows
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to insert comments to document?

Post by Zizi64 »

Sorry, no more ideas.
The C # language I do not know.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: How to insert comments to document?

Post by B Marcelly »

Hi,
Your initial code is used for a comment in a document using versioning, see documentation of service MediaDescriptor.

For what you want to do, you have to get the DocumentProperties from the document.
Then you have to modify the attribute Description. Note : an attribute is not a property, it is related to an interface.
There is no setDocumentProperties(), it is magically modified.

Code: Select all

REM  *****  BASIC  *****

Option Explicit

Sub fillDocumentDescription
Dim docInfos As Object

docInfos = ThisComponent.getDocumentProperties()
docInfos.Description = "This is a comment" & chr(13) & "inside File > Properties > Description"
' and that's all !
End Sub
I know, C# is not as easy as Basic. :crazy:
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
sinxxx
Posts: 20
Joined: Mon Jun 07, 2010 4:01 am

Re: How to insert comments to document?

Post by sinxxx »

hi,
I can't find the interface "XDocumentProperties" or "XDocumentPropertiesSupplier" in the api for c#.
But I had been solved this issue by edit the "meta.xml" file by AODL lib :D ,
and after all, thanks every one ,and I will still try to find the method to solve these problem by OOo api by c#.

Thanks.
openoffice 3.2 for windows
Post Reply