1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
13 #include <string_view>
16 #include <validat.hxx>
17 #include <tabvwsh.hxx>
18 #include <com/sun/star/drawing/FillStyle.hpp>
19 #include "helper/qahelper.hxx"
20 #include <svx/svdocapt.hxx>
21 #include <svx/xfillit0.hxx>
22 #include <svx/xflclit.hxx>
23 #include <svx/xflgrit.hxx>
24 #include <svx/xflhtit.hxx>
25 #include <drwlayer.hxx>
26 #include <svx/svdpage.hxx>
27 #include <svx/svdomeas.hxx>
28 #include <userdat.hxx>
29 #include <stlpool.hxx>
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::uno
;
34 class ScFiltersTest
: public ScModelTestBase
39 void testTdf137576_Measureline();
40 void testTdf137216_HideCol();
41 void testTdf137044_CoverHiddenRows();
42 void testTdf137020_FlipVertical();
48 // void testTdf40110();
51 void testTdf88821_2();
53 void testRhbz1390776();
60 void testTdf104502_hiddenColsCountedInPageCount();
61 void testTdf108188_pagestyle();
63 CPPUNIT_TEST_SUITE(ScFiltersTest
);
64 CPPUNIT_TEST(testTdf137576_Measureline
);
65 CPPUNIT_TEST(testTdf137216_HideCol
);
66 CPPUNIT_TEST(testTdf137044_CoverHiddenRows
);
67 CPPUNIT_TEST(testTdf137020_FlipVertical
);
68 CPPUNIT_TEST(testTdf64229
);
69 CPPUNIT_TEST(testTdf36933
);
70 CPPUNIT_TEST(testTdf43700
);
71 CPPUNIT_TEST(testTdf43534
);
72 CPPUNIT_TEST(testTdf91979
);
73 // CPPUNIT_TEST(testTdf40110);
74 CPPUNIT_TEST(testTdf98657
);
75 CPPUNIT_TEST(testTdf88821
);
76 CPPUNIT_TEST(testTdf88821_2
);
77 CPPUNIT_TEST(testTdf103960
);
78 CPPUNIT_TEST(testRhbz1390776
);
79 CPPUNIT_TEST(testTdf104310
);
80 CPPUNIT_TEST(testTdf31231
);
81 CPPUNIT_TEST(testTdf141914
);
82 CPPUNIT_TEST(testTdf128951
);
83 CPPUNIT_TEST(testTdf129789
);
84 CPPUNIT_TEST(testTdf130725
);
85 CPPUNIT_TEST(testTdf104502_hiddenColsCountedInPageCount
);
86 CPPUNIT_TEST(testTdf108188_pagestyle
);
87 CPPUNIT_TEST_SUITE_END();
90 static void lcl_AssertRectEqualWithTolerance(std::string_view sInfo
,
91 const tools::Rectangle
& rExpected
,
92 const tools::Rectangle
& rActual
,
93 const sal_Int32 nTolerance
)
96 OString sMsg
= OString::Concat(sInfo
) + " Left expected " + OString::number(rExpected
.Left())
97 + " actual " + OString::number(rActual
.Left()) + " Tolerance "
98 + OString::number(nTolerance
);
99 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(),
100 std::abs(rExpected
.Left() - rActual
.Left()) <= nTolerance
);
103 sMsg
= OString::Concat(sInfo
) + " Top expected " + OString::number(rExpected
.Top()) + " actual "
104 + OString::number(rActual
.Top()) + " Tolerance " + OString::number(nTolerance
);
105 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(), std::abs(rExpected
.Top() - rActual
.Top()) <= nTolerance
);
108 sMsg
= OString::Concat(sInfo
) + " Width expected " + OString::number(rExpected
.GetWidth())
109 + " actual " + OString::number(rActual
.GetWidth()) + " Tolerance "
110 + OString::number(nTolerance
);
111 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(),
112 std::abs(rExpected
.GetWidth() - rActual
.GetWidth()) <= nTolerance
);
115 sMsg
= OString::Concat(sInfo
) + " Height expected " + OString::number(rExpected
.GetHeight())
116 + " actual " + OString::number(rActual
.GetHeight()) + " Tolerance "
117 + OString::number(nTolerance
);
118 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(),
119 std::abs(rExpected
.GetHeight() - rActual
.GetHeight()) <= nTolerance
);
122 static void lcl_AssertPointEqualWithTolerance(std::string_view sInfo
, const Point rExpected
,
123 const Point rActual
, const sal_Int32 nTolerance
)
126 OString sMsg
= OString::Concat(sInfo
) + " X expected " + OString::number(rExpected
.X())
127 + " actual " + OString::number(rActual
.X()) + " Tolerance "
128 + OString::number(nTolerance
);
129 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(), std::abs(rExpected
.X() - rActual
.X()) <= nTolerance
);
131 sMsg
= OString::Concat(sInfo
) + " Y expected " + OString::number(rExpected
.Y()) + " actual "
132 + OString::number(rActual
.Y()) + " Tolerance " + OString::number(nTolerance
);
133 CPPUNIT_ASSERT_MESSAGE(sMsg
.getStr(), std::abs(rExpected
.Y() - rActual
.Y()) <= nTolerance
);
136 void ScFiltersTest::testTdf137576_Measureline()
138 // The document contains a vertical measure line, anchored "To Cell (resize with cell)" with
139 // length 37mm. Save and reload had resulted in a line of 0mm length.
142 createScDoc("ods/tdf137576_Measureline.ods");
143 ScDocument
* pDoc
= getScDoc();
146 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
147 CPPUNIT_ASSERT_MESSAGE("Load: No ScDrawLayer", pDrawLayer
);
148 SdrPage
* pPage
= pDrawLayer
->GetPage(0);
149 CPPUNIT_ASSERT_MESSAGE("Load: No draw page", pPage
);
150 SdrMeasureObj
* pObj
= static_cast<SdrMeasureObj
*>(pPage
->GetObj(0));
151 CPPUNIT_ASSERT_MESSAGE("Load: No measure object", pObj
);
153 // Check start and end point of measureline
154 const Point aStart
= pObj
->GetPoint(0);
155 lcl_AssertPointEqualWithTolerance("Load, start point: ", Point(4800, 1500), aStart
, 1);
156 const Point aEnd
= pObj
->GetPoint(1);
157 lcl_AssertPointEqualWithTolerance("Load, end point: ", Point(4800, 5200), aEnd
, 1);
160 saveAndReload("calc8");
164 pDrawLayer
= pDoc
->GetDrawLayer();
165 CPPUNIT_ASSERT_MESSAGE("Reload: No ScDrawLayer", pDrawLayer
);
166 pPage
= pDrawLayer
->GetPage(0);
167 CPPUNIT_ASSERT_MESSAGE("Reload: No draw page", pPage
);
168 pObj
= static_cast<SdrMeasureObj
*>(pPage
->GetObj(0));
169 CPPUNIT_ASSERT_MESSAGE("Reload: No measure object", pObj
);
171 // Check start and end point of measureline, should be unchanged
172 const Point aStart2
= pObj
->GetPoint(0);
173 lcl_AssertPointEqualWithTolerance("Reload start point: ", Point(4800, 1500), aStart2
, 1);
174 const Point aEnd2
= pObj
->GetPoint(1);
175 lcl_AssertPointEqualWithTolerance("Reload end point: ", Point(4800, 5200), aEnd2
, 1);
178 void ScFiltersTest::testTdf137216_HideCol()
180 // The document contains a shape anchored "To Cell (resize with cell)" with start in C3.
181 // Error was, that hiding column C did not make the shape invisible.
184 createScDoc("ods/tdf137216_HideCol.ods");
185 ScDocument
* pDoc
= getScDoc();
188 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
189 CPPUNIT_ASSERT_MESSAGE("Load: No ScDrawLayer", pDrawLayer
);
190 const SdrPage
* pPage
= pDrawLayer
->GetPage(0);
191 CPPUNIT_ASSERT_MESSAGE("Load: No draw page", pPage
);
192 SdrObject
* pObj
= pPage
->GetObj(0);
193 CPPUNIT_ASSERT_MESSAGE("Load: No object found", pObj
);
195 // Assert object is visible before and invisible after hiding column.
196 CPPUNIT_ASSERT_MESSAGE("before column hide: Object should be visible", pObj
->IsVisible());
197 pDoc
->SetColHidden(2, 2, 0, true); // col C in UI = col index 2 to 2.
198 CPPUNIT_ASSERT_MESSAGE("after column hide: Object should be invisible", !pObj
->IsVisible());
201 void ScFiltersTest::testTdf137044_CoverHiddenRows()
203 // The document contains a shape anchored "To Cell (resize with cell)" with start in cell A4 and
204 // end in cell A7. Row height is 30mm. Hiding rows 5 and 6, then saving and reload had resulted
205 // in a wrong end cell offset and thus a wrong height of the shape.
208 createScDoc("ods/tdf137044_CoverHiddenRows.ods");
209 ScDocument
* pDoc
= getScDoc();
212 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
213 CPPUNIT_ASSERT_MESSAGE("Load: No ScDrawLayer", pDrawLayer
);
214 SdrPage
* pPage
= pDrawLayer
->GetPage(0);
215 CPPUNIT_ASSERT_MESSAGE("Load: No draw page", pPage
);
216 SdrObject
* pObj
= pPage
->GetObj(0);
217 CPPUNIT_ASSERT_MESSAGE("Load: No object", pObj
);
219 // Get original object values
220 tools::Rectangle aSnapRectOrig
= pObj
->GetSnapRect();
221 Point aOriginalEndOffset
= ScDrawLayer::GetObjData(pObj
)->maEndOffset
;
222 lcl_AssertRectEqualWithTolerance("Load:", tools::Rectangle(Point(500, 3500), Size(1501, 11001)),
224 lcl_AssertPointEqualWithTolerance("Load: end offset", Point(2000, 2499), aOriginalEndOffset
, 1);
226 // Hide rows 5 and 6 in UI = row index 4 to 5.
227 pDoc
->SetRowHidden(4, 5, 0, true);
230 saveAndReload("calc8");
234 pDrawLayer
= pDoc
->GetDrawLayer();
235 CPPUNIT_ASSERT_MESSAGE("Reload: No ScDrawLayer", pDrawLayer
);
236 pPage
= pDrawLayer
->GetPage(0);
237 CPPUNIT_ASSERT_MESSAGE("Reload: No draw page", pPage
);
238 pObj
= pPage
->GetObj(0);
239 CPPUNIT_ASSERT_MESSAGE("Reload: No object", pObj
);
241 // Get new values and compare. End offset should be the same, height should be 6000 smaller.
242 tools::Rectangle aSnapRectReload
= pObj
->GetSnapRect();
243 Point aReloadEndOffset
= ScDrawLayer::GetObjData(pObj
)->maEndOffset
;
244 lcl_AssertRectEqualWithTolerance(
245 "Reload:", tools::Rectangle(Point(500, 3500), Size(1501, 5001)), aSnapRectReload
, 1);
246 lcl_AssertPointEqualWithTolerance("Reload: end offset", Point(2000, 2499), aReloadEndOffset
, 1);
249 void ScFiltersTest::testTdf137020_FlipVertical()
252 createScDoc("ods/tdf137020_FlipVertical.ods");
253 ScDocument
* pDoc
= getScDoc();
256 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
257 CPPUNIT_ASSERT_MESSAGE("Load: No ScDrawLayer", pDrawLayer
);
258 SdrPage
* pPage
= pDrawLayer
->GetPage(0);
259 CPPUNIT_ASSERT_MESSAGE("Load: No draw page", pPage
);
260 SdrObject
* pObj
= pPage
->GetObj(0);
261 CPPUNIT_ASSERT_MESSAGE("Load: No object", pObj
);
263 const tools::Rectangle aSnapRectOrig
= pObj
->GetSnapRect();
265 // Vertical mirror on center should not change the snap rect.
266 pObj
->Mirror(aSnapRectOrig
.LeftCenter(), aSnapRectOrig
.RightCenter());
267 const tools::Rectangle aSnapRectFlip
= pObj
->GetSnapRect();
268 lcl_AssertRectEqualWithTolerance("Mirror:", aSnapRectOrig
, aSnapRectFlip
, 1);
271 saveAndReload("calc8");
275 pDrawLayer
= pDoc
->GetDrawLayer();
276 CPPUNIT_ASSERT_MESSAGE("Reload: No ScDrawLayer", pDrawLayer
);
277 pPage
= pDrawLayer
->GetPage(0);
278 CPPUNIT_ASSERT_MESSAGE("Reload: No draw page", pPage
);
279 pObj
= pPage
->GetObj(0);
280 CPPUNIT_ASSERT_MESSAGE("Reload: No object", pObj
);
282 // Check pos and size of shape again, should be unchanged
283 const tools::Rectangle aSnapRectReload
= pObj
->GetSnapRect();
284 lcl_AssertRectEqualWithTolerance("Reload:", aSnapRectOrig
, aSnapRectReload
, 1);
287 void ScFiltersTest::testTdf64229()
289 createScDoc("ods/fdo64229b.ods");
291 ScDocShell
* pDocSh
= getScDocShell();
292 pDocSh
->DoHardRecalc();
294 ScDocument
* pDoc
= getScDoc();
296 //test hard recalc: document has an incorrect cached formula result
297 //hard recalc should have updated to the correct result
298 OUString aCSVFileName
= createFilePath(u
"contentCSV/fdo64229b.csv");
299 testFile(aCSVFileName
, *pDoc
, 0);
302 void ScFiltersTest::testTdf36933()
304 createScDoc("ods/fdo36933test.ods");
306 ScDocShell
* pDocSh
= getScDocShell();
307 pDocSh
->DoHardRecalc();
309 ScDocument
* pDoc
= getScDoc();
311 //test hard recalc: document has an incorrect cached formula result
312 //hard recalc should have updated to the correct result
313 OUString aCSVFileName
= createFilePath(u
"contentCSV/fdo36933test.csv");
314 testFile(aCSVFileName
, *pDoc
, 0);
317 void ScFiltersTest::testTdf43700()
319 createScDoc("ods/fdo43700test.ods");
321 ScDocShell
* pDocSh
= getScDocShell();
322 pDocSh
->DoHardRecalc();
324 ScDocument
* pDoc
= getScDoc();
326 //test hard recalc: document has an incorrect cached formula result
327 //hard recalc should have updated to the correct result
328 OUString aCSVFileName
= createFilePath(u
"contentCSV/fdo43700test.csv");
329 testFile(aCSVFileName
, *pDoc
, 0);
332 void ScFiltersTest::testTdf43534()
334 createScDoc("ods/fdo43534test.ods");
336 ScDocShell
* pDocSh
= getScDocShell();
337 pDocSh
->DoHardRecalc();
339 //test hard recalc: document has an incorrect cached formula result
340 //hard recalc should have updated to the correct result
341 // createCSVPath("fdo43534test.", aCSVFileName);
342 // testFile(aCSVFileName, rDoc, 0);
345 void ScFiltersTest::testTdf91979()
349 ScDocument
* pDoc
= getScDoc();
350 ScTabViewShell
* pViewShell
= getViewShell();
351 auto& aViewData
= pViewShell
->GetViewData();
353 // Check coordinates of a distant cell
354 Point aPos
= aViewData
.GetScrPos(pDoc
->MaxCol() - 1, 10000, SC_SPLIT_TOPLEFT
, true);
355 int nColWidth
= ScViewData::ToPixel(pDoc
->GetColWidth(0, 0), aViewData
.GetPPTX());
356 int nRowHeight
= ScViewData::ToPixel(pDoc
->GetRowHeight(0, 0), aViewData
.GetPPTY());
357 CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long
>((pDoc
->MaxCol() - 1) * nColWidth
), aPos
.getX());
358 CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long
>(10000 * nRowHeight
), aPos
.getY());
362 void ScFiltersTest::testTdf40110()
364 ScDocShellRef xDocSh = loadDoc("fdo40110test.", FORMAT_ODS);
366 CPPUNIT_ASSERT_MESSAGE("Failed to load fdo40110test.*", xDocSh.Is());
367 xDocSh->DoHardRecalc();
369 ScDocument& rDoc = xDocSh->GetDocument();
371 //test hard recalc: document has an incorrect cached formula result
372 //hard recalc should have updated to the correct result
373 createCSVPath(OUString("fdo40110test."));
374 testFile(aCSVFileName, rDoc, 0);
379 void ScFiltersTest::testTdf98657()
381 createScDoc("ods/tdf98657.ods");
382 ScDocument
* pDoc
= getScDoc();
384 ScDocShell
* pDocSh
= getScDocShell();
385 pDocSh
->DoHardRecalc();
387 // this was a NaN before the fix
388 CPPUNIT_ASSERT_EQUAL(285.0, pDoc
->GetValue(ScAddress(1, 1, 0)));
391 void ScFiltersTest::testTdf88821()
393 setImportFilterName("calc_HTML_WebQuery");
394 createScDoc("html/tdf88821.html");
395 ScDocument
* pDoc
= getScDoc();
397 // B2 should be 'Périmètre', not 'Périmètre'
398 CPPUNIT_ASSERT_EQUAL(OStringToOUString("P\xC3\xA9rim\xC3\xA8tre", RTL_TEXTENCODING_UTF8
),
399 pDoc
->GetString(1, 1, 0));
402 void ScFiltersTest::testTdf88821_2()
404 setImportFilterName("calc_HTML_WebQuery");
405 createScDoc("html/tdf88821-2.html");
406 ScDocument
* pDoc
= getScDoc();
408 // A2 should be 'ABCabcČŠŽčšž', not 'ABCabcČŠŽÄヘšž'
409 CPPUNIT_ASSERT_EQUAL(OStringToOUString("ABCabc\xC4\x8C\xC5\xA0\xC5\xBD\xC4\x8D\xC5\xA1\xC5\xBE",
410 RTL_TEXTENCODING_UTF8
),
411 pDoc
->GetString(0, 1, 0));
414 void ScFiltersTest::testTdf103960()
416 setImportFilterName("calc_HTML_WebQuery");
417 createScDoc("html/tdf103960.html");
418 ScDocument
* pDoc
= getScDoc();
420 // A1 should be 'Data', not the entire content of the file
421 CPPUNIT_ASSERT_EQUAL(OStringToOUString("Data", RTL_TEXTENCODING_UTF8
),
422 pDoc
->GetString(0, 0, 0));
425 void ScFiltersTest::testRhbz1390776()
427 createScDoc("xml/rhbz1390776.xml");
428 ScDocument
* pDoc
= getScDoc();
430 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong range", OUString("=SUM(A18:A23)"),
431 pDoc
->GetFormula(0, 27, 0));
434 void ScFiltersTest::testTdf104310()
436 // 1. Test x14 extension
438 createScDoc("xlsx/tdf104310.xlsx");
439 ScDocument
* pDoc
= getScDoc();
441 const ScValidationData
* pData
= pDoc
->GetValidationEntry(1);
442 CPPUNIT_ASSERT(pData
);
444 // Make sure the list is correct.
445 std::vector
<ScTypedStrData
> aList
;
446 pData
->FillSelectionList(aList
, ScAddress(0, 1, 0));
447 CPPUNIT_ASSERT_EQUAL(size_t(5), aList
.size());
448 for (size_t i
= 0; i
< 5; ++i
)
449 CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i
+ 1), aList
[i
].GetValue(), 1e-8);
452 // 2. Test x12ac extension
454 createScDoc("xlsx/tdf104310-2.xlsx");
455 ScDocument
* pDoc
= getScDoc();
457 const ScValidationData
* pData
= pDoc
->GetValidationEntry(1);
458 CPPUNIT_ASSERT(pData
);
460 // Make sure the list is correct.
461 std::vector
<ScTypedStrData
> aList
;
462 pData
->FillSelectionList(aList
, ScAddress(0, 1, 0));
463 CPPUNIT_ASSERT_EQUAL(size_t(3), aList
.size());
464 CPPUNIT_ASSERT_EQUAL(OUString("1"), aList
[0].GetString());
465 CPPUNIT_ASSERT_EQUAL(OUString("2,3"), aList
[1].GetString());
466 CPPUNIT_ASSERT_EQUAL(OUString("4"), aList
[2].GetString());
470 void ScFiltersTest::testTdf31231()
472 // We must open it read-write to allow setting modified flag
473 createScDoc("ods/tdf31231.ods");
474 ScDocShell
* pDocSh
= getScDocShell();
476 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must be allowed to set modified state",
477 pDocSh
->IsEnableSetModified());
478 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must not be modified on open", !pDocSh
->IsModified());
480 pDocSh
->DoHardRecalc();
482 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must be allowed to set modified state",
483 pDocSh
->IsEnableSetModified());
484 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must not be modified on open", pDocSh
->IsModified());
487 void ScFiltersTest::testTdf141914()
489 // We must open it read-write to allow setting modified flag
490 createScDoc("ods/tdf141914.ods");
491 ScDocShell
* pDocSh
= getScDocShell();
493 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must be allowed to set modified state",
494 pDocSh
->IsEnableSetModified());
495 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must not be modified on open", !pDocSh
->IsModified());
497 pDocSh
->DoHardRecalc();
499 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must be allowed to set modified state",
500 pDocSh
->IsEnableSetModified());
501 CPPUNIT_ASSERT_MESSAGE("The spreadsheet must not be modified on open", pDocSh
->IsModified());
504 void ScFiltersTest::testTdf128951()
508 // 2. Create a new sheet instance
509 css::uno::Reference
<css::lang::XMultiServiceFactory
> xFac(mxComponent
,
510 css::uno::UNO_QUERY_THROW
);
511 auto xSheet
= xFac
->createInstance("com.sun.star.sheet.Spreadsheet");
513 // 3. Insert sheet into the spreadsheet (was throwing IllegalArgumentException)
514 css::uno::Reference
<css::sheet::XSpreadsheetDocument
> xDoc(mxComponent
,
515 css::uno::UNO_QUERY_THROW
);
516 CPPUNIT_ASSERT_NO_THROW(xDoc
->getSheets()->insertByName("mustNotThrow", css::uno::Any(xSheet
)));
521 SdrCaptionObj
* checkCaption(ScDocument
& rDoc
, const ScAddress
& rAddress
, bool bIsShown
)
523 ScPostIt
* pNote
= rDoc
.GetNote(rAddress
);
525 CPPUNIT_ASSERT(pNote
);
526 CPPUNIT_ASSERT_EQUAL(pNote
->IsCaptionShown(), bIsShown
);
529 pNote
->ShowCaption(rAddress
, true);
531 SdrCaptionObj
* pCaption
= pNote
->GetCaption();
532 CPPUNIT_ASSERT(pCaption
);
538 void ScFiltersTest::testTdf129789()
540 createScDoc("ods/tdf129789.ods");
541 ScDocument
* pDoc
= getScDoc();
545 SdrCaptionObj
* const pCaptionB2
= checkCaption(*pDoc
, ScAddress(1, 1, 0), true);
547 const XFillStyleItem
& rStyleItemB2
= pCaptionB2
->GetMergedItem(XATTR_FILLSTYLE
);
549 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rStyleItemB2
.GetValue());
551 SdrCaptionObj
* const pCaptionB9
= checkCaption(*pDoc
, ScAddress(1, 8, 0), false);
553 const XFillStyleItem
& rStyleItemB9
= pCaptionB9
->GetMergedItem(XATTR_FILLSTYLE
);
555 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rStyleItemB9
.GetValue());
560 SdrCaptionObj
* const pCaptionE2
= checkCaption(*pDoc
, ScAddress(4, 1, 0), true);
562 const XFillStyleItem
& rStyleItemE2
= pCaptionE2
->GetMergedItem(XATTR_FILLSTYLE
);
564 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItemE2
.GetValue());
566 const XFillColorItem
& rColorItem
= pCaptionE2
->GetMergedItem(XATTR_FILLCOLOR
);
567 CPPUNIT_ASSERT_EQUAL(Color(0xffffc0), rColorItem
.GetColorValue());
569 SdrCaptionObj
* const pCaptionE9
= checkCaption(*pDoc
, ScAddress(4, 8, 0), false);
571 const XFillStyleItem
& rStyleItemE9
= pCaptionE9
->GetMergedItem(XATTR_FILLSTYLE
);
573 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItemE9
.GetValue());
575 const XFillColorItem
& rColorItem2
= pCaptionE9
->GetMergedItem(XATTR_FILLCOLOR
);
576 CPPUNIT_ASSERT_EQUAL(Color(0xffffc0), rColorItem2
.GetColorValue());
581 SdrCaptionObj
* const pCaptionH2
= checkCaption(*pDoc
, ScAddress(7, 1, 0), true);
583 const XFillStyleItem
& rStyleItemH2
= pCaptionH2
->GetMergedItem(XATTR_FILLSTYLE
);
585 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, rStyleItemH2
.GetValue());
586 const XFillGradientItem
& rGradientItem
= pCaptionH2
->GetMergedItem(XATTR_FILLGRADIENT
);
587 CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), rGradientItem
.GetGradientValue().GetStartColor());
588 CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), rGradientItem
.GetGradientValue().GetEndColor());
590 SdrCaptionObj
* const pCaptionH9
= checkCaption(*pDoc
, ScAddress(7, 8, 0), false);
592 const XFillStyleItem
& rStyleItemH9
= pCaptionH9
->GetMergedItem(XATTR_FILLSTYLE
);
594 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, rStyleItemH9
.GetValue());
595 const XFillGradientItem
& rGradientItem2
= pCaptionH2
->GetMergedItem(XATTR_FILLGRADIENT
);
596 CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), rGradientItem2
.GetGradientValue().GetStartColor());
597 CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), rGradientItem2
.GetGradientValue().GetEndColor());
602 SdrCaptionObj
* const pCaptionK2
= checkCaption(*pDoc
, ScAddress(10, 1, 0), true);
604 const XFillStyleItem
& rStyleItemK2
= pCaptionK2
->GetMergedItem(XATTR_FILLSTYLE
);
606 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, rStyleItemK2
.GetValue());
607 const XFillHatchItem
& rHatchItem
= pCaptionK2
->GetMergedItem(XATTR_FILLHATCH
);
608 CPPUNIT_ASSERT_EQUAL(Color(0x000080), rHatchItem
.GetHatchValue().GetColor());
610 SdrCaptionObj
* const pCaptionK9
= checkCaption(*pDoc
, ScAddress(10, 8, 0), false);
612 const XFillStyleItem
& rStyleItemK9
= pCaptionK9
->GetMergedItem(XATTR_FILLSTYLE
);
614 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH
, rStyleItemK9
.GetValue());
615 const XFillHatchItem
& rHatchItem2
= pCaptionK9
->GetMergedItem(XATTR_FILLHATCH
);
616 CPPUNIT_ASSERT_EQUAL(Color(0x000080), rHatchItem2
.GetHatchValue().GetColor());
621 SdrCaptionObj
* const pCaptionN2
= checkCaption(*pDoc
, ScAddress(13, 1, 0), true);
623 const XFillStyleItem
& rStyleItemN2
= pCaptionN2
->GetMergedItem(XATTR_FILLSTYLE
);
625 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, rStyleItemN2
.GetValue());
627 SdrCaptionObj
* const pCaptionN9
= checkCaption(*pDoc
, ScAddress(13, 8, 0), false);
629 const XFillStyleItem
& rStyleItemN9
= pCaptionN9
->GetMergedItem(XATTR_FILLSTYLE
);
631 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, rStyleItemN9
.GetValue());
635 void ScFiltersTest::testTdf130725()
639 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
641 // 2. Insert 0.0042 into a cell as a formula, to force the conversion from string to double
642 css::uno::Reference
<css::sheet::XCellRangesAccess
> xSheets(xDoc
->getSheets(),
643 css::uno::UNO_QUERY_THROW
);
644 css::uno::Reference
<css::table::XCell
> xCell
= xSheets
->getCellByPosition(0, 0, 0);
645 xCell
->setFormula("0.0042"); // this assumes en-US locale
647 // 3. Check that the value is the nearest double-precision representation of the decimal 0.0042
648 // (it was 0.0042000000000000006 instead of 0.0041999999999999997).
649 CPPUNIT_ASSERT_EQUAL_MESSAGE("Value must be the nearest representation of decimal 0.0042",
650 0.0042, xCell
->getValue()); // strict equality
653 void ScFiltersTest::testTdf104502_hiddenColsCountedInPageCount()
655 createScDoc("ods/tdf104502_hiddenColsCountedInPageCount.ods");
657 ScDocument
* pDoc
= getScDoc();
659 //Check that hidden columns are not calculated into Print Area
662 CPPUNIT_ASSERT(pDoc
->GetPrintArea(0, nEndCol
, nEndRow
, false));
663 CPPUNIT_ASSERT_EQUAL(SCCOL(0), nEndCol
);
664 CPPUNIT_ASSERT_EQUAL(SCROW(55), nEndRow
);
666 void ScFiltersTest::testTdf108188_pagestyle()
668 createScDoc("ods/tdf108188_pagestyle.ods");
670 // Check if the user defined page style is present
671 const OUString aTestPageStyle
= "TestPageStyle";
672 ScDocument
* pDoc
= getScDoc();
673 CPPUNIT_ASSERT_EQUAL(aTestPageStyle
, pDoc
->GetPageStyle(0));
675 // Without the accompanying fix in place, the page styles are always used
676 ScStyleSheetPool
* pStylePool
= pDoc
->GetStyleSheetPool();
677 CPPUNIT_ASSERT(pStylePool
->Find(aTestPageStyle
, SfxStyleFamily::Page
)->IsUsed());
678 CPPUNIT_ASSERT(!pStylePool
->Find("Default", SfxStyleFamily::Page
)->IsUsed());
681 ScFiltersTest::ScFiltersTest()
682 : ScModelTestBase("sc/qa/unit/data")
686 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest
);
688 CPPUNIT_PLUGIN_IMPLEMENT();
690 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */