RepositoryExternal.mk | 4 configure.ac | 2 desktop/CppunitTest_desktop_lib.mk | 2 download.lst | 4 external/liborcus/0001-workaround-a-linking-problem-on-windows.patch | 4 external/liborcus/ExternalPackage_liborcus.mk | 8 external/liborcus/ExternalProject_liborcus.mk | 4 external/liborcus/Library_orcus-parser.mk | 3 external/liborcus/Library_orcus.mk | 1 sc/CppunitTest_sc_subsequent_filters_test.mk | 13 sc/Module_sc.mk | 1 sc/Package_res_xml.mk | 16 sc/inc/orcusfilters.hxx | 6 sc/inc/stlpool.hxx | 7 sc/qa/unit/data/xml/styles.xml | 34 sc/qa/unit/subsequent_filters-test.cxx | 239 +++++ sc/qa/unit/ucalc.cxx | 2 sc/qa/unit/ucalc_formula.cxx | 3 sc/qa/unit/ucalc_sharedformula.cxx | 1 sc/res/xml/styles.xml | 43 sc/source/core/data/stlpool.cxx | 2 sc/source/filter/inc/orcusfiltersimpl.hxx | 2 sc/source/filter/inc/orcusinterface.hxx | 48 + sc/source/filter/orcus/interface.cxx | 431 +++++++++- sc/source/filter/orcus/orcusfiltersimpl.cxx | 27 sc/source/ui/docshell/docsh.cxx | 32 sc/source/ui/docshell/docsh2.cxx | 24 sc/source/ui/inc/docsh.hxx | 3 28 files changed, 916 insertions(+), 50 deletions(-)
New commits: commit 5a2cc16f701a8e03307f6d5286e53c3305d9c6a4 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sat Sep 17 13:37:24 2016 +0200 make sure that we are not trying to load the filter lib in ucalc This casues crashes on exit as the ucalc lib loads the filter lib which is linked against the sclo lib. The sclo lib is statically linked into the ucalc code so that this causes the symbols to be two times in the program. Change-Id: I93e5a9b4dffa7c4b797ffef91b91f5f29f65348e diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 9546694..7e8654f 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -134,6 +134,7 @@ void Test::setUp() SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + m_pImpl->m_xDocShell->SetIsInUcalc(); m_pImpl->m_xDocShell->DoInitUnitTest(); m_pDoc = &m_pImpl->m_xDocShell->GetDocument(); } @@ -4436,6 +4437,7 @@ void Test::testCopyPasteFormulasExternalDoc() m_pDoc = &getDocShell().GetDocument(); ScDocShellRef xExtDocSh = new ScDocShell; + xExtDocSh->SetIsInUcalc(); OUString aExtDocName("file:///extdata.fake"); OUString aExtSh1Name("ExtSheet1"); OUString aExtSh2Name("ExtSheet2"); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 468295c..38f15fa 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -5289,6 +5289,7 @@ void Test::testFormulaMatrixResultUpdate() void Test::testExternalRef() { ScDocShellRef xExtDocSh = new ScDocShell; + xExtDocSh->SetIsInUcalc(); OUString aExtDocName("file:///extdata.fake"); OUString aExtSh1Name("Data1"); OUString aExtSh2Name("Data2"); @@ -5461,6 +5462,7 @@ void Test::testExternalRef() void Test::testExternalRangeName() { ScDocShellRef xExtDocSh = new ScDocShell; + xExtDocSh->SetIsInUcalc(); OUString aExtDocName("file:///extdata.fake"); OUString aExtSh1Name("Data1"); SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE); @@ -5557,6 +5559,7 @@ void testExtRefFuncVLOOKUP(ScDocument* pDoc, ScDocument& rExtDoc) void Test::testExternalRefFunctions() { ScDocShellRef xExtDocSh = new ScDocShell; + xExtDocSh->SetIsInUcalc(); OUString aExtDocName("file:///extdata.fake"); SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE); xExtDocSh->DoInitNew(pMed); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index f75a7a1..a66a093 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -742,6 +742,7 @@ void Test::testSharedFormulasRefUpdateExternal() // Launch an external document shell. ScDocShellRef xExtDocSh = new ScDocShell; + xExtDocSh->SetIsInUcalc(); OUString aExtDocName("file:///extdata.fake"); SfxMedium* pMed = new SfxMedium(aExtDocName, StreamMode::STD_READWRITE); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 0992786..384823e 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -594,19 +594,21 @@ bool ScDocShell::Load( SfxMedium& rMedium ) aDocument.UpdStlShtPtrsFrmNms(); #if ENABLE_ORCUS - /* Create styles that are imported through Orcus */ + if (!mbUcalcTest) + { + /* Create styles that are imported through Orcus */ - OUString aURL("$BRAND_BASE_DIR" LIBO_SHARE_FOLDER "/calc/styles.xml"); - rtl::Bootstrap::expandMacros(aURL); + OUString aURL("$BRAND_BASE_DIR" LIBO_SHARE_FOLDER "/calc/styles.xml"); + rtl::Bootstrap::expandMacros(aURL); - OUString aPath; - osl::FileBase::getSystemPathFromFileURL(aURL, aPath); + OUString aPath; + osl::FileBase::getSystemPathFromFileURL(aURL, aPath); - ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); - if (!pOrcus) - return false; + ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); - pOrcus->importODS_Styles(aDocument, aPath); + if (pOrcus) + pOrcus->importODS_Styles(aDocument, aPath); + } #endif bRet = LoadXML( &rMedium, nullptr ); @@ -2675,6 +2677,7 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : bIsInUndo ( false ), bDocumentModifiedPending( false ), bUpdateEnabled ( true ), + mbUcalcTest(rShell.mbUcalcTest), nDocumentLock ( 0 ), nCanUpdate (css::document::UpdateDocMode::ACCORDING_TO_CONFIG), pOldAutoDBRange ( nullptr ), @@ -2719,6 +2722,7 @@ ScDocShell::ScDocShell( const SfxModelFlags i_nSfxCreationFlags ) : bIsInUndo ( false ), bDocumentModifiedPending( false ), bUpdateEnabled ( true ), + mbUcalcTest ( false ), nDocumentLock ( 0 ), nCanUpdate (css::document::UpdateDocMode::ACCORDING_TO_CONFIG), pOldAutoDBRange ( nullptr ), @@ -3243,4 +3247,9 @@ bool ScDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPas return bRes; } +void ScDocShell::SetIsInUcalc() +{ + mbUcalcTest = true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 358732a..86055ed 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -61,18 +61,20 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) aDocument.UpdStlShtPtrsFrmNms(); #if ENABLE_ORCUS - /* Create styles that are imported through Orcus */ + if (!mbUcalcTest) + { + /* Create styles that are imported through Orcus */ - OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml"); - rtl::Bootstrap::expandMacros(aURL); + OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml"); + rtl::Bootstrap::expandMacros(aURL); - OUString aPath; - osl::FileBase::getSystemPathFromFileURL(aURL, aPath); + OUString aPath; + osl::FileBase::getSystemPathFromFileURL(aURL, aPath); - ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); - if (!pOrcus) - return false; - pOrcus->importODS_Styles(aDocument, aPath); + ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); + if (pOrcus) + pOrcus->importODS_Styles(aDocument, aPath); + } #endif // SetDocumentModified is not allowed anymore in Load/InitNew! diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index f8efd11..80f16e1 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -97,6 +97,7 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener bool bIsInUndo:1; bool bDocumentModifiedPending:1; bool bUpdateEnabled:1; + bool mbUcalcTest:1; // avoid loading the styles in the ucalc test sal_uInt16 nDocumentLock; sal_Int16 nCanUpdate; // stores the UpdateDocMode from loading a document till update links @@ -420,6 +421,8 @@ public: virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; void SnapVisArea( Rectangle& rRect ) const; + + void SetIsInUcalc(); }; void UpdateAcceptChangesDialog(); commit bebb04bec523efe300863a39df719795cb4379cc Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sat Sep 17 13:36:56 2016 +0200 make sure the test is not executed before the libs have been built Change-Id: Idf9e638ac559e1135182811c2bc30465efe45d3d diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk index 93b75f0..bfcbf56 100644 --- a/desktop/CppunitTest_desktop_lib.mk +++ b/desktop/CppunitTest_desktop_lib.mk @@ -20,6 +20,8 @@ $(eval $(call gb_CppunitTest_use_libraries,desktop_lib, \ cppu \ cppuhelper \ sal \ + sc \ + scfilt \ sfx \ sofficeapp \ subsequenttest \ commit 53ece9928587fedc93231a8f730455d638663296 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 23 00:51:47 2016 +0200 place the calc default style file in the share folder Change-Id: I1b8bfee1abf82c5a55cbfc5c1674b115cdfe63b8 diff --git a/sc/Package_res_xml.mk b/sc/Package_res_xml.mk index 1a25a66..383e8d5 100644 --- a/sc/Package_res_xml.mk +++ b/sc/Package_res_xml.mk @@ -9,7 +9,7 @@ $(eval $(call gb_Package_Package,sc_res_xml,$(SRCDIR)/sc/res/xml)) -$(eval $(call gb_Package_add_files,sc_res_xml,$(LIBO_BIN_FOLDER),\ +$(eval $(call gb_Package_add_files,sc_res_xml,$(LIBO_SHARE_FOLDER)/calc,\ styles.xml \ )) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 62e2a8d..0992786 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -39,6 +39,7 @@ #include <svl/documentlockfile.hxx> #include <svl/sharecontrolfile.hxx> #include <svl/urihelper.hxx> +#include <osl/file.hxx> #include "chgtrack.hxx" #include "chgviset.hxx" #include <com/sun/star/awt/Key.hpp> @@ -62,6 +63,8 @@ #include <com/sun/star/frame/XStorable2.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <config_folders.h> + #include "scabstdlg.hxx" #include <sot/formats.hxx> @@ -590,29 +593,21 @@ bool ScDocShell::Load( SfxMedium& rMedium ) aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); - #if ENABLE_ORCUS +#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 aURL("$BRAND_BASE_DIR" LIBO_SHARE_FOLDER "/calc/styles.xml"); + rtl::Bootstrap::expandMacros(aURL); - OUString aFileName = "styles.xml"; - aValidPath += aFileName; + OUString aPath; + osl::FileBase::getSystemPathFromFileURL(aURL, aPath); ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); if (!pOrcus) return false; - pOrcus->importODS_Styles(aDocument, aValidPath); - #endif + + pOrcus->importODS_Styles(aDocument, aPath); +#endif bRet = LoadXML( &rMedium, nullptr ); } diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index 46adfa8..358732a 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -19,6 +19,7 @@ #include "scitems.hxx" #include <rtl/bootstrap.hxx> +#include <osl/file.hxx> #include <svx/drawitem.hxx> #include <svl/asiancfg.hxx> #include <editeng/forbiddencharacterstable.hxx> @@ -26,6 +27,7 @@ #include <orcus/orcus_import_ods.hpp> #include <orcusfiltersimpl.hxx> #include <config_orcus.h> +#include <config_folders.h> #include "drwlayer.hxx" #include "stlpool.hxx" @@ -58,29 +60,20 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); - #if ENABLE_ORCUS +#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; + OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml"); + rtl::Bootstrap::expandMacros(aURL); - /* 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; + OUString aPath; + osl::FileBase::getSystemPathFromFileURL(aURL, aPath); ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); if (!pOrcus) return false; - pOrcus->importODS_Styles(aDocument, aValidPath); - #endif + pOrcus->importODS_Styles(aDocument, aPath); +#endif // SetDocumentModified is not allowed anymore in Load/InitNew! InitItems(); commit 1c54582a045ccd434e7c4e0cadb7275468c6a53c Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sat Aug 6 15:22:16 2016 +0530 Enable cell alignment test in orcus interface Change-Id: I1078e29d6fa0c51a4457b43806340eaf10096a92 diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index b481219..fa5cd27 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -29,6 +29,6 @@ </style:style> <style:style style:name="Name10" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:vertical-align="middle"/> - <style:paragraph-properties fo:text-align="start"/> + <style:paragraph-properties fo:text-align="end"/> </style:style> </office:styles> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 25f9ea2..9adc1a0 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -2867,7 +2867,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() /* Test for Style Name "10" * Has ver align, and hor align */ - /* + pStyleSheet = pStyleSheetPool->FindCaseIns("Name10", SfxStyleFamily::Para); CPPUNIT_ASSERT_MESSAGE("Style Name10 : Doesn't have Attribute hor justify, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_HOR_JUSTIFY, &pItem)); @@ -2881,7 +2881,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() const SvxVerJustifyItem* pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem); CPPUNIT_ASSERT_MESSAGE("Style Name10 :Error with ver justify", pVerJustify->GetValue() == SVX_VER_JUSTIFY_CENTER); - */ + } #endif commit 55fcc386401bca573a95bfed37a3de687f83884c Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sat Aug 6 13:33:42 2016 +0530 Add test for cell align in orcus interface(currently disabled) Change-Id: Icbb139cc520e4afd84986d245fab5f157431fc4e diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index ef9c337..b481219 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -27,7 +27,7 @@ <style:style style:name="Name9" style:family="table-cell" style:parent-style-name="Default"> <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-text="/"/> </style:style> - <style:style style:name="Name23" style:family="table-cell" style:parent-style-name="Text"> + <style:style style:name="Name10" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:vertical-align="middle"/> <style:paragraph-properties fo:text-align="start"/> </style:style> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index dc11d9b..25f9ea2 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -2864,6 +2864,24 @@ void ScFiltersTest::testOrcusODSStyleInterface() pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); CPPUNIT_ASSERT_MESSAGE("Style Name9 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_SLASH); + /* Test for Style Name "10" + * Has ver align, and hor align + */ + /* + pStyleSheet = pStyleSheetPool->FindCaseIns("Name10", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name10 : Doesn't have Attribute hor justify, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_HOR_JUSTIFY, &pItem)); + + const SvxHorJustifyItem* pHorJustify = static_cast<const SvxHorJustifyItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name10 :Error with hor justify", pHorJustify->GetValue() == SVX_HOR_JUSTIFY_RIGHT); + + pStyleSheet = pStyleSheetPool->FindCaseIns("Name10", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name10 : Doesn't have Attribute ver justify, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_VER_JUSTIFY, &pItem)); + + const SvxVerJustifyItem* pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name10 :Error with ver justify", pVerJustify->GetValue() == SVX_VER_JUSTIFY_CENTER); + */ } #endif commit 7e45d7effb280a1116d7a4891813c39951849eb1 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sat Aug 6 13:32:26 2016 +0530 Correct initial values for cell align in orcus interface Change-Id: I54b7def1d1d1a5b518abc6774495dd371a928ef3 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index c07ecb2..a94b6f7 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -941,8 +941,8 @@ ScOrcusStyles::xf::xf(): mnNumberFormatId(0), mnStyleXf(0), mbAlignment(false), - meHor_alignment(SVX_HOR_JUSTIFY_LEFT), - meVer_alignment(SVX_VER_JUSTIFY_CENTER) + meHor_alignment(SVX_HOR_JUSTIFY_RIGHT), + meVer_alignment(SVX_VER_JUSTIFY_BOTTOM) { } commit da891402371535f39613dc8be9e5d022e1e533a8 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sat Aug 6 00:03:50 2016 +0530 Add test for strikeout in orcus interface Change-Id: I72e917934919ddf5cc2cdd188a692c3fba94433e diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index 118561f..ef9c337 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -18,13 +18,13 @@ <style:style style:name="Name6" style:family="table-cell" style:parent-style-name="Text"> <style:text-properties style:font-name="Liberation Sans" style:text-underline-style="solid" fo:font-size="24pt" fo:color="#808080" fo:font-style="italic" style:text-underline-color="font-color" fo:font-weight="bold"/> </style:style> - <style:style style:name="Name20" style:family="table-cell" style:parent-style-name="Default"> + <style:style style:name="Name7" style:family="table-cell" style:parent-style-name="Default"> <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single"/> </style:style> - <style:style style:name="Name21" style:family="table-cell" style:parent-style-name="Default"> + <style:style style:name="Name8" style:family="table-cell" style:parent-style-name="Default"> <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-width="bold"/> </style:style> - <style:style style:name="Name22" style:family="table-cell" style:parent-style-name="Default"> + <style:style style:name="Name9" style:family="table-cell" style:parent-style-name="Default"> <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-text="/"/> </style:style> <style:style style:name="Name23" style:family="table-cell" style:parent-style-name="Text"> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 24fdfa3..dc11d9b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -2834,6 +2834,35 @@ void ScFiltersTest::testOrcusODSStyleInterface() CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Style", pUnderlineItem->GetLineStyle() == LINESTYLE_SINGLE); CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Color", pUnderlineItem->GetColor() == Color(128, 128, 128)); + /* Test for Style Name "7" + * Has strikethrough single + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name7", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name7 : Doesn't have Attribute Strikeout, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); + + const SvxCrossedOutItem* pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name7 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_SINGLE); + + /* Test for Style Name "8" + * Has strikethrough bold + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name8", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name8 : Doesn't have Attribute Strikeout, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); + + pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name7 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_BOLD); + + /* Test for Style Name "9" + * Has strikethrough slash + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name9", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name9 : Doesn't have Attribute Strikeout, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); + + pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name9 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_SLASH); } #endif commit cf03533f572a7aa542587bbc837dc124ffde66d3 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 23:24:24 2016 +0530 Add test for font in orcus interface Change-Id: Ibe2b5ef344a8f1ca27d3b59be9ac53e2c6f5b3b0 diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index 19eeff5..118561f 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -15,11 +15,8 @@ <style:style style:name="Name5" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:cell-protect="none" style:print-content="true"/> </style:style> - <style:style style:name="Name8" style:family="table-cell" style:parent-style-name="Text"> - <style:text-properties style:font-name="Liberation Sans" style:text-underline-style="solid" fo:font-size="24pt" fo:color="#808080" fo:font-style="italic" style:text-underline-color="font-color" fo:font-weight="bold" style:text-underline-width="thick"/> - </style:style> - <style:style style:name="Name9" style:family="table-cell" style:parent-style-name="Text"> - <style:text-properties style:font-name="Tahoma" style:text-underline-style="dash" fo:font-size="00pt" style:text-underline-color="#1856ff" fo:font-weight="bold" style:text-underline-width="bold"/> + <style:style style:name="Name6" style:family="table-cell" style:parent-style-name="Text"> + <style:text-properties style:font-name="Liberation Sans" style:text-underline-style="solid" fo:font-size="24pt" fo:color="#808080" fo:font-style="italic" style:text-underline-color="font-color" fo:font-weight="bold"/> </style:style> <style:style style:name="Name20" style:family="table-cell" style:parent-style-name="Default"> <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single"/> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index d57cd6b..24fdfa3 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -38,6 +38,7 @@ #include <editeng/flditem.hxx> #include <editeng/justifyitem.hxx> #include <editeng/lineitem.hxx> +#include <editeng/colritem.hxx> #include <dbdata.hxx> #include "validat.hxx" #include "formulacell.hxx" @@ -2792,6 +2793,48 @@ void ScFiltersTest::testOrcusODSStyleInterface() CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute number format, but it shouldn't.", !pStyleSheet->GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem)); + /* Test for Style "Name6" + * Has Font name, posture, weight, color, height + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name6", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); + + const SvxFontItem* pFontItem= static_cast<const SvxFontItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font name", pFontItem->GetStyleName() == "Liberation Sans"); + + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Height, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_HEIGHT, &pItem)); + + const SvxFontHeightItem* pFontHeightItem= static_cast<const SvxFontHeightItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Height", pFontHeightItem->GetHeight() == 480); + + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Posture, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_POSTURE, &pItem)); + + const SvxPostureItem* pFontPostureItem= static_cast<const SvxPostureItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Posture", pFontPostureItem->GetPosture() == ITALIC_NORMAL); + + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Weight, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_WEIGHT, &pItem)); + + const SvxWeightItem* pFontWeightItem= static_cast<const SvxWeightItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Weight", pFontWeightItem->GetWeight() == WEIGHT_BOLD); + + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Color, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_COLOR, &pItem)); + + const SvxColorItem* pFontColorItem= static_cast<const SvxColorItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Color", pFontColorItem->GetValue() == Color(128, 128, 128)); + + CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Underline, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_FONT_UNDERLINE, &pItem)); + + const SvxUnderlineItem* pUnderlineItem= static_cast<const SvxUnderlineItem*>(pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Style", pUnderlineItem->GetLineStyle() == LINESTYLE_SINGLE); + CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Color", pUnderlineItem->GetColor() == Color(128, 128, 128)); + + } #endif commit 301e0dd1d223cea43390bc886c3ae39d6cadb5e5 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 14:36:53 2016 +0530 Add test for cell protection in orcus interface Change-Id: I952b5897bf3f728d103c43d93cadeffb92d1c3a9 diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index 85c1e49..19eeff5 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -6,16 +6,13 @@ <style:style style:name="Name2" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties fo:diagonal-bl-tr="1.74pt dashed #ffccee" fo:diagonal-tl-br="0.74pt dash-dot #120000" fo:border-left="none" fo:border-right="0.74pt dotted #ff0000"/> </style:style> - <style:style style:name="Name4" style:family="table-cell" style:parent-style-name="Text"> - <style:table-cell-properties fo:border-top="0.74pt double-border #000000" fo:border-bottom="none" fo:border-left="0.74pt solid #000000" fo:border-right="0.74pt dotted #000000"/> - </style:style> - <style:style style:name="Name5" style:family="table-cell" style:parent-style-name="Text"> + <style:style style:name="Name3" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:cell-protect="hidden-and-protected" style:print-content="true"/> </style:style> - <style:style style:name="Name6" style:family="table-cell" style:parent-style-name="Text"> + <style:style style:name="Name4" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:cell-protect="protected formula-hidden" style:print-content="false"/> </style:style> - <style:style style:name="Name7" style:family="table-cell" style:parent-style-name="Text"> + <style:style style:name="Name5" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties style:cell-protect="none" style:print-content="true"/> </style:style> <style:style style:name="Name8" style:family="table-cell" style:parent-style-name="Text"> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 8c1b490..d57cd6b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -65,6 +65,7 @@ #include "externalrefmgr.hxx" #include <stlpool.hxx> #include <config_orcus.h> +#include <attrib.hxx> #if ENABLE_ORCUS #include <orcusfiltersimpl.hxx> @@ -2709,7 +2710,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() ASSERT_DOUBLES_EQUAL_MESSAGE("Error with top width", 1, pBoxItem->GetTop()->GetWidth()); ASSERT_DOUBLES_EQUAL_MESSAGE("Error with bottom width", 1, pBoxItem->GetBottom()->GetWidth()); - CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute border, but it shouldn't.", + CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute Protection, but it shouldn't.", !pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute font, but it shouldn't.", !pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); @@ -2754,6 +2755,43 @@ void ScFiltersTest::testOrcusODSStyleInterface() !pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); CPPUNIT_ASSERT_MESSAGE("Style Name2 : Has Attribute number format, but it shouldn't.", !pStyleSheet->GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem)); + + /* Test for Style "Name3" + * Hidden, protected and content is printed. + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name3", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name3 : Doesn't have Attribute Protection, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); + + CPPUNIT_ASSERT_MESSAGE("Style Name 3 : Error with Protection attribute." ,ScProtectionAttr(true, false, true, true) == *pItem); + + /* Test for Style "Name4" + * Hidden, protected and content is printed. + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name4", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name4 : Doesn't have Attribute Protection, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); + + CPPUNIT_ASSERT_MESSAGE("Style Name 4 : Error with Protection attribute." ,ScProtectionAttr(true, true, false, false) == *pItem); + + /* Test for Style "Name3" + * Hidden, protected and content is printed. + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name5", SfxStyleFamily::Para); + CPPUNIT_ASSERT_MESSAGE("Style Name5 : Doesn't have Attribute Protection, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); + + CPPUNIT_ASSERT_MESSAGE("Style Name 5 : Error with Protection attribute." ,ScProtectionAttr(false, false, false, true) == *pItem); + + CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute Border, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_BORDER, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name5: Has Attribute background, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute font, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute number format, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem)); + } #endif commit cc65cc7846758cc3aad987be5ab7b70d4c68f39a Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 00:13:37 2016 +0530 Add diagonal border test for orcus interface Change-Id: I762e3b5f634b96664a3687e89b1a117895265bee diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml index f6f9183..85c1e49 100644 --- a/sc/qa/unit/data/xml/styles.xml +++ b/sc/qa/unit/data/xml/styles.xml @@ -4,10 +4,7 @@ <style:table-cell-properties fo:background-color="#feffcc" fo:border="0.06pt dotted #ffcc12"/> </style:style> <style:style style:name="Name2" style:family="table-cell" style:parent-style-name="Text"> - <style:table-cell-properties fo:border-top="0.74pt fine-dashed #ffee11" fo:border-bottom="1.74pt double-thin #aeee11" fo:border-left="0.74pt none #11ee11" fo:border-right="0.22pt dash-dot-dot #05ee11"/> - </style:style> - <style:style style:name="Name3" style:family="table-cell" style:parent-style-name="Text"> - <style:table-cell-properties fo:diagonal-bl-tr="1.74pt dashed #ffccee" fo:diagonal-tl-br="0.74pt dash-dot #120000" fo:border-left="none" fo:border-right="0.74pt dotted #000000"/> + <style:table-cell-properties fo:diagonal-bl-tr="1.74pt dashed #ffccee" fo:diagonal-tl-br="0.74pt dash-dot #120000" fo:border-left="none" fo:border-right="0.74pt dotted #ff0000"/> </style:style> <style:style style:name="Name4" style:family="table-cell" style:parent-style-name="Text"> <style:table-cell-properties fo:border-top="0.74pt double-border #000000" fo:border-bottom="none" fo:border-left="0.74pt solid #000000" fo:border-right="0.74pt dotted #000000"/> diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 80e13fc..8c1b490 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -37,6 +37,7 @@ #include <editeng/fontitem.hxx> #include <editeng/flditem.hxx> #include <editeng/justifyitem.hxx> +#include <editeng/lineitem.hxx> #include <dbdata.hxx> #include "validat.hxx" #include "formulacell.hxx" @@ -2681,6 +2682,9 @@ void ScFiltersTest::testOrcusODSStyleInterface() pOrcus->importODS_Styles(aDoc, aValidPath); ScStyleSheetPool* pStyleSheetPool = aDoc.GetStyleSheetPool(); + /* Test cases for Style "Name1" + * Has Border and Fill. + */ ScStyleSheet* pStyleSheet = pStyleSheetPool->FindCaseIns("Name1", SfxStyleFamily::Para); const SfxPoolItem* pItem = nullptr; @@ -2704,6 +2708,52 @@ void ScFiltersTest::testOrcusODSStyleInterface() 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()); + + CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute border, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute font, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name1 : Has Attribute number format, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem)); + + /* Test for Style "Name2" + * Has 4 sided borders + Diagonal borders. + */ + pStyleSheet = pStyleSheetPool->FindCaseIns("Name2", SfxStyleFamily::Para); + + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Doesn't have Attribute background, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_BORDER, &pItem)); + + pBoxItem = static_cast<const SvxBoxItem*>(pItem); + CPPUNIT_ASSERT_EQUAL(Color(0, 0, 0), pBoxItem->GetLeft()->GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(255, 0, 0), pBoxItem->GetRight()->GetColor()); + CPPUNIT_ASSERT_EQUAL(pBoxItem->GetLeft()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::SOLID); + CPPUNIT_ASSERT_EQUAL(pBoxItem->GetRight()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DOTTED); + ASSERT_DOUBLES_EQUAL_MESSAGE("Error with left width", 0, pBoxItem->GetLeft()->GetWidth()); + ASSERT_DOUBLES_EQUAL_MESSAGE("Error with right width", 14, pBoxItem->GetRight()->GetWidth()); + + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Doesn't have Attribute diagonal(tl-br) border, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_BORDER_TLBR, &pItem)); + + const SvxLineItem* pTLBR= static_cast<const SvxLineItem*>(pItem); + CPPUNIT_ASSERT_EQUAL(Color(18, 0, 0), pTLBR->GetLine()->GetColor()); + CPPUNIT_ASSERT_EQUAL(pTLBR->GetLine()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DASH_DOT); + ASSERT_DOUBLES_EQUAL_MESSAGE("Error with diagonal tl-br width", 14, pTLBR->GetLine()->GetWidth()); + + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Doesn't have Attribute diagonal(bl-tr) border, but it should have.", + pStyleSheet->GetItemSet().HasItem(ATTR_BORDER_BLTR, &pItem)); + + const SvxLineItem* pBLTR= static_cast<const SvxLineItem*>(pItem); + CPPUNIT_ASSERT_EQUAL(Color(255, 204, 238), pBLTR->GetLine()->GetColor()); + CPPUNIT_ASSERT_EQUAL(pBLTR->GetLine()->GetBorderLineStyle(), ::com::sun::star::table::BorderLineStyle::DASHED); + ASSERT_DOUBLES_EQUAL_MESSAGE("Error with diagonal tl-br width", 34, pBLTR->GetLine()->GetWidth()); + + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Has Attribute background, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Has Attribute font, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); + CPPUNIT_ASSERT_MESSAGE("Style Name2 : Has Attribute number format, but it shouldn't.", + !pStyleSheet->GetItemSet().HasItem(ATTR_VALUE_FORMAT, &pItem)); } #endif commit a531c8ce9e0b7fad6efe58f089c4e58411ff9dd1 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 00:12:11 2016 +0530 Fix a bug in border import in orcus interface Change-Id: Ic058787b1779f7731c0fe60d73b221011abe2b6c diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 72a2f4e..c07ecb2 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -898,7 +898,7 @@ void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); aDiagonal_TLBR.SetLine(&aLine); } - if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_bl_tr) + else if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_bl_tr) { editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); aDiagonal_BLTR.SetLine(&aLine); commit ab4aeb14edeedda65d29db228df16b50de447ede Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 00:10:43 2016 +0530 Fix a typo in border style import in orcus interface Change-Id: Ib8dcf0cb031ed39987b14706026f658bbea0a080 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index c5569a5..72a2f4e 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -896,12 +896,12 @@ void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_tl_br) { editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); - aDiagonal_BLTR.SetLine(&aLine); + aDiagonal_TLBR.SetLine(&aLine); } if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_bl_tr) { editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); - aDiagonal_TLBR.SetLine(&aLine); + aDiagonal_BLTR.SetLine(&aLine); } else { commit 9cab12f925e5b6656d9e8e0c58f81e0833dc12a6 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Aug 5 00:09:10 2016 +0530 Initialize border attributes in orcus interface Change-Id: I99994147830e96bea07f52fc6f2575f05cb0a40f diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index c6d3d5a..e467b85 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -299,6 +299,8 @@ private: SvxBorderStyle mestyle; Color maColor; double mnWidth; + + border_line(); }; std::map<orcus::spreadsheet::border_direction_t, border_line> border_lines; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index e6dedef..c5569a5 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -847,6 +847,14 @@ void ScOrcusStyles::protection::applyToItemSet(SfxItemSet& rSet) const ScOrcusStyles::border::border(): mbHasBorderAttr(false) { + border_line(); +} + +ScOrcusStyles::border::border_line::border_line(): + mestyle(::com::sun::star::table::BorderLineStyle::SOLID), + maColor(COL_WHITE), + mnWidth(0) +{ } namespace { commit 759b2fcb2ff3e916e7f69d182c74bac03e9f2da3 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Mon Aug 1 21:00:03 2016 +0530 Disable printing default protection in imported styles Change-Id: Iba85a8a401542496f2313af576344d8ffdf768fe diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index b9d8f66..e6dedef 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -835,7 +835,7 @@ ScOrcusStyles::protection::protection(): mbLocked(true), mbPrintContent(false), mbFormulaHidden(false), - mbHasProtectionAttr(true) + mbHasProtectionAttr(false) { } commit 2210d4bb2beebb392939cb6b94d00d24cac81a9d Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Mon Aug 1 19:20:26 2016 +0530 Make sc/res/xml/styles.xml install on every build Change-Id: I1656a24057d9aae513cd9e7e736bfb7b258ba733 diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 642c6b8..cdba1fe 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Module_add_targets,sc,\ Library_scfilt \ $(call gb_Helper_optional,DESKTOP,Library_scui) \ $(call gb_Helper_optional,OPENCL,Package_opencl) \ + Package_res_xml \ )) $(eval $(call gb_Module_add_l10n_targets,sc,\ diff --git a/sc/Package_res_xml.mk b/sc/Package_res_xml.mk new file mode 100644 index 0000000..1a25a66 --- /dev/null +++ b/sc/Package_res_xml.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Package_Package,sc_res_xml,$(SRCDIR)/sc/res/xml)) + +$(eval $(call gb_Package_add_files,sc_res_xml,$(LIBO_BIN_FOLDER),\ + styles.xml \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/res/xml/styles.xml b/sc/res/xml/styles.xml new file mode 100644 index 0000000..f6f9183 --- /dev/null +++ b/sc/res/xml/styles.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<office:styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"> + <style:style style:name="Name1" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:background-color="#feffcc" fo:border="0.06pt dotted #ffcc12"/> + </style:style> + <style:style style:name="Name2" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:border-top="0.74pt fine-dashed #ffee11" fo:border-bottom="1.74pt double-thin #aeee11" fo:border-left="0.74pt none #11ee11" fo:border-right="0.22pt dash-dot-dot #05ee11"/> + </style:style> + <style:style style:name="Name3" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:diagonal-bl-tr="1.74pt dashed #ffccee" fo:diagonal-tl-br="0.74pt dash-dot #120000" fo:border-left="none" fo:border-right="0.74pt dotted #000000"/> + </style:style> + <style:style style:name="Name4" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:border-top="0.74pt double-border #000000" fo:border-bottom="none" fo:border-left="0.74pt solid #000000" fo:border-right="0.74pt dotted #000000"/> + </style:style> + <style:style style:name="Name5" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="hidden-and-protected" style:print-content="true"/> + </style:style> + <style:style style:name="Name6" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="protected formula-hidden" style:print-content="false"/> + </style:style> + <style:style style:name="Name7" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="none" style:print-content="true"/> + </style:style> + <style:style style:name="Name8" style:family="table-cell" style:parent-style-name="Text"> + <style:text-properties style:font-name="Liberation Sans" style:text-underline-style="solid" fo:font-size="24pt" fo:color="#808080" fo:font-style="italic" style:text-underline-color="font-color" fo:font-weight="bold" style:text-underline-width="thick"/> + </style:style> + <style:style style:name="Name9" style:family="table-cell" style:parent-style-name="Text"> + <style:text-properties style:font-name="Tahoma" style:text-underline-style="dash" fo:font-size="00pt" style:text-underline-color="#1856ff" fo:font-weight="bold" style:text-underline-width="bold"/> + </style:style> + <style:style style:name="Name20" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single"/> + </style:style> + <style:style style:name="Name21" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-width="bold"/> + </style:style> + <style:style style:name="Name22" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-text="/"/> + </style:style> + <style:style style:name="Name23" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:vertical-align="middle"/> + <style:paragraph-properties fo:text-align="start"/> + </style:style> +</office:styles> commit f13cea7a9c074e21102eacb16448454f38961787 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Mon Aug 1 09:37:19 2016 +0530 Add Test File for Orcus ODF styles import Change-Id: I3131fe598b1af4731214d02e1ef09e7ab10f4761 diff --git a/sc/qa/unit/data/xml/styles.xml b/sc/qa/unit/data/xml/styles.xml new file mode 100644 index 0000000..f6f9183 --- /dev/null +++ b/sc/qa/unit/data/xml/styles.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<office:styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"> + <style:style style:name="Name1" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:background-color="#feffcc" fo:border="0.06pt dotted #ffcc12"/> + </style:style> + <style:style style:name="Name2" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:border-top="0.74pt fine-dashed #ffee11" fo:border-bottom="1.74pt double-thin #aeee11" fo:border-left="0.74pt none #11ee11" fo:border-right="0.22pt dash-dot-dot #05ee11"/> + </style:style> + <style:style style:name="Name3" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:diagonal-bl-tr="1.74pt dashed #ffccee" fo:diagonal-tl-br="0.74pt dash-dot #120000" fo:border-left="none" fo:border-right="0.74pt dotted #000000"/> + </style:style> + <style:style style:name="Name4" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties fo:border-top="0.74pt double-border #000000" fo:border-bottom="none" fo:border-left="0.74pt solid #000000" fo:border-right="0.74pt dotted #000000"/> + </style:style> + <style:style style:name="Name5" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="hidden-and-protected" style:print-content="true"/> + </style:style> + <style:style style:name="Name6" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="protected formula-hidden" style:print-content="false"/> + </style:style> + <style:style style:name="Name7" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:cell-protect="none" style:print-content="true"/> + </style:style> + <style:style style:name="Name8" style:family="table-cell" style:parent-style-name="Text"> + <style:text-properties style:font-name="Liberation Sans" style:text-underline-style="solid" fo:font-size="24pt" fo:color="#808080" fo:font-style="italic" style:text-underline-color="font-color" fo:font-weight="bold" style:text-underline-width="thick"/> + </style:style> + <style:style style:name="Name9" style:family="table-cell" style:parent-style-name="Text"> + <style:text-properties style:font-name="Tahoma" style:text-underline-style="dash" fo:font-size="00pt" style:text-underline-color="#1856ff" fo:font-weight="bold" style:text-underline-width="bold"/> + </style:style> + <style:style style:name="Name20" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single"/> + </style:style> + <style:style style:name="Name21" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-width="bold"/> + </style:style> + <style:style style:name="Name22" style:family="table-cell" style:parent-style-name="Default"> + <style:text-properties style:text-line-through-style="solid" style:text-line-through-type="single" style:text-line-through-text="/"/> + </style:style> + <style:style style:name="Name23" style:family="table-cell" style:parent-style-name="Text"> + <style:table-cell-properties style:vertical-align="middle"/> + <style:paragraph-properties fo:text-align="start"/> + </style:style> +</office:styles> commit 983d1c4d4c6f69c6b4e2d2fa88d408e35ed6b220 Author: Jaskaran Singh <jvsg1...@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 42aa391..80e13fc 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 @@ -271,6 +285,11 @@ public: CPPUNIT_TEST(testComplexIconSetsXLSX); CPPUNIT_TEST(testCondFormatParentXLSX); CPPUNIT_TEST(testColorScaleNumWithRefXLSX); + + #if ENABLE_ORCUS + CPPUNIT_TEST(testOrcusODSStyleInterface); + #endif + CPPUNIT_TEST(testLiteralInFormulaXLS); CPPUNIT_TEST(testNumberFormatHTML); @@ -2646,6 +2665,48 @@ void ScFiltersTest::testColorScaleNumWithRefXLSX() xDocSh->DoClose(); } +#if ENABLE_ORCUS +void ScFiltersTest::testOrcusODSStyleInterface() +{ + ScDocument aDoc; + 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 */ + OUString aValidPath; + osl::FileBase::getSystemPathFromFileURL(aFullUrl, aValidPath); + + 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 c2dfe8f2fdb7b6df0bc939530dcef25605f7c86c Author: Jaskaran Singh <jvsg1...@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 c364896..62e2a8d 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> @@ -588,13 +590,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 04989b09..46adfa8 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 9b49fe9e47b561ae0bb665cd7f565c4262c5e6c4 Author: Jaskaran Singh <jvsg1...@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 47df0c0..ef3e197 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) \ )) @@ -118,6 +119,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 9cb0042e9552e055fc34aea6abcb6c5359be1302 Author: Jaskaran Singh <jvsg1...@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 7155255..2b7f1f0 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, @@ -43,7 +43,7 @@ public: SfxStyleSheetBase* GetActualStyleSheet () { return pActualStyleSheet; } - void SC_DLLPUBLIC CreateStandardStyles(); + void CreateStandardStyles(); void CopyStdStylesFrom( ScStyleSheetPool* pSrcPool ); void CopyStyleFrom( ScStyleSheetPool* pSrcPool, commit 16b8a44c6067b0ab72da730d9b24cff7bb09a104 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Thu Jul 28 15:41:02 2016 +0530 Add facility for cell alignment to orcus interface Change-Id: If073c34bc9898f2a069815892431a2db22f43d3a diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index f3520b4..c6d3d5a 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -15,6 +15,7 @@ #include <tools/color.hxx> #include <tools/fontenum.hxx> +#include <editeng/svxenum.hxx> #include "sharedformulagroups.hxx" @@ -348,6 +349,10 @@ private: size_t mnProtectionId; size_t mnNumberFormatId; size_t mnStyleXf; + bool mbAlignment; + + SvxCellHorJustify meHor_alignment; + SvxCellVerJustify meVer_alignment; xf(); }; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index ff8c7465..b9d8f66 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -39,6 +39,7 @@ #include <editeng/fhgtitem.hxx> #include <editeng/lineitem.hxx> #include <editeng/crossedoutitem.hxx> +#include <editeng/justifyitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -930,7 +931,10 @@ ScOrcusStyles::xf::xf(): mnBorderId(0), mnProtectionId(0), mnNumberFormatId(0), - mnStyleXf(0) + mnStyleXf(0), + mbAlignment(false), + meHor_alignment(SVX_HOR_JUSTIFY_LEFT), + meVer_alignment(SVX_VER_JUSTIFY_CENTER) { } @@ -992,6 +996,12 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) const number_format& rFormat = maNumberFormats[nNumberFormatId]; if (rFormat.mbHasNumberFormatAttr) rFormat.applyToItemSet(rSet, mrDoc); + + if(rXf.mbAlignment) + { + rSet.Put(SvxHorJustifyItem(rXf.meHor_alignment, ATTR_HOR_JUSTIFY)); + rSet.Put(SvxVerJustifyItem(rXf.meVer_alignment, ATTR_VER_JUSTIFY)); + } } void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, size_t xfId) @@ -1463,12 +1473,48 @@ void ScOrcusStyles::set_xf_apply_alignment(bool /*b*/) { } -void ScOrcusStyles::set_xf_horizontal_alignment(orcus::spreadsheet::hor_alignment_t /*align*/) +void ScOrcusStyles::set_xf_horizontal_alignment(orcus::spreadsheet::hor_alignment_t align) { + switch (align) + { + case os::hor_alignment_t::left: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_LEFT; + break; + case os::hor_alignment_t::right: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_RIGHT; + break; + case os::hor_alignment_t::center: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_CENTER; + break; + case os::hor_alignment_t::justified: + maCurrentXF.meHor_alignment = SVX_HOR_JUSTIFY_STANDARD; + break; + default: + ; + } + maCurrentXF.mbAlignment = true; } -void ScOrcusStyles::set_xf_vertical_alignment(orcus::spreadsheet::ver_alignment_t /*align*/) +void ScOrcusStyles::set_xf_vertical_alignment(orcus::spreadsheet::ver_alignment_t align) { + switch (align) + { + case os::ver_alignment_t::top: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_TOP; + break; + case os::ver_alignment_t::bottom: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_BOTTOM; + break; + case os::ver_alignment_t::middle: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_CENTER; + break; + case os::ver_alignment_t::justified: + maCurrentXF.meVer_alignment = SVX_VER_JUSTIFY_STANDARD; + break; + default: + ; + } + maCurrentXF.mbAlignment = true; } // cell style entry commit 933ae1905617a2e2cc177a34a7060a2b26e5827c Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Thu Jul 28 15:40:22 2016 +0530 Reform orcus interface to set border width Change-Id: Ic93b334205221548e4bd7920551034b1ccee4fa8 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 9afc218..f3520b4 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -417,7 +417,7 @@ public: orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override; - virtual void set_border_width(orcus::spreadsheet::border_direction_t dir, orcus::length_t width) override; + virtual void set_border_width(orcus::spreadsheet::border_direction_t dir, double val, orcus::length_unit_t unit) override; virtual size_t commit_border() override; // cell protection diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 5f30120..ff8c7465 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -1318,10 +1318,10 @@ void ScOrcusStyles::set_border_color(orcus::spreadsheet::border_direction_t dir, current_line.maColor = Color(alpha, red, green, blue); } -void ScOrcusStyles::set_border_width(orcus::spreadsheet::border_direction_t dir, orcus::length_t width ) +void ScOrcusStyles::set_border_width(orcus::spreadsheet::border_direction_t dir, double val, orcus::length_unit_t unit ) { border::border_line& current_line = maCurrentBorder.border_lines[dir]; - current_line.mnWidth = translateToInternal(width.value, width.unit); + current_line.mnWidth = translateToInternal(val, unit); } size_t ScOrcusStyles::commit_border() commit 872c5e0c807ae248387ee425615e4c8080d01221 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Thu Jul 28 14:00:46 2016 +0530 Add odf strikeout to orcus interface Change-Id: Ibf8d1e7b0272fe4112fda0249eafef1aa5438d9a diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 9754ea4..9afc218 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -260,10 +260,13 @@ private: bool mbHasFontAttr; bool mbHasUnderlineAttr; + bool mbHasStrikeout; FontLineStyle meUnderline; Color maUnderlineColor; + FontStrikeout meStrikeout; + font(); void applyToItemSet(SfxItemSet& rSet) const; @@ -390,6 +393,10 @@ public: orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override; + virtual void set_strikethrough_style(orcus::spreadsheet::strikethrough_style_t s) override; + virtual void set_strikethrough_type(orcus::spreadsheet::strikethrough_type_t s) override; + virtual void set_strikethrough_width(orcus::spreadsheet::strikethrough_width_t s) override; + virtual void set_strikethrough_text(orcus::spreadsheet::strikethrough_text_t s) override; virtual size_t commit_font() override; // fill diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 1be81262..5f30120 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -38,6 +38,7 @@ #include <editeng/fontitem.hxx> #include <editeng/fhgtitem.hxx> #include <editeng/lineitem.hxx> +#include <editeng/crossedoutitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -758,8 +759,10 @@ ScOrcusStyles::font::font(): maColor(COL_WHITE), mbHasFontAttr(false), mbHasUnderlineAttr(false), + mbHasStrikeout(false), meUnderline(LINESTYLE_NONE), - maUnderlineColor(COL_WHITE) + maUnderlineColor(COL_WHITE), + meStrikeout(STRIKEOUT_NONE) { } @@ -791,11 +794,18 @@ std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const { - FontItalic eItalic = mbItalic ? ITALIC_NORMAL : ITALIC_NONE; - rSet.Put(SvxPostureItem(eItalic, ATTR_FONT_POSTURE)); + if (mbHasFontAttr) + { + FontItalic eItalic = mbItalic ? ITALIC_NORMAL : ITALIC_NONE; + rSet.Put(SvxPostureItem(eItalic, ATTR_FONT_POSTURE)); + + FontWeight eWeight = mbBold ? WEIGHT_BOLD : WEIGHT_NORMAL; + rSet.Put(SvxWeightItem(eWeight, ATTR_FONT_WEIGHT)); - FontWeight eWeight = mbBold ? WEIGHT_BOLD : WEIGHT_NORMAL; - rSet.Put(SvxWeightItem(eWeight, ATTR_FONT_WEIGHT)); + rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); + rSet.Put( SvxFontItem( FAMILY_DONTKNOW, maName, maName, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT )); + rSet.Put( SvxFontHeightItem (translateToInternal(mnSize, orcus::length_unit_t::point), 100, ATTR_FONT_HEIGHT)); + } if (mbHasUnderlineAttr) { @@ -804,9 +814,8 @@ void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const rSet.Put(aUnderline); } - rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); - rSet.Put( SvxFontItem( FAMILY_DONTKNOW, maName, maName, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT )); - rSet.Put( SvxFontHeightItem (translateToInternal(mnSize, orcus::length_unit_t::point), 100, ATTR_FONT_HEIGHT)); + if (mbHasStrikeout) + rSet.Put(SvxCrossedOutItem(meStrikeout, ATTR_FONT_CROSSEDOUT)); } void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const @@ -941,8 +950,7 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) } const font& rFont = maFonts[nFontId]; - if (rFont.mbHasFontAttr) - rFont.applyToItemSet(rSet); + rFont.applyToItemSet(rSet); size_t nFillId = rXf.mnFillId; if (nFillId >= maFills.size()) @@ -1141,6 +1149,66 @@ void ScOrcusStyles::set_font_color(orcus::spreadsheet::color_elem_t alpha, maCurrentFont.maColor = Color(alpha, red, green, blue); } +void ScOrcusStyles::set_strikethrough_style(orcus::spreadsheet::strikethrough_style_t /*s*/) +{ +} + +void ScOrcusStyles::set_strikethrough_type(orcus::spreadsheet::strikethrough_type_t s) +{ + if (maCurrentFont.meStrikeout != STRIKEOUT_BOLD && + maCurrentFont.meStrikeout != STRIKEOUT_SLASH && + maCurrentFont.meStrikeout != STRIKEOUT_X) + { + switch (s) + { + case os::strikethrough_type_t::unknown: + maCurrentFont.meStrikeout = STRIKEOUT_DONTKNOW; + break; + case os::strikethrough_type_t::none: + maCurrentFont.meStrikeout = STRIKEOUT_NONE; + break; + case os::strikethrough_type_t::single: + maCurrentFont.meStrikeout = STRIKEOUT_SINGLE; + break; + case os::strikethrough_type_t::double_type: + maCurrentFont.meStrikeout = STRIKEOUT_DOUBLE; + break; + default: + ; + } + } + maCurrentFont.mbHasStrikeout = true; +} + +void ScOrcusStyles::set_strikethrough_width(orcus::spreadsheet::strikethrough_width_t s) +{ + switch (s) + { + case os::strikethrough_width_t::bold: + maCurrentFont.meStrikeout = STRIKEOUT_BOLD; + break; + default: + ; + } + maCurrentFont.mbHasStrikeout = true; +} + +void ScOrcusStyles::set_strikethrough_text(orcus::spreadsheet::strikethrough_text_t s) +{ + switch (s) + { + case os::strikethrough_text_t::slash: + maCurrentFont.meStrikeout = STRIKEOUT_SLASH; + break; + case os::strikethrough_text_t::cross: + maCurrentFont.meStrikeout = STRIKEOUT_X; + break; + default: + ; + } + maCurrentFont.mbHasStrikeout = true; +} + size_t ScOrcusStyles::commit_font() { SAL_INFO("sc.orcus.style", "commit font"); commit 7c48d3d49463eae8afb4738b9b79f8024f773074 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Jul 22 21:03:43 2016 +0530 Reform orcus unit warning Change-Id: Iec221f019a65fcb42281f76b724ea306587f66c8 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 4591843..1be81262 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -258,7 +258,8 @@ double translateToInternal(double nVal, orcus::length_unit_t unit) return nVal * 20.0 * 72.0 / 2.54; break; case orcus::length_unit_t::unknown: - SAL_WARN("sc.orcus", "unknown unit"); + if (nVal != 0) + SAL_WARN("sc.orcus", "unknown unit"); break; default: break; commit 0dae3aacbf46ddd7dbef10b3f376ca2ad7665212 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Jul 22 18:38:45 2016 +0530 Fix reorder and overflow warning in orcus interface Change-Id: I700463434a99a87e485b61bac78513a286f507cd diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index b6f05b4..4591843 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -753,18 +753,19 @@ ScOrcusStyles::ScOrcusStyles(ScDocument& rDoc): ScOrcusStyles::font::font(): mbBold(false), mbItalic(false), + mnSize(10), + maColor(COL_WHITE), mbHasFontAttr(false), mbHasUnderlineAttr(false), - mnSize(10), meUnderline(LINESTYLE_NONE), - maColor(COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE) + maUnderlineColor(COL_WHITE) { } ScOrcusStyles::fill::fill(): maPattern(""), - maFgColor(Color(COL_WHITE, COL_WHITE, COL_WHITE)), - maBgColor(Color(COL_WHITE, COL_WHITE, COL_WHITE)), + maFgColor(COL_WHITE), + maBgColor(COL_WHITE), mbHasFillAttr(false) { } commit 77e568cd4c0e20fe26219487f89e56d80a11713a Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Fri Jul 22 18:36:57 2016 +0530 Remove unused variable from orcus interface Change-Id: I3883b5361824838a3cb802cb9c577d4d39c070b2 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index 32b5049..9754ea4 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -262,8 +262,6 @@ private: bool mbHasUnderlineAttr; FontLineStyle meUnderline; - FontLineStyle meUnderlineType; - FontLineStyle meUnderlineWidth; Color maUnderlineColor; font(); commit 862846ef4797bdcc0f2cd78178bf3e3d451222c6 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Jul 19 23:18:30 2016 +0200 fix assert in number format orcus import Change-Id: Ib0a8ce074c9245fa8ba66008524887f015c7bf76 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index b0ce0a4..b6f05b4 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -906,7 +906,7 @@ void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& rSet, ScDocument& { if (nCheckPos == 0) { - rSet.Put(SfxUInt32Item(nKey, ATTR_VALUE_FORMAT)); + rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nKey)); } } else commit 99b353e00c2cdcae92c1632e4e14fa4033ba2277 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Jul 19 23:25:43 2016 +0200 use ScDocument's number formatter Change-Id: Iff04869b8e8ba73575bd5d336db42f1e08cec5d8 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index c33151e..32b5049 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -333,7 +333,7 @@ private: bool mbHasNumberFormatAttr; number_format(); - void applyToItemSet(SfxItemSet& rSet) const; + void applyToItemSet(SfxItemSet& rSet, ScDocument& rDoc) const; }; number_format maCurrentNumberFormat; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index b6b12b4..b0ce0a4 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -894,15 +894,15 @@ void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const rSet.Put(aBoxItem); } -void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& rSet) const +void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& rSet, ScDocument& rDoc) const { sal_uInt32 nKey; sal_Int32 nCheckPos; - SvNumberFormatter NumberFormatter(comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US); + SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); OUString Code = maCode; /* <-- Done because the SvNumberFormatter::PutEntry demands a non const NumFormat Code*/ sal_Int16 type = css::util::NumberFormat::ALL; - if (NumberFormatter.PutEntry(Code, nCheckPos, type, nKey, LANGUAGE_ENGLISH_US)) + if (pFormatter->PutEntry(Code, nCheckPos, type, nKey, LANGUAGE_ENGLISH_US)) { if (nCheckPos == 0) { @@ -981,7 +981,7 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) } const number_format& rFormat = maNumberFormats[nNumberFormatId]; if (rFormat.mbHasNumberFormatAttr) - rFormat.applyToItemSet(rSet); + rFormat.applyToItemSet(rSet, mrDoc); } void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, size_t xfId) commit 6efdcc4c0fa42e3a7b01924d6e5cf576a1ded8d8 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Jul 19 23:06:36 2016 +0200 fix assert when opening a calc document in new orcus styles import Change-Id: I6e62ddaeb20687bf3ad3e7de86f749e1047363b9 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 6be6374..b6b12b4 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -797,8 +797,9 @@ void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const if (mbHasUnderlineAttr) { - rSet.Put(SvxUnderlineItem(meUnderline, ATTR_FONT_UNDERLINE)); - rSet.Put(SvxColorItem(maUnderlineColor, ATTR_FONT_UNDERLINE)); + SvxUnderlineItem aUnderline(meUnderline, ATTR_FONT_UNDERLINE); + aUnderline.SetColor(maUnderlineColor); + rSet.Put(aUnderline); } rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); commit 99dfc082da2886975b32c66a7812122194ba63ce Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sun Jul 17 14:52:13 2016 +0530 Reform function to apply protection in orcus interface Change-Id: Idb25283fbd504d64c3518b1a4b742e9e50f6ccff diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 5282344..6be6374 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -22,6 +22,7 @@ #include "scitems.hxx" #include "patattr.hxx" #include "docpool.hxx" +#include "attrib.hxx" #include <editeng/postitem.hxx> #include <editeng/wghtitem.hxx> @@ -827,22 +828,7 @@ ScOrcusStyles::protection::protection(): void ScOrcusStyles::protection::applyToItemSet(SfxItemSet& rSet) const { - if (mbHidden) - rSet.Put(SvxCharHiddenItem(mbHidden, ATTR_PROTECTION)); - - if (!mbLocked) - { - SvxProtectItem aItem(ATTR_PROTECTION); - - aItem.SetContentProtect (false); - aItem.SetSizeProtect (false); - aItem.SetPosProtect (false); - - rSet.Put(aItem); - } - - if (!mbPrintContent) - rSet.Put(SvxPrintItem(ATTR_PROTECTION, mbPrintContent)); + rSet.Put(ScProtectionAttr(mbLocked, mbFormulaHidden, mbHidden, mbPrintContent)); } ScOrcusStyles::border::border(): commit 6670cc357a015eb497437a559c25105a08c54474 Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Sun Jul 17 13:48:45 2016 +0530 Add diagonal borders to calc orcus interface Change-Id: Ia0d41baa4e4d6fdb5872c8ec3f462ff02a32f518 diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index 846ef07..5282344 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -36,6 +36,7 @@ #include <editeng/prntitem.hxx> #include <editeng/fontitem.hxx> #include <editeng/fhgtitem.hxx> +#include <editeng/lineitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> @@ -877,16 +878,33 @@ SvxBoxItemLine getDirection(os::border_direction_t dir) void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const { - SvxBoxItem aItem(ATTR_BORDER); + SvxBoxItem aBoxItem(ATTR_BORDER); + SvxLineItem aDiagonal_TLBR(ATTR_BORDER_TLBR); + SvxLineItem aDiagonal_BLTR(ATTR_BORDER_BLTR); for (auto& current_border_line : border_lines) { SvxBoxItemLine eDir = getDirection(current_border_line.first); - editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); - aItem.SetLine(&aLine, eDir); - } - rSet.Put(aItem); + if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_tl_br) + { + editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); + aDiagonal_BLTR.SetLine(&aLine); + } + if (current_border_line.first == orcus::spreadsheet::border_direction_t::diagonal_bl_tr) + { + editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); + aDiagonal_TLBR.SetLine(&aLine); + } + else + { + editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); + aBoxItem.SetLine(&aLine, eDir); + } + } + rSet.Put(aDiagonal_BLTR); + rSet.Put(aDiagonal_TLBR); + rSet.Put(aBoxItem); } void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& rSet) const commit 57f71f190a2b11fdcc471d94cdc60727f18a656f Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Wed Jul 13 12:22:49 2016 +0530 Add call to import ODF styles when spreadsheet is created or loaded Change-Id: If2f6843337f554829a321cfbe0b7dfdba90dca48 diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index dadb9c5..c364896 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -109,6 +109,8 @@ #include "docshimp.hxx" #include "sizedev.hxx" #include "refreshtimerprotector.hxx" +#include <orcus/orcus_import_ods.hpp> +#include <orcusfiltersimpl.hxx> #include <officecfg/Office/Calc.hxx> #include <comphelper/processfactory.hxx> @@ -586,6 +588,14 @@ bool ScDocShell::Load( SfxMedium& rMedium ) aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); + /* Create styles that are imported through Orcus */ + + OUString aFileName = "styles.xml"; + ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); + if (!pOrcus) + return false; + pOrcus->importODS_Styles(aDocument, aFileName); + bRet = LoadXML( &rMedium, nullptr ); } } diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx index d4b2cdf..04989b09 100644 --- a/sc/source/ui/docshell/docsh2.cxx +++ b/sc/source/ui/docshell/docsh2.cxx @@ -22,6 +22,8 @@ #include <svl/asiancfg.hxx> #include <editeng/forbiddencharacterstable.hxx> #include <editeng/unolingu.hxx> +#include <orcus/orcus_import_ods.hpp> +#include <orcusfiltersimpl.hxx> #include "drwlayer.hxx" #include "stlpool.hxx" @@ -29,6 +31,7 @@ #include "docshimp.hxx" #include "docfunc.hxx" #include "sc.hrc" +#include "filter.hxx" using namespace com::sun::star; @@ -53,6 +56,14 @@ bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) aDocument.GetStyleSheetPool()->CreateStandardStyles(); aDocument.UpdStlShtPtrsFrmNms(); + /* Create styles that are imported through Orcus */ + + OUString aFileName = "styles.xml"; + ScOrcusFilters* pOrcus = ScFormatFilter::Get().GetOrcusFilters(); + if (!pOrcus) + return false; + pOrcus->importODS_Styles(aDocument, aFileName); + // SetDocumentModified is not allowed anymore in Load/InitNew! InitItems(); CalcOutputFactor(); commit e57e81ad89cf6271ee55fae077290c3f65bb5afc Author: Jaskaran Singh <jvsg1...@gmail.com> Date: Tue Jul 12 17:37:59 2016 +0530 Implement Interface for Importing Styles via Orcus Change-Id: I2ec4cb1ad358e2e4a49e82e916a54fae81558937 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index dfecde4..c33151e 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -258,7 +258,12 @@ private: double mnSize; Color maColor; + bool mbHasFontAttr; + bool mbHasUnderlineAttr; + FontLineStyle meUnderline; + FontLineStyle meUnderlineType; + FontLineStyle meUnderlineWidth; Color maUnderlineColor; font(); @@ -275,6 +280,10 @@ private: Color maFgColor; Color maBgColor; + bool mbHasFillAttr; + + fill(); + void applyToItemSet(SfxItemSet& rSet) const; }; @@ -291,6 +300,8 @@ private: }; std::map<orcus::spreadsheet::border_direction_t, border_line> border_lines; + bool mbHasBorderAttr; + border(); void applyToItemSet(SfxItemSet& rSet) const; @@ -306,6 +317,8 @@ private: bool mbPrintContent; bool mbFormulaHidden; + bool mbHasProtectionAttr; + protection(); void applyToItemSet(SfxItemSet& rSet) const; }; @@ -317,6 +330,9 @@ private: { OUString maCode; + bool mbHasNumberFormatAttr; + + number_format(); void applyToItemSet(SfxItemSet& rSet) const; }; diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index c10a4e6..846ef07 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -34,13 +34,21 @@ #include <editeng/charhiddenitem.hxx> #include <editeng/protitem.hxx> #include <editeng/prntitem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/fhgtitem.hxx> #include <formula/token.hxx> #include <tools/datetime.hxx> #include <svl/sharedstringpool.hxx> #include <o3tl/make_unique.hxx> - +#include <svl/zforlist.hxx> +#include <svl/intitem.hxx> #include <com/sun/star/task/XStatusIndicator.hpp> +#include <comphelper/processfactory.hxx> +#include <i18nlangtag/lang.h> +#include <vcl/outdev.hxx> +#include <tools/colordata.hxx> +#include <tools/fontenum.hxx> using namespace com::sun::star; @@ -736,14 +744,32 @@ size_t ScOrcusSharedStrings::commit_segments() ScOrcusStyles::ScOrcusStyles(ScDocument& rDoc): mrDoc(rDoc) { - mrDoc.GetStyleSheetPool()->CreateStandardStyles(); + if (!mrDoc.GetStyleSheetPool()->HasStandardStyles()) + mrDoc.GetStyleSheetPool()->CreateStandardStyles(); } ScOrcusStyles::font::font(): mbBold(false), mbItalic(false), + mbHasFontAttr(false), + mbHasUnderlineAttr(false), mnSize(10), - meUnderline(LINESTYLE_NONE) + meUnderline(LINESTYLE_NONE), + maColor(COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE) +{ +} + +ScOrcusStyles::fill::fill(): + maPattern(""), + maFgColor(Color(COL_WHITE, COL_WHITE, COL_WHITE)), + maBgColor(Color(COL_WHITE, COL_WHITE, COL_WHITE)), + mbHasFillAttr(false) +{ +} + +ScOrcusStyles::number_format::number_format(): + maCode(""), + mbHasNumberFormatAttr(false) { } @@ -767,9 +793,15 @@ void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const FontWeight eWeight = mbBold ? WEIGHT_BOLD : WEIGHT_NORMAL; rSet.Put(SvxWeightItem(eWeight, ATTR_FONT_WEIGHT)); - rSet.Put(SvxColorItem(maColor, ATTR_FONT_COLOR)); - rSet.Put(SvxUnderlineItem(meUnderline, ATTR_FONT_UNDERLINE)); - rSet.Put(SvxColorItem(maUnderlineColor, ATTR_FONT_UNDERLINE)); + if (mbHasUnderlineAttr) + { + rSet.Put(SvxUnderlineItem(meUnderline, ATTR_FONT_UNDERLINE)); + rSet.Put(SvxColorItem(maUnderlineColor, ATTR_FONT_UNDERLINE)); + } + + rSet.Put( SvxColorItem(maColor, ATTR_FONT_COLOR)); + rSet.Put( SvxFontItem( FAMILY_DONTKNOW, maName, maName, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT )); + rSet.Put( SvxFontHeightItem (translateToInternal(mnSize, orcus::length_unit_t::point), 100, ATTR_FONT_HEIGHT)); } void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const @@ -785,20 +817,35 @@ void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const ScOrcusStyles::protection::protection(): mbHidden(false), - mbLocked(false) + mbLocked(true), + mbPrintContent(false), + mbFormulaHidden(false), + mbHasProtectionAttr(true) { } void ScOrcusStyles::protection::applyToItemSet(SfxItemSet& rSet) const { - rSet.Put(SvxCharHiddenItem(mbHidden, ATTR_PROTECTION)); + if (mbHidden) + rSet.Put(SvxCharHiddenItem(mbHidden, ATTR_PROTECTION)); + + if (!mbLocked) + { + SvxProtectItem aItem(ATTR_PROTECTION); - if (mbLocked) - rSet.Put(SvxProtectItem(ATTR_PROTECTION)); - rSet.Put(SvxPrintItem(ATTR_PROTECTION, mbPrintContent)); + aItem.SetContentProtect (false); + aItem.SetSizeProtect (false); + aItem.SetPosProtect (false); + + rSet.Put(aItem); + } + + if (!mbPrintContent) + rSet.Put(SvxPrintItem(ATTR_PROTECTION, mbPrintContent)); } -ScOrcusStyles::border::border() +ScOrcusStyles::border::border(): + mbHasBorderAttr(false) { } @@ -835,16 +882,30 @@ void ScOrcusStyles::border::applyToItemSet(SfxItemSet& rSet) const for (auto& current_border_line : border_lines) { SvxBoxItemLine eDir = getDirection(current_border_line.first); - editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, 1); + editeng::SvxBorderLine aLine(¤t_border_line.second.maColor, current_border_line.second.mnWidth, current_border_line.second.mestyle); aItem.SetLine(&aLine, eDir); } rSet.Put(aItem); } -void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& /*rSet*/) const +void ScOrcusStyles::number_format::applyToItemSet(SfxItemSet& rSet) const { - (void)this; // loplugin:staticmethods + sal_uInt32 nKey; + sal_Int32 nCheckPos; + SvNumberFormatter NumberFormatter(comphelper::getProcessComponentContext(), LANGUAGE_ENGLISH_US); + OUString Code = maCode; /* <-- Done because the SvNumberFormatter::PutEntry demands a non const NumFormat Code*/ + sal_Int16 type = css::util::NumberFormat::ALL; + + if (NumberFormatter.PutEntry(Code, nCheckPos, type, nKey, LANGUAGE_ENGLISH_US)) + { + if (nCheckPos == 0) + { + rSet.Put(SfxUInt32Item(nKey, ATTR_VALUE_FORMAT)); + } + } + else + SAL_WARN("sc.orcus.style", "Cannot set Number Format"); } ScOrcusStyles::xf::xf(): @@ -873,7 +934,8 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) } const font& rFont = maFonts[nFontId]; - rFont.applyToItemSet(rSet); + if (rFont.mbHasFontAttr) + rFont.applyToItemSet(rSet); size_t nFillId = rXf.mnFillId; if (nFillId >= maFills.size()) @@ -883,7 +945,8 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) } const fill& rFill = maFills[nFillId]; - rFill.applyToItemSet(rSet); + if (rFill.mbHasFillAttr) + rFill.applyToItemSet(rSet); size_t nBorderId = rXf.mnBorderId; if (nBorderId >= maBorders.size()) @@ -892,7 +955,8 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) return; } const border& rBorder = maBorders[nBorderId]; - rBorder.applyToItemSet(rSet); + if (rBorder.mbHasBorderAttr) + rBorder.applyToItemSet(rSet); size_t nProtectionId = rXf.mnProtectionId; if (nProtectionId >= maProtections.size()) @@ -901,7 +965,8 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) return; } const protection& rProtection = maProtections[nProtectionId]; - rProtection.applyToItemSet(rSet); + if (rProtection.mbHasProtectionAttr) + rProtection.applyToItemSet(rSet); size_t nNumberFormatId = rXf.mnNumberFormatId; if (nNumberFormatId >= maNumberFormats.size()) @@ -910,7 +975,8 @@ void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, const xf& rXf) return; } const number_format& rFormat = maNumberFormats[nNumberFormatId]; - rFormat.applyToItemSet(rSet); + if (rFormat.mbHasNumberFormatAttr) + rFormat.applyToItemSet(rSet); } void ScOrcusStyles::applyXfToItemSet(SfxItemSet& rSet, size_t xfId) @@ -945,6 +1011,7 @@ void ScOrcusStyles::set_font_name(const char* s, size_t n) { OUString aName(s, n, RTL_TEXTENCODING_UTF8); maCurrentFont.maName = aName; + maCurrentFont.mbHasFontAttr = true; } void ScOrcusStyles::set_font_size(double point) @@ -988,11 +1055,12 @@ void ScOrcusStyles::set_font_underline(orcus::spreadsheet::underline_t e) default: ; } + maCurrentFont.mbHasUnderlineAttr = true; } void ScOrcusStyles::set_font_underline_width(orcus::spreadsheet::underline_width_t e ) { - if (e == orcus::spreadsheet::underline_width_t::bold) + if (e == orcus::spreadsheet::underline_width_t::bold || e == orcus::spreadsheet::underline_width_t::thick) { switch(maCurrentFont.meUnderline) { @@ -1022,6 +1090,7 @@ void ScOrcusStyles::set_font_underline_width(orcus::spreadsheet::underline_width ; } } + maCurrentFont.mbHasUnderlineAttr = true; } void ScOrcusStyles::set_font_underline_mode(orcus::spreadsheet::underline_mode_t /* e */) @@ -1046,6 +1115,7 @@ void ScOrcusStyles::set_font_underline_type(orcus::spreadsheet::underline_type_t ; } } + maCurrentFont.mbHasUnderlineAttr = true; } void ScOrcusStyles::set_font_underline_color(orcus::spreadsheet::color_elem_t alpha, @@ -1082,16 +1152,19 @@ void ScOrcusStyles::set_fill_count(size_t /*n*/) void ScOrcusStyles::set_fill_pattern_type(const char* s, size_t n) { maCurrentFill.maPattern = OUString(s, n, RTL_TEXTENCODING_UTF8); + maCurrentFill.mbHasFillAttr = true; } void ScOrcusStyles::set_fill_fg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) { maCurrentFill.maFgColor = Color(alpha, red, green, blue); + maCurrentFill.mbHasFillAttr = true; } void ScOrcusStyles::set_fill_bg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) { maCurrentFill.maBgColor = Color(alpha, red, green, blue); + maCurrentFill.mbHasFillAttr = true; } size_t ScOrcusStyles::commit_fill() @@ -1157,6 +1230,7 @@ void ScOrcusStyles::set_border_style( default: ; } + maCurrentBorder.mbHasBorderAttr = true; } void ScOrcusStyles::set_border_color(orcus::spreadsheet::border_direction_t dir, @@ -1187,21 +1261,25 @@ size_t ScOrcusStyles::commit_border() void ScOrcusStyles::set_cell_hidden(bool b) { maCurrentProtection.mbHidden = b; + maCurrentProtection.mbHasProtectionAttr = true; } void ScOrcusStyles::set_cell_locked(bool b) { maCurrentProtection.mbLocked = b; + maCurrentProtection.mbHasProtectionAttr = true; } void ScOrcusStyles::set_cell_print_content(bool b ) { maCurrentProtection.mbPrintContent = b; ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits