Page 1 of 2

Book in Hebrew opening from left to right

Posted: Sun Apr 19, 2020 10:51 am
by david613
Hello!

I am trying to make a document for a book in Hebrew which has to be open from left to right (the opposite of books printed in English).

It might simple to edit the document, but I can't find a way to do it and neither found the topic on the forum.

Can someone help me? :)

Thank you!

Re: Book in Hebrew opening from left to right

Posted: Sun Apr 19, 2020 11:18 am
by robleyd
Have you configured AOO for enhanced language support? Go to Tools | Options | Language Settings | Language and select Show UI Elements for bi-directional writing; you can then select the default language for CTL (Complex Text Layout) You may need to set the text direction in the paragraph alignment; this is best done using styles.

Search HELP for right-to-left text for more information.

Re: Book in Hebrew opening from left to right

Posted: Sun Apr 19, 2020 11:21 am
by John_Ha
Search the forum with Hebrew for many posts.

Re: Book in Hebrew opening from left to right

Posted: Sun Apr 19, 2020 11:46 am
by david613
Robleyd: Those options were checked, but Open Office keeps counting the pages according to the books printed in English (page 1 on the left and page 2 on the right).

John_Ha: I will try again.

Thank you!

Re: Book in Hebrew opening from left to right

Posted: Sun Apr 19, 2020 12:12 pm
by John_Ha
hebrew finds 133 threads

Also see Chapter 2 > Setting up Writer > Choosing language settings in the writer Guide.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 10:41 am
by david613
I checked in the Writer Guide, but nothing is said about reversing the way pages are counted (from left to right in English to the opposite for Hebrew).

I also checked the forum with the subject "Hebrew", but no answers were given.

More: I deleted Open Office from my computer and downloaded Open Office in Hebrew (I thought that the default settings will be fine for the counting of the pages). To my surprise, even in the Hebrew version, the pages are counted according to English and not Hebrew!

In short: I'm still stuck with a problem which - I am sure - is very simple to solve (to my embarrassment).

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 10:43 am
by RoryOF
Will you please upload a short document of a few pages showing your problem.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 11:00 am
by david613
I uploaded a short file (only two pages).

The problem is very simple: the page number 1 is on the left and the page number 2 is on the right.

For a book printed in Hebrew, it should be the opposite.

How do I do that?

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 12:31 pm
by RoryOF
My memory of previous discussions is that it may not be possible, but I normally only remember things that are relevant to me, so I may be incorrect.

This thread, on another forum, may help
https://askubuntu.com/questions/282981/ ... ers#283000

Alternately, simply number the pages manually when the document is finished.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 2:16 pm
by John_Ha
Try asking in the Hebrew AOO forum at https://www.openoffice.org/he/

Is there a way to set a field which calls a table cell where the page numbers in the table are written in descending order? Or from a cell in a database? or a spreadsheet?

Can you calculate in a field? If so define a field to have the value (Page Count - Page Number + 1). In a 45 page book, page 45 will then show (45 - 45 + 1) = 1; page 44 will show (45 - 44 + 1) = 2 etc.

Can MS Word do it? If so, how?

The workaround of manually adding them is clunky but very effective - it may be quicker than searching for an automated solution.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 2:37 pm
by RoryOF
John, one cannot calculate in an OO field, unfortunately. This was discussed some years ago, something to do with numbering columns on two column pages.

There was published, again some years ago, perhaps not on this forum, a method of accessing an OO field value, and transferring it into a python variable (? fairly sure it was python), and I think later someone figured out how to do this using OO BASIC; if the value could be read into an external variable, probably the massaged value could be written back to that field.

I may later be able to find a note I printed out on this, which note is somewhere in a stack of 5000 A4 pages of notes for various things.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 3:08 pm
by RoryOF
Found references
how-to-access-document-variables-from-basic-macro

To change the page numbering, one might have to use a user defined field and having written to that, inset it in the header/footer. It is probable that the PageNumber field will be "owned" by OO and it won't allow a changed value be displayed from that.

