[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/inc sc/qa sc/source

2019-01-22 Thread Libreoffice Gerrit user
 sc/inc/dpcache.hxx   |1 
 sc/qa/unit/data/ods/numgroup_example.ods |binary
 sc/qa/unit/helper/qahelper.cxx   |   10 -
 sc/qa/unit/helper/qahelper.hxx   |3 +-
 sc/qa/unit/subsequent_export-test.cxx|   33 +++
 sc/source/core/data/dpcache.cxx  |5 
 sc/source/core/data/dpobject.cxx |4 +--
 7 files changed, 52 insertions(+), 4 deletions(-)

New commits:
commit 59d4b488e0d25266f02ca142d18deee7ecc5dc55
Author: Katarina Behrens 
AuthorDate: Tue Dec 18 11:12:49 2018 +0100
Commit: Eike Rathke 
CommitDate: Tue Jan 22 21:31:38 2019 +0100

Resetting all fields for all dims corrupts pivot cache

test case is exporting ooo55266-3 (contains data grouped in numerical
intervals) to xlsx and without closing the document, opening filter on
1st pivot table (kaboom!)

ClearGroupFields corrupts the cache bc it resets Field.mpGroup items
for all dimensions, not just the one present in ScDPDimensionSaveData
(all this happening in ScDPCollection::SheetCaches::getCache).
Consequently, accessing or rebuilding pivot cache may crash bc mpGroup
now points nowhere.

I split and renamed ScDPCache::ClearGroupFields into 2 parts, one of
them clears maGroupFields, the other resets mpGroup ptrs in maFields.
When adding data to cache, the former is used (bc group ptrs get reset
almost immediately afterwards)

Reviewed-on: https://gerrit.libreoffice.org/65329
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
Reviewed-by: Kohei Yoshida 
Reviewed-by: Katarina Behrens 
(cherry picked from commit f70d29fd91d232f0b030f0f76bd23bd2919eb868)

Change-Id: I96e8d234a17da0f3cc65c0625aa47b12284b98b8
Reviewed-on: https://gerrit.libreoffice.org/66622
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 8386c1d4b3f3..4a41bc3aff46 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -144,6 +144,7 @@ public:
 SCROW SetGroupItem(long nDim, const ScDPItemData& rData);
 void GetGroupDimMemberIds(long nDim, std::vector& rIds) const;
 void ClearGroupFields();
+void ClearAllFields();
 const ScDPNumGroupInfo* GetNumGroupInfo(long nDim) const;
 
 /**
diff --git a/sc/qa/unit/data/ods/numgroup_example.ods 
b/sc/qa/unit/data/ods/numgroup_example.ods
new file mode 100644
index ..008e1bfd4970
Binary files /dev/null and b/sc/qa/unit/data/ods/numgroup_example.ods differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index d414b1abfb96..809fdbf4bbd0 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -689,7 +689,7 @@ ScDocShellRef ScBootstrapFixture::saveAndReload( 
ScDocShell* pShell, sal_Int32 n
 return xDocSh;
 }
 
-std::shared_ptr ScBootstrapFixture::exportTo( ScDocShell* 
pShell, sal_Int32 nFormat )
+std::shared_ptr ScBootstrapFixture::saveAs( ScDocShell* pShell, 
sal_Int32 nFormat )
 {
 OUString aFilterName(aFileFormats[nFormat].pFilterName, 
strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
 OUString aFilterType(aFileFormats[nFormat].pTypeName, 
strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8);
@@ -708,8 +708,16 @@ std::shared_ptr 
ScBootstrapFixture::exportTo( ScDocShell* pShell,
 pExportFilter.get()->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
 aStoreMedium.SetFilter(pExportFilter);
 pShell->DoSaveAs( aStoreMedium );
+
+return pTempFile;
+}
+
+std::shared_ptr ScBootstrapFixture::exportTo( ScDocShell* 
pShell, sal_Int32 nFormat )
+{
+std::shared_ptr pTempFile = saveAs(pShell, nFormat);
 pShell->DoClose();
 
+SfxFilterFlags nFormatType = aFileFormats[nFormat].nFormatType;
 if(nFormatType == XLSX_FORMAT_TYPE)
 validate(pTempFile->GetFileName(), test::OOXML);
 else if (nFormatType == ODS_FORMAT_TYPE)
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index f8d522e65387..c31569068a30 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -204,7 +204,8 @@ public:
 
 ScDocShellRef saveAndReload( ScDocShell* pShell, sal_Int32 nFormat );
 
-static std::shared_ptr exportTo( ScDocShell* pShell, 
sal_Int32 nFormat );
+static std::shared_ptr saveAs(ScDocShell* pShell, sal_Int32 
nFormat);
+static std::shared_ptr exportTo(ScDocShell* pShell, 
sal_Int32 nFormat);
 
 void miscRowHeightsTest( TestParam const * aTestValues, unsigned int 
numElems );
 };
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 2fb53a18ac3c..28f0782e5ad8 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -43,6 +43,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -211,6 +213,7 @@ public:
 
 void testTdf118990();
 void testTdf121612();
+

[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sc/inc sc/qa sc/source

2018-07-04 Thread Henry Castro
 sc/inc/postit.hxx   |  114 ---
 sc/inc/scmod.hxx|2 
 sc/qa/unit/ucalc.cxx|   18 -
 sc/source/core/data/documen3.cxx|3 
 sc/source/core/data/document.cxx|   10 
 sc/source/core/data/postit.cxx  |  554 +++-
 sc/source/core/tool/detfunc.cxx |2 
 sc/source/filter/excel/xeescher.cxx |2 
 sc/source/filter/xml/xmlexprt.cxx   |   10 
 sc/source/ui/app/scmod.cxx  |   28 -
 sc/source/ui/docshell/docfunc.cxx   |4 
 sc/source/ui/docshell/docsh.cxx |   33 ++
 sc/source/ui/drawfunc/futext3.cxx   |4 
 sc/source/ui/inc/docsh.hxx  |2 
 sc/source/ui/inc/notemark.hxx   |2 
 sc/source/ui/inc/undocell.hxx   |   45 ++
 sc/source/ui/undo/undocell.cxx  |  185 +++-
 sc/source/ui/unoobj/editsrc.cxx |2 
 sc/source/ui/unoobj/notesuno.cxx|2 
 sc/source/ui/view/drawview.cxx  |2 
 sc/source/ui/view/gridwin.cxx   |2 
 sc/source/ui/view/notemark.cxx  |2 
 sc/source/ui/view/tabview5.cxx  |2 
 sc/source/ui/view/viewfun6.cxx  |2 
 24 files changed, 403 insertions(+), 629 deletions(-)

New commits:
commit ee7638061e787e6a1c37b2d3be1c14852cbc3381
Author: Henry Castro 
Date:   Fri Jun 8 17:09:55 2018 -0400

sc: replace ScCaptionPtr with std::shared_ptr, tdf#117997, tdf#117228

Change-Id: I9b6a2c2504c9ce060906ac3bf156721709fef2f3
Reviewed-on: https://gerrit.libreoffice.org/55490
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
Reviewed-on: https://gerrit.libreoffice.org/56651
Tested-by: Eike Rathke 

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index bf29a9693904..de77e208b829 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -36,110 +36,6 @@ class ScDocument;
 namespace tools { class Rectangle; }
 struct ScCaptionInitData;
 
-/** Some desperate attempt to fight against the caption object ownership mess,
-to which none of shared/weak/plain pointer is a cure.
- */
-class ScCaptionPtr
-{
-public:
-ScCaptionPtr();
-explicit ScCaptionPtr( SdrCaptionObj* p );
-ScCaptionPtr( const ScCaptionPtr& r );
-ScCaptionPtr( ScCaptionPtr&& r );
-~ScCaptionPtr();
-
-ScCaptionPtr& operator=( const ScCaptionPtr& r );
-ScCaptionPtr& operator=( ScCaptionPtr&& r );
-explicit operator bool() const{ return mpCaption != nullptr; }
-const SdrCaptionObj* get() const{ return mpCaption; }
-SdrCaptionObj* get(){ return mpCaption; }
-const SdrCaptionObj* operator->() const { return mpCaption; }
-SdrCaptionObj* operator->() { return mpCaption; }
-const SdrCaptionObj& operator*() const  { return *mpCaption; }
-SdrCaptionObj& operator*()  { return *mpCaption; }
-
-// Does not default to nullptr to make it visually obvious where such is 
used.
-void reset( SdrCaptionObj* p );
-
-/** Insert to draw page. The caption object is owned by the draw page then.
- */
-void insertToDrawPage( SdrPage& rDrawPage );
-
-/** Remove from draw page. The caption object is not owned anymore by the
-draw page then.
- */
-void removeFromDrawPage( SdrPage& rDrawPage );
-
-/** Remove from draw page and free caption object if no Undo recording.
- */
-void removeFromDrawPageAndFree( bool bIgnoreUndo = false );
-
-/** Release all management of the SdrCaptionObj* in all instances of this
-list and dissolve. The SdrCaptionObj pointer returned is ready to be
-managed elsewhere.
- */
-SdrCaptionObj* release();
-
-/** Forget the SdrCaptionObj pointer in this one instance.
-Decrements a use count but does not destroy the object, it's up to the
-caller to manage this mess..
- */
-void forget();
-
-/** Flag that this instance is in Undo, so drawing layer owns it. */
-void setNotOwner();
-
-oslInterlockedCount getRefs() const;
-
-private:
-
-struct Head
-{
-ScCaptionPtr*   mpFirst;///< first in list
-oslInterlockedCount mnRefs; ///< use count
-
-Head() = delete;
-explicit Head( ScCaptionPtr* );
-};
-
-Head* mpHead;   ///< points to the "master" entry
-mutable ScCaptionPtr* mpNext;   ///< next in list
-SdrCaptionObj*mpCaption;///< the caption object, managed by 
head master
-bool  mbNotOwner;   ///< whether this caption object is 
owned by something else, e.g. held in Undo
-/* TODO: can that be moved to Head?
- * It's unclear when to reset, so
- * each instance has its own flag.
- * The last reference count
- * decrement automatically has the
- * then current