https://bugs.freedesktop.org/show_bug.cgi?id=39484

--- Comment #74 from Michael Meeks <[email protected]> ---
Another interesting data-point is that this is exclusive to cut/paste,
copy/paste doesn't suffer from the same issue; so back up to:

bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc,

The more I read this the more I marvel at what is going on - it looks rather
fragile. It appears that the code wants to preserve formulae on ~all sheets so
we can undo the effects of cut/paste.

Unfortunately, the CopyToDocument method has two modes of operation: one where
every tab is present (when it really copies the range you pass), and another
when tabs are not present (when it only copies to existing tabs).

First we try to CopyToDocument with a limited set of (the selected) tabs - to
just copy that data for undo; so we only copy the outline data for sheets that
are active.

         // all sheets - CopyToDocument skips those that don't exist in
pUndoDoc
         SCTAB nTabCount = pDoc->GetTableCount();
+        if ( bCutMode )
+        {
+            // fdo#39484 - needs to be done before the CopyToDocument to
preserve
+            //             outline & other data on sheets that we're not
viewing.
+            pUndoDoc->AddUndoTab( 0, nTabCount-1 );
+        }

fixes that; but of course it then starts to copy far too much.

Then unfortunately, we do another copy into the pUndoDoc here:

            pRefUndoDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
                                            IDF_FORMULA, false, pUndoDoc );

Which is presumably intended to preserve formulae, however this was again not
constructed for all tabs, so it now overwrites the outline data with NULL dummy
data.

So ... it seems that the basic problem here is a mis-understanding of how
CopyToDocument interacts with outlining. We pass the IDF_FORMULA flag, but the
code then operates on far more than just formulae.

Having fiddled a fair bit here; I think the best sol'n is to add an IDF_OUTLINE
- or IDF_NOOUTLINE bit to add in there, to allow the IDF_FORMULA mask to only
mutate formulae. Or worse - add some IDF_FORMULAONLY - which would suck ;-)
I'll try to come up with something pleasant.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to