Bug 146157 - Please make the inverted question marks after trailing equality signs optional
Summary: Please make the inverted question marks after trailing equality signs optional
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
7.2.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Formula-Editor
  Show dependency treegraph
 
Reported: 2021-12-10 10:20 UTC by Michael Kogan
Modified: 2025-02-23 09:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kogan 2021-12-10 10:20:28 UTC
Description:
When opening a .docx file which most probably has been created with MS Word and contains mathematical expressions with trailing equality signs, there is an inverted question mark after each such equality sign which isn't there when opening the same file with MS Word. Example:

2+3 = ___

Writer shows:

2+3 =¿ ___

I understand that this is supposed to highlight equations which are incomplete and miss the r.h.s. but in some contexts the missing part is intended. 

I already found the solution to write

2+3 =""___

which suppresses the question mark, but this way I always need to edit each expression in a .docx file I open which is quite cumbersome. It would be great if these question marks could be made optional.

Steps to Reproduce:
1. Open a .docx document with formulas containing expressions with trailing equality signs or write such an expression, for example "2+3=" into the formula editor of an empty document.
2. Observe that there is an inverted question mark after each trailing equality sign.
3. Profit!

Actual Results:
An inverted question mark is shown after every trailing equality sign.

Expected Results:
The question mark shown after a trailing equality sign should be optional.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Version: 7.2.2.2 / LibreOffice Community
Build ID: 20(Build:2)
CPU threads: 8; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.utf8); UI: de-DE
7.2.2-2
Calc: threaded
Comment 1 Rafael Lima 2022-05-06 00:03:40 UTC
The "=" sign is a binary operator, meaning that it requires values in both sides. 

Instead of changing the behavior in Math, making the "=" unary, we could change the DOCX import so that when nothing is found after the equal sign, then {} is added after the equals sign.

In your example, instead of using "" you could use {}.
Comment 2 Rafael Lima 2022-05-06 00:04:17 UTC
I am setting this to NEW since this behavior is acceptable in MS Office and is imported as an error in LibreOffice.
Comment 3 Michael Kogan 2022-05-06 00:59:37 UTC
This would solve it for me!
Comment 4 QA Administrators 2024-05-06 03:15:05 UTC Comment hidden (obsolete)
Comment 5 Michael Kogan 2024-05-06 05:03:07 UTC
The bug is still present at least in 24.2.0, most probably in later versions as well.
Comment 6 Michael Kogan 2025-02-22 08:51:50 UTC
Hi guys, did anyone have time to have a look into this already?

I'm a math teacher and I am unable to edit material from my colleagues with LO Writer, because this would require removing the question marks from lots of formulas. This small issue really makes LO Writer unusable for me..

Thanks for having a look into it!

P.S.: Maybe there is a possibility to add the {} to all mathematical expressions in a document in one go, somehow? Something like Search&Replace for math expressions?
Comment 7 Michael Kogan 2025-02-23 09:06:18 UTC
I added the following Macro and ran it:

_________________________________________
Sub Writer_Find_and_Replace_Formula( strFind As String, strReplace As String )
REM	This finds all occurrences of <strFind> within all Formula objects embedded within the current Writer document,
REM and replaces the found occurrences by <strReplace>.
REM NB. This action can not be Undone via the menu "Edit : Undo".
	Dim oDoc As Object
	oDoc = ThisComponent
	
	Dim oEmbeddedObjects As Object, oObj As Object
	oEmbeddedObjects = oDoc.getEmbeddedObjects()
	
	Dim i As Integer
	For i = 0 To oEmbeddedObjects.getCount() - 1
		oObj = oEmbeddedObjects.getByIndex( i ).getEmbeddedObject()
		
		If oObj.ImplementationName = "com.sun.star.comp.Math.FormulaDocument" Then	REM Found a Formula.
			oObj.Formula = Join( Split( oObj.Formula, strFind ), strReplace )		REM Perform Find & Replace.
		End If
		
	Next i
End Sub
_______________________________________

Reference: https://ask.libreoffice.org/t/find-and-replace-for-formulas-in-libreoffice-writer/27113/5
Comment 8 Michael Kogan 2025-02-23 09:09:03 UTC
Sorry, I pasted the wrong piece of code, here is the specific one for this case:


_________________________________________
REM  *****  BASIC  *****

Sub Writer_Find_and_Replace_Formula()
REM	This finds all occurrences of "=" within all Formula objects embedded within the current Writer document,
REM and adds curly braces "{}" to prevent the display of question marks.
REM NB. This action can not be Undone via the menu "Edit : Undo".
	Dim oDoc As Object
	oDoc = ThisComponent
	
	Dim oEmbeddedObjects As Object, oObj As Object
	oEmbeddedObjects = oDoc.getEmbeddedObjects()
	
	Dim i As Integer
	For i = 0 To oEmbeddedObjects.getCount() - 1
		oObj = oEmbeddedObjects.getByIndex( i ).getEmbeddedObject()
		
		If oObj.ImplementationName = "com.sun.star.comp.Math.FormulaDocument" Then	REM Found a Formula.
			oObj.Formula = Join( Split( oObj.Formula, "=" ), "={}" )		REM Perform Find & Replace.
		End If
		
	Next i
End Sub
_________________________________________