[Solved] Copy text format to entire document ?

Discuss the word processor
Post Reply
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

[Solved] Copy text format to entire document ?

Post by BubikolRamios »

1. Mark part of text
2. click Format Paintbrush
3. How to transfer that format to entire document which is from here to Mars ? Click, drag will nod be useful, right.

EDIT: to mark entire text with click ...... shift/click obviously does not work.
Last edited by robleyd on Fri May 21, 2021 1:33 pm, edited 2 times in total.
Reason: Add green tick
OPen office 4.1.5/ win 7
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Copy text format to entire document ?

Post by Hagar Delest »

Make a paragraph style from the selection and then select the whole document (Ctrl+A) and apply that style.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the *EDIT button if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: Copy text format to entire document ?

Post by BubikolRamios »

F11, select text, click button : new style from selection, name it 'foo', appears in list, looks like saved.

select some text that you want to format, dblclick on any in that F11 window list and I see the effect, except my 'foo', no effect ?
OPen office 4.1.5/ win 7
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: Copy text format to entire document ?

Post by BubikolRamios »

Ehh, had to switch to character styles, then your recipe works.

Thanks.
OPen office 4.1.5/ win 7
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

Doh I would suggest that functionality to be expanded/shortcuted so that click,shift Click (mark text) would work after Paintbrush click.

If possible.
OPen office 4.1.5/ win 7
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Copy text format to entire document ?

Post by JeJe »

When you've chosen the format and the paintbrush icon is showing:
press down with the mouse button at the start of the document but don't release
move the mouse to the bottom of the edit window so it scrolls to the end of the document and selects all the text as it does so.
Release the button.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Copy text format to entire document ?

Post by Hagar Delest »

In fact, it can work for paragraphs but you've to edit the paragraph style afterward (or create a paragraph style before) so that the character related settings are accessible. It's true that the paintbrush works on characters, not on paragraphs.
Note that double-click on the paintbrush button keeps the function active until you exit it (Esc key or click on the button).
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Bill
Volunteer
Posts: 8932
Joined: Sat Nov 24, 2007 6:48 am

Re: [Solved] Copy text format to entire document ?

Post by Bill »

BubikolRamios wrote:Ehh, had to switch to character styles, then your recipe works.

Thanks.
Character styles are not usually applied to whole paragraphs, much less whole documents. They are usually applied to a limited number of words in a paragraph. Paragraph styles contain both paragraph and character attributes and are applied to complete paragraphs, so applying a new paragraph style should have worked (it does for me).

Please upload a sample document so we can check to see if there is some corner case where applying the new paragraph style does not work.
AOO 4.1.14 on Ubuntu MATE 22.04
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Copy text format to entire document ?

Post by Hagar Delest »

BubikolRamios wrote:F11, select text, click button : new style from selection, name it 'foo', appears in list, looks like saved.

select some text that you want to format, dblclick on any in that F11 window list and I see the effect, except my 'foo', no effect ?
You may have applied a direct formatting on characters (bold for example). But the new style from selection for a paragraph style will NOT include the direct settings applied to characters (even those selected). That's why I said that you have to edit the paragraph style AFTER it has been created/applied so that you can access the Font tab.

Applying a character style to a whole document is indeed not a good idea.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Copy text format to entire document ?

Post by JeJe »

If you edit the default paragraph style... say making the font bold... then it and any styles linked with it will be changed to bold... which will possibly be the whole document.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Bill
Volunteer
Posts: 8932
Joined: Sat Nov 24, 2007 6:48 am

Re: [Solved] Copy text format to entire document ?

Post by Bill »

Hagar Delest wrote:
BubikolRamios wrote:F11, select text, click button : new style from selection, name it 'foo', appears in list, looks like saved.

select some text that you want to format, dblclick on any in that F11 window list and I see the effect, except my 'foo', no effect ?
You may have applied a direct formatting on characters (bold for example). But the new style from selection for a paragraph style will NOT include the direct settings applied to characters (even those selected).
That's probably it. The new paragraph style will include the direct formatting on characters if the direct formatting is applied to the whole paragraph. If the direct formatting is not applied to the whole paragraph, it won't be included in the new paragraph style.
Hagar Delest wrote:That's why I said that you have to edit the paragraph style AFTER it has been created/applied so that you can access the Font tab.

Applying a character style to a whole document is indeed not a good idea.
AOO 4.1.14 on Ubuntu MATE 22.04
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

JeJe wrote:When you've chosen the format and the paintbrush icon is showing:
press down with the mouse button at the start of the document but don't release
move the mouse to the bottom of the edit window so it scrolls to the end of the document and selects all the text as it does so.
Release the button.
I know that, but as stated in OP, the document is from here to Mars and you are siting there as d... a.., holding down mouse button, because this scroll is slow even at highest speed.
OPen office 4.1.5/ win 7
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Copy text format to entire document ?

