summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-09-15 04:46:03 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-09-15 05:19:41 +0200
commit4fe079747a25013032724418b7ec76a827426907 (patch)
treeeead0afc06c2ccc7fe4000b61ba10512c09c1e35 /sc/qa
parent2b75f5908ba50dc5bcd20472ad7a6087a0b0753f (diff)
add formats test for xls and xlsx
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/data/xls/formats.xlsbin0 -> 8704 bytes
-rw-r--r--sc/qa/unit/data/xlsx/formats.xlsxbin0 -> 6118 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx145
3 files changed, 79 insertions, 66 deletions
diff --git a/sc/qa/unit/data/xls/formats.xls b/sc/qa/unit/data/xls/formats.xls
new file mode 100644
index 000000000000..5868a9304e75
--- /dev/null
+++ b/sc/qa/unit/data/xls/formats.xls
Binary files differ
diff --git a/sc/qa/unit/data/xlsx/formats.xlsx b/sc/qa/unit/data/xlsx/formats.xlsx
new file mode 100644
index 000000000000..2cd31f5a1c97
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/formats.xlsx
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 48bec6fedc6d..3b9bc50a0914 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -82,6 +82,10 @@ const int indeterminate = 2;
#define XLS_FORMAT_TYPE 318767171
#define XLSX_FORMAT_TYPE 268959811
+#define ODS 0
+#define XLS 1
+#define XLSX 2
+
using namespace ::com::sun::star;
namespace {
@@ -496,74 +500,83 @@ void FiltersTest::testDatabaseRanges()
void FiltersTest::testFormats()
{
const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("formats."));
- rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
- rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
- rtl::OUString aFileName;
- createFilePath(aFileNameBase, aFileExtension, aFileName);
- rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
- std::cout << aFileFormats[0].pName << " Test" << std::endl;
- ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[0].nFormatType);
- xDocSh->DoHardRecalc(true);
+ for(int i = 0; i < 3; ++i)
+ {
+ rtl::OUString aFileExtension(aFileFormats[i].pName, strlen(aFileFormats[i].pName), RTL_TEXTENCODING_UTF8 );
+ rtl::OUString aFilterName(aFileFormats[i].pFilterName, strlen(aFileFormats[i].pFilterName), RTL_TEXTENCODING_UTF8) ;
+ rtl::OUString aFileName;
+ createFilePath(aFileNameBase, aFileExtension, aFileName);
+ rtl::OUString aFilterType(aFileFormats[i].pTypeName, strlen(aFileFormats[i].pTypeName), RTL_TEXTENCODING_UTF8);
+ std::cout << aFileFormats[i].pName << " Test" << std::endl;
+ ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[i].nFormatType);
+ xDocSh->DoHardRecalc(true);
- CPPUNIT_ASSERT_MESSAGE("Failed to load formats.*", xDocSh.Is());
- ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT_MESSAGE("Failed to load formats.*", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
- //test Sheet1 with csv file
- rtl::OUString aCSVFileName;
- createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("numberFormat.")), aCSVFileName);
- testFile(aCSVFileName, pDoc, 0, PureString);
- //need to test the color of B3
- //it's not a font color!
- //formatting for B5: # ??/100 gets lost during import
-
- //test Sheet2
- const ScPatternAttr* pPattern = NULL;
- pPattern = pDoc->GetPattern(0,0,1);
- Font aFont;
- pPattern->GetFont(aFont,SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font size should be 10", aFont.GetSize().getHeight() == 200);
- CPPUNIT_ASSERT_MESSAGE("font color should be black", aFont.GetColor() == COL_AUTO);
- pPattern = pDoc->GetPattern(0,1,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font size should be 12", aFont.GetSize().getHeight() == 240);
- pPattern = pDoc->GetPattern(0,2,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be italic",aFont.GetItalic() == ITALIC_NORMAL);
- pPattern = pDoc->GetPattern(0,4,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be bold",aFont.GetWeight() == WEIGHT_BOLD );
- pPattern = pDoc->GetPattern(1,0,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be blue", aFont.GetColor() == COL_BLUE );
- pPattern = pDoc->GetPattern(1,1,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be striked out with a single line", aFont.GetStrikeout() == STRIKEOUT_SINGLE );
- pPattern = pDoc->GetPattern(1,2,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be striked out with a double line", aFont.GetStrikeout() == STRIKEOUT_DOUBLE );
- pPattern = pDoc->GetPattern(1,3,1);
- pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
- CPPUNIT_ASSERT_MESSAGE("font should be underlined with a dotted line", aFont.GetUnderline() == UNDERLINE_DOTTED);
- pPattern = pDoc->GetPattern(1,4,1);
- Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
- std::cerr << "red: " << (int)aColor.GetRed() << " green: " << (int)aColor.GetGreen() << " blue: " << (int)aColor.GetBlue() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("background color should be green", aColor == COL_LIGHTGREEN);
- pPattern = pDoc->GetPattern(2,0,1);
- SvxCellHorJustify eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
- CPPUNIT_ASSERT_MESSAGE("cell content should be aligned centre horizontally", eHorJustify == SVX_HOR_JUSTIFY_CENTER);
- //test alignment
- pPattern = pDoc->GetPattern(2,1,1);
- eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
- CPPUNIT_ASSERT_MESSAGE("cell content should be aligned centre horizontally", eHorJustify == SVX_HOR_JUSTIFY_RIGHT);
- pPattern = pDoc->GetPattern(2,2,1);
- eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
- CPPUNIT_ASSERT_MESSAGE("cell content should be aligned centre horizontally", eHorJustify == SVX_HOR_JUSTIFY_BLOCK);
-
- //test Sheet3
- rtl::OUString aCondString = getConditionalFormatString(pDoc, 3,0,2);
- std::cerr << rtl::OUStringToOString(aCondString, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("conditionalFormatting.")), aCSVFileName);
- testCondFile(aCSVFileName, pDoc, 2);
+ //test Sheet1 with csv file
+ rtl::OUString aCSVFileName;
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("numberFormat.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 0, PureString);
+ //need to test the color of B3
+ //it's not a font color!
+ //formatting for B5: # ??/100 gets lost during import
+
+ //test Sheet2
+ const ScPatternAttr* pPattern = NULL;
+ pPattern = pDoc->GetPattern(0,0,1);
+ Font aFont;
+ pPattern->GetFont(aFont,SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font size should be 10", aFont.GetSize().getHeight() == 200);
+ CPPUNIT_ASSERT_MESSAGE("font color should be black", aFont.GetColor() == COL_AUTO);
+ pPattern = pDoc->GetPattern(0,1,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font size should be 12", aFont.GetSize().getHeight() == 240);
+ pPattern = pDoc->GetPattern(0,2,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be italic",aFont.GetItalic() == ITALIC_NORMAL);
+ pPattern = pDoc->GetPattern(0,4,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be bold",aFont.GetWeight() == WEIGHT_BOLD );
+ pPattern = pDoc->GetPattern(1,0,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be blue", aFont.GetColor() == COL_BLUE );
+ pPattern = pDoc->GetPattern(1,1,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be striked out with a single line", aFont.GetStrikeout() == STRIKEOUT_SINGLE );
+ //test double strikeout only for ods
+ if (i == ODS)
+ {
+ pPattern = pDoc->GetPattern(1,2,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be striked out with a double line", aFont.GetStrikeout() == STRIKEOUT_DOUBLE );
+ pPattern = pDoc->GetPattern(1,3,1);
+ pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
+ CPPUNIT_ASSERT_MESSAGE("font should be underlined with a dotted line", aFont.GetUnderline() == UNDERLINE_DOTTED);
+ }
+ pPattern = pDoc->GetPattern(1,4,1);
+ Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
+ CPPUNIT_ASSERT_MESSAGE("background color should be green", aColor == COL_LIGHTGREEN);
+ pPattern = pDoc->GetPattern(2,0,1);
+ SvxCellHorJustify eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
+ CPPUNIT_ASSERT_MESSAGE("cell content should be aligned centre horizontally", eHorJustify == SVX_HOR_JUSTIFY_CENTER);
+ //test alignment
+ pPattern = pDoc->GetPattern(2,1,1);
+ eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
+ CPPUNIT_ASSERT_MESSAGE("cell content should be aligned right horizontally", eHorJustify == SVX_HOR_JUSTIFY_RIGHT);
+ pPattern = pDoc->GetPattern(2,2,1);
+ eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
+ CPPUNIT_ASSERT_MESSAGE("cell content should be aligned block horizontally", eHorJustify == SVX_HOR_JUSTIFY_BLOCK);
+
+ //test Sheet3 only for ods
+ if ( i == ODS )
+ {
+ rtl::OUString aCondString = getConditionalFormatString(pDoc, 3,0,2);
+ std::cerr << rtl::OUStringToOString(aCondString, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("conditionalFormatting.")), aCSVFileName);
+ testCondFile(aCSVFileName, pDoc, 2);
+ }
+ }
}
void FiltersTest::testBugFixesODS()