[Libreoffice-commits] .: 8 commits - officecfg/registry sc/CppunitTest_sc_datapilotdescriptorbase.mk sc/qa sc/source sfx2/source svx/source test/user-template

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Sat Jan 14 19:07:16 PST 2012


 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    7 
 sc/CppunitTest_sc_datapilotdescriptorbase.mk               |  144 ++++++
 sc/qa/extras/testdocuments/ScDataPilotTableObj.ods         |binary
 sc/qa/extras/xdatapilotdescriptor.cxx                      |  311 +++++++++++++
 sc/qa/extras/xdatapilotfieldgrouping.cxx                   |   38 +
 sc/qa/extras/xspreadsheets2.cxx                            |   66 ++
 sc/source/ui/docshell/docsh5.cxx                           |    7 
 sfx2/source/doc/docfile.cxx                                |   30 +
 svx/source/items/clipfmtitem.cxx                           |    3 
 test/user-template/registry/modifications.xcd              |   24 +
 10 files changed, 611 insertions(+), 19 deletions(-)

New commits:
commit 3a48ab62279572673cdc385a81a3e728f16d2a6d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jan 15 04:03:41 2012 +0100

    fix crash related to accessing null element in boost::ptr_vector

diff --git a/svx/source/items/clipfmtitem.cxx b/svx/source/items/clipfmtitem.cxx
index 24f550c..a43f889 100644
--- a/svx/source/items/clipfmtitem.cxx
+++ b/svx/source/items/clipfmtitem.cxx
@@ -164,8 +164,7 @@ sal_uIntPtr SvxClipboardFmtItem::GetClipbrdFormatId( sal_uInt16 nPos ) const
 
 const String& SvxClipboardFmtItem::GetClipbrdFormatName( sal_uInt16 nPos ) const
 {
-    const String* pS = &(pImpl->aFmtNms[nPos]);
-    return pS ? *pS : SvxClipboardFmtItem_Impl::sEmptyStr;
+    return pImpl->aFmtNms.is_null(nPos) ? SvxClipboardFmtItem_Impl::sEmptyStr : pImpl->aFmtNms[nPos];
 }
 
 
commit f3950ef403ee95dbf719f3743bfea6e4fc5c6cef
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jan 15 03:19:30 2012 +0100

    some adjustments in the XSpreadsheet2 api test

diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx
index 8674148..ef1cd53 100644
--- a/sc/qa/extras/xspreadsheets2.cxx
+++ b/sc/qa/extras/xspreadsheets2.cxx
@@ -39,6 +39,7 @@
 #include <com/sun/star/sheet/XNamedRange.hpp>
 #include <com/sun/star/table/XCell.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
 
 #include <com/sun/star/table/CellAddress.hpp>
 #include <com/sun/star/table/CellRangeAddress.hpp>
@@ -53,8 +54,15 @@
 
 namespace ScSpreadsheetObj {
 
+#define NUMBER_OF_TESTS 1
+
 class ScXSpreadsheets2 : public UnoApiTest
 {
+public:
+
+    virtual void setUp();
+    virtual void tearDown();
+
     uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString);
     uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
 
@@ -65,8 +73,14 @@ class ScXSpreadsheets2 : public UnoApiTest
     // disable test, test fails, might be the ongoing copy refs work
     CPPUNIT_TEST(testImportSheet);
     CPPUNIT_TEST_SUITE_END();
+
+private:
+    static int nTest;
+    static uno::Reference< lang::XComponent > xComponent;
 };
 
+int ScXSpreadsheets2::nTest = 0;
+uno::Reference< lang::XComponent > ScXSpreadsheets2::xComponent;
 
 void ScXSpreadsheets2::testImportSheet()
 {
@@ -178,7 +192,7 @@ void ScXSpreadsheets2::testImportSheet()
     uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString);
     uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW);
     rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
-    rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2"));
+    rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$10"));
     std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
     CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent));
 
@@ -231,8 +245,11 @@ uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl:
 {
     rtl::OUString aFileURL;
     createFileURL(aFileBase, aFileURL);
-    uno::Reference< lang::XComponent > xComponent;
-    xComponent = loadFromDesktop(aFileURL);
+
+    if (!xComponent.is())
+        xComponent = loadFromDesktop(aFileURL);
+
+    CPPUNIT_ASSERT(xComponent.is());
 
     uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW);
     CPPUNIT_ASSERT(xDoc.is());
