KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

416 lines
10KB

  1. /* This file is part of the KDE project
  2. Copyright 2002 Laurent Montel <montel@kde.org>
  3. Copyright 2002 Philipp Mueller <philipp.mueller@gmx.de>
  4. Copyright 2002 John Dailey <dailey@vt.edu>
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public License
  14. along with this library; see the file COPYING.LIB. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. * Boston, MA 02110-1301, USA.
  17. */
  18. #include "KSpreadLayoutIface.h"
  19. #include <tqbrush.h>
  20. #include "kspread_format.h"
  21. using namespace KSpread;
  22. LayoutIface::LayoutIface(Format *_layout)
  23. {
  24. layout=_layout;
  25. }
  26. void LayoutIface::setBgColor(const TQString& _c)
  27. {
  28. TQColor c(_c);
  29. layout->setBgColor(c);
  30. }
  31. void LayoutIface::setBgColor(int r,int g,int b)
  32. {
  33. TQColor c(r,g,b);
  34. layout->setBgColor(c);
  35. }
  36. void LayoutIface::setTextColor(int r,int g,int b)
  37. {
  38. TQColor c(r,g,b);
  39. layout->setTextColor(c);
  40. }
  41. void LayoutIface::setTextColor(const TQString& _c)
  42. {
  43. TQColor c(_c);
  44. layout->setTextColor(c);
  45. }
  46. void LayoutIface::setAngle(int angle)
  47. {
  48. layout->setAngle(angle);
  49. }
  50. void LayoutIface::setVerticalText(bool _vertical)
  51. {
  52. layout->setVerticalText(_vertical);
  53. }
  54. void LayoutIface::setMultiRow(bool _multi)
  55. {
  56. layout->setMultiRow( _multi );
  57. }
  58. void LayoutIface::setAlign( const TQString& _Align )
  59. {
  60. Format::Align Align;
  61. if(_Align=="Left")
  62. Align=Format::Left;
  63. else if(_Align=="Right")
  64. Align=Format::Right;
  65. else if(_Align=="Center")
  66. Align=Format::Center;
  67. else
  68. Align=Format::Undefined;
  69. layout->setAlign( Align);
  70. }
  71. void LayoutIface::setAlignY( const TQString& _AlignY )
  72. {
  73. Format::AlignY AlignY;
  74. if(_AlignY=="Top")
  75. AlignY=Format::Top;
  76. else if(_AlignY=="Middle")
  77. AlignY=Format::Middle;
  78. else if(_AlignY=="Bottom")
  79. AlignY=Format::Bottom;
  80. else
  81. AlignY=Format::Middle;
  82. layout->setAlignY( AlignY);
  83. }
  84. void LayoutIface::setPostfix(const TQString &_postfix)
  85. {
  86. layout->setPostfix( _postfix );
  87. }
  88. void LayoutIface::setPrefix(const TQString &_prefix)
  89. {
  90. layout->setPrefix( _prefix );
  91. }
  92. void LayoutIface::setFormatType(const TQString &_formatType)
  93. {
  94. FormatType format;
  95. layout->setPrecision(2);
  96. if (_formatType=="Generic")
  97. format = Generic_format;
  98. else if(_formatType=="Number")
  99. format=Number_format;
  100. else if(_formatType=="Money")
  101. format=Money_format;
  102. else if(_formatType=="Percentage")
  103. format=Percentage_format;
  104. else if(_formatType=="Scientific")
  105. format=Scientific_format;
  106. else if(_formatType=="ShortDate")
  107. format=ShortDate_format;
  108. else if(_formatType=="TextDate")
  109. format=TextDate_format;
  110. else if(_formatType=="Time")
  111. format=Time_format;
  112. else if(_formatType=="SecondeTime")
  113. format=SecondeTime_format;
  114. else if(_formatType=="fraction_half")
  115. format=fraction_half;
  116. else if(_formatType=="fraction_quarter")
  117. format=fraction_quarter;
  118. else if(_formatType=="fraction_eighth")
  119. format=fraction_eighth;
  120. else if(_formatType=="fraction_sixteenth")
  121. format=fraction_sixteenth;
  122. else if(_formatType=="fraction_tenth")
  123. format=fraction_tenth;
  124. else if(_formatType=="fraction_hundredth")
  125. format=fraction_hundredth;
  126. else if(_formatType=="fraction_one_digit")
  127. format=fraction_one_digit;
  128. else if(_formatType=="fraction_two_digits")
  129. format=fraction_two_digits;
  130. else if(_formatType=="fraction_three_digits")
  131. format=fraction_three_digits;
  132. else
  133. format=Generic_format;
  134. layout->setFormatType( format);
  135. }
  136. void LayoutIface::setPrecision(int _p)
  137. {
  138. layout->setPrecision( _p );
  139. }
  140. void LayoutIface::setTextFontBold(bool _b)
  141. {
  142. layout->setTextFontBold( _b );
  143. }
  144. void LayoutIface::setTextFontItalic(bool _b)
  145. {
  146. layout->setTextFontItalic( _b );
  147. }
  148. void LayoutIface::setTextFontUnderline(bool _b)
  149. {
  150. layout->setTextFontUnderline( _b );
  151. }
  152. void LayoutIface::setTextFontStrike(bool _b)
  153. {
  154. layout->setTextFontStrike( _b );
  155. }
  156. void LayoutIface::setTextFontSize( int _size )
  157. {
  158. layout->setTextFontSize( _size );
  159. }
  160. void LayoutIface::setTextFontFamily( const TQString& _font )
  161. {
  162. layout->setTextFontFamily( _font );
  163. }
  164. //border left
  165. void LayoutIface::setLeftBorderStyle( const TQString& _style )
  166. {
  167. if(_style=="DotLine")
  168. layout->setLeftBorderStyle(Qt::DotLine);
  169. else if(_style=="DashLine")
  170. layout->setLeftBorderStyle(Qt::DashLine);
  171. else if(_style=="DashDotLine")
  172. layout->setLeftBorderStyle(Qt::DashDotLine);
  173. else if(_style=="DashDotDotLine")
  174. layout->setLeftBorderStyle(Qt::DashDotDotLine);
  175. else if(_style=="SolidLine")
  176. layout->setLeftBorderStyle(Qt::SolidLine);
  177. else
  178. layout->setLeftBorderStyle(Qt::SolidLine);
  179. }
  180. void LayoutIface::setLeftBorderColor(const TQString& _c)
  181. {
  182. TQColor c(_c);
  183. layout->setLeftBorderColor(c );
  184. }
  185. void LayoutIface::setLeftBorderColor(int r,int g,int b)
  186. {
  187. TQColor c(r,g,b);
  188. layout->setLeftBorderColor(c );
  189. }
  190. void LayoutIface::setLeftBorderWidth( int _size )
  191. {
  192. layout->setLeftBorderWidth( _size );
  193. }
  194. //border right
  195. void LayoutIface::setRightBorderStyle( const TQString& _style )
  196. {
  197. if(_style=="DotLine")
  198. layout->setRightBorderStyle(Qt::DotLine);
  199. else if(_style=="DashLine")
  200. layout->setRightBorderStyle(Qt::DashLine);
  201. else if(_style=="DashDotLine")
  202. layout->setRightBorderStyle(Qt::DashDotLine);
  203. else if(_style=="DashDotDotLine")
  204. layout->setRightBorderStyle(Qt::DashDotDotLine);
  205. else if(_style=="SolidLine")
  206. layout->setRightBorderStyle(Qt::SolidLine);
  207. else
  208. layout->setRightBorderStyle(Qt::SolidLine);
  209. }
  210. void LayoutIface::setRightBorderColor(const TQString& _c)
  211. {
  212. TQColor c(_c);
  213. layout->setRightBorderColor(c );
  214. }
  215. void LayoutIface::setRightBorderColor(int r,int g,int b)
  216. {
  217. TQColor c(r,g,b);
  218. layout->setRightBorderColor(c );
  219. }
  220. void LayoutIface::setRightBorderWidth( int _size )
  221. {
  222. layout->setRightBorderWidth( _size );
  223. }
  224. //border top
  225. void LayoutIface::setTopBorderStyle( const TQString& _style )
  226. {
  227. if(_style=="DotLine")
  228. layout->setTopBorderStyle(Qt::DotLine);
  229. else if(_style=="DashLine")
  230. layout->setTopBorderStyle(Qt::DashLine);
  231. else if(_style=="DashDotLine")
  232. layout->setTopBorderStyle(Qt::DashDotLine);
  233. else if(_style=="DashDotDotLine")
  234. layout->setTopBorderStyle(Qt::DashDotDotLine);
  235. else if(_style=="SolidLine")
  236. layout->setTopBorderStyle(Qt::SolidLine);
  237. else
  238. layout->setTopBorderStyle(Qt::SolidLine);
  239. }
  240. void LayoutIface::setTopBorderColor(const TQString& _c)
  241. {
  242. TQColor c(_c);
  243. layout->setTopBorderColor(c );
  244. }
  245. void LayoutIface::setTopBorderColor(int r,int g,int b)
  246. {
  247. TQColor c(r,g,b);
  248. layout->setTopBorderColor(c );
  249. }
  250. void LayoutIface::setTopBorderWidth( int _size )
  251. {
  252. layout->setTopBorderWidth( _size );
  253. }
  254. //border bottom
  255. void LayoutIface::setBottomBorderStyle( const TQString& _style )
  256. {
  257. if(_style=="DotLine")
  258. layout->setBottomBorderStyle(Qt::DotLine);
  259. else if(_style=="DashLine")
  260. layout->setBottomBorderStyle(Qt::DashLine);
  261. else if(_style=="DashDotLine")
  262. layout->setBottomBorderStyle(Qt::DashDotLine);
  263. else if(_style=="DashDotDotLine")
  264. layout->setBottomBorderStyle(Qt::DashDotDotLine);
  265. else if(_style=="SolidLine")
  266. layout->setBottomBorderStyle(Qt::SolidLine);
  267. else
  268. layout->setBottomBorderStyle(Qt::SolidLine);
  269. }
  270. void LayoutIface::setBottomBorderColor(const TQString& _c)
  271. {
  272. TQColor c(_c);
  273. layout->setBottomBorderColor(c );
  274. }
  275. void LayoutIface::setBottomBorderColor(int r,int g,int b)
  276. {
  277. TQColor c(r,g,b);
  278. layout->setBottomBorderColor(c );
  279. }
  280. void LayoutIface::setBottomBorderWidth( int _size )
  281. {
  282. layout->setBottomBorderWidth( _size );
  283. }
  284. //fall back diagonal
  285. void LayoutIface::setFallDiagonalStyle( const TQString& _style )
  286. {
  287. if(_style=="DotLine")
  288. layout->setFallDiagonalStyle(Qt::DotLine);
  289. else if(_style=="DashLine")
  290. layout->setFallDiagonalStyle(Qt::DashLine);
  291. else if(_style=="DashDotLine")
  292. layout->setFallDiagonalStyle(Qt::DashDotLine);
  293. else if(_style=="DashDotDotLine")
  294. layout->setFallDiagonalStyle(Qt::DashDotDotLine);
  295. else if(_style=="SolidLine")
  296. layout->setFallDiagonalStyle(Qt::SolidLine);
  297. else
  298. layout->setFallDiagonalStyle(Qt::SolidLine);
  299. }
  300. void LayoutIface::setFallDiagonalColor(const TQString& _c)
  301. {
  302. TQColor c(_c);
  303. layout->setFallDiagonalColor(c );
  304. }
  305. void LayoutIface::setFallDiagonalColor(int r,int g,int b)
  306. {
  307. TQColor c(r,g,b);
  308. layout->setFallDiagonalColor(c );
  309. }
  310. void LayoutIface::setFallDiagonalWidth( int _size )
  311. {
  312. layout->setFallDiagonalWidth( _size );
  313. }
  314. //GoUpDiagonal
  315. void LayoutIface::setGoUpDiagonalStyle( const TQString& _style )
  316. {
  317. if(_style=="DotLine")
  318. layout->setGoUpDiagonalStyle(Qt::DotLine);
  319. else if(_style=="DashLine")
  320. layout->setGoUpDiagonalStyle(Qt::DashLine);
  321. else if(_style=="DashDotLine")
  322. layout->setGoUpDiagonalStyle(Qt::DashDotLine);
  323. else if(_style=="DashDotDotLine")
  324. layout->setGoUpDiagonalStyle(Qt::DashDotDotLine);
  325. else if(_style=="SolidLine")
  326. layout->setGoUpDiagonalStyle(Qt::SolidLine);
  327. else
  328. layout->setGoUpDiagonalStyle(Qt::SolidLine);
  329. }
  330. void LayoutIface::setGoUpDiagonalColor(const TQString& _c)
  331. {
  332. TQColor c(_c);
  333. layout->setGoUpDiagonalColor(c );
  334. }
  335. void LayoutIface::setGoUpDiagonalColor(int r,int g,int b)
  336. {
  337. TQColor c(r,g,b);
  338. layout->setGoUpDiagonalColor(c );
  339. }
  340. void LayoutIface::setGoUpDiagonalWidth( int _size )
  341. {
  342. layout->setGoUpDiagonalWidth( _size );
  343. }
  344. void LayoutIface::setIndent( double indent )
  345. {
  346. if( indent >= 0.0 )
  347. layout->setIndent( indent );
  348. else
  349. layout->setIndent( 0.0 );
  350. }
  351. void LayoutIface::setDontPrintText ( bool _print)
  352. {
  353. layout->setDontPrintText ( _print);
  354. }