Пример #1
0
void block_justify( t_block *block, int dir)
{
	t_lst *lst = block_leaves_get( block, dir);

	t_link *l;
	t_block *previous = NULL;
	for( l = lst->first; l; l = l->next)
	{
		t_block *block_nearest = l->data;
		justify( block, block_nearest, dir);

		if( previous)
		{
			if( previous->id.id != block_nearest->id.id)
			{
				justify( previous, block_nearest, NORTH);
				//justify_tree( previous, block_nearest, NORTH);
			}
		}

		// Go Recursive
		block_justify( block_nearest, dir);

		previous = block_nearest;
	}

	lst_free( lst);
}
Пример #2
0
UniscribeHelperTextRun::UniscribeHelperTextRun(const TextRun& run,
                                               const Font& font)
    : UniscribeHelper(0, run.length(), run.rtl(),
                      font.primaryFont()->platformData().hfont(),
                      font.primaryFont()->platformData().scriptCache(),
                      font.primaryFont()->platformData().scriptFontProperties(),
                      font.primaryFont()->spaceGlyph())
    , m_font(&font)
    , m_fontIndex(0)
{
    if (run.is8Bit()) {
        m_stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length());
        setInput(m_stringFor8BitRun.characters16());
    } else {
        setInput(run.characters16());
    }

    setDirectionalOverride(run.directionalOverride());
    setLetterSpacing(font.letterSpacing());
    setSpaceWidth(font.spaceWidth());
    setWordSpacing(font.wordSpacing());
    setAscent(font.fontMetrics().ascent());
    setRangeProperties(font.fontDescription().featureSettings());

    init();

    // Expansion is the amount to add to make justification happen. This
    // should be done after Init() so all the runs are already measured.
    if (run.expansion() > 0)
        justify(run.expansion());
}
Пример #3
0
int main()
{
	int type;
	scanf("%s",str);
	if (str[0]=='L')
		type=LEFT;
	else if (str[0]=='R')
		type=RIGHT;
	else if (str[0]=='C')
		type=CENTER;
	else type=JUSTIFY;
	scanf("%s",str);
	while (makeline()==1)
	{
		if (type==LEFT)
			left();
		else if (type==RIGHT)
			right();
		else if (type==CENTER)
			center();
		else justify();
		len=0;
		line[0]='\0';
	}
	if (type==LEFT)
		left();
	else if (type==RIGHT)
		right();
	else if (type==CENTER)
		center();
	else left();
    return 0;
}
Пример #4
0
void GLFTFont::draw(const char* text, int length, double adjx, double adjy, const RenderContext& rc) {
  
  if ( justify( width(text), height(), adjx, adjy, rc ) ) {
    if (rc.gl2psActive == GL2PS_NONE)
      font->Render(text);
    else
      gl2psTextOpt(text, GL2PS_FONT, GL2PS_FONTSIZE, gl2ps_centering, 0.0);
  }
}
Пример #5
0
    void format()
    {
        char line[80], word[30];
        ifstream inFile("quote.txt", ios::in);
        line[0] = '\0';

        inFile >> word;
        strcat(line, word);
        while (inFile >> word)
        {
            if (strlen(line) + strlen(word) + 1 > width_)
              justify(line);
            else
              strcat(line, " ");
            strcat(line, word);
        }
        justify(line);
    }
Пример #6
0
// Make both columns the same height.
// (Maybe this should also be governed by minfull,
// to prevent padding very underfull columns.)
void multicol::stretch(int wantht)
{
	if (wantht < height())
		ERROR "page %d: two-column chunk cannot shrink\n", userpn FATAL;
	for (int i = 0; i < 2; i++)
		justify(&(column[i]), wantht);
	if (dbg & 16)
		printf("#col hts: left %d right %d\n",
			column[0].height(), column[1].height());
}
Пример #7
0
// Reset text formatting parameters.
void Adafruit_Thermal::setDefault(){
  online();
  justify('L');
  inverseOff();
  doubleHeightOff();
  setLineHeight(32);
  boldOff();
  underlineOff();
  setBarcodeHeight(50);
  setSize('s');
}
Пример #8
0
void GLBitmapFont::draw(const wchar_t* text, int length, 
                        double adjx, double adjy, const RenderContext& rc) {
  
  if (justify(width(text), height(), adjx, adjy, rc)) {
  
    if (rc.gl2psActive == GL2PS_NONE) {
      glListBase(listBase);
      glCallLists(length, GL_UNSIGNED_BYTE, text);
    }
  // gl2ps doesn't support wchar_t?  Should convert?
  }
}
Пример #9
0
void GLBitmapFont::draw(const char* text, int length, 
                        double adjx, double adjy, const RenderContext& rc) {
    
  if (justify(width(text), height(), adjx, adjy, rc)) {
  
    if (rc.gl2psActive == GL2PS_NONE) {
      glListBase(listBase);
      glCallLists(length, GL_UNSIGNED_BYTE, text);
    } else
      gl2psTextOpt(text, GL2PS_FONT, GL2PS_FONTSIZE, gl2ps_centering, 0.0);
  }
}
Пример #10
0
void justify( t_block *block, t_block *block_nearest, int dir)
{
	float x = block_nearest->pos[0];
	float y = block_nearest->pos[1];
	float m = 60;
	switch( dir)
	{
		case WEST:
			if( x + block_nearest->width + m >= block->pos[0])
			{
				displace( block, block_nearest, dir);
				justify( block, block_nearest, dir);
			}
			break;
		case EAST:
			if( x <= block->pos[0] +block->width + m)
			{
				displace( block, block_nearest, dir);
				justify( block, block_nearest, dir);
			}
			break;

		case NORTH:
			if( y <= block->pos[1] + block->height + m)
			{
				displace( block, block_nearest, dir);
				justify( block, block_nearest, dir);
			}
			break;

		case SOUTH:
			if( y <= block->pos[1] + block->height + m)
			{
				displace( block, block_nearest, dir);
				justify( block, block_nearest, dir);
			}
			break;
	}
}
Пример #11
0
 vector<string> fullJustify(vector<string> &words, int L) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     vector<string> ret;
     int start = 0;
     while (start<words.size()) {
         int end = find_end(words, start, L);
         string s = justify(words, start, end, L);
         ret.push_back(s);
         start = end;
     }
     return ret;
 }
