Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : : *
5 : : * The contents of this file are subject to the Mozilla Public License Version
6 : : * 1.1 (the "License"); you may not use this file except in compliance with
7 : : * the License or as specified alternatively below. You may obtain a copy of
8 : : * the License at http://www.mozilla.org/MPL/
9 : : *
10 : : * Software distributed under the License is distributed on an "AS IS" basis,
11 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : : * for the specific language governing rights and limitations under the
13 : : * License.
14 : : *
15 : : * Major Contributor(s):
16 : : * Copyright (C) 2010 Red Hat, Inc., Caolán McNamara <caolanm@redhat.com>
17 : : * (initial developer)
18 : : *
19 : : * All Rights Reserved.
20 : : *
21 : : * For minor contributions see the git repository.
22 : : *
23 : : * Alternatively, the contents of this file may be used under the terms of
24 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
25 : : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
26 : : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
27 : : * instead of those above.
28 : : */
29 : :
30 : : #include <sal/config.h>
31 : : #include <unotest/filters-test.hxx>
32 : : #include <test/bootstrapfixture.hxx>
33 : : #include <rtl/strbuf.hxx>
34 : : #include <osl/file.hxx>
35 : :
36 : : #include <sfx2/app.hxx>
37 : : #include <sfx2/docfilt.hxx>
38 : : #include <sfx2/docfile.hxx>
39 : : #include <sfx2/sfxmodelfactory.hxx>
40 : : #include <svl/stritem.hxx>
41 : : #include "svx/svdpage.hxx"
42 : :
43 : : #include <editeng/brshitem.hxx>
44 : : #include <editeng/justifyitem.hxx>
45 : : #include <editeng/borderline.hxx>
46 : : #include <dbdata.hxx>
47 : : #include "validat.hxx"
48 : : #include "cell.hxx"
49 : : #include "drwlayer.hxx"
50 : : #include "userdat.hxx"
51 : :
52 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
53 : : #include <com/sun/star/drawing/XControlShape.hpp>
54 : : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
55 : : #include <com/sun/star/container/XIndexAccess.hpp>
56 : : #include <com/sun/star/frame/XModel.hpp>
57 : :
58 : : #define CALC_DEBUG_OUTPUT 0
59 : : #define TEST_BUG_FILES 0
60 : :
61 : : #include "helper/qahelper.hxx"
62 : :
63 : : #define ODS_FORMAT_TYPE 50331943
64 : : #define XLS_FORMAT_TYPE 318767171
65 : : #define XLSX_FORMAT_TYPE 268959811
66 : : #define CSV_FORMAT_TYPE (SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_USESOPTIONS)
67 : : #define HTML_FORMAT_TYPE (SFX_FILTER_IMPORT | SFX_FILTER_EXPORT | SFX_FILTER_ALIEN | SFX_FILTER_USESOPTIONS)
68 : :
69 : : #define ODS 0
70 : : #define XLS 1
71 : : #define XLSX 2
72 : : #define CSV 3
73 : : #define HTML 4
74 : :
75 : : using namespace ::com::sun::star;
76 : : using namespace ::com::sun::star::uno;
77 : :
78 : : namespace {
79 : :
80 : : struct FileFormat {
81 : : const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
82 : : };
83 : :
84 : : FileFormat aFileFormats[] = {
85 : : { "ods" , "calc8", "", ODS_FORMAT_TYPE },
86 : : { "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
87 : : { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE },
88 : : { "csv" , "Text - txt - csv (StarCalc)", "generic_Text", CSV_FORMAT_TYPE },
89 : : { "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE }
90 : : };
91 : :
92 : : }
93 : :
94 : : /* Implementation of Filters test */
95 : :
96 [ + - ][ - + ]: 216 : class ScFiltersTest
97 : : : public test::FiltersTest
98 : : , public test::BootstrapFixture
99 : : {
100 : : public:
101 : : ScFiltersTest();
102 : :
103 : : virtual bool load(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData);
104 : : ScDocShellRef load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
105 : : const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType=0);
106 : :
107 : : void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
108 : : void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath);
109 : :
110 : : virtual void setUp();
111 : : virtual void tearDown();
112 : :
113 : : //ods, xls, xlsx filter tests
114 : : void testRangeNameXLS();
115 : : void testRangeNameXLSX();
116 : : void testHardRecalcODS();
117 : : void testFunctionsODS();
118 : : void testCachedFormulaResultsODS();
119 : : void testVolatileFunctionsODS();
120 : : void testCachedMatrixFormulaResultsODS();
121 : : void testDatabaseRangesODS();
122 : : void testDatabaseRangesXLS();
123 : : void testDatabaseRangesXLSX();
124 : : void testFormatsODS();
125 : : void testFormatsXLS();
126 : : void testFormatsXLSX();
127 : : void testMatrixODS();
128 : : void testMatrixXLS();
129 : : void testBorderODS();
130 : : void testBorderXLS();
131 : : void testBordersOoo33();
132 : : void testBugFixesODS();
133 : : void testBugFixesXLS();
134 : : void testBugFixesXLSX();
135 : : void testBrokenQuotesCSV();
136 : : void testMergedCellsODS();
137 : : void testRepeatedColumnsODS();
138 : : void testDataValidityODS();
139 : :
140 : : void testColorScale();
141 : : void testDataBar();
142 : : void testCondFormat();
143 : :
144 : : //change this test file only in excel and not in calc
145 : : void testSharedFormulaXLSX();
146 : : void testCellValueXLSX();
147 : :
148 : : //misc tests unrelated to the import filters
149 : : void testPasswordNew();
150 : : void testPasswordOld();
151 : :
152 : : //test shape import
153 : : void testControlImport();
154 : :
155 : : void testNumberFormatHTML();
156 : : void testNumberFormatCSV();
157 : :
158 : : void testCellAnchoredShapesODS();
159 : :
160 [ + - ][ + - ]: 6 : CPPUNIT_TEST_SUITE(ScFiltersTest);
[ + - ][ + - ]
[ # # ]
161 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testRangeNameXLS);
[ + - ][ + - ]
[ + - ][ + - ]
162 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testRangeNameXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
163 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testHardRecalcODS);
[ + - ][ + - ]
[ + - ][ + - ]
164 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testFunctionsODS);
[ + - ][ + - ]
[ + - ][ + - ]
165 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testCachedFormulaResultsODS);
[ + - ][ + - ]
[ + - ][ + - ]
166 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testVolatileFunctionsODS);
[ + - ][ + - ]
[ + - ][ + - ]
167 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
[ + - ][ + - ]
[ + - ][ + - ]
168 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testDatabaseRangesODS);
[ + - ][ + - ]
[ + - ][ + - ]
169 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testDatabaseRangesXLS);
[ + - ][ + - ]
[ + - ][ + - ]
170 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testDatabaseRangesXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
171 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testFormatsODS);
[ + - ][ + - ]
[ + - ][ + - ]
172 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testFormatsXLS);
[ + - ][ + - ]
[ + - ][ + - ]
173 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testFormatsXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
174 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testMatrixODS);
[ + - ][ + - ]
[ + - ][ + - ]
175 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testMatrixXLS);
[ + - ][ + - ]
[ + - ][ + - ]
176 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBorderODS);
[ + - ][ + - ]
[ + - ][ + - ]
177 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBorderXLS);
[ + - ][ + - ]
[ + - ][ + - ]
178 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBordersOoo33);
[ + - ][ + - ]
[ + - ][ + - ]
179 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBugFixesODS);
[ + - ][ + - ]
[ + - ][ + - ]
180 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBugFixesXLS);
[ + - ][ + - ]
[ + - ][ + - ]
181 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBugFixesXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
182 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testMergedCellsODS);
[ + - ][ + - ]
[ + - ][ + - ]
183 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testRepeatedColumnsODS);
[ + - ][ + - ]
[ + - ][ + - ]
184 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testDataValidityODS);
[ + - ][ + - ]
[ + - ][ + - ]
185 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testBrokenQuotesCSV);
[ + - ][ + - ]
[ + - ][ + - ]
186 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testSharedFormulaXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
187 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testCellValueXLSX);
[ + - ][ + - ]
[ + - ][ + - ]
188 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testControlImport);
[ + - ][ + - ]
[ + - ][ + - ]
189 : :
190 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testColorScale);
[ + - ][ + - ]
[ + - ][ + - ]
191 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testDataBar);
[ + - ][ + - ]
[ + - ][ + - ]
192 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testCondFormat);
[ + - ][ + - ]
[ + - ][ + - ]
193 : :
194 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testNumberFormatHTML);
[ + - ][ + - ]
[ + - ][ + - ]
195 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testNumberFormatCSV);
[ + - ][ + - ]
[ + - ][ + - ]
196 : :
197 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testCellAnchoredShapesODS);
[ + - ][ + - ]
[ + - ][ + - ]
198 : :
199 : : //disable testPassword on MacOSX due to problems with libsqlite3
200 : : //also crashes on DragonFly due to problems with nss/nspr headers
201 : : #if !defined(MACOSX) && !defined(DRAGONFLY) && !defined(WNT)
202 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testPasswordOld);
[ + - ][ + - ]
[ + - ][ + - ]
203 [ + - ][ + - ]: 3 : CPPUNIT_TEST(testPasswordNew);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
204 : : #endif
205 : :
206 : : #if TEST_BUG_FILES
207 : : CPPUNIT_TEST(testBugFiles);
208 : : CPPUNIT_TEST(testBugFilesXLS);
209 : : CPPUNIT_TEST(testBugFilesXLSX);
210 : : #endif
211 [ + - ][ + - ]: 6 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
212 : :
213 : : private:
214 : : void testPassword_Impl(const rtl::OUString& rFileNameBase);
215 : : ScDocShellRef loadDoc(const rtl::OUString& rName, sal_Int32 nType);
216 : :
217 : : uno::Reference<uno::XInterface> m_xCalcComponent;
218 : : ::rtl::OUString m_aBaseString;
219 : : };
220 : :
221 : 96 : ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
222 : : const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType)
223 : : {
224 : 96 : sal_uInt32 nFormat = 0;
225 [ + - ]: 96 : if (nFormatType)
226 : 96 : nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
227 : : SfxFilter* aFilter = new SfxFilter(
228 : : rFilter,
229 : : rtl::OUString(), nFormatType, nFormat, rTypeName, 0, rtl::OUString(),
230 [ + - ][ + - ]: 96 : rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
231 : 96 : aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
232 : :
233 [ + - ]: 96 : ScDocShellRef xDocShRef = new ScDocShell;
234 [ + - ][ + - ]: 96 : SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
[ + - ][ + - ]
235 [ + - ]: 96 : pSrcMed->SetFilter(aFilter);
236 [ + - ][ - + ]: 96 : if (!xDocShRef->DoLoad(pSrcMed))
237 : : {
238 [ # # ]: 0 : xDocShRef->DoClose();
239 : : // load failed.
240 [ # # ]: 0 : xDocShRef.Clear();
241 : : }
242 : :
243 : 96 : return xDocShRef;
244 : : }
245 : :
246 : 0 : bool ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
247 : : const rtl::OUString &rUserData)
248 : : {
249 [ # # ]: 0 : ScDocShellRef xDocShRef = load(rFilter, rURL, rUserData, rtl::OUString());
250 : 0 : bool bLoaded = xDocShRef.Is();
251 : : //reference counting of ScDocShellRef is very confused.
252 [ # # ]: 0 : if (bLoaded)
253 [ # # ]: 0 : xDocShRef->DoClose();
254 [ # # ]: 0 : return bLoaded;
255 : : }
256 : :
257 : 63 : ScDocShellRef ScFiltersTest::loadDoc(const rtl::OUString& rName, sal_Int32 nFormat)
258 : : {
259 [ + - ]: 63 : rtl::OUString aFileExtension(aFileFormats[nFormat].pName, strlen(aFileFormats[nFormat].pName), RTL_TEXTENCODING_UTF8 );
260 [ + - ]: 63 : rtl::OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ;
261 : 63 : rtl::OUString aFileName;
262 [ + - ]: 63 : createFileURL( rName, aFileExtension, aFileName );
263 [ + - ]: 63 : rtl::OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8);
264 [ + - ]: 63 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[nFormat].nFormatType);
265 [ + - ][ + - ]: 63 : CPPUNIT_ASSERT(xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
266 : 63 : return xDocSh;
267 : : }
268 : :
269 : 102 : void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath)
270 : : {
271 [ + - ]: 102 : rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/"));
272 [ + - ]: 102 : rtl::OUStringBuffer aBuffer( getSrcRootURL() );
273 [ + - ][ + - ]: 102 : aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension);
[ + - ]
274 [ + - ][ + - ]: 102 : aBuffer.append(aSep).append(aFileBase).append(aFileExtension);
[ + - ]
275 [ + - ]: 102 : rFilePath = aBuffer.makeStringAndClear();
276 : 102 : }
277 : :
278 : 84 : void ScFiltersTest::createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rCSVPath)
279 : : {
280 [ + - ]: 84 : rtl::OUStringBuffer aBuffer(getSrcRootPath());
281 [ + - ][ + - ]: 84 : aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/contentCSV/")));
[ + - ]
282 [ + - ][ + - ]: 84 : aBuffer.append(aFileBase).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("csv")));
[ + - ]
283 [ + - ]: 84 : rCSVPath = aBuffer.makeStringAndClear();
284 : 84 : }
285 : :
286 : : namespace {
287 : :
288 : 6 : void testRangeNameImpl(ScDocument* pDoc)
289 : : {
290 : : //check one range data per sheet and one global more detailed
291 : : //add some more checks here
292 [ + - ][ + - ]: 6 : ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1")));
[ + - ]
293 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
294 : : double aValue;
295 [ + - ]: 6 : pDoc->GetValue(1,0,0,aValue);
296 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Global1 should reference Sheet1.A1", 1.0, aValue);
[ + - ][ + - ]
[ + - ]
297 [ + - ][ + - ]: 6 : pRangeData = pDoc->GetRangeName(0)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1")));
[ + - ]
298 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
299 [ + - ]: 6 : pDoc->GetValue(1,2,0,aValue);
300 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", 3.0, aValue);
[ + - ][ + - ]
[ + - ]
301 [ + - ][ + - ]: 6 : pRangeData = pDoc->GetRangeName(1)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2")));
[ + - ]
302 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
303 [ + - ]: 6 : pDoc->GetValue(1,1,1,aValue);
304 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", 7.0, aValue);
[ + - ][ + - ]
[ + - ]
305 : : //check for correct results for the remaining formulas
306 [ + - ]: 6 : pDoc->GetValue(1,1,0, aValue);
307 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("=global2 should be 2", 2.0, aValue);
[ + - ][ + - ]
[ + - ]
308 [ + - ]: 6 : pDoc->GetValue(1,3,0, aValue);
309 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("=local2 should be 4", 4.0, aValue);
[ + - ][ + - ]
[ + - ]
310 [ + - ]: 6 : pDoc->GetValue(2,0,0, aValue);
311 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("=SUM(global3) should be 10", 10.0, aValue);
[ + - ][ + - ]
[ + - ]
312 [ + - ]: 6 : pDoc->GetValue(1,0,1,aValue);
313 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", 5.0, aValue);
[ + - ][ + - ]
[ + - ]
314 : 6 : }
315 : :
316 : : }
317 : :
318 : 3 : void ScFiltersTest::testRangeNameXLS()
319 : : {
320 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("named-ranges-global."));
321 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, XLS);
322 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
323 : :
324 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
325 [ + - ]: 3 : testRangeNameImpl(pDoc);
326 : :
327 [ + - ]: 3 : rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2."));
328 : 3 : rtl::OUString aCSVPath;
329 [ + - ]: 3 : createCSVPath( aSheet2CSV, aCSVPath );
330 : : // fdo#44587
331 [ + - ]: 3 : testFile( aCSVPath, pDoc, 1);
332 : :
333 [ + - ][ + - ]: 3 : xDocSh->DoClose();
334 : 3 : }
335 : :
336 : 3 : void ScFiltersTest::testRangeNameXLSX()
337 : : {
338 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("named-ranges-global."));
339 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, XLSX);
340 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
341 : :
342 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
343 [ + - ]: 3 : testRangeNameImpl(pDoc);
344 : :
345 [ + - ][ + - ]: 3 : xDocSh->DoClose();
346 : 3 : }
347 : :
348 : 3 : void ScFiltersTest::testHardRecalcODS()
349 : : {
350 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("hard-recalc."));
351 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
352 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
353 : :
354 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load hard-recalc.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
355 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
356 : 3 : rtl::OUString aCSVFileName;
357 : :
358 : : //test hard recalc: document has an incorrect cached formula result
359 : : //hard recalc should have updated to the correct result
360 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("hard-recalc.")), aCSVFileName);
361 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
362 : :
363 [ + - ][ + - ]: 3 : xDocSh->DoClose();
364 : 3 : }
365 : :
366 : 3 : void ScFiltersTest::testFunctionsODS()
367 : : {
368 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("functions."));
369 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
370 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
371 : :
372 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
373 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
374 : 3 : rtl::OUString aCSVFileName;
375 : :
376 : : //test logical functions
377 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName);
378 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
379 : : //test spreadsheet functions
380 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName);
381 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 1);
382 : : //test mathematical functions
383 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName);
384 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 2, PureString);
385 : : //test informations functions
386 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName);
387 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 3);
388 : :
389 [ + - ][ + - ]: 3 : xDocSh->DoClose();
390 : 3 : }
391 : :
392 : 3 : void ScFiltersTest::testCachedFormulaResultsODS()
393 : : {
394 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("functions."));
395 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
396 : :
397 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
398 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
399 : 3 : rtl::OUString aCSVFileName;
400 : :
401 : : //test cached formula results of logical functions
402 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName);
403 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
404 : : //test cached formula results of spreadsheet functions
405 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName);
406 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 1);
407 : : //test cached formula results of mathematical functions
408 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName);
409 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 2, PureString);
410 : : //test cached formula results of informations functions
411 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName);
412 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 3);
413 : :
414 [ + - ][ + - ]: 3 : xDocSh->DoClose();
415 : 3 : }
416 : :
417 : 3 : void ScFiltersTest::testVolatileFunctionsODS()
418 : : {
419 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("volatile."));
420 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
421 : :
422 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load volatile.ods", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
423 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
424 : :
425 : : //we want to me sure that volatile functions are always recalculated
426 : : //regardless of cached results. if you update the ods file, you must
427 : : //update the values here.
428 : : //if NOW() is recacluated, then it should never equal sTodayCache
429 : 3 : OUString sTodayCache("07/11/12 12:28 AM");
430 [ + - ]: 3 : OUString sTodayRecalc(pDoc->GetString(0,1,0));
431 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(sTodayCache != sTodayRecalc);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
432 : :
433 [ + - ]: 3 : OUString sTodayRecalcRef(pDoc->GetString(2,1,0));
434 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(sTodayCache != sTodayRecalcRef);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
435 : :
436 [ + - ][ + - ]: 3 : xDocSh->DoClose();
437 : 3 : }
438 : :
439 : 3 : void ScFiltersTest::testCachedMatrixFormulaResultsODS()
440 : : {
441 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("matrix."));
442 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS);
443 : :
444 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load matrix.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
445 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
446 : :
447 : : //test matrix
448 : 3 : rtl::OUString aCSVFileName;
449 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName);
450 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
451 : : //test matrices with special cases
452 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix2.")), aCSVFileName);
453 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 1);
454 : : //The above testFile() does not catch the below case.
455 : : //If a matrix formula has a matrix reference cell that is intended to have
456 : : //a blank text result, the matrix reference cell is actually saved(export)
457 : : //as a float cell with 0 as the value and an empty <text:p/>.
458 : : //Import works around this by setting these cells as text cells so that
459 : : //the blank text is used for display instead of the number 0.
460 : : //If this is working properly, the following cell should NOT have value data.
461 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pDoc->GetCell(ScAddress(3,5,1))->HasValueData());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
462 : :
463 [ + - ][ + - ]: 3 : xDocSh->DoClose();
464 : 3 : }
465 : :
466 : : namespace {
467 : :
468 : 9 : void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat)
469 : : {
470 [ + - ]: 9 : ScDBCollection* pDBCollection = pDoc->GetDBCollection();
471 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("no database collection", pDBCollection);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
472 : :
473 [ + - ]: 9 : ScDBData* pAnonDBData = pDoc->GetAnonymousDBData(0);
474 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("missing anonymous DB data in sheet 1", pAnonDBData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
475 : : //control hidden rows
476 : : bool bHidden;
477 : : SCROW nRow1, nRow2;
478 [ + - ]: 9 : bHidden = pDoc->RowHidden(0, 0, &nRow1, &nRow2);
479 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("Sheet1: row 0 should be visible", !bHidden && nRow1 == 0 && nRow2 == 0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
480 [ + - ]: 9 : bHidden = pDoc->RowHidden(1, 0, &nRow1, &nRow2);
481 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("Sheet1: rows 1-2 should be hidden", bHidden && nRow1 == 1 && nRow2 == 2);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
482 [ + - ]: 9 : bHidden = pDoc->RowHidden(3, 0, &nRow1, &nRow2);
483 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("Sheet1: row 3 should be visible", !bHidden && nRow1 == 3 && nRow2 == 3);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
484 [ + - ]: 9 : bHidden = pDoc->RowHidden(4, 0, &nRow1, &nRow2);
485 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("Sheet1: row 4-5 should be hidden", bHidden && nRow1 == 4 && nRow2 == 5);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
486 [ + - ]: 9 : bHidden = pDoc->RowHidden(6, 0, &nRow1, &nRow2);
487 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("Sheet1: row 6-end should be visible", !bHidden && nRow1 == 6 && nRow2 == MAXROW);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
488 [ + + ]: 9 : if(nFormat == ODS) //excel doesn't support named db ranges
489 : : {
490 : : double aValue;
491 [ + - ]: 3 : pDoc->GetValue(0,10,1, aValue);
492 : 3 : rtl::OUString aString;
493 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: A11: formula result is incorrect", 4.0, aValue);
[ + - ][ + - ]
[ + - ]
494 [ + - ]: 3 : pDoc->GetValue(1, 10, 1, aValue);
495 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: B11: formula result is incorrect", 2.0, aValue);
[ + - ][ + - ]
[ + - ]
496 : : }
497 : : double aValue;
498 [ + - ]: 9 : pDoc->GetValue(3,10,1, aValue);
499 : 9 : rtl::OUString aString;
500 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: D11: formula result is incorrect", 4.0, aValue);
[ + - ][ + - ]
[ + - ]
501 [ + - ]: 9 : pDoc->GetValue(4, 10, 1, aValue);
502 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet2: E11: formula result is incorrect", 2.0, aValue);
[ + - ][ + - ]
[ + - ]
503 : :
504 : 9 : }
505 : :
506 : : }
507 : :
508 : 3 : void ScFiltersTest::testDatabaseRangesODS()
509 : : {
510 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
511 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0);
512 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
513 : :
514 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
515 : :
516 [ + - ]: 3 : testDBRanges_Impl(pDoc, ODS);
517 [ + - ][ + - ]: 3 : xDocSh->DoClose();
518 : 3 : }
519 : :
520 : 3 : void ScFiltersTest::testDatabaseRangesXLS()
521 : : {
522 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
523 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1);
524 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
525 : :
526 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
527 : :
528 [ + - ]: 3 : testDBRanges_Impl(pDoc, XLS);
529 [ + - ][ + - ]: 3 : xDocSh->DoClose();
530 : 3 : }
531 : :
532 : 3 : void ScFiltersTest::testDatabaseRangesXLSX()
533 : : {
534 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database."));
535 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 2);
536 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
537 : :
538 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
539 : :
540 [ + - ]: 3 : testDBRanges_Impl(pDoc, XLSX);
541 [ + - ][ + - ]: 3 : xDocSh->DoClose();
542 : 3 : }
543 : :
544 : : namespace {
545 : :
546 : 9 : void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 nFormat)
547 : : {
548 : : //test Sheet1 with csv file
549 : 9 : rtl::OUString aCSVFileName;
550 [ + - ][ + - ]: 9 : pFiltersTest->createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("numberFormat.")), aCSVFileName);
551 [ + - ]: 9 : testFile(aCSVFileName, pDoc, 0, PureString);
552 : : //need to test the color of B3
553 : : //it's not a font color!
554 : : //formatting for B5: # ??/100 gets lost during import
555 : :
556 : : //test Sheet2
557 : 9 : const ScPatternAttr* pPattern = NULL;
558 [ + - ]: 9 : pPattern = pDoc->GetPattern(0,0,1);
559 [ + - ]: 9 : Font aFont;
560 [ + - ]: 9 : pPattern->GetFont(aFont,SC_AUTOCOL_RAW);
561 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 10", 200l, aFont.GetSize().getHeight());
[ + - ][ + - ]
[ + - ][ + - ]
562 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font color should be black", COL_AUTO, aFont.GetColor().GetColor());
[ + - ][ + - ]
[ + - ][ + - ]
563 [ + - ]: 9 : pPattern = pDoc->GetPattern(0,1,1);
564 [ + - ]: 9 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
565 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 12", 240l, aFont.GetSize().getHeight());
[ + - ][ + - ]
[ + - ][ + - ]
566 [ + - ]: 9 : pPattern = pDoc->GetPattern(0,2,1);
567 [ + - ]: 9 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
568 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be italic", ITALIC_NORMAL, aFont.GetItalic());
[ + - ][ + - ]
[ + - ][ + - ]
569 [ + - ]: 9 : pPattern = pDoc->GetPattern(0,4,1);
570 [ + - ]: 9 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
571 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be bold", WEIGHT_BOLD, aFont.GetWeight());
[ + - ][ + - ]
[ + - ][ + - ]
572 [ + - ]: 9 : pPattern = pDoc->GetPattern(1,0,1);
573 [ + - ]: 9 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
574 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be blue", COL_BLUE, aFont.GetColor().GetColor());
[ + - ][ + - ]
[ + - ][ + - ]
575 [ + - ]: 9 : pPattern = pDoc->GetPattern(1,1,1);
576 [ + - ]: 9 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
577 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be striked out with a single line", STRIKEOUT_SINGLE, aFont.GetStrikeout());
[ + - ][ + - ]
[ + - ][ + - ]
578 : : //some tests on sheet2 only for ods
579 [ + + ]: 9 : if (nFormat == ODS)
580 : : {
581 [ + - ]: 3 : pPattern = pDoc->GetPattern(1,2,1);
582 [ + - ]: 3 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
583 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be striked out with a double line", STRIKEOUT_DOUBLE, aFont.GetStrikeout());
[ + - ][ + - ]
[ + - ][ + - ]
584 [ + - ]: 3 : pPattern = pDoc->GetPattern(1,3,1);
585 [ + - ]: 3 : pPattern->GetFont(aFont, SC_AUTOCOL_RAW);
586 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be underlined with a dotted line", UNDERLINE_DOTTED, aFont.GetUnderline());
[ + - ][ + - ]
[ + - ][ + - ]
587 : : //check row height import
588 : : //disable for now until we figure out cause of win tinderboxes test failures
589 : : //CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(256), pDoc->GetRowHeight(0,1) ); //0.178in
590 : : //CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(304), pDoc->GetRowHeight(1,1) ); //0.211in
591 : : //CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(477), pDoc->GetRowHeight(5,1) ); //0.3311in
592 : : //check column width import
593 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(555), pDoc->GetColWidth(4,1) ); //0.3854in
[ + - ][ + - ]
[ + - ][ + - ]
594 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(1280), pDoc->GetColWidth(5,1) ); //0.889in
[ + - ][ + - ]
[ + - ][ + - ]
595 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(4153), pDoc->GetColWidth(6,1) ); //2.8839in
[ + - ][ + - ]
[ + - ][ + - ]
596 : : //test case for i53253 where a cell has text with different styles and space between the text.
597 : 3 : rtl::OUString aTestStr;
598 [ + - ]: 3 : pDoc->GetString(3,0,1, aTestStr);
599 : 3 : rtl::OUString aKnownGoodStr("text14 space");
600 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL( aKnownGoodStr, aTestStr );
[ + - ][ + - ]
[ + - ]
601 : : //test case for cell text with line breaks.
602 [ + - ]: 3 : pDoc->GetString(3,5,1, aTestStr);
603 : 3 : aKnownGoodStr = "Hello,\nCalc!";
604 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL( aKnownGoodStr, aTestStr );
[ + - ][ + - ]
[ + - ]
605 : : }
606 [ + - ]: 9 : pPattern = pDoc->GetPattern(1,4,1);
607 [ + - ]: 9 : Color aColor = static_cast<const SvxBrushItem&>(pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
608 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_MESSAGE("background color should be green", aColor == COL_LIGHTGREEN);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
609 [ + - ]: 9 : pPattern = pDoc->GetPattern(2,0,1);
610 [ + - ]: 9 : SvxCellHorJustify eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
611 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("cell content should be aligned centre horizontally", SVX_HOR_JUSTIFY_CENTER, eHorJustify);
[ + - ][ + - ]
[ + - ]
612 : : //test alignment
613 [ + - ]: 9 : pPattern = pDoc->GetPattern(2,1,1);
614 [ + - ]: 9 : eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
615 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("cell content should be aligned right horizontally", SVX_HOR_JUSTIFY_RIGHT, eHorJustify);
[ + - ][ + - ]
[ + - ]
616 [ + - ]: 9 : pPattern = pDoc->GetPattern(2,2,1);
617 [ + - ]: 9 : eHorJustify = static_cast<SvxCellHorJustify>(static_cast<const SvxHorJustifyItem&>(pPattern->GetItem(ATTR_HOR_JUSTIFY)).GetValue());
618 [ + - ][ + - ]: 9 : CPPUNIT_ASSERT_EQUAL_MESSAGE("cell content should be aligned block horizontally", SVX_HOR_JUSTIFY_BLOCK, eHorJustify);
[ + - ][ + - ]
[ + - ]
619 : :
620 : : //test Sheet3 only for ods
621 [ + + ]: 9 : if ( nFormat == ODS )
622 : : {
623 [ + - ]: 3 : rtl::OUString aCondString = getConditionalFormatString(pDoc, 3,0,2);
624 [ + - ][ + - ]: 3 : pFiltersTest->createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("conditionalFormatting.")), aCSVFileName);
625 [ + - ]: 3 : testCondFile(aCSVFileName, pDoc, 2);
626 [ + - ]: 9 : }
627 : 9 : }
628 : :
629 : : }
630 : :
631 : 3 : void ScFiltersTest::testFormatsODS()
632 : : {
633 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("formats."));
634 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0);
635 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
636 : :
637 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
638 : :
639 [ + - ]: 3 : testFormats_Impl(this, pDoc, ODS);
640 [ + - ][ + - ]: 3 : xDocSh->DoClose();
641 : 3 : }
642 : :
643 : 3 : void ScFiltersTest::testFormatsXLS()
644 : : {
645 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("formats."));
646 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1);
647 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
648 : :
649 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
650 : :
651 [ + - ]: 3 : testFormats_Impl(this, pDoc, XLS);
652 [ + - ][ + - ]: 3 : xDocSh->DoClose();
653 : 3 : }
654 : :
655 : 3 : void ScFiltersTest::testFormatsXLSX()
656 : : {
657 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("formats."));
658 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc(aFileNameBase, 2);
659 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
660 : :
661 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
662 : :
663 [ + - ]: 3 : testFormats_Impl(this, pDoc, XLSX);
664 [ + - ][ + - ]: 3 : xDocSh->DoClose();
665 : 3 : }
666 : :
667 : 3 : void ScFiltersTest::testMatrixODS()
668 : : {
669 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("matrix."));
670 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
671 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
672 : :
673 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
674 : :
675 : 3 : rtl::OUString aCSVFileName;
676 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName);
677 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
678 : :
679 [ + - ][ + - ]: 3 : xDocSh->DoClose();
680 : 3 : }
681 : :
682 : 3 : void ScFiltersTest::testMatrixXLS()
683 : : {
684 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("matrix."));
685 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 1);
686 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
687 : :
688 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load matrix.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
689 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
690 : :
691 : 3 : rtl::OUString aCSVFileName;
692 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName);
693 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 0);
694 : :
695 [ + - ][ + - ]: 3 : xDocSh->DoClose();
696 : 3 : }
697 : :
698 : 3 : void ScFiltersTest::testBorderODS()
699 : : {
700 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("border."));
701 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
702 : :
703 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load border.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
704 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
705 : :
706 : 3 : const editeng::SvxBorderLine* pLeft = NULL;
707 : 3 : const editeng::SvxBorderLine* pTop = NULL;
708 : 3 : const editeng::SvxBorderLine* pRight = NULL;
709 : 3 : const editeng::SvxBorderLine* pBottom = NULL;
710 : :
711 [ + - ]: 3 : pDoc->GetBorderLines( 0, 1, 0, &pLeft, &pTop, &pRight, &pBottom );
712 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pLeft);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
713 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pTop);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
714 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pBottom);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
715 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
716 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
717 [ + - ]: 3 : table::BorderLineStyle::SOLID);
718 : :
719 [ + - ]: 3 : pDoc->GetBorderLines( 2, 1, 0, &pLeft, &pTop, &pRight, &pBottom );
720 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pLeft);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
721 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pTop);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
722 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pBottom);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
723 : :
724 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
725 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
726 [ + - ]: 3 : table::BorderLineStyle::SOLID);
727 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),20L);
[ + - ][ + - ]
[ + - ]
728 : :
729 [ + - ]: 3 : pDoc->GetBorderLines( 2, 8, 0, &pLeft, &pTop, &pRight, &pBottom );
730 : :
731 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pLeft);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
732 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pTop);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
733 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pBottom);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
734 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
735 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
736 [ + - ]: 3 : table::BorderLineStyle::SOLID);
737 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),5L);
[ + - ][ + - ]
[ + - ]
738 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight->GetColor() == Color(COL_BLUE));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
739 : :
740 [ + - ][ + - ]: 3 : xDocSh->DoClose();
741 : 3 : }
742 : :
743 : 3 : void ScFiltersTest::testBorderXLS()
744 : : {
745 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("border."));
746 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 1);
747 : :
748 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load border.xls", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
749 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
750 : :
751 : 3 : const editeng::SvxBorderLine* pLeft = NULL;
752 : 3 : const editeng::SvxBorderLine* pTop = NULL;
753 : 3 : const editeng::SvxBorderLine* pRight = NULL;
754 : 3 : const editeng::SvxBorderLine* pBottom = NULL;
755 : :
756 [ + - ]: 3 : pDoc->GetBorderLines( 2, 3, 0, &pLeft, &pTop, &pRight, &pBottom );
757 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
758 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
759 [ + - ]: 3 : table::BorderLineStyle::SOLID);
760 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),6L);
[ + - ][ + - ]
[ + - ]
761 : :
762 [ + - ]: 3 : pDoc->GetBorderLines( 3, 5, 0, &pLeft, &pTop, &pRight, &pBottom );
763 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
764 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
765 [ + - ]: 3 : table::BorderLineStyle::SOLID);
766 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),18L);
[ + - ][ + - ]
[ + - ]
767 : :
768 [ + - ]: 3 : pDoc->GetBorderLines( 5, 7, 0, &pLeft, &pTop, &pRight, &pBottom );
769 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pRight);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
770 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(),
[ + - ][ + - ]
771 [ + - ]: 3 : table::BorderLineStyle::SOLID);
772 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),24L);
[ + - ][ + - ]
[ + - ][ + - ]
773 : 3 : }
774 : : struct Border
775 : : {
776 : : sal_Int16 column;
777 : : sal_Int32 row;
778 : : long leftWidth;
779 : : long topWidth;
780 : : long rightWidth;
781 : : long bottomWidth;
782 : : sal_uInt16 lOutWidth;
783 : : sal_uInt16 lInWidth;
784 : : sal_uInt16 lDistance;
785 : : sal_uInt16 tOutWidth;
786 : : sal_uInt16 tInWidth;
787 : : sal_uInt16 tDistance;
788 : : sal_uInt16 rOutWidth;
789 : : sal_uInt16 rInWidth;
790 : : sal_uInt16 rDistance;
791 : : sal_uInt16 bOutWidth;
792 : : sal_uInt16 bInWidth;
793 : : sal_uInt16 bDistance;
794 : : sal_Int32 lStyle;
795 : : sal_Int32 tStyle;
796 : : sal_Int32 rStyle;
797 : : sal_Int32 bStyle;
798 : : // that's a monstrum
799 : 51 : Border(sal_Int16 col, sal_Int32 r, sal_Int32 lW, sal_Int32 tW, sal_Int32 rW, sal_Int32 bW, sal_uInt16 lOutW, sal_uInt16 lInW,
800 : : sal_uInt16 lDist, sal_uInt16 tOutW, sal_uInt16 tInW, sal_uInt16 tDist, sal_uInt16 rOutW, sal_uInt16 rInW, sal_uInt16 rDist,
801 : : sal_uInt16 bOutW, sal_uInt16 bInW, sal_uInt16 bDist, sal_Int32 lSt, sal_Int32 tSt, sal_Int32 rSt, sal_Int32 bSt):
802 : : column(col), row(r), leftWidth(lW), topWidth(tW), rightWidth(rW), bottomWidth(bW), lOutWidth(lOutW), lInWidth(lInW), lDistance(lDist),
803 : : tOutWidth(tOutW), tInWidth(tInW), tDistance(tDist), rOutWidth(rOutW), rInWidth(rInW), rDistance(rDist), bOutWidth(bOutW), bInWidth(bInW),
804 : 51 : bDistance(bDist), lStyle(lSt), tStyle(tSt), rStyle(rSt), bStyle(bSt) {};
805 : : };
806 : :
807 : 3 : void ScFiltersTest::testBordersOoo33()
808 : : {
809 [ + - ]: 3 : std::vector<Border> borders;
810 [ + - ]: 3 : borders.push_back(Border(1, 1, 22, 22, 22, 22, 1, 1, 20, 1, 1, 20, 1, 1, 20, 1, 1, 20, 3, 3, 3, 3));
811 [ + - ]: 3 : borders.push_back(Border(1, 3, 52, 52, 52, 52, 1, 1, 50, 1, 1, 50, 1, 1, 50, 1, 1, 50, 3, 3, 3, 3));
812 [ + - ]: 3 : borders.push_back(Border(1, 5, 60, 60, 60, 60, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 3, 3, 3, 3));
813 [ + - ]: 3 : borders.push_back(Border(1, 7, 150, 150, 150, 150, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 3, 3, 3, 3));
814 [ + - ]: 3 : borders.push_back(Border(1, 9, 71, 71, 71, 71, 20, 1, 50, 20, 1, 50, 20, 1, 50, 20, 1, 50, 3, 3, 3, 3));
815 [ + - ]: 3 : borders.push_back(Border(1, 11, 101, 101, 101, 101, 50, 1, 50, 50, 1, 50, 50, 1, 50, 50, 1, 50, 3, 3, 3, 3));
816 [ + - ]: 3 : borders.push_back(Border(1, 13, 131, 131, 131, 131, 80, 1, 50, 80, 1, 50, 80, 1, 50, 80, 1, 50, 3, 3, 3, 3));
817 [ + - ]: 3 : borders.push_back(Border(1, 15, 120, 120, 120, 120, 50, 20, 50, 50, 20, 50, 50, 20, 50, 50, 20, 50, 3, 3, 3, 3));
818 [ + - ]: 3 : borders.push_back(Border(1, 17, 90, 90, 90, 90, 20, 50, 20, 20, 50, 20, 20, 50, 20, 20, 50, 20, 3, 3, 3, 3));
819 [ + - ]: 3 : borders.push_back(Border(1, 19, 180, 180, 180, 180, 80, 50, 50, 80, 50, 50, 80, 50, 50, 80, 50, 50, 3, 3, 3, 3));
820 [ + - ]: 3 : borders.push_back(Border(1, 21, 180, 180, 180, 180, 50, 80, 50, 50, 80, 50, 50, 80, 50, 50, 80, 50, 3, 3, 3, 3));
821 [ + - ]: 3 : borders.push_back(Border(4, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0));
822 [ + - ]: 3 : borders.push_back(Border(4, 3, 10, 10, 10, 10, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 0, 0, 0, 0));
823 [ + - ]: 3 : borders.push_back(Border(4, 5, 20, 20, 20, 20, 20, 0, 0, 20, 0, 0, 20, 0, 0, 20, 0, 0, 0, 0, 0, 0));
824 [ + - ]: 3 : borders.push_back(Border(4, 7, 50, 50, 50, 50, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 0, 0, 0, 0));
825 [ + - ]: 3 : borders.push_back(Border(4, 9, 80, 80, 80, 80, 80, 0, 0, 80, 0, 0, 80, 0, 0, 80, 0, 0, 0, 0, 0, 0));
826 [ + - ]: 3 : borders.push_back(Border(4, 11, 100, 100, 100, 100, 100, 0, 0, 100, 0, 0, 100, 0, 0, 100, 0, 0, 0, 0, 0, 0));
827 : :
828 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("borders_ooo33."));
829 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
830 : :
831 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load borders_ooo33.*", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
832 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
833 : :
834 : 3 : const editeng::SvxBorderLine* pLeft = NULL;
835 : 3 : const editeng::SvxBorderLine* pTop = NULL;
836 : 3 : const editeng::SvxBorderLine* pRight = NULL;
837 : 3 : const editeng::SvxBorderLine* pBottom = NULL;
838 : 3 : sal_Int16 temp = 0;
839 [ + + ]: 21 : for(sal_Int16 i = 0; i<6; ++i)
840 : : {
841 [ + + ]: 414 : for(sal_Int32 j = 0; j<22; ++j)
842 : : {
843 [ + - ]: 396 : pDoc->GetBorderLines( i, j, 0, &pLeft, &pTop, &pRight, &pBottom );
844 [ + + ][ + + ]: 396 : if(pLeft!=NULL && pTop!=NULL && pRight!=NULL && pBottom!=NULL)
[ + - ][ + - ]
845 : : {
846 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].column, i);
[ + - ][ + - ]
[ + - ]
847 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].row, j);
[ + - ][ + - ]
[ + - ]
848 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].leftWidth, pLeft->GetWidth());
[ + - ][ + - ]
[ + - ]
849 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].topWidth, pTop->GetWidth());
[ + - ][ + - ]
[ + - ]
850 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].rightWidth, pRight->GetWidth());
[ + - ][ + - ]
[ + - ]
851 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].bottomWidth, pBottom->GetWidth());
[ + - ][ + - ]
[ + - ]
852 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].lOutWidth, pLeft->GetOutWidth());
[ + - ][ + - ]
[ + - ][ + - ]
853 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].lInWidth, pLeft->GetInWidth());
[ + - ][ + - ]
[ + - ][ + - ]
854 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].lDistance, pLeft->GetDistance());
[ + - ][ + - ]
[ + - ][ + - ]
855 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].tOutWidth, pTop->GetOutWidth());
[ + - ][ + - ]
[ + - ][ + - ]
856 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].tInWidth, pTop->GetInWidth());
[ + - ][ + - ]
[ + - ][ + - ]
857 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].tDistance, pTop->GetDistance());
[ + - ][ + - ]
[ + - ][ + - ]
858 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].rOutWidth, pRight->GetOutWidth());
[ + - ][ + - ]
[ + - ][ + - ]
859 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].rInWidth, pRight->GetInWidth());
[ + - ][ + - ]
[ + - ][ + - ]
860 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].rDistance, pRight->GetDistance());
[ + - ][ + - ]
[ + - ][ + - ]
861 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].bOutWidth, pBottom->GetOutWidth());
[ + - ][ + - ]
[ + - ][ + - ]
862 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].bInWidth, pBottom->GetInWidth());
[ + - ][ + - ]
[ + - ][ + - ]
863 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].bDistance, pBottom->GetDistance());
[ + - ][ + - ]
[ + - ][ + - ]
864 : 51 : sal_Int32 tempStyle = pLeft->GetBorderLineStyle();
865 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].lStyle, tempStyle);
[ + - ][ + - ]
[ + - ]
866 : 51 : tempStyle = pTop->GetBorderLineStyle();
867 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].tStyle, tempStyle);
[ + - ][ + - ]
[ + - ]
868 : 51 : tempStyle = pRight->GetBorderLineStyle();
869 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].rStyle, tempStyle);
[ + - ][ + - ]
[ + - ]
870 : 51 : tempStyle = pBottom->GetBorderLineStyle();
871 [ + - ][ + - ]: 51 : CPPUNIT_ASSERT_EQUAL(borders[temp].bStyle, tempStyle);
[ + - ][ + - ]
[ + - ]
872 : 51 : ++temp;
873 : : }
874 : : }
875 [ + - ]: 3 : }
876 : 3 : }
877 : :
878 : 3 : void ScFiltersTest::testBugFixesODS()
879 : : {
880 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("bug-fixes."));
881 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
882 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
883 : 3 : rtl::OUString aFileName;
884 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
885 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
886 [ + - ][ + - ]: 3 : std::cout << aFileFormats[0].pName << " Test" << std::endl;
[ + - ]
887 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[0].nFormatType);
888 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
889 : :
890 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load bugFixes.ods", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
891 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
892 : :
893 : : {
894 : : // fdo
895 : 3 : rtl::OUString aCSVFileName;
896 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bugFix_Sheet2.")), aCSVFileName);
897 [ + - ]: 3 : testFile(aCSVFileName, pDoc, 1);
898 : : }
899 : :
900 : : {
901 : : // fdo#40426
902 [ + - ][ + - ]: 3 : ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByName("DBRange1");
[ + - ]
903 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pDBData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
904 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pDBData->HasHeader());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
905 : : // no header
906 [ + - ][ + - ]: 3 : pDBData = pDoc->GetDBCollection()->getNamedDBs().findByName("DBRange2");
[ + - ]
907 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pDBData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
908 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(!pDBData->HasHeader());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
909 : : }
910 : :
911 [ + - ][ + - ]: 3 : xDocSh->DoClose();
912 : 3 : }
913 : :
914 : 3 : void ScFiltersTest::testBugFixesXLS()
915 : : {
916 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("bug-fixes."));
917 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[1].pName, strlen(aFileFormats[1].pName), RTL_TEXTENCODING_UTF8 );
918 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ;
919 : 3 : rtl::OUString aFileName;
920 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
921 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8);
922 [ + - ][ + - ]: 3 : std::cout << aFileFormats[1].pName << " Test" << std::endl;
[ + - ]
923 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[1].nFormatType);
924 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
925 : :
926 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load bugFixes.xls", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
927 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
928 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
929 [ + - ][ + - ]: 3 : xDocSh->DoClose();
930 : 3 : }
931 : :
932 : 3 : void ScFiltersTest::testBugFixesXLSX()
933 : : {
934 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("bug-fixes."));
935 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[2].pName, strlen(aFileFormats[2].pName), RTL_TEXTENCODING_UTF8 );
936 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[2].pFilterName, strlen(aFileFormats[2].pFilterName), RTL_TEXTENCODING_UTF8) ;
937 : 3 : rtl::OUString aFileName;
938 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
939 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[2].pTypeName, strlen(aFileFormats[2].pTypeName), RTL_TEXTENCODING_UTF8);
940 [ + - ][ + - ]: 3 : std::cout << aFileFormats[2].pName << " Test" << std::endl;
[ + - ]
941 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[2].nFormatType);
942 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
943 : :
944 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load bugFixes.xlsx", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
945 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
946 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
947 [ + - ][ + - ]: 3 : xDocSh->DoClose();
948 : 3 : }
949 : :
950 : : namespace {
951 : :
952 : 12 : void checkMergedCells( ScDocument* pDoc, const ScAddress& rStartAddress,
953 : : const ScAddress& rExpectedEndAddress )
954 : : {
955 : 12 : SCCOL nActualEndCol = rStartAddress.Col();
956 : 12 : SCROW nActualEndRow = rStartAddress.Row();
957 : 12 : pDoc->ExtendMerge( rStartAddress.Col(), rStartAddress.Row(),
958 [ + - ]: 24 : nActualEndCol, nActualEndRow, rStartAddress.Tab(), false );
959 : 12 : rtl::OString sTab = rtl::OString::valueOf( static_cast<sal_Int32>(rStartAddress.Tab() + 1) );
960 : 12 : rtl::OString msg = "Merged cells are not correctly imported on sheet" + sTab;
961 : 12 : rtl::OString msgCol = msg + "; end col";
962 : 12 : rtl::OString msgRow = msg + "; end row";
963 [ + - ][ + - ]: 12 : CPPUNIT_ASSERT_EQUAL_MESSAGE( msgCol.pData->buffer, rExpectedEndAddress.Col(), nActualEndCol );
[ + - ][ + - ]
[ + - ]
964 [ + - ][ + - ]: 12 : CPPUNIT_ASSERT_EQUAL_MESSAGE( msgRow.pData->buffer, rExpectedEndAddress.Row(), nActualEndRow );
[ + - ][ + - ]
[ + - ]
965 : 12 : }
966 : :
967 : : }
968 : :
969 : 3 : void ScFiltersTest::testMergedCellsODS()
970 : : {
971 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("merged."));
972 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
973 : :
974 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
975 : :
976 : : //check sheet1 content
977 : 3 : rtl::OUString aCSVFileName1;
978 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged1.")), aCSVFileName1);
979 [ + - ]: 3 : testFile(aCSVFileName1, pDoc, 0);
980 : :
981 : : //check sheet1 merged cells
982 [ + - ]: 3 : checkMergedCells( pDoc, ScAddress( 0, 0, 0 ), ScAddress( 5, 11, 0 ) );
983 [ + - ]: 3 : checkMergedCells( pDoc, ScAddress( 7, 2, 0 ), ScAddress( 9, 12, 0 ) );
984 [ + - ]: 3 : checkMergedCells( pDoc, ScAddress( 3, 15, 0 ), ScAddress( 7, 23, 0 ) );
985 : :
986 : : //check sheet2 content
987 : 3 : rtl::OUString aCSVFileName2;
988 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged2.")), aCSVFileName2);
989 [ + - ]: 3 : testFile(aCSVFileName2, pDoc, 1);
990 : :
991 : : //check sheet2 merged cells
992 [ + - ]: 3 : checkMergedCells( pDoc, ScAddress( 4, 3, 1 ), ScAddress( 6, 15, 1 ) );
993 : :
994 [ + - ][ + - ]: 3 : xDocSh->DoClose();
995 : 3 : }
996 : :
997 : 3 : void ScFiltersTest::testRepeatedColumnsODS()
998 : : {
999 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns."));
1000 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
1001 : :
1002 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1003 : :
1004 : : //text
1005 : 3 : rtl::OUString aCSVFileName1;
1006 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns1.")), aCSVFileName1);
1007 [ + - ]: 3 : testFile(aCSVFileName1, pDoc, 0);
1008 : :
1009 : : //numbers
1010 : 3 : rtl::OUString aCSVFileName2;
1011 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns2.")), aCSVFileName2);
1012 [ + - ]: 3 : testFile(aCSVFileName2, pDoc, 1);
1013 : :
1014 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1015 : 3 : }
1016 : :
1017 : : namespace {
1018 : :
1019 : : //for cleaner passing of parameters
1020 [ + - ][ + - ]: 6 : struct ValDataTestParams
[ + - ]
1021 : : {
1022 : : ScValidationMode eValMode;
1023 : : ScConditionMode eCondOp;
1024 : : String aStrVal1, aStrVal2;
1025 : : ScDocument* pDocument;
1026 : : ScAddress aPosition;
1027 : : String aErrorTitle, aErrorMessage;
1028 : : ScValidErrorStyle eErrorStyle;
1029 : : sal_uLong nExpectedIndex;
1030 : :
1031 : 6 : ValDataTestParams( ScValidationMode eMode, ScConditionMode eOp,
1032 : : String aExpr1, String aExpr2, ScDocument* pDoc,
1033 : : ScAddress aPos, String aETitle, String aEMsg,
1034 : : ScValidErrorStyle eEStyle, sal_uLong nIndex ):
1035 : : eValMode(eMode), eCondOp(eOp), aStrVal1(aExpr1),
1036 : : aStrVal2(aExpr2), pDocument(pDoc), aPosition(aPos),
1037 : : aErrorTitle(aETitle), aErrorMessage(aEMsg),
1038 [ + - ][ + - ]: 6 : eErrorStyle(eEStyle), nExpectedIndex(nIndex) { };
[ + - ]
1039 : : };
1040 : :
1041 : 6 : void checkValiditationEntries( const ValDataTestParams& rVDTParams )
1042 : : {
1043 : 6 : ScDocument* pDoc = rVDTParams.pDocument;
1044 : :
1045 : : //create expected data validation entry
1046 : : ScValidationData aValData(
1047 : : rVDTParams.eValMode, rVDTParams.eCondOp, rVDTParams.aStrVal1,
1048 [ + - ]: 6 : rVDTParams.aStrVal2, pDoc, rVDTParams.aPosition, EMPTY_STRING,
1049 [ + - ]: 6 : EMPTY_STRING, pDoc->GetStorageGrammar(), pDoc->GetStorageGrammar()
1050 [ + - ]: 12 : );
1051 [ + - ]: 6 : aValData.SetIgnoreBlank( true );
1052 : 6 : aValData.SetListType( 1 );
1053 [ + - ]: 6 : aValData.ResetInput();
1054 [ + - ]: 6 : aValData.SetError( rVDTParams.aErrorTitle, rVDTParams.aErrorMessage, rVDTParams.eErrorStyle );
1055 [ + - ][ + - ]: 6 : aValData.SetSrcString( EMPTY_STRING );
1056 : :
1057 : : //get actual data validation entry from document
1058 [ + - ]: 6 : const ScValidationData* pValDataTest = pDoc->GetValidationEntry( rVDTParams.nExpectedIndex );
1059 : :
1060 : 6 : sal_Int32 nCol( static_cast<sal_Int32>(rVDTParams.aPosition.Col()) );
1061 : 6 : sal_Int32 nRow( static_cast<sal_Int32>(rVDTParams.aPosition.Row()) );
1062 : 6 : sal_Int32 nTab( static_cast<sal_Int32>(rVDTParams.aPosition.Tab()) );
1063 : 6 : rtl::OStringBuffer sMsg("Data Validation Entry with base-cell-address: (");
1064 [ + - ][ + - ]: 6 : sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") was not imported correctly.");
[ + - ][ + - ]
[ + - ][ + - ]
1065 : : //check if expected and actual data validation entries are equal
1066 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE( sMsg.getStr(), pValDataTest && aValData.EqualEntries(*pValDataTest) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ + - ]
[ + - ]
1067 : 6 : }
1068 : :
1069 : 6 : void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, const ScDocument* pDoc )
1070 : : {
1071 : 6 : SCCOL nBCol( rValBaseAddr.Col() );
1072 : 6 : SCROW nBRow( rValBaseAddr.Row() );
1073 : 6 : SCTAB nTab( static_cast<const sal_Int32>(rValBaseAddr.Tab()) );
1074 : : //get from the document the data validation entry we are checking against
1075 : 6 : const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(nBCol, nBRow, nTab, ATTR_VALIDDATA) );
1076 : 6 : const ScValidationData* pValData = pDoc->GetValidationEntry( pItem->GetValue() );
1077 : :
1078 : : //check that each cell in the expected range is associated with the data validation entry
1079 [ + + ]: 24 : for(SCCOL i = rRange.aStart.Col(); i <= rRange.aEnd.Col(); ++i)
1080 : : {
1081 [ + + ]: 108 : for(SCROW j = rRange.aStart.Row(); j <= rRange.aEnd.Row(); ++j)
1082 : : {
1083 : 90 : const SfxUInt32Item* pItemTest = static_cast<const SfxUInt32Item*>( pDoc->GetAttr(i, j, nTab, ATTR_VALIDDATA) );
1084 : 90 : const ScValidationData* pValDataTest = pDoc->GetValidationEntry( pItemTest->GetValue() );
1085 : : //prevent string operations for occurring unnecessarily
1086 [ - + ][ - + ]: 90 : if(!(pValDataTest && pValData->GetKey() == pValDataTest->GetKey()))
[ + - ]
1087 : : {
1088 : 0 : sal_Int32 nCol = static_cast<const sal_Int32>(i);
1089 : 0 : sal_Int32 nRow = static_cast<const sal_Int32>(j);
1090 : 0 : sal_Int32 nTab32 = static_cast<const sal_Int32>(nTab);
1091 : 0 : rtl::OStringBuffer sMsg("\nData validation entry base-cell-address: (");
1092 [ # # ][ # # ]: 0 : sMsg.append( static_cast<const sal_Int32>(nBCol) ).append(",");
1093 [ # # ][ # # ]: 0 : sMsg.append( static_cast<const sal_Int32>(nBRow) ).append(",");
1094 [ # # ][ # # ]: 0 : sMsg.append( nTab32 ).append(")\n");
1095 [ # # ][ # # ]: 0 : sMsg.append("Cell: (").append(nCol).append(",").append(nRow).append(",").append(nTab32).append(")");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1096 : 0 : sal_uInt32 expectedKey(pValData->GetKey());
1097 : 0 : sal_uInt32 actualKey(-1);
1098 [ # # ]: 0 : if(pValDataTest)
1099 : 0 : actualKey = pValDataTest->GetKey();
1100 [ # # ][ # # ]: 0 : CPPUNIT_ASSERT_EQUAL_MESSAGE(sMsg.getStr(), expectedKey, actualKey);
[ # # ][ # # ]
[ # # ]
1101 : : }
1102 : : }
1103 : : }
1104 : 6 : }
1105 : :
1106 : : }
1107 : :
1108 : 3 : void ScFiltersTest::testDataValidityODS()
1109 : : {
1110 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("dataValidity."));
1111 [ + - ]: 3 : ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0);
1112 : :
1113 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1114 : :
1115 : 3 : ScAddress aValBaseAddr1( 2,6,0 ); //sheet1
1116 : 3 : ScAddress aValBaseAddr2( 2,3,1 ); //sheet2
1117 : :
1118 : : //sheet1's expected Data Validation Entry values
1119 : : ValDataTestParams aVDTParams1(
1120 [ + - ]: 3 : SC_VALID_DECIMAL, SC_COND_GREATER, String("3.14"), EMPTY_STRING, pDoc,
1121 : : aValBaseAddr1, String("Too small"),
1122 : : String("The number you are trying to enter is not greater than 3.14! Are you sure you want to enter it anyway?"),
1123 : : SC_VALERR_WARNING, 1
1124 [ + - ][ + - ]: 6 : );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1125 : : //sheet2's expected Data Validation Entry values
1126 : : ValDataTestParams aVDTParams2(
1127 : : SC_VALID_WHOLE, SC_COND_BETWEEN, String("1"), String("10"), pDoc,
1128 : : aValBaseAddr2, String("Error sheet 2"),
1129 : : String("Must be a whole number between 1 and 10."),
1130 : : SC_VALERR_STOP, 2
1131 [ + - ][ + - ]: 3 : );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1132 : : //check each sheet's Data Validation Entries
1133 [ + - ]: 3 : checkValiditationEntries( aVDTParams1 );
1134 [ + - ]: 3 : checkValiditationEntries( aVDTParams2 );
1135 : :
1136 : : //expected ranges to be associated with data validity
1137 : 3 : ScRange aRange1( 2,2,0, 2,6,0 ); //sheet1
1138 : 3 : ScRange aRange2( 2,3,1, 6,7,1 ); //sheet2
1139 : :
1140 : : //check each sheet's cells for data validity
1141 [ + - ]: 3 : checkCellValidity( aValBaseAddr1, aRange1, pDoc );
1142 [ + - ]: 3 : checkCellValidity( aValBaseAddr2, aRange2, pDoc );
1143 : :
1144 : : //check each sheet's content
1145 : 3 : rtl::OUString aCSVFileName1;
1146 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity1.")), aCSVFileName1);
1147 [ + - ]: 3 : testFile(aCSVFileName1, pDoc, 0);
1148 : :
1149 : 3 : rtl::OUString aCSVFileName2;
1150 [ + - ][ + - ]: 3 : createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dataValidity2.")), aCSVFileName2);
1151 [ + - ]: 3 : testFile(aCSVFileName2, pDoc, 1);
1152 : :
1153 [ + - ][ + - ]: 3 : xDocSh->DoClose();
[ + - ][ + - ]
1154 : 3 : }
1155 : :
1156 : 3 : void ScFiltersTest::testBrokenQuotesCSV()
1157 : : {
1158 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes."));
1159 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[CSV].pName, strlen(aFileFormats[CSV].pName), RTL_TEXTENCODING_UTF8 );
1160 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[CSV].pFilterName, strlen(aFileFormats[CSV].pFilterName), RTL_TEXTENCODING_UTF8) ;
1161 : 3 : rtl::OUString aFileName;
1162 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1163 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[CSV].pTypeName, strlen(aFileFormats[CSV].pTypeName), RTL_TEXTENCODING_UTF8);
1164 [ + - ][ + - ]: 3 : std::cout << aFileFormats[CSV].pName << " Test" << std::endl;
[ + - ]
1165 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[CSV].nFormatType);
1166 : :
1167 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load fdo48621_broken_quotes.csv", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1168 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1169 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1170 : :
1171 [ + - ]: 3 : rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("fdo48621_broken_quotes_exported."));
1172 : 3 : rtl::OUString aCSVPath;
1173 [ + - ]: 3 : createCSVPath( aSheet2CSV, aCSVPath );
1174 : : // fdo#48621
1175 [ + - ]: 3 : testFile( aCSVPath, pDoc, 0, PureString);
1176 : :
1177 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1178 : 3 : }
1179 : :
1180 : 3 : void ScFiltersTest::testSharedFormulaXLSX()
1181 : : {
1182 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("shared-formula."));
1183 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
1184 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
1185 : 3 : rtl::OUString aFileName;
1186 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1187 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8);
1188 [ + - ][ + - ]: 3 : std::cout << aFileFormats[XLSX].pName << " Test" << std::endl;
[ + - ]
1189 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[XLSX].nFormatType);
1190 [ + - ]: 3 : xDocSh->DoHardRecalc(true);
1191 : :
1192 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load shared-formula.xlsx", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1193 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1194 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1195 : :
1196 : 3 : rtl::OUString aCSVPath;
1197 [ + - ]: 3 : createCSVPath( aFileNameBase, aCSVPath );
1198 [ + - ]: 3 : testFile( aCSVPath, pDoc, 0 );
1199 : :
1200 : : //test some additional properties
1201 [ + - ]: 3 : ScRangeName* pName = pDoc->GetRangeName();
1202 [ + - ][ + - ]: 6 : for (ScRangeName::iterator itr = pName->begin(); itr != pName->end(); ++itr)
[ + - ][ + - ]
[ + + ]
1203 : : {
1204 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(itr->second->GetType() & RT_SHARED);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1205 : : }
1206 : :
1207 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1208 : 3 : }
1209 : :
1210 : 3 : void ScFiltersTest::testCellValueXLSX()
1211 : : {
1212 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("cell-value."));
1213 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
1214 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
1215 : 3 : rtl::OUString aFileName;
1216 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1217 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8);
1218 [ + - ][ + - ]: 3 : std::cout << aFileFormats[XLSX].pName << " Test" << std::endl;
[ + - ]
1219 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[XLSX].nFormatType);
1220 : :
1221 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load cell-value.xlsx", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1222 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1223 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1224 : :
1225 : 3 : rtl::OUString aCSVPath;
1226 [ + - ]: 3 : createCSVPath( aFileNameBase, aCSVPath );
1227 [ + - ]: 3 : testFile( aCSVPath, pDoc, 0 );
1228 : :
1229 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1230 : 3 : }
1231 : :
1232 : 6 : void ScFiltersTest::testPassword_Impl(const rtl::OUString& aFileNameBase)
1233 : : {
1234 [ + - ]: 6 : rtl::OUString aFileExtension(aFileFormats[0].pName, strlen(aFileFormats[0].pName), RTL_TEXTENCODING_UTF8 );
1235 [ + - ]: 6 : rtl::OUString aFilterName(aFileFormats[0].pFilterName, strlen(aFileFormats[0].pFilterName), RTL_TEXTENCODING_UTF8) ;
1236 : 6 : rtl::OUString aFileName;
1237 [ + - ]: 6 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1238 [ + - ]: 6 : rtl::OUString aFilterType(aFileFormats[0].pTypeName, strlen(aFileFormats[0].pTypeName), RTL_TEXTENCODING_UTF8);
1239 : :
1240 : 6 : sal_uInt32 nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
1241 : : SfxFilter* aFilter = new SfxFilter(
1242 : : aFilterName,
1243 : : rtl::OUString(), aFileFormats[0].nFormatType, nFormat, aFilterType, 0, rtl::OUString(),
1244 [ + - ][ + - ]: 6 : rtl::OUString(), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1245 : 6 : aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
1246 : :
1247 [ + - ][ + - ]: 6 : ScDocShellRef xDocSh = new ScDocShell;
1248 [ + - ][ + - ]: 6 : SfxMedium* pMedium = new SfxMedium(aFileName, STREAM_STD_READWRITE);
[ + - ][ + - ]
1249 [ + - ]: 6 : SfxItemSet* pSet = pMedium->GetItemSet();
1250 [ + - ][ + - ]: 6 : pSet->Put(SfxStringItem(SID_PASSWORD, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test"))));
[ + - ][ + - ]
[ + - ][ + - ]
1251 [ + - ]: 6 : pMedium->SetFilter(aFilter);
1252 [ + - ][ - + ]: 6 : if (!xDocSh->DoLoad(pMedium))
1253 : : {
1254 [ # # ]: 0 : xDocSh->DoClose();
1255 : : // load failed.
1256 [ # # ]: 0 : xDocSh.Clear();
1257 : : }
1258 : :
1259 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("Failed to load password.ods", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1260 : 6 : ScDocument* pDoc = xDocSh->GetDocument();
1261 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1262 [ + - ][ + - ]: 6 : xDocSh->DoClose();
1263 : :
1264 : 6 : }
1265 : :
1266 : 3 : void ScFiltersTest::testPasswordNew()
1267 : : {
1268 : : //tests opening a file with new password algorithm
1269 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("password."));
1270 [ + - ]: 3 : testPassword_Impl(aFileNameBase);
1271 : 3 : }
1272 : :
1273 : 3 : void ScFiltersTest::testPasswordOld()
1274 : : {
1275 : : //tests opening a file with old password algorithm
1276 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("passwordOld."));
1277 [ + - ]: 3 : testPassword_Impl(aFileNameBase);
1278 : 3 : }
1279 : :
1280 : 3 : void ScFiltersTest::testControlImport()
1281 : : {
1282 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("singlecontrol."));
1283 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[XLSX].pName, strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
1284 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
1285 : 3 : rtl::OUString aFileName;
1286 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1287 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, strlen(aFileFormats[XLSX].pTypeName), RTL_TEXTENCODING_UTF8);
1288 [ + - ][ + - ]: 3 : std::cout << aFileFormats[XLSX].pName << " Test" << std::endl;
[ + - ]
1289 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[XLSX].nFormatType);
1290 : :
1291 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load cell-value.xlsx", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1292 : :
1293 [ + - ]: 3 : uno::Reference< frame::XModel > xModel = xDocSh->GetModel();
1294 [ + - ]: 3 : uno::Reference< sheet::XSpreadsheetDocument > xDoc(xModel, UNO_QUERY_THROW);
1295 [ + - ][ + - ]: 3 : uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW);
[ + - ]
1296 [ + - ][ + - ]: 3 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW);
[ + - ]
1297 [ + - ][ + - ]: 3 : uno::Reference< container::XIndexAccess > xIA_DrawPage(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW);
[ + - ]
1298 [ + - ][ + - ]: 3 : uno::Reference< drawing::XControlShape > xControlShape(xIA_DrawPage->getByIndex(0), UNO_QUERY_THROW);
[ + - ]
1299 : :
1300 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(xControlShape.is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1301 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1302 : 3 : }
1303 : :
1304 : 3 : void ScFiltersTest::testNumberFormatHTML()
1305 : : {
1306 : 3 : OUString aFileNameBase("numberformat.");
1307 : 3 : OUString aFileExt = OUString::createFromAscii(aFileFormats[HTML].pName);
1308 : 3 : OUString aFilterName = OUString::createFromAscii(aFileFormats[HTML].pFilterName);
1309 : 3 : OUString aFilterType = OUString::createFromAscii(aFileFormats[HTML].pTypeName);
1310 : :
1311 : 3 : rtl::OUString aFileName;
1312 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExt, aFileName);
1313 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[HTML].nFormatType);
1314 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1315 : :
1316 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1317 : :
1318 : : // Check the header just in case.
1319 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(0, 0, 0) == "Product");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1320 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(1, 0, 0) == "Price");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1321 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(2, 0, 0) == "Note");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1322 : :
1323 : : // B2 should be imported as a value cell.
1324 [ + - ]: 3 : bool bHasValue = pDoc->HasValueData(1, 1, 0);
1325 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Fail to import number as a value cell.", bHasValue);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1326 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Incorrect value.", pDoc->GetValue(1, 1, 0) == 199.98);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1327 : :
1328 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1329 : 3 : }
1330 : :
1331 : 3 : void ScFiltersTest::testNumberFormatCSV()
1332 : : {
1333 : 3 : OUString aFileNameBase("numberformat.");
1334 : 3 : OUString aFileExt = OUString::createFromAscii(aFileFormats[CSV].pName);
1335 : 3 : OUString aFilterName = OUString::createFromAscii(aFileFormats[CSV].pFilterName);
1336 : 3 : OUString aFilterType = OUString::createFromAscii(aFileFormats[CSV].pTypeName);
1337 : :
1338 : 3 : rtl::OUString aFileName;
1339 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExt, aFileName);
1340 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[CSV].nFormatType);
1341 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load numberformat.html", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1342 : :
1343 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1344 : :
1345 : : // Check the header just in case.
1346 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(0, 0, 0) == "Product");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1347 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(1, 0, 0) == "Price");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1348 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Cell value is not as expected", pDoc->GetString(2, 0, 0) == "Note");
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1349 : :
1350 : : // B2 should be imported as a value cell.
1351 [ + - ]: 3 : bool bHasValue = pDoc->HasValueData(1, 1, 0);
1352 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Fail to import number as a value cell.", bHasValue);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1353 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Incorrect value.", pDoc->GetValue(1, 1, 0) == 199.98);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1354 : :
1355 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1356 : 3 : }
1357 : :
1358 : 3 : void ScFiltersTest::testCellAnchoredShapesODS()
1359 : : {
1360 : 3 : OUString aFileNameBase("cell-anchored-shapes.");
1361 : 3 : OUString aFileExt = OUString::createFromAscii(aFileFormats[ODS].pName);
1362 : 3 : OUString aFilterName = OUString::createFromAscii(aFileFormats[ODS].pFilterName);
1363 : 3 : OUString aFilterType = OUString::createFromAscii(aFileFormats[ODS].pTypeName);
1364 : :
1365 : 3 : rtl::OUString aFileName;
1366 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExt, aFileName);
1367 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[ODS].nFormatType);
1368 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load cell-anchored-shapes.ods", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1369 : :
1370 : : // There are two cell-anchored objects on the first sheet.
1371 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1372 : :
1373 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("There should be at least one sheet.", pDoc->GetTableCount() > 0);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1374 : :
1375 [ + - ]: 3 : ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1376 [ + - ]: 3 : SdrPage* pPage = pDrawLayer->GetPage(0);
1377 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1378 [ + - ]: 3 : sal_uIntPtr nCount = pPage->GetObjCount();
1379 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("There should be 2 objects.", nCount == 2);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1380 [ + + ]: 9 : for (sal_uIntPtr i = 0; i < nCount; ++i)
1381 : : {
1382 [ + - ]: 6 : SdrObject* pObj = pPage->GetObj(i);
1383 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("Failed to get drawing object.", pObj);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1384 [ + - ]: 6 : ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj, false);
1385 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("Failed to retrieve user data for this object.", pData);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1386 [ + - ][ + - ]: 6 : CPPUNIT_ASSERT_MESSAGE("Bounding rectangle should have been calculated upon import.", !pData->maLastRect.IsEmpty());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1387 : : }
1388 : :
1389 [ + - ][ + - ]: 3 : xDocSh->DoClose();
1390 : 3 : }
1391 : :
1392 : 3 : void ScFiltersTest::testColorScale()
1393 : : {
1394 [ + - ]: 3 : const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("colorScale."));
1395 [ + - ]: 3 : rtl::OUString aFileExtension(aFileFormats[ODS].pName, strlen(aFileFormats[ODS].pName), RTL_TEXTENCODING_UTF8 );
1396 [ + - ]: 3 : rtl::OUString aFilterName(aFileFormats[ODS].pFilterName, strlen(aFileFormats[ODS].pFilterName), RTL_TEXTENCODING_UTF8) ;
1397 : 3 : rtl::OUString aFileName;
1398 [ + - ]: 3 : createFileURL(aFileNameBase, aFileExtension, aFileName);
1399 [ + - ]: 3 : rtl::OUString aFilterType(aFileFormats[ODS].pTypeName, strlen(aFileFormats[ODS].pTypeName), RTL_TEXTENCODING_UTF8);
1400 [ + - ][ + - ]: 3 : std::cout << aFileFormats[ODS].pName << " Test" << std::endl;
[ + - ]
1401 [ + - ]: 3 : ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[ODS].nFormatType);
1402 : :
1403 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT_MESSAGE("Failed to load colorScale.ods", xDocSh.Is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1404 : :
1405 : 3 : ScDocument* pDoc = xDocSh->GetDocument();
1406 : :
1407 [ + - ]: 3 : const ScPatternAttr* pPattern = pDoc->GetPattern(1,1,0);
1408 [ + - ]: 3 : sal_uLong nIndex = static_cast<const SfxUInt32Item&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
1409 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(nIndex);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1410 [ + - ]: 3 : ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(0);
1411 [ + - ]: 3 : const ScConditionalFormat* pFormat = pCondFormatList->GetFormat(nIndex);
1412 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pFormat);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1413 [ + - ]: 3 : pFormat->dumpInfo();
1414 : :
1415 [ + - ]: 3 : pPattern = pDoc->GetPattern(1,5,0);
1416 [ + - ]: 3 : nIndex = static_cast<const SfxUInt32Item&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
1417 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(nIndex);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1418 [ + - ]: 3 : pFormat = pCondFormatList->GetFormat(nIndex);
1419 [ + - ][ + - ]: 3 : CPPUNIT_ASSERT(pFormat);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1420 : 3 : }
1421 : :
1422 : 3 : void ScFiltersTest::testDataBar()
1423 : : {
1424 : :
1425 : 3 : }
1426 : :
1427 : 3 : void ScFiltersTest::testCondFormat()
1428 : : {
1429 : :
1430 : 3 : }
1431 : :
1432 : 108 : ScFiltersTest::ScFiltersTest()
1433 [ + - ][ + - ]: 108 : : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
1434 : : {
1435 : 108 : }
1436 : :
1437 : 108 : void ScFiltersTest::setUp()
1438 : : {
1439 : 108 : test::BootstrapFixture::setUp();
1440 : :
1441 : : // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
1442 : : // which is a private symbol to us, gets called
1443 : : m_xCalcComponent =
1444 [ + - ]: 216 : getMultiServiceFactory()->createInstance(rtl::OUString(
1445 [ + - ][ + - ]: 108 : RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Calc.SpreadsheetDocument")));
[ + - ]
1446 [ + - ][ + - ]: 108 : CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1447 : 108 : }
1448 : :
1449 : 108 : void ScFiltersTest::tearDown()
1450 : : {
1451 [ + - ][ + - ]: 108 : uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
1452 : 108 : test::BootstrapFixture::tearDown();
1453 : 108 : }
1454 : :
1455 : 3 : CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest);
1456 : :
1457 [ + - ][ + - ]: 12 : CPPUNIT_PLUGIN_IMPLEMENT();
[ + - ][ + - ]
[ + - ][ # # ]
1458 : :
1459 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|