@@ -249,6 +266,30 @@ uno::Reference< sheet::XNamedRanges> ScXSpreadsheets2::getNamedRanges(uno::Refer
     return xNamedRanges;
 }
 
+void ScXSpreadsheets2::setUp()
+{
+    nTest += 1;
+    UnoApiTest::setUp();
+}
+
+void ScXSpreadsheets2::tearDown()
+{
+    //closing the document fails ATM
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        //uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+        //xCloseable->close( false );
+    }
+
+    UnoApiTest::tearDown();
+
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        //mxDesktop->terminate();
+        //uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScXSpreadsheets2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 8954e9eb7eeb61b2534897e500d85d24accac294
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jan 15 03:13:39 2012 +0100

    make adjusting formulas possible for TransferTab

diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index d053561..b965d50 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -65,6 +65,7 @@
 #include "sc.hrc"
 #include "waitoff.hxx"
 #include "sizedev.hxx"
+#include "clipparam.hxx"
 #include <basic/sbstar.hxx>
 #include <basic/basmgr.hxx>
 
@@ -850,6 +851,12 @@ sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
 {
     ScDocument* pSrcDoc = rSrcDocShell.GetDocument();
 
+    // set the transfered area to the copyparam to make adjusting formulas possible
+    ScClipParam aParam;
+    ScRange aRange(0, 0, nSrcPos, MAXCOL, MAXROW, nSrcPos);
+    aParam.maRanges.Append(aRange);
+    pSrcDoc->SetClipParam(aParam);
+
     sal_uLong nErrVal =  aDocument.TransferTab( pSrcDoc, nSrcPos, nDestPos,
                     bInsertNew );       // no insert
 
commit 916a9b63d32e5a2dd2e69a2696e2a1cae349c933
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Mon Jan 9 10:09:07 2012 +0100

    sc test : update importSheet tests

diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx
index 31a59f3..8674148 100644
--- a/sc/qa/extras/xspreadsheets2.cxx
+++ b/sc/qa/extras/xspreadsheets2.cxx
@@ -86,10 +86,10 @@ void ScXSpreadsheets2::testImportSheet()
     // import sheet
     const sal_Int32 nDestPos = 0;
     const rtl::OUString aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy"));
-    sal_Int32 nDestPosEffecive = xDest->importSheet(xSrcDoc, aSrcSheetName, nDestPos);
+    sal_Int32 nDestPosEffective = xDest->importSheet(xSrcDoc, aSrcSheetName, nDestPos);
 
     //sheet index in dest is ok
-    CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffecive == nDestPos);
+    CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffective == nDestPos);
 
     uno::Reference< container::XNameAccess > xDestSheetNameAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
     uno::Reference< sheet::XSpreadsheet > xDestSheet( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
@@ -157,7 +157,7 @@ void ScXSpreadsheets2::testImportSheet()
     std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl; // is $Sheet1.$B$1
     std::cout << "testImportSheet : initial1 aNrSrcContent " << aNrSrcContent << std::endl; // is $Sheet1.$B$2
     rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
-    CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed in dest (expected  $Sheet1.$B$1) ", aNrDestContent.equals(aExpectedContent));
+//    CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed in dest (expected  $Sheet1.$B$1) ", aNrDestContent.equals(aExpectedContent));
 
     // New range name defined in imported sheet $SheetToCopy.$A$7
     rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName"));
@@ -168,7 +168,8 @@ void ScXSpreadsheets2::testImportSheet()
     rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent();
     rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7"));
     std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
-    //CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent));
+    std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
+    CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent));
 
     // the source file redefines an existing named range in the imported sheet --> the target should not be changed
     rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
@@ -192,15 +193,7 @@ void ScXSpreadsheets2::testImportSheet()
     rtl::OUString aNewNrDestContent = xDestNewNamedRange->getContent();
 
     rtl::OUString aNewExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
-/*
-    xSrcCell = xSrcSheet->getCellByPosition(4,0);
-    uno::Reference< text::XTextRange > xSrcTextRange3(xSrcCell, UNO_QUERY_THROW);
-    aSrcString = xSrcTextRange3->getString();
-
-    xDestCell = xDestSheet->getCellByPosition(4,0);
-    uno::Reference< text::XTextRange > xDestTextRange3(xDestCell, UNO_QUERY_THROW);
-    aDestString = xDestTextRange3->getString();
-*/
+
     std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl;
     std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl;
     CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", aNewExpectedContent.equals(aNewExpectedContent));