UniscribeHelperTextRun::UniscribeHelperTextRun(const TextRun& run,
                                               const Font& font)
    : UniscribeHelper(run.characters(), run.length(), run.rtl(),
                      font.primaryFont()->platformData().hfont(),
                      font.primaryFont()->platformData().scriptCache(),
                      font.primaryFont()->platformData().scriptFontProperties(),
                      font.primaryFont()->spaceGlyph())
    , m_font(&font)
    , m_fontIndex(0)
{
    setDirectionalOverride(run.directionalOverride());
    setLetterSpacing(font.letterSpacing());
    setSpaceWidth(font.spaceWidth());
    setWordSpacing(font.wordSpacing());
    setAscent(font.fontMetrics().ascent());

    init();

    // Expansion is the amount to add to make justification happen. This
    // should be done after Init() so all the runs are already measured.
    if (run.expansion() > 0)
        justify(run.expansion());
}
Пример #13
0
void GR_Graphics::measureRenderedCharWidths(GR_RenderInfo & ri) 
{
	UT_return_if_fail(ri.getType() == GRRI_XP);
	GR_XPRenderInfo & RI = (GR_XPRenderInfo &) ri;
	UT_return_if_fail(RI.m_pWidths);
	
	//bool bReverse = (RI.m_iVisDir == UT_BIDI_RTL);

	UT_sint32 i;

	for (i = 0; i < RI.m_iLength; i++)
	{
		if(i > 0 && *(RI.m_pChars + i) == UCS_LIGATURE_PLACEHOLDER)
		{
			RI.m_pWidths[i]   = RI.m_pWidths[i - 1]/2;
			UT_uint32 mod     = RI.m_pWidths[i-1]%2;
			RI.m_pWidths[i-1] = RI.m_pWidths[i] + mod;
		}
		else
		{

			measureString(RI.m_pChars + i, 0, 1,
					 static_cast<UT_GrowBufElement*>(RI.m_pWidths) + i);
		}
	}

	if(RI.isJustified())
	{
		justify(RI);
	}
	
	// make sure that we invalidate the static buffers if we own them
	if(RI.s_pOwner == &RI)
		RI.s_pOwner = NULL;
	
}
Пример #14
0
char *justifynum (char *target, int source, long tmax) {
    char x[33];
    ltoa(source, x, 10);
    return justify(target, x, tmax);
}
Пример #15
0
int main(int argc, char *argv[], char *envp[])
{
  register char    *pl, *pr, *p, x;
#ifdef AK
  auto     FILE    *f = fopen("/www/log/isdn.log", "r");
#else
  auto     FILE    *f = fopen("/var/log/isdn.log", "r");
#endif
  auto     char     s[BUFSIZ], sx[BUFSIZ];
  auto     int      i, l, col, day, lday = UNKNOWN, month, lmonth = UNKNOWN;
  auto     double   dur;
  auto     char    *version;
  auto     char    *myname = basename(argv[0]);
  auto     int      opt, go, s0, indent;
  auto	   time_t   now;
  auto 	   struct   tm *tm;


  if (f != (FILE *)NULL) {

    while ((opt = getopt(argc, argv, options)) != EOF)
      switch (opt) {
        case 'n' : onlynumbers++;
                   break;

        case 'v' : verbose = atoi(optarg);
                   break;

        case 'V' : print_version(myname);
                   exit(0);

        case 'i' : showincoming++;
                   break;

        case 'o' : showoutgoing++;
                   break;

        case 'e' : showerrors++;
                   break;

        case 'a' : showincoming = showoutgoing = showerrors = 1;
                   break;

        case 'N' : strcpy(onlythis, optarg);
                   break;

        case 'm' : netto++;
             	   break;

        case 'f' : force++;
             	   break;

        case 't' : onlytoday++;
             	   break;

        case 'I' : onlyInternal++;
             	   break;

        case 'E' : onlyExternal++;
             	   break;

        case '?' : printf(usage, argv[0], argv[0], options);
                   return(1);
      } /* switch */

    if (!showincoming && !showoutgoing && !showerrors) {
      printf("This makes no sense! You must specify -i, -o or -e\n");
      printf("\t-a    -> alle Verbindungen anzeigen i.e. \"-ioe\"\n");
      printf("\t      -> show all connections\n");
      printf("\t-e    -> nichtzustandegekommene Verbindungen anzeigen\n");
      printf("\t      -> show incomplete calls\n");
      printf("\t-f    -> Verbindungsentgeld _immer_ neu berechnen\n");
      printf("\t      -> recalculate costs _always_\n");
      printf("\t-i    -> reinkommende Verbindungen anzeigen\n");
      printf("\t      -> show incoming calls\n");
      printf("\t-m    -> ohne MwSt anzeigen\n");
      printf("\t      -> prices without VAT\n");
      printf("\t-n    -> _nicht_ anstelle Rufnummern Alias-Bezeichnungen anzeigen\n");
      printf("\t      -> do _not_ replace numbers with aliases\n");
      printf("\t-o    -> rausgehende Verbindungen anzeigen\n");
      printf("\t      -> show outgoing calls\n");
      printf("\t-t    -> nur die heutigen Verbindungen anzeigen\n");
      printf("\t      -> show only current connections\n");
      printf("\t-vn   -> Verbose Level\n");
      printf("\t-Nnnn -> nur Verbindungen mit _dieser_ Rufnummer anzeigen\n");
      printf("\t      -> show only calls with the specified number\n");
      printf("\t-I    -> nur Verbindungen am Internen S0-Bus anzeigen\n");
      printf("\t      -> show only calls on the internal S0 bus\n");
      printf("\t-E    -> nur Verbindungen am Externen S0-Bus anzeigen\n");
      printf("\t      -> show only calls on the external S0 bus\n");
      printf("\t-V    -> Version anzeigen\n");
      printf("\t      -> show version\n");

      return(1);
    } /* if */

    *home = 0;

    interns0 = 3;

    set_print_fct_for_tools(print_in_modules);

    if (!readconfig(myname)) {

      initHoliday(holifile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      initDest(destfile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      initRate(rateconf, ratefile, zonefile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      memset(&msnsum, 0, sizeof(msnsum));
      memset(&provsum, 0, sizeof(provsum));
      memset(&zonesum, 0, sizeof(zonesum));

      partner[0] = (PARTNER *)calloc(knowns, sizeof(PARTNER));
      partner[1] = (PARTNER *)calloc(knowns, sizeof(PARTNER));

      time(&now);
      tm = localtime(&now);
      tm->tm_sec = tm->tm_min = tm->tm_hour = 0;
      now = mktime(tm);

      while (fgets(s, BUFSIZ, f)) {
        pl = s;
        col = 0;

        memset(&c, 0, sizeof(c));

        while ((pr = strchr(pl, '|'))) {
          memcpy(sx, pl, (l = (pr - pl)));
          sx[l] = 0;
          pl = pr + 1;

          switch (col++) {
            case  0 :                               break;

            case  1 : deb(sx);
                      strcpy(c.num[CALLING], sx);
                      break;

            case  2 : deb(sx);
                      strcpy(c.num[CALLED], sx);
                      break;

            case  3 : dur = atoi(sx);               break;

            case  4 : c.duration = atol(sx) / 100;
                      break;

            case  5 : c.connect = atol(sx);         break;
            case  6 : c.units = atoi(sx);           break;
            case  7 : c.dialout = *sx == 'O';       break;
            case  8 : c.cause = atoi(sx);           break;
            case  9 : c.ibytes = atoi(sx);          break;
            case 10 : c.obytes = atoi(sx);          break;
            case 11 : strcpy(c.version, sx);        break;
            case 12 : c.si1 = atoi(sx);             break;
            case 13 : c.si2 = atoi(sx);             break;
            case 14 : c.currency_factor = atof(sx); break;
            case 15 : strcpy(c.currency, sx);       break;
            case 16 : c.pay = atof(sx);             break;
            case 17 : c.provider = atoi(sx);        break;
            case 18 :                               break;
          } /* switch */

        } /* while */


        /* Repair wrong entries from older (or current?) isdnlog-versions ... */

        if (abs((int)dur - (int)c.duration) > 1) {
          if (verbose)
            fprintf(stderr, "REPAIR: Duration %f -> %f\n", c.duration, dur);

          c.duration = dur;
        } /* if */

        if (!memcmp(c.num[CALLED], "+4910", 5)) {
          p = c.num[CALLED] + 7;
          x = *p;
          *p = 0;

          c.provider = atoi(c.num[CALLED] + 5);

          *p = x;

          if (strlen(c.num[CALLED]) > 7)
            memmove(c.num[CALLED] + 3, c.num[CALLED] + 8, strlen(c.num[CALLED]) - 7);

          if (verbose)
            fprintf(stderr, "REPAIR: Provider=%d\n", c.provider);
        } /* if */

        if (!c.provider || (c.provider == UNKNOWN)) {
          if (verbose)
            fprintf(stderr, "REPAIR: Provider %d -> %d\n", c.provider, preselect);

          c.provider = preselect;
        } /* if */

        if (c.dialout && (strlen(c.num[CALLED]) > 3) && !getSpecial(c.num[CALLED])) {
          sprintf(s, "0%s", c.num[CALLED] + 3);

          if (getSpecial(s)) {
            if (verbose)
              fprintf(stderr, "REPAIR: Callee %s -> %s\n", c.num[CALLED], s);

            strcpy(c.num[CALLED], s);
          } /* if */
        } /* if */

        if (!c.dialout && (strlen(c.num[CALLING]) > 3) && !getSpecial(c.num[CALLING])) {
          sprintf(s, "0%s", c.num[CALLING] + 3);

          if (getSpecial(s)) {
            if (verbose)
              fprintf(stderr, "REPAIR: Caller %s -> %s\n", c.num[CALLING], s);

            strcpy(c.num[CALLING], s);
          } /* if */
        } /* if */


        go = 0;

        if (showoutgoing && c.dialout && c.duration)
          go++;

        if (showincoming && !c.dialout && c.duration)
          go++;

        if (showerrors && !c.duration)
          go++;

        if (*onlythis && strstr(c.num[CALLING], onlythis) == NULL &&
           	      	 strstr(c.num[CALLED], onlythis) == NULL)
          go = 0;

        if (onlytoday && c.connect < now)
          go = 0;

        s0 = 0; /* Externer S0 */

        if (c.dialout && (strlen(c.num[CALLING]) < interns0))
          s0 = 1; /* Interner S0-Bus */

        if (!c.dialout && (strlen(c.num[CALLED]) < interns0))
          s0 = 1; /* Interner S0-Bus */

        if (onlyInternal && !s0)
          go = 0;

        if (onlyExternal && s0)
          go = 0;


        if (go) {
          when(s, &day, &month);

          if (lmonth == UNKNOWN)
            lmonth = month;
          else if (month != lmonth) {
            total(SUBTOTAL);
            lmonth = month;
          } /* if */

          if (lday == UNKNOWN)
            lday = day;
          else if (day != lday) {
            printf("\n");
            lday = day;
          } /* else */

          printf("%s%s ", s, timestr(c.duration));

	  if (*c.num[CALLING])
            normalizeNumber(c.num[CALLING], &number[CALLING], TN_ALL);
          else {
	    memset(&number[CALLING], 0, sizeof(TELNUM));
            strcpy(number[CALLING].msn, "UNKNOWN");
          } /* else */

	  if (*c.num[CALLED])
            normalizeNumber(c.num[CALLED], &number[CALLED], TN_ALL);
          else {
	    memset(&number[CALLED], 0, sizeof(TELNUM));
            strcpy(number[CALLED].msn, "UNKNOWN");
          } /* else */

          findme();

          indent = 11 + strlen(c.currency);

          if (c.dialout) {

            findrate();

            msnsum[SUBTOTAL][c.si1][c.ihome].ncalls++;

            justify(number[CALLING].msn, c.num[CALLED], number[CALLED]);

            provsum[SUBTOTAL][c.provider].ncalls++;

            strcpy(s, getProvider(pnum2prefix(c.provider, c.connect)));
            s[PROVLEN] = 0;

            if (c.provider < 100)
              sprintf(c.sprovider, "  010%02d:%-*s", c.provider, PROVLEN, s);
            else if (c.provider < 200)
              sprintf(c.sprovider, "0100%03d:%-*s", c.provider - 100, PROVLEN, s);
            else
              sprintf(c.sprovider, "01900%02d:%-*s", c.provider - 200, PROVLEN, s);


            if (c.duration) {

#if 0 // Berechnung, um wieviel es mit AktivPlus der DTAG billiger waere -- stimmt irgendwie eh nicht mehr ...

              if ((preselect == DTAG) && ((c.zone == 1) || (c.zone == 2))) {
                auto struct tm *tm = localtime(&c.connect);
                auto int        takte;
                auto double     price;


                takte = (c.duration + 59) / 60;

                if ((tm->tm_wday > 0) && (tm->tm_wday < 5)) {   /* Wochentag */
                  if ((tm->tm_hour > 8) && (tm->tm_hour < 18))  /* Hauptzeit */
                    price = 0.06;
                  else
                    price = 0.03;
                }
                else                                            /* Wochenende */
                  price = 0.03;

                c.aktiv = takte * price;

                msnsum[SUBTOTAL][c.si1][c.ihome].aktiv += c.aktiv;
                provsum[SUBTOTAL][c.provider].aktiv += c.aktiv;
                zonesum[SUBTOTAL][c.zone].aktiv += c.aktiv;
              } /* if */
#endif

              if (c.pay < 0.0) { /* impossible! */
                c.pay = c.compute;
                c.computed++;
              } /* if */

              if (force || fabs(c.pay - c.compute) > 1.00) {
                c.pay = c.compute;
                c.computed++;
              } /* if */

              if (netto)
                c.pay = c.pay * 100.0 / 116.0;

              if (c.pay)
                printf("%12s%s ", printRate(c.pay), c.computed ? "*" : " ");
              else
                printf("%*s", indent, "");

              printf("%s%s%s", c.country, c.sprovider, c.error);

#if 0
              if (c.aktiv)
                printf(" AktivPlus - %13s", printRate(c.pay - c.aktiv));
#endif

              msnsum[SUBTOTAL][c.si1][c.ihome].pay += c.pay;
              msnsum[SUBTOTAL][c.si1][c.ihome].duration += c.duration;
              msnsum[SUBTOTAL][c.si1][c.ihome].compute += c.compute;
              msnsum[SUBTOTAL][c.si1][c.ihome].ibytes += c.ibytes;
              msnsum[SUBTOTAL][c.si1][c.ihome].obytes += c.obytes;

              provsum[SUBTOTAL][c.provider].pay += c.pay;
              provsum[SUBTOTAL][c.provider].duration += c.duration;
              provsum[SUBTOTAL][c.provider].compute += c.compute;
              provsum[SUBTOTAL][c.provider].ibytes += c.ibytes;
              provsum[SUBTOTAL][c.provider].obytes += c.obytes;

              zonesum[SUBTOTAL][c.zone].pay += c.pay;
              zonesum[SUBTOTAL][c.zone].duration += c.duration;
              zonesum[SUBTOTAL][c.zone].compute += c.compute;
              zonesum[SUBTOTAL][c.zone].ibytes += c.ibytes;
              zonesum[SUBTOTAL][c.zone].obytes += c.obytes;
            }
            else {
              printf("%*s%s%s", indent, "", c.country, c.sprovider);

              if ((c.cause != 0x1f) && /* Normal, unspecified */
                  (c.cause != 0x10))   /* Normal call clearing */
                printf(" %s", qmsg(TYPE_CAUSE, VERSION_EDSS1, c.cause));

              if ((c.cause == 0x22) || /* No circuit/channel available */
                  (c.cause == 0x2a) || /* Switching equipment congestion */
                  (c.cause == 0x2f))   /* Resource unavailable, unspecified */
                provsum[SUBTOTAL][c.provider].failed++;
            } /* else */
          }
          else { /* Dialin: */
            justify(number[CALLED].msn, c.num[CALLING], number[CALLING]);
            printf("%*s%s%s", indent, "", c.country, c.sprovider);
          } /* else */


          if (c.known[OTHER] == UNKNOWN) {
            l = UNKNOWN;

            for (i = 0; i < nunknown[c.dialout]; i++) {
              if (!strcmp(unknown[c.dialout][i].num, c.num[OTHER])) {
                l = i;
                break;
              } /* if */
            } /* for */

            if (l == UNKNOWN) {
              l = nunknown[c.dialout];

              nunknown[c.dialout]++;

              if (!l)
                unknown[c.dialout] = (PARTNER *)malloc(sizeof(PARTNER));
              else
                unknown[c.dialout] = (PARTNER *)realloc(unknown[c.dialout], sizeof(PARTNER) * nunknown[c.dialout]);

              memset(&unknown[c.dialout][l], 0, sizeof(PARTNER));
            } /* if */

            strcpy(unknown[c.dialout][l].num, c.num[OTHER]);

            unknown[c.dialout][l].ihome = c.ihome;
            unknown[c.dialout][l].ncalls++;
            unknown[c.dialout][l].pay += c.pay;
            unknown[c.dialout][l].duration += c.duration;
            unknown[c.dialout][l].compute += c.compute;
            unknown[c.dialout][l].ibytes += c.ibytes;
            unknown[c.dialout][l].obytes += c.obytes;
          }
          else {
            strcpy(partner[c.dialout][c.known[OTHER]].num, c.num[OTHER]);
            partner[c.dialout][c.known[OTHER]].ncalls++;
            partner[c.dialout][c.known[OTHER]].pay += c.pay;
            partner[c.dialout][c.known[OTHER]].duration += c.duration;
            partner[c.dialout][c.known[OTHER]].compute += c.compute;
            partner[c.dialout][c.known[OTHER]].ibytes += c.ibytes;
            partner[c.dialout][c.known[OTHER]].obytes += c.obytes;
          } /* else */

          printf("\n");

        } /* if */
      } /* while */

      fclose(f);
      total(SUBTOTAL);

      if (!onlytoday)
        total(TOTAL);

      showpartner();

    }
    else
      fprintf(stderr, "%s: Can't read configuration file(s)\n", myname);
  }
  else
    fprintf(stderr, "%s: Can't open \"isdn.log\" file\n", myname);

  return(0);
} /* isdnbill */
Пример #16
0
/*!
    shape() processes the information encapsulated by GR_ShapingInfo
    si and stores results in GR_*RenderInfo* pri.

    If the contents of pri are NULL the function must create a new
    instance of GR_*RenderInfo of the appropriate type and store the
    pointer in pri; it also must store pointer to this graphics
    instance in pri->m_pGraphics.

    If ri indicates that the text is justified, appropriate processing
    needs to be done

    This function is tied closely together to a class derrived from
    GR_RenderInfo which may contain caches of various data that will
    speed subsequent calls to prepareToRenderChars() and renderChars()
*/
bool GR_Graphics::shape(GR_ShapingInfo & si, GR_RenderInfo *& pri)
{
	if(!si.m_pItem || si.m_pItem->getType() == GRScriptType_Void || !si.m_pFont)
		return false;

	if(!pri)
	{
		pri = new GR_XPRenderInfo(si.m_pItem->getType());
		UT_return_val_if_fail(pri, false);
		pri->m_pGraphics = this;
	}

	GR_XPRenderInfo * pRI = (GR_XPRenderInfo *)pri;

	const GR_Font *pFont = si.m_pFont;
	
	// make sure that the buffers are of sufficient size ...
	if(si.m_iLength > pRI->m_iBufferSize) //buffer too small, reallocate
	{
		delete[] pRI->m_pChars;
		delete[] pRI->m_pWidths;
			
		pRI->m_pChars = new UT_UCS4Char[si.m_iLength + 1];
		UT_return_val_if_fail(pRI->m_pChars, false);

		pRI->m_pWidths = new UT_sint32[si.m_iLength + 1];
		UT_return_val_if_fail(pRI->m_pWidths, false);

		pRI->m_iBufferSize = si.m_iLength + 1;
	}

	pRI->m_iLength = si.m_iLength;
	pRI->m_iTotalLength = si.m_iLength;
	pRI->m_eScriptType = si.m_pItem->getType();
	pRI->m_pItem = si.m_pItem;

	UT_UCS4Char glyph, current;
	UT_UCS4Char * dst_ptr = pRI->m_pChars;
	bool previousWasSpace = si.m_previousWasSpace;

	for(UT_sint32 i = 0; i < si.m_iLength; ++i, ++si.m_Text)
	{
		UT_return_val_if_fail(si.m_Text.getStatus() == UTIter_OK, false);
		current = si.m_Text.getChar();

		if (si.m_TextTransform == GR_ShapingInfo::LOWERCASE)
			current = g_unichar_tolower(current);
		else if (si.m_TextTransform == GR_ShapingInfo::UPPERCASE)
			current = g_unichar_toupper(current);
		else if (si.m_TextTransform == GR_ShapingInfo::CAPITALIZE) {
				if (previousWasSpace) {
					current = g_unichar_toupper(current);
				}
		} // else si.m_TextTransform == GR_ShapingInfo::NONE

		previousWasSpace = g_unichar_isspace(current);

		if(si.m_iVisDir == UT_BIDI_RTL)
			glyph = s_getMirrorChar(current);
		else
			glyph = current;

		if(pFont->doesGlyphExist(glyph))
			*dst_ptr++ = glyph;
		else
		{
			UT_UCS4Char t = s_remapGlyph(glyph);
			if(pFont->doesGlyphExist(t))
			{
				*dst_ptr++ = t;
			}
			else
			{
				*dst_ptr++ = s_cDefaultGlyph;
			}
		}
	}
	
	pRI->m_eState = GRSR_BufferClean;
	
	if(pRI->isJustified())
		justify(*pRI);

	// make sure that we invalidate the static buffers if we own them
	if(pRI->s_pOwner == pRI)
		pRI->s_pOwner = NULL;
	
	return true;
}
Пример #17
0
//! [4]
void MainWindow::createActions()
{
//! [5]
    newAct = new QAction(tr("&New"), this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
//! [4]

    openAct = new QAction(tr("&Open..."), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open an existing file"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
//! [5]

    saveAct = new QAction(tr("&Save"), this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tr("Save the document to disk"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

    printAct = new QAction(tr("&Print..."), this);
    printAct->setShortcuts(QKeySequence::Print);
    printAct->setStatusTip(tr("Print the document"));
    connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

    exitAct = new QAction(tr("E&xit"), this);
    exitAct->setShortcuts(QKeySequence::Quit);
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    undoAct = new QAction(tr("&Undo"), this);
    undoAct->setShortcuts(QKeySequence::Undo);
    undoAct->setStatusTip(tr("Undo the last operation"));
    connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));

    redoAct = new QAction(tr("&Redo"), this);
    redoAct->setShortcuts(QKeySequence::Redo);
    redoAct->setStatusTip(tr("Redo the last operation"));
    connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));

    cutAct = new QAction(tr("Cu&t"), this);
    cutAct->setShortcuts(QKeySequence::Cut);
    cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));

    copyAct = new QAction(tr("&Copy"), this);
    copyAct->setShortcuts(QKeySequence::Copy);
    copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));

    pasteAct = new QAction(tr("&Paste"), this);
    pasteAct->setShortcuts(QKeySequence::Paste);
    pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));

    boldAct = new QAction(tr("&Bold"), this);
    boldAct->setCheckable(true);
    boldAct->setShortcut(QKeySequence::Bold);
    boldAct->setStatusTip(tr("Make the text bold"));
    connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));

    QFont boldFont = boldAct->font();
    boldFont.setBold(true);
    boldAct->setFont(boldFont);

    italicAct = new QAction(tr("&Italic"), this);
    italicAct->setCheckable(true);
    italicAct->setShortcut(QKeySequence::Italic);
    italicAct->setStatusTip(tr("Make the text italic"));
    connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));

    QFont italicFont = italicAct->font();
    italicFont.setItalic(true);
    italicAct->setFont(italicFont);

    setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this);
    setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a "
                                       "paragraph"));
    connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing()));

    setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this);
    setLineSpacingAct->setStatusTip(tr("Change the gap between paragraphs"));
    connect(setParagraphSpacingAct, SIGNAL(triggered()),
            this, SLOT(setParagraphSpacing()));

    aboutAct = new QAction(tr("&About"), this);
    aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAct = new QAction(tr("About &Qt"), this);
    aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));

    leftAlignAct = new QAction(tr("&Left Align"), this);
    leftAlignAct->setCheckable(true);
    leftAlignAct->setShortcut(tr("Ctrl+L"));
    leftAlignAct->setStatusTip(tr("Left align the selected text"));
    connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign()));

    rightAlignAct = new QAction(tr("&Right Align"), this);
    rightAlignAct->setCheckable(true);
    rightAlignAct->setShortcut(tr("Ctrl+R"));
    rightAlignAct->setStatusTip(tr("Right align the selected text"));
    connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign()));

    justifyAct = new QAction(tr("&Justify"), this);
    justifyAct->setCheckable(true);
    justifyAct->setShortcut(tr("Ctrl+J"));
    justifyAct->setStatusTip(tr("Justify the selected text"));
    connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify()));

    centerAct = new QAction(tr("&Center"), this);
    centerAct->setCheckable(true);
    centerAct->setShortcut(tr("Ctrl+E"));
    centerAct->setStatusTip(tr("Center the selected text"));
    connect(centerAct, SIGNAL(triggered()), this, SLOT(center()));

