Prevent the loss of header/footer when pasting

Discuss the word processor

Prevent the loss of header/footer when pasting

Postby BenDev » Fri Nov 22, 2019 3:44 pm

Hi there,

On LibreOffice, I've got a document X with specific header and footer.
Both header and footer are locked as much as LibreOffice let me to lock elements.

I'm facing an issue when it's about pasting some content from another document Y (also a .odt document).
If the block copied from the other document was overlapping at least 2 pages, when I paste the content of document Y on document X, on the part pasted, the header or footer of document X has gone.
The header that replaces the original one on document X display a name like "header(converted1).

Is it an already known issue (I've not found any thread on this for now)?
Is there a way to force the paste applying only for the bloc content body and exclude the header/footer?
Notice that I have not encountered this issue when pasting content from word document or html page.

Thanks in advance for any clue or advice on this ;)
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Fri Nov 22, 2019 4:13 pm

The header and footer text are structurally different from the document body content.

Copy/paste the document text in one operation.

Copy/paste the header/footer content in a separate operation, pasting it into a previously created empty header/footer.

Be sure to understand Page Formats - see Chapter 4 - Formatting Pages in the Writer Guide.

You will find much useful information in the Writer FAQ, the Writer Tutorials, the up to date AOO Writer for Students and the Writer User Guide. May I suggest you bookmark the pages.

Press F1 to access the Help screen and search for your problem

The chapter headings in the manual are:

1 - Introducing Writer
2 - Setting up Writer
3 - Working with Text
4 - Formatting Pages
5 - Printing, Exporting, Faxing and E-Mailing
6 - Introduction to Styles
7 - Working with Styles
8 - Working with Graphics
9 - Working with Tables
10 - Working with Templates
11 - Using Mail Merge
12 - Tables of Contents, Indexes and Bibliographies
13 - Working with Master Documents
14 - Working with Fields
15 - Using Forms in Writer
16 - Customizing Writer – Keyboard shortcuts.

When a pop-up window opens, click the Help button for extensive help on that function - it is often more comprehensive than the manual.

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.
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby BenDev » Fri Nov 22, 2019 4:37 pm

@John_Ha:

Thanks for those informations, but I think you have misunderstood my question.

So, to be more precise, I'm not new in the use of LibreOffice/OpenOffice.
I'm working as a developper and actually working on a document that is managed by code to put in the header some informations given by the user.

