This macro will do copy of the active sheet and in this copy it removes the hidden rows or rows with zero height, and then it removes the hidden columns or columns with zero width.
Sub copyOnlyVisibleCells 'it do copy of active sheet and remove from this copy the hidden rows/columns and rows/columns with zero width/height
dim oDoc as object, oSheets as object, oSheet as object, oCur as object, i&, o as object
oDoc=ThisComponent
oSheets=oDoc.Sheets
oSheet=oDoc.CurrentController.ActiveSheet
s=oSheet.Name & "-COPY" 'name of copied sheet
oSheets.copyByName(oSheet.Name, s, oSheets.Count)
oSheet=oSheets.getbyName(s) 'copied sheet
oCur=oSheet.createCursor
oCur.goToEndOfUsedArea(false)
for i=0 to oCur.RangeAddress.EndRow 'remove hidden or no-height rows
o=oSheet.Rows.getByIndex(i)
if o.isVisible=false OR o.Height=0 then
oSheet.Rows.removeByIndex(i, 1)
end if
next i
for i=0 to oCur.RangeAddress.EndColumn 'remove hidden or no-width columns
o=oSheet.Columns.getByIndex(i)
if o.isVisible=false OR o.Width=0 then
oSheet.Columns.removeByIndex(i, 1)
end if
next i
End Sub