Post by robleyd »

Ctrl+Shift+End will select from the cursor location to the end of the document.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

It does, same as CTRL+A. But you are left with paint bucket pointer and can't aplay formatting to selection (one would expect click to selection would do, it does not).
OPen office 4.1.5/ win 7
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

as it looks if nothing is selected format is set to entire clicked line (or something like that, word ... I don't know)
if something is selected, the same, to clicked line. That should be: to selected.

I hope that gets to developers ....
OPen office 4.1.5/ win 7
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Copy text format to entire document ?

Post by Hagar Delest »

No developers here. You've to file an enhancement request for that.
But the paintbrush is a direct formatting tool only, for very limited number of text strings. If you want a global formatting, then use styles as advised before.
If there is a part that you want to be in red for example and want to change the font type afterward, the paintbrush will remove the font color as well. With styles, the direct formatting or styles changes applied remain.
Paintbrush may be quicker for short documents but for long documents, forget about it. Use paragraph styles and character styles.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Copy text format to entire document ?

Post by JeJe »

JeJe wrote:
When you've chosen the format and the paintbrush icon is showing:
press down with the mouse button at the start of the document but don't release
move the mouse to the bottom of the edit window so it scrolls to the end of the document and selects all the text as it does so.
Release the button.

I know that, but as stated in OP, the document is from here to Mars and you are siting there as d... a.., holding down mouse button, because this scroll is slow even at highest speed.
Yes, but there is simple work around:

When you've chosen the format and the paintbrush icon is showing:

- press down with the mouse button at the start of the document but don't release
- Affix a strong crocodile clip to the mouse keeping the button held down
- Go for a cup of tea and return when the document has scrolled to the end.
- Release the crocodile clip


(joke...)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

OT Re: [Solved] Copy text format to entire document ?

Post by robleyd »

That could end badly :shock:
croc_mouse.jpg
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Copy text format to entire document ?

Post by JeJe »

People here strongly advocate using styles but the interface encourages the opposite. The buttons on the toolbar, the tab stops on the ruler, the paintbrush etc. all are for applying direct formatting.

A macro might be best here.

Its simple to see what the formatting is at the cursor and apply it to the whole text. This one does it for font height/weight/italic and name but can easily be extended by adding other attributes to the list:

Code: Select all

Sub ApplyFormattingToAll()
	dim vc,tc	
	vc = thiscomponent.currentcontroller.viewcursor
	with vc
	tc= .text.createtextcursorbyrange(.text)	
	tc.charweight = .charweight
	tc.charheight = .charheight
	tc.charfontname = .charfontname
	tc.CharPosture = .CharPosture
	end with

End Sub


Its also a simple macro to apply the current formatting to the current style instead:

Code: Select all

Sub ApplyFormattingToCurrentStyle()
	dim vc,sty
	vc = thiscomponent.currentcontroller.viewcursor
	with vc
	sname = .parastylename
	sty =thiscomponent.stylefamilies.getbyname("ParagraphStyles").getbyname(sname)
	sty.setpropertyvalues(array("CharWeight","CharHeight","CharPosture","CharFontName"), _
	array(.charweight,.charheight,.CharPosture,.charfontname)
	end with
End Sub
Coping with the problem of direct formatting remaining (which overrides style changes) is a bit more complicated.
The following sets the current style at the cursor to the direct formatting there and removes it.

Code: Select all


Sub ApplyFormattingToCurrentStyleResetAttributes()

	dim document as object,dispatcher as object,vc,tc,sname,sty
	
	vc = thiscomponent.currentcontroller.viewcursor
	tc= vc.text.createtextcursorbyrange(vc)

	sname = vc.parastylename
	
	sty =thiscomponent.stylefamilies.getbyname("ParagraphStyles").getbyname(sname)
	with vc
	sty.setpropertyvalues(array("CharWeight","CharHeight","CharPosture","CharFontName"), _
	array(.charweight,.charheight,.CharPosture,.charfontname)
	end with

	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
	
End Sub

Note: limited testing of above/no error checking.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

A note: I pasted some big amount of text from pdf to odt. Some text came out practically unreadable because of some strange font.
Recipe: CTRL+A, CTRL+M (aplay default format to all).

Any of above recipes or most of it, except this, produces some in behind formatting that results in notably slow document save.
One can go to cofee without aplaying crocodile clamps (-:
OPen office 4.1.5/ win 7
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Copy text format to entire document ?

Post by robleyd »

See if Edit | Paste Special | Unformatted text instead of a normal paste helps.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: [Solved] Copy text format to entire document ?

Post by BubikolRamios »

It does. Thanks.
OPen office 4.1.5/ win 7
Post Reply