diff options
Diffstat (limited to 'quanta/components/csseditor/shorthandformer.cpp')
-rw-r--r-- | quanta/components/csseditor/shorthandformer.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/quanta/components/csseditor/shorthandformer.cpp b/quanta/components/csseditor/shorthandformer.cpp index e8b7a837..08acc819 100644 --- a/quanta/components/csseditor/shorthandformer.cpp +++ b/quanta/components/csseditor/shorthandformer.cpp @@ -18,38 +18,38 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "shorthandformer.h" -#include <qstringlist.h> +#include <tqstringlist.h> #include "cssshpropertyparser.h" #include <kdebug.h> #include "csseditor_globals.h" -QRegExp globalPercentagePattern("\\d%"), +TQRegExp globalPercentagePattern("\\d%"), globalLengthPattern("\\d(ex|em|px|cm|pt|pc|in|mm)"), globalColorPattern("#[\\w\\d]*"), globalNumberPattern("\\d*"); -static const QString borderStyleValueString("none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"); -static const QString widthValueString("thin,medium,thick,inherit"); -static const QString listTypeValueString("disc,circle,square,decimal,decimal-leading-zero,lower-roman,upper-roman,lower-greek,lower-alpha,lower-latin,upper-alpha,upper-latin,hebrew,armenian,georgian,cjk-ideographic,hiragana,katakana,hiragana-iroha,katakana-iroha,none,inherit"); -static const QString fontSizeValueString("smaller,larger,xx-large,x-large,large,medium,small,x-small,xx-small,inherit"); -static const QString fontWeightValueString("900,800,700,600,500,400,300,200,100,lighter,bolder,normal,bold,inherit"); -static const QString fontVariantValueString("normal,small-caps,inherit"); -static const QString fontStyleValueString("oblique,italic,normal,inherit"); -static const QString backgroundRepeatValueString("repeat,repeat-x,repeat-y,no-repeat,inherit"); +static const TQString borderStyleValueString("none,hidden,dotted,dashed,solid,double,groove,ridge,inset,outset,inherit"); +static const TQString widthValueString("thin,medium,thick,inherit"); +static const TQString listTypeValueString("disc,circle,square,decimal,decimal-leading-zero,lower-roman,upper-roman,lower-greek,lower-alpha,lower-latin,upper-alpha,upper-latin,hebrew,armenian,georgian,cjk-ideographic,hiragana,katakana,hiragana-iroha,katakana-iroha,none,inherit"); +static const TQString fontSizeValueString("smaller,larger,xx-large,x-large,large,medium,small,x-small,xx-small,inherit"); +static const TQString fontWeightValueString("900,800,700,600,500,400,300,200,100,lighter,bolder,normal,bold,inherit"); +static const TQString fontVariantValueString("normal,small-caps,inherit"); +static const TQString fontStyleValueString("oblique,italic,normal,inherit"); +static const TQString backgroundRepeatValueString("repeat,repeat-x,repeat-y,no-repeat,inherit"); -static const QStringList borderStyleValueList = QStringList::split(",",borderStyleValueString); -static const QStringList widthValueList = QStringList::split(",",widthValueString); -static const QStringList listTypeValueList = QStringList::split(",",listTypeValueString); -static const QStringList fontSizeValueList = QStringList::split(",",fontSizeValueString); -static const QStringList fontWeightValueList = QStringList::split(",",fontWeightValueString); -static const QStringList fontStyleValueList = QStringList::split(",",fontStyleValueString); -static const QStringList fontVariantValueList = QStringList::split(",",fontVariantValueString); -static const QStringList backgroundRepeatValueList = QStringList::split(",",backgroundRepeatValueString); +static const TQStringList borderStyleValueList = TQStringList::split(",",borderStyleValueString); +static const TQStringList widthValueList = TQStringList::split(",",widthValueString); +static const TQStringList listTypeValueList = TQStringList::split(",",listTypeValueString); +static const TQStringList fontSizeValueList = TQStringList::split(",",fontSizeValueString); +static const TQStringList fontWeightValueList = TQStringList::split(",",fontWeightValueString); +static const TQStringList fontStyleValueList = TQStringList::split(",",fontStyleValueString); +static const TQStringList fontVariantValueList = TQStringList::split(",",fontVariantValueString); +static const TQStringList backgroundRepeatValueList = TQStringList::split(",",backgroundRepeatValueString); -ShorthandFormer::ShorthandFormer( QMap<QString,QString> m){ +ShorthandFormer::ShorthandFormer( TQMap<TQString,TQString> m){ m_properties = m; if(m_properties.contains("cue-after")){ @@ -218,8 +218,8 @@ ShorthandFormer::ShorthandFormer( QMap<QString,QString> m){ } } -QString ShorthandFormer::compress(){ - QString props; +TQString ShorthandFormer::compress(){ + TQString props; props += compressCueProp(); props += compressPauseProp(); @@ -231,7 +231,7 @@ QString ShorthandFormer::compress(){ props += compressListStyleProp(); props += compressBorderProp(); - QMap<QString,QString>::Iterator it; + TQMap<TQString,TQString>::Iterator it; for ( it = m_properties.begin(); it != m_properties.end(); ++it ) props += it.key() + " : " + it.data().stripWhiteSpace() + "; " ; @@ -240,8 +240,8 @@ QString ShorthandFormer::compress(){ return props; } -QString ShorthandFormer::compressBorderProp(){ - QString props; +TQString ShorthandFormer::compressBorderProp(){ + TQString props; bool allColorSidesSet = false, allStyleSidesSet = false, @@ -306,17 +306,17 @@ QString ShorthandFormer::compressBorderProp(){ return props; } -QString ShorthandFormer::compressBorderStyleProp(){ +TQString ShorthandFormer::compressBorderStyleProp(){ return compressImplementation( "border-style" ,border_top_style, border_bottom_style, border_right_style, border_left_style, "none"); } -QString ShorthandFormer::compressBorderWidthProp(){ +TQString ShorthandFormer::compressBorderWidthProp(){ return compressImplementation( "border-width" ,border_top_width, border_bottom_width, border_right_width, border_left_width, "medium"); } -QString ShorthandFormer::compressBorderColorProp(){ +TQString ShorthandFormer::compressBorderColorProp(){ //because the default value of color property is browser dependant, this method doesn't compress the color value - QString props; + TQString props; if( !border_top_color.isEmpty() ) props += "border-top-color : " + border_top_color +"; "; if( !border_right_color.isEmpty() ) @@ -328,8 +328,8 @@ QString ShorthandFormer::compressBorderColorProp(){ return props; } -QString ShorthandFormer::compressFontProp(){ - QString fontProp, +TQString ShorthandFormer::compressFontProp(){ + TQString fontProp, props; //bool appendLineHeight = false; @@ -368,51 +368,51 @@ QString ShorthandFormer::compressFontProp(){ return props; } -QString ShorthandFormer::compressCueProp(){ +TQString ShorthandFormer::compressCueProp(){ return compressImplementation2( "cue", cue_after, cue_before, "none"); } -QString ShorthandFormer::compressPauseProp(){ +TQString ShorthandFormer::compressPauseProp(){ return compressImplementation2( "pause", pause_after, pause_before, "0"); } -QString ShorthandFormer::compressBackgroundProp(){ - QString backgroundProp; +TQString ShorthandFormer::compressBackgroundProp(){ + TQString backgroundProp; if( !background_color.isEmpty() ) backgroundProp += (" " + background_color ); if( !background_image.isEmpty() ) backgroundProp += (" " + background_image ); if( !background_repeat.isEmpty() ) backgroundProp += (" " + background_repeat ); if( !background_attachment.isEmpty() ) backgroundProp += (" " + background_attachment ); if( !background_position.isEmpty() ) backgroundProp += (" " + background_position ); if( !backgroundProp.isEmpty() ) return ( "background :" + backgroundProp + "; "); - return QString::null; + return TQString::null; } -QString ShorthandFormer::compressPaddingProp(){ +TQString ShorthandFormer::compressPaddingProp(){ return compressImplementation( "padding" ,padding_top, padding_bottom, padding_right, padding_left, "0"); } -QString ShorthandFormer::compressMarginProp(){ +TQString ShorthandFormer::compressMarginProp(){ return compressImplementation( "margin" ,margin_top, margin_bottom, margin_right, margin_left, "0"); } -QString ShorthandFormer::compressOutlineProp(){ +TQString ShorthandFormer::compressOutlineProp(){ return compressImplementation3("outline", outline_color, outline_style, outline_width); } -QString ShorthandFormer::compressListStyleProp(){ +TQString ShorthandFormer::compressListStyleProp(){ return compressImplementation3("list-style", list_style_type, list_style_image, list_style_position); } -QString ShorthandFormer::compressImplementation3( const QString& prop, const QString& p1, const QString& p2, const QString& p3){ - QString props; +TQString ShorthandFormer::compressImplementation3( const TQString& prop, const TQString& p1, const TQString& p2, const TQString& p3){ + TQString props; if( !p1.isEmpty() ) props += (" " + p1 ); if( !p2.isEmpty() ) props += (" " + p2 ); if( !p3.isEmpty() ) props += (" " + p3 ); if( !props.isEmpty() ) return ( prop + " :" + props + "; "); - return QString::null; + return TQString::null; } -QString ShorthandFormer::compressImplementation2( const QString& prop, const QString& after, const QString& before, const QString& defValue){ - QString props; +TQString ShorthandFormer::compressImplementation2( const TQString& prop, const TQString& after, const TQString& before, const TQString& defValue){ + TQString props; if(after == before){ if(!after.isEmpty()) props+=( prop + " : " + after + "; "); } @@ -425,9 +425,9 @@ QString ShorthandFormer::compressImplementation2( const QString& prop, const QSt return props; } -QString ShorthandFormer::compressImplementation( const QString& prop, const QString& t, const QString& b, const QString& r, const QString& l, const QString& defValue){ +TQString ShorthandFormer::compressImplementation( const TQString& prop, const TQString& t, const TQString& b, const TQString& r, const TQString& l, const TQString& defValue){ - QString props, + TQString props, top(t.stripWhiteSpace()), bottom(b.stripWhiteSpace()), left(l.stripWhiteSpace()), @@ -440,7 +440,7 @@ QString ShorthandFormer::compressImplementation( const QString& prop, const QStr if( top == defValue && bottom == defValue && right == defValue && left == defValue) - return QString::null; + return TQString::null; if( top == bottom && bottom == right && right == left ) return ( prop +" : " + top + "; "); @@ -456,9 +456,9 @@ QString ShorthandFormer::compressImplementation( const QString& prop, const QStr //+++++++++++++++++++++EXPANDING METHODS+++++++++++++++++++++++++++++++++++ -QMap<QString,QString> ShorthandFormer::expand( const QString& propertyName, const QString& propertyValue ){ +TQMap<TQString,TQString> ShorthandFormer::expand( const TQString& propertyName, const TQString& propertyValue ){ CSSSHPropertyParser parser(propertyValue); - QStringList foundValues = parser.parse(); + TQStringList foundValues = parser.parse(); if( propertyName == "cue" ) return expandCueProp(foundValues); if( propertyName == "pause") return expandPauseProp(foundValues); @@ -476,19 +476,19 @@ QMap<QString,QString> ShorthandFormer::expand( const QString& propertyName, cons if( propertyName == "border") return expandBorderProp(foundValues); if( propertyName == "padding") return expandPaddingProp(foundValues); if( propertyName == "margin") return expandMarginProp(foundValues); - return QMap<QString,QString>();//dummy instruction avoiding a pedantic warning; can never be reached + return TQMap<TQString,TQString>();//dummy instruction avoiding a pedantic warning; can never be reached } -QMap<QString,QString> ShorthandFormer::expandCueProp(const QStringList& l){ +TQMap<TQString,TQString> ShorthandFormer::expandCueProp(const TQStringList& l){ return expandImplementation("cue",l); } -QMap<QString,QString> ShorthandFormer::expandPauseProp(const QStringList& l){ +TQMap<TQString,TQString> ShorthandFormer::expandPauseProp(const TQStringList& l){ return expandImplementation("pause",l); } -QMap<QString,QString> ShorthandFormer::expandImplementation(const QString& propertyName, const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandImplementation(const TQString& propertyName, const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; if( l.count()==1) { expandedProps[propertyName + "-before"] = l[0] ; expandedProps[propertyName + "-after"] = l[0] ; @@ -502,8 +502,8 @@ QMap<QString,QString> ShorthandFormer::expandImplementation(const QString& prop } } -QMap<QString,QString> ShorthandFormer::expandBackgroundProp(const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandBackgroundProp(const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; if(l.count()==1 && l[0] == "inherit"){ // it works also as protection against wrong single value inserted expandedProps["background-color"] = l[0]; expandedProps["background-image"] = l[0]; @@ -513,10 +513,10 @@ QMap<QString,QString> ShorthandFormer::expandBackgroundProp(const QStringList& } else { - QStringList::ConstIterator it = l.begin(); + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString temp((*it).stripWhiteSpace()); + TQString temp((*it).stripWhiteSpace()); if( (*it).contains("url(") || temp == "none" || temp == "inherit" ){ expandedProps["background-image"] = (*it); } @@ -546,9 +546,9 @@ QMap<QString,QString> ShorthandFormer::expandBackgroundProp(const QStringList& return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandBox(const QString& subPropName, const QStringList& l){ +TQMap<TQString,TQString> ShorthandFormer::expandBox(const TQString& subPropName, const TQStringList& l){ - QMap<QString,QString> expandedProps; + TQMap<TQString,TQString> expandedProps; expandedProps["border-top-" + subPropName] = l[0]; switch(l.count()){ case 1 : @@ -576,14 +576,14 @@ QMap<QString,QString> ShorthandFormer::expandBox(const QString& subPropName, co return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandFontProp(const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandFontProp(const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; - QRegExp percentagePattern("/"+globalPercentagePattern.pattern()), + TQRegExp percentagePattern("/"+globalPercentagePattern.pattern()), lengthPattern("/"+globalLengthPattern.pattern()), numberPattern("/"+globalNumberPattern.pattern()); - QStringList fontPseudoSHFormValues; + TQStringList fontPseudoSHFormValues; fontPseudoSHFormValues.append("caption"); fontPseudoSHFormValues.append("icon"); fontPseudoSHFormValues.append("menu"); @@ -595,10 +595,10 @@ QMap<QString,QString> ShorthandFormer::expandFontProp(const QStringList& l){ return expandedProps; } else { - QStringList::ConstIterator it = l.begin(); + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString currentIt = (*it); - QString temp(currentIt.stripWhiteSpace()); + TQString currentIt = (*it); + TQString temp(currentIt.stripWhiteSpace()); if( fontStyleValueList.contains(temp)!=0 ) expandedProps["font-style"] = (*it); else if( fontVariantValueList.contains(temp)!=0 ) expandedProps["font-variant"] = currentIt ; @@ -621,8 +621,8 @@ QMap<QString,QString> ShorthandFormer::expandFontProp(const QStringList& l){ } } -QMap<QString,QString> ShorthandFormer::expandListstyleProp( const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandListstyleProp( const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; if( (l.count() == 1) && (l[0] == "inherit")){ expandedProps["list-style-image"] ="inherit"; expandedProps["list-style-type"] ="inherit"; @@ -637,9 +637,9 @@ QMap<QString,QString> ShorthandFormer::expandListstyleProp( const QStringList& l } - QStringList::ConstIterator it = l.begin(); + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString temp((*it).stripWhiteSpace()); + TQString temp((*it).stripWhiteSpace()); if( listTypeValueList.contains(temp)!=0) { expandedProps["list-style-type"] = (*it) ; } @@ -656,11 +656,11 @@ QMap<QString,QString> ShorthandFormer::expandListstyleProp( const QStringList& l return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandOutlineProp( const QStringList& l){ - QMap<QString,QString> expandedProps; - QStringList::ConstIterator it = l.begin(); +TQMap<TQString,TQString> ShorthandFormer::expandOutlineProp( const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString temp((*it).stripWhiteSpace()); + TQString temp((*it).stripWhiteSpace()); if( borderStyleValueList.contains(temp)!=0 ) expandedProps["outline-style"] = (*it); else if( (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "invert" || temp == "inherit") @@ -673,12 +673,12 @@ QMap<QString,QString> ShorthandFormer::expandOutlineProp( const QStringList& l) return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandBoxSide(const QString& subPropName, const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandBoxSide(const TQString& subPropName, const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; - QStringList::ConstIterator it = l.begin(); + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString temp((*it).stripWhiteSpace()); + TQString temp((*it).stripWhiteSpace()); if( borderStyleValueList.contains(temp)!=0 ) expandedProps[subPropName + "-style"] = (*it); else if( (*it).contains(globalColorPattern) || CSSEditorGlobals::HTMLColors.contains((*it))!=0 || temp == "transparent" || temp == "inherit") @@ -691,11 +691,11 @@ QMap<QString,QString> ShorthandFormer::expandBoxSide(const QString& subPropName return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandBorderProp(const QStringList& l){ - QMap<QString,QString> expandedProps; - QStringList::ConstIterator it = l.begin(); +TQMap<TQString,TQString> ShorthandFormer::expandBorderProp(const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; + TQStringList::ConstIterator it = l.begin(); while ( it != l.end() ) { - QString temp((*it).stripWhiteSpace()); + TQString temp((*it).stripWhiteSpace()); if( borderStyleValueList.contains(temp)!=0 ){ expandedProps["border-top-style"] = (*it); expandedProps["border-left-style"] = (*it); @@ -721,8 +721,8 @@ QMap<QString,QString> ShorthandFormer::expandBorderProp(const QStringList& l){ return expandedProps; } -QMap<QString,QString> ShorthandFormer::expandImplementation2(const QString& propertyName, const QStringList& l){ - QMap<QString,QString> expandedProps; +TQMap<TQString,TQString> ShorthandFormer::expandImplementation2(const TQString& propertyName, const TQStringList& l){ + TQMap<TQString,TQString> expandedProps; expandedProps[ propertyName + "-top" ] = l[0]; switch(l.count()){ case 1 : @@ -750,16 +750,16 @@ QMap<QString,QString> ShorthandFormer::expandImplementation2(const QString& prop return expandedProps; } - QMap<QString,QString> ShorthandFormer::expandPaddingProp(const QStringList& l){ + TQMap<TQString,TQString> ShorthandFormer::expandPaddingProp(const TQStringList& l){ return expandImplementation2("padding", l); } - QMap<QString,QString> ShorthandFormer::expandMarginProp(const QStringList& l){ + TQMap<TQString,TQString> ShorthandFormer::expandMarginProp(const TQStringList& l){ return expandImplementation2("margin", l); } -QStringList ShorthandFormer::SHFormList() { - QStringList l; +TQStringList ShorthandFormer::SHFormList() { + TQStringList l; l.append("cue"); l.append("pause"); l.append("font"); |