Example #1
0
bool Global::fromString(const std::string& data )
{
    if( data.empty() || data[0] != SEPARATOR )
        return false;

    std::vector< uint32_t > newGlobals;
    newGlobals.reserve(IATTR_ALL);

    size_t startMarker( 1u );
    size_t endMarker( 1u );
    while( true )
    {
        startMarker = data.find( SEPARATOR, endMarker );
        if( startMarker == std::string::npos )
            break;

        endMarker = data.find( SEPARATOR, startMarker + 1 );
        if( endMarker == std::string::npos )
            break;

        const std::string sub = data.substr( startMarker + 1,
                                             endMarker - startMarker - 1 );
        if( !sub.empty() && isdigit( sub[0] ))
            newGlobals.push_back( atoi( sub.c_str( )) );
        else
            break;
    }

    // only apply a 'complete' global list
    if( newGlobals.size() != IATTR_ALL )
        return false;

    std::copy( newGlobals.begin(), newGlobals.end(), _iAttributes );
    return true;
}
// -----------------------------------------------------------------------------
// For Devanagari AS
// Mark the end boundary of syllables in input string
// @param aCriteria - The search/input string entered so far
// @param aStart - The start boundary of syllable to be marked
// @return the end boundary of the syllable  
// -----------------------------------------------------------------------------
//  
inline TInt IndicSyllableEnd( TInt& aStart, const TDesC& aCriteria )
	{
	TInt maxLength = aCriteria.Length();
	TInt endMarker(-1);
	if(aStart >= (maxLength-1))
		{		
		aStart = endMarker = maxLength-1;
		}
	else 
		{			
		TInt nextCharIndex = aStart + 1 ;
		TChar startingChar = aCriteria[aStart];
		if ( IsIndicIndependentChar(startingChar) )
			{
			//Check if syllable contains a special ligature		
			if(  aStart < (maxLength-2) && IsSpecialIndicLigature(aCriteria.Mid(aStart, 3)) ) 
				{
				//Move nextCharIndex till after the 3rd symbol of special ligature.
				nextCharIndex+=2;
				}					
			//check for the next character that is a matra/halant/nukta/modifier
			//Currently this check only for Devanagari characters. If other Indic language support
			//is required, we will need to add to this list.
			while( (nextCharIndex<maxLength) && 
			      ( ( IsIndicMatra(aCriteria[nextCharIndex]) ) //matra
		          ||( aCriteria[nextCharIndex] == 0x094D ) //Devanagari halant
		          ||( aCriteria[nextCharIndex] == 0x093C ) //Devanagari nukta 
			      ||( aCriteria[nextCharIndex] >= 0x0901 && aCriteria[nextCharIndex] <= 0x0903 ))) //Devanagari modifier			      
			    {
				//check if this is a fallback rendered character. Increment index only if it isn't:
				if ( !IsFallbackRenderedCharacter(aCriteria, nextCharIndex) )
				    {
				    ++nextCharIndex;
				    }
				else
				    {
				    break;
				    }
				}
			}		
		//nextCharIndex should now be pointing to either the start of the next syllable
		//or a non-Devanagari-letter. 
		//End marker of current syllable should be placed just before the nextCharIndex
		endMarker = nextCharIndex-1;		
		}		
	return endMarker;			
	}
Example #3
0
void libcdr::CDRContentCollector::_lineProperties(librevenge::RVNGPropertyList &propList)
{
  if (m_currentLineStyle.lineType == (unsigned short)-1)
  {
    propList.insert("draw:stroke", "solid");
    propList.insert("svg:stroke-width", 0.0);
    propList.insert("svg:stroke-color", "#000000");
  }
  else
  {
    if (m_currentLineStyle.lineType & 0x1)
      propList.insert("draw:stroke", "none");
    else if (m_currentLineStyle.lineType & 0x6)
    {
      if (m_currentLineStyle.dashArray.size() && (m_currentLineStyle.lineType & 0x4))
        propList.insert("draw:stroke", "dash");
      else
        propList.insert("draw:stroke", "solid");
      double scale = 1.0;
      if (m_currentLineStyle.lineType & 0x20) // scale line with image
      {
        scale = m_currentTransforms.getScaleX();
        double scaleY = m_currentTransforms.getScaleY();
        if (scaleY > scale)
          scale = scaleY;
      }
      scale *= m_currentLineStyle.stretch;
      propList.insert("svg:stroke-width", m_currentLineStyle.lineWidth * scale);
      propList.insert("svg:stroke-color", m_ps.getRGBColorString(m_currentLineStyle.color));

      switch (m_currentLineStyle.capsType)
      {
      case 1:
        propList.insert("svg:stroke-linecap", "round");
        break;
      case 2:
        propList.insert("svg:stroke-linecap", "square");
        break;
      default:
        propList.insert("svg:stroke-linecap", "butt");
      }

      switch (m_currentLineStyle.joinType)
      {
      case 1:
        propList.insert("svg:stroke-linejoin", "round");
        break;
      case 2:
        propList.insert("svg:stroke-linejoin", "bevel");
        break;
      default:
        propList.insert("svg:stroke-linejoin", "miter");
      }

      if (m_currentLineStyle.dashArray.size())
      {
        int dots1 = 0;
        int dots2 = 0;
        unsigned dots1len = 0;
        unsigned dots2len = 0;
        unsigned gap = 0;

        if (m_currentLineStyle.dashArray.size() >= 2)
        {
          dots1len = m_currentLineStyle.dashArray[0];
          gap = m_currentLineStyle.dashArray[1];
        }

        unsigned long count = m_currentLineStyle.dashArray.size() / 2;
        unsigned i = 0;
        for (; i < count;)
        {
          if (dots1len == m_currentLineStyle.dashArray[2*i])
            dots1++;
          else
            break;
          gap = gap < m_currentLineStyle.dashArray[2*i+1] ?  m_currentLineStyle.dashArray[2*i+1] : gap;
          i++;
        }
        if (i < count)
        {
          dots2len = m_currentLineStyle.dashArray[2*i];
          gap = gap < m_currentLineStyle.dashArray[2*i+1] ? m_currentLineStyle.dashArray[2*i+1] : gap;
        }
        for (; i < count;)
        {
          if (dots2len == m_currentLineStyle.dashArray[2*i])
            dots2++;
          else
            break;
          gap = gap < m_currentLineStyle.dashArray[2*i+1] ? m_currentLineStyle.dashArray[2*i+1] : gap;
          i++;
        }
        if (!dots2)
        {
          dots2 = dots1;
          dots2len = dots1len;
        }
        propList.insert("draw:dots1", dots1);
        propList.insert("draw:dots1-length", 72.0*(m_currentLineStyle.lineWidth * scale)*dots1len, librevenge::RVNG_POINT);
        propList.insert("draw:dots2", dots2);
        propList.insert("draw:dots2-length", 72.0*(m_currentLineStyle.lineWidth * scale)*dots2len, librevenge::RVNG_POINT);
        propList.insert("draw:distance", 72.0*(m_currentLineStyle.lineWidth * scale)*gap, librevenge::RVNG_POINT);
      }
    }
    else
    {
      propList.insert("draw:stroke", "solid");
      propList.insert("svg:stroke-width", 0.0);
      propList.insert("svg:stroke-color", "#000000");
    }
  }

  // Deal with line markers (arrows, etc.)
  if (!m_currentLineStyle.startMarker.empty())
  {
    CDRPath startMarker(m_currentLineStyle.startMarker);
    startMarker.transform(m_currentTransforms);
    if (!m_groupTransforms.empty())
      startMarker.transform(m_groupTransforms.top());
    CDRTransform tmpTrafo = CDRTransform(1.0, 0.0, 0.0, 0.0, -1.0, 0);
    startMarker.transform(tmpTrafo);
    librevenge::RVNGString path, viewBox;
    double width;
    startMarker.writeOut(path, viewBox, width);
    propList.insert("draw:marker-start-viewbox", viewBox);
    propList.insert("draw:marker-start-path", path);
    // propList.insert("draw:marker-start-width", width);
  }
  if (!m_currentLineStyle.endMarker.empty())
  {
    CDRPath endMarker(m_currentLineStyle.endMarker);
    endMarker.transform(m_currentTransforms);
    if (!m_groupTransforms.empty())
      endMarker.transform(m_groupTransforms.top());
    CDRTransform tmpTrafo = CDRTransform(-1.0, 0.0, 0.0, 0.0, -1.0, 0);
    endMarker.transform(tmpTrafo);
    librevenge::RVNGString path, viewBox;
    double width;
    endMarker.writeOut(path, viewBox, width);
    propList.insert("draw:marker-end-viewbox", viewBox);
    propList.insert("draw:marker-end-path", path);
    // propList.insert("draw:marker-end-width", width);
  }



}