trichview.com

trichview.support




Re: Blocking unicode characters


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/17/2005 21:17:40


const AlienCharsets = ARABIC_CHARSET | HEBREW_CHARSET | SHIFTJIS_CHARSET |

  HANGEUL_CHARSET | JOHAB_CHARSET | GB2312_CHARSET | CHINESEBIG5_CHARSET |

  VIETNAMESE_CHARSET | THAI_CHARSET;


void RemoveAlienText(TCustomRVData* RVData)

{

  int i = RVData->ItemCount-1;

  while (i>=0)

  {

    if (RVData->GetItemStyle(i)>=0 &&


(RVData->GetRVStyle()->TextStyles->Items[RVData->GetItemStyle(i)]->Charset &

AlienCharsets))

    {

      bool SameAsPrev = RVData->GetItem(i)->SameAsPrev;

      bool PageBreak = RVData->GetItem(i)->PageBreakBefore;

      bool BR = RVData->GetItem(i)->BR;

      RVData->DeleteItems(i, 1);

      if (i>0 && RVData->GetItemStyle(i-1)==rvsListMarker &&

         (i==RVData->ItemCount || RVData->IsFromNewLine(i)))

      {

        i--;

        RVData->DeleteItems(i, 1);

      }

      else if (!SameAsPrev && i<RVData->ItemCount &&

        ! RVData->IsFromNewLine(i))

      {

        RVData->GetItem(i)->SameAsPrev = false;

        RVData->GetItem(i)->BR = BR;

        RVData->GetItem(i)->PageBreakBefore = PageBreak;

      }

    }

    else if (RVData->GetItemStyle(i)==rvsTable)

    {

      TRVTableItemInfo* table = (TRVTableItemInfo*)(RVData->GetItem(i));

      for (int r=0; r<table->Rows->Count; r++)

        for (int c=0; c<table->Rows->Items[r]->Count; c++)

          if (table->Cells[r][c])

            RemoveAlienText(table->Cells[r][c]->GetRVData());

    }

    i--;

  }

}


Call:


  RemoveAlienText(RichViewEdit1->RVData);

  RichViewEdit1->ClearUndo();

  RichViewEdit1->Format();


I created and tested this function in Pascal, then translated to C++. I hope

the translation is correct.

The pascal code is below (for any case):


const AlienCharsets = [ARABIC_CHARSET, HEBREW_CHARSET, SHIFTJIS_CHARSET,

  HANGEUL_CHARSET, JOHAB_CHARSET, GB2312_CHARSET, CHINESEBIG5_CHARSET,

  VIETNAMESE_CHARSET, THAI_CHARSET];


procedure RemoveAlienText(RVData: TCustomRVData);

var i,r,c: Integer;

    table: TRVTableItemInfo;

    PageBreak, BR, SameAsPrev: Boolean;

begin

  i := RVData.ItemCount-1;

  while i>=0 do begin

    if (RVData.GetItemStyle(i)>=0) and

       (RVData.GetRVStyle.TextStyles[RVData.GetItemStyle(i)].Charset in

AlienCharsets) then begin

      SameAsPrev := RVData.GetItem(i).SameAsPrev;

      PageBreak := RVData.GetItem(i).PageBreakBefore;

      BR := RVData.GetItem(i).BR;

      RVData.DeleteItems(i, 1);

      if (i>0) and (RVData.GetItemStyle(i-1)=rvsListMarker) and

         ((i=RVData.ItemCount) or RVData.IsFromNewLine(i)) then begin

        dec(i);

        RVData.DeleteItems(i, 1);

        end

      else if not SameAsPrev and (i<RVData.ItemCount) and

        not RVData.IsFromNewLine(i) then begin

        RVData.GetItem(i).SameAsPrev := False;

        RVData.GetItem(i).BR := BR;

        RVData.GetItem(i).PageBreakBefore := PageBreak;

      end;

      end

    else if (RVData.GetItemStyle(i)=rvsTable) then begin

      table := TRVTableItemInfo(RVData.GetItem(i));

      for r := 0 to table.Rows.Count-1 do

        for c := 0 to table.Rows[r].Count-1 do

          if table.Cells[r,c]<>nil then

            RemoveAlienText(table.Cells[r,c].GetRVData);

    end;

    dec(i);

  end;

end;



>

> Dear Sergey,

>

> Could you give me a example (in C++)??

>

> Thanks.

>

> Pieter E.

>

> "Sergey Tkachenko" <svt@trichview.com> wrote:

> >Blocking? I am afraid no.

> >You can only postprocess the document, check charsets of text style, and

> >remove text of undesired charsets.

> >

> >

>





Powered by ABC Amber Outlook Express Converter