[Libreoffice-commits] core.git: Branch 'feature/orcus-odf' - 4 commits - sc/CppunitTest_sc_subsequent_filters_test.mk sc/inc sc/qa sc/source

Jaskaran Singh jvsg1303 at gmail.com
Sun Jul 31 19:09:30 UTC 2016


 sc/CppunitTest_sc_subsequent_filters_test.mk |   13 +++++
 sc/inc/stlpool.hxx                           |    2 
 sc/qa/unit/subsequent_filters-test.cxx       |   63 +++++++++++++++++++++++++++
 sc/source/filter/orcus/orcusfiltersimpl.cxx  |   17 -------
 sc/source/ui/docshell/docsh.cxx              |   20 ++++++++
 sc/source/ui/docshell/docsh2.cxx             |   20 ++++++++
 6 files changed, 117 insertions(+), 18 deletions(-)

New commits:
commit c2663da206fa14ac8076f2318f2fd7420dd605ef
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date:   Mon Aug 1 00:37:03 2016 +0530

    Add test for orcus style import
    
    Change-Id: I4731ed1854f854651b828ae4cb27e6b040660bdf

diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 0c1428e..1f7780a 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -31,6 +31,7 @@
 #include <editeng/udlnitem.hxx>
 #include <editeng/editobj.hxx>
 #include <editeng/borderline.hxx>
+#include <editeng/boxitem.hxx>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/brushitem.hxx>
 #include <editeng/fontitem.hxx>
@@ -61,6 +62,15 @@
 #include <tokenstringcontext.hxx>
 #include <formula/errorcodes.hxx>
 #include "externalrefmgr.hxx"
+#include <stlpool.hxx>
+#include <config_orcus.h>
+
+#if ENABLE_ORCUS
+#include <orcusfiltersimpl.hxx>
+#include "orcusfilters.hxx"
+#include "filter.hxx"
+#include "orcusinterface.hxx"
+#endif
 
 
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
@@ -149,6 +159,10 @@ public:
     void testCondFormatParentXLSX();
     void testColorScaleNumWithRefXLSX();
 
+    #if ENABLE_ORCUS
+    void testOrcusODSStyleInterface();
+    #endif
+
     void testLiteralInFormulaXLS();
 
     //change this test file only in excel and not in calc
@@ -268,6 +282,11 @@ public:
     CPPUNIT_TEST(testComplexIconSetsXLSX);
     CPPUNIT_TEST(testCondFormatParentXLSX);
     CPPUNIT_TEST(testColorScaleNumWithRefXLSX);
+
+    #if ENABLE_ORCUS
+    CPPUNIT_TEST(testOrcusODSStyleInterface);
+    #endif
+
     CPPUNIT_TEST(testLiteralInFormulaXLS);
 
     CPPUNIT_TEST(testNumberFormatHTML);
@@ -2640,6 +2659,50 @@ void ScFiltersTest::testColorScaleNumWithRefXLSX()
     xDocSh->DoClose();
 }
 
