69
69
* This function will check if a cell has any type of border.
71
bool GNUMERICExport::hasBorder( const Cell& cell, int currentcolumn, int currentrow)
71
bool GNUMERICExport::hasBorder(const Cell& cell, int currentcolumn, int currentrow)
73
Q_UNUSED(currentcolumn);
73
75
const Style style = cell.style();
74
if ( ( (style.leftBorderPen().width() != 0) &&
75
(style.leftBorderPen().style() != Qt::NoPen ) ) ||
76
( (style.rightBorderPen().width() != 0) &&
77
(style.rightBorderPen().style() != Qt::NoPen ) ) ||
78
( (style.topBorderPen().width() != 0) &&
79
(style.topBorderPen().style() != Qt::NoPen ) ) ||
80
( (style.bottomBorderPen().width() != 0) &&
81
(style.bottomBorderPen().style() != Qt::NoPen ) ) ||
82
( (style.fallDiagonalPen().width() != 0) &&
83
(style.fallDiagonalPen().style() != Qt::NoPen ) ) ||
84
( (style.goUpDiagonalPen().width() != 0) &&
85
(style.goUpDiagonalPen().style() != Qt::NoPen ) ) )
76
if (((style.leftBorderPen().width() != 0) &&
77
(style.leftBorderPen().style() != Qt::NoPen)) ||
78
((style.rightBorderPen().width() != 0) &&
79
(style.rightBorderPen().style() != Qt::NoPen)) ||
80
((style.topBorderPen().width() != 0) &&
81
(style.topBorderPen().style() != Qt::NoPen)) ||
82
((style.bottomBorderPen().width() != 0) &&
83
(style.bottomBorderPen().style() != Qt::NoPen)) ||
84
((style.fallDiagonalPen().width() != 0) &&
85
(style.fallDiagonalPen().style() != Qt::NoPen)) ||
86
((style.goUpDiagonalPen().width() != 0) &&
87
(style.goUpDiagonalPen().style() != Qt::NoPen)))
104
109
border_style = gnumeric_doc.createElement("gmr:StyleBorder");
105
110
const Style style = cell.style();
107
if ( (style.leftBorderPen().width() != 0) &&
108
(style.leftBorderPen().style() != Qt::NoPen ) )
112
if ((style.leftBorderPen().width() != 0) &&
113
(style.leftBorderPen().style() != Qt::NoPen)) {
110
114
border = gnumeric_doc.createElement("gmr:Left");
111
border.setAttribute("Style","1");
115
border.setAttribute("Style", "1");
113
117
color = style.leftBorderPen().color();
114
red = color.red()<<8;
115
green = color.green()<<8;
116
blue = color.blue()<<8;
118
red = color.red() << 8;
119
green = color.green() << 8;
120
blue = color.blue() << 8;
118
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
122
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
122
124
border = gnumeric_doc.createElement("gmr:Left");
123
border.setAttribute("Style","0");
125
border.setAttribute("Style", "0");
126
128
border_style.appendChild(border);
128
if ( (style.rightBorderPen().width() != 0) &&
129
(style.rightBorderPen().style() != Qt::NoPen ) )
130
if ((style.rightBorderPen().width() != 0) &&
131
(style.rightBorderPen().style() != Qt::NoPen)) {
131
132
border = gnumeric_doc.createElement("gmr:Right");
132
border.setAttribute("Style","1");
133
border.setAttribute("Style", "1");
134
135
color = style.rightBorderPen().color();
135
red = color.red()<<8;
136
green = color.green()<<8;
137
blue = color.blue()<<8;
136
red = color.red() << 8;
137
green = color.green() << 8;
138
blue = color.blue() << 8;
139
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
140
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
143
142
border = gnumeric_doc.createElement("gmr:Right");
144
border.setAttribute("Style","0");
143
border.setAttribute("Style", "0");
147
146
border_style.appendChild(border);
149
if ( (style.topBorderPen().width() != 0) &&
150
(style.topBorderPen().style() != Qt::NoPen ) )
148
if ((style.topBorderPen().width() != 0) &&
149
(style.topBorderPen().style() != Qt::NoPen)) {
152
150
border = gnumeric_doc.createElement("gmr:Top");
153
border.setAttribute("Style","1");
151
border.setAttribute("Style", "1");
155
153
color = style.topBorderPen().color();
156
red = color.red()<<8;
157
green = color.green()<<8;
158
blue = color.blue()<<8;
154
red = color.red() << 8;
155
green = color.green() << 8;
156
blue = color.blue() << 8;
160
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
158
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
164
160
border = gnumeric_doc.createElement("gmr:Top");
165
border.setAttribute("Style","0");
161
border.setAttribute("Style", "0");
168
164
border_style.appendChild(border);
170
if ( (style.bottomBorderPen().width() != 0) &&
171
(style.bottomBorderPen().style() != Qt::NoPen ) )
166
if ((style.bottomBorderPen().width() != 0) &&
167
(style.bottomBorderPen().style() != Qt::NoPen)) {
173
168
border = gnumeric_doc.createElement("gmr:Bottom");
174
border.setAttribute("Style","1");
169
border.setAttribute("Style", "1");
176
171
color = style.bottomBorderPen().color();
177
red = color.red()<<8;
178
green = color.green()<<8;
179
blue = color.blue()<<8;
172
red = color.red() << 8;
173
green = color.green() << 8;
174
blue = color.blue() << 8;
181
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
176
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
185
178
border = gnumeric_doc.createElement("gmr:Bottom");
186
border.setAttribute("Style","0");
179
border.setAttribute("Style", "0");
189
182
border_style.appendChild(border);
191
if ( (style.fallDiagonalPen().width() != 0) &&
192
(style.fallDiagonalPen().style() != Qt::NoPen ) )
184
if ((style.fallDiagonalPen().width() != 0) &&
185
(style.fallDiagonalPen().style() != Qt::NoPen)) {
194
186
border = gnumeric_doc.createElement("gmr:Diagonal");
195
border.setAttribute("Style","1");
187
border.setAttribute("Style", "1");
197
189
color = style.fallDiagonalPen().color();
198
red = color.red()<<8;
199
green = color.green()<<8;
200
blue = color.blue()<<8;
190
red = color.red() << 8;
191
green = color.green() << 8;
192
blue = color.blue() << 8;
202
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
194
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
206
196
border = gnumeric_doc.createElement("gmr:Diagonal");
207
border.setAttribute("Style","0");
197
border.setAttribute("Style", "0");
210
200
border_style.appendChild(border);
212
if ( (style.goUpDiagonalPen().width() != 0) &&
213
(style.goUpDiagonalPen().style() != Qt::NoPen ) )
202
if ((style.goUpDiagonalPen().width() != 0) &&
203
(style.goUpDiagonalPen().style() != Qt::NoPen)) {
215
204
border = gnumeric_doc.createElement("gmr:Rev-Diagonal");
216
border.setAttribute("Style","1");
205
border.setAttribute("Style", "1");
218
207
color = style.goUpDiagonalPen().color();
219
red = color.red()<<8;
220
green = color.green()<<8;
221
blue = color.blue()<<8;
208
red = color.red() << 8;
209
green = color.green() << 8;
210
blue = color.blue() << 8;
223
border.setAttribute("Color", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
212
border.setAttribute("Color", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
227
214
border = gnumeric_doc.createElement("gmr:Rev-Diagonal");
228
border.setAttribute("Style","0");
215
border.setAttribute("Style", "0");
231
218
border_style.appendChild(border);
233
220
return border_style;
236
QDomElement GNUMERICExport::GetValidity( QDomDocument gnumeric_doc, const Cell& cell )
223
QDomElement GNUMERICExport::GetValidity(QDomDocument gnumeric_doc, const Cell& cell)
238
225
//<gmr:Validation Style="1" Type="1" Operator="7" AllowBlank="true" UseDropdown="false" Title="ghhg" Message="ghghhhjfhfghjfghj fg hjgf hj">
239
226
// <gmr:Expression0>45</gmr:Expression0>
240
227
// </gmr:Validation>
241
228
Validity kspread_validity = cell.validity();
242
QDomElement val = gnumeric_doc.createElement( "gmr:Validation" );
243
val.setAttribute( "Title", kspread_validity.title() );
244
val.setAttribute( "Message", kspread_validity.message() );
245
val.setAttribute( "AllowBlank", kspread_validity.allowEmptyCell() ? "true":"false" );
246
if ( !kspread_validity.displayMessage() )
248
val.setAttribute("Style", "0" );
252
switch( kspread_validity.action() )
255
val.setAttribute("Style", "1" );
257
case Validity::Warning:
258
val.setAttribute("Style", "2" );
260
case Validity::Information:
261
val.setAttribute("Style", "3" );
229
QDomElement val = gnumeric_doc.createElement("gmr:Validation");
230
val.setAttribute("Title", kspread_validity.title());
231
val.setAttribute("Message", kspread_validity.message());
232
val.setAttribute("AllowBlank", kspread_validity.allowEmptyCell() ? "true" : "false");
233
if (!kspread_validity.displayMessage()) {
234
val.setAttribute("Style", "0");
236
switch (kspread_validity.action()) {
238
val.setAttribute("Style", "1");
240
case Validity::Warning:
241
val.setAttribute("Style", "2");
243
case Validity::Information:
244
val.setAttribute("Style", "3");
266
switch( kspread_validity.condition() )
268
case Conditional::None:
249
switch (kspread_validity.condition()) {
250
case Conditional::None:
271
case Conditional::Equal:
272
val.setAttribute("Operator", "2" );
274
case Conditional::Superior:
275
val.setAttribute("Operator", "4" );
277
case Conditional::Inferior:
278
val.setAttribute("Operator", "5" );
280
case Conditional::SuperiorEqual:
281
val.setAttribute("Operator", "6" );
283
case Conditional::InferiorEqual:
284
val.setAttribute("Operator", "7" );
286
case Conditional::Between:
287
val.setAttribute("Operator", "0" );
289
case Conditional::Different:
290
val.setAttribute("Operator", "3" );
292
case Conditional::DifferentTo:
293
val.setAttribute("Operator", "1" );
253
case Conditional::Equal:
254
val.setAttribute("Operator", "2");
256
case Conditional::Superior:
257
val.setAttribute("Operator", "4");
259
case Conditional::Inferior:
260
val.setAttribute("Operator", "5");
262
case Conditional::SuperiorEqual:
263
val.setAttribute("Operator", "6");
265
case Conditional::InferiorEqual:
266
val.setAttribute("Operator", "7");
268
case Conditional::Between:
269
val.setAttribute("Operator", "0");
271
case Conditional::Different:
272
val.setAttribute("Operator", "3");
274
case Conditional::DifferentTo:
275
val.setAttribute("Operator", "1");
296
switch( kspread_validity.restriction() )
278
switch (kspread_validity.restriction()) {
298
279
case Validity::None:
299
val.setAttribute("Type", "0" );
280
val.setAttribute("Type", "0");
301
case Validity::Number:
303
val.setAttribute("Type", "2" );
304
switch( kspread_validity.condition() )
306
case Conditional::None:
282
case Validity::Number: {
283
val.setAttribute("Type", "2");
284
switch (kspread_validity.condition()) {
285
case Conditional::None:
309
case Conditional::Equal:
310
case Conditional::Superior:
311
case Conditional::Inferior:
312
case Conditional::SuperiorEqual:
313
case Conditional::InferiorEqual:
314
case Conditional::Different:
316
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
317
tmp.appendChild( gnumeric_doc.createTextNode( QString::number( kspread_validity.minimumValue() ) ) );
318
val.appendChild( tmp );
288
case Conditional::Equal:
289
case Conditional::Superior:
290
case Conditional::Inferior:
291
case Conditional::SuperiorEqual:
292
case Conditional::InferiorEqual:
293
case Conditional::Different: {
294
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
295
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
296
val.appendChild(tmp);
321
case Conditional::Between:
322
case Conditional::DifferentTo:
324
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
325
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.minimumValue() ) ) );
326
val.appendChild( tmp );
327
tmp = gnumeric_doc.createElement( "gmr:Expression1" );
328
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.maximumValue() ) ) );
329
val.appendChild( tmp );
299
case Conditional::Between:
300
case Conditional::DifferentTo: {
301
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
302
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
303
val.appendChild(tmp);
304
tmp = gnumeric_doc.createElement("gmr:Expression1");
305
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.maximumValue())));
306
val.appendChild(tmp);
338
315
//val.setAttribute("Type", "1" );
340
317
case Validity::Time:
341
val.setAttribute("Type", "5" );
342
switch( kspread_validity.condition() )
344
case Conditional::None:
318
val.setAttribute("Type", "5");
319
switch (kspread_validity.condition()) {
320
case Conditional::None:
347
case Conditional::Equal:
348
case Conditional::Superior:
349
case Conditional::Inferior:
350
case Conditional::SuperiorEqual:
351
case Conditional::InferiorEqual:
352
case Conditional::Different:
354
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
355
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.minimumTime().toString() ) );
356
val.appendChild( tmp );
323
case Conditional::Equal:
324
case Conditional::Superior:
325
case Conditional::Inferior:
326
case Conditional::SuperiorEqual:
327
case Conditional::InferiorEqual:
328
case Conditional::Different: {
329
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
330
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.minimumTime().toString()));
331
val.appendChild(tmp);
359
case Conditional::Between:
360
case Conditional::DifferentTo:
362
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
363
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.minimumTime().toString() ) );
364
val.appendChild( tmp );
365
tmp = gnumeric_doc.createElement( "gmr:Expression1" );
366
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.maximumTime().toString() ) );
367
val.appendChild( tmp );
334
case Conditional::Between:
335
case Conditional::DifferentTo: {
336
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
337
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.minimumTime().toString()));
338
val.appendChild(tmp);
339
tmp = gnumeric_doc.createElement("gmr:Expression1");
340
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.maximumTime().toString()));
341
val.appendChild(tmp);
373
347
case Validity::Date:
374
val.setAttribute("Type", "4" );
375
switch( kspread_validity.condition() )
377
case Conditional::None:
348
val.setAttribute("Type", "4");
349
switch (kspread_validity.condition()) {
350
case Conditional::None:
380
case Conditional::Equal:
381
case Conditional::Superior:
382
case Conditional::Inferior:
383
case Conditional::SuperiorEqual:
384
case Conditional::InferiorEqual:
385
case Conditional::Different:
387
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
388
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.minimumDate().toString() ) );
389
val.appendChild( tmp );
353
case Conditional::Equal:
354
case Conditional::Superior:
355
case Conditional::Inferior:
356
case Conditional::SuperiorEqual:
357
case Conditional::InferiorEqual:
358
case Conditional::Different: {
359
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
360
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.minimumDate().toString()));
361
val.appendChild(tmp);
392
case Conditional::Between:
393
case Conditional::DifferentTo:
395
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
396
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.minimumDate().toString() ) );
397
val.appendChild( tmp );
398
tmp = gnumeric_doc.createElement( "gmr:Expression1" );
399
tmp.appendChild( gnumeric_doc.createTextNode( kspread_validity.maximumDate().toString() ) );
400
val.appendChild( tmp );
364
case Conditional::Between:
365
case Conditional::DifferentTo: {
366
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
367
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.minimumDate().toString()));
368
val.appendChild(tmp);
369
tmp = gnumeric_doc.createElement("gmr:Expression1");
370
tmp.appendChild(gnumeric_doc.createTextNode(kspread_validity.maximumDate().toString()));
371
val.appendChild(tmp);
406
377
case Validity::Integer:
407
val.setAttribute("Type", "1" );
408
switch( kspread_validity.condition() )
410
case Conditional::None:
378
val.setAttribute("Type", "1");
379
switch (kspread_validity.condition()) {
380
case Conditional::None:
413
case Conditional::Equal:
414
case Conditional::Superior:
415
case Conditional::Inferior:
416
case Conditional::SuperiorEqual:
417
case Conditional::InferiorEqual:
418
case Conditional::Different:
420
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
421
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.minimumValue() ) ) );
422
val.appendChild( tmp );
383
case Conditional::Equal:
384
case Conditional::Superior:
385
case Conditional::Inferior:
386
case Conditional::SuperiorEqual:
387
case Conditional::InferiorEqual:
388
case Conditional::Different: {
389
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
390
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
391
val.appendChild(tmp);
425
case Conditional::Between:
426
case Conditional::DifferentTo:
428
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
429
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.minimumValue() ) ) );
430
val.appendChild( tmp );
431
tmp = gnumeric_doc.createElement( "gmr:Expression1" );
432
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.maximumValue() ) ) );
433
val.appendChild( tmp );
394
case Conditional::Between:
395
case Conditional::DifferentTo: {
396
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
397
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
398
val.appendChild(tmp);
399
tmp = gnumeric_doc.createElement("gmr:Expression1");
400
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.maximumValue())));
401
val.appendChild(tmp);
438
406
case Validity::TextLength:
439
val.setAttribute("Type", "6" );
440
switch( kspread_validity.condition() )
442
case Conditional::None:
407
val.setAttribute("Type", "6");
408
switch (kspread_validity.condition()) {
409
case Conditional::None:
445
case Conditional::Equal:
446
case Conditional::Superior:
447
case Conditional::Inferior:
448
case Conditional::SuperiorEqual:
449
case Conditional::InferiorEqual:
450
case Conditional::Different:
452
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
453
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.minimumValue() ) ) );
454
val.appendChild( tmp );
412
case Conditional::Equal:
413
case Conditional::Superior:
414
case Conditional::Inferior:
415
case Conditional::SuperiorEqual:
416
case Conditional::InferiorEqual:
417
case Conditional::Different: {
418
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
419
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
420
val.appendChild(tmp);
457
case Conditional::Between:
458
case Conditional::DifferentTo:
460
QDomElement tmp = gnumeric_doc.createElement( "gmr:Expression0" );
461
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.minimumValue() ) ) );
462
val.appendChild( tmp );
463
tmp = gnumeric_doc.createElement( "gmr:Expression1" );
464
tmp.appendChild( gnumeric_doc.createTextNode( QString::number(kspread_validity.maximumValue() ) ) );
465
val.appendChild( tmp );
423
case Conditional::Between:
424
case Conditional::DifferentTo: {
425
QDomElement tmp = gnumeric_doc.createElement("gmr:Expression0");
426
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.minimumValue())));
427
val.appendChild(tmp);
428
tmp = gnumeric_doc.createElement("gmr:Expression1");
429
tmp.appendChild(gnumeric_doc.createTextNode(QString::number(kspread_validity.maximumValue())));
430
val.appendChild(tmp);
470
435
case Validity::List:
471
val.setAttribute("Type", "3" );
472
switch( kspread_validity.condition() )
474
case Conditional::None:
436
val.setAttribute("Type", "3");
437
switch (kspread_validity.condition()) {
438
case Conditional::None:
477
case Conditional::Equal:
478
case Conditional::Superior:
479
case Conditional::Inferior:
480
case Conditional::SuperiorEqual:
481
case Conditional::InferiorEqual:
482
case Conditional::Different:
441
case Conditional::Equal:
442
case Conditional::Superior:
443
case Conditional::Inferior:
444
case Conditional::SuperiorEqual:
445
case Conditional::InferiorEqual:
446
case Conditional::Different:
484
case Conditional::Between:
485
case Conditional::DifferentTo:
448
case Conditional::Between:
449
case Conditional::DifferentTo:
494
QDomElement GNUMERICExport::GetFontStyle( QDomDocument gnumeric_doc,const Cell& cell, int currentcolumn, int currentrow)
458
QDomElement GNUMERICExport::GetFontStyle(QDomDocument gnumeric_doc, const Cell& cell, int currentcolumn, int currentrow)
496
460
QDomElement font_style;
497
461
const Style style = cell.style();
498
kDebug(30521)<<" currentcolumn :"<<currentcolumn<<" currentrow :"<<currentrow;
462
kDebug(30521) << " currentcolumn :" << currentcolumn << " currentrow :" << currentrow;
499
463
font_style = gnumeric_doc.createElement("gmr:Font");
500
464
font_style.appendChild(gnumeric_doc.createTextNode(style.fontFamily()));
502
if (style.italic() || (isLink && isLinkItalic))
504
font_style.setAttribute("Italic","1");
506
if (style.bold() || (isLink && isLinkBold))
508
font_style.setAttribute("Bold","1");
510
if (style.underline())
512
font_style.setAttribute("Underline","1");
514
if (style.strikeOut())
516
font_style.setAttribute("StrikeThrough","1");
518
if (style.fontSize())
520
font_style.setAttribute("Unit",QString::number(style.fontSize()));
466
if (style.italic() || (isLink && isLinkItalic)) {
467
font_style.setAttribute("Italic", "1");
469
if (style.bold() || (isLink && isLinkBold)) {
470
font_style.setAttribute("Bold", "1");
472
if (style.underline()) {
473
font_style.setAttribute("Underline", "1");
475
if (style.strikeOut()) {
476
font_style.setAttribute("StrikeThrough", "1");
478
if (style.fontSize()) {
479
font_style.setAttribute("Unit", QString::number(style.fontSize()));
523
482
return font_style;
536
if (path.section(":",0,0).toLower() == "http")
537
link_style.setAttribute("type","GnmHLinkURL");
538
else if (path.section(":",0,0).toLower() == "mailto")
539
link_style.setAttribute("type","GnmHLinkEMail");
540
else if (path.section(":",0,0).toLower() == "file")
541
link_style.setAttribute("type","GnmHLinkExternal");
495
if (path.section(":", 0, 0).toLower() == "http")
496
link_style.setAttribute("type", "GnmHLinkURL");
497
else if (path.section(":", 0, 0).toLower() == "mailto")
498
link_style.setAttribute("type", "GnmHLinkEMail");
499
else if (path.section(":", 0, 0).toLower() == "file")
500
link_style.setAttribute("type", "GnmHLinkExternal");
542
501
else if (path.left(5).toLower() == "sheet")
543
link_style.setAttribute("type","GnmHLinkCurWB");
502
link_style.setAttribute("type", "GnmHLinkCurWB");
545
link_style.setAttribute("type","");
504
link_style.setAttribute("type", "");
547
link_style.setAttribute("target",path);
506
link_style.setAttribute("target", path);
549
508
// KSpread doesn't support link tips.
550
link_style.setAttribute("tip","");
509
link_style.setAttribute("tip", "");
552
511
return link_style;
555
QDomElement GNUMERICExport::GetCellStyle(QDomDocument gnumeric_doc,const Cell& cell, int currentcolumn, int currentrow)
514
QDomElement GNUMERICExport::GetCellStyle(QDomDocument gnumeric_doc, const Cell& cell, int currentcolumn, int currentrow)
557
QColorGroup defaultColorGroup = QApplication::palette().active();
559
QDomElement cell_style;
561
cell_style = gnumeric_doc.createElement("gmr:Style");
516
QDomElement cell_style;
518
cell_style = gnumeric_doc.createElement("gmr:Style");
563
520
int red, green, blue;
565
522
const Style style = cell.style();
566
523
QColor bgColor = style.backgroundColor();
567
524
if (bgColor.isValid()) {
568
red = bgColor.red()<<8;
569
green = bgColor.green()<<8;
570
blue = bgColor.blue()<<8;
525
red = bgColor.red() << 8;
526
green = bgColor.green() << 8;
527
blue = bgColor.blue() << 8;
572
529
// Let's use white default for background
578
switch (style.backgroundBrush().style())
581
cell_style.setAttribute("Shade","0");
583
case Qt::SolidPattern:
585
cell_style.setAttribute("Shade","1");
587
case Qt::Dense1Pattern:
589
cell_style.setAttribute("Shade","25");
591
case Qt::Dense2Pattern:
593
cell_style.setAttribute("Shade","2");
595
case Qt::Dense3Pattern:
597
// Not supported by GNumeric
599
cell_style.setAttribute("Shade","3");
601
case Qt::Dense4Pattern:
603
cell_style.setAttribute("Shade","3");
605
case Qt::Dense5Pattern:
607
cell_style.setAttribute("Shade","4");
609
case Qt::Dense6Pattern:
611
cell_style.setAttribute("Shade","5");
613
case Qt::Dense7Pattern:
615
cell_style.setAttribute("Shade","6");
618
cell_style.setAttribute("Shade","13");
621
cell_style.setAttribute("Shade","14");
623
case Qt::CrossPattern:
624
cell_style.setAttribute("Shade","17");
626
case Qt::BDiagPattern:
627
cell_style.setAttribute("Shade","16");
629
case Qt::FDiagPattern:
630
cell_style.setAttribute("Shade","15");
632
case Qt::DiagCrossPattern:
633
cell_style.setAttribute("Shade","18");
635
case Qt::TexturePattern:
636
// Not supported by Gnumeric
637
cell_style.setAttribute("Shade","0");
641
cell_style.setAttribute("Back",QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16) );
644
QColor textColor = style.fontColor();
645
red = textColor.red()<<8;
646
green = textColor.green()<<8;
647
blue = textColor.blue()<<8;
649
cell_style.setAttribute("Fore",QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16) );
651
if (style.halign() == Style::HAlignUndefined)
653
cell_style.setAttribute("HAlign","1");
655
else if (style.halign() == Style::Left)
657
cell_style.setAttribute("HAlign","2");
659
else if (style.halign() == Style::Right)
661
cell_style.setAttribute("HAlign","4");
663
else if (style.halign() == Style::Center)
665
cell_style.setAttribute("HAlign","8");
668
if (style.valign() == Style::Top)
670
cell_style.setAttribute("VAlign","1");
672
else if (style.valign() == Style::Bottom)
674
cell_style.setAttribute("VAlign","2");
676
else if (style.valign() == Style::Middle)
678
cell_style.setAttribute("VAlign","4");
535
switch (style.backgroundBrush().style()) {
537
cell_style.setAttribute("Shade", "0");
539
case Qt::SolidPattern:
541
cell_style.setAttribute("Shade", "1");
543
case Qt::Dense1Pattern:
545
cell_style.setAttribute("Shade", "25");
547
case Qt::Dense2Pattern:
549
cell_style.setAttribute("Shade", "2");
551
case Qt::Dense3Pattern:
553
// Not supported by GNumeric
555
cell_style.setAttribute("Shade", "3");
557
case Qt::Dense4Pattern:
559
cell_style.setAttribute("Shade", "3");
561
case Qt::Dense5Pattern:
563
cell_style.setAttribute("Shade", "4");
565
case Qt::Dense6Pattern:
567
cell_style.setAttribute("Shade", "5");
569
case Qt::Dense7Pattern:
571
cell_style.setAttribute("Shade", "6");
574
cell_style.setAttribute("Shade", "13");
577
cell_style.setAttribute("Shade", "14");
579
case Qt::CrossPattern:
580
cell_style.setAttribute("Shade", "17");
582
case Qt::BDiagPattern:
583
cell_style.setAttribute("Shade", "16");
585
case Qt::FDiagPattern:
586
cell_style.setAttribute("Shade", "15");
588
case Qt::DiagCrossPattern:
589
cell_style.setAttribute("Shade", "18");
591
case Qt::TexturePattern:
593
// Not supported by Gnumeric
594
cell_style.setAttribute("Shade", "0");
598
cell_style.setAttribute("Back", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
601
QColor textColor = style.fontColor();
602
red = textColor.red() << 8;
603
green = textColor.green() << 8;
604
blue = textColor.blue() << 8;
606
cell_style.setAttribute("Fore", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
608
if (style.halign() == Style::HAlignUndefined) {
609
cell_style.setAttribute("HAlign", "1");
610
} else if (style.halign() == Style::Left) {
611
cell_style.setAttribute("HAlign", "2");
612
} else if (style.halign() == Style::Right) {
613
cell_style.setAttribute("HAlign", "4");
614
} else if (style.halign() == Style::Center) {
615
cell_style.setAttribute("HAlign", "8");
618
if (style.valign() == Style::Top) {
619
cell_style.setAttribute("VAlign", "1");
620
} else if (style.valign() == Style::Bottom) {
621
cell_style.setAttribute("VAlign", "2");
622
} else if (style.valign() == Style::Middle) {
623
cell_style.setAttribute("VAlign", "4");
681
626
if (style.wrapText())
682
cell_style.setAttribute("WrapText","1");
627
cell_style.setAttribute("WrapText", "1");
684
cell_style.setAttribute("WrapText","0");
629
cell_style.setAttribute("WrapText", "0");
686
631
// ShrinkToFit not supported by KSpread (?)
687
cell_style.setAttribute("ShrinkToFit","0");
632
cell_style.setAttribute("ShrinkToFit", "0");
689
634
// I'm not sure about the rotation values.
690
635
// I never got it to work in GNumeric.
703
648
cell_style.setAttribute("Hidden", style.hideAll());
705
650
QColor patColor = style.backgroundBrush().color();
706
red = patColor.red()<<8;
707
green = patColor.green()<<8;
708
blue = patColor.blue()<<8;
651
red = patColor.red() << 8;
652
green = patColor.green() << 8;
653
blue = patColor.blue() << 8;
710
cell_style.setAttribute("PatternColor", QString::number(red,16)+':'+QString::number(green,16) +':'+QString::number(blue,16));
655
cell_style.setAttribute("PatternColor", QString::number(red, 16) + ':' + QString::number(green, 16) + ':' + QString::number(blue, 16));
713
658
cell_style.appendChild(GetLinkStyle(gnumeric_doc));
715
660
cell_style.appendChild(GetFontStyle(gnumeric_doc, cell, currentcolumn, currentrow));
717
if ( !cell.validity().isEmpty() )
719
cell_style.appendChild( GetValidity( gnumeric_doc, cell ) );
662
if (!cell.validity().isEmpty()) {
663
cell_style.appendChild(GetValidity(gnumeric_doc, cell));
722
QString stringFormat;
666
QString stringFormat;
724
668
Currency currency;
726
switch( style.formatType())
728
case Format::Generic:
729
stringFormat="General";
735
stringFormat="General";
739
if (!style.hasAttribute(Style::CurrencyFormat))
741
stringFormat = "0.00";
744
currency = style.currency();
746
if (currency.code().isEmpty())
747
stringFormat = "0.00";
748
else if (currency.code() == "$")
749
stringFormat = "$0.00";
750
else if (currency.code() == QString::fromUtf8("€"))
751
stringFormat = "[$€-2]0.00";
752
else if (currency.code() == QString::fromUtf8("£"))
753
stringFormat = "£0.00";
754
else if (currency.code() == QString::fromUtf8("¥"))
755
stringFormat = "¥0.00";
757
stringFormat="[$" + currency.code() + "]0.00";
760
case Format::Percentage:
761
stringFormat="0.00%";
763
case Format::Scientific:
764
stringFormat="0.00E+00";
766
case Format::ShortDate:
767
stringFormat=cell.locale()->dateFormatShort();
769
case Format::TextDate:
770
stringFormat=cell.locale()->dateFormat();
773
stringFormat="dd-mmm-yy";
776
stringFormat="dd-mmm-yyyy";
779
stringFormat="dd-mmm";
782
stringFormat="dd-mm";
785
stringFormat="dd/mm/yy";
788
stringFormat="dd/mm/yyyy";
791
stringFormat="mmm-yy";
794
stringFormat="mmmm-yy";
797
stringFormat="mmmm-yyyy";
803
stringFormat="dd/mmm";
806
stringFormat="dd/mm";
809
stringFormat="dd/mmm/yyyy";
812
stringFormat="yyyy/mmm/dd";
815
stringFormat="yyyy-mmm-dd";
818
stringFormat="yyyy-mm-dd";
821
stringFormat="d mmmm yyyy";
824
stringFormat="mm/dd/yyyy";
827
stringFormat="mm/dd/yy";
830
stringFormat="mmm/dd/yy";
833
stringFormat="mmm/dd/yyyy";
836
stringFormat="mmm-yyyy";
845
stringFormat="yyyy/mm/dd";
848
stringFormat="yyyy/mmm/dd";
851
case Format::SecondeTime:
852
stringFormat=cell.locale()->timeFormat();
855
stringFormat = "h:mm AM/PM";
858
stringFormat = "h:mm:ss AM/PM";
861
stringFormat = "h \"h\" mm \"min\" ss \"s\"";
864
stringFormat = "h:mm";
867
stringFormat = "h:mm:ss";
870
stringFormat = "mm:ss";
873
stringFormat = "[h]:mm:ss";
876
stringFormat = "[h]:mm";
878
case Format::fraction_half:
879
stringFormat="# ?/2";
881
case Format::fraction_quarter:
882
stringFormat="# ?/4";
884
case Format::fraction_eighth:
885
stringFormat="# ?/8";
887
case Format::fraction_sixteenth:
888
stringFormat="# ?/16";
890
case Format::fraction_tenth:
891
stringFormat="# ?/10";
893
case Format::fraction_hundredth:
894
stringFormat="# ?/100";
896
case Format::fraction_one_digit:
897
stringFormat="# ?/?";
899
case Format::fraction_two_digits:
900
stringFormat="# ?\?/?\?";
902
case Format::fraction_three_digits:
903
stringFormat="# ?\?\?/?\?\?";
906
stringFormat = style.customFormat();
909
// This is a required parameter, so let's write a sane default
910
kWarning(30521) << "Unhandled Format value, setting 'General' as default: " << style.formatType();
911
stringFormat = "General";
670
switch (style.formatType()) {
671
case Format::Generic:
672
stringFormat = "General";
675
stringFormat = "0.00";
678
stringFormat = "General";
682
if (!style.hasAttribute(Style::CurrencyFormat)) {
683
stringFormat = "0.00";
686
currency = style.currency();
688
if (currency.code().isEmpty())
689
stringFormat = "0.00";
690
else if (currency.code() == "$")
691
stringFormat = "$0.00";
692
else if (currency.code() == QString::fromUtf8("€"))
693
stringFormat = "[$€-2]0.00";
694
else if (currency.code() == QString::fromUtf8("£"))
695
stringFormat = "£0.00";
696
else if (currency.code() == QString::fromUtf8("¥"))
697
stringFormat = "¥0.00";
699
stringFormat = "[$" + currency.code() + "]0.00";
702
case Format::Percentage:
703
stringFormat = "0.00%";
705
case Format::Scientific:
706
stringFormat = "0.00E+00";
708
case Format::ShortDate:
709
stringFormat = cell.locale()->dateFormatShort();
711
case Format::TextDate:
712
stringFormat = cell.locale()->dateFormat();
715
stringFormat = "dd-mmm-yy";
718
stringFormat = "dd-mmm-yyyy";
721
stringFormat = "dd-mmm";
724
stringFormat = "dd-mm";
727
stringFormat = "dd/mm/yy";
730
stringFormat = "dd/mm/yyyy";
733
stringFormat = "mmm-yy";
736
stringFormat = "mmmm-yy";
739
stringFormat = "mmmm-yyyy";
742
stringFormat = "m-yy";
745
stringFormat = "dd/mmm";
748
stringFormat = "dd/mm";
751
stringFormat = "dd/mmm/yyyy";
754
stringFormat = "yyyy/mmm/dd";
757
stringFormat = "yyyy-mmm-dd";
760
stringFormat = "yyyy-mm-dd";
763
stringFormat = "d mmmm yyyy";
766
stringFormat = "mm/dd/yyyy";
769
stringFormat = "mm/dd/yy";
772
stringFormat = "mmm/dd/yy";
775
stringFormat = "mmm/dd/yyyy";
778
stringFormat = "mmm-yyyy";
781
stringFormat = "yyyy";
787
stringFormat = "yyyy/mm/dd";
790
stringFormat = "yyyy/mmm/dd";
793
case Format::SecondeTime:
794
stringFormat = cell.locale()->timeFormat();
797
stringFormat = "h:mm AM/PM";
800
stringFormat = "h:mm:ss AM/PM";
803
stringFormat = "h \"h\" mm \"min\" ss \"s\"";
806
stringFormat = "h:mm";
809
stringFormat = "h:mm:ss";
812
stringFormat = "mm:ss";
815
stringFormat = "[h]:mm:ss";
818
stringFormat = "[h]:mm";
820
case Format::fraction_half:
821
stringFormat = "# ?/2";
823
case Format::fraction_quarter:
824
stringFormat = "# ?/4";
826
case Format::fraction_eighth:
827
stringFormat = "# ?/8";
829
case Format::fraction_sixteenth:
830
stringFormat = "# ?/16";
832
case Format::fraction_tenth:
833
stringFormat = "# ?/10";
835
case Format::fraction_hundredth:
836
stringFormat = "# ?/100";
838
case Format::fraction_one_digit:
839
stringFormat = "# ?/?";
841
case Format::fraction_two_digits:
842
stringFormat = "# ?\?/?\?";
844
case Format::fraction_three_digits:
845
stringFormat = "# ?\?\?/?\?\?";
848
stringFormat = style.customFormat();
851
// This is a required parameter, so let's write a sane default
852
kWarning(30521) << "Unhandled Format value, setting 'General' as default: " << style.formatType();
853
stringFormat = "General";
914
cell_style.setAttribute("Format",stringFormat);
856
cell_style.setAttribute("Format", stringFormat);
916
if(hasBorder(cell, currentcolumn, currentrow))
858
if (hasBorder(cell, currentcolumn, currentrow))
917
859
cell_style.appendChild(GetBorderStyle(gnumeric_doc, cell, currentcolumn, currentrow));
967
909
// The reason why we use the KoDocument* approach and not the QDomDocument
968
910
// approach is because we don't want to export formulas but values !
969
KoFilter::ConversionStatus GNUMERICExport::convert( const QByteArray& from, const QByteArray& to )
911
KoFilter::ConversionStatus GNUMERICExport::convert(const QByteArray& from, const QByteArray& to)
971
kDebug(30521) <<"Exporting GNUmeric";
913
kDebug(30521) << "Exporting GNUmeric";
973
QDomDocument gnumeric_doc=QDomDocument();
915
QDomDocument gnumeric_doc = QDomDocument();
975
917
KoDocument* document = m_chain->inputDocument();
978
920
return KoFilter::StupidError;
980
if ( !qobject_cast<const KSpread::Doc *>( document ) ) // it's safer that way :)
982
kWarning(30521) << "document isn't a KSpread::Doc but a " << document->metaObject()->className();
922
if (!qobject_cast<const KSpread::Doc *>(document)) { // it's safer that way :)
923
kWarning(30521) << "document isn't a KSpread::Doc but a " << document->metaObject()->className();
983
924
return KoFilter::NotImplemented;
985
if (to != "application/x-gnumeric" || from != "application/x-kspread")
926
if (to != "application/x-gnumeric" || from != "application/x-kspread") {
987
927
kWarning(30521) << "Invalid mimetypes " << to << " " << from;
988
928
return KoFilter::NotImplemented;
991
931
Doc* ksdoc = (Doc*)document;
993
if (ksdoc->mimeType() != "application/x-kspread")
933
if (ksdoc->mimeType() != "application/x-kspread") {
995
934
kWarning(30521) << "Invalid document mimetype " << ksdoc->mimeType();
996
935
return KoFilter::NotImplemented;
999
938
/* This could be Made into a function */
1001
gnumeric_doc.appendChild( gnumeric_doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
940
gnumeric_doc.appendChild(gnumeric_doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
1003
942
QDomElement workbook = gnumeric_doc.createElement("gmr:Workbook");
1004
workbook.setAttribute("xmlns:gmr","http://www.gnumeric.org/v10.dtd");
1005
workbook.setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
943
workbook.setAttribute("xmlns:gmr", "http://www.gnumeric.org/v10.dtd");
944
workbook.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1006
945
workbook.setAttribute("xmlns:schemaLocation", "http://www.gnumeric.org/v8.xsd");
1007
946
gnumeric_doc.appendChild(workbook);
1009
948
/* End Made into a function */
1011
QDomElement sheets,sheet,tmp,cells,selections, cols,rows,styles,merged, margins, top, left, bottom, right, orientation, paper, header, footer, customSize, cellComment, objects, repeatColumns, repeatRows;
950
QDomElement sheets, sheet, tmp, cells, selections, cols, rows, styles, merged, margins, topMargin, leftMargin, bottomMargin, rightMargin, orientation, paper, header, footer, customSize, cellComment, objects, repeatColumns, repeatRows;
1013
952
KoDocumentInfo *DocumentInfo = document->documentInfo();
1169
1102
sheet.appendChild(tmp);
1172
tmp = gnumeric_doc.createElement( "gmr:PrintInformation" );
1173
margins = gnumeric_doc.createElement( "gmr:Margins" );
1175
top = gnumeric_doc.createElement( "gmr:top" );
1176
top.setAttribute("Points", table->print()->settings()->pageLayout().top);
1177
top.setAttribute("PrefUnit", "mm");
1178
margins.appendChild( top );
1180
bottom = gnumeric_doc.createElement( "gmr:bottom" );
1181
bottom.setAttribute("Points", table->print()->settings()->pageLayout().bottom);
1182
bottom.setAttribute("PrefUnit", "mm");
1183
margins.appendChild( bottom );
1185
left = gnumeric_doc.createElement( "gmr:left" );
1186
left.setAttribute("Points", table->print()->settings()->pageLayout().left);
1187
left.setAttribute("PrefUnit", "mm");
1188
margins.appendChild( left );
1190
right = gnumeric_doc.createElement( "gmr:right" );
1191
right.setAttribute("Points", table->print()->settings()->pageLayout().right);
1192
right.setAttribute("PrefUnit", "mm");
1193
margins.appendChild( right );
1195
tmp.appendChild( margins );
1105
tmp = gnumeric_doc.createElement("gmr:PrintInformation");
1106
margins = gnumeric_doc.createElement("gmr:Margins");
1108
topMargin = gnumeric_doc.createElement("gmr:top");
1109
topMargin.setAttribute("Points", table->print()->settings()->pageLayout().topMargin);
1110
topMargin.setAttribute("PrefUnit", "mm");
1111
margins.appendChild(topMargin);
1113
bottomMargin = gnumeric_doc.createElement("gmr:bottom");
1114
bottomMargin.setAttribute("Points", table->print()->settings()->pageLayout().bottomMargin);
1115
bottomMargin.setAttribute("PrefUnit", "mm");
1116
margins.appendChild(bottomMargin);
1118
leftMargin = gnumeric_doc.createElement("gmr:left");
1119
leftMargin.setAttribute("Points", table->print()->settings()->pageLayout().leftMargin);
1120
leftMargin.setAttribute("PrefUnit", "mm");
1121
margins.appendChild(leftMargin);
1123
rightMargin = gnumeric_doc.createElement("gmr:right");
1124
rightMargin.setAttribute("Points", table->print()->settings()->pageLayout().rightMargin);
1125
rightMargin.setAttribute("PrefUnit", "mm");
1126
margins.appendChild(rightMargin);
1128
tmp.appendChild(margins);
1196
1129
sheet.appendChild(tmp);
1198
orientation = gnumeric_doc.createElement( "gmr:orientation" );
1131
orientation = gnumeric_doc.createElement("gmr:orientation");
1199
1132
QString orientString = table->print()->settings()->pageLayout().orientation == KoPageFormat::Landscape ? "landscape" : "portrait";
1200
orientation.appendChild( gnumeric_doc.createTextNode(orientString) );
1201
tmp.appendChild( orientation );
1133
orientation.appendChild(gnumeric_doc.createTextNode(orientString));
1134
tmp.appendChild(orientation);
1203
1136
//TODO for future
1204
1137
//<gmr:repeat_top value="A1:IV5"/>
1207
1140
int _tmpRepeatColumnStart = table->print()->printRepeatColumns().first;
1208
1141
int _tmpRepeatColumnEnd = table->print()->printRepeatColumns().second;
1209
if ( _tmpRepeatColumnStart!=0 )
1211
repeatColumns = gnumeric_doc.createElement( "gmr:repeat_left" );
1212
QString value = Cell::columnName( _tmpRepeatColumnStart )+"1:"+Cell::columnName(_tmpRepeatColumnEnd )+"65536";
1213
repeatColumns.setAttribute( "value", value );
1214
tmp.appendChild( repeatColumns );
1142
if (_tmpRepeatColumnStart != 0) {
1143
repeatColumns = gnumeric_doc.createElement("gmr:repeat_left");
1144
QString value = Cell::columnName(_tmpRepeatColumnStart) + "1:" + Cell::columnName(_tmpRepeatColumnEnd) + "65536";
1145
repeatColumns.setAttribute("value", value);
1146
tmp.appendChild(repeatColumns);
1216
1148
int _tmpRepeatRowStart = table->print()->printRepeatRows().first;
1217
1149
int _tmpRepeatRowEnd = table->print()->printRepeatRows().second;
1218
if ( _tmpRepeatRowStart!=0 )
1220
repeatRows = gnumeric_doc.createElement( "gmr:repeat_top" );
1221
QString value = 'A'+ QString::number(_tmpRepeatRowStart ) +":IV"+QString::number( _tmpRepeatRowEnd );
1222
repeatRows.setAttribute( "value", value );
1223
tmp.appendChild( repeatRows );
1150
if (_tmpRepeatRowStart != 0) {
1151
repeatRows = gnumeric_doc.createElement("gmr:repeat_top");
1152
QString value = 'A' + QString::number(_tmpRepeatRowStart) + ":IV" + QString::number(_tmpRepeatRowEnd);
1153
repeatRows.setAttribute("value", value);
1154
tmp.appendChild(repeatRows);
1226
header = gnumeric_doc.createElement( "gmr:Header" );
1227
header.setAttribute( "Left", convertVariable(table->print()->headLeft() ) );
1228
header.setAttribute( "Middle", convertVariable(table->print()->headMid() ) );
1229
header.setAttribute( "Right", convertVariable(table->print()->headRight() ) );
1230
tmp.appendChild( header );
1232
footer = gnumeric_doc.createElement( "gmr:Footer" );
1233
footer.setAttribute( "Left", convertVariable( table->print()->footLeft() ) );
1234
footer.setAttribute( "Middle", convertVariable( table->print()->footMid() ) );
1235
footer.setAttribute( "Right", convertVariable( table->print()->footRight() ));
1236
tmp.appendChild( footer );
1238
paper = gnumeric_doc.createElement( "gmr:paper" );
1239
paper.appendChild( gnumeric_doc.createTextNode( table->print()->paperFormatString() ) );
1240
tmp.appendChild( paper );
1157
header = gnumeric_doc.createElement("gmr:Header");
1158
header.setAttribute("Left", convertVariable(table->print()->headLeft()));
1159
header.setAttribute("Middle", convertVariable(table->print()->headMid()));
1160
header.setAttribute("Right", convertVariable(table->print()->headRight()));
1161
tmp.appendChild(header);
1163
footer = gnumeric_doc.createElement("gmr:Footer");
1164
footer.setAttribute("Left", convertVariable(table->print()->footLeft()));
1165
footer.setAttribute("Middle", convertVariable(table->print()->footMid()));
1166
footer.setAttribute("Right", convertVariable(table->print()->footRight()));
1167
tmp.appendChild(footer);
1169
paper = gnumeric_doc.createElement("gmr:paper");
1170
paper.appendChild(gnumeric_doc.createTextNode(table->print()->paperFormatString()));
1171
tmp.appendChild(paper);
1242
1173
styles = gnumeric_doc.createElement("gmr:Styles");
1243
1174
sheet.appendChild(styles);
1485
1400
cells.appendChild(gnumeric_cell);
1487
gnumeric_cell.setAttribute("Col", QString::number(currentcolumn-1));
1488
gnumeric_cell.setAttribute("Row", QString::number(currentrow-1));
1402
gnumeric_cell.setAttribute("Col", QString::number(currentcolumn - 1));
1403
gnumeric_cell.setAttribute("Row", QString::number(currentrow - 1));
1490
1405
/* Right now, we create a single region for each cell.. This is inefficient,
1491
1406
* but the implementation is quicker.. Probably later we will have to
1492
1407
* consolidate styles into style regions.
1495
style_region.setAttribute("startCol", QString::number(currentcolumn-1));
1496
style_region.setAttribute("startRow", QString::number(currentrow-1));
1497
style_region.setAttribute("endCol", QString::number(currentcolumn-1));
1498
style_region.setAttribute("endRow", QString::number(currentrow-1));
1410
style_region.setAttribute("startCol", QString::number(currentcolumn - 1));
1411
style_region.setAttribute("startRow", QString::number(currentrow - 1));
1412
style_region.setAttribute("endCol", QString::number(currentcolumn - 1));
1413
style_region.setAttribute("endRow", QString::number(currentrow - 1));
1500
cell_style = GetCellStyle(gnumeric_doc,cell,currentcolumn,currentrow);
1415
cell_style = GetCellStyle(gnumeric_doc, cell, currentcolumn, currentrow);
1502
1417
style_region.appendChild(cell_style);
1556
QString GNUMERICExport::convertRefToRange( const QString & table, const QRect & rect )
1558
QPoint topLeft( rect.topLeft() );
1559
QPoint bottomRight( rect.bottomRight() );
1560
if ( topLeft == bottomRight )
1561
return convertRefToBase( table, rect );
1565
s += Cell::columnName( topLeft.x() );
1567
s += QString::number( topLeft.y() );
1569
s += Cell::columnName( bottomRight.x() );
1571
s += QString::number( bottomRight.y() );
1577
QString GNUMERICExport::convertRefToBase( const QString & table, const QRect & rect )
1579
QPoint bottomRight( rect.bottomRight() );
1584
s += Cell::columnName( bottomRight.x() );
1586
s += QString::number( bottomRight.y() );
1591
QString GNUMERICExport::convertVariable( QString headerFooter )
1593
headerFooter = headerFooter.replace( "<sheet>", "&[TAB]" );
1594
headerFooter = headerFooter.replace( "<date>", "&[DATE]" );
1595
headerFooter = headerFooter.replace( "<page>", "&[PAGE]" );
1596
headerFooter = headerFooter.replace( "<pages>", "&[PAGES]" );
1597
headerFooter = headerFooter.replace( "<time>", "&[TIME]" );
1598
headerFooter = headerFooter.replace( "<file>", "&[FILE]" );
1469
QString GNUMERICExport::convertRefToRange(const QString & table, const QRect & rect)
1471
QPoint topLeft(rect.topLeft());
1472
QPoint bottomRight(rect.bottomRight());
1473
if (topLeft == bottomRight)
1474
return convertRefToBase(table, rect);
1478
s += Cell::columnName(topLeft.x());
1480
s += QString::number(topLeft.y());
1482
s += Cell::columnName(bottomRight.x());
1484
s += QString::number(bottomRight.y());
1490
QString GNUMERICExport::convertRefToBase(const QString & table, const QRect & rect)
1492
QPoint bottomRight(rect.bottomRight());
1497
s += Cell::columnName(bottomRight.x());
1499
s += QString::number(bottomRight.y());
1504
QString GNUMERICExport::convertVariable(QString headerFooter)
1506
headerFooter = headerFooter.replace("<sheet>", "&[TAB]");
1507
headerFooter = headerFooter.replace("<date>", "&[DATE]");
1508
headerFooter = headerFooter.replace("<page>", "&[PAGE]");
1509
headerFooter = headerFooter.replace("<pages>", "&[PAGES]");
1510
headerFooter = headerFooter.replace("<time>", "&[TIME]");
1511
headerFooter = headerFooter.replace("<file>", "&[FILE]");
1600
1513
return headerFooter;