update emoji autocorrect entries from po-files
[LibreOffice.git] / sw / qa / extras / inc / bordertest.hxx
blobfdee574641b298380d841c6f881900f465c7e7d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <com/sun/star/table/XCell.hpp>
11 #include <com/sun/star/table/BorderLine.hpp>
12 #include <com/sun/star/text/XTextTable.hpp>
14 #ifndef INCLUDED_SW_QA_EXTRAS_INC_BORDERTEST_HXX
15 #define INCLUDED_SW_QA_EXTRAS_INC_BORDERTEST_HXX
17 typedef std::map<OUString, com::sun::star::table::BorderLine> BorderLineMap;
18 typedef std::pair<OUString, com::sun::star::table::BorderLine> StringBorderPair;
20 using namespace com::sun::star;
22 class BorderTest
24 public:
25 BorderTest()
29 static void testTheBorders(uno::Reference<lang::XComponent> mxComponent, bool isBinaryDoc)
31 uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
32 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(textDocument->getText(), uno::UNO_QUERY);
33 // list of paragraphs
34 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
36 // maps containing TopBorder widths for every cell
37 // one map for each tables - there are 8 of them, counting from 0
38 BorderLineMap map0;
39 map0.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 26)));
40 map0.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 79, 26, 26)));
41 map0.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 106, 26, 26)));
42 map0.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 159, 26, 26)));
43 map0.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 212, 26, 26)));
44 BorderLineMap map1;
45 map1.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 9, 9, 9)));
46 map1.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 18, 18, 18)));
47 map1.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 26, 26)));
48 map1.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 53)));
49 map1.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 79)));
50 map1.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 106)));
51 BorderLineMap map2;
52 map2.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 9, 5, 5)));
53 map2.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 18, 9, 9)));
54 map2.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 14, 14)));
55 map2.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 35, 18, 18)));
56 map2.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 26)));
57 map2.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 79, 41, 41)));
58 map2.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 106, 53, 53)));
59 map2.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 159, 79, 79)));
60 map2.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 212, 106, 106)));
61 BorderLineMap map3;
62 map3.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 9)));
63 map3.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 53, 26, 18)));
64 map3.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 53, 26, 26)));
65 map3.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 26, 35)));
66 map3.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 53)));
67 map3.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 53, 26, 79)));
68 map3.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 53, 26, 106)));
69 map3.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 53, 26, 159)));
70 map3.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 53, 26, 212)));
71 map3.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 53, 26, 9)));
73 // Binary-DOC importer changes 'inset' and 'outset' border styles to other styles
74 // during import, so for now - leaving binary-doc results as they were.
75 BorderLineMap map4;
76 if (isBinaryDoc)
78 map4.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 53, 26, 18)));
79 map4.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 53, 26, 26)));
80 map4.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 26, 35)));
81 map4.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 35)));
82 map4.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 53, 26, 79)));
83 map4.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 53, 26, 106)));
84 map4.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 53, 26, 159)));
85 map4.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 53, 26, 212)));
87 else
89 map4.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 0, 26, 4)));
90 map4.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 5, 26, 5)));
91 map4.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 14, 26, 14)));
92 map4.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 23, 26, 23)));
93 map4.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 41, 26, 41)));
94 map4.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 67, 26, 67)));
95 map4.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 93, 26, 93)));
96 map4.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 146, 26, 146)));
97 map4.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 199, 26, 199)));
99 BorderLineMap map5;
100 if (isBinaryDoc)
102 map5.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 26, 53, 9)));
103 map5.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 53, 18)));
104 map5.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 53, 26)));
105 map5.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 26, 53, 35)));
106 map5.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 26, 53, 53)));
107 map5.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 26, 53, 79)));
108 map5.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 26, 53, 106)));
109 map5.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 26, 53, 159)));
110 map5.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 26, 53, 212)));
112 else
114 map5.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 26, 2, 4)));
115 map5.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 5, 5)));
116 map5.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 14, 14)));
117 map5.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 26, 23, 23)));
118 map5.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 26, 41, 41)));
119 map5.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 26, 67, 67)));
120 map5.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 26, 93, 93)));
121 map5.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 26, 146, 146)));
122 map5.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 26, 199, 199)));
124 BorderLineMap map6;
125 map6.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26)));
126 map6.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53)));
127 map6.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79)));
128 map6.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106)));
129 map6.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159)));
130 map6.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212)));
131 BorderLineMap map7;
132 map7.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26)));
133 map7.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53)));
134 map7.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79)));
135 map7.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106)));
136 map7.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159)));
137 map7.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212)));
139 sal_Int32 currentTable = 0; //to know which map should we check with the current table
140 BorderLineMap* tempMap;
141 tempMap = &map0;
144 uno::Reference<lang::XServiceInfo> xServiceInfo;
145 if (xParaEnum->nextElement() >>= xServiceInfo)
147 if (xServiceInfo->supportsService("com.sun.star.text.TextTable"))
149 uno::Reference<text::XTextTable> const xTextTable(xServiceInfo, uno::UNO_QUERY_THROW);
150 uno::Sequence<OUString> const cells = xTextTable->getCellNames();
151 sal_Int32 nLength = cells.getLength();
153 if(currentTable == sal_Int32(1))
154 tempMap = &map1;
155 if(currentTable == sal_Int32(2))
156 tempMap = &map2;
157 if(currentTable == sal_Int32(3))
158 tempMap = &map3;
159 if(currentTable == sal_Int32(4))
160 tempMap = &map4;
161 if(currentTable == sal_Int32(5))
162 tempMap = &map5;
163 if(currentTable == sal_Int32(6))
164 tempMap = &map6;
165 if(currentTable == sal_Int32(7))
166 tempMap = &map7;
168 BorderLineMap::iterator it;
169 it = tempMap->begin();
171 for (sal_Int32 i = 0; i < nLength; ++i)
173 uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]);
174 uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
175 uno::Any aAny = xPropSet->getPropertyValue("TopBorder");
176 table::BorderLine aBorderLine;
177 it = tempMap->find(cells[i]);
178 if ((aAny >>= aBorderLine) && (it!=tempMap->end()))
180 sal_Int32 innerLineWidth = aBorderLine.InnerLineWidth;
181 sal_Int32 outerLineWidth = aBorderLine.OuterLineWidth;
182 sal_Int32 lineDistance = aBorderLine.LineDistance;
184 sal_Int32 perfectInner = it->second.InnerLineWidth;
185 sal_Int32 perfectOuter = it->second.OuterLineWidth;
186 sal_Int32 perfectDistance = it->second.LineDistance;
187 CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
188 CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
189 CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
192 ++currentTable;
195 } while(xParaEnum->hasMoreElements());
199 #endif
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */