20#include "stylefactory.h"
23#include <tqdatetime.h>
27StyleFactory::StyleFactory()
29 m_strokeDashStyles.setAutoDelete(
true );
30 m_gradientStyles.setAutoDelete(
true );
31 m_hatchStyles.setAutoDelete(
true );
32 m_markerStyles.setAutoDelete(
true );
33 m_fillImageStyles.setAutoDelete(
true );
34 m_listStyles.setAutoDelete(
true );
35 m_pageStyles.setAutoDelete(
true );
36 m_textStyles.setAutoDelete(
true );
37 m_graphicStyles.setAutoDelete(
true );
38 m_paragraphStyles.setAutoDelete(
true );
39 m_pageMasterStyles.setAutoDelete(
true );
42 GraphicStyle * graphicStyle;
43 graphicStyle =
new GraphicStyle (
"standard",
"solid",
"0cm",
"0x000000",
44 "hidden",
"0.3cm",
"0.3cm",
"0x808080",
45 "0cm",
"0cm",
"0cm",
"0cm",
"0x000000",
46 "false",
"none",
"Thorndale",
"24pt",
47 "normal",
"none",
"none",
"normal",
48 "100%",
"start",
"solid",
"0x00b8ff",
51 m_graphicStyles.append( graphicStyle );
54StyleFactory::~StyleFactory()
58void StyleFactory::addOfficeStyles( TQDomDocument & doc, TQDomElement & styles )
61 for ( sd = m_strokeDashStyles.first(); sd ; sd = m_strokeDashStyles.next() )
62 sd->toXML( doc, styles );
65 for ( g = m_gradientStyles.first(); g ; g = m_gradientStyles.next() )
66 g->toXML( doc, styles );
69 for ( m = m_markerStyles.first(); m ; m = m_markerStyles.next() )
70 m->toXML( doc, styles );
73 for ( h = m_hatchStyles.first(); h ; h = m_hatchStyles.next() )
74 h->toXML( doc, styles );
77 gr = m_graphicStyles.first();
78 gr->toXML( doc, styles );
81void StyleFactory::addOfficeMaster( TQDomDocument & doc, TQDomElement & master )
84 for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
86 TQDomElement masterPage = doc.createElement(
"style:master-page" );
87 masterPage.setAttribute(
"style:name", p->style() );
88 masterPage.setAttribute(
"style:page-master-name", p->name() );
89 masterPage.setAttribute(
"draw:style-name",
"dp1" );
90 master.appendChild( masterPage );
94void StyleFactory::addOfficeAutomatic( TQDomDocument & doc, TQDomElement & automatic )
97 for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
99 p->toXML( doc, automatic );
103void StyleFactory::addAutomaticStyles( TQDomDocument & doc, TQDomElement & autoStyles )
106 for ( l = m_listStyles.first(); l ; l = m_listStyles.next() )
107 l->toXML( doc, autoStyles );
110 for ( p = m_pageStyles.first(); p ; p = m_pageStyles.next() )
111 p->toXML( doc, autoStyles );
114 for ( t = m_textStyles.first(); t ; t = m_textStyles.next() )
115 t->toXML( doc, autoStyles );
118 g = m_graphicStyles.first();
119 for ( g = m_graphicStyles.next(); g ; g = m_graphicStyles.next() )
120 g->toXML( doc, autoStyles );
123 for ( pg = m_paragraphStyles.first(); pg ; pg = m_paragraphStyles.next() )
124 pg->toXML( doc, autoStyles );
127TQString StyleFactory::createStrokeDashStyle(
int style )
129 StrokeDashStyle * newStrokeDashStyle, * sd;
130 newStrokeDashStyle =
new StrokeDashStyle( style );
131 for ( sd = m_strokeDashStyles.first(); sd ; sd = m_strokeDashStyles.next() )
133 if ( sd->name() == newStrokeDashStyle->name() )
135 delete newStrokeDashStyle;
140 m_strokeDashStyles.append( newStrokeDashStyle );
141 return newStrokeDashStyle->name();
144TQString StyleFactory::createGradientStyle( TQDomElement & gradient )
146 GradientStyle * newGradientStyle, * g;
147 newGradientStyle =
new GradientStyle( gradient, m_gradientStyles.count() + 1 );
148 for ( g = m_gradientStyles.first(); g ; g = m_gradientStyles.next() )
150 if ( g->name() == newGradientStyle->name() )
152 delete newGradientStyle;
157 m_gradientStyles.append( newGradientStyle );
158 return newGradientStyle->name();
161TQString StyleFactory::createMarkerStyle(
int style )
163 MarkerStyle * newMarkerStyle, * m;
164 newMarkerStyle =
new MarkerStyle( style );
165 for ( m = m_markerStyles.first(); m ; m = m_markerStyles.next() )
167 if ( m->name() == newMarkerStyle->name() )
169 delete newMarkerStyle;
174 m_markerStyles.append( newMarkerStyle );
175 return newMarkerStyle->name();
178TQString StyleFactory::createHatchStyle(
int style, TQString & color )
180 HatchStyle * newHatchStyle, * h;
181 newHatchStyle =
new HatchStyle( style, color );
182 for ( h = m_hatchStyles.first(); h ; h = m_hatchStyles.next() )
184 if ( h->name() == newHatchStyle->name() )
186 delete newHatchStyle;
191 m_hatchStyles.append( newHatchStyle );
192 return newHatchStyle->name();
195TQString StyleFactory::createListStyle( TQDomElement & e )
197 ListStyle * newListStyle, * l;
198 newListStyle =
new ListStyle( e, m_listStyles.count() + 1 );
199 for ( l = m_listStyles.first(); l ; l = m_listStyles.next() )
201 if ( *l == *newListStyle )
208 m_listStyles.append( newListStyle );
209 return newListStyle->name();
212TQString StyleFactory::createPageStyle( TQDomElement & e )
214 PageStyle * newPageStyle, * p;
215 newPageStyle =
new PageStyle(
this, e, m_pageStyles.count() + 1 );
216 for ( p = m_pageStyles.first(); p ; p = m_pageStyles.next() )
218 if ( *p == *newPageStyle )
225 m_pageStyles.append( newPageStyle );
226 return newPageStyle->name();
229TQString StyleFactory::createTextStyle( TQDomElement & e )
231 TextStyle * newTextStyle, * t;
232 newTextStyle =
new TextStyle( e, m_textStyles.count() + 1 );
233 for ( t = m_textStyles.first(); t ; t = m_textStyles.next() )
235 if ( *t == *newTextStyle )
242 m_textStyles.append( newTextStyle );
243 return newTextStyle->name();
246TQString StyleFactory::createGraphicStyle( TQDomElement & e )
248 GraphicStyle * newGraphicStyle, * g;
249 newGraphicStyle =
new GraphicStyle(
this, e, m_graphicStyles.count() );
250 for ( g = m_graphicStyles.first(); g ; g = m_graphicStyles.next() )
252 if ( *g == *newGraphicStyle )
254 delete newGraphicStyle;
259 m_graphicStyles.append( newGraphicStyle );
260 return newGraphicStyle->name();
263TQString StyleFactory::createParagraphStyle( TQDomElement & e )
265 ParagraphStyle * newParagraphStyle, * p;
266 newParagraphStyle =
new ParagraphStyle( e, m_paragraphStyles.count() + 1 );
267 for ( p = m_paragraphStyles.first(); p ; p = m_paragraphStyles.next() )
269 if ( *p == *newParagraphStyle )
271 delete newParagraphStyle;
276 m_paragraphStyles.append( newParagraphStyle );
277 return newParagraphStyle->name();
280TQString StyleFactory::createPageMasterStyle( TQDomElement & e )
282 PageMasterStyle * newPMStyle, * p;
283 newPMStyle =
new PageMasterStyle( e, m_pageMasterStyles.count() );
284 for ( p = m_pageMasterStyles.first(); p ; p = m_pageMasterStyles.next() )
286 if ( *p == *newPMStyle )
293 m_pageMasterStyles.append( newPMStyle );
294 return newPMStyle->style();
297TQString StyleFactory::toCM(
const TQString & point )
299 double pt = point.toFloat();
300 double cm = KoUnit::toCM( pt );
301 return TQString(
"%1cm" ).arg ( cm );
304StrokeDashStyle::StrokeDashStyle(
int style )
309 m_name =
"Fine Dashed";
312 m_dots1_length =
"0.508cm";
314 m_dots2_length =
"0.508cm";
315 m_distance =
"0.508cm";
318 m_name =
"Fine Dotted";
321 m_distance =
"0.257cm";
324 m_name =
"Ultrafine 1 Dot 1 Dash";
327 m_dots1_length =
"0.051cm";
329 m_dots2_length =
"0.254cm";
330 m_distance =
"0.127cm";
333 m_name =
"2 Dots 1 Dash";
337 m_dots2_length =
"0.203cm";
338 m_distance =
"0.203cm";
343void StrokeDashStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
345 TQDomElement strokeDash = doc.createElement(
"draw:stroke-dash" );
346 strokeDash.setAttribute(
"draw:name", m_name );
347 if ( !m_style.isNull() )
348 strokeDash.setAttribute(
"draw:style", m_style );
349 if ( !m_dots1.isNull() )
350 strokeDash.setAttribute(
"draw:dots1", m_dots1 );
351 if ( !m_dots1_length.isNull() )
352 strokeDash.setAttribute(
"draw:dots1-length", m_dots1_length );
353 if ( !m_dots2.isNull() )
354 strokeDash.setAttribute(
"draw:dots2", m_dots2 );
355 if ( !m_dots2_length.isNull() )
356 strokeDash.setAttribute(
"draw:dots2-length", m_dots2_length );
357 if ( !m_distance.isNull() )
358 strokeDash.setAttribute(
"draw:distance", m_distance );
360 e.appendChild( strokeDash );
363GradientStyle::GradientStyle( TQDomElement & gradient,
int index )
365 m_name = TQString(
"Gradient %1" ).arg( index );
366 m_start_intensity =
"100%";
367 m_end_intensity =
"100%";
371 if ( gradient.nodeName() ==
"PAGE" )
374 TQDomElement backColor1 = gradient.namedItem(
"BACKCOLOR1" ).toElement();
375 TQDomElement backColor2 = gradient.namedItem(
"BACKCOLOR2" ).toElement();
376 TQDomElement bcType = gradient.namedItem(
"BCTYPE" ).toElement();
377 TQDomElement bGradient = gradient.namedItem(
"BGRADIENT" ).toElement();
379 if ( !backColor1.isNull() )
380 m_start_color = backColor1.attribute(
"color" );
381 if ( !backColor2.isNull() )
382 m_end_color = backColor2.attribute(
"color" );
383 if ( !bcType.isNull() )
384 type = bcType.attribute(
"value" ).toInt();
385 if ( !bGradient.isNull() )
387 if ( bGradient.attribute(
"unbalanced" ) ==
"0" )
394 int cx = bGradient.attribute(
"xfactor" ).toInt();
395 int cy = bGradient.attribute(
"yfactor" ).toInt();
396 m_cx = TQString(
"%1%" ).arg( cx / 4 + 50 );
397 m_cy = TQString(
"%1%" ).arg( cy / 4 + 50 );
405 if ( gradient.hasAttribute(
"color1" ) )
406 m_start_color = gradient.attribute(
"color1" );
407 if ( gradient.hasAttribute(
"color2" ) )
408 m_end_color = gradient.attribute(
"color2" );
409 if ( gradient.hasAttribute(
"type" ) )
410 type = gradient.attribute(
"type" ).toInt();
411 if ( gradient.hasAttribute(
"unbalanced" ) )
413 if ( gradient.attribute(
"unbalanced" ) ==
"0" )
420 int cx = gradient.attribute(
"xfactor" ).toInt();
421 int cy = gradient.attribute(
"yfactor" ).toInt();
422 m_cx = TQString(
"%1%" ).arg( cx / 4 + 50 );
423 m_cy = TQString(
"%1%" ).arg( cy / 4 + 50 );
462void GradientStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
464 TQDomElement gradient = doc.createElement(
"draw:gradient" );
465 gradient.setAttribute(
"draw:name", m_name );
466 if ( !m_style.isNull() )
467 gradient.setAttribute(
"draw:style", m_style );
468 if ( !m_start_color.isNull() )
469 gradient.setAttribute(
"draw:start-color", m_start_color );
470 if ( !m_end_color.isNull() )
471 gradient.setAttribute(
"draw:end-color", m_end_color );
472 if ( !m_start_intensity.isNull() )
473 gradient.setAttribute(
"draw:start-intensity", m_start_intensity );
474 if ( !m_end_intensity.isNull() )
475 gradient.setAttribute(
"draw:end-intensity", m_end_intensity );
476 if ( !m_angle.isNull() )
477 gradient.setAttribute(
"draw:angle", m_angle );
478 if ( !m_border.isNull() )
479 gradient.setAttribute(
"draw:border", m_border );
480 if ( !m_cx.isNull() )
481 gradient.setAttribute(
"draw:cx", m_cx );
482 if ( !m_cy.isNull() )
483 gradient.setAttribute(
"draw:cy", m_cy );
485 e.appendChild( gradient );
488MarkerStyle::MarkerStyle(
int style )
498 m_viewBox =
"0 0 20 30";
499 m_d =
"m10 0-10 30h20z";
503 m_viewBox =
"0 0 10 10";
504 m_d =
"m0 0h10v10h-10z";
508 m_viewBox =
"0 0 1131 1131";
509 m_d =
"m462 1118-102-29-102-51-93-72-72-93-51-102-29-102-13-105 13-102 29-106 51-102 72-89 93-72 102-50 102-34 106-9 101 9 106 34 98 50 93 72 72 89 51 102 29 106 13 102-13 105-29 102-51 102-72 93-93 72-98 51-106 29-101 13z";
512 m_name =
"Line Arrow";
513 m_viewBox =
"0 0 1122 2243";
514 m_d =
"m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z";
517 m_name =
"Dimension Lines";
518 m_viewBox =
"0 0 836 110";
519 m_d =
"m0 0h278 278 280v36 36 38h-278-278-280v-36-36z";
523 m_name =
"Double Arrow";
524 m_viewBox =
"0 0 1131 1918";
525 m_d =
"m737 1131h394l-564-1131-567 1131h398l-398 787h1131z";
530void MarkerStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
532 TQDomElement marker = doc.createElement(
"draw:marker" );
533 marker.setAttribute(
"draw:name", m_name );
534 if ( !m_viewBox.isNull() )
535 marker.setAttribute(
"svg:viewBox", m_viewBox );
537 marker.setAttribute(
"svg:d", m_d );
539 e.appendChild( marker );
542HatchStyle::HatchStyle(
int style, TQString & color )
549 m_name = m_color +
" 0 Degrees";
551 m_distance =
"0.102cm";
555 m_name = m_color +
" 90 Degrees";
557 m_distance =
"0.102cm";
561 m_name = m_color +
" Crossed 0 Degrees";
563 m_distance =
"0.076cm";
567 m_name = m_color +
" 45 Degrees";
569 m_distance =
"0.102cm";
573 m_name = m_color +
" -45 Degrees";
575 m_distance =
"0.102cm";
579 m_name = m_color +
" Crossed 45 Degrees";
581 m_distance =
"0.076cm";
587void HatchStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
589 TQDomElement hatch = doc.createElement(
"draw:hatch" );
590 hatch.setAttribute(
"draw:name", m_name );
591 if ( !m_style.isNull() )
592 hatch.setAttribute(
"draw:style", m_style );
593 if ( !m_color.isNull() )
594 hatch.setAttribute(
"draw:color", m_color );
595 if ( !m_distance.isNull() )
596 hatch.setAttribute(
"draw:distance", m_distance );
597 if ( !m_rotation.isNull() )
598 hatch.setAttribute(
"draw:rotation", m_rotation );
600 e.appendChild( hatch );
603FillImageStyle::FillImageStyle( TQString & name )
608void FillImageStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
613PageMasterStyle::PageMasterStyle( TQDomElement & e,
const uint index )
615 TQDomNode borders = e.namedItem(
"PAPERBORDERS" );
616 TQDomElement b = borders.toElement();
618 m_name = TQString(
"PM%1" ).arg( index );
619 m_style = TQString(
"Default%1" ).arg( index );
620 m_margin_top = StyleFactory::toCM( b.attribute(
"ptTop" ) );
621 m_margin_bottom = StyleFactory::toCM( b.attribute(
"ptBottom" ) );
622 m_margin_left = StyleFactory::toCM( b.attribute(
"ptLeft" ) );
623 m_margin_right = StyleFactory::toCM( b.attribute(
"ptRight" ) );
624 m_page_width = StyleFactory::toCM( e.attribute(
"ptWidth" ) );
625 m_page_height = StyleFactory::toCM( e.attribute(
"ptHeight" ) );
626 m_orientation =
"landscape";
629void PageMasterStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
631 TQDomElement style = doc.createElement(
"style:page-master" );
632 style.setAttribute(
"style:name",
"PM0" );
634 TQDomElement properties = doc.createElement(
"style:properties" );
635 properties.setAttribute(
"fo:margin-top", m_margin_top );
636 properties.setAttribute(
"fo:margin-bottom", m_margin_bottom );
637 properties.setAttribute(
"fo:margin-left", m_margin_left );
638 properties.setAttribute(
"fo:margin-right", m_margin_right );
639 properties.setAttribute(
"fo:page-width", m_page_width );
640 properties.setAttribute(
"fo:page-height", m_page_height );
641 properties.setAttribute(
"fo:print-orientation", m_orientation );
643 style.appendChild( properties );
644 e.appendChild( style );
647bool PageMasterStyle::operator==(
const PageMasterStyle & pageMasterStyle )
const
649 return ( m_margin_top == pageMasterStyle.m_margin_top &&
650 m_margin_bottom == pageMasterStyle.m_margin_bottom &&
651 m_margin_left == pageMasterStyle.m_margin_left &&
652 m_margin_right == pageMasterStyle.m_margin_right &&
653 m_page_width == pageMasterStyle.m_page_width &&
654 m_page_height == pageMasterStyle.m_page_height &&
655 m_orientation == pageMasterStyle.m_orientation );
658PageStyle::PageStyle( StyleFactory * styleFactory, TQDomElement & e,
const uint index )
660 TQDomElement backMaster = e.namedItem(
"BACKMASTER" ).toElement();
661 if( !backMaster.isNull())
664 if(backMaster.hasAttribute(
"displayBackground"))
665 tmp = backMaster.attribute(
"displayBackground").toInt();
666 m_bg_visible = (tmp==1) ?
"true" :
"false";
668 if(backMaster.hasAttribute(
"displayMasterPageObject"))
669 tmp = backMaster.attribute(
"displayMasterPageObject").toInt();
670 m_bg_objects_visible = (tmp==1) ?
"true" :
"false";
674 m_bg_visible =
"true";
675 m_bg_objects_visible =
"true";
678 m_name = TQString(
"dp%1" ).arg( index );
681 if ( !e.hasChildNodes() )
684 TQDomElement backType = e.namedItem(
"BACKTYPE" ).toElement();
685 if ( backType.isNull() || backType.attribute(
"value" ) ==
"0" )
688 TQDomElement bcType = e.namedItem(
"BCTYPE" ).toElement();
689 if ( bcType.isNull() || bcType.attribute(
"value" ) ==
"0" )
692 TQDomElement backColor = e.namedItem(
"BACKCOLOR1" ).toElement();
694 m_fill_color = backColor.attribute(
"color" );
700 m_fill_gradient_name = styleFactory->createGradientStyle( e );
708 TQDomElement pageDuration = e.namedItem(
"PGTIMER" ).toElement();
709 if ( !pageDuration.isNull() )
713 time = time.addSecs( pageDuration.attribute(
"timer").toInt() );
714 TQString hours( TQString::number( time.hour() ).rightJustify( 2,
'0' ) );
715 TQString ms( TQString::number( time.minute() ).rightJustify( 2,
'0' ) );
716 TQString sec( TQString::number( time.second() ).rightJustify( 2,
'0' ) );
721 m_page_duration = TQString(
"PT%1H%2M%3S" ).arg( hours ).arg( ms ).arg( sec );
724 TQDomElement pageEffect = e.namedItem(
"PGEFFECT" ).toElement();
725 if ( !pageEffect.isNull() )
728 if(pageEffect.hasAttribute(
"value"))
729 tmp=pageEffect.attribute(
"value").toInt();
730 kdDebug(30518)<<
" tmp :"<<tmp<<endl;
734 m_page_effect =
"random";
737 m_page_effect =
"close-vertical";
740 m_page_effect =
"close-horizontal";
743 m_page_effect =
"fade-to-center";
746 m_page_effect =
"open-vertical";
749 m_page_effect =
"open-horizontal";
752 m_page_effect =
"fade-from-center";
758 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
761 m_page_effect =
"spiralin-left";
770 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
773 m_page_effect =
"fade-from-top";
776 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
779 m_page_effect =
"fade-from-bottom";
782 m_page_effect =
"roll-from-bottom";
785 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
788 m_page_effect =
"roll-from-right";
791 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
794 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
797 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
800 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
803 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
806 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
809 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
812 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
815 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
818 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
821 m_page_effect =
"dissolve";
824 m_page_effect =
"fade-from-lowerright";
827 m_page_effect =
"fade-from-upperright";
830 m_page_effect =
"fade-from-lowerleft";
833 m_page_effect =
"fade-from-upperleft";
836 kdDebug(30518)<<
" this style is not defined :"<<tmp<<endl;
839 kdDebug(30518)<<
" style page effect not define : "<<tmp<<endl;
845void PageStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
847 TQDomElement style = doc.createElement(
"style:style" );
848 style.setAttribute(
"style:name", m_name );
849 style.setAttribute(
"style:family",
"drawing-page" );
851 TQDomElement properties = doc.createElement(
"style:properties" );
852 properties.setAttribute(
"presentation:background-visible", m_bg_visible );
853 properties.setAttribute(
"presentation:background-objects-visible",
854 m_bg_objects_visible );
855 if ( !m_page_duration.isEmpty() )
857 properties.setAttribute(
"presentation:duration", m_page_duration );
858 properties.setAttribute(
"presentation:transition-type",
"automatic" );
860 if ( !m_page_effect.isEmpty() )
861 properties.setAttribute(
"presentation:transition-style",
863 if ( !m_fill.isNull() )
864 properties.setAttribute(
"draw:fill", m_fill );
865 if ( !m_fill_color.isNull() )
866 properties.setAttribute(
"draw:fill-color", m_fill_color );
867 if ( !m_fill_image_name.isNull() )
868 properties.setAttribute(
"draw:fill-image-name", m_fill_image_name );
869 if ( !m_fill_image_width.isNull() )
870 properties.setAttribute(
"draw:fill-image-width", m_fill_image_width );
871 if ( !m_fill_image_height.isNull() )
872 properties.setAttribute(
"draw:fill-image-height", m_fill_image_height );
873 if ( !m_fill_image_ref_point.isNull() )
874 properties.setAttribute(
"draw:fill-image-ref-point", m_fill_image_ref_point );
875 if ( !m_fill_gradient_name.isNull() )
876 properties.setAttribute(
"draw:fill-gradient-name", m_fill_gradient_name );
877 if ( !m_repeat.isNull() )
878 properties.setAttribute(
"style:repeat", m_repeat );
880 style.appendChild( properties );
881 e.appendChild( style );
884bool PageStyle::operator==(
const PageStyle & pageStyle )
const
886 return ( m_bg_visible == pageStyle.m_bg_visible &&
887 m_bg_objects_visible == pageStyle.m_bg_objects_visible &&
888 m_fill == pageStyle.m_fill &&
889 m_fill_color == pageStyle.m_fill_color &&
890 m_fill_image_name == pageStyle.m_fill_image_name &&
891 m_fill_image_width == pageStyle.m_fill_image_width &&
892 m_fill_image_height == pageStyle.m_fill_image_height &&
893 m_fill_image_ref_point == pageStyle.m_fill_image_ref_point &&
894 m_fill_gradient_name == pageStyle.m_fill_gradient_name &&
895 m_repeat == pageStyle.m_repeat &&
896 m_page_effect == pageStyle.m_page_effect &&
897 m_page_duration == pageStyle.m_page_duration );
900TextStyle::TextStyle( TQDomElement & e,
const uint index )
902 m_name = TQString(
"T%1" ).arg( index );
903 if ( e.hasAttribute(
"family" ) )
904 m_font_family = e.attribute(
"family" );
905 if ( e.hasAttribute(
"pointSize" ) )
906 m_font_size = TQString(
"%1pt" ).arg( e.attribute(
"pointSize" ) );
907 if ( e.hasAttribute(
"color" ) )
908 m_color = e.attribute(
"color" );
909 if ( e.hasAttribute(
"bold" ) && e.attribute(
"bold" ) ==
"1" )
910 m_font_weight =
"bold";
911 if ( e.hasAttribute(
"italic" ) && e.attribute(
"italic" ) ==
"1" )
912 m_font_style =
"italic";
913 if ( e.hasAttribute(
"strikeOut" ) )
915 if ( e.attribute(
"strikeOut" ) ==
"single" )
916 m_text_crossing_out =
"single-line";
917 else if ( e.attribute(
"strikeOut" ) ==
"single-bold" )
918 m_text_crossing_out =
"thick-line";
919 else if ( e.attribute(
"strikeOut" ) ==
"double" )
920 m_text_crossing_out =
"double-line";
922 if ( e.hasAttribute(
"underline" ) )
924 TQString underline = e.attribute(
"underline" );
925 TQString style = e.attribute(
"underlinestyleline" );
926 m_text_underline_color = e.attribute(
"underlinecolor" );
928 if ( style ==
"solid" )
930 if ( underline ==
"1" )
931 m_text_underline =
"single";
932 else if ( underline ==
"single-bold" )
933 m_text_underline =
"bold";
934 else if ( underline ==
"double" )
935 m_text_underline =
"double";
936 else if ( underline ==
"wave" )
937 m_text_underline =
"wave";
939 else if ( style ==
"dot" )
941 if ( underline ==
"1" )
942 m_text_underline =
"dotted";
943 else if ( underline ==
"single-bold" )
944 m_text_underline =
"bold-dotted";
946 else if ( style ==
"dash" )
947 m_text_underline =
"dash";
951void TextStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
953 TQDomElement style = doc.createElement(
"style:style" );
954 style.setAttribute(
"style:name", m_name );
955 style.setAttribute(
"style:family",
"text" );
957 TQDomElement properties = doc.createElement(
"style:properties" );
958 if ( !m_font_size.isNull() )
959 properties.setAttribute(
"fo:font-size", m_font_size );
960 if ( !m_font_family.isNull() )
961 properties.setAttribute(
"fo:font-family", m_font_family );
962 if ( !m_font_family_generic.isNull() )
963 properties.setAttribute(
"fo:font-family-generic", m_font_family_generic );
964 if ( !m_color.isNull() )
965 properties.setAttribute(
"fo:color", m_color );
966 if ( !m_font_pitch.isNull() )
967 properties.setAttribute(
"style:font-pitch", m_font_pitch );
968 if ( !m_font_style.isNull() )
969 properties.setAttribute(
"fo:font-style", m_font_style );
970 if ( !m_font_weight.isNull() )
971 properties.setAttribute(
"fo:font-weight", m_font_weight );
972 if ( !m_text_shadow.isNull() )
973 properties.setAttribute(
"fo:text-shadow", m_text_shadow );
974 if ( !m_text_underline.isNull() )
975 properties.setAttribute(
"style:text-underline", m_text_underline );
976 if ( !m_text_underline_color.isNull() )
977 properties.setAttribute(
"style:text-underline-color", m_text_underline_color );
978 if ( !m_text_crossing_out.isNull() )
979 properties.setAttribute(
"style:text-crossing-out", m_text_crossing_out );
981 style.appendChild( properties );
982 e.appendChild( style );
985bool TextStyle::operator==(
const TextStyle & textStyle )
const
987 return ( m_font_size == textStyle.m_font_size &&
988 m_font_family == textStyle.m_font_family &&
989 m_font_family_generic == textStyle.m_font_family_generic &&
990 m_color == textStyle.m_color &&
991 m_font_pitch == textStyle.m_font_pitch &&
992 m_font_style == textStyle.m_font_style &&
993 m_font_weight == textStyle.m_font_weight &&
994 m_text_shadow == textStyle.m_text_shadow &&
995 m_text_underline == textStyle.m_text_underline &&
996 m_text_underline_color == textStyle.m_text_underline_color &&
997 m_text_crossing_out == textStyle.m_text_crossing_out );
1000GraphicStyle::GraphicStyle( StyleFactory * styleFactory, TQDomElement & e,
const uint index )
1002 TQDomNode pen = e.namedItem(
"PEN" );
1003 TQDomNode brush = e.namedItem(
"BRUSH" );
1004 TQDomNode linebegin = e.namedItem(
"LINEBEGIN" );
1005 TQDomNode lineend = e.namedItem(
"LINEEND" );
1006 TQDomNode gradient = e.namedItem(
"GRADIENT" );
1007 TQDomNode shadow = e.namedItem(
"SHADOW" );
1008 TQDomNode textObject = e.namedItem(
"TEXTOBJ" );
1009 if ( !textObject.isNull() )
1011 TQDomElement textObjectElement = textObject.toElement();
1012 if ( textObjectElement.hasAttribute(
"verticalAlign" ) )
1014 m_textAlignment = textObjectElement.attribute(
"verticalAlign");
1015 if ( m_textAlignment ==
"center" )
1016 m_textAlignment =
"middle";
1018 if ( textObjectElement.hasAttribute(
"bleftpt" ) )
1020 m_textMarginLeft = TQString(
"%1pt" ).arg( textObjectElement.attribute(
"bleftpt" ) );
1022 if ( textObjectElement.hasAttribute(
"bbottompt" ) )
1024 m_textMarginBottom = TQString(
"%1pt" ).arg( textObjectElement.attribute(
"bbottompt" ) );
1026 if ( textObjectElement.hasAttribute(
"btoppt" ) )
1028 m_textMarginTop = TQString(
"%1pt" ).arg( textObjectElement.attribute(
"btoppt" ) );
1030 if ( textObjectElement.hasAttribute(
"brightpt" ) )
1032 m_textMarginRight = TQString(
"%1pt" ).arg( textObjectElement.attribute(
"brightpt" ) );
1036 kdDebug(30518)<<
" alignment :"<<m_textAlignment<<endl;
1038 m_name = TQString(
"gr%1" ).arg( index );
1039 if ( !pen.isNull() )
1041 TQDomElement p = pen.toElement();
1042 m_stroke_width = StyleFactory::toCM( p.attribute(
"width" ) );
1043 m_stroke_color = p.attribute(
"color" );
1045 int style = p.attribute(
"style" ).toInt();
1048 else if ( style >= 2 && style <= 5 )
1051 m_stroke_dash = styleFactory->createStrokeDashStyle( style );
1057 if ( !brush.isNull() )
1059 TQDomElement b = brush.toElement();
1060 m_fill_color = b.attribute(
"color" );
1062 int style = b.attribute(
"style" ).toInt();
1065 else if ( style >= 9 && style <= 14 )
1068 m_fill_hatch_name = styleFactory->createHatchStyle( style, m_fill_color );
1070 else if ( style >= 2 && style <= 8 )
1073 m_transparency =
"94%";
1074 else if ( style == 3 )
1075 m_transparency =
"88%";
1076 else if ( style == 4 )
1077 m_transparency =
"63%";
1078 else if ( style == 5 )
1079 m_transparency =
"50%";
1080 else if ( style == 6 )
1081 m_transparency =
"37%";
1082 else if ( style == 7 )
1083 m_transparency =
"12%";
1084 else if ( style == 8 )
1085 m_transparency =
"6%";
1088 else if ( !gradient.isNull() )
1090 TQDomElement g = gradient.toElement();
1091 m_fill =
"gradient";
1092 m_fill_gradient_name = styleFactory->createGradientStyle( g );
1097 if ( !linebegin.isNull() )
1099 TQDomElement lb = linebegin.toElement();
1100 m_marker_start_width =
"0.25cm";
1102 int style = lb.attribute(
"value" ).toInt();
1103 m_marker_start = styleFactory->createMarkerStyle( style );
1106 if ( !lineend.isNull() )
1108 TQDomElement le = lineend.toElement();
1109 m_marker_end_width =
"0.25cm";
1111 int style = le.attribute(
"value" ).toInt();
1112 m_marker_end = styleFactory->createMarkerStyle( style );
1115 if ( !shadow.isNull() )
1117 TQDomElement s = shadow.toElement();
1118 m_shadow =
"visible";
1119 m_shadow_color = s.attribute(
"color" );
1121 int direction = s.attribute(
"direction" ).toInt();
1122 TQString distance = StyleFactory::toCM( s.attribute(
"distance" ) );
1123 switch ( direction )
1126 m_shadow_offset_x =
"-" + distance;
1127 m_shadow_offset_y =
"-" + distance;
1130 m_shadow_offset_x =
"0cm";
1131 m_shadow_offset_y =
"-" + distance;
1134 m_shadow_offset_x = distance;
1135 m_shadow_offset_y =
"-" + distance;
1138 m_shadow_offset_x = distance;
1139 m_shadow_offset_y =
"0cm";
1142 m_shadow_offset_x = distance;
1143 m_shadow_offset_y = distance;
1146 m_shadow_offset_x =
"0cm";
1147 m_shadow_offset_y = distance;
1150 m_shadow_offset_x =
"-" + distance;
1151 m_shadow_offset_y = distance;
1154 m_shadow_offset_x =
"-" + distance;
1155 m_shadow_offset_y =
"0cm";
1161GraphicStyle::GraphicStyle(
const char * name,
1162 const char * stroke,
const char * stroke_color,
1163 const char * stroke_width,
const char * shadow,
1164 const char * shadow_offset_x,
const char * shadow_offset_y,
1165 const char * shadow_color,
const char * margin_left,
1166 const char * margin_right,
const char * margin_top,
1167 const char * margin_bottom,
const char * color,
1168 const char * text_outline,
const char * text_crossing_out,
1169 const char * font_family,
const char * font_size,
1170 const char * font_style,
const char * text_shadow,
1171 const char * text_underline,
const char * font_weight,
1172 const char * line_height,
const char * text_align,
1173 const char * fill,
const char * fill_color,
1174 const char * enable_numbering )
1176 , m_stroke( stroke )
1177 , m_stroke_color( stroke_color )
1178 , m_stroke_width( stroke_width )
1179 , m_shadow( shadow )
1180 , m_shadow_offset_x( shadow_offset_x )
1181 , m_shadow_offset_y( shadow_offset_y )
1182 , m_shadow_color( shadow_color )
1183 , m_margin_left( margin_left )
1184 , m_margin_right( margin_right )
1185 , m_margin_top( margin_top )
1186 , m_margin_bottom( margin_bottom )
1188 , m_text_outline( text_outline )
1189 , m_text_crossing_out( text_crossing_out )
1190 , m_font_family( font_family )
1191 , m_font_size( font_size )
1192 , m_font_style( font_style )
1193 , m_text_shadow( text_shadow )
1194 , m_text_underline( text_underline )
1195 , m_font_weight( font_weight )
1196 , m_line_height( line_height )
1197 , m_text_align( text_align )
1199 , m_fill_color( fill_color )
1200 , m_enable_numbering( enable_numbering )
1205void GraphicStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
1207 TQDomElement style = doc.createElement(
"style:style" );
1208 style.setAttribute(
"style:name", m_name );
1209 style.setAttribute(
"style:family",
"graphics" );
1210 if ( m_name !=
"standard" )
1211 style.setAttribute(
"style:parent-style-name",
"standard" );
1213 TQDomElement properties = doc.createElement(
"style:properties" );
1214 if ( !m_stroke.isNull() )
1215 properties.setAttribute(
"draw:stroke", m_stroke );
1216 if ( !m_stroke_dash.isNull() )
1217 properties.setAttribute(
"draw:stroke-dash", m_stroke_dash );
1218 if ( !m_stroke_color.isNull() )
1219 properties.setAttribute(
"svg:stroke-color", m_stroke_color );
1220 if ( !m_stroke_width.isNull() )
1221 properties.setAttribute(
"svg:stroke-width", m_stroke_width );
1222 if ( !m_shadow.isNull() )
1223 properties.setAttribute(
"draw:shadow", m_shadow );
1224 if ( !m_shadow_offset_x.isNull() )
1225 properties.setAttribute(
"draw:shadow-offset-x", m_shadow_offset_x );
1226 if ( !m_shadow_offset_y.isNull() )
1227 properties.setAttribute(
"draw:shadow-offset-y", m_shadow_offset_y );
1228 if ( !m_shadow_color.isNull() )
1229 properties.setAttribute(
"draw:shadow-color", m_shadow_color );
1230 if ( !m_margin_left.isNull() )
1231 properties.setAttribute(
"fo:margin-left", m_margin_left );
1232 if ( !m_margin_right.isNull() )
1233 properties.setAttribute(
"fo:margin-right", m_margin_right );
1234 if ( !m_margin_top.isNull() )
1235 properties.setAttribute(
"fo:margin-top", m_margin_top );
1236 if ( !m_margin_bottom.isNull() )
1237 properties.setAttribute(
"fo:margin-bottom", m_margin_bottom );
1238 if ( !m_color.isNull() )
1239 properties.setAttribute(
"fo:color", m_color );
1240 if ( !m_text_outline.isNull() )
1241 properties.setAttribute(
"style:text-outline", m_text_outline );
1242 if ( !m_text_crossing_out.isNull() )
1243 properties.setAttribute(
"style:text-crossing-out", m_text_crossing_out );
1244 if ( !m_font_family.isNull() )
1245 properties.setAttribute(
"fo:font-family", m_font_family );
1246 if ( !m_font_size.isNull() )
1247 properties.setAttribute(
"fo:font-size", m_font_size );
1248 if ( !m_font_style.isNull() )
1249 properties.setAttribute(
"fo:font-style", m_font_style );
1250 if ( !m_text_shadow.isNull() )
1251 properties.setAttribute(
"fo:text-shadow", m_text_shadow );
1252 if ( !m_text_underline.isNull() )
1253 properties.setAttribute(
"style:text-underline", m_text_underline );
1254 if ( !m_font_weight.isNull() )
1255 properties.setAttribute(
"fo:font-weight", m_font_weight );
1256 if ( !m_line_height.isNull() )
1257 properties.setAttribute(
"fo:line-height", m_line_height );
1258 if ( !m_text_align.isNull() )
1259 properties.setAttribute(
"fo:text-align", m_text_align );
1260 if ( !m_fill.isNull() )
1261 properties.setAttribute(
"draw:fill", m_fill );
1262 if ( !m_fill_color.isNull() )
1263 properties.setAttribute(
"draw:fill-color", m_fill_color );
1264 if ( !m_fill_hatch_name.isNull() )
1265 properties.setAttribute(
"draw:fill-hatch-name", m_fill_hatch_name );
1266 if ( !m_enable_numbering.isNull() )
1267 properties.setAttribute(
"text:enable-numbering", m_enable_numbering );
1268 if ( !m_marker_start.isNull() )
1269 properties.setAttribute(
"draw:marker-start", m_marker_start );
1270 if ( !m_marker_start_width.isNull() )
1271 properties.setAttribute(
"draw:marker-start-width", m_marker_start_width );
1272 if ( !m_marker_end.isNull() )
1273 properties.setAttribute(
"draw:marker-end", m_marker_end );
1274 if ( !m_marker_end_width.isNull() )
1275 properties.setAttribute(
"draw:marker-end-width", m_marker_end_width );
1276 if ( !m_fill_gradient_name.isNull() )
1277 properties.setAttribute(
"draw:fill-gradient-name", m_fill_gradient_name );
1278 if ( !m_transparency.isNull() )
1279 properties.setAttribute(
"draw:transparency", m_transparency );
1280 if ( !m_textAlignment.isNull() )
1281 properties.setAttribute(
"draw:textarea-vertical-align", m_textAlignment );
1282 if ( !m_textMarginLeft.isNull() )
1283 properties.setAttribute(
"fo:padding-left", m_textMarginLeft );
1284 if ( !m_textMarginBottom.isNull() )
1285 properties.setAttribute(
"fo:padding-bottom", m_textMarginBottom );
1286 if ( !m_textMarginTop.isNull() )
1287 properties.setAttribute(
"fo:padding-top", m_textMarginTop );
1288 if ( !m_textMarginRight.isNull() )
1289 properties.setAttribute(
"fo:padding-right", m_textMarginRight );
1292 style.appendChild( properties );
1293 e.appendChild( style );
1296bool GraphicStyle::operator==(
const GraphicStyle & graphicStyle )
const
1298 return ( m_stroke == graphicStyle.m_stroke &&
1299 m_stroke_dash == graphicStyle.m_stroke_dash &&
1300 m_stroke_color == graphicStyle.m_stroke_color &&
1301 m_stroke_width == graphicStyle.m_stroke_width &&
1302 m_shadow == graphicStyle.m_shadow &&
1303 m_shadow_offset_x == graphicStyle.m_shadow_offset_x &&
1304 m_shadow_offset_y == graphicStyle.m_shadow_offset_y &&
1305 m_shadow_color == graphicStyle.m_shadow_color &&
1306 m_margin_left == graphicStyle.m_margin_left &&
1307 m_margin_right == graphicStyle.m_margin_right &&
1308 m_margin_top == graphicStyle.m_margin_top &&
1309 m_margin_bottom == graphicStyle.m_margin_bottom &&
1310 m_color == graphicStyle.m_color &&
1311 m_text_outline == graphicStyle.m_text_outline &&
1312 m_text_crossing_out == graphicStyle.m_text_crossing_out &&
1313 m_font_family == graphicStyle.m_font_family &&
1314 m_font_size == graphicStyle.m_font_size &&
1315 m_font_style == graphicStyle.m_font_style &&
1316 m_text_shadow == graphicStyle.m_text_shadow &&
1317 m_text_underline == graphicStyle.m_text_underline &&
1318 m_font_weight == graphicStyle.m_font_weight &&
1319 m_line_height == graphicStyle.m_line_height &&
1320 m_text_align == graphicStyle.m_text_align &&
1321 m_fill == graphicStyle.m_fill &&
1322 m_fill_color == graphicStyle.m_fill_color &&
1323 m_fill_hatch_name == graphicStyle.m_fill_hatch_name &&
1324 m_enable_numbering == graphicStyle.m_enable_numbering &&
1325 m_marker_start == graphicStyle.m_marker_start &&
1326 m_marker_start_width == graphicStyle.m_marker_start_width &&
1327 m_marker_end == graphicStyle.m_marker_end &&
1328 m_marker_end_width == graphicStyle.m_marker_end_width &&
1329 m_fill_gradient_name == graphicStyle.m_fill_gradient_name &&
1330 m_transparency == graphicStyle.m_transparency &&
1331 m_textAlignment == graphicStyle.m_textAlignment &&
1332 m_textMarginLeft == graphicStyle.m_textMarginLeft &&
1333 m_textMarginBottom == graphicStyle.m_textMarginBottom &&
1334 m_textMarginTop == graphicStyle.m_textMarginTop &&
1335 m_textMarginRight == graphicStyle.m_textMarginRight);
1338ParagraphStyle::ParagraphStyle( TQDomElement & e,
const uint index )
1341 m_margin_left =
"0cm";
1342 m_margin_right =
"0cm";
1343 m_text_indent =
"0cm";
1345 TQDomNode shadow = e.namedItem(
"SHADOW" );
1346 TQDomNode indents = e.namedItem(
"INDENTS" );
1347 TQDomNode offsets = e.namedItem(
"OFFSETS" );
1348 TQDomNode leftBorder = e.namedItem(
"LEFTBORDER" );
1349 TQDomNode rightBorder = e.namedItem(
"RIGHTBORDER" );
1350 TQDomNode topBorder = e.namedItem(
"TOPBORDER" );
1351 TQDomNode bottomBorder = e.namedItem(
"BOTTOMBORDER" );
1352 TQDomNode lineSpacing = e.namedItem(
"LINESPACING" );
1353 TQDomNode counter = e.namedItem(
"COUNTER" );
1355 m_name = TQString(
"P%1" ).arg( index );
1356 if ( e.hasAttribute(
"align" ) )
1358 int align = e.attribute(
"align" ).toInt();
1362 m_text_align =
"start";
1365 m_text_align =
"end";
1368 m_text_align =
"center";
1371 m_text_align =
"justify";
1376 if ( !shadow.isNull() )
1378 TQDomElement s = shadow.toElement();
1379 TQString distance = TQString(
"%1pt" ).arg( s.attribute(
"distance" ) );
1380 m_text_shadow = distance +
" " + distance;
1383 if ( !indents.isNull() )
1385 TQDomElement i = indents.toElement();
1386 m_margin_left = StyleFactory::toCM( i.attribute(
"left" ) );
1387 m_margin_right = StyleFactory::toCM( i.attribute(
"right" ) );
1388 m_text_indent = StyleFactory::toCM( i.attribute(
"first" ) );
1391 if ( !offsets.isNull() )
1393 TQDomElement o = offsets.toElement();
1394 m_margin_top = StyleFactory::toCM( o.attribute(
"before" ) );
1395 m_margin_bottom = StyleFactory::toCM( o.attribute(
"after" ) );
1398 if ( !leftBorder.isNull() )
1399 m_border_left = parseBorder( leftBorder.toElement() );
1400 if ( !rightBorder.isNull() )
1401 m_border_right = parseBorder( rightBorder.toElement() );
1402 if ( !topBorder.isNull() )
1403 m_border_top = parseBorder( topBorder.toElement() );
1404 if ( !bottomBorder.isNull() )
1405 m_border_bottom = parseBorder( bottomBorder.toElement() );
1407 if ( !lineSpacing.isNull() )
1409 TQDomElement l = lineSpacing.toElement();
1410 TQString type = l.attribute(
"type" );
1412 if ( type ==
"single" )
1413 m_line_height =
"100%";
1414 else if ( type ==
"oneandhalf" )
1415 m_line_height =
"150%";
1416 else if ( type ==
"double" )
1417 m_line_height =
"200%";
1418 else if ( type ==
"multiple" )
1419 m_line_height = TQString(
"%1%" ).arg( l.attribute(
"spacingvalue" ).toInt() * 100 );
1420 else if ( type ==
"custom" )
1421 m_line_spacing = StyleFactory::toCM( l.attribute(
"spacingvalue" ) );
1422 else if ( type ==
"atleast" )
1423 m_line_height_at_least = StyleFactory::toCM( l.attribute(
"spacingvalue" ) );
1426 if ( !counter.isNull() )
1427 m_enable_numbering =
"true";
1430void ParagraphStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
1432 TQDomElement style = doc.createElement(
"style:style" );
1433 style.setAttribute(
"style:name", m_name );
1434 style.setAttribute(
"style:family",
"paragraph" );
1436 TQDomElement properties = doc.createElement(
"style:properties" );
1437 if ( !m_margin_left.isNull() )
1438 properties.setAttribute(
"fo:margin-left", m_margin_left );
1439 if ( !m_margin_right.isNull() )
1440 properties.setAttribute(
"fo:margin-right", m_margin_right );
1441 if ( !m_text_indent.isNull() )
1442 properties.setAttribute(
"fo:text-indent", m_text_indent );
1443 if ( !m_text_align.isNull() )
1444 properties.setAttribute(
"fo:text-align", m_text_align );
1445 if ( !m_enable_numbering.isNull() )
1446 properties.setAttribute(
"text:enable-numbering", m_enable_numbering );
1447 if ( !m_text_shadow.isNull() )
1448 properties.setAttribute(
"fo:text-shadow", m_text_shadow );
1449 if ( !m_margin_top.isNull() )
1450 properties.setAttribute(
"fo:margin-top", m_margin_top );
1451 if ( !m_margin_bottom.isNull() )
1452 properties.setAttribute(
"fo:margin-bottom", m_margin_bottom );
1453 if ( !m_border_left.isNull() )
1454 properties.setAttribute(
"fo:border-left", m_border_left );
1455 if ( !m_border_right.isNull() )
1456 properties.setAttribute(
"fo:border-right", m_border_right );
1457 if ( !m_border_top.isNull() )
1458 properties.setAttribute(
"fo:border-top", m_border_top );
1459 if ( !m_border_bottom.isNull() )
1460 properties.setAttribute(
"fo:border-bottom", m_border_bottom );
1461 if ( !m_line_height.isNull() )
1462 properties.setAttribute(
"fo:line-height", m_line_height );
1463 if ( !m_line_height_at_least.isNull() )
1464 properties.setAttribute(
"style:line-height-at-least", m_line_height_at_least );
1465 if ( !m_line_spacing.isNull() )
1466 properties.setAttribute(
"style:line-spacing", m_line_spacing );
1468 style.appendChild( properties );
1469 e.appendChild( style );
1472bool ParagraphStyle::operator==(
const ParagraphStyle & paragraphStyle )
const
1474 return ( m_margin_left == paragraphStyle.m_margin_left &&
1475 m_margin_right == paragraphStyle.m_margin_right &&
1476 m_text_indent == paragraphStyle.m_text_indent &&
1477 m_text_align == paragraphStyle.m_text_align &&
1478 m_enable_numbering == paragraphStyle.m_enable_numbering &&
1479 m_text_shadow == paragraphStyle.m_text_shadow &&
1480 m_margin_top == paragraphStyle.m_margin_top &&
1481 m_margin_bottom == paragraphStyle.m_margin_bottom &&
1482 m_border_left == paragraphStyle.m_border_left &&
1483 m_border_right == paragraphStyle.m_border_right &&
1484 m_border_top == paragraphStyle.m_border_top &&
1485 m_border_bottom == paragraphStyle.m_border_bottom &&
1486 m_line_height == paragraphStyle.m_line_height &&
1487 m_line_height_at_least == paragraphStyle.m_line_height_at_least &&
1488 m_line_spacing == paragraphStyle.m_line_spacing );
1491TQString ParagraphStyle::parseBorder( TQDomElement e )
1494 int _style = e.attribute(
"style" ).toInt();
1500 TQString width = StyleFactory::toCM( e.attribute(
"width" ) );
1502 TQColor color( e.attribute(
"red" ).toInt(),
1503 e.attribute(
"green" ).toInt(),
1504 e.attribute(
"blue" ).toInt() );
1506 return TQString(
"%1 %2 %3" ).arg( width ).arg( style ).arg( color.name() );
1509ListStyle::ListStyle( TQDomElement & e,
const uint index )
1512 m_min_label_width = 0.6;
1513 m_color =
"#000000";
1514 m_font_size =
"100%";
1516 m_name = TQString(
"L%1" ).arg( index );
1518 if ( e.hasAttribute(
"type" ) )
1520 int type = e.attribute(
"type" ).toInt();
1524 m_listLevelStyle = LLS_NUMBER;
1529 m_listLevelStyle = LLS_NUMBER;
1534 m_listLevelStyle = LLS_NUMBER;
1539 m_listLevelStyle = LLS_NUMBER;
1544 m_listLevelStyle = LLS_NUMBER;
1549 m_listLevelStyle = LLS_BULLET;
1550 if ( e.hasAttribute(
"text" ) )
1551 m_bullet_char = e.attribute(
"text" );
1554 m_listLevelStyle = LLS_BULLET;
1557 m_listLevelStyle = LLS_BULLET;
1560 m_listLevelStyle = LLS_BULLET;
1563 m_listLevelStyle = LLS_BULLET;
1568 if ( e.hasAttribute(
"bulletfont" ) )
1569 m_font_family = e.attribute(
"bulletfont" );
1572void ListStyle::toXML( TQDomDocument & doc, TQDomElement & e )
const
1574 TQDomElement style = doc.createElement(
"text:list-style" );
1575 style.setAttribute(
"style:name", m_name );
1577 for (
int level = 1; level <= 10; level++ )
1579 TQDomElement listLevelStyle;
1580 if ( m_listLevelStyle == LLS_NUMBER )
1582 listLevelStyle = doc.createElement(
"text:list-level-style-number" );
1583 listLevelStyle.setAttribute(
"text:level", level );
1584 if ( !m_num_suffix.isNull() )
1585 listLevelStyle.setAttribute(
"style:num-suffix", m_num_suffix );
1586 if ( !m_num_format.isNull() )
1587 listLevelStyle.setAttribute(
"style:num-format", m_num_format );
1591 listLevelStyle = doc.createElement(
"text:list-level-style-bullet" );
1592 listLevelStyle.setAttribute(
"text:level", level );
1593 if ( !m_bullet_char.isNull() )
1594 listLevelStyle.setAttribute(
"text:bullet-char", m_bullet_char );
1597 TQDomElement properties = doc.createElement(
"style:properties" );
1600 properties.setAttribute(
"text:min-label-width",
1601 TQString(
"%1cm" ).arg( m_min_label_width ) );
1602 properties.setAttribute(
"text:space-before",
1603 TQString(
"%1cm" ).arg( m_min_label_width * ( level - 1 ) ) );
1606 if ( !m_color.isNull() )
1607 properties.setAttribute(
"fo:color", m_color );
1608 if ( !m_font_size.isNull() )
1609 properties.setAttribute(
"fo:font-size", m_font_size );
1610 if ( !m_font_family.isNull() )
1611 properties.setAttribute(
"fo:font-family", m_font_family );
1613 listLevelStyle.appendChild( properties );
1614 style.appendChild( listLevelStyle );
1616 e.appendChild( style );
1619bool ListStyle::operator==(
const ListStyle & listStyle )
const
1621 return ( m_listLevelStyle == listStyle.m_listLevelStyle &&
1622 m_num_suffix == listStyle.m_num_suffix &&
1623 m_num_format == listStyle.m_num_format &&
1624 m_bullet_char == listStyle.m_bullet_char &&
1625 m_min_label_width == listStyle.m_min_label_width &&
1626 m_color == listStyle.m_color &&
1627 m_font_size == listStyle.m_font_size &&
1628 m_font_family == listStyle.m_font_family );