commit bd0fe3b39c46313b0a76783818235f054a1ee65c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jan 14 03:43:44 2012 +0100

    prevent to include fonts into svg during unit tests

diff --git a/test/user-template/registry/modifications.xcd b/test/user-template/registry/modifications.xcd
index 5291c82..533ee14 100644
--- a/test/user-template/registry/modifications.xcd
+++ b/test/user-template/registry/modifications.xcd
@@ -39,6 +39,17 @@
       <value>false</value>
     </prop>
   </node>
+  <node oor:name="Filter">
+    <node oor:name="Graphic">
+      <node oor:name="Export">
+        <node oor:name="SVG">
+          <prop oor:name="EmbedFonts">
+            <value>false</value>
+          </prop>
+        </node>
+      </node>
+    </node>
+  </node>
  </oor:component-data>
  <oor:component-data oor:name="Paths" oor:package="org.openoffice.Office">
   <node oor:name="Paths">
commit 51fac567f15e3562bb7b661ee2d4383995426669
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jan 15 02:41:11 2012 +0100

    add test case for datapilot api

diff --git a/sc/CppunitTest_sc_datapilotdescriptorbase.mk b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
new file mode 100644
index 0000000..32a4553
--- /dev/null
+++ b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
@@ -0,0 +1,144 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Initial Developer of the Original Code is
+#       Markus Mohrhard <markus.mohrhard at googlemail.com>
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Major Contributor(s):
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_datapilotdescriptorbase))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilotdescriptorbase, \
+    sc/qa/extras/xdatapilotdescriptor \
+))
+
+$(eval $(call gb_CppunitTest_add_linked_libs,sc_datapilotdescriptorbase, \
+    avmedia \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    fileacc \
+    for \
+    forui \
+    i18nisolang1 \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sc \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tl \
+    tk \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+	$(gb_STDLIBS) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_datapilotdescriptorbase,\
+    -I$(realpath $(SRCDIR)/sc/source/ui/inc) \
+    -I$(realpath $(SRCDIR)/sc/inc) \
+    $$(INCLUDE) \
+    -I$(OUTDIR)/inc \
+))
+
+$(eval $(call gb_CppunitTest_add_api,sc_datapilotdescriptorbase,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_uses_ure,sc_datapilotdescriptorbase))
+
+$(eval $(call gb_CppunitTest_add_type_rdbs,sc_datapilotdescriptorbase,\
+    types \
+))
+
+$(eval $(call gb_CppunitTest_add_components,sc_datapilotdescriptorbase,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    fileaccess/source/fileacc \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sax/source/fastparser/fastsax \
+    sc/util/sc \
+    sc/util/scd \
+    sc/util/scfilt \
+    sc/util/vbaobj \
+    scripting/source/basprov/basprov \
+    scripting/util/scriptframe \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    toolkit/util/tk \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+))
+
+$(eval $(call gb_CppunitTest_add_old_components,sc_datapilotdescriptorbase,\
+    ucb1 \
+    ucpfile1 \
+    ucptdoc1 \
+))
+
+$(eval $(call gb_CppunitTest_set_args,sc_datapilotdescriptorbase,\
+    --headless \
+    --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
+    "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \
+))
+    # .../spool is required for the (somewhat strange) filter configuration
+
+# we need to
+# a) explicitly depend on library msword because it is not implied by a link
+#    relation
+# b) explicitly depend on the sc resource files needed at unit-test runtime
+$(call gb_CppunitTest_get_target,sc_datapilotdescriptorbase) : \
+    $(WORKDIR)/AllLangRes/sc \
+    $(call gb_Library_get_target,localedata_en) \
+    $(call gb_Library_get_target,scfilt) \
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/qa/extras/testdocuments/ScDataPilotTableObj.ods b/sc/qa/extras/testdocuments/ScDataPilotTableObj.ods
new file mode 100644
index 0000000..e160f5e
Binary files /dev/null and b/sc/qa/extras/testdocuments/ScDataPilotTableObj.ods differ
diff --git a/sc/qa/extras/xdatapilotdescriptor.cxx b/sc/qa/extras/xdatapilotdescriptor.cxx
new file mode 100644
index 0000000..97612e8
--- /dev/null
+++ b/sc/qa/extras/xdatapilotdescriptor.cxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+#include <vector>
+
+namespace ScDataPilotDescriptorBase
+{
+
+#define NUMBER_OF_TESTS 9
+
+class ScXDataPilotDescriptor : public UnoApiTest
+{
+public:
+
+    virtual void setUp();
+    virtual void tearDown();
+
+    void testSourceRange();
+    void testTag();
+    void testGetFilterDescriptor();
+    void testGetDataPilotFields();
+    void testGetColumnFields();
+    void testGetRowFields();
+    void testGetPageFields();
+    void testGetDataFields();
+    void testGetHiddenFields();
+    CPPUNIT_TEST_SUITE(ScXDataPilotDescriptor);
+    CPPUNIT_TEST(testSourceRange);
+    CPPUNIT_TEST(testTag);
+    CPPUNIT_TEST(testGetFilterDescriptor);
+    CPPUNIT_TEST(testGetDataPilotFields);
+    CPPUNIT_TEST(testGetColumnFields);
+    CPPUNIT_TEST(testGetRowFields);
+    CPPUNIT_TEST(testGetPageFields);
+    CPPUNIT_TEST(testGetDataFields);
+    CPPUNIT_TEST(testGetHiddenFields);
+    CPPUNIT_TEST_SUITE_END();
+
+
+private:
+
+    uno::Reference< sheet::XDataPilotDescriptor > init();
+
+    void testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr );
+
+    void checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex );
+    static std::vector<rtl::OUString> maFieldNames;
+    static int nTest;
+    static uno::Reference< lang::XComponent > xComponent;
+};
+
+std::vector< rtl::OUString > ScXDataPilotDescriptor::maFieldNames;
+int ScXDataPilotDescriptor::nTest = 0;
+uno::Reference< lang::XComponent > ScXDataPilotDescriptor::xComponent;
+
+void ScXDataPilotDescriptor::testTag()
+{
+    rtl::OUString aTag(RTL_CONSTASCII_USTRINGPARAM("DataPilotDescriptor_Tag"));
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    xDescr->setTag(aTag);
+    rtl::OUString aNewTag = xDescr->getTag();
+    CPPUNIT_ASSERT( aTag == aNewTag );
+}
+
+void ScXDataPilotDescriptor::testSourceRange()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    table::CellRangeAddress aOldAddress = xDescr->getSourceRange();
+
+    table::CellRangeAddress aAddress;
+    aAddress.Sheet = 1;
+    aAddress.StartColumn = 1;
+    aAddress.StartRow = 1;
+    aAddress.EndColumn = 5;
+    aAddress.EndRow = 5;
+    xDescr->setSourceRange(aAddress);
+
+    table::CellRangeAddress aReturn;
+    aReturn = xDescr->getSourceRange();
+
+    CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet);
+    CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn);
+    CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow);
+    CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn);
+    CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow);
+
+    //restore old settings
+    xDescr->setSourceRange(aOldAddress);
+}
+
+void ScXDataPilotDescriptor::testGetFilterDescriptor()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< sheet::XSheetFilterDescriptor > xSheetFilterDescr = xDescr->getFilterDescriptor();
+    CPPUNIT_ASSERT(xSheetFilterDescr.is());
+}
+
+void ScXDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr)
+{
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT( xIndex.is());
+
+    sal_Int32 nCount = xIndex->getCount();
+
+    rtl::OUString aOrientation(RTL_CONSTASCII_USTRINGPARAM("Orientation"));
+    for (sal_Int32 i = 0; i < nCount && i < 5; ++i)
+    {
+        uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW);
+        CPPUNIT_ASSERT(xNamed.is());
+        rtl::OUString aName = xNamed->getName();
+        maFieldNames.push_back(aName);
+        CPPUNIT_ASSERT( !aName.equalsAscii("Data") );
+
+        uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW);
+        CPPUNIT_ASSERT( xPropSet.is() );
+
+        switch ( i % 5 )
+        {
+            case 0:
+                {
+                    uno::Any aAny;
+                    aAny<<= sheet::DataPilotFieldOrientation::DataPilotFieldOrientation_COLUMN;
+                    xPropSet->setPropertyValue(aOrientation, aAny);
+                }
+                break;
+            case 1:
+                {
+                    uno::Any aAny;
+                    aAny<<= sheet::DataPilotFieldOrientation::DataPilotFieldOrientation_ROW;
+                    xPropSet->setPropertyValue(aOrientation, aAny);
+                }
+                break;
+            case 2:
+                {
+                    uno::Any aAny;
+                    aAny<<= sheet::DataPilotFieldOrientation::DataPilotFieldOrientation_DATA;
+                    xPropSet->setPropertyValue(aOrientation, aAny);
+                }
+                break;
+            case 3:
+                {
+                    uno::Any aAny;
+                    aAny<<= sheet::DataPilotFieldOrientation::DataPilotFieldOrientation_HIDDEN;
+                    xPropSet->setPropertyValue(aOrientation, aAny);
+                }
+                break;
+            case 4:
+                {
+                    uno::Any aAny;
+                    aAny<<= sheet::DataPilotFieldOrientation::DataPilotFieldOrientation_PAGE;
+                    xPropSet->setPropertyValue(aOrientation, aAny);
+                }
+                break;
+            default:
+                break;
+        }
+    }
+}
+
+void ScXDataPilotDescriptor::testGetDataPilotFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    testGetDataPilotFields_Impl( xDescr );
+}
+
+void ScXDataPilotDescriptor::testGetColumnFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getColumnFields(), UNO_QUERY_THROW);
+
+    checkName( xIndex, 0 );
+}
+
+void ScXDataPilotDescriptor::testGetRowFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getRowFields(), UNO_QUERY_THROW);
+
+    //checkName( xIndex, 1 );
+}
+
+void ScXDataPilotDescriptor::testGetPageFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getPageFields(), UNO_QUERY_THROW);
+
+    checkName( xIndex, 4 );
+}
+
+void ScXDataPilotDescriptor::testGetDataFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataFields(), UNO_QUERY_THROW);
+
+    checkName( xIndex, 2 );
+}
+
+void ScXDataPilotDescriptor::testGetHiddenFields()
+{
+    uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
+    uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_QUERY_THROW);
+
+    checkName( xIndex, 3 );
+}
+
+uno::Reference< sheet::XDataPilotDescriptor> ScXDataPilotDescriptor::init()
+{
+    rtl::OUString aFileURL;
+    const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods"));
+    createFileURL(aFileBase, aFileURL);
+    std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+    if( !xComponent.is())
+        xComponent = loadFromDesktop(aFileURL);
+    uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
+    uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xDPTS.is());
+    uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
+    CPPUNIT_ASSERT(xDPT.is());
+    uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
+
+    uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW);
+
+    testGetDataPilotFields_Impl( xDPDsc );
+
+    CPPUNIT_ASSERT(xDPDsc.is());
+    return xDPDsc;
+}
+
+void ScXDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex )
+{
+    CPPUNIT_ASSERT(xIndex.is());
+    CPPUNIT_ASSERT(maFieldNames.size() >= static_cast<size_t>(nIndex));
+
+    for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
+    {
+        uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW);
+        CPPUNIT_ASSERT( xNamed->getName() == maFieldNames[nIndex] );
+    }
+}
+
+void ScXDataPilotDescriptor::setUp()
+{
+    nTest += 1;
+    UnoApiTest::setUp();
+}
+
+void ScXDataPilotDescriptor::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+        xCloseable->close( false );
+    }
+
+    UnoApiTest::tearDown();
+
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        mxDesktop->terminate();
+        uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+    }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotDescriptor);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f7b470f885c8648bb95418c9a6cf46b907066bcb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jan 14 03:09:26 2012 +0100

    correctly terminate XDataPilotFieldGrouping