+#if ENABLE_ORCUS
+void ScFiltersTest::testOrcusODSStyleInterface()
+{
+    ScDocument aDoc;
+    OUString aValidPath;
+    OUString aFullUrl = m_directories.getURLFromSrc("sc/qa/unit/data/xml/styles.xml");
+
+    /* This loop below trims file:// from the start because orcus doesn't accept such a url */
+
+    for (sal_Int32 i = 7; i < aFullUrl.getLength(); ++i)
+        aValidPath += OUString(aFullUrl[i]);
+
+    ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
+    CPPUNIT_ASSERT(pOrcus);
+
+    pOrcus->importODS_Styles(aDoc, aValidPath);
+    ScStyleSheetPool* pStyleSheetPool = aDoc.GetStyleSheetPool();
+
+    ScStyleSheet* pStyleSheet = pStyleSheetPool->FindCaseIns("Name1", SfxStyleFamily::Para);
+    const SfxPoolItem* pItem = nullptr;
+
+    CPPUNIT_ASSERT_MESSAGE("Style Name1 : Doesn't have Attribute background, but it should have.",
+        pStyleSheet->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem));
+    const SvxBrushItem* pBackground = static_cast<const SvxBrushItem*>(pItem);
+    CPPUNIT_ASSERT_EQUAL(Color(254, 255, 204), pBackground->GetColor());
+
+    CPPUNIT_ASSERT_MESSAGE("Style Name1 : Doesn't have Attribute border, but it should have.",
+        pStyleSheet->GetItemSet().HasItem(ATTR_BORDER, &pItem));
+    const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem);
+    CPPUNIT_ASSERT_EQUAL(Color(255, 204, 18), pBoxItem->GetLeft()->GetColor());
+    CPPUNIT_ASSERT_EQUAL(Color(255, 204, 18), pBoxItem->GetRight()->GetColor());
+    CPPUNIT_ASSERT_EQUAL(Color(255, 204, 18), pBoxItem->GetTop()->GetColor());
+    CPPUNIT_ASSERT_EQUAL(Color(255, 204, 18), pBoxItem->GetBottom()->GetColor());
+    CPPUNIT_ASSERT_EQUAL(pBoxItem->GetLeft()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DOTTED);
+    CPPUNIT_ASSERT_EQUAL(pBoxItem->GetRight()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DOTTED);
+    CPPUNIT_ASSERT_EQUAL(pBoxItem->GetTop()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DOTTED);
+    CPPUNIT_ASSERT_EQUAL(pBoxItem->GetBottom()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DOTTED);
+    ASSERT_DOUBLES_EQUAL_MESSAGE("Error with left width", 1, pBoxItem->GetLeft()->GetWidth());
+    ASSERT_DOUBLES_EQUAL_MESSAGE("Error with right width", 1, pBoxItem->GetRight()->GetWidth());
+    ASSERT_DOUBLES_EQUAL_MESSAGE("Error with top width", 1, pBoxItem->GetTop()->GetWidth());
+    ASSERT_DOUBLES_EQUAL_MESSAGE("Error with bottom width", 1, pBoxItem->GetBottom()->GetWidth());
+}
+#endif
+
 void ScFiltersTest::testLiteralInFormulaXLS()
 {
     ScDocShellRef xDocSh = loadDoc("shared-string/literal-in-formula.", FORMAT_XLS);
commit 52d9c87fed0b55399dcc7f4ab026066f886a4ba9
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date:   Mon Aug 1 00:35:48 2016 +0530

    Change the way url is handled for orcus style import
    
    Change-Id: I6d5f9059f8a83ae5b148ff0498d8af0777acfac8

diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index e16cc7f..66a9ca2 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -147,22 +147,9 @@ bool ScOrcusFiltersImpl::importODS(ScDocument& rDoc, SfxMedium& rMedium) const
     return true;
 }
 
-bool ScOrcusFiltersImpl::importODS_Styles(ScDocument& rDoc, OUString& aFileName) const
+bool ScOrcusFiltersImpl::importODS_Styles(ScDocument& rDoc, OUString& aPath) const
 {
-    OUString aPath("$BRAND_BASE_DIR/");  /* Read the comment below before changing this */
-    rtl::Bootstrap::expandMacros(aPath);
-    OUString aValidPath;
-
-    /* The Following loop trims 'file://' from start of string and
-     * '../' from the end of string. If you ever happen to change the above macro
-     * please consider changing the following range too, otherwise app would
-     * crash!!
-     */
-    for (sal_Int32 i = 7; i < aPath.getLength() - 3; ++i)
-        aValidPath += OUString(aPath[i]);
-
-    aValidPath += aFileName;
-    OString aUrl = OUStringToOString(aValidPath, RTL_TEXTENCODING_UTF8);
+    OString aUrl = OUStringToOString(aPath, RTL_TEXTENCODING_UTF8);
     const char* path = aUrl.getStr();
 
     try
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index c2367ef..089d6d5 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -27,6 +27,7 @@
 #include <vcl/msgbox.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/waitobj.hxx>
+#include <rtl/bootstrap.hxx>
 #include <svl/PasswordHelper.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/bindings.hxx>
@@ -111,6 +112,7 @@
 #include "refreshtimerprotector.hxx"
 #include <orcus/orcus_import_ods.hpp>
 #include <orcusfiltersimpl.hxx>
+#include <config_orcus.h>
 
 #include <officecfg/Office/Calc.hxx>
 #include <comphelper/processfactory.hxx>
@@ -577,13 +579,29 @@ bool ScDocShell::Load( SfxMedium& rMedium )
             aDocument.GetStyleSheetPool()->CreateStandardStyles();
             aDocument.UpdStlShtPtrsFrmNms();
 
+            #if ENABLE_ORCUS
             /* Create styles that are imported through Orcus */
 
+            OUString aPath("$BRAND_BASE_DIR/");  /* Read the comment below before changing this */
+            rtl::Bootstrap::expandMacros(aPath);
+            OUString aValidPath;
+
+            /* The Following loop trims 'file://' from start of string and
+             * '../' from the end of string. If you ever happen to change the above macro
+             * please consider changing the following range too, otherwise app would
+             * crash!!
+             */
+            for (sal_Int32 i = 7; i < aPath.getLength() - 3; ++i)
+                aValidPath += OUString(aPath[i]);
+
             OUString aFileName = "styles.xml";
+            aValidPath += aFileName;
+
             ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
             if (!pOrcus)
                 return false;
-            pOrcus->importODS_Styles(aDocument, aFileName);
+            pOrcus->importODS_Styles(aDocument, aValidPath);
+            #endif
 
             bRet = LoadXML( &rMedium, nullptr );
         }
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
index 376b508..5d25017 100644
--- a/sc/source/ui/docshell/docsh2.cxx
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -18,12 +18,14 @@
  */
 
 #include "scitems.hxx"
