From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../components/csseditor/cssshpropertyparser.cpp | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 quanta/components/csseditor/cssshpropertyparser.cpp (limited to 'quanta/components/csseditor/cssshpropertyparser.cpp') diff --git a/quanta/components/csseditor/cssshpropertyparser.cpp b/quanta/components/csseditor/cssshpropertyparser.cpp new file mode 100644 index 00000000..d02c39a5 --- /dev/null +++ b/quanta/components/csseditor/cssshpropertyparser.cpp @@ -0,0 +1,127 @@ +/*************************************************************************** + * Copyright (C) 2003 by Gulmini Luciano * + * gulmini.luciano@student.unife.it * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#include "cssshpropertyparser.h" +#include +//#include + +CSSSHPropertyParser::CSSSHPropertyParser(const QString& s){ + QStringList l1, + l2=QStringList::split(",",s); + + for ( QStringList::Iterator it = l2.begin(); it != l2.end(); ++it ) { + QString temp; + temp=removeBeginningWhiteSpaces((*it)); + temp=removeEndingWhiteSpaces(temp); + l1.append(temp); + } + + m_propertyToParse = l1.join(",");// we eliminte blanks before after a comma in things like "something" , something , serif +} + +CSSSHPropertyParser::~CSSSHPropertyParser(){} + +QString CSSSHPropertyParser::removeEndingWhiteSpaces(const QString& s){ + int index = s.length()-1; + while(s[index] == ' ' ) index--; + return s.left(index+1); +} + +QString CSSSHPropertyParser::removeBeginningWhiteSpaces(const QString& s){ + int index = 0; + while(s[index] == ' ' ) index++; + return s.right(s.length()-index); +} + +QString CSSSHPropertyParser::extractFunctionList(){ + QRegExp functionListPattern("\\s*([a-zA-Z0-9_]*\\([\\W\\w]*\\))\\s*"); + functionListPattern.search(m_propertyToParse); + return functionListPattern.cap(1); +} + +QString CSSSHPropertyParser::extractQuotedStringList(){ + QString temp; + bool stop = false; + unsigned int i=0; + while(!stop && i