Punctuation and symbols like # and + have no intrinsic directionality; they use the one in effect in the surrounding context.
In your case, default language is Persian. Consequently, # and + behave RTL.
C++ or C# are not seen as words, but as a "latin" word C (thus LTR) with punctuation. You have in fact 2 sequences and the result is as expected. To get the usual C++ formatting, you must tell LO Writer that the whole sequence is LTR.
You do that with a character style. Create one you'll call Technical. In the Font
tab, force Language to None from the drop-down menu (or English in case it doesn't work as expected -- None is better because it also disables spell-checking, which is preferable for acronyms).
After that, select all your LTR sequences and give them character style Technical. The important point is to select together C and the symbols so that it is seen as a single sequence.
To show the community your question has been answered, click the ✓ next to the correct answer, and "upvote" by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!
EDIT 2018-11-5 (after discussion with @Ali Baghernejad)
The cause seems to be a symbol (# or +) at the boundary between RTL and LTR text. This symbol, which can be used in any language, adopts directionality of its context. Here we have mixed context and tie is resolved in favour of "main" context, i.e. Persian because it is the document language.
Forcing language through a character style proves inoperative because CTL styles seems to decide on which part to use (Western or CTL) based on the current character. Here, + or # have no intrinsic directionality and we revert to the context (see previous argument).
The only way to force directionality is to add LTR character around the problematic sequence. C++ is typed C++a: now we have an LTR run but an extra a. This extra a is formatted Hidden so that it does not display.
This is an ugly workaround. There should be a way to tell LO Writer we want an LTR sequence (or RTL when writing Western), no matter the internal Writer rules, i.e. unconditionally force directionality.
I filed a bug as tdf#121182 (closed because it is intended behaviour; work around with explicit directionality marks)
EDIT 2018-11-6 after information from the bug site
Completely forgotten about U+202A to U+202C (bidirectionality control characters), sorry for the fuss.
I had a look to the sample file with bidirectionality controls addes attached to the bug report. It matches the required, but from a user perspective, I could not find a way to edit these controls. Backspace
or Delete
do not seem to act upon them. Instead, the erase the nearest graphic character. Consequently, you can't manage easily the marks, other than selecting a wider sequence, erasing it and retyping the missing part.
This is not user-friendly. Have ... (more)
Don't post as wiki for one-person questions. It will prevent you from receiving karma points to access higher features on this site.
Don't
Ctrl
+Shift
+A
/Ctrl
+Shift
+D
help?@Mike Kaganski No, it doesn't work. ctrl+shift+A make the C# and C++ words correct but the Persian words in the sentence give incorrect sequential ordering.
Then please try
Left-to-right mark
/Right-to-left mark
underInsert
-Formatting Mark
(sorry for being unable to test myself - I can't use any RTL). They are a different thing, and if they help, they may be assigned dedicated key bindings.@Mike Kaganski I attach a doc file here and embed all required fonts into that. link to doc
You can try it.