My question was about an operation done by lot of users who are going to use the document for a classical editing, except for the fact that they may copy/paste content from other files (so I can't manage the way they will do the copy/paste operation).

So I wished to find a means to prevent the specific header on the document to be lost/replace due to the paste operation of a user....
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Fri Nov 22, 2019 5:08 pm

Sorry - I misread it.

See below. When I select everything in Fred (cursor at start > SHIFT + click with cursor at end) and copy it; and paste it into Bill, the Bill header is not affected and the headers on the newly created pages are the same as they were in the original Bill. Is that what you want?

Or do you want to allow a user to edit the body but prevent a user from modifying the header? I don't know how to do that other than by extreme measures like putting non-field, and hence constant, header text in an image inserted on the page and called through the Page Format (or anchored in the header?) so that newly created pages include it.
Attachments
fred.odt
(14.82 KiB) Downloaded 8 times
bill.odt
(20.49 KiB) Downloaded 10 times
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby RoryOF » Fri Nov 22, 2019 5:17 pm

As the header/footer information is part of the Page Style of the source document, it is not transferred to the destination document in pasting; the header/footer information of that destination document takes precedence.

Perhaps use a screenshot?
Apache OpenOffice 4.1.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 30616
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Fri Nov 22, 2019 5:27 pm

RoryOF wrote:Perhaps use a screenshot?

Better would be two files, one with the text to be copied, the other of where it needs to go.

If either file has confidential material in it, you can obscure the contents without affecting the structure too much (lines will spill differently because different characters have different widths) by changing every lower case alphabetic character to an " x ". Select all the text (Ctrl+A) and:

Edit > Find and Replace
Find box [a-z]
Replace box x
Options: Match case: YES, Regular expressions: YES
click Replace all

Repeat the above using [A-Z] and X to scramble the upper case letters, and [0-9] and 0 to scramble numeric data.

The limit here is 128kB, or use a fileshare site like mediafire for larger files.
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Fri Nov 22, 2019 5:30 pm

John_Ha wrote:Or do you want to allow a user to edit the body but prevent a user from modifying the header? I don't know how to do that other than by extreme measures like ...

Would removing Format > Page ..., from the menu do what you want?
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby RoryOF » Fri Nov 22, 2019 5:31 pm

I was thinking of screenshot in destination document, not Forum.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 30616
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Prevent the lost of header/footer when pasting

Postby BenDev » Fri Nov 22, 2019 5:57 pm

Maybe try this joined document to select its content and copy it into bill document.

The strange thing is that if you open bill document and just paste where the cursor is, it will be good, only text body will be pasted.
But if go to a new line or put the cursor elsewhere and paste, then you will see that header and footer of my document will be replacing bill's ones.
Attachments
Ben For Copy.odt
(89.32 KiB) Downloaded 11 times
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm

Re: Prevent the lost of header/footer when pasting

Postby Bill » Fri Nov 22, 2019 6:37 pm

BenDev wrote:I'm working as a developper and actually working on a document that is managed by code to put in the header some informations given by the user.

Just to clarify, is the problem only being seen when pasting in a document managed by the code?
AOO 4.1.7 and LO 6.3.2.2 on Manjaro KDE
Bill
Volunteer
 
Posts: 7628
Joined: Sat Nov 24, 2007 6:48 am

Re: Prevent the lost of header/footer when pasting

Postby BenDev » Fri Nov 22, 2019 6:59 pm

@bill:

No, as you can read it on my last post:
viewtopic.php?f=7&t=100114&p=481746#p481746
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Fri Nov 22, 2019 8:15 pm

I think we have an XY problem here. You want to do X but you cannot. You come up with a solution Y which you find does not quite work and is probably not a good idea. You then ask for help to fix Y.

It is far better to say "I want to do X ..." and ask for help on X. That way we can consider all your options without getting drawn down the possible dead end of Y - see The XY problem.

So, please tell us in very clear terms exactly what you want to achieve. Do not tell us how to do it. We may then be able to suggest a different solution instead of trying to fix something which does not work.

As an aside how did you insert those two header images? I cannot see any anchors and they seem to be write protected.

 Edit: The "header images" are not headers - they are write protected sections.

The section is created in the header space and the image is anchored in the section. The section is then write protected. Page Formats are alternately Only_Left and Only_Right. Because the section is included in the header it is replicated when a new page is added so some oddities should be expected.

Including a section within a header is, to say the least, most surprising and not conventional usage.

For further advice to be given it is critical that we understand the design objectives - what are you trying to achieve? I think it is

1. I want a "header" with text_L on each left page and a header with text_R on each right page.
2. I do not want a user to be able to make any changes to my "header".
3. A user can copy from a normal document or from a document with my custom "headers". A user can paste into a normal document or into a document with my custom "headers".
4. Case 1: When a user copies multiple pages from a normal document, where that document may or may not have headers and/or footers, and pastes into a document with my custom "headers", I want only the body content to be pasted and I want my custom "headers" to continue to be used on the new pages added for the copied content.
5. Case 2: When a user copies multiple pages from a document with my custom "headers" and pastes into a document with my custom "headers", I want ????
6. Case 3: When a user copies multiple pages from a normal document, where that document may or may not have headers and/or footers, and pastes into a normal document, I want ???
7. Case 4: When a user copies multiple pages from a document with my custom "headers" and pastes into a normal document, I want ????
8. I want ... 


 Edit: It appears that the developers of AOO did consider that sections might be inserted in headers.

Page 124 of the Writer Guide says
Note You cannot hide a section if it is the only content on the page or if the section is in a header, footer, footnote, endnote, frame, or table cell.
Note that there are immediate restrictions when a section is placed in a header - other "funnies" may also be found. 
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby Bill » Fri Nov 22, 2019 10:24 pm

I think I've reproduced the problem using LO 6.3.3.2. I opened "Ben for Copy.odt" and a new document "Untitled 1". In Ben for Copy, I selected all text and copied it. In Untitled 1, I pasted the text and saw that the page styles from Ben for Copy had been pasted and applied in Untitled 1. This is what causes the changing of the headers and footers. In addition, trying to do anything else with Untitled 1 caused LO to lock up or crash. I have no solution and don't know if the behavior can be changed. I tried the same process using a source document I created and saw the same behavior except that LO did not lock up or crash when using my document.

At the moment, I don't have AOO installed so I don't know if this behavior is the same in AOO.
AOO 4.1.7 and LO 6.3.2.2 on Manjaro KDE
Bill
Volunteer
 
Posts: 7628
Joined: Sat Nov 24, 2007 6:48 am

Re: Prevent the lost of header/footer when pasting

Postby John_Ha » Sat Nov 23, 2019 12:26 am

Bill

I followed your instructions with AOO 4.1.6

1 Open Ben for Copy.odt
2 File > New > Text document ... to get Untitled 1
3 Select all text in Ben for Copy and Edit > Copy
4 Paste into Untitled 1 with Edit > Paste

Whereas Untitled 1 started out with Page Style Default it now had Page Styles Only Left and Only Right and the "header images" appeared appropriately on Left and Right pages.

5 I then typed some text, added a table and inserted an image into Untitled 1 and saved the file. I got no crash or hang.

6 I then repeated the test and happened to go Undo immediately after the paste. AOO promptly crashed. The recovered file Untitled 1 now had only the text and no images or headers and the Page Style was Default for all pages.

7 I repeated the test a third time. At Step 4 I used Edit > Paste Special > Unformatted text. Untitled 1 then contained only the text without the images. Each page had the Page Style as Default.

Whereas I believe Test 7 gives the correct result I don't know whether Test (1-4) is giving the correct result. Note I never used Select All so I don't think the images should have been copied. But if the copy is intended to include the Page Style, then I think Test (1-4) is working as designed.

I also experimented with the images and found they do not need to be placed in a section in order to write protect them. Anchor the images in the header itself > right-click the Image > Options ..., allows you to protect it. You can similarly protect a Frame containing an image.
LO 6.3.5.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7365
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Prevent the lost of header/footer when pasting

Postby BenDev » Mon Nov 25, 2019 12:20 pm

@Bill thanks a lot for having a try to understand the context I am dealing with.

Just to be more precise on the context:
The header on my document need to be locked because the user is not allowed to edit it.
But based on what I now for now, I don't think it's possible to really lock header or footer on a Libreoffice document, so I went for the most close reachable workaround.
So I use section in the header because the header will contain many different elements such as image but also textfield, and protecting the section is the only way I've found to avoid user to modifiy those elements.

But even with the section locked, it won't prevent the header from being replaced by the paste operation...
Hence my original question on the thread...
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm

Re: Prevent the lost of header/footer when pasting

Postby keme » Mon Nov 25, 2019 7:02 pm

The existence of "Convert1" suggests to me that the source of the copied content was at some point part of a MS Word document, even though you stated that you don't copy from Word. If this is the cause, it may help if you use Edit - Paste special to paste unformatted text, then format as needed after the paste.

Writer distinguishes between page, paragraph and text style classes while Word uses one single style class for everything, and also a couple of other formatting choices do not transfer nicely between the two applications. The "ConvertX" styles are workarounds required to sort out the limitations in compatibility between them, and they stick to content until "forcibly removed" e.g. by paste unformatted.
User avatar
keme
Volunteer
 
Posts: 3305
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Prevent the lost of header/footer when pasting

Postby BenDev » Tue Nov 26, 2019 11:07 am

@keme: thanks for your answer.

Right, it seems that "Convert 1" is an attribute specific to headers coming from another type of document like word.
But the problem of header replacement also occurs when pasting from odt document to another.

About the paste in unformatted text format, as I said, there will be a lot of users working with this document, so I can't manage the way the paste operation will be done manually.
The only thing I'm thinking of as a workaround is to add on my custom toolbar a button to let the user paste in unformatted text format. But then it will be about sending the guidelines to the final users, with no guarantees they will follow it...

My last hope is that I can find a way to catch events related to the document and then be able to transform a classic CTRL-V operation to a unformatted text paste...
I've already done such a catch on MS Excel, but for now I didn't find a way on LibreOffice :roll:
LibreOffice 6.1.5.2 (x64) and LibreOffice 6.2.4.2 (x64)
Windows 8.1 Pro
User avatar
BenDev
 
Posts: 46
Joined: Sat May 18, 2019 3:32 pm


Return to Writer

Who is online

Users browsing this forum: No registered users and 21 guests