Ejemplo n.º 1
0
/************************************************************************************************
 * cStrings
 *
 * inputs:
 *
 * return:
 *
 ************************************************************************************************/
cStrings::cStrings(unsigned int initFlags, char *initReference)
{
	Flags = initFlags;
	Reference = NULL;

	SetReference(initReference);
}
Ejemplo n.º 2
0
cStringPackage::cStringPackage(const char *in, unsigned char initID, char *initDescription, char *initReference)
{
	ID = initID;
	Registration = 0;
	name = in;
	Reference = NULL;

	SetReference(initReference);
}
Ejemplo n.º 3
0
// For token elements, mBoundingMetrics is computed at the ReflowToken
// pass, it is not computed here because our children may be text frames
// that do not implement the GetBoundingMetrics() interface.
/* virtual */ nsresult
nsMathMLTokenFrame::Place(nsRenderingContext& aRenderingContext,
                          bool                 aPlaceOrigin,
                          nsHTMLReflowMetrics& aDesiredSize)
{
  mBoundingMetrics = nsBoundingMetrics();
  for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
       childFrame = childFrame->GetNextSibling()) {
    nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
    GetReflowAndBoundingMetricsFor(childFrame, childSize,
                                   childSize.mBoundingMetrics, nullptr);
    // compute and cache the bounding metrics
    mBoundingMetrics += childSize.mBoundingMetrics;
  }

  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  nscoord ascent = fm->MaxAscent();
  nscoord descent = fm->MaxDescent();

  aDesiredSize.mBoundingMetrics = mBoundingMetrics;
  aDesiredSize.Width() = mBoundingMetrics.width;
  aDesiredSize.SetTopAscent(std::max(mBoundingMetrics.ascent, ascent));
  aDesiredSize.Height() = aDesiredSize.TopAscent() +
                        std::max(mBoundingMetrics.descent, descent);

  if (aPlaceOrigin) {
    nscoord dy, dx = 0;
    for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame;
         childFrame = childFrame->GetNextSibling()) {
      nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode());
      GetReflowAndBoundingMetricsFor(childFrame, childSize,
                                     childSize.mBoundingMetrics);

      // place and size the child; (dx,0) makes the caret happy - bug 188146
      dy = childSize.Height() == 0 ? 0 : aDesiredSize.TopAscent() - childSize.TopAscent();
      FinishReflowChild(childFrame, PresContext(), childSize, nullptr, dx, dy, 0);
      dx += childSize.Width();
    }
  }

  SetReference(nsPoint(0, aDesiredSize.TopAscent()));

  return NS_OK;
}
Ejemplo n.º 4
0
bool MODULE::IncrementReference( bool aFillSequenceGaps )
{
    BOARD* board = GetBoard();

    if( !board )
        return false;

    bool success = false;
    const wxString prefix = GetReferencePrefix();
    const wxString newReference = board->GetNextModuleReferenceWithPrefix(
            prefix, aFillSequenceGaps );

    if( !newReference.IsEmpty() )
    {
        SetReference( newReference );
        success = true;
    }

    return success;
}
Ejemplo n.º 5
0
bool cStringPackage::UnderstandToken(char *&Data, int &Size, int token, char *data )
{
	switch(token)
	{
		case TK_ID:
			ID = (unsigned char)atol(data);
			return true;

		case TK_CONFIG:
			return true;

		case TK_REFERENCE:
			SetReference(data);
			return true;
	}

	if (token == TK_INVALID)
	{
		return false;
	}

	return true;
}
Ejemplo n.º 6
0
bool cStringPackage::UnderstandToken(char *&Data, int &Size, int token, char *data )
{
	cCriteria FullCriteria;

	switch(token)
	{
		case TK_ID:
			ID = (unsigned char)atol(data);
			return true;

		case TK_CONFIG:
#ifdef _STRIPED_
			ConfigFile.Load(data,FullCriteria);
#endif
			return true;

		case TK_REFERENCE:
#ifdef _STRIPED_
			if (Reference)
			{
				char temp[1024];

				sprintf(temp, "Please get RJ about this error!  Do NOT save or do anything!  OldRefeence: %s, New: %s", Reference, data);
				MessageBox(NULL, temp, "RJ Error!", MB_OK);
			}
#endif
			SetReference(data);
			return true;
	}

	if (token == TK_INVALID)
	{
		return false;
	}

	return true;
}
Ejemplo n.º 7
0
bool cStrings::UnderstandToken(int token, char *data)
{
	sFlagPair		*FlagPair;

	switch(token)
	{
		case TK_FLAGS:
			while(token != TK_INVALID)
			{
				token = FindToken(data, false);
				for(FlagPair = FlagPairs; FlagPair->Name != TK_INVALID; FlagPair++)
				{
					if (FlagPair->Name == token)
					{
						Flags |= FlagPair->Value;
						break;
					}
				}
			}
			return true;

		case TK_REFERENCE:
			SetReference(data);
			return true;

		case TK_RIGHT_BRACE:
			return false;
	}

	if (token == TK_INVALID)
	{
		return false;
	}

	return true;
}
NS_IMETHODIMP
nsMathMLmfencedFrame::Reflow(nsPresContext*          aPresContext,
                             nsHTMLReflowMetrics&     aDesiredSize,
                             const nsHTMLReflowState& aReflowState,
                             nsReflowStatus&          aStatus)
{
  nsresult rv;
  aDesiredSize.width = aDesiredSize.height = 0;
  aDesiredSize.ascent = 0;
  aDesiredSize.mBoundingMetrics = nsBoundingMetrics();

  PRInt32 i;
  const nsStyleFont* font = GetStyleFont();
  nsRefPtr<nsFontMetrics> fm;
  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
  aReflowState.rendContext->SetFont(fm);
  nscoord axisHeight, em;
  GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
  GetEmHeight(fm, em);
  // leading to be left at the top and the bottom of stretched chars
  nscoord leading = NSToCoordRound(0.2f * em); 

  /////////////
  // Reflow children
  // Asking each child to cache its bounding metrics

  // Note that we don't use the base method nsMathMLContainerFrame::Reflow()
  // because we want to stretch our fences, separators and stretchy frames using
  // the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
  // method here, our stretchy frames will be stretched and placed, and we may
  // end up stretching our fences/separators with a different aDesiredSize.
  // XXX The above decision was revisited in bug 121748 and this code can be
  // refactored to use nsMathMLContainerFrame::Reflow() at some stage.

  nsReflowStatus childStatus;
  nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
  nsIFrame* firstChild = GetFirstChild(nsnull);
  nsIFrame* childFrame = firstChild;
  nscoord ascent = 0, descent = 0;
  if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
    // We use the ASCII metrics to get our minimum height. This way,
    // if we have borders or a background, they will fit better with
    // other elements on the line.
    ascent = fm->MaxAscent();
    descent = fm->MaxDescent();
  }
  while (childFrame) {
    nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
                                         | NS_REFLOW_CALC_BOUNDING_METRICS);
    nsHTMLReflowState childReflowState(aPresContext, aReflowState,
                                       childFrame, availSize);
    rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
                     childReflowState, childStatus);
    //NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
    if (NS_FAILED(rv)) {
      // Call DidReflow() for the child frames we successfully did reflow.
      DidReflowChildren(firstChild, childFrame);
      return rv;
    }

    SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                    childDesiredSize.mBoundingMetrics);

    nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
    if (descent < childDescent)
      descent = childDescent;
    if (ascent < childDesiredSize.ascent)
      ascent = childDesiredSize.ascent;

    childFrame = childFrame->GetNextSibling();
  }

  /////////////
  // Ask stretchy children to stretch themselves

  nsBoundingMetrics containerSize;
  nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;

  GetPreferredStretchSize(*aReflowState.rendContext,
                          0, /* i.e., without embellishments */
                          stretchDir, containerSize);
  childFrame = firstChild;
  while (childFrame) {
    nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
    if (mathmlChild) {
      nsHTMLReflowMetrics childDesiredSize;
      // retrieve the metrics that was stored at the previous pass
      GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                     childDesiredSize.mBoundingMetrics);
      
      mathmlChild->Stretch(*aReflowState.rendContext, 
                           stretchDir, containerSize, childDesiredSize);
      // store the updated metrics
      SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
                                      childDesiredSize.mBoundingMetrics);
      
      nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
      if (descent < childDescent)
        descent = childDescent;
      if (ascent < childDesiredSize.ascent)
        ascent = childDesiredSize.ascent;
    }
    childFrame = childFrame->GetNextSibling();
  }

  // bug 121748: for surrounding fences & separators, use a size that covers everything
  GetPreferredStretchSize(*aReflowState.rendContext,
                          STRETCH_CONSIDER_EMBELLISHMENTS,
                          stretchDir, containerSize);

  //////////////////////////////////////////
  // Prepare the opening fence, separators, and closing fence, and
  // adjust the origin of children.

  // we need to center around the axis
  nscoord delta = NS_MAX(containerSize.ascent - axisHeight, 
                         containerSize.descent + axisHeight);
  containerSize.ascent = delta + axisHeight;
  containerSize.descent = delta - axisHeight;

  /////////////////
  // opening fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
             NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, 
             axisHeight, leading, em, containerSize, ascent, descent);
  /////////////////
  // separators ...
  for (i = 0; i < mSeparatorsCount; i++) {
    ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
               NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
               axisHeight, leading, em, containerSize, ascent, descent);
  }
  /////////////////
  // closing fence ...
  ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
             NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
             axisHeight, leading, em, containerSize, ascent, descent);

  //////////////////
  // Adjust the origins of each child.
  // and update our bounding metrics

  i = 0;
  nscoord dx = 0;
  nsBoundingMetrics bm;
  PRBool firstTime = PR_TRUE;
  if (mOpenChar) {
    PlaceChar(mOpenChar, ascent, bm, dx);
    aDesiredSize.mBoundingMetrics = bm;
    firstTime = PR_FALSE;
  }

  childFrame = firstChild;
  while (childFrame) {
    nsHTMLReflowMetrics childSize;
    GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
    if (firstTime) {
      firstTime = PR_FALSE;
      aDesiredSize.mBoundingMetrics  = bm;
    }
    else  
      aDesiredSize.mBoundingMetrics += bm;

    FinishReflowChild(childFrame, aPresContext, nsnull, childSize, 
                      dx, ascent - childSize.ascent, 0);
    dx += childSize.width;

    if (i < mSeparatorsCount) {
      PlaceChar(&mSeparatorsChar[i], ascent, bm, dx);
      aDesiredSize.mBoundingMetrics += bm;
    }
    i++;

    childFrame = childFrame->GetNextSibling();
  }

  if (mCloseChar) {
    PlaceChar(mCloseChar, ascent, bm, dx);
    if (firstTime)
      aDesiredSize.mBoundingMetrics  = bm;
    else  
      aDesiredSize.mBoundingMetrics += bm;
  }

  aDesiredSize.width = aDesiredSize.mBoundingMetrics.width;
  aDesiredSize.height = ascent + descent;
  aDesiredSize.ascent = ascent;

  SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
  SetReference(nsPoint(0, aDesiredSize.ascent));

  // see if we should fix the spacing
  FixInterFrameSpacing(aDesiredSize);

  // Finished with these:
  ClearSavedChildMetrics();

  // Set our overflow area
  GatherAndStoreOverflow(&aDesiredSize);

  aStatus = NS_FRAME_COMPLETE;
  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
  return NS_OK;
}
Ejemplo n.º 9
0
 inline void OnStart(RefType* t) { SetReference(t); }
