diff --git a/Database/udfs/funciones.pas b/Database/udfs/funciones.pas index b0001ae5..7a8cbc13 100644 --- a/Database/udfs/funciones.pas +++ b/Database/udfs/funciones.pas @@ -2,234 +2,38 @@ unit funciones; interface -function RtfToText(Cadena: PChar): PChar; cdecl; export; +function RtfToText(const Cadena: PChar): PChar; cdecl; export; implementation uses - Forms, Classes, SysUtils, StdCtrls, ComCtrls; + Windows, Forms, Classes, SysUtils, StdCtrls, ComCtrls; -// Esta función falla cuando hay caracteres especiales en el texto (ñ, por ejemplo). -// Mejor la de abajo. - -function RtfToText2(Cadena: PChar): PChar; +function RtfToText(const Cadena: PChar): PChar; var - i: integer; - CadenaAux1: String; - + RTFConverter: TRichEdit; + MyStringStream: TStringStream; begin - //Si no tiene ninguna llave no esta guardado como rtf - if (Pos('{', Cadena) = 0) then - Result := Cadena - else - //Esta guardado con rtf - begin - //Quitamos todo lo que está antes de \fs1x - i := Pos('\fs', Cadena); - CadenaAux1 := Copy(Cadena, i, StrLen(Cadena)-1); - - //Quitamos la parte de delante \fs1x - i:= Pos(' ', CadenaAux1); - CadenaAux1 := Copy(PChar(CadenaAux1), i+1, StrLen(PChar(CadenaAux1))-1); - - //Quitamos todo lo de la parte de atras a partir de la primera barra \ que tengamos - i:= Pos('\', CadenaAux1); - CadenaAux1 := Copy(PChar(CadenaAux1), 0, i-1); - - Result := PChar(CadenaAux1); + RTFConverter := TRichEdit.CreateParented(HWND_MESSAGE); + try + MyStringStream := TStringStream.Create(Cadena); + try + RTFConverter.Lines.LoadFromStream(MyStringStream); + RTFConverter.PlainText := True; + RTFConverter.WantReturns := False; + RTFConverter.WordWrap := False; + RTFConverter.Lines.StrictDelimiter := True; + RTFConverter.Lines.Delimiter := #13; + Result := PChar(RTFConverter.Lines.Text); + finally + MyStringStream.Free; + end; + finally + RTFConverter.Free; end; end; - -{ - Convert RTF enabled text to plain. - http://www.delphipraxis.net/topic45179.html -} - -// HAY QUE LIMPIAR LA CADENA DE ENTRADA DE SALTOS DE LÍNEA (#$D#$A) POR QUE -// SI NO, NO ES UNA CADENA CON TEXTO RTF VÁLIDO - -function RtfToText(Cadena: PChar): PChar; -const - SaltoLinea = #13#10; //--> #$D#$A -var - aSource: string; // <- Para almacenar la cadena de entrada sin saltos de línea - Source: string; - NChar: Integer; - - function ProcessGroupRecursevly: string; - - function HexToInt(HexStr: String): Integer; - begin - result := StrToInt('$' + HexStr); - end; - - procedure SkipStar; - var - BracesOpened: Integer; - Escaped: Boolean; - begin - BracesOpened:=1; - Escaped:=false; - while BracesOpened>0 - do begin - Inc (NChar); - case Source [NChar] of - '{': if Escaped - then Escaped:=false - else Inc (BracesOpened); - '}': if Escaped - then Escaped:=false - else Dec (BracesOpened); - '\': Escaped:=not Escaped; - else Escaped:=false; - end; - end; - end; - - function UnicodeCharCode2ANSIChar (aCode: LongInt): Char; - type - TUnicode2ANSITable=array [$0410..$044f] of Char; - const - Unicode2ANSITable: TUnicode2AnsiTable=('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', - 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ'); - begin - if (Low (Unicode2ANSITable)<=aCode) and (aCode<=High (Unicode2ANSITable)) then - UnicodeCharCode2ANSIChar:=Unicode2ANSITable [aCode] - else UnicodeCharCode2ANSIChar:='?'; - end; - - var - Control, NumericValue, TextValue: string; - begin - Result:=''; - Inc (NChar); - while NChar<=Length (Source) - do case Source [NChar] of - '{': Result:=Result+ProcessGroupRecursevly; - '}': begin - Inc (NChar); - Break; - end; - '\': begin - Inc (NChar); - case Source [NChar] of - '''': begin - Result:=Result+Chr (HexToInt (Copy (Source, NChar+1, 2))); - Inc (NChar, 3); - end; - '~': Result:=Result+#$20; - '*': SkipStar; - 'a'..'z': begin - Control:=''; - while Source [NChar] in ['a'..'z'] - do begin - Control:=Control+Source [NChar]; - Inc (NChar); - end; - if Source [NChar]='-' - then begin - NumericValue:=Source [NChar]; - Inc (NChar); - end - else NumericValue:=''; - while Source [NChar] in ['0'..'9'] - do begin - NumericValue:=NumericValue+Source [NChar]; - Inc (NChar); - end; - if Source [NChar]='{' - then ProcessGroupRecursevly; - TextValue:=''; - if not (Source [NChar] in ['a'..'z', '{', '}', '\']) - then begin - Inc (NChar); - while not (Source [NChar] in ['{', '}', '\']) - do begin - TextValue:=TextValue+Source [NChar]; - Inc (NChar); - end; - end; - if (Control='line') or (Control='par') - then Result:=Result+#$0D#$0A - else if Control='tab' - then Result:=Result+#$09 - else if Control='u' - then Result:=Result+UnicodeCharCode2ANSIChar (StrToInt (NumericValue)) - else if Control='colortbl' - then TextValue:=''; - if Length (TextValue)>0 - then if (not ((TextValue [Length (TextValue)]=';') and (Source [NChar]='}'))) - then begin - Result:=Result+TextValue; - TextValue:=''; - end; - end; - else begin - Result:=Result+Source [NChar]; - Inc (NChar); - end; - end; - end; - else begin - Result:=Result+Source [NChar]; - Inc (NChar); - end; - end; - end; - - function InitSource: Boolean; - var - BracesCount: Integer; - Escaped: Boolean; - begin - if Copy (aSource, 1, 5) <> '{\rtf' then - InitSource:=false - else begin - Source:=''; - BracesCount:=0; - Escaped:=false; - NChar:=1; - while (NChar<=Length (aSource)) and (BracesCount>=0) - do begin - if not (aSource [NChar] in [#$0D, #$0A]) - then begin - Source:=Source+aSource [NChar]; - case aSource [NChar] of - '{': if not Escaped - then Inc (BracesCount) - else Escaped:=false; - '}': if not Escaped - then Dec (BracesCount) - else Escaped:=false; - '\': Escaped:=true; - else Escaped:=false; - end; - end; - Inc (NChar); - end; - InitSource:=BracesCount=0; - end; - end; - -begin - // Hay que quitar el salto de línea al final de la aSource RTF - aSource := Copy(Cadena, 1, length(Cadena)-2); - - // Cambiar los saltos de línea que no son de RTF por un caracter para - // que se limpien. - aSource := StringReplace(aSource, SaltoLinea, '^', [rfreplaceall]); - - if InitSource then - begin - NChar:=1; - Result:= PChar(ProcessGroupRecursevly); - end - else - Result := PChar(aSource); -end; - end. diff --git a/Database/udfs/udf_RtfToText.dll b/Database/udfs/udf_RtfToText.dll index d326ff57..1d297121 100644 Binary files a/Database/udfs/udf_RtfToText.dll and b/Database/udfs/udf_RtfToText.dll differ diff --git a/Database/udfs/udf_RtfToText.dproj b/Database/udfs/udf_RtfToText.dproj index 5ba99a5d..ec92f59f 100644 --- a/Database/udfs/udf_RtfToText.dproj +++ b/Database/udfs/udf_RtfToText.dproj @@ -1,8 +1,9 @@ - + + {5eb7350e-c612-4139-a532-3b8a4617e544} udf_RtfToText.dpr - Debug + Release AnyCPU DCC32 udf_RtfToText.dll @@ -12,8 +13,7 @@ False False 0 - 3 - EUREKALOG;EUREKALOG_VER5;RELEASE + RELEASE 7.0 @@ -24,10 +24,9 @@ Delphi.Personality -FalseTrueFalse +FalseTrueFalseFalseFalse1000FalseFalseFalseFalseFalse308212521.0.0.01.0.0.0 - FalseFalse1000FalseFalseFalseFalseFalse308212521.0.0.01.0.0.0 @@ -39,65 +38,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Muststang Peak EasyListview Runtime Package - RemObjects Pascal Script - RemObjects SDK 3.0 Integration + ExpressPrinting System by Developer Express Inc. + ExpressQuantumTreeList 4 by Developer Express Inc. + ExpressVerticalGrid by Developer Express Inc. + ExpressDocking Library by Developer Express Inc. + ExpressSpellChecker by Developer Express Inc. + ExpressPrinting System ReportLink for ExpressQuantumTreeList 4 by Developer Express Inc. + ExpressPrinting System ReportLink for ExpressVerticalGrid by Developer Express Inc. udf_RtfToText.dpr diff --git a/Database/udfs/udf_RtfToText.drc b/Database/udfs/udf_RtfToText.drc index 433507d3..340333de 100644 --- a/Database/udfs/udf_RtfToText.drc +++ b/Database/udfs/udf_RtfToText.drc @@ -8,78 +8,88 @@ resources were bound to the produced executable. */ -#define Consts_SDockZoneHasNoCtl 65312 -#define Consts_SDockZoneVersionConflict 65313 -#define Consts_SANSIEncoding 65314 -#define Consts_SASCIIEncoding 65315 -#define Consts_SUnicodeEncoding 65316 -#define Consts_SBigEndianEncoding 65317 -#define Consts_SUTF8Encoding 65318 -#define Consts_SUTF7Encoding 65319 -#define Consts_SmkcEnd 65328 -#define Consts_SmkcHome 65329 -#define Consts_SmkcLeft 65330 -#define Consts_SmkcUp 65331 -#define Consts_SmkcRight 65332 -#define Consts_SmkcDown 65333 -#define Consts_SmkcIns 65334 -#define Consts_SmkcDel 65335 -#define Consts_SmkcShift 65336 -#define Consts_SmkcCtrl 65337 -#define Consts_SmkcAlt 65338 -#define Consts_SIconToClipboard 65339 -#define Consts_SDuplicateMenus 65340 -#define Consts_SDockedCtlNeedsName 65341 -#define Consts_SDockTreeRemoveError 65342 -#define Consts_SDockZoneNotFound 65343 -#define Consts_SMsgDlgOK 65344 -#define Consts_SMsgDlgCancel 65345 -#define Consts_SMsgDlgHelp 65346 -#define Consts_SMsgDlgAbort 65347 -#define Consts_SMsgDlgRetry 65348 -#define Consts_SMsgDlgIgnore 65349 -#define Consts_SMsgDlgAll 65350 -#define Consts_SMsgDlgNoToAll 65351 -#define Consts_SMsgDlgYesToAll 65352 -#define Consts_SmkcBkSp 65353 -#define Consts_SmkcTab 65354 -#define Consts_SmkcEsc 65355 -#define Consts_SmkcEnter 65356 -#define Consts_SmkcSpace 65357 -#define Consts_SmkcPgUp 65358 -#define Consts_SmkcPgDn 65359 -#define Consts_SCancelButton 65360 -#define Consts_SYesButton 65361 -#define Consts_SNoButton 65362 -#define Consts_SHelpButton 65363 -#define Consts_SCloseButton 65364 -#define Consts_SIgnoreButton 65365 -#define Consts_SRetryButton 65366 -#define Consts_SAbortButton 65367 -#define Consts_SAllButton 65368 -#define Consts_SCannotDragForm 65369 -#define Consts_SMsgDlgWarning 65370 -#define Consts_SMsgDlgError 65371 -#define Consts_SMsgDlgInformation 65372 -#define Consts_SMsgDlgConfirm 65373 -#define Consts_SMsgDlgYes 65374 -#define Consts_SMsgDlgNo 65375 +#define ComStrs_sRichEditLoadFail 65296 +#define ComStrs_sRichEditSaveFail 65297 +#define Consts_SIconToClipboard 65312 +#define Consts_SInvalidMemoSize 65313 +#define Consts_SNoDefaultPrinter 65314 +#define Consts_SDuplicateMenus 65315 +#define Consts_SDockedCtlNeedsName 65316 +#define Consts_SDockTreeRemoveError 65317 +#define Consts_SDockZoneNotFound 65318 +#define Consts_SDockZoneHasNoCtl 65319 +#define Consts_SDockZoneVersionConflict 65320 +#define Consts_SANSIEncoding 65321 +#define Consts_SASCIIEncoding 65322 +#define Consts_SUnicodeEncoding 65323 +#define Consts_SBigEndianEncoding 65324 +#define Consts_SUTF8Encoding 65325 +#define Consts_SUTF7Encoding 65326 +#define ComStrs_sRichEditInsertError 65327 +#define Consts_SmkcEsc 65328 +#define Consts_SmkcEnter 65329 +#define Consts_SmkcSpace 65330 +#define Consts_SmkcPgUp 65331 +#define Consts_SmkcPgDn 65332 +#define Consts_SmkcEnd 65333 +#define Consts_SmkcHome 65334 +#define Consts_SmkcLeft 65335 +#define Consts_SmkcUp 65336 +#define Consts_SmkcRight 65337 +#define Consts_SmkcDown 65338 +#define Consts_SmkcIns 65339 +#define Consts_SmkcDel 65340 +#define Consts_SmkcShift 65341 +#define Consts_SmkcCtrl 65342 +#define Consts_SmkcAlt 65343 +#define Consts_SMsgDlgError 65344 +#define Consts_SMsgDlgInformation 65345 +#define Consts_SMsgDlgConfirm 65346 +#define Consts_SMsgDlgYes 65347 +#define Consts_SMsgDlgNo 65348 +#define Consts_SMsgDlgOK 65349 +#define Consts_SMsgDlgCancel 65350 +#define Consts_SMsgDlgHelp 65351 +#define Consts_SMsgDlgAbort 65352 +#define Consts_SMsgDlgRetry 65353 +#define Consts_SMsgDlgIgnore 65354 +#define Consts_SMsgDlgAll 65355 +#define Consts_SMsgDlgNoToAll 65356 +#define Consts_SMsgDlgYesToAll 65357 +#define Consts_SmkcBkSp 65358 +#define Consts_SmkcTab 65359 +#define Consts_SDeviceOnPort 65360 +#define Consts_SGroupIndexTooLow 65361 +#define Consts_SNoMDIForm 65362 +#define Consts_SControlParentSetToSelf 65363 +#define Consts_SOKButton 65364 +#define Consts_SCancelButton 65365 +#define Consts_SYesButton 65366 +#define Consts_SNoButton 65367 +#define Consts_SHelpButton 65368 +#define Consts_SCloseButton 65369 +#define Consts_SIgnoreButton 65370 +#define Consts_SRetryButton 65371 +#define Consts_SAbortButton 65372 +#define Consts_SAllButton 65373 +#define Consts_SCannotDragForm 65374 +#define Consts_SMsgDlgWarning 65375 #define Consts_SImageWriteFail 65376 #define Consts_SWindowDCError 65377 #define Consts_SWindowClass 65378 #define Consts_SCannotFocus 65379 #define Consts_SParentRequired 65380 -#define Consts_SMDIChildNotVisible 65381 -#define Consts_SVisibleChanged 65382 -#define Consts_SCannotShowModal 65383 -#define Consts_SMenuIndexError 65384 -#define Consts_SMenuReinserted 65385 -#define Consts_SMenuNotFound 65386 -#define Consts_SNoTimers 65387 -#define Consts_SGroupIndexTooLow 65388 -#define Consts_SNoMDIForm 65389 -#define Consts_SControlParentSetToSelf 65390 -#define Consts_SOKButton 65391 +#define Consts_SParentGivenNotAParent 65381 +#define Consts_SMDIChildNotVisible 65382 +#define Consts_SVisibleChanged 65383 +#define Consts_SCannotShowModal 65384 +#define Consts_SMenuIndexError 65385 +#define Consts_SMenuReinserted 65386 +#define Consts_SMenuNotFound 65387 +#define Consts_SNoTimers 65388 +#define Consts_SNotPrinting 65389 +#define Consts_SPrinting 65390 +#define Consts_SInvalidPrinter 65391 #define RTLConsts_SWriteError 65392 #define HelpIntfs_hNoTableOfContents 65393 #define HelpIntfs_hNothingFound 65394 @@ -226,6 +236,15 @@ #define SysConst_SOverflow 65535 STRINGTABLE BEGIN + ComStrs_sRichEditLoadFail, "Failed to Load Stream" + ComStrs_sRichEditSaveFail, "Failed to Save Stream" + Consts_SIconToClipboard, "Clipboard does not support Icons" + Consts_SInvalidMemoSize, "Text exceeds memo capacity" + Consts_SNoDefaultPrinter, "There is no default printer currently selected" + Consts_SDuplicateMenus, "Menu '%s' is already being used by another form" + Consts_SDockedCtlNeedsName, "Docked control must have a name" + Consts_SDockTreeRemoveError, "Error removing control from dock tree" + Consts_SDockZoneNotFound, " - Dock zone not found" Consts_SDockZoneHasNoCtl, " - Dock zone has no control" Consts_SDockZoneVersionConflict, "Error loading dock zone from the stream. Expecting version %d, but found %d." Consts_SANSIEncoding, "ANSI" @@ -234,6 +253,12 @@ BEGIN Consts_SBigEndianEncoding, "Big Endian Unicode" Consts_SUTF8Encoding, "UTF-8" Consts_SUTF7Encoding, "UTF-7" + ComStrs_sRichEditInsertError, "RichEdit line insertion error" + Consts_SmkcEsc, "Esc" + Consts_SmkcEnter, "Enter" + Consts_SmkcSpace, "Space" + Consts_SmkcPgUp, "PgUp" + Consts_SmkcPgDn, "PgDn" Consts_SmkcEnd, "End" Consts_SmkcHome, "Home" Consts_SmkcLeft, "Left" @@ -245,11 +270,11 @@ BEGIN Consts_SmkcShift, "Shift+" Consts_SmkcCtrl, "Ctrl+" Consts_SmkcAlt, "Alt+" - Consts_SIconToClipboard, "Clipboard does not support Icons" - Consts_SDuplicateMenus, "Menu '%s' is already being used by another form" - Consts_SDockedCtlNeedsName, "Docked control must have a name" - Consts_SDockTreeRemoveError, "Error removing control from dock tree" - Consts_SDockZoneNotFound, " - Dock zone not found" + Consts_SMsgDlgError, "Error" + Consts_SMsgDlgInformation, "Information" + Consts_SMsgDlgConfirm, "Confirm" + Consts_SMsgDlgYes, "&Yes" + Consts_SMsgDlgNo, "&No" Consts_SMsgDlgOK, "OK" Consts_SMsgDlgCancel, "Cancel" Consts_SMsgDlgHelp, "&Help" @@ -261,11 +286,11 @@ BEGIN Consts_SMsgDlgYesToAll, "Yes to &All" Consts_SmkcBkSp, "BkSp" Consts_SmkcTab, "Tab" - Consts_SmkcEsc, "Esc" - Consts_SmkcEnter, "Enter" - Consts_SmkcSpace, "Space" - Consts_SmkcPgUp, "PgUp" - Consts_SmkcPgDn, "PgDn" + Consts_SDeviceOnPort, "%s on %s" + Consts_SGroupIndexTooLow, "GroupIndex cannot be less than a previous menu item's GroupIndex" + Consts_SNoMDIForm, "Cannot create form. No MDI forms are currently active" + Consts_SControlParentSetToSelf, "A control cannot have itself as its parent" + Consts_SOKButton, "OK" Consts_SCancelButton, "Cancel" Consts_SYesButton, "&Yes" Consts_SNoButton, "&No" @@ -277,16 +302,12 @@ BEGIN Consts_SAllButton, "&All" Consts_SCannotDragForm, "Cannot drag a form" Consts_SMsgDlgWarning, "Warning" - Consts_SMsgDlgError, "Error" - Consts_SMsgDlgInformation, "Information" - Consts_SMsgDlgConfirm, "Confirm" - Consts_SMsgDlgYes, "&Yes" - Consts_SMsgDlgNo, "&No" Consts_SImageWriteFail, "Failed to write ImageList data to stream" Consts_SWindowDCError, "Error creating window device context" Consts_SWindowClass, "Error creating window class" Consts_SCannotFocus, "Cannot focus a disabled or invisible window" Consts_SParentRequired, "Control '%s' has no parent window" + Consts_SParentGivenNotAParent, "Parent given is not a parent of '%s'" Consts_SMDIChildNotVisible, "Cannot hide an MDI Child Form" Consts_SVisibleChanged, "Cannot change Visible in OnShow or OnHide" Consts_SCannotShowModal, "Cannot make a visible window modal" @@ -294,10 +315,9 @@ BEGIN Consts_SMenuReinserted, "Menu inserted twice" Consts_SMenuNotFound, "Sub-menu is not in menu" Consts_SNoTimers, "Not enough timers available" - Consts_SGroupIndexTooLow, "GroupIndex cannot be less than a previous menu item's GroupIndex" - Consts_SNoMDIForm, "Cannot create form. No MDI forms are currently active" - Consts_SControlParentSetToSelf, "A control cannot have itself as its parent" - Consts_SOKButton, "OK" + Consts_SNotPrinting, "Printer is not currently printing" + Consts_SPrinting, "Printing in progress" + Consts_SInvalidPrinter, "Printer selected is not valid" RTLConsts_SWriteError, "Stream write error" HelpIntfs_hNoTableOfContents, "Unable to find a Table of Contents" HelpIntfs_hNothingFound, "No help found for %s"