1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 8 9 #include "cxftristimulusspec.h" 10 #include "cxfutils.h" 11 CxfTristimulusSpec()12CxfTristimulusSpec::CxfTristimulusSpec() 13 { 14 m_illuminant = cxfIlluminantUnknown; 15 m_observer = cxfObserverUnknown; 16 m_convMethod = cxfMethodUnknown; 17 } 18 isValid() const19bool CxfTristimulusSpec::isValid() const 20 { 21 bool valid = true; 22 valid &= (m_illuminant != cxfIlluminantUnknown); 23 valid &= (m_observer != cxfObserverUnknown); 24 valid &= (m_convMethod != cxfMethodUnknown); 25 return valid; 26 } 27 isSupported() const28bool CxfTristimulusSpec::isSupported() const 29 { 30 bool supported = true; 31 supported &= (m_illuminant == cxfIlluminantD50 || m_illuminant == cxfIlluminantD65); 32 supported &= (m_observer == cxfObserver2_Degree || m_observer == cxfObserver10_Degree); 33 return supported; 34 } 35 parse(QDomElement & elem)36bool CxfTristimulusSpec::parse(QDomElement& elem) 37 { 38 bool parsingError = false; 39 reset(); 40 41 QDomNodeList childNodes = elem.childNodes(); 42 for (int i = 0; i < childNodes.count(); ++i) 43 { 44 QDomNode childNode = childNodes.at(i); 45 if (!childNode.isElement()) 46 continue; 47 QDomElement childElem = childNode.toElement(); 48 QString tagName = childElem.tagName(); 49 50 if (tagName == QLatin1String("CustomIlluminant")) 51 { 52 m_illuminant = cxfIlluminantCustom; 53 } 54 if (tagName == QLatin1String("Illuminant")) 55 { 56 m_illuminant = qstrToCxfIlluminant(childElem.text()); 57 if (m_illuminant == cxfIlluminantUnknown) 58 parsingError = true; 59 } 60 if (tagName == QLatin1String("Observer")) 61 { 62 m_observer = qstrToCxfObserver(childElem.text()); 63 if (m_observer == cxfObserverUnknown) 64 parsingError = true; 65 } 66 if (tagName == QLatin1String("Method")) 67 { 68 m_convMethod = qstrToCxfCIEConversionMethod(childElem.text()); 69 if (m_convMethod == cxfMethodUnknown) 70 parsingError = true; 71 } 72 73 if (parsingError) 74 break; 75 } 76 77 if (parsingError) 78 reset(); 79 return isValid(); 80 } 81 reset()82void CxfTristimulusSpec::reset() 83 { 84 m_illuminant = cxfIlluminantUnknown; 85 m_observer = cxfObserverUnknown; 86 m_convMethod = cxfMethodUnknown; 87 } 88