Ejemplo n.º 10
0
void UtilityVisitor::startElement(const char *name, const XMLAttributes &atts)
{
	const char *attval;

	// clear data at the start of each element
	m_data = "";

	if (m_state == 0)
	{
		if (!strcmp(name, "UtilityCollection"))
		{
			m_state = 1;
		}
		else
		{
			string message = "Root element name is ";
			message += name;
			message += "; expected UtilityCollection";
			throw xh_io_exception(message, "XML Reader");
		}
		return;
	}
	if (m_state == 1)
	{
		if (!strcmp(name, "OverheadLine"))
		{
			m_pRoute = new vtRoute(GetCurrentTerrain());		// Create new route (should this be in vtUtilityMap ??)
			attval = atts.getValue("name");
			if (attval)
				m_pRoute->SetName(attval);		// TODO Set Name of the overhead line
			GetCurrentTerrain()->AddRoute(m_pRoute);
			m_state = 2;
		}
		return;
	}

	if (m_state == 2)	// Conductor
	{
		if (!strcmp(name, "Conductor"))
		{
			attval = atts.getValue("width");
			if (attval)
				m_pRoute->SetThickness(atof(attval));
			attval = atts.getValue("color");
			if (attval)
				m_pRoute->SetColor(ParseHexColor(attval));
			m_state = 3;
		}
		return;
	}

	if (m_state == 3)	// Pylon
	{
		if (!strcmp(name, "Pylon"))
		{
			attval = atts.getValue("name");
			if (attval)
				SetName(attval);
			attval = atts.getValue("reference");
			if (attval)
				SetReference(attval);
			attval = atts.getValue("rotation");
			if (attval)
				SetRotation(atof(attval));

			m_state = 4;	// now read in the coordinate ...
		}
		else
			m_state = 1;	// then it is a new overhead line
		return;
	}
}
Ejemplo n.º 11
0
/*----------------------------------------------------------------------
   CheckReferences        On vient de coller le sous-arbre de racine	
   pRoot dans le document pDoc. Verifie la coherence des elements	
   reference's et des references presents dans ce sous-arbre.      
  ----------------------------------------------------------------------*/