Also
https://stackoverflow.com/questions/297 ... able-field

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 3:11 pm
by John_Ha
RoryOF wrote: It is probable that the PageNumber field will be "owned" by OO and it won't allow a changed value be displayed from that.
We don't need to change PageNumber field.

We define a variable Fred and set Fred = (PageCount - PageNumber + 1). We put Fred in the header or footer.

Insert > Object > Formula ..., has a variable PAGE equal to PageCount.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 3:44 pm
by RoryOF
The API reference is
https://www.openoffice.org/api/docs/com ... plier.html

The process was documented at
http://codesnippets.services.openoffice ... Field.snip
which is now inaccessible. It might be found on a wayback machine.

I have found the following code snippet

Code: Select all

Fields test and test2 are already defined in a document
Set their values this way:

Dim xNamedFieldMasters as Object
Dim xEnumeratedFields as Object

xNamedFieldMasters = ThisComponent.getTextFieldMasters()
xEnumeratedFields   = ThisComponent.getTextFields()

XNamedFieldMasters.getByName("com.sun.star.text.FieldMaster.User.test").Content = "SUPER"

xNamedFieldMasters.getByName("com.sun.star.text.FieldMaster.User.test2").Content = "SUPER2"

xEnumeratedFields.refresh()


Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 4:18 pm
by John_Ha
Rory

I am sure that it can be done - but I don't know enough about it to write the code. As the page number and the page count are both shown on screen AOO must have internal variables which hold them. We just need to know them.

As always Pitoynak is interesting and suggests the variable PageNumberOffset may be useful.
7.8. Inserting A New Page

In my quest to insert a new page into a document, I stumbled across the following link: http://api.openoffice.org/docs/common/r ... rties.html which discusses two properties.

The PageNumberOffset states: “If a page break property is set at a paragraph, this property contains the new value for the page number.”

The PageDescName property states: “If this property is set, it creates a page break before the paragraph it belongs to and assigns the value as the name of the new page style sheet to use.”

I reasoned that if I set the PageDescName, then I could create a new page and set the page number. What was not said is that the PageDescName is the name of the new page style to use after the page break. If you do not use an existing page style, then this will fail!

Listing 7.33: Insert a page break.

Code: Select all

Sub ExampleNewPage
Dim oSels As Object, oSel As Object, oText As Object
Dim lSelCount As Long, lWhichSelection As Long
Dim oLCurs As Object, oRCurs As Object
oText = ThisComponent.Text
oSels = ThisComponent.getCurrentSelection()
lSelCount = oSels.getCount()
For lWhichSelection = 0 To lSelCount - 1
oSel = oSels.getByIndex(lWhichSelection)
oLCurs = oText.CreateTextCursorByRange(oSel)
oLCurs.gotoStartOfParagraph(false)
oLCurs.gotoEndOfParagraph(true)
REM Preserve the existing page style!
oLCurs.PageDescName = oLCurs.PageStyleName
oLCurs.PageNumberOffset = 7
Next
End Sub

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 4:23 pm
by John_Ha
A search on page number in Macros and UNO API found lots as did a search on page count

I have asked Hebrew reverse pagination by page number and page count?.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 5:32 pm
by david613
All of you, thank you for help.

Since what I asked is more complicated than I thought, I might ask my question in the forum but more directly to the people who use Open Office for documents written in Hebrew (or Arabic): "How (if you did) did you solve that problem?"

Thank you again :bravo:

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 10:42 pm
by Villeroy
http://openoffice-uni.org/ used to have an Arabic example document. Now there is only the PDF version of it. Does that PDF look right? I informed the owner of the web site about the missing Arabic document.

Re: Book in Hebrew opening from left to right

