[PATCH libreoffice-4-0] handle note export correctly, fdo#61165

Markus Mohrhard (via Code Review) gerrit at gerrit.libreoffice.org
Sat Mar 9 16:39:38 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2629

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/29/2629/1

handle note export correctly, fdo#61165

This code was horribly over-optimized and that actually with an error.
There is a nasty corner cases that has been left out in the code. Note
captions are actually normally not deleted from the document even if the
note is deleted. So we had now wrong note captions in the list that we
should not process but they were screwing up the export code that only
exports captions for existing notes.

When we only add the caption data for existing notes the code becomes so
much cleaner and the bug is immediately gone.

Change-Id: I51f1e9042f88f3f1b2d7aae75942629771d39012
(cherry picked from commit c7937e2a38501266ed658553c19db5b4a2237864)
---
M sc/source/filter/xml/XMLExportIterator.cxx
M sc/source/filter/xml/xmlexprt.cxx
2 files changed, 23 insertions(+), 32 deletions(-)



diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index cfbbe54..1662db7 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -861,33 +861,21 @@
     table::CellAddress  aAddress( nCurrentTable, MAXCOL + 1, MAXROW + 1 );
 
     UpdateAddress( aAddress );
-    if( (maNoteExportListItr != maNoteExportList.end()) && IsNoteBeforeNextCell(maNoteExportListItr->nCol, maNoteExportListItr->nRow, aAddress) )
-    {
-        //we have a note before the new cell
-        aAddress.Column = maNoteExportListItr->nCol;
-        aAddress.Row = maNoteExportListItr->nRow;
-        ++maNoteExportListItr;
-    }
-    else
-    {
-        if(maNoteExportListItr != maNoteExportList.end() && maNoteExportListItr->nCol == aAddress.Column && maNoteExportListItr->nRow == aAddress.Row)
-            ++maNoteExportListItr;
 
-        if( pShapes )
-            pShapes->UpdateAddress( aAddress );
-        if( pNoteShapes )
-            pNoteShapes->UpdateAddress( aAddress );
-        if( pEmptyDatabaseRanges )
-            pEmptyDatabaseRanges->UpdateAddress( aAddress );
-        if( pMergedRanges )
-            pMergedRanges->UpdateAddress( aAddress );
-        if( pAreaLinks )
-            pAreaLinks->UpdateAddress( aAddress );
-        if( pDetectiveObj )
-            pDetectiveObj->UpdateAddress( aAddress );
-        if( pDetectiveOp )
-            pDetectiveOp->UpdateAddress( aAddress );
-    }
+    if( pShapes )
+        pShapes->UpdateAddress( aAddress );
+    if( pNoteShapes )
+        pNoteShapes->UpdateAddress( aAddress );
+    if( pEmptyDatabaseRanges )
+        pEmptyDatabaseRanges->UpdateAddress( aAddress );
+    if( pMergedRanges )
+        pMergedRanges->UpdateAddress( aAddress );
+    if( pAreaLinks )
+        pAreaLinks->UpdateAddress( aAddress );
+    if( pDetectiveObj )
+        pDetectiveObj->UpdateAddress( aAddress );
+    if( pDetectiveOp )
+        pDetectiveOp->UpdateAddress( aAddress );
 
     bool bFoundCell((aAddress.Column <= MAXCOL) && (aAddress.Row <= MAXROW));
     if( bFoundCell )
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index b599e6e..3882e2f 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2531,13 +2531,16 @@
             // collect note caption objects from all layers (internal or hidden)
             if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, static_cast< SCTAB >( nCurrentTable ) ) )
             {
-                pSharedData->AddNoteObj( xShape, pCaptData->maStart );
+                if(pDoc->GetNotes(nCurrentTable)->findByAddress(pCaptData->maStart))
+                {
+                    pSharedData->AddNoteObj( xShape, pCaptData->maStart );
 
-                // #i60851# When the file is saved while editing a new note,
-                // the cell is still empty -> last column/row must be updated
-                OSL_ENSURE( pCaptData->maStart.Tab() == nCurrentTable, "invalid table in object data" );
-                pSharedData->SetLastColumn( nCurrentTable, pCaptData->maStart.Col() );
-                pSharedData->SetLastRow( nCurrentTable, pCaptData->maStart.Row() );
+                    // #i60851# When the file is saved while editing a new note,
+                    // the cell is still empty -> last column/row must be updated
+                    OSL_ENSURE( pCaptData->maStart.Tab() == nCurrentTable, "invalid table in object data" );
+                    pSharedData->SetLastColumn( nCurrentTable, pCaptData->maStart.Col() );
+                    pSharedData->SetLastRow( nCurrentTable, pCaptData->maStart.Row() );
+                }
             }
             // other objects from internal layer only (detective)
             else if( pObject->GetLayer() == SC_LAYER_INTERN )

-- 
To view, visit https://gerrit.libreoffice.org/2629
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51f1e9042f88f3f1b2d7aae75942629771d39012
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Markus Mohrhard <markus.mohrhard at googlemail.com>



More information about the LibreOffice mailing list