//! [6] //! [7]
    alignmentGroup = new QActionGroup(this);
    alignmentGroup->addAction(leftAlignAct);
    alignmentGroup->addAction(rightAlignAct);
    alignmentGroup->addAction(justifyAct);
    alignmentGroup->addAction(centerAct);
    leftAlignAct->setChecked(true);
//! [6]
}
Пример #18
0
void GLFTFont::draw(const wchar_t* text, int length, double adjx, double adjy, const RenderContext& rc) {
  if ( justify( width(text), height(), adjx, adjy, rc ) ) {
    if (rc.gl2psActive == GL2PS_NONE) 
      font->Render(text);
  }      
}
Пример #19
0
/******************************************************************************
 Function: void stringer(void)

 By: David Schwartz

 Date: Jan 1995

 Parameters: fnt_state - init state information
			 fnt_buffer - set to text to print
			 current_proc->pa8 - ptr to fnt_buffer

			str_flags - insert:justify
			bit 17 = set the "no_scroll" bit in oflags2
			bit 16 = 1 insert on obj list
			bit 15 = 1 shadow the characters that get kicked out

			justify =  0 left justify
					   1 center justify
					   2 right justify

 Returns: None

 Description:	read fnt_buffer and create an object lists of text to display
******************************************************************************/
void stringer(void)
{
	LONG str_flags;
	short b2;				// emul b2 register
	XYTYPE initpos;		// a3
	char cur_char;
	FNTTPAGE *fptr;
	OBJECT *obj,*tobj;			// current object

	/* setup correct flag state */
	switch (fnt_state.fnt_routine)
	{
		case STRCNRMOS:
			str_flags=0x18001;
			break;
		case STRCNRMOS_SCR:
			str_flags=0x18001|STR_SCROLL;
			break;
		case STRLNRMOS_SCR:
			str_flags=0x18000|STR_SCROLL;
			break;
		case STRRNRMOS_SCR:
			str_flags=0x18002|STR_SCROLL;
			break;
		case STRCNRMO_SCR:
			str_flags=0x10001|STR_SCROLL;
			break;
		case STRLNRMO_SCR:
			str_flags=0x10002|STR_SCROLL;
			break;
		case STRRNRMO_SCR:
			str_flags=0x10000|STR_SCROLL;
			break;
	}

	string_underline=0;			// clear shadowing and underling flag
	(char *)current_proc->pa8=fnt_buffer;			// set to start of string to display

	string_shadow=(str_flags & STR_SHADOW) ? 1:0;

	/* stringer_noshad */
	spacing();

	initpos.u.xpos=fnt_state.fnt_posx;
	initpos.u.ypos=fnt_state.fnt_posy;

	justify(str_flags & STR_JUSTIFY);

	/* stringr2 */
	while (((short)*((char *)current_proc->pa8))!=0)
	{
		cur_char=*((char *)current_proc->pa8);
		((char *)(current_proc->pa8))++;					// next char
		b0=0;					// not a space, yet

		if (cur_char<' ')
		{
			/* control character */
			switch ((short)cur_char)
			{
				case NEW_XY:
					fnt_state.fnt_posx=(short)(*((char *)(current_proc->pa8)));
					((char *)(current_proc->pa8))++;					// next char
					fnt_state.fnt_posy=(short)(*((char *)(current_proc->pa8)));
					((char *)(current_proc->pa8))++;					// next char
					break;
				case NEW_SPACING:
					fnt_state.fnt_spacing=(WORD)(*((char *)(current_proc->pa8)));
					((char *)(current_proc->pa8))++;					// next char
					break;
				case ASCII_CR:
					fnt_state.fnt_posx=initpos.u.xpos;			// get back to where we started
					fnt_state.fnt_posy=initpos.u.ypos+fnt_spacing.u.ypos;	// move down 1 line
					initpos.u.xpos=fnt_state.fnt_posx;		// store position
					initpos.u.ypos=fnt_state.fnt_posy;
					justify(str_flags & STR_JUSTIFY);
					break;
				case ADD_DYDX:
					fnt_state.fnt_posx+=((short)(*((char *)(current_proc->pa8))));		// add delta x
					((char *)(current_proc->pa8))++;					// next char
					fnt_state.fnt_posy+=((short)(*((char *)(current_proc->pa8))));			// add delta y
					((char *)(current_proc->pa8))++;					// next char
					break;
			}
		}
		else
		{
			if (cur_char==' ')
			{
				/* spacing info setup */
				b2=fnt_state.fnt_posx;
				fnt_state.fnt_posx+=(fnt_spacing.u.xpos+fnt_state.fnt_spacing);

				if (string_underline==0)
					goto SKIP_DRAW;

				b0=b2;
				b2=fnt_state.fnt_posx;		// swap locations
				fnt_state.fnt_posx=b0;

				b0=1;
				cur_char='a';

				goto SKIP_DRAW;
			}

			/* strnchar, legal character draw time */
			fptr=(font_lists[fnt_state.fnt_num].f_ptr)+((WORD)cur_char-0x21);		// get ptr to correct character

			if (text_draw==1) 
			{
				
					setXY4(cdb->curr_prim, \
						fnt_state.fnt_posx,fnt_state.fnt_posy, \
						fnt_state.fnt_posx+fptr->w,fnt_state.fnt_posy, \
						fnt_state.fnt_posx,fnt_state.fnt_posy+fptr->h, \
						fnt_state.fnt_posx+fptr->w,fnt_state.fnt_posy+fptr->h);

					SetUVWH(cdb->curr_prim,fptr->u0,	\
							fptr->v0, \
							fptr->w, \
							fptr->h);

					cdb->curr_prim->tpage=font_lists[fnt_state.fnt_num].f_tpage;
					cdb->curr_prim->clut=get_fore_pal(fnt_state.fnt_pal);
					DrawPrim(cdb->curr_prim);
					DrawSync(0);
				
			}
			else
			{
				if ((obj=get_object())!=NULL)
				{
					obj->oflags2=0;

					if (str_flags & STR_SCROLL)
						obj->oflags2|=M_NOSCROLL;		// set no scroll bit

					obj->osag=fptr;

					obj->oxvel.pos=0;			// clear out position & vel info
					obj->oyvel.pos=0;
					obj->oxpos.pos=0;
					obj->oypos.pos=0;

#if CD_DEBUG
					if ( f_cdbug==1 )
					{
						obj->oid=OID_CD;				// stuff findable ID
						obj->opal=get_fore_pal(YELLOW_p);
						obj->ozval=1000;
					}
					else
					{
						obj->oid=OID_TEXT;				// stuff findable ID
						obj->opal=get_fore_pal(fnt_state.fnt_pal);
						obj->ozval=1;
					}
#else
					obj->oid=OID_TEXT;				// stuff findable ID
					obj->opal=get_fore_pal(fnt_state.fnt_pal);
					obj->ozval=1;
#endif

					obj->oxpos.u.intpos=fnt_state.fnt_posx;		// eliminated anim point stuff
					obj->oypos.u.intpos=fnt_state.fnt_posy;

					/* setup header stuff */
					obj->header.tpage=font_lists[fnt_state.fnt_num].f_tpage;
					obj->header.t_xoffset=(fptr->u0);
					obj->header.t_yoffset=fptr->v0;
					obj->header.t_width=fptr->w;
					obj->header.t_height=fptr->h;

					if (b0==0)
						insert_object(obj,&objlst2);

					/* check for underlining */

					/* check for shadowing */
					if (string_shadow!=0)
					{
						tobj=obj;
						if ((obj=get_object())!=NULL)
						{
							copy_obj(tobj,obj);

							if (fnt_state.fnt_num==FONT_15)
							{
								obj->oxpos.u.intpos+=1;
								obj->oypos.u.intpos+=1;
							}
							else
							{
								obj->oxpos.u.intpos+=1;
								obj->oypos.u.intpos+=1;
							}

							obj->ozval=0;				// normal letters in front of shadows

							obj->opal=get_fore_pal(bpal_black_P);		// shadow is done in black

							insert_object(obj,&objlst2);
						}
					}
				}
			}

			/* strngdun */
			if (b0==0)
			{
				/* if characters is one need special spacing routine */
				if (cur_char=='1')
					fptr++;

				fnt_state.fnt_posx+=(fnt_state.fnt_spacing+fptr->w);	// pass character size and font spacing
			}
			else
			{
				fnt_state.fnt_posx=b2;
			}

			/* strng_bypass_1 */
			if (fnt_state.fnt_sleep!=0)
				process_sleep(fnt_state.fnt_sleep);
		}

SKIP_DRAW:
	}

	/* stringrx */
	return;
}

