[Solved] Ctrl+M removes Character Style in AOO but not in LO

Discuss the word processor
Post Reply
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

[Solved] Ctrl+M removes Character Style in AOO but not in LO

Post by LastUnicorn »

Can someone please explain this to me? If I write a sentence in OpenOffice Writer and apply a character style to some of the words then do CTRL+A then apply CTRL+M then the character styled words go back to be being 'plain text' Text Body style.

If I do the same procedure in LibreOffice then the character styled words do not get reverted to Text Body style (which is what I would really expect to happen in OpenOffice too).

So, what is going on with this and OpenOffice Writer and the difference when compared to LibreOffice?
Last edited by Hagar Delest on Sun Dec 05, 2021 8:19 pm, edited 1 time in total.
Reason: Tagged [Solved].
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
RoryOF
Moderator
Posts: 34588
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Character Style Removed on CTRL+M

Post by RoryOF »

Different choices by the software designers. You pays your money and makes your choice.

OpenOffice and LibreOffice are not "work-alike" clones; their commonality is the OpenDocument format, and that is starting to show differences between LibreOffice's use of ODF1.3, and OpenOffice's use of ODF 1.2.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Character Style Removed on CTRL+M

Post by LastUnicorn »

Okay, thank you Rory.

One question arises for me. Is there an equivalent keyboard shortcut routine for OpenOffice that allows removal of all direct formatting from a document but leaves character style formats untouched?
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
Hagar Delest
Moderator
Posts: 32628
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Character Style Removed on CTRL+M

Post by Hagar Delest »

That's the kind of inconsistencies that drove me to LibreOffice too.
It is clearly bug in AOO IMHO. Considering a character style as direct formatting (removed with Ctrl+M) defeats the point of [character] styles...

Never heard of such a shortcut that would keep the character style format. A macro may be able to do that. But why the hassle if LO does it right?
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Character Style Removed on CTRL+M

Post by LastUnicorn »

Hagar Delest wrote:That's the kind of inconsistencies that drove me to LibreOffice too... [Why] the hassle if LO does it right?
Yes, this is what I am considering myself. I haven't used LibreOffice much but am working my way through the LibreOffice Writer manual and learning what I need to know for my own limited use of Writer -- no more need to write student essays. I have, I think, a reasonable handle on styles and templates now, enough to cover my needs until I hit a bump in the road. That said I have to note that I find the Writer manual somewhat schizophrenic in places: users are extorted to use styles, fine, but in places in the manual there are examples given (by implication, direction given) to, in effect, use direct formatting.

My next challenge is Page Styles. If I can nail that down then I will have all I need for my use.

In any case I think LibreOffice is going to win the contest for me now. More up to date, ODF 1.3, and I do find the visual preview of styles in the Styles Deck very helpful, and also I have occasional use for opening .docx files and LibreOffice manages that better than OpenOffice.

Thanks for the responses.
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
RoryOF
Moderator
Posts: 34588
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Character Style Removed on CTRL+M

Post by RoryOF »

My preference is that Ctrl M should take one back to plain text.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Character Style Removed on CTRL+M

Post by Zizi64 »

My preference is that Ctrl M should take one back to plain text.
There is not "plain text" in the AOO/LO. A text has at least a Default (Paragraph and Character) style.

Maybe it sould better to have two separated options in the office suites:
- one for reset all of the direct formatting properties as in the LibreOffice.
- and an another one to reset the styles (charecter and/or paragraph styles) to the Default one: similarly to the function of the Apache OpenOffice.
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.
User avatar
RoryOF
Moderator
Posts: 34588
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Character Style Removed on CTRL+M

Post by RoryOF »

Default was what I meant. It has merely the Default formatting.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Ctrl+M removes Character Style in OO but not in LO

Post by JeJe »

The macro would be something like this (there may be a slicker way)
Edit: yes there is, slightly improved

Code: Select all

sub RemoveFormattingLeaveCharstyleUntouched()
dim vc,tc,charattributes
vc = thiscomponent.currentcontroller.viewcursor
charattributes="CharAutoEscapement CharAutoKerning CharBackColor CharBackTransparent CharCaseMap CharColor CharCombineIsOn CharCombinePrefix CharCombineSuffix CharContoured CharCrossedOut CharEmphasis CharEscapement CharEscapementHeight CharFlash CharFontCharSet CharFontCharSetAsian CharFontCharSetComplex CharFontFamily CharFontFamilyAsian CharFontFamilyComplex CharFontName CharFontNameAsian CharFontNameComplex CharFontPitch CharFontPitchAsian CharFontPitchComplex CharFontStyleName CharFontStyleNameAsian CharFontStyleNameComplex CharHeight CharHeightAsian CharHeightComplex CharHidden CharKerning CharLocale CharLocaleAsian CharLocaleComplex CharNoHyphenation CharOverline CharOverlineColor CharOverlineHasColor CharPosture CharPostureAsian CharPostureComplex CharRelief CharRotation CharRotationIsFitToLine CharScaleWidth CharShadowed CharStrikeout CharUnderline CharUnderlineColor CharUnderlineHasColor CharWeight CharWeightAsian CharWeightComplex CharWordMode"
'CharStyleName CharStyleNames CharAutoStyleName 
tc= vc.text.createtextcursorbyrange(vc)
tc.setPropertiesToDefault(split(charattributes," "))
end sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Thanks very much for the macro JeJe. Never having used a macro before in OpenOffice it took me a couple of hours to get the thing into it but it seems to work fine. So now I'm thinking that I'll just incorporate it into my own default template and it will be available for all new documents.

Thanks again.
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Ctrl+M removes Character Style in OO but not in LO

