fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sw / qa / extras / inc / bordertest.hxx
blobadac3da62c47770056b095a6bbf053368fceec03
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 bordertest_hxx
15 #define 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 void testTheBorders(uno::Reference<lang::XComponent> mxComponent)
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)));
72 BorderLineMap map4;
73 map4.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 53, 26, 18)));
74 map4.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 53, 26, 26)));
75 map4.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 26, 35)));
76 map4.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 53, 26, 35)));
77 map4.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 53, 26, 79)));
78 map4.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 53, 26, 106)));
79 map4.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 53, 26, 159)));
80 map4.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 53, 26, 212)));
81 BorderLineMap map5;
82 map5.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 26, 53, 9)));
83 map5.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 53, 18)));
84 map5.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 26, 53, 26)));
85 map5.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 26, 53, 35)));
86 map5.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 26, 53, 53)));
87 map5.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 26, 53, 79)));
88 map5.insert(StringBorderPair(OUString("G1"), table::BorderLine(0, 26, 53, 106)));
89 map5.insert(StringBorderPair(OUString("H1"), table::BorderLine(0, 26, 53, 159)));
90 map5.insert(StringBorderPair(OUString("I1"), table::BorderLine(0, 26, 53, 212)));
91 BorderLineMap map6;
92 map6.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26)));
93 map6.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53)));
94 map6.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79)));
95 map6.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106)));
96 map6.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159)));
97 map6.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212)));
98 BorderLineMap map7;
99 map7.insert(StringBorderPair(OUString("A1"), table::BorderLine(0, 14, 14, 26)));
100 map7.insert(StringBorderPair(OUString("B1"), table::BorderLine(0, 26, 26, 53)));
101 map7.insert(StringBorderPair(OUString("C1"), table::BorderLine(0, 41, 41, 79)));
102 map7.insert(StringBorderPair(OUString("D1"), table::BorderLine(0, 53, 53, 106)));
103 map7.insert(StringBorderPair(OUString("E1"), table::BorderLine(0, 79, 79, 159)));
104 map7.insert(StringBorderPair(OUString("F1"), table::BorderLine(0, 106, 106, 212)));
106 sal_Int32 currentTable = 0; //to know which map should we check with the current table
107 BorderLineMap* tempMap;
108 tempMap = &map0;
111 uno::Reference<lang::XServiceInfo> xServiceInfo;
112 if (xParaEnum->nextElement() >>= xServiceInfo)
114 if (xServiceInfo->supportsService("com.sun.star.text.TextTable"))
116 uno::Reference<text::XTextTable> const xTextTable(xServiceInfo, uno::UNO_QUERY_THROW);
117 uno::Sequence<OUString> const cells = xTextTable->getCellNames();
118 uno::Sequence< uno::Sequence< sal_Int32 > > borderWidthSequence;
119 sal_Int32 nLength = cells.getLength();
121 if(currentTable == sal_Int32(1))
122 tempMap = &map1;
123 if(currentTable == sal_Int32(2))
124 tempMap = &map2;
125 if(currentTable == sal_Int32(3))
126 tempMap = &map3;
127 if(currentTable == sal_Int32(4))
128 tempMap = &map4;
129 if(currentTable == sal_Int32(5))
130 tempMap = &map5;
131 if(currentTable == sal_Int32(6))
132 tempMap = &map6;
133 if(currentTable == sal_Int32(7))
134 tempMap = &map7;
136 BorderLineMap::iterator it;
137 it = tempMap->begin();
139 for (sal_Int32 i = 0; i < nLength; ++i)
141 uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]);
142 uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
143 uno::Any aAny = xPropSet->getPropertyValue("TopBorder");
144 table::BorderLine aBorderLine;
145 it = tempMap->find(cells[i]);
146 if ((aAny >>= aBorderLine) && (it!=tempMap->end()))
148 sal_Int32 innerLineWidth = aBorderLine.InnerLineWidth;
149 sal_Int32 outerLineWidth = aBorderLine.OuterLineWidth;
150 sal_Int32 lineDistance = aBorderLine.LineDistance;
152 sal_Int32 perfectInner = it->second.InnerLineWidth;
153 sal_Int32 perfectOuter = it->second.OuterLineWidth;
154 sal_Int32 perfectDistance = it->second.LineDistance;
155 CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
156 CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
157 CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
160 ++currentTable;
163 } while(xParaEnum->hasMoreElements());
167 #endif