i had a similar problem and in my case, the GLYPH_TYPE of numbered lists got lost, too.
But i detected that the images will be fine copied if the CellChildren are copied one by one.
So i solved my problem by copying the new table at whole and then replacing the contents of each dstTable cell one by one from the original table.
This works fine now even with nested tables, since the function calls itself, if another table within the table is detected.
And the problem with the lost ListItem attribute is solved, too by setting the attributes additionally after the insert.
Here is my well working code segment:
Firstly i detect the table and insert it in the dstBody ...
...
dstChild = srcChild.copy();
switch( dstChild.getType() ) {
case DocumentApp.ElementType.PARAGRAPH:
...
case DocumentApp.ElementType.LIST_ITEM:
...
case DocumentApp.ElementType.TABLE:
var newTable =
dstBody.insertTable( dstBody.getNumChildren()-1, dstChild );
copyTableCellByCell( dstChild, newTable );
break;
....
}
And this is the maybe recursive function that replaces each cell by first clearing it and copying the content from the original table:
function copyTableCellByCell( srcTable, dstTable ) {
var numRows = dstTable.getNumRows();
var dstRow, numCells, dstCell, actCellIndex;
for ( var actRowIndex = 0; actRowIndex < numRows; actRowIndex++ ) {
dstRow = dstTable.getRow( actRowIndex );
numCells = dstRow.getNumCells();
for ( actCellIndex = 0; actCellIndex < numCells; actCellIndex++ ) {
dstCell = dstRow.getCell( actCellIndex );
dstCell.clear();
var srcCell = srcTable.getCell( actRowIndex, actCellIndex );
var numCellChildren = srcCell.getNumChildren();
for ( var y = 0; y < numCellChildren; y++ ) {
var cellChild = srcCell.getChild( y );
var childCopy = cellChild.copy();
switch( childCopy.getType() ) {
case DocumentApp.ElementType.PARAGRAPH:
dstCell.insertParagraph( y, childCopy );
break;
case DocumentApp.ElementType.LIST_ITEM:
// that the GLYPH_TYPE doesn't get lost
var atts = childCopy.getAttributes();
var
newListItem = dstCell.insertListItem( y, childCopy );
newListItem.setAttributes( atts );
break;
case DocumentApp.ElementType.TABLE:
var newTable =
dstCell.insertTable( y, childCopy );
copyTableCellByCell( cellChild, newTable );
break;
}
}
// remove the very first empty paragraph in the cell
while ( (y = dstCell.getNumChildren()) > numCellChildren ) {
dstCell.getChild( y - 1 ).removeFromParent();
}
}
}
}
This could be fine tuned, of course.
You could just search and pick out the inline images, if you want the servers have to do less work.
I hope, this helps in any way.
Thank you very much for your attention,
Richard