Beiträge von dex

    Hi,

    I am trying to do hyphenation based on text language. If document contains text in several languages, I need to use hyphenation rules appropriate for each language.

    To achieve this, I need Text Language attribute.

    MS Word adjust text language attribute (or, for RTF \lang RTF tag) according to the current keyboard layout.

    Zitat


    Character Formatting
    ...
    \langN -- language N

    US English: 1033 MX Spanish: 2058 French: 1036
    Turkish: 1055 No language: 1024

    Can WPTools read, use and write \lang RTF tag? If currently not supported, is it among planned features?

    Apologies for this rather basic question, but I cannot find the correct way to load RTF or HTML files, nor those that require use of converters.

    Currently, I use LoadFromFile procedure for RTF, but when loaded, document is shown with squares (whole document or just some parts). If I load that same document in WPdemo, or even in default editor in design time, everything is shown correctly, so it not about the document itself.

    I have also tried to use format options (RTF-codepage:xxxx) AUTO, etc. to no avail. RTF code itself contains information about the codepage.

    LoadWithConverters works, I can select and load .doc or .docx files, however they are also shown incorrectly, with squares.

    What settings control the way documents are loaded into the control?

    Hi,

    I am trying to make a demo version of my application. I want to show protected predefined text, which still can be changed through spell checking (Addict), changing of font attributes, hyphenating text, etc. In order to prevent users from inserting their own text I have disabled Paste and Open File functions.

    Setting ppParProtected to ProtectedProp for every paragraph, and saving Demo text document in wpt format seems to do the job. Loading this document at run-time keeps the text protected.

    However, when I load Demo text document with protected paragraphs in design mode into WPTools default editor, text is no longer protected (users can enter their own text by typing).

    Is it possible to have protected predefined text appear in WPTools editor which is loaded at design time, rather than at run-time?

    Or, is there some other way to achieve predefined protected text in the editor?

    Thanks!
    Dex

    Hi,

    I had the same problem with selection of the text becoming invisible after changing HighlightTextColor. Also, selection of cell, row, column or table also became invisible.

    After unchecking wpDontExtendSelectionToRightMargin in ViewOptionsEx, all went back to normal again.

    I am using wp 6.25.4, on WinXP.

    Hi,

    Suppose I want to hyphenate a word in the following way:

    au¬to¬mat¬i¬cal¬ly

    Using Ctrl+ '-', I manually insert five soft hyphens. However, the word will break only in four positions. It will not break right before letter 'i'.

    It seems that latter soft hyphen somehow disables the former if there is only one character in between.

    How can I get around this behaviour?

    Hi,

    I am trying to localize WP dialogs in Serbian Cyrillic. Everything works fine for languages that use Windows-1250 codepage (DE, IT, EN, ...).

    However, for Serbian Cyrillic I need to use RUSSIAN_CHARSET. Otherwise, labels and other captions show unintelligible letters.

    So, the question is how do I change font charset for dialog forms at runtime?

    I am using WPTools 6.14 Standard and RAD Studion 2010 (C++).

    Thanks!

    Hi,

    I am using wp6 together with addict 4.2.

    There is a problem with IgnoreAll or Add functionality, for Cyrillic text.

    If there are several instances of a misspelled cyrillic word within a text, after choosing IgnoreAll from the context menu, only the word where the cursor was loses its red underline, while other instances not.

    I have narrowed down the problem to the function WPTIgnoreWord in WPTAddict.pas.


    Code
    if par.IsWordDelimiter (i + l) and par.IsWordDelimiter (i - 1) and
                             par.Compare (i, AWord, false) then


    pas.Compare is performing comparison but is not checking for ANSI code pages, as mentioned in Help.

    Do you have a suggestion what alternative function can be used here, which would properly recognize the word and subsequently remove the red underline from all instances?

    Thanks!

    Hi,

    I am trying to change case of the text to UpperCase/LowerCase. After experimenting for quite a while with styles, came to the conclusion that the only "right" way to do it is to use CallForSelectedText method.

    However, I cannot get it to work in C++ :(

    Code
    procedure CharCallback(Sender: TObject;      var CharItem: WideChar;      par: TParagraph;      posinpar: Integer;      var Abort: Boolean);
    Code
    type TWPConvertMode = (wpUppercase, wpLowercase);var ConvertMode: TWPConvertMode;procedure TWPTBXForm.CharCallback(Sender: TObject;  var CharItem: WideChar;  par: TParagraph;  posinpar: Integer;  var Abort: Boolean);begin  { if ConvertMode=wpUppercase then         par.ANSIChr[posinpar] := ANSIUppercase(par.ANSIChr[posinpar])[1]   else if ConvertMode=wpLowercase then         par.ANSIChr[posinpar] := ANSILowercase(par.ANSIChr[posinpar])[1];   }  if ConvertMode = wpUppercase then    CharItem := WideUpperCase(CharItem)[1]  else CharItem := WideLowerCase(CharItem)[1];  include(par.prop, paprMustInit);end;
    Code
    procedure TWPTBXForm.Lowercase(Sender: TObject);
    begin
      ConvertMode := wpLowercase;
      WPRichText1.TextCursor.CallForSelectedText(Self, [], nil, nil, CharCallback, nil);
      WPRichText1.DelayedReformat;
    end;

    Has anyone succesfully implemented CallForSelectedText in C++?
    Basic example would help a lot!

    dex

    Hi,

    Inserting Horizontal Line works perfectly, with code:

    Code
    Editor->TextObjects->InsertNewObject(wpobjHorizontalLine, false, false);

    However, Undo doesn't seem to catch it, not even when I enclose it with StartUndoLevel(), EndUndoLevel().

    Latest WPTools 6 demo also shows the same behaviour.

    What is the proper way to achieve inserting and undoing insertion of a Horizontal Line?

    Dex

    Hi,

    Does anyone knows how can I insert optional hyphen via code?

    Purpose of the optional hyphen (also know as: discretionary, soft) is to mark a possible hyphenation point, 'invisible' point at which a word can be broken.

    Keyboard shortcut is Ctrl + '-' and works great.

    How do I do it in code?

    BR

    Florian,

    It is a general problem with BCB but it can be overcomed!

    Once upon a time I was struggling with it, and then came across a simple unit, which can be compiled and installed in BCB as a new component.

    After installing it, editing Pascal forms becomes possible.

    When I type in some cyrillic characters into WP5.38 demo, save the file as RTF and load it again, text has gone.

    If I load RTF file containing cyrillic text created with WordPad, everything is ok.

    It seems that it is the case not only with cyrillic characters, but all outside CP1252.


    I have located a code in WPIOWRITERTF.PAS, introduced in WP5.38 which seems to be responsible for this behaviour, but I don't know how to fix it.

    How do I load a file which I have saved in WPT file format, using

    wpEditor->OpenDialog(wpdiaSaveAs);


    It is not possible using the code:

    wpEditor->OpenDialog(wpdiaLoad);

    because WPT format (as well as All files) is not listed in Filter list of the Open dialog.

    What am I missing?

    OK, here is a better description, together with my understanding of how it works (Please, correct me where I'm wrong):

    WPTools internally works with Unicode, and Addict works with AnsiStrings.
    Each time a conversion is performed, code page should be taken into account, otherwise results will not be what I expect.

    If I switch to Serbian (Cyrillic) keyboard, and type in some correctly spelled words, WPTools shows them properly because for each character UpdateCodePage function is executed. However, Addict does not recognize them properly, and underlines them as misspelled, because of the code page issue.

    Here is the solution I found:

    In WPTAddict.pas I located a procedure WPOnSpellCheckWord:

    Code
    {$IFDEF WPTOOLS5}procedure TWPTAddictInstance.WPOnSpellCheckWord(Sender: TObject; var Word: WideString;       var Res: TSpellCheckResult; var Hyphen: TSpellCheckHyphen;           par : TParagraph;posinpar : Integer);begin  if (Assigned(FAddictSpell)) and FLiveSpell then  begin    if (FAddictSpell.WordAcceptable(Word)) then...

    Addict's function WordAcceptable will automatically convert Word parameter, using current code page. Therefore, deliberate conversion to Cyrillic codepage was needed:

    Code
    if (FAddictSpell.WordAcceptable(WideStringToStringEx(Word, 1251))) then
    ...

    Now, Addict perfectly singles out only really misspelled words.

    This, however, raises two questions:

    1. I have hardcoded Windows Cyrillic code page 1251, which is bad. Of course, I can use _CodePage variable, but anyway this would imply that only one code page can be supported per document. No mixing of English and Serbian text within one document :( . It would be nice to have this codepage attribute somewhere in word, style or at least paragraph level. Or, this already exists :

    2. Addict also needs to generate suggestions, and to replace misspelled word. Can you please tell me which functions should I analyze, in order to find where else the conversion is needed?