[Solved] Can I merge sidebar comments into main text?

Discuss the word processor

[Solved] Can I merge sidebar comments into main text?

Postby linter » Wed May 20, 2020 11:43 pm

so, i've got this doc that has a bunch of comments in the righthand sidebar with dotted-lines connecting them to the main text. but it's all incredibly confusing to me. i don't know what goes with what. it'd be much easier if the comments were placed right in the text where appropriate, maybe in a different color, if necessary.

is that possible? i'm working on something that has to be done in a hurry and i'm afraid i don't have time to learn a whole new way of doing things. perhaps later, but not now.

what do you think?
Last edited by Hagar Delest on Thu May 21, 2020 8:36 pm, edited 1 time in total.
Reason: tagged solved
OOo 2.3.X on MS Windows Vista
linter
 
Posts: 5
Joined: Fri May 22, 2009 1:44 pm

Re: can i merge sidebar comments into main text?

Postby JeJe » Thu May 21, 2020 12:50 am

You can create a character style with a background color for this.

The following macro will create a character style called "CommentStyle" with a yellow background, and copy the text of the comments into the document in that style.

TO BE SAFE MAKE A COPY OF YOUR DOCUMENT FIRST BEFORE RUNNING.

Code: Select all   Expand viewCollapse view

cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor =  rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)

en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
loop


Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1146
Joined: Wed Mar 09, 2016 2:40 pm

Re: can i merge sidebar comments into main text?

Postby linter » Thu May 21, 2020 2:35 am

thank you for that. it'll merge the comments into the text, right?

now all i have to do is figure out macros!
OOo 2.3.X on MS Windows Vista
linter
 
Posts: 5
Joined: Fri May 22, 2009 1:44 pm

Re: can i merge sidebar comments into main text?

Postby JeJe » Thu May 21, 2020 7:44 am

You have an ancient version of OO according to your signature. All I can do is go through what to do on my more up to date version as I don't have that old version. It may or may not be the same

Make a copy of your document, close all your others and open that.

Go to Tools menu/Macros/Organise Macros/Openoffice basic

In the dialog that pops up select the name of your document from the left side listbox and click the "New" button.

A popup box will ask you for the name of a module - just click on Okay.

You'll be taken to the macro area for your document where you'll find this:


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

Sub Main

End Sub


Copy and past the macro code I wrote above in between the sub main and end sub so it looks like this

Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Sub Main
cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor =  rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)

en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
loop
End Sub






When that's done press F5 to run the macro and see if the result is what you want.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1146
Joined: Wed Mar 09, 2016 2:40 pm

Re: Can I merge sidebar comments into main text?

Postby JeJe » Thu May 21, 2020 12:42 pm

Slightly improved version makes sure the textfields are all comments in case you have other ones in the document:

Code: Select all   Expand viewCollapse view

cs = thiscomponent.stylefamilies.getbyname("CharacterStyles")
if cs.hasbyname("CommentStyle") = false then
ss=thiscomponent.createinstance("com.sun.star.style.CharacterStyle")
ss.charbackcolor =  rgb(255,255,20)
cs.insertbyname("CommentStyle",ss)
end if

en =thiscomponent.textfields.createenumeration
tc = thiscomponent.text.createtextcursorbyrange(thiscomponent.text.start)
do until en.hasmoreelements = false
ff= en.nextelement
if ff.supportsService("com.sun.star.text.TextField.Annotation") then
anch= ff.anchor
tc.gotorange(anch.end,false)
tc.string =ff.textrange.text.string
tc.charstylename = "CommentStyle"
end if
loop

Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1146
Joined: Wed Mar 09, 2016 2:40 pm

Re: Can I merge sidebar comments into main text?

Postby linter » Thu May 21, 2020 2:06 pm

good golly that worked perfectly. what a life saver. i can't thank you enough. thank you!!!!
OOo 2.3.X on MS Windows Vista
linter
 
Posts: 5
Joined: Fri May 22, 2009 1:44 pm

Re: Can I merge sidebar comments into main text?

Postby JeJe » Thu May 21, 2020 2:18 pm

If you want to change the color or hide/show them you just have to change the properties of the character style.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1146
Joined: Wed Mar 09, 2016 2:40 pm


Return to Writer

Who is online

Users browsing this forum: No registered users and 13 guests