[Libreoffice-commits] core.git: Branch 'feature/orcus-odf-rebased2' - 41 commits - configure.ac desktop/CppunitTest_desktop_lib.mk download.lst external/liborcus include/o3tl RepositoryExternal.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/inc sc/Module_sc.mk sc/Package_res_xml.mk sc/qa sc/res sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Sep 17 16:21:13 UTC 2016
Rebased ref, commits from common ancestor:
commit 3ba2878bdfc62760ab50b0dac05dc0397793e702
Author: Markus Mohrhard <markus.mohrhard at 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 26b959f60c7ec356665556978a6fe5eb7c3dc1f7
Author: Markus Mohrhard <markus.mohrhard at 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 cc6fce5565d32830954687ed7201b108a7bdadca
Author: Jaskaran Singh <jvsg1303 at 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 362ed6e47e931b6c86e9ce2b0658517c3415b66c
Author: Jaskaran Singh <jvsg1303 at 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 9bfd58a6bf2a39f27943bad1a0cf0bb1eea2f5ad
Author: Jaskaran Singh <jvsg1303 at 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 b2907a1b571dc88b203c260bb4e96ccd472e7faf
Author: Jaskaran Singh <jvsg1303 at 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 40202a7a4e47e3fd9bbe36fe0a511498a8aff74d
Author: Jaskaran Singh <jvsg1303 at 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 4b98a4a8f86a8420d9693ec7f96e0b6b7968a7f7
Author: Jaskaran Singh <jvsg1303 at 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 f9c39c38d00de882628026cfa85d95008d9fb4b5
Author: Jaskaran Singh <jvsg1303 at 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 74872e33fcb6a10c29ce78bb7b9dd31eede0e7b1
Author: Jaskaran Singh <jvsg1303 at 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 4e79e17a9f8145f12654cbc68443309afd019395
Author: Jaskaran Singh <jvsg1303 at 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 0cad48d2cbdf42ddc57174b70c80eed4611395b5
Author: Jaskaran Singh <jvsg1303 at 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 2be609e3203c5820496057bea5a4acaff2f8f321
Author: Jaskaran Singh <jvsg1303 at 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 f3797086cc2aaf47ff359299e4b8f3565683e78f
Author: Jaskaran Singh <jvsg1303 at 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 7d4fa18c98f67df6b677d503ca61b76921d8a816
Author: Jaskaran Singh <jvsg1303 at 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 e2799afab1c3beca5b51f013253943c4cf063054
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Mon Aug 1 00:37:03 2016 +0530
Add test for orcus style import
Change-Id: I4731ed1854f854651b828ae4cb27e6b040660bdf
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 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 cfdabc426428e2b966c9cc7ebd817543b919ca13
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Mon Aug 1 00:35:48 2016 +0530
Change the way url is handled for orcus style import
Change-Id: I6d5f9059f8a83ae5b148ff0498d8af0777acfac8
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index e16cc7f..66a9ca2 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -147,22 +147,9 @@ bool ScOrcusFiltersImpl::importODS(ScDocument& rDoc, SfxMedium& rMedium) const
return true;
}
-bool ScOrcusFiltersImpl::importODS_Styles(ScDocument& rDoc, OUString& aFileName) const
+bool ScOrcusFiltersImpl::importODS_Styles(ScDocument& rDoc, OUString& aPath) const
{
- OUString aPath("$BRAND_BASE_DIR/"); /* Read the comment below before changing this */
- rtl::Bootstrap::expandMacros(aPath);
- OUString aValidPath;
-
- /* The Following loop trims 'file://' from start of string and
- * '../' from the end of string. If you ever happen to change the above macro
- * please consider changing the following range too, otherwise app would
- * crash!!
- */
- for (sal_Int32 i = 7; i < aPath.getLength() - 3; ++i)
- aValidPath += OUString(aPath[i]);
-
- aValidPath += aFileName;
- OString aUrl = OUStringToOString(aValidPath, RTL_TEXTENCODING_UTF8);
+ OString aUrl = OUStringToOString(aPath, RTL_TEXTENCODING_UTF8);
const char* path = aUrl.getStr();
try
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 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 17aedb0f500d72302c74273528876e0eb105ec94
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Mon Aug 1 00:33:11 2016 +0530
Link orcus headers and libs to subsequent filters test
Change-Id: If036666f16dec23539e0e5a78f3a28d9cdc8be53
diff --git a/sc/CppunitTest_sc_subsequent_filters_test.mk b/sc/CppunitTest_sc_subsequent_filters_test.mk
index 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 8adc86d4e95d70bd27124f819d0a1b6695551d56
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Mon Aug 1 00:31:14 2016 +0530
Export ScStyleSheetPool Symbol out of its lib
Change-Id: I7fe0842be5e3c07b3d0b8936b276d3107e8daa14
diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx
index 7155255..7836302 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,
commit b0a7a8044a5db9f58cc4a1275b42e54d09e66f55
Author: Jaskaran Singh <jvsg1303 at 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 d39e1d4d87ca43bd0790669aa8aff5966a208015
Author: Jaskaran Singh <jvsg1303 at 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 e497cfce0340f79558dca1266339511710708a57
Author: Jaskaran Singh <jvsg1303 at 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 d98f55a6acbec5bea1502418823546e88e5c8f26
Author: Jaskaran Singh <jvsg1303 at 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 c54b7a90c27b7742ad49b3d99a2dade77c8cb8e7
Author: Jaskaran Singh <jvsg1303 at 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 83c2387a1a3508787006dd07c1c2bcdc44bf0f4c
Author: Jaskaran Singh <jvsg1303 at 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 baf05046cc6ce1ff478a278405202bf96e792597
Author: Markus Mohrhard <markus.mohrhard at 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 d3cf657be25e1aa1a4d96bd997b28facd96247e4
Author: Markus Mohrhard <markus.mohrhard at 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 b725609577b3b0f6ae50518bc64a61b87a0222b5
Author: Markus Mohrhard <markus.mohrhard at 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 a508a32f88e809ea40cc1e888e0057ae6aa33abc
Author: Jaskaran Singh <jvsg1303 at 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 5c51367951f78bd2d6cddb9522792ceaaf6c5ecf
Author: Jaskaran Singh <jvsg1303 at 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 b93ae96b4260b470d982b01a6f8586c9e3e3af71
Author: Jaskaran Singh <jvsg1303 at 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 15222c789ab5f5ee93eed1a3a3b8a44e362bae2c
Author: Jaskaran Singh <jvsg1303 at 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;
+ maCurrentProtection.mbHasProtectionAttr = true;
}
void ScOrcusStyles::set_cell_formula_hidden(bool b )
{
maCurrentProtection.mbFormulaHidden = b;
+ maCurrentProtection.mbHasProtectionAttr = true;
}
size_t ScOrcusStyles::commit_cell_protection()
@@ -1224,6 +1302,7 @@ void ScOrcusStyles::set_number_format_code(const char* s, size_t n)
{
OUString aCode(s, n, RTL_TEXTENCODING_UTF8);
maCurrentNumberFormat.maCode = aCode;
+ maCurrentNumberFormat.mbHasNumberFormatAttr = true;
}
size_t ScOrcusStyles::commit_number_format()
@@ -1355,6 +1434,10 @@ size_t ScOrcusStyles::commit_cell_style()
SAL_WARN("sc.orcus.style", "invalid xf id for commit cell style");
return 0;
}
+ if (maCurrentCellStyle.mnXFId == 0)
+ {
+ return 0;
+ }
ScStyleSheetPool* pPool = mrDoc.GetStyleSheetPool();
SfxStyleSheetBase& rBase = pPool->Make(maCurrentCellStyle.maName, SfxStyleFamily::Para);
@@ -1363,6 +1446,9 @@ size_t ScOrcusStyles::commit_cell_style()
xf& rXf = maCellStyleXfs[maCurrentCellStyle.mnXFId];
applyXfToItemSet(rSet, rXf);
+ maCurrentXF = ScOrcusStyles::xf();
+ maCurrentCellStyle = ScOrcusStyles::cell_style();
+
return 0;
}
commit 515044a8a55e2ed0e14ce994f41afce121360e71
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Tue Jul 12 17:32:19 2016 +0530
Add a method to import ODF styles via orcus
Change-Id: Id76593bbb9982ec6745737ade800ae669e8e4471
diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index 58e6fcb..e96facb 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -36,6 +36,12 @@ public:
virtual bool importODS(ScDocument& rDoc, SfxMedium& rMedium) const = 0;
/**
+ * Used to import just the styles from an xml file.
+ */
+
+ virtual bool importODS_Styles(ScDocument& rDoc, OUString& aFileName) const = 0;
+
+ /**
* Create a context for XML file. The context object stores session
* information for each unique XML file. You must create a new context
* for each XML file, and never to re-use the same context for multiple
diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx
index 47f88f3..d0d40f8 100644
--- a/sc/source/filter/inc/orcusfiltersimpl.hxx
+++ b/sc/source/filter/inc/orcusfiltersimpl.hxx
@@ -25,6 +25,8 @@ public:
virtual bool importXLSX(ScDocument& rDoc, SfxMedium& rMedium) const override;
virtual bool importODS(ScDocument& rDoc, SfxMedium& rMedium) const override;
+ virtual bool importODS_Styles(ScDocument& rDoc, OUString& aFileName) const override;
+
virtual ScOrcusXMLContext* createXMLContext(ScDocument& rDoc, const OUString& rPath) const override;
};
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index c86ca3b..e16cc7f 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -17,14 +17,19 @@
#include <sfx2/frame.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/itemset.hxx>
+#include <rtl/bootstrap.hxx>
+#include <rtl/ustring.hxx>
+#include <comphelper/string.hxx>
#include <orcus/spreadsheet/import_interface.hpp>
#include <orcus/orcus_csv.hpp>
#include <orcus/orcus_gnumeric.hpp>
#include <orcus/orcus_xlsx.hpp>
#include <orcus/orcus_ods.hpp>
+#include <orcus/orcus_import_ods.hpp>
#include <orcus/global.hpp>
-
+#include <orcus/stream.hpp>
+#include <orcus/orcus_import_ods.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#ifdef _WIN32
@@ -142,6 +147,39 @@ bool ScOrcusFiltersImpl::importODS(ScDocument& rDoc, SfxMedium& rMedium) const
return true;
}
+bool ScOrcusFiltersImpl::importODS_Styles(ScDocument& rDoc, OUString& aFileName) 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);
+ const char* path = aUrl.getStr();
+
+ try
+ {
+ std::string content = orcus::load_file_content(path);
+ ScOrcusStyles styles(rDoc);
+ orcus::import_ods::read_styles(content.c_str(), content.size(), &styles);
+ }
+ catch (const std::exception& e)
+ {
+ SAL_WARN("sc", "Unable to load styles from xml file! " << e.what());
+ return false;
+ }
+
+ return true;
+}
+
ScOrcusXMLContext* ScOrcusFiltersImpl::createXMLContext(ScDocument& rDoc, const OUString& rPath) const
{
return new ScOrcusXMLContextImpl(rDoc, rPath);
commit 8b15a9537fba2b0271262320829b131d1968bac4
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Tue Jul 12 17:08:33 2016 +0530
Add to a method to check if stlpool already has standard styles
Change-Id: I9173b0232d466a27cf8a7b35e0a9f0567b398115
diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx
index 842ae88..7155255 100644
--- a/sc/inc/stlpool.hxx
+++ b/sc/inc/stlpool.hxx
@@ -49,6 +49,8 @@ public:
void CopyStyleFrom( ScStyleSheetPool* pSrcPool,
const OUString& rName, SfxStyleFamily eFamily );
+ bool HasStandardStyles() { return bHasStandardStyles; }
+
ScStyleSheet* FindCaseIns( const OUString& rName, SfxStyleFamily eFam );
virtual SfxStyleSheetBase& Make( const OUString&, SfxStyleFamily eFam,
@@ -67,6 +69,7 @@ protected:
private:
SfxStyleSheetBase* pActualStyleSheet;
ScDocument* pDoc;
+ bool bHasStandardStyles;
};
#endif // INCLUDED_SC_INC_STLPOOL_HXX
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index d1f06ce..a0cfdc9 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -433,6 +433,8 @@ void ScStyleSheetPool::CreateStandardStyles()
delete pTxtObj;
delete pEmptyTxtObj;
+
+ bHasStandardStyles = true;
}
namespace {
commit 4d56d43c6f2e0c9a9fcc4109982cbbc8ddd09fa3
Author: Jaskaran Singh <jvsg1303 at gmail.com>
Date: Mon Jun 27 11:53:57 2016 +0530
Add functions for cell protection in orcus interface
Change-Id: I86111e9584e9d629d5fbb6a17c8936de719d190b
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index df1e9ed..dfecde4 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -303,6 +303,8 @@ private:
{
bool mbHidden;
bool mbLocked;
+ bool mbPrintContent;
+ bool mbFormulaHidden;
protection();
void applyToItemSet(SfxItemSet& rSet) const;
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index dbcbf27..c10a4e6 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -31,6 +31,9 @@
#include <editeng/boxitem.hxx>
#include <editeng/borderline.hxx>
#include <editeng/lcolitem.hxx>
+#include <editeng/charhiddenitem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/prntitem.hxx>
#include <formula/token.hxx>
#include <tools/datetime.hxx>
@@ -786,9 +789,13 @@ ScOrcusStyles::protection::protection():
{
}
-void ScOrcusStyles::protection::applyToItemSet(SfxItemSet& /*rSet*/) const
+void ScOrcusStyles::protection::applyToItemSet(SfxItemSet& rSet) const
{
- (void)this; // loplugin:staticmethods
+ rSet.Put(SvxCharHiddenItem(mbHidden, ATTR_PROTECTION));
+
+ if (mbLocked)
+ rSet.Put(SvxProtectItem(ATTR_PROTECTION));
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list