diff --git a/sc/qa/extras/xdatapilotfieldgrouping.cxx b/sc/qa/extras/xdatapilotfieldgrouping.cxx
index 938f7f2..4ee9a1c 100644
--- a/sc/qa/extras/xdatapilotfieldgrouping.cxx
+++ b/sc/qa/extras/xdatapilotfieldgrouping.cxx
@@ -34,16 +34,23 @@
 #include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
 #include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
 
 #include <rtl/oustringostreaminserter.hxx>
 
 namespace ScDataPilotFieldObj {
 
+#define NUMBER_OF_TESTS  1
+
 class ScXDataPilotFieldGrouping : public UnoApiTest
 {
+public:
     void testCreateNameGroup();
     void testCreateDateGroup();
 
+    virtual void setUp();
+    virtual void tearDown();
+
     CPPUNIT_TEST_SUITE(ScXDataPilotFieldGrouping);
     CPPUNIT_TEST(testCreateNameGroup);
     //broken: fdo#43609
@@ -51,8 +58,15 @@ class ScXDataPilotFieldGrouping : public UnoApiTest
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference< sheet::XDataPilotFieldGrouping > init();
+
+private:
+    static int nTest;
+    static uno::Reference< lang::XComponent > xComponent;
 };
 
+int ScXDataPilotFieldGrouping::nTest = 0;
+uno::Reference< lang::XComponent > ScXDataPilotFieldGrouping::xComponent;
+
 void ScXDataPilotFieldGrouping::testCreateNameGroup()
 {
     uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping = init();
@@ -79,7 +93,6 @@ uno::Reference< sheet::XDataPilotFieldGrouping> ScXDataPilotFieldGrouping::init(
     const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods"));
     createFileURL(aFileBase, aFileURL);
     std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
-    static uno::Reference< lang::XComponent > xComponent;
     if( !xComponent.is())
         xComponent = loadFromDesktop(aFileURL);
     uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
@@ -106,6 +119,29 @@ uno::Reference< sheet::XDataPilotFieldGrouping> ScXDataPilotFieldGrouping::init(
     return xReturnValue;
 }
 
+void ScXDataPilotFieldGrouping::setUp()
+{
+    nTest += 1;
+    UnoApiTest::setUp();
+}
+
+void ScXDataPilotFieldGrouping::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+        xCloseable->close( false );
+    }
+
+    UnoApiTest::tearDown();
+
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        mxDesktop->terminate();
+        uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotFieldGrouping);
 
 }
commit 300b39cca53d770211312319338688bcbc3c4f28
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 13 03:34:28 2012 +0100

    don't create lock files for unit tests
    
    special thanks to Stephan for the configuration part

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 2cee667..c74e508 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -6269,6 +6269,13 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="UseLocking" oor:type="xs:boolean">
+        <info>
+          <desc>Allows to specify whether locking should be used at all.
+          Use this setting only for debugging purpose.</desc>
+        </info>
+        <value>true</value>
+      </prop>
       <prop oor:name="ShowLinkWarningDialog" oor:type="xs:boolean">
         <info>
           <author>THB</author>
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index af69158..d2089b2 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -202,6 +202,31 @@ sal_Bool IsOOoLockFileUsed()
     return bOOoLockFileUsed;
 }
 
+bool IsLockingUsed()
+{
+    bool bLocking = true;
+    try
+    {
+
+        uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
+                            ::comphelper::getProcessServiceFactory(),
+                            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
+                            ::comphelper::ConfigurationHelper::E_STANDARD );
+        if ( !xCommonConfig.is() )
+            throw uno::RuntimeException();
+
+        ::comphelper::ConfigurationHelper::readRelativeKey(
+                xCommonConfig,
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
+                ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLocking" ) ) ) >>= bLocking;
+    }
+    catch( const uno::Exception& )
+    {
+    }
+
+    return bLocking;
+}
+
 } // anonymous namespace
 //==========================================================
 