Posted: Mon Apr 20, 2020 10:53 pm
by RoryOF
Villeroy wrote:http://openoffice-uni.org/ used to have an Arabic example document. Now there is only the PDF version of it. Does that PDF look right? I informed the owner of the web site about the missing Arabic document.
As far as I can see, it is paginated to open right to left - that is, as if it was written in a European language, although the text is Arabic..

Re: Book in Hebrew opening from left to right

Posted: Tue Apr 21, 2020 9:52 am
by david613
RoryOF wrote:As far as I can see, it is paginated to open right to left - that is, as if it was written in a European language, although the text is Arabic..
You're right: the pagination follows the rule for English, odd-numbered pages appear on the right side and even-numbered pages on the left.

For Hebrew and Arabic, it should be the opposite.

Re: Book in Hebrew opening from left to right

Posted: Tue Apr 21, 2020 5:41 pm
by John_Ha
See Hebrew reverse pagination by page number and page count? where JeJe has uploaded page labels.odt which has three macros as below which create a label in the header which is populated with a "Hebrew running backwards" page number. As a new page is added a new label is added to the new page and all pages are renumbered.

You need to install the macros into the actual document being typed and not into AOO's My Macros because they are only needed for documents requiring backward page numbering.

sub addlabel(p) contains the line

Code: Select all

oButtonModel.label ="page " & pages -p +1
where page is the text which appears in the label in the header and can be changed or omitted as required. pages -p +1 is the calculation to get the Hebrew page number.

Code: Select all

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

Sub setpagelabels
	pages= thiscomponent.currentcontroller.pagecount
	for i = 0 to thiscomponent.drawpage.getcount -1
		with thiscomponent.drawpage.getbyindex(i)
		if instr(1,.name,"PageLabel") then
			.control.label ="page " & pages - .anchorpageno +1
		end if
		end with
	next
End Sub


sub changepages
pages = thiscomponent.currentcontroller.pagecount

	for i = 0 to thiscomponent.drawpage.getcount -1
		with thiscomponent.drawpage.getbyindex(i)
		if .name = ("PageLabel" & pages) then
			gotlastpage = true
			exit for
		end if
		end with
	next
	IF gotlastpage =FALSE THEN ADDLABEL (PAGES)
	setpagelabels
end sub

sub addlabel(p)
	doc = thiscomponent
	ocontrolshape = doc.createInstance("com.sun.star.drawing.ControlShape")


	oButtonModel = CreateUnoService("com.sun.star.form.component.FixedText")
	oControlShape.Name = "PageLabel" & p
	pages= doc.currentcontroller.pagecount
	oButtonModel.label ="page " & pages -p +1
	oControlShape.setControl(oButtonModel)
	oControlShape.anchortype = com.sun.star.text.TextContentAnchorType.AT_PAGE
	oControlShape.AnchorPageNo = p

	with thiscomponent.drawpage.getbyindex(0)
	ocontrolshape.position = .position
	ocontrolshape.size = .size
	end with

	doc.drawpage.add (ocontrolshape)

End Sub
 Edit: I puzzled as to where the macro positioned the new label and it appears that it uses the same location as the label on conventional page 1.

So, if I move the label on conventional page 1 (by going into Design Mode = ON with the Form Controls Toolbar) to the centre of the page all new (but not existing) labels are created in the middle of the page. 
Tools > Macros > Organise macros > OO Basic
Tools > Macros > Organise macros > OO Basic
Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.

Re: Book in Hebrew opening from left to right

Posted: Tue Apr 21, 2020 5:47 pm
by Villeroy
Would be a good occasion to make a template which includes that macro and all the styles and layouts for Hebrew books.

Re: Book in Hebrew opening from left to right

Posted: Tue Apr 21, 2020 7:28 pm
by Villeroy
First page is a left one.
Page style "Left", with follow up style "Right" and with a footer having a page number field in the left corner. Page number with an offset of -1 so it starts with 1.
Page style "Right", with follow up style "Left" and with a footer having a page number field in the right corner. Page number with an offset of -1 so it follows with a 2.