/******************************************************************************
 Function: void spacing(void)

 By: David Schwartz

 Date: Jan 1995

 Parameters: None

 Returns: fnt_spacing - sets variables with correct spacing

 Description:	set the spacing for the current font
******************************************************************************/
void spacing(void)
{
	FNTTPAGE *fptr;

	if (fnt_state.fnt_num==FONT_15)
	{
		fnt_spacing.u.xpos=SCX(0x0a);
		fnt_spacing.u.ypos=SCY(0x13);
	}
	else
	{
		fptr=font_lists[fnt_state.fnt_num].f_ptr;			// get pointer to font info

		fptr+='H'-0x21;				// USE 'H' for space and newline stuff

		/* x sizing = (x size of 'H')/2 */
		fnt_spacing.u.xpos=(fptr->w)>>1;

		/* x sizing = 3*(y size of 'H')/2 */
		fnt_spacing.u.ypos=(fptr->h)+((fptr->h)>>1);
	}

	return;
}
Пример #20
0
  // separator before 6
  ,{QN("Set foreground color"), NULL, "icon-foreground-color.png", SLOT(foreground_color()), NA }
  ,{QN("Set background color"), NULL, "icon-background-color.png", SLOT(background_color()), NA }
  ,{QN("Insert image"), NULL, "icon-image.png", SLOT(insert_image()), NA }
  ,{QN("Insert link"), NULL, "icon-link.png", SLOT(insert_link()), NA }
  ,{QN("Insert horizontal rule"), NULL, "icon-hr.png", SLOT(insert_hr()), NA }
  ,{QN("Insert unordered list"), NULL, "icon-bullet-list.png", SLOT(insert_unordered_list()), NA }
  ,{QN("Insert ordered list"), NULL, "icon-ordered-list.png", SLOT(insert_ordered_list()), NA }
  ,{QN("Remove format"), NULL, "icon-eraser.png", SLOT(remove_format()), NA }
  ,{QN("Cut"), NULL, "icon-cut.png", NULL, QWebPage::Cut }
  ,{QN("Copy"), NULL, "icon-copy.png", NULL, QWebPage::Copy }
  ,{QN("Paste"), NULL, "icon-paste.png", NULL, QWebPage::Paste }
  ,{QN("Undo"), QN("Ctrl+Z"), "icon-undo.png", NULL, QWebPage::Undo }
  ,{QN("Redo"), NULL, "icon-redo.png", NULL, QWebPage::Redo }
  ,{QN("Align left"), NULL, "icon-align-left.png", SLOT(align_left()), NA }
  ,{QN("Justify"), NULL, "icon-justify.png", SLOT(justify()), NA }
  ,{QN("Align right"), NULL, "icon-align-right.png", SLOT(align_right()), NA }
  ,{QN("Center"), NULL, "icon-center.png", SLOT(center()), NA }
  ,{QN("Indent right"), NULL, "icon-indent-right.png", SLOT(indent_right()), NA }
  ,{QN("Indent left"), NULL, "icon-indent-left.png", SLOT(indent_left()), NA }

#undef NA
#undef QN
};

link_editor::link_editor(QWidget* parent): QDialog(parent)
{
  setWindowTitle(tr("Edit link"));
  QVBoxLayout* layout = new QVBoxLayout(this);
  QGridLayout* grid = new QGridLayout();
  layout->addLayout(grid);