19#include "KoParagStyle.h"
20#include "KoOasisContext.h"
21#include "KoParagCounter.h"
23#include <KoGenStyles.h>
24#include <KoXmlWriter.h>
52 m_followingStyle =
this;
55 m_paragLayout.style =
this;
57 m_inheritedParagLayoutFlag = 0;
58 m_inheritedFormatFlag = 0;
68KoParagStyle::~KoParagStyle()
74 KoCharStyle::operator=( rhs );
75 m_paragLayout = rhs.m_paragLayout;
76 m_followingStyle = rhs.m_followingStyle;
77 m_paragLayout.style =
this;
78 m_parentStyle = rhs.m_parentStyle;
79 m_inheritedParagLayoutFlag = rhs.m_inheritedParagLayoutFlag;
80 m_inheritedFormatFlag = rhs.m_inheritedFormatFlag;
81 m_bOutline = rhs.m_bOutline;
86 m_followingStyle = fst;
91 m_paragLayout.saveParagLayout( parentElem, m_paragLayout.alignment );
93 if ( followingStyle() )
95 TQDomElement element = parentElem.ownerDocument().createElement(
"FOLLOWING" );
96 parentElem.appendChild( element );
97 element.setAttribute(
"name", followingStyle()->
displayName() );
101 parentElem.setAttribute(
"outline", m_bOutline ?
"true" :
"false" );
111 m_paragLayout = layout;
114 TQDomElement nameElem = parentElem.namedItem(
"NAME").toElement();
115 if ( !nameElem.isNull() ) {
116 m_name = nameElem.attribute(
"value");
117 m_displayName = i18n(
"Style name", m_name.utf8() );
119 kdWarning() <<
"No NAME tag in LAYOUT -> no name for this style!" << endl;
123 m_bOutline = parentElem.attribute(
"outline" ) ==
"true";
129 m_name = styleElem.attributeNS( KoXmlNS::style,
"name", TQString() );
130 m_displayName = styleElem.attributeNS( KoXmlNS::style,
"display-name", TQString() );
131 if ( m_displayName.isEmpty() )
132 m_displayName = m_name;
137 m_bOutline = styleElem.hasAttributeNS( KoXmlNS::style,
"default-outline-level" );
139 context.styleStack().save();
140 context.addStyles( &styleElem,
"paragraph" );
147 const TQString listStyleName = styleElem.attributeNS( KoXmlNS::style,
"list-style-name", TQString() );
149 level = styleElem.attributeNS( KoXmlNS::style,
"default-outline-level", TQString() ).toInt();
150 listOK = context.pushOutlineListLevelStyle( level );
152 if ( !listStyleName.isEmpty() )
153 context.pushListLevelStyle( listStyleName, level );
166 level = styleElem.attributeNS( KoXmlNS::style,
"default-level",
"1" ).toInt();
167 listOK = !listStyleName.isEmpty();
169 listOK = context.pushListLevelStyle( listStyleName, level );
172 const TQDomElement listStyle = context.listStyleStack().currentListStyle();
174 const bool ordered = listStyle.localName() ==
"list-level-style-number";
178 context.listStyleStack().pop();
183 m_paragLayout = layout;
185 m_format.load( context );
187 context.styleStack().restore();
192 KoGenStyle gs( styleType,
"paragraph", parentStyleName );
195 if ( m_paragLayout.counter ) {
197 gs.
addAttribute(
"style:default-outline-level", (
int)m_paragLayout.counter->depth() + 1 );
198 else if ( m_paragLayout.counter->depth() )
200 gs.
addAttribute(
"style:default-level", (
int)m_paragLayout.counter->depth() + 1 );
202 if ( m_paragLayout.counter->numbering() != KoParagCounter::NUM_NONE &&
203 m_paragLayout.counter->style() != KoParagCounter::STYLE_NONE )
205 KoGenStyle listStyle( KoGenStyle::STYLE_LIST );
206 m_paragLayout.counter->saveOasis( listStyle,
true );
210 i18n(
"Numbering Style for %1" ).arg( m_displayName ) );
212 TQString autoListStyleName = genStyles.
lookup( listStyle,
"L", KoGenStyles::ForceNumbering );
213 gs.
addAttribute(
"style:list-style-name", autoListStyleName );
217 m_paragLayout.saveOasis( gs, context,
true );
219 m_format.save( gs, context );
223 bool nameIsConform = !m_name.isEmpty() && m_name.find(
' ' ) == -1;
226 newName = genStyles.
lookup( gs, m_name, KoGenStyles::DontForceNumbering );
228 newName = genStyles.
lookup( gs,
"U", KoGenStyles::ForceNumbering );
235 return m_paragLayout;
240 return m_paragLayout;
243void KoParagStyle::propagateChanges(
int paragLayoutFlag,
int )
245 if ( !m_parentStyle )
247 if ( !(paragLayoutFlag & KoParagLayout::Alignment) )
248 m_paragLayout.
alignment = m_parentStyle->paragLayout().alignment;
249 if ( !(paragLayoutFlag & KoParagLayout::Margins) )
250 for (
int i = 0 ; i < 5 ; ++i )
251 m_paragLayout.margins[i] = m_parentStyle->paragLayout().margins[i];
252 if ( !(paragLayoutFlag & KoParagLayout::LineSpacing) )
254 m_paragLayout.setLineSpacingValue(m_parentStyle->paragLayout().lineSpacingValue());
255 m_paragLayout.lineSpacingType = m_parentStyle->paragLayout().lineSpacingType;
257 if ( !(paragLayoutFlag & KoParagLayout::Borders) )
259 m_paragLayout.leftBorder = m_parentStyle->paragLayout().leftBorder;
260 m_paragLayout.rightBorder = m_parentStyle->paragLayout().rightBorder;
261 m_paragLayout.topBorder = m_parentStyle->paragLayout().topBorder;
262 m_paragLayout.bottomBorder = m_parentStyle->paragLayout().bottomBorder;
263 m_paragLayout.joinBorder = m_parentStyle->paragLayout().joinBorder;
265 if ( !(paragLayoutFlag & KoParagLayout::BulletNumber) )
266 m_paragLayout.counter = m_parentStyle->paragLayout().counter;
267 if ( !(paragLayoutFlag & KoParagLayout::Tabulator) )
268 m_paragLayout.setTabList(m_parentStyle->paragLayout().tabList());
270 if ( paragLayoutFlag == KoParagLayout::All )
272 setDirection(
static_cast<TQChar::Direction
>(layout.direction) );
274 setStyle( layout.style );
281void KoParagStyle::setOutline(
bool b )
KoCharStyle(const TQString &name)
Create a blank style (with default attributes).
const KoTextFormat & format() const
Return a format.
void addAttribute(const TQString &attrName, const TQString &attrValue)
Add an attribute to the style The difference between property and attributes is a bit oasis-format-sp...
Repository of styles used during saving of OASIS/OOo file.
TQString lookup(const KoGenStyle &style, const TQString &name=TQString(), int flags=NoFlag)
Look up a style in the collection, inserting it if necessary.
Used during loading of Oasis format (and discarded at the end of the loading).
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
void loadOasis(KoOasisContext &context, int restartNumbering, bool orderedList, bool heading, int level, bool loadingStyle=false)
Load from OASIS XML.
This class holds the paragraph-specific formatting information It's separated from KoTextParag so tha...
static void loadOasisParagLayout(KoParagLayout &layout, KoOasisContext &context)
Load this parag layout from Oasis XML.
static void loadParagLayout(KoParagLayout &layout, const TQDomElement &parentElem, int docVersion=2)
Load this parag layout from XML.
KoParagCounter * counter
can be 0 if no counter set
char alignment
Alignment flag (AlignAuto/AlignLeft/AlignRight/AlignJustify).
A paragraph style is a combination of a character style and paragraph-layout attributes,...
void saveStyle(TQDomElement &parentElem)
Saves the name, layout, the following style and the outline bool.
KoParagStyle(const TQString &name)
Create a blank style (with default attributes).
void loadStyle(TQDomElement &parentElem, int docVersion=2)
Loads the name, layout and the outline bool.
Used during saving to Oasis format (and discarded at the end of the saving).
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
TQString displayName() const
The user-visible name (e.g. translated, or set by the user).
TQString name() const
The internal name (used for loading/saving, but not shown to the user) Should be unique in a given st...