The page preview looks weird and so does PDF output but when I print to a duplex printer (with blank pages suppressed), the paper sheets look alright (for me at least who has no Hebrew nor Arabic book at hand because library and mosque are closed and my imagination is limited if you know what I mean...).

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 9:29 am
by david613
I am amazed to your knowledge and will to solve my problem. If if was only for that, I already have to thank you - of all you - a lot.

Nevertheless, even if the problem regarding the page numbers seems to have been solved, one is still unsolved: while a text in Hebrew (or Arabic) is written, and when the written text is too long for a single page, a second page appears to have it written on it.

When we write in English, that second page appears on the right but when writing in Hebrew, it should appears on the left.

This problem makes it impossible to write a book in Hebrew on Open Office. :knock:

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 10:23 am
by John_Ha
david613 wrote:When we write in English, that second page appears on the right but when writing in Hebrew, it should appears on the left.

This problem makes it impossible to write a book in Hebrew on Open Office. :knock:
Have you searched or posted a question on the Hebrew AOO forum?

Also, JeJe has uploaded a new and improved file in the Macros and UNO API forum. I have added "_NEW" to the file name.
JeJe wrote:Here's a small update on the label code (attached document)

-You can insert a page anywhere and the labels will be set appropriately
-They will all be positioned in the same place as the first page one when the page numbers change
page labels_NEW.odt
(12.22 KiB) Downloaded 168 times

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 10:30 am
by RoryOF
Would choosing a custom page style (rather than Default page style) which was sequenced as left, right, left etc solve the problem?

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 10:55 am
by david613
I searched on Hebrew AOO forum, but there is not a forum in Hebrew. A link points to this forum.

The file from JeJe deals only with page numbers.

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 3:48 pm
by Villeroy
david613 wrote:I am amazed to your knowledge and will to solve my problem. If if was only for that, I already have to thank you - of all you - a lot.

Nevertheless, even if the problem regarding the page numbers seems to have been solved, one is still unsolved: while a text in Hebrew (or Arabic) is written, and when the written text is too long for a single page, a second page appears to have it written on it.
Diid you test my document? Every odd page number on the left hand side is followed by an even page on the right which itself is followed by another odd page on the left. It works automatically as you add new text to this document. And when you print the pages, you get a booklet where you turn the pages from right to left.

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 6:44 pm
by david613
Villeroy: I did tried your document, but like I wrote before:
david613 wrote:Even if the problem regarding the page numbers seems to have been solved, one is still unsolved: while a text in Hebrew (or Arabic) is written, and when the written text is too long for a single page, a second page appears to have it written on it.

When we write in English, that second page appears on the right but when writing in Hebrew, it should appears on the left.

This problem makes it impossible to write a book in Hebrew on Open Office. :knock:

Re: Book in Hebrew opening from left to right

Posted: Wed Apr 22, 2020 8:08 pm
by MrProgrammer
david613 wrote:I am trying to make a document for a book in Hebrew which has to be open from left to right (the opposite of books printed in English).
Given the difficulties you have found doing this in OpenOffice, with workarounds involving macros and label fields, perhaps it is time to investigate other tools which may be easier for you. Scribus, another open-source project, definitely supports complex text layouts including scripts like Hebrew that are written right to left. In 2013 I found it was easier to create our club newsletter with Scribus than with Writer. I last worked with Scribus in 2016 but never had any reason to explore if it would support pagination in the opposite order than we use in English. I do not have it installed on my current system for tests, but a web search quickly found that it supports numbering pages in Hebrew instead of using 1, 2, 3,… so I think it might be able to number pages right to left.

You could so some searching in the Scribus documentation or, if necessary, ask about that feature on the Scribus Wiki. If you determine that Scribus is better suited to your project, we would definitely like to know about your findings in this topic and also in Have you been using Open Office in Hebrew (or Arabic)? so that we can direct future questioners there.

You will need to learn how to use Scribus, of course, but that time may be better spent than time wasted fighting with OpenOffice.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.