void CheckReferences (PtrElement pRoot, PtrDocument pDoc)
{
   PtrElement          pEl, pElRef, pSource;
   PtrReference        pRef, pNextRef;
   PtrAttribute        pAttr, pNextAttr;
   PtrElement          pElemRef;
   LabelString         oldLabel;
   PtrReference        pRefClipboard;
   PtrDocument         pDocRef;
   int                 l;
   ThotBool            delAttr;

   /* on se souvient du label de l'original */
   strncpy (oldLabel, pRoot->ElLabel, MAX_LABEL_LEN);
   if (ChangeLabel || pDoc != DocOfSavedElements)
     {
	/* on affecte un nouveau label a l'element */
	l = NewLabel (pDoc);
	ConvertIntToLabel (l, pRoot->ElLabel);
     }
   if (pRoot->ElReferredDescr != NULL)
      /* l'original de l'element colle' est reference' */
     {
       /* l'element original */
       pSource = pRoot->ElReferredDescr->ReReferredElem;
       pRoot->ElReferredDescr = NULL;
       /* l'element colle' n'est pas reference', il prend le label de son
	  element original (celui qui est dans le tampon Couper-Copier)
	  si la commande precedente etait Couper et s'il ne change pas de
	  document. Dans les autres cas (commande precedente Copier ou
	  changement de document), il prend un nouveau label. */

       /* alloue a l'element un descripteur d'element reference' */
       pRoot->ElReferredDescr = NewReferredElDescr (pDoc);
       pRoot->ElReferredDescr->ReReferredElem = pRoot;
       if (!ChangeLabel && pSource != NULL && pDoc == DocOfSavedElements)
	 /* l'element prend le meme label que l'element original */
	 strncpy (pRoot->ElLabel, pSource->ElLabel, MAX_LABEL_LEN);

       /* on cherche toutes les references a l'element original et on les */
       /* fait pointer sur l'element colle'. */
       /* cherche d'abord la premiere reference */
       pDocRef = DocOfSavedElements;
       pRef = NextReferenceToEl (pSource, DocOfSavedElements, NULL);
       while (pRef)
	  {
	     /* cherche la reference suivante a l'original avant de modifier */
	     /* la reference courante */
	     pNextRef = NextReferenceToEl (pSource, DocOfSavedElements, pRef);
	     /* traite la reference courante */
	     /* si elle est dans le tampon, on n'y touche pas : sa copie dans
	        le document ou on colle a deja ete traitee ou sera traitee
		dans cette boucle */
	     if (!IsASavedElement (pRef->RdElement))
		/* on fait pointer la reference sur l'element colle' */
	       {
		  if (IsWithinANewElement (pRef->RdElement))
		     pDocRef = pDoc;
		  if (pRef->RdAttribute)
		     pElemRef = NULL;
		  else
		     pElemRef = pRef->RdElement;
		  SetReference (pElemRef, pRef->RdAttribute, pRoot, pDocRef,
				pDoc, FALSE, FALSE);
	       }
	     pRef = pNextRef;	/* passe a la reference suivante */
	     pDocRef = DocOfSavedElements;
	  }
     }
   /* Traite les attributs de type reference porte's par l'element */
   pAttr = pRoot->ElFirstAttr;
   while (pAttr != NULL)
      /* examine tous les attributs de l'element */
     {
     	pNextAttr = pAttr->AeNext;
	if (pAttr->AeAttrType == AtReferenceAttr)
	   /* c'est un attribut de type reference */
	   /* cherche l'element reference', pElRef */
	  {
	     pElRef = NULL;
	     delAttr = FALSE;
	     if (pAttr->AeAttrReference != NULL)
		 if (pAttr->AeAttrReference->RdReferred != NULL)
		   {
		     pElRef = pAttr->AeAttrReference->RdReferred->ReReferredElem;
		     /* si l'element reference' est aussi colle', */
		     /* on ne fait rien: ce cas est traite' plus haut */
		     if (pElRef != NULL)
		       if (!IsASavedElement (pElRef))
			 if (!IsWithinANewElement (pElRef))
			   {
			     if (DocOfSavedElements != pDoc)
			       /* reference et objet reference' sont */
			       /* dans des documents differents, on */
			       /* supprime l'attribut, sauf dans le */
			       /* cas particulier des tableaux. */
			       {
				 RemoveAttribute (pRoot, pAttr);
				 delAttr = TRUE;
			       }
			   }
		     if (delAttr)
			DeleteAttribute (pRoot, pAttr);
		   }  
	  }
	pAttr = pNextAttr;
     }
   /* Lorsqu'on fait un copier/coller d'un element LtReference, */
   /* il faut chainer les references entre element ancien et */
   /* element nouveau : la reference de la copie qui est dans */
   /* le tampon est dechainee entre les deux elements. */
   /* pRoot est le nouvel element cree : son descripteur */
   /* a ete chaine devant le descripteur de la copie qui est */
   /* dans le tampon, qui est devant celui de l'element copie */
   if (pRoot->ElTerminal && pRoot->ElLeafType == LtReference)
     {
	/* c'est un element reference */
	pRef = pRoot->ElReference;
	if (pRef != NULL)	/*  on cherche le suivant */
	  {
	     pRefClipboard = pRef->RdNext;
	     if (pRefClipboard != NULL
		 && IsASavedElement (pRefClipboard->RdElement))
		/* il faut retirer pRefClipboard du chainage */
	       {
		  pRef->RdNext = pRefClipboard->RdNext;
		  if (pRefClipboard->RdNext != NULL)
		     pRefClipboard->RdNext->RdPrevious = pRef;
	       }
	  }
     }

   if (!pRoot->ElTerminal && pRoot->ElSource == NULL)
      /* ce n'est ni une inclusion ni un terminal, on traite tous les fils */
     {
	pEl = pRoot->ElFirstChild;
	while (pEl != NULL)
	  {
	     CheckReferences (pEl, pDoc);
	     pEl = pEl->ElNext;
	  }
     }
}