+#include <rtl/bootstrap.hxx>
 #include <svx/drawitem.hxx>
 #include <svl/asiancfg.hxx>
 #include <editeng/forbiddencharacterstable.hxx>
 #include <editeng/unolingu.hxx>
 #include <orcus/orcus_import_ods.hpp>
 #include <orcusfiltersimpl.hxx>
+#include <config_orcus.h>
 
 #include "drwlayer.hxx"
 #include "stlpool.hxx"
@@ -56,13 +58,29 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
     aDocument.GetStyleSheetPool()->CreateStandardStyles();
     aDocument.UpdStlShtPtrsFrmNms();
 
+    #if ENABLE_ORCUS
     /* Create styles that are imported through Orcus */
 
+    OUString aPath("$BRAND_BASE_DIR/");  /* Read the comment below before changing this */
+    rtl::Bootstrap::expandMacros(aPath);
+    OUString aValidPath;
+
+    /* The Following loop trims 'file://' from start of string and
+     * '../' from the end of string. If you ever happen to change the above macro
+     * please consider changing the following range too, otherwise app would
+     * crash!!
+     */
+    for (sal_Int32 i = 7; i < aPath.getLength() - 3; ++i)
+        aValidPath += OUString(aPath[i]);
+
     OUString aFileName = "styles.xml";
+    aValidPath += aFileName;
+
     ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters();
     if (!pOrcus)
         return false;
-    pOrcus->importODS_Styles(aDocument, aFileName);
+    pOrcus->importODS_Styles(aDocument, aValidPath);
+    #endif
 
     //  SetDocumentModified is not allowed anymore in Load/InitNew!
     InitItems();
commit 501886f7d93aff59bfcf193cd0a9a6b4bd8ef08a
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date:   Mon Aug 1 00:33:11 2016 +0530

    Link orcus headers and libs to subsequent filters test
    
    Change-Id: If036666f16dec23539e0e5a78f3a28d9cdc8be53

diff --git a/sc/CppunitTest_sc_subsequent_filters_test.mk b/sc/CppunitTest_sc_subsequent_filters_test.mk
index bd0a06b..5c266c4 100644
--- a/sc/CppunitTest_sc_subsequent_filters_test.mk
+++ b/sc/CppunitTest_sc_subsequent_filters_test.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_filters_test, \
 $(eval $(call gb_CppunitTest_set_include,sc_subsequent_filters_test,\
     -I$(SRCDIR)/sc/source/ui/inc \
     -I$(SRCDIR)/sc/inc \
+	-I$(SRCDIR)/sc/source/filter/inc \
     $$(INCLUDE) \
 ))
 
@@ -117,6 +118,18 @@ $(eval $(call gb_CppunitTest_use_components,sc_subsequent_filters_test,\
 ))
 endif
 
+ifeq ($(ENABLE_ORCUS),TRUE)
+$(eval $(call gb_CppunitTest_use_externals,sc_subsequent_filters_test,\
+	orcus \
+	orcus-parser \
+	boost_filesystem \
+	boost_system \
+	boost_iostreams \
+	zlib \
+))
+
+endif
+
 $(eval $(call gb_CppunitTest_use_configuration,sc_subsequent_filters_test))
 
 # vim: set noet sw=4 ts=4:
commit bbebdb1cea91e302c175cfb13c252370a22ae1d9
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date:   Mon Aug 1 00:31:14 2016 +0530

    Export ScStyleSheetPool Symbol out of its lib
    
    Change-Id: I7fe0842be5e3c07b3d0b8936b276d3107e8daa14

diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx
index af98861..38f51aa 100644
--- a/sc/inc/stlpool.hxx
+++ b/sc/inc/stlpool.hxx
@@ -26,7 +26,7 @@
 class ScStyleSheet;
 class ScDocument;
 
-class ScStyleSheetPool : public SfxStyleSheetPool
+class SC_DLLPUBLIC ScStyleSheetPool : public SfxStyleSheetPool
 {
 public:
                         ScStyleSheetPool( SfxItemPool&  rPool,


More information about the Libreoffice-commits mailing list