Beispiel #1
0
void XmlTextWriter::WriteCData(RCString text) {
	if (strstr(text.c_str(), "]]"))
		throw logic_error("Not allowed \"]]\" in CDATA"); //!!! XmlException
	CloseElement(false);
	m_os << "<![CDATA[" << text << "]]>";
	m_bEoled = false;
}
Beispiel #2
0
bool CXmlStreamRead::GetElementS(std::string tag, std::string* pString, bool RepeatingTag)
{
	if (!OpenElement(tag, RepeatingTag)) return false;
	*pString = std::string(ElStack.back()->first_node()->value());
	if (*pString == "")	return false;

	if (!RepeatingTag) CloseElement(); //if we're not expecting to load more tags of the same name...
	return true;
}
Beispiel #3
0
void XmlTextWriter::WriteStartElement(RCString name) {
	CloseElement();
	if (!m_bEoled)
		Eol();
	Indent();
	m_os << '<' << name;
	m_elements.push(name.c_str()); //!!!
	m_bOpenedElement = true;
	m_bEoled = false;
}
Beispiel #4
0
void XmlTextWriter::WriteEndElement() {
	if (m_bOpenedElement) {
		m_os << "/";
		CloseElement();
		m_elements.pop();
	} else {
		if (m_elements.empty())
			throw logic_error(string(__FUNCTION__)+ string(" at root element"));
		string tag = m_elements.top();
		m_elements.pop();
		if (m_bEoled)
			Indent();
		m_os << "</" << tag << ">";
	}
	Eol();
}
Beispiel #5
0
void CXMLWriterStd::WriteElement(
	const char * name,
	const char * content,
	bool escapeWhitespace)
{
    m_bEmpty = false;
    if(content && content[0])
    {
	OpenElement(name);
	Stream() << content;
	CloseElement(name);
    }
    else
    {
	Stream() << "<" << name;
	WriteAttributes();
	Stream() << "/>\n"; 
    }
}
Beispiel #6
0
bool CXmlStreamRead::OpenElement(std::string tag, bool RepeatingTag) //finds element if it exists and appends ptr to stack. if called subsequently with the same tag, looks for siblings, not children.
{
	rapidxml::xml_node<>* tmpElement;
	bool IsSameTag = (tag == StrStack.back()); //flag to see if we just searched for this one
	
	if (IsSameTag && RepeatingTag){ //if this IS the last tag we searched for and we're looking for siblings...
		tmpElement = ElStack.back()->next_sibling(tag.c_str(), 0, false); //try to find a next sibling
		if (tmpElement){ //if we find it, move the top of the stack to the new sibling
			ElStack.back() = tmpElement; 
			return true;
		}
	}
	else { //If not the same tag we searched for (or we searched for the same tag name as a child element)
		tmpElement = ElStack.back()->first_node(tag.c_str(), 0, false); //if this is the first time we've searched for the tag
		if (tmpElement){
			ElStack.push_back(tmpElement); //if first element of this type
			StrStack.push_back(tag);
			return true;
		}
	}

	if (IsSameTag && RepeatingTag) CloseElement(); //automatically close the tag we were searching repeatedly for...
	return false;
}
Beispiel #7
0
	bool XMLPrinter::VisitExit( const XMLElement& )
	{
		CloseElement();
		return true;
	}
Beispiel #8
0
void XmlTextWriter::WriteString(RCString text) {
	CloseElement(false);
	WriteQuotedString(text);
	m_bEoled = false;
}
Beispiel #9
0
void XmlTextWriter::WriteRaw(RCString s) {
	CloseElement(false);
	m_os << s;
}
	bool XMLPrinter::VisitExit(const XMLElement& element)
	{
		CloseElement(CompactMode(element));
		return true;
	}
Beispiel #11
0
BOOL ProcessPath::Process(const ProcessFlags& PFlags)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=0;
    BOOL ok = TRUE;

	// scan through the input verbs
    while ((i<numinsource) && (ok))
    {
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				ok = NewPoint(PT_MOVETO, &ICoords[i]);
				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }
	return ok;
}
Beispiel #12
0
INT32 ProcessPathDistance::Process(const ProcessFlags& PFlags, INT32 AlreadyProcessed)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	UINT32*     IPressure = NULL;
	if (ProcSource->HasWidth())
		IPressure = ProcSource->GetWidthArray();
	
	//if (IPressure == NULL)
	//	ERROR3("No pressure array");

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=AlreadyProcessed;
    BOOL ok = TRUE;
	if ( i > 0)
	{
		ProcFirstPoint = FALSE;
	}
	
	// scan through the input verbs
    while ((i < numinsource) && (ok) && (!Found))
    {
	//	if (IPressure != NULL)
	//		TRACEUSER( "Diccon", _T("PathProc Pressure =  %d\n"), IPressure[i]);
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				if (IPressure != NULL)
					ok = NewPointA(PT_MOVETO, &ICoords[i], &IPressure[i]);
				else
					ok = NewPoint(PT_MOVETO, &ICoords[i]);

				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							if (IPressure != NULL)
								ok = NewPointA(PT_LINETO, &ICoords[i], &IPressure[i]);
							else
								ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }

	// we are recording the point previous to the one we just found. 
	// i represents the next point, i-1 is the point we just found, so 
	// the one before that is i-2
	if (Found)
		m_LastFoundIndex = i -2;

	INT32 ReturnValue;
	// we have processed i-1 points
	if (ok)
		ReturnValue = i-1; 
	else
		ReturnValue = -1;

	return ok;
}