Summary: | Add warning about data loss when creating pivot table and deleting data source | ||
---|---|---|---|
Product: | LibreOffice | Reporter: | raal <raal> |
Component: | Calc | Assignee: | abhilash300singh |
Status: | VERIFIED FIXED | ||
Severity: | major | CC: | mentoring, michael.meeks, robinson.libreoffice, suokunlong, yeliztaneroglu |
Priority: | highest | Keywords: | difficultyInteresting, easyHack, skillCpp |
Version: | Inherited From OOo | ||
Hardware: | Other | ||
OS: | All | ||
See Also: | https://bugs.freedesktop.org/show_bug.cgi?id=79332 | ||
Whiteboard: | target:5.4.0 | ||
Crash report or crash signature: | Regression By: | ||
Bug Depends on: | |||
Bug Blocks: | 103381 | ||
Attachments: | It's now fixed in master. See screenshot. |
Description
raal
2014-12-08 17:40:26 UTC
(In reply to raal from comment #0) > How to reproduce > Create pivot table on new sheet > Delete Sheet1 (sheet with data). --> *add warning here* > Save file. > You can filter in pivot table, data are in the pivot cache. > Close file. > Open File > Pivot table broken CONFIRMED with LO 4.4.0.0.beta2 + Ubuntu 14.04. Pivot table is broken after reopening file. Bug 79332 was marked as a MAB due to potential for data loss. As such, I'll add this back to mab4.3 and increase the priority; it would behoove us to look at the broader category of all generated data in Calc (pivot tables, charts, etc..) and warn users if they delete required data. Status -> NEW The warning on sheet deletion is here: sc/source/ui/view/tabvwshf.cxx: // no parameter given, ask for confirmation bDoIt = ( RET_YES == ScopedVclPtr<QueryBox>::Create( GetDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ), ScGlobal::GetRscString(STR_QUERY_DELTAB) )->Execute() ); And I imagine we need a more complex dialog here that will mention that if there are pivot tables pointing to these sheets (in TheTabs) - and we should build the list of TheTabs before prompting instead of after as we do now. Then we should warn harder =) To find all the pivot tables use: sc/inc/document.hxx (ScDocument)'s: SC_DLLPUBLIC ScDPCollection* GetDPCollection(); sc/inc/dpobject.hxx (ScDPCollection): -> a list of Pivot Tables (Data Pilot) ultimately this: typedef std::vector< std::unique_ptr<ScDPObject> > TablesType; TablesType maTables; Where a 'ScDPObject' - is really a Pivot Table. So we need to find all of the sheets that may reference us in this case - by poking at ScDPObjects ... Quite probably this: const ScSheetSourceDesc* GetSheetDesc() const { return pSheetDesc; } Tells us about the source ranges this comes from. This is defined in: sc/inc/dpshttab.hxx Which has: SC_DLLPUBLIC const ScRange& GetSourceRange() const; sc/inc/address.hxx: // ScRange class ScRange { public: ScAddress aStart; ScAddress aEnd; class ScAddress { private: SCROW nRow; SCCOL nCol; SCTAB nTab; =) Beware: a source range can be 3D - ie. it can span rows, columns -and- sheets =) Thanks ! Converted to easyhacks as discussed pr email Abhilash Singh committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=65d10c4dedbf72f87888e14984393c222a5b31f9 tdf#87111 Warn about data loss when deleting source data of pivot table It will be available in 5.4.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback. Seems solved Created attachment 130274 [details] It's now fixed in master. See screenshot. Confirm fixed in Version: 5.4.0.0.alpha0+ Build ID: d1bad9c12d61c9f662abe6439b87a057bb54c8ca CPU Threads: 4; OS Version: Linux 4.4; UI Render: default; VCL: gtk3; Locale: zh-CN (zh_CN.UTF-8); Calc: group |