Pasting in Writer or how to create a SwDoc deep copy?

Jan-Marek Glogowski glogow at fbihome.de
Thu Jun 26 11:37:02 PDT 2014


Hi Miklos,

Am 26.06.2014 10:54, schrieb Miklos Vajna:
> On Wed, Jun 25, 2014 at 01:09:01PM +0200, Jan-Marek Glogowski <glogow at fbihome.de> wrote:
>> My best idea is to use
>>
>> SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), *1* );
> 
> Are you sure such an explicit offset is required here? I'm thinking
> about special situations like when the document starts with a table, if
> you want to paste that into a new document, you probably want to have
> the selection start at the first content node of the document, so no
> static offset will work here.
> 
> I'm thinking about something like:
> 
> SwNodeIndex aNodeIndex rSource.GetNodes().GetEndOfAutotext();
> SwCntntNode* pStart = rSource.GetNodes().GoNext(&aNodeIndex);
> 
> Any kind of explicit offset sounds a bit scary to me.

Well the current code uses the explicit offset 2 in SwDoc::Paste and
SwFEShell::Paste, which ignores the first content node, which results in
losing the paragraph anchored Flys of the first paragraph of the document.

For a whole document paste, I want the whole document, including the
first node with the pagedesc. This is probably special case for Mail
Merge. I added a boolean to SwFEShell::Paste, so this really pastes the
whole document.

The only user of SwDoc::Paste is SwDoc::CreateCopy. I've merged the
SwDoc::Paste code into SwDoc::CreateCopy. SwDoc::Paste used the fixed
offset of 2 for the source document content offset - same for the target
insert.

>> SwPaM aPara( <document content start );
>> this->DelFullPara(aPara);
> 
> But you're not really trying to delete the paragraph content, just join
> the two, right? SwDoc::DeleteAndJoin() might be useful to do that.

No - I really tried to get rid of the whole page.

I pushed my current "works for me" changeset to
private/jmux/mailmerge-fixes. Would be happy, if I can get a review.

Thanks

Jan-Marek


More information about the LibreOffice mailing list