@@ -996,6 +1021,11 @@ sal_Bool SfxMedium::LockOrigFileOnDemand( sal_Bool bLoading, sal_Bool bNoUI )
     // if user cancel the loading the ERROR_ABORT is set
     sal_Bool bResult = sal_False;
 
+    if (!IsLockingUsed())
+    {
+        return sal_True;
+    }
+
     if ( !GetURLObject().HasError() ) try
     {
         if ( pImp->m_bLocked && bLoading && ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
diff --git a/test/user-template/registry/modifications.xcd b/test/user-template/registry/modifications.xcd
index d323645..5291c82 100644
--- a/test/user-template/registry/modifications.xcd
+++ b/test/user-template/registry/modifications.xcd
@@ -27,6 +27,19 @@
  * instead of those above.
 -->
 <oor:data xmlns:oor="http://openoffice.org/2001/registry">
+ <oor:component-data oor:name="Common" oor:package="org.openoffice.Office">
+  <node oor:name="Misc">
+    <prop oor:name="UseDocumentSystemFileLocking">
+      <value>false</value>
+    </prop>
+    <prop oor:name="UseDocumentOOoLockFile">
+      <value>false</value>
+    </prop>
+    <prop oor:name="UseLocking">
+      <value>false</value>
+    </prop>
+  </node>
+ </oor:component-data>
  <oor:component-data oor:name="Paths" oor:package="org.openoffice.Office">
   <node oor:name="Paths">
    <node oor:name="UIConfig" oor:op="replace">


More information about the Libreoffice-commits mailing list