Post by JeJe »

You can paste the macro to MyMacros where it will be available to all documents and then set a shortcut or menu or toolbar item to it.

Go to:

Tools menu/macros/organize macros/Openoffice basic

From the dialog that pops up select MyMacros/Standard from the left hand box

If there's a Module1 below Standard click that and then "Edit"

If not click "New" and create it first

Paste the macro in that module and then use tools menu customize to set a menu item or whatever to it.

Similar instructions on this page

viewtopic.php?t=5519
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Thanks again, JeJe. Your instructions, and Hagar's, are much easier to step through than the Manual way I was using yesterday. I followed your instructions, works with all documents now and have the macro assigned to a keyboard shortcut. :super:

Above said, I'll work my way through the Manual stuff again sometime and see if I understand it better second-time around.
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Character Style Removed on CTRL+M

Post by LastUnicorn »

After toying around with the macro supplied by JeJe it kind of occurs to me that there might be some occasion when the user does want to remove in LibreOffice all direct formatting from text and would also like to remove all character styles. As Zizi says in his comment:
Zizi64 wrote:Maybe it sould better to have two separated options in the office suites:
- one for reset all of the direct formatting properties as in the LibreOffice.
- and an another one to reset the styles (charecter and/or paragraph styles) to the Default one: similarly to the function of the Apache OpenOffice.
So can someone give macro code to manage this in LibreOffice -- to remove all character styles from a selection, as Zizi suggests. (I did read JeJe's code for OpenOffice but I don't understand it and hence can't alter the code for use in LibreOffice to achieve the above -- above my pay-grade.)
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Zizi64 »

So can someone give macro code to manage this in LibreOffice -- toremove all character styles from a selection, as Zizi suggests.
Select all of the text in a paragraph, and just apply the applied Paragraph Style again. This method will reset all of the applied different Character Styles from a selected paragraph.
Yes, I know it: you can not do this with a selection what has various Paragraph Styles.
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.
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Zizi64 »

An another tip:


Right click on the selection, what has various Paragraph Styles and some Character Styles inside the text of the paragraphs. Then click on the the item in the appeared context menu:

Styles - Default character

Tested in my LO 6.1.6

I suppose it: you can assign this feature to a free hotkey.
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.
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Zizi64 wrote:Select all of the text in a paragraph, and just apply the applied Paragraph Style again. This method will reset all of the applied different Character Styles from a selected paragraph.
Zizi I tried this several times and it doesn't work -- or I'm doing something in my attempts that makes it not work. Can you post step-by-step instructions on how to get this to work?

What does work is making a selection of a paragraph (or more) and applying "No Character Style" to the paragraph.
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
Hagar Delest
Moderator
Posts: 32628
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Hagar Delest »

Zizi64 wrote:Then click on the the item in the appeared context menu:

Styles - Default character
No such option in my context menu with LO 7.2.2.2.

An option to reset all would be good, not found any so far.
But a macro that set the para style to default then the char style to default and then clear formatting would do the job.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Zizi64 »

No such option in my context menu with LO 7.2.2.2.
The menu item is named as
Character - Default character
in my LO 7.2.1 portable version.
Last edited by Zizi64 on Sun Dec 05, 2021 1:29 pm, edited 1 time in total.
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.
User avatar
Hagar Delest
Moderator
Posts: 32628
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Hagar Delest »

OK, I see it indeed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Zizi64 »

Zizi I tried this several times and it doesn't work -- or I'm doing something in my attempts that makes it not work. Can you post step-by-step instructions on how to get this to work?
Please upload an ODF type, prepared file here (with your formatting examples). Or: are you using other file type documents?
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.
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Try this Zizi.
Test.odt
(9.52 KiB) Downloaded 169 times
Was created in LibreOffice and only saved as .odt (I'm not trying to do anything with a .doc imported file).
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Zizi64 »

Test_Zizi64.odt
(16.57 KiB) Downloaded 161 times
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.
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Well, yes Zizi thanks for testing. You managed to do it by the route that I found worked. However, when you said:
Zizi64 wrote:Select all of the text in a paragraph, and just apply the applied Paragraph Style again. This method will reset all of the applied different Character Styles from a selected paragraph.
That doesn't work and wasn't what you actually did on the Test.odt.

Thanks anyway. At least I have some method that works.
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
User avatar
Hagar Delest
Moderator
Posts: 32628
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Ctrl+M removes Character Style in OO but not in LO

Post by Hagar Delest »

Here is my code proposal (select the text and then run it), assign it to a shortcut (Ctrl+M for example):

Code: Select all

Sub Reset_formatting
Dim oVC as object

oVC = ThisComponent.getCurrentController().getViewCursor()
oVC.ParaStyleName = "Standard"
oVC.CharStyleName = "Standard"
subDispatch("ResetAttributes")
end sub

sub subDispatch(sCommand as string)
dim oFrame as object, oDispatcher as object
oFrame = ThisComponent.CurrentController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDispatcher.executeDispatch(oFrame, ".uno:" & sCommand, "", 0, array())
end sub
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
LastUnicorn
Posts: 542
Joined: Sat Mar 29, 2008 2:41 am
Location: Scotland

Re: Ctrl+M removes Character Style in OO but not in LO

Post by LastUnicorn »

Thanks very much Hagar. Assigned to CTRL+Shift+M works a treat, best of both worlds now. :)
Windows 10 Pro. x64
LibreOffice (Still) 7.6.5.2 (x64) Fully installed to system
LibreOffice (Still) Portable 7.6.5.2 (x86) [PortableApps]
Apache OpenOffice Portable 4.1.15 [PortableApps]
Post Reply