+ bool const target_empty = pars[pit].empty();
+ // Use the paste content's layout, if...
+ bool const paste_layout =
+ // if target paragraph is empty
+ (target_empty
+ // ... and its layout is default
+ && (pars[pit].layout() == defaultLayout
+ // ... or plain
+ || pars[pit].layout() == plainLayout
+ // ... or the paste content spans several paragraphs
+ || insertion.size() > 1))
+ // or if pasting is done at the beginning of paragraph
+ || (pos == 0
+ // and the paste content spans several paragraphs
+ && insertion.size() > 1);
+ if (!paste_layout)
+ // Give the first paragraph to insert the same layout as the
+ // target paragraph.