Commit 5ff6f8a9 authored by Cyrille Berger's avatar Cyrille Berger

start a parser of color space xml

svn path=/trunk/koffice/; revision=951676
parent 9126f0bf
......@@ -10,6 +10,8 @@ set( CTLCS_SRCS
KoCtlColorProfile.cpp
KoCtlColorConversionTransformation.cpp
KoCtlColorSpace.cpp
KoCtlColorSpaceInfo.cpp
KoCtlParser.cpp
ctl_cs_plugin.cpp
)
......
......@@ -43,6 +43,8 @@
#include <OpenCTL/Program.h>
#include <OpenCTL/Module.h>
#include "KoCtlParser.h"
struct ConversionInfo {
QString sourceColorModelID;
QString sourceColorDepthID;
......@@ -218,15 +220,6 @@ void KoCtlColorProfile::decodeTransformations(QDomElement& elt)
}
}
QString generateDepthID(QString depth, QString type)
{
QString prefix;
if(type == "integer") prefix = "U";
else if(type == "float") prefix = "F";
else dbgPigment << "Invalid type";
return prefix + depth;
}
void KoCtlColorProfile::decodeConversions(QDomElement& elt)
{
for(QDomNode n = elt.firstChild(); not n.isNull(); n = n.nextSibling())
......@@ -244,10 +237,10 @@ void KoCtlColorProfile::decodeConversions(QDomElement& elt)
ConversionInfo ci;
ci.function = e.attribute("function");
ci.sourceColorModelID = eIn.attribute("colorModel");
ci.sourceColorDepthID = generateDepthID(eIn.attribute("depth"), eIn.attribute("type"));
ci.sourceColorDepthID = KoCtlParser::generateDepthID(eIn.attribute("depth"), eIn.attribute("type"));
ci.sourceProfile = eIn.attribute("profile");
ci.destinationColorModelID = eOut.attribute("colorModel");
ci.destinationColorDepthID = generateDepthID(eOut.attribute("depth"), eOut.attribute("type") );
ci.destinationColorDepthID = KoCtlParser::generateDepthID(eOut.attribute("depth"), eOut.attribute("type") );
ci.destinationProfile = eOut.attribute("profile");
if( ci.sourceColorModelID == colorModel() and ci.sourceColorDepthID == colorDepth() and ci.sourceProfile.isEmpty())
{
......@@ -301,7 +294,7 @@ bool KoCtlColorProfile::load()
if( e.tagName() == "info")
{
setName(e.attribute("name"));
d->colorDepthID = generateDepthID(e.attribute("depth"), e.attribute("type"));
d->colorDepthID = KoCtlParser::generateDepthID(e.attribute("depth"), e.attribute("type"));
d->colorDepthIDNumber = KoUniqueNumberForIdServer::instance()->numberForId( d->colorDepthID );
d->colorModelID = e.attribute("colorModel");
d->colorModelIDNumber = KoUniqueNumberForIdServer::instance()->numberForId( d->colorModelID );
......
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoCtlColorSpaceInfo.h"
#include <QFile>
#include <QDomDocument>
#include <kis_debug.h>
#include <KoCtlParser.h>
struct KoCtlColorSpaceInfo::ChannelInfo::Private {
};
KoCtlColorSpaceInfo::ChannelInfo::ChannelInfo() : d(new Private) {
}
KoCtlColorSpaceInfo::ChannelInfo::~ChannelInfo() {
delete d;
}
struct KoCtlColorSpaceInfo::Private {
QString fileName;
QString colorDepthID;
};
KoCtlColorSpaceInfo::KoCtlColorSpaceInfo(const QString& _xmlfile) : d(new Private)
{
d->fileName = _xmlfile;
}
KoCtlColorSpaceInfo::~KoCtlColorSpaceInfo()
{
delete d;
}
const QString& KoCtlColorSpaceInfo::fileName() const
{
return d->fileName;
}
bool KoCtlColorSpaceInfo::load()
{
QDomDocument doc;
QFile file(fileName());
if (not file.open(QIODevice::ReadOnly))
{
dbgPlugins << "Can't open file : " << fileName();
return false;
}
QString errorMsg;
int errorLine;
if (not doc.setContent(&file, &errorMsg, &errorLine)) {
dbgPlugins << "Can't parse file : " << fileName() << " Error at line " << errorLine << " " << errorMsg;
file.close();
return false;
}
file.close();
QDomElement docElem = doc.documentElement();
if(docElem.tagName() != "ctlcolorspace")
{
dbgPlugins << "Not a ctlcolorspace, root tag was : " << docElem.tagName();
return false;
}
QDomNode n = docElem.firstChild();
while(not n.isNull()) {
QDomElement e = n.toElement();
if(not e.isNull()) {
dbgPlugins << e.tagName();
if( e.tagName() == "info")
{
d->colorDepthID = KoCtlParser::generateDepthID(e.attribute("depth"), e.attribute("type"));
}
}
}
}
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KO_CTL_COLOR_SPACE_INFO_H_
#define _KO_CTL_COLOR_SPACE_INFO_H_
class QString;
class KoCtlColorSpaceInfo {
public:
class ChannelInfo {
ChannelInfo();
~ChannelInfo();
public:
private:
struct Private;
Private* const d;
};
public:
KoCtlColorSpaceInfo(const QString& _xmlfile);
const QString& fileName() const;
bool load();
~KoCtlColorSpaceInfo();
private:
struct Private;
Private* const d;
};
#endif
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoCtlParser.h"
#include<QString>
#include <kis_debug.h>
QString KoCtlParser::generateDepthID(const QString& depth, const QString& type)
{
QString prefix;
if(type == "integer") prefix = "U";
else if(type == "float") prefix = "F";
else dbgPlugins << "Invalid type";
return prefix + depth;
}
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
class QString;
namespace KoCtlParser {
QString generateDepthID(const QString& depth, const QString& type);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment