Ticket #146 -> Fallo al copiar y pegar en un presupuesto conceptos desde una hoja de Excel.
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@648 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
fee2708366
commit
da33b733df
@ -112,6 +112,7 @@ contains
|
||||
ClipboardUtils in 'Utiles\ClipboardUtils.pas',
|
||||
uGridClipboardUtils in 'Utiles\uGridClipboardUtils.pas',
|
||||
uReferenciasUtils in 'Utiles\uReferenciasUtils.pas',
|
||||
uEMailUtils in 'Utiles\uEMailUtils.pas';
|
||||
uEMailUtils in 'Utiles\uEMailUtils.pas',
|
||||
uSaveClipboard in 'Utiles\uSaveClipboard.pas';
|
||||
|
||||
end.
|
||||
|
||||
@ -53,57 +53,6 @@
|
||||
<DelphiCompile Include="Base.dpk">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\adortl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxDataD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxEditorsD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxExportD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxExtEditorsD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxGridD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxIntl6D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxIntlPrintSys3D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxLibraryD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\cxPageControlD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\DataAbstract_Core_D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dbrtl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dclIndyCore.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\designide.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dsnap.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dxGDIPlusD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dxPSCoreD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\dxThemeD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\GUISDK_D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\IndyCore.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\IndyProtocols.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\IndySystem.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\Jcl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JclVcl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JSDialog100.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvCmpD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvCoreD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvCtrlsD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvDlgsD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvMMD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvNetD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvPageCompsD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvStdCtrlsD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\JvSystemD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\pckMD5.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\pckUCDataConnector.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\pckUserControl_RT.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\PngComponentsD10.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\PNG_D10.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\RemObjects_Core_D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\RemObjects_Indy_D11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\rtl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\TB2k_D10.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\tbx_d10.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\vcl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\vclactnband.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\vcldb.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\vcljpg.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\VclSmp.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\vclx.dcp" />
|
||||
<DCCReference Include="..\Modulos\Presupuestos de cliente\xmlrtl.dcp" />
|
||||
<DCCReference Include="..\Servicios\FactuGES_Intf.pas" />
|
||||
<DCCReference Include="Conexion\uConfigurarConexion.pas">
|
||||
<Form>fConfigurarConexion</Form>
|
||||
@ -128,12 +77,56 @@
|
||||
<Form>dmBase</Form>
|
||||
<DesignClass>TDataModule</DesignClass>
|
||||
</DCCReference>
|
||||
<DCCReference Include="Utiles\adortl.dcp" />
|
||||
<DCCReference Include="Utiles\ClassRegistry\uClassRegistryUtils.pas" />
|
||||
<DCCReference Include="Utiles\ClassRegistry\uEditorRegistryUtils.pas" />
|
||||
<DCCReference Include="Utiles\ClassRegistry\uInformeRegistryUtils.pas" />
|
||||
<DCCReference Include="Utiles\ClassRegistry\uViewRegistryUtils.pas" />
|
||||
<DCCReference Include="Utiles\ClipboardUtils.pas" />
|
||||
<DCCReference Include="Utiles\Ctltortf.pas" />
|
||||
<DCCReference Include="Utiles\cxDataD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxEditorsD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxExportD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxExtEditorsD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxGridD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxIntl6D11.dcp" />
|
||||
<DCCReference Include="Utiles\cxIntlPrintSys3D11.dcp" />
|
||||
<DCCReference Include="Utiles\cxLibraryD11.dcp" />
|
||||
<DCCReference Include="Utiles\cxPageControlD11.dcp" />
|
||||
<DCCReference Include="Utiles\DataAbstract_Core_D11.dcp" />
|
||||
<DCCReference Include="Utiles\dbrtl.dcp" />
|
||||
<DCCReference Include="Utiles\dclIndyCore.dcp" />
|
||||
<DCCReference Include="Utiles\designide.dcp" />
|
||||
<DCCReference Include="Utiles\dsnap.dcp" />
|
||||
<DCCReference Include="Utiles\dxGDIPlusD11.dcp" />
|
||||
<DCCReference Include="Utiles\dxPSCoreD11.dcp" />
|
||||
<DCCReference Include="Utiles\dxThemeD11.dcp" />
|
||||
<DCCReference Include="Utiles\GUISDK_D11.dcp" />
|
||||
<DCCReference Include="Utiles\IndyCore.dcp" />
|
||||
<DCCReference Include="Utiles\IndyProtocols.dcp" />
|
||||
<DCCReference Include="Utiles\IndySystem.dcp" />
|
||||
<DCCReference Include="Utiles\Jcl.dcp" />
|
||||
<DCCReference Include="Utiles\JclVcl.dcp" />
|
||||
<DCCReference Include="Utiles\JSDialog100.dcp" />
|
||||
<DCCReference Include="Utiles\JvCmpD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvCoreD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvCtrlsD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvDlgsD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvMMD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvNetD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvPageCompsD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvStdCtrlsD11R.dcp" />
|
||||
<DCCReference Include="Utiles\JvSystemD11R.dcp" />
|
||||
<DCCReference Include="Utiles\pckMD5.dcp" />
|
||||
<DCCReference Include="Utiles\pckUCDataConnector.dcp" />
|
||||
<DCCReference Include="Utiles\pckUserControl_RT.dcp" />
|
||||
<DCCReference Include="Utiles\PngComponentsD10.dcp" />
|
||||
<DCCReference Include="Utiles\PNG_D10.dcp" />
|
||||
<DCCReference Include="Utiles\RemObjects_Core_D11.dcp" />
|
||||
<DCCReference Include="Utiles\RemObjects_Indy_D11.dcp" />
|
||||
<DCCReference Include="Utiles\rtl.dcp" />
|
||||
<DCCReference Include="Utiles\TB2k_D10.dcp" />
|
||||
<DCCReference Include="Utiles\tbx_d10.dcp" />
|
||||
<DCCReference Include="Utiles\uAppInfoUtils.pas" />
|
||||
<DCCReference Include="Utiles\uCalculosUtils.pas" />
|
||||
<DCCReference Include="Utiles\uDataTableUtils.pas" />
|
||||
@ -150,8 +143,16 @@
|
||||
<DCCReference Include="Utiles\uPasswordUtils.pas" />
|
||||
<DCCReference Include="Utiles\uReferenciasUtils.pas" />
|
||||
<DCCReference Include="Utiles\uRTFUtils.pas" />
|
||||
<DCCReference Include="Utiles\uSaveClipboard.pas" />
|
||||
<DCCReference Include="Utiles\uSistemaFunc.pas" />
|
||||
<DCCReference Include="Utiles\uStringsUtils.pas" />
|
||||
<DCCReference Include="Utiles\vcl.dcp" />
|
||||
<DCCReference Include="Utiles\vclactnband.dcp" />
|
||||
<DCCReference Include="Utiles\vcldb.dcp" />
|
||||
<DCCReference Include="Utiles\vcljpg.dcp" />
|
||||
<DCCReference Include="Utiles\VclSmp.dcp" />
|
||||
<DCCReference Include="Utiles\vclx.dcp" />
|
||||
<DCCReference Include="Utiles\xmlrtl.dcp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
<!-- EurekaLog First Line
|
||||
|
||||
Binary file not shown.
@ -135,8 +135,9 @@ begin
|
||||
else
|
||||
TargetURL := ROChannel.TargetURL;
|
||||
end;
|
||||
if AHTTPChannel.Encryption.EncryptionMethod <> tetNone then
|
||||
ShowMessage('funcionando');
|
||||
|
||||
{ if AHTTPChannel.Encryption.EncryptionMethod <> tetNone then
|
||||
ShowMessage('funcionando');}
|
||||
|
||||
ACoService.ServiceName := 'srvLogin';
|
||||
ACoService.Message := AROBinMessage;
|
||||
|
||||
@ -6,17 +6,21 @@ uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, cxGrid;
|
||||
|
||||
procedure PegarSeleccionGridDesdePortapapeles (AGrid : TcxGrid);
|
||||
procedure PegarAlGridDesdePortapapeles (AGrid : TcxGrid);
|
||||
procedure CopiarSeleccionGridAlPortapapeles (AGrid : TcxGrid);
|
||||
procedure CortarSeleccionGridAlPortapapeles (AGrid : TcxGrid);
|
||||
function HayDatosEnPortapapeles: Boolean;
|
||||
|
||||
function HayDatosEnPortapapeles(AFormat: Cardinal = 0): Boolean;
|
||||
|
||||
procedure CopiarGridAlPortapapelesRTF (AGrid : TcxGrid; const ASoloSeleccion : Boolean = false);
|
||||
procedure CopiarGridAlPortapapelesHTML (AGrid : TcxGrid; const ASoloSeleccion : Boolean = false);
|
||||
procedure CopiarGridAlPortapapelesTXT (AGrid : TcxGrid; const ASoloSeleccion : Boolean = false);
|
||||
procedure CopiarGridAlPortapapelesExcel (AGrid : TcxGrid; const ASoloSeleccion : Boolean = false);
|
||||
|
||||
var
|
||||
CF_FACTUGES : Cardinal;
|
||||
CF_RTF : Cardinal;
|
||||
CF_HTML: Cardinal;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -26,6 +30,20 @@ uses
|
||||
cxGridTableView, cxGridDBTableView, cxGridDBDataDefinitions, uGridStatusUtils;
|
||||
|
||||
|
||||
procedure RegistrarFormatos;
|
||||
begin
|
||||
CF_FACTUGES := RegisterClipboardFormat ('FactuGES Format');
|
||||
if CF_FACTUGES = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_FACTUGES');
|
||||
|
||||
CF_HTML := RegisterClipboardFormat ('HTML Format');
|
||||
if CF_HTML = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_HTML');
|
||||
|
||||
CF_RTF := RegisterClipboardFormat('Rich Text Format');
|
||||
if CF_RTF = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_RTF (CopiarSeleccionGridAlPortapapelesRTF)');
|
||||
end;
|
||||
|
||||
procedure RenumerarCampoPosicion(ADataSet : TDataSet);
|
||||
var
|
||||
@ -47,6 +65,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function _BuscarColumna (AView: TcxGridDBTableView;
|
||||
const AName, ATypeValue : String; var AIndex : Integer) : Boolean;
|
||||
var
|
||||
i : Integer;
|
||||
bNombreOk : Boolean;
|
||||
begin
|
||||
AIndex := -1;
|
||||
Result := False;
|
||||
for i := 0 to AView.ItemCount - 1 do
|
||||
begin
|
||||
if (AView.Items[i].DataBinding is TcxGridItemDBDataBinding) then
|
||||
with (AView.Items[i].DataBinding as TcxGridItemDBDataBinding) do
|
||||
bNombreOk := (FieldName = AName)
|
||||
else
|
||||
bNombreOk := (AView.Items[i].Caption = AName);
|
||||
|
||||
if bNombreOk and (AView.Items[i].DataBinding.ValueType = ATypeValue) then
|
||||
begin
|
||||
AIndex := i;
|
||||
Result := True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{$REGION 'LoadGridRowsFromStream'}
|
||||
procedure LoadGridRowsFromStream(AView : TcxGridDBTableView; AStream: TStream;
|
||||
@ -67,31 +110,6 @@ var
|
||||
AValue : Variant;
|
||||
AIndex : integer;
|
||||
|
||||
function _BuscarColumna (const AName, ATypeValue : String; var AIndex : Integer) : Boolean;
|
||||
var
|
||||
i : Integer;
|
||||
bNombreOk : Boolean;
|
||||
begin
|
||||
AIndex := -1;
|
||||
Result := False;
|
||||
for i := 0 to AView.ItemCount - 1 do
|
||||
begin
|
||||
if (AView.Items[i].DataBinding is TcxGridItemDBDataBinding) then
|
||||
with (AView.Items[i].DataBinding as TcxGridItemDBDataBinding) do
|
||||
bNombreOk := (FieldName = AName)
|
||||
else
|
||||
bNombreOk := (AView.Items[i].Caption = AName);
|
||||
|
||||
if bNombreOk and (AView.Items[i].DataBinding.ValueType = ATypeValue) then
|
||||
begin
|
||||
AIndex := i;
|
||||
Result := True;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
if not Assigned(AView) then
|
||||
raise Exception.Create('Vista no asignada (SaveGridViewToStream)');
|
||||
@ -150,7 +168,7 @@ begin
|
||||
begin
|
||||
AValue := AReader.ReadVariant;
|
||||
if (Pos(AValueNameList[iCols], AView.DataController.KeyFieldNames) = 0) then
|
||||
if _BuscarColumna(AValueNameList[iCols], AValueTypeList[iCols], AIndex) then
|
||||
if _BuscarColumna(AView, AValueNameList[iCols], AValueTypeList[iCols], AIndex) then
|
||||
begin
|
||||
if AIndex <> -1 then
|
||||
ADataSet.FieldByName(AView.DataController.GetItemField(AIndex).FieldName).Value := AValue;
|
||||
@ -317,11 +335,12 @@ var
|
||||
AFicheroTMP : String;
|
||||
AStringList : TStringList;
|
||||
HTMLText : String;
|
||||
CF_HTML : Cardinal;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Vista no asignada (CopiarSeleccionGridAlPortapapelesTXT)');
|
||||
|
||||
RegistrarFormatos;
|
||||
|
||||
AFicheroTMP := DarFicheroHTMLTemporal;
|
||||
ExportGridToHTML(AFicheroTMP, AGrid, True, not ASoloSeleccion);
|
||||
|
||||
@ -333,11 +352,6 @@ begin
|
||||
HTMLText := AStringList.Text;
|
||||
AStringList.Insert(0, GetHeader(HTMLText));
|
||||
AStringList.Add(GetFooter);
|
||||
|
||||
CF_HTML := RegisterClipboardFormat ('HTML Format');
|
||||
if CF_HTML = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_HTML (CopiarSeleccionGridAlPortapapelesHTML)');
|
||||
|
||||
CopyStringsToClipboard(CF_HTML, AStringList);
|
||||
finally
|
||||
FreeANDNIL(AStringList);
|
||||
@ -350,19 +364,15 @@ procedure CopiarGridAlPortapapelesRTF (AGrid : TcxGrid; const ASoloSeleccion : B
|
||||
var
|
||||
ARTFConv : TCtrlToRTF;
|
||||
AStringList : TStringList;
|
||||
CF_RTF : Cardinal;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Grid no asignado (CopiarSeleccionGridAlPortapapelesTXT)');
|
||||
|
||||
RegistrarFormatos;
|
||||
ARTFConv := TCtrlToRTF.Create(NIL);
|
||||
try
|
||||
ARTFConv.cxGridViewToRTF(TcxGridTableView(AGrid.ActiveView));
|
||||
|
||||
CF_RTF := RegisterClipboardFormat('Rich Text Format');
|
||||
if CF_RTF = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_RTF (CopiarSeleccionGridAlPortapapelesRTF)');
|
||||
|
||||
AStringList := TStringList.Create;
|
||||
try
|
||||
AStringList.Add(ARTFConv.RTFText);
|
||||
@ -399,11 +409,12 @@ procedure CopiarGridAlPortapapelesExcel (AGrid : TcxGrid; const ASoloSeleccion :
|
||||
var
|
||||
AFicheroTMP : String;
|
||||
AStream : TFileStream;
|
||||
CF_HTML : Cardinal;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Vista no asignada (CopiarSeleccionGridAlPortapapelesTXT)');
|
||||
|
||||
RegistrarFormatos;
|
||||
|
||||
AFicheroTMP := DarFicheroExcelTemporal;
|
||||
ExportGridToExcel(AFicheroTMP, AGrid, True, not ASoloSeleccion);
|
||||
|
||||
@ -411,10 +422,6 @@ begin
|
||||
begin
|
||||
AStream := TFileStream.Create(AFicheroTMP, fmOpenRead);
|
||||
try
|
||||
CF_HTML := RegisterClipboardFormat ('HTML Format');
|
||||
if CF_HTML = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_HTML (CopiarSeleccionGridAlPortapapelesHTML)');
|
||||
|
||||
CopyStreamToClipboard(CF_HTML, AStream);
|
||||
finally
|
||||
FreeANDNIL(AStream);
|
||||
@ -427,12 +434,13 @@ end;
|
||||
procedure CopiarSeleccionGridAlPortapapeles (AGrid : TcxGrid);
|
||||
var
|
||||
AMemStream : TMemoryStream;
|
||||
CF_FACTUGES : Cardinal;
|
||||
AGridStatus : TcxGridStatus;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Grid no asignado (CopiarSeleccionGridAlPortapapelesTXT)');
|
||||
|
||||
RegistrarFormatos;
|
||||
|
||||
AGridStatus := TcxGridStatus.Create(TcxGridDBTableView(AGrid.ActiveView));
|
||||
Clipboard.Open;
|
||||
try
|
||||
@ -443,9 +451,6 @@ begin
|
||||
AMemStream := TMemoryStream.Create;
|
||||
try
|
||||
SaveGridRowsToStream(TcxGridDBTableView(AGrid.ActiveView), AMemStream, AGrid.ActiveView.Name, True);
|
||||
CF_FACTUGES := RegisterClipboardFormat ('FactuGES Format');
|
||||
if CF_FACTUGES = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_HTML (CopiarSeleccionGridAlPortapapelesHTML)');
|
||||
CopyStreamToClipboard(CF_FACTUGES, AMemStream);
|
||||
finally
|
||||
FreeAndNil(AMemStream);
|
||||
@ -474,16 +479,13 @@ end;
|
||||
procedure PegarSeleccionGridDesdePortapapeles (AGrid : TcxGrid);
|
||||
var
|
||||
AMemStream : TMemoryStream;
|
||||
CF_FACTUGES : Cardinal;
|
||||
ACaption : String;
|
||||
AGridStatus : TcxGridStatus;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Grid no asignado (PegarSeleccionGridDesdePortapapeles)');
|
||||
|
||||
CF_FACTUGES := RegisterClipboardFormat ('FactuGES Format');
|
||||
if CF_FACTUGES = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_FACTUGES (PegarSeleccionGridDesdePortapapeles)');
|
||||
RegistrarFormatos;
|
||||
|
||||
if not Clipboard.HasFormat(CF_FACTUGES) then
|
||||
raise Exception.Create('No hay nada en el portapapeles');
|
||||
@ -505,15 +507,122 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function HayDatosEnPortapapeles: Boolean;
|
||||
var
|
||||
CF_FACTUGES : Cardinal;
|
||||
begin
|
||||
CF_FACTUGES := RegisterClipboardFormat ('FactuGES Format');
|
||||
if CF_FACTUGES = 0 then
|
||||
raise Exception.Create('Error al registrar formato CF_FACTUGES (HayDatosEnPortapapeles)');
|
||||
|
||||
Result := Clipboard.HasFormat(CF_FACTUGES);
|
||||
procedure PegarTextoDesdePortapapeles (AGrid : TcxGrid);
|
||||
var
|
||||
ACaption : String;
|
||||
AGridStatus : TcxGridStatus;
|
||||
ATextList : TStringList;
|
||||
|
||||
ADataSet : TDataSet;
|
||||
AColumnID: Integer;
|
||||
|
||||
ARecordID : Integer;
|
||||
ARecordIndex : Integer;
|
||||
bEstabaVacia : Boolean;
|
||||
AView : TcxGridDBTableView;
|
||||
|
||||
iContador : Integer;
|
||||
begin
|
||||
if not Assigned(AGrid) then
|
||||
raise Exception.Create('Grid no asignado (PegarTextoDesdePortapapeles)');
|
||||
|
||||
RegistrarFormatos;
|
||||
|
||||
if not Clipboard.HasFormat(CF_TEXT) then
|
||||
raise Exception.Create('No hay nada en el portapapeles');
|
||||
|
||||
AView := TcxGridDBTableView(AGrid.ActiveView);
|
||||
|
||||
|
||||
AGridStatus := TcxGridStatus.Create(TcxGridDBTableView(AGrid.ActiveView));
|
||||
Clipboard.Open;
|
||||
try
|
||||
ATextList := TStringList.Create;
|
||||
try
|
||||
CopyStringsFromClipboard(CF_TEXT, ATextList);
|
||||
|
||||
ADataSet := AView.DataController.DataSource.DataSet;
|
||||
bEstabaVacia := ADataSet.IsEmpty;
|
||||
|
||||
AView.DataController.BeginUpdate;
|
||||
try
|
||||
// Localizar el punto donde se empieza a insertar
|
||||
if not bEstabaVacia then
|
||||
begin
|
||||
ARecordIndex := AView.DataController.FocusedRecordIndex;
|
||||
if ARecordIndex >= 0 then
|
||||
begin
|
||||
ARecordID := AView.DataController.GetRecordId(ARecordIndex);
|
||||
ADataSet.Locate(AView.DataController.KeyFieldNames, ARecordID, []);
|
||||
end;
|
||||
end;
|
||||
|
||||
for iContador := 0 to ATextList.Count - 1 do
|
||||
begin
|
||||
// Insertar una tupla de la forma adecuada
|
||||
if bEstabaVacia then
|
||||
ADataSet.Append
|
||||
else begin
|
||||
{if iContador > 0 then
|
||||
ADataSet.Next;}
|
||||
ADataSet.Insert;
|
||||
end;
|
||||
|
||||
try
|
||||
ADataSet.Edit;
|
||||
ADataSet.FieldByName('CONCEPTO').AsString := ATextList[iContador];
|
||||
finally
|
||||
ADataSet.Post;
|
||||
end;
|
||||
end;
|
||||
RenumerarCampoPosicion(ADataSet);
|
||||
finally
|
||||
AView.DataController.EndUpdate;
|
||||
end;
|
||||
finally
|
||||
FreeANDNIL(ATextList);
|
||||
end;
|
||||
finally
|
||||
Clipboard.Close;
|
||||
AGridStatus.Restore(TcxGridDBTableView(AGrid.ActiveView));
|
||||
FreeAndNil(AGridStatus);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function HayDatosEnPortapapeles(AFormat: Cardinal): Boolean;
|
||||
begin
|
||||
RegistrarFormatos;
|
||||
|
||||
if AFormat = 0 then
|
||||
Result := Clipboard.HasFormat(CF_FACTUGES) or Clipboard.HasFormat(CF_TEXT)
|
||||
else
|
||||
Result := Clipboard.HasFormat(AFormat);
|
||||
end;
|
||||
|
||||
|
||||
procedure PegarAlGridDesdePortapapeles (AGrid : TcxGrid);
|
||||
begin
|
||||
{ Aqui se determina qué hacer. Si en el portapapeles hay datos en formato...
|
||||
1. CF_FACTUGES -> pegar conceptos
|
||||
2. CF_TEXT -> tratar y pegar texto plano
|
||||
}
|
||||
|
||||
RegistrarFormatos;
|
||||
|
||||
if Clipboard.HasFormat(CF_FACTUGES) then
|
||||
begin
|
||||
PegarSeleccionGridDesdePortapapeles(AGrid);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if Clipboard.HasFormat(CF_TEXT) then
|
||||
begin
|
||||
PegarTextoDesdePortapapeles(AGrid);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
270
Source/Base/Utiles/uSaveClipboard.pas
Normal file
270
Source/Base/Utiles/uSaveClipboard.pas
Normal file
@ -0,0 +1,270 @@
|
||||
unit uSaveClipboard;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, RichEdit, Clipbrd,
|
||||
registry, ActiveX, ShellAPI, ShlObj;
|
||||
|
||||
type
|
||||
|
||||
TSaveClipboard = class(TObject)
|
||||
private
|
||||
FTxt, FRTF, FHTML, FOEMText, FCSV : string;
|
||||
FUnicodeText : WideString;
|
||||
FBitmap : TBitmap;
|
||||
FMetafile : TMetafile;
|
||||
CF_RTF, CF_HTML, CF_CSV : UINT;
|
||||
FFiles : TStringList;
|
||||
procedure ClearBuffer;
|
||||
public
|
||||
constructor Create;reintroduce;
|
||||
destructor Destroy;override;
|
||||
procedure Save;
|
||||
procedure Restore;
|
||||
|
||||
property PlainText : String read FTxt write FTxt;
|
||||
property RTFText : String read FRTF write FRTF;
|
||||
property CSVText : String read FCSV write FCSV;
|
||||
property HTMLText : String read FHTML write FHTML;
|
||||
property OEMText : String read FOEMText write FOEMText;
|
||||
property UnicodeText : WideString read FUnicodeText write FUnicodeText;
|
||||
property Bitmap : TBitmap read FBitmap write FBitmap;
|
||||
property Metafile : TMetafile read FMetafile write FMetafile;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Dialogs;
|
||||
|
||||
{ TSaveClipboard }
|
||||
|
||||
procedure TSaveClipboard.ClearBuffer;
|
||||
begin
|
||||
FTxt:='';
|
||||
FRTF:='';
|
||||
FHTML:='';
|
||||
FCSV := '';
|
||||
FOEMText:='';
|
||||
FUnicodeText:='';
|
||||
FBitmap.Free;
|
||||
FBitmap:=nil;
|
||||
FMetafile.Free;
|
||||
FMetafile:=nil;
|
||||
FFiles.Clear;
|
||||
end;
|
||||
|
||||
constructor TSaveClipboard.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FFiles := TStringList.Create;
|
||||
ClearBuffer;
|
||||
CF_RTF := RegisterClipboardFormat(RichEdit.CF_RTF);
|
||||
CF_HTML := {16;//}RegisterClipboardFormat('HTML Format');
|
||||
CF_CSV := RegisterClipboardFormat('CSV');
|
||||
end;
|
||||
|
||||
destructor TSaveClipboard.Destroy;
|
||||
begin
|
||||
ClearBuffer;
|
||||
FFiles.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure CopyClipboardData(Format : UINT; Buffer : pointer; Length :
|
||||
integer);
|
||||
var Data:THandle;
|
||||
DataPtr: Pointer;
|
||||
begin
|
||||
Data := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, Length);
|
||||
try
|
||||
DataPtr := GlobalLock(Data);
|
||||
try
|
||||
CopyMemory(DataPtr, Buffer, Length);
|
||||
SetClipboardData(Format, Data);
|
||||
finally
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
except
|
||||
GlobalFree(Data);
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSaveClipboard.Restore;
|
||||
const NULL : Char = #0;
|
||||
var //Data:THandle;
|
||||
//DataPtr: Pointer;
|
||||
DF : TDropFiles;
|
||||
i : integer;
|
||||
begin
|
||||
try
|
||||
Clipboard.Clear;
|
||||
Clipboard.Open;
|
||||
//text
|
||||
if Length(FTxt) > 0 then Clipboard.AsText:=FTxt;
|
||||
//OEM text
|
||||
if Length(FOEMText) > 0 then CopyClipboardData(CF_OEMTEXT,
|
||||
PChar(FOEMText), Length(FOEMText)+1);
|
||||
//HTML text
|
||||
if Length(FHTML) > 0 then CopyClipboardData(CF_HTML, PChar(FHTML),
|
||||
Length(FHTML)+1);
|
||||
|
||||
//CSV text
|
||||
if Length(FCSV) > 0 then
|
||||
CopyClipboardData(CF_CSV, PChar(FCSV), Length(FCSV)+1);
|
||||
|
||||
//Unicode text
|
||||
if Length(FUnicodeText) > 0 then CopyClipboardData(CF_UNICODETEXT,
|
||||
PWideChar(FUnicodeText), 2*Length(FUnicodeText)+2);
|
||||
//RTF
|
||||
if Length(FRTF) > 0 then CopyClipboardData(CF_RTF, PChar(FRTF),
|
||||
Length(FRTF)+1);
|
||||
//BMP
|
||||
if FBitmap <> nil then Clipboard.Assign(FBitmap);
|
||||
//Metafile
|
||||
if FMetafile <> nil then Clipboard.Assign(FMetafile);
|
||||
//files
|
||||
if FFiles.Count > 0 then begin
|
||||
DF.pFiles:=SizeOf(DF);
|
||||
DF.pt.x:=0;
|
||||
DF.pt.y:=0;
|
||||
DF.fNC:=false;
|
||||
DF.fWide:=false;
|
||||
with TMemoryStream.Create do
|
||||
try
|
||||
Write(DF, SizeOf(DF));
|
||||
for i:=0 to FFiles.Count-1 do begin
|
||||
Write(FFiles[i][1], Length(FFiles[i]));
|
||||
Write(NULL, SizeOf(NULL));
|
||||
end;
|
||||
Write(NULL, SizeOf(NULL));
|
||||
CopyClipboardData(CF_HDROP, Memory, Size);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Clipboard.Close;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSaveClipboard.Save;
|
||||
var Data:THandle;
|
||||
p : pointer;
|
||||
Count, i : integer;
|
||||
Buffer : array[0..MAX_PATH] of Char;
|
||||
AList : TStringLIst;
|
||||
begin
|
||||
|
||||
{ AList := TStringList.Create;
|
||||
try
|
||||
AList.Add('Lista ----------');
|
||||
//GetClipboardFormatName(CF_HTML, @Buffer, SizeOf(Buffer));
|
||||
for i:=0 to Clipboard.FormatCount-1 do begin
|
||||
if Clipboard.Formats[i] = 0 then beep;
|
||||
GetClipboardFormatName(Clipboard.Formats[i], @Buffer, SizeOf(Buffer));
|
||||
AList.Add(Buffer);
|
||||
end;
|
||||
ShowMessage(AList.Text);
|
||||
finally
|
||||
FreeANDNIL(AList);
|
||||
end;}
|
||||
|
||||
|
||||
ClearBuffer;
|
||||
//text
|
||||
if Clipboard.HasFormat(CF_TEXT) then FTxt:=Clipboard.AsText;
|
||||
//RTF
|
||||
if Clipboard.HasFormat(CF_RTF) then
|
||||
begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_RTF);
|
||||
if Data <> 0 then begin
|
||||
FRTF := PChar(GlobalLock(Data));
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
|
||||
//CSV
|
||||
if Clipboard.HasFormat(CF_CSV) then
|
||||
begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_CSV);
|
||||
if Data <> 0 then begin
|
||||
FCSV := PChar(GlobalLock(Data));
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
|
||||
|
||||
//HTML
|
||||
if Clipboard.HasFormat(CF_HTML) then begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_HTML);
|
||||
if Data <> 0 then begin
|
||||
FHTML := PChar(GlobalLock(Data));
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
|
||||
//OEM Text
|
||||
if Clipboard.HasFormat(CF_OEMTEXT) then begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_OEMTEXT);
|
||||
if Data <> 0 then begin
|
||||
FOEMText := PChar(GlobalLock(Data));
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
//Unicode
|
||||
if Clipboard.HasFormat(CF_UNICODETEXT) then begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_UNICODETEXT);
|
||||
if Data <> 0 then begin
|
||||
FUnicodeText := PWideChar(GlobalLock(Data));
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
//Bitmap
|
||||
if Clipboard.HasFormat(CF_BITMAP) then
|
||||
try
|
||||
FBitmap:=TBitmap.Create;
|
||||
FBitmap.Assign(Clipboard);
|
||||
except
|
||||
FBitmap.Free;
|
||||
end;
|
||||
//metafile
|
||||
if Clipboard.HasFormat(CF_METAFILEPICT) then
|
||||
try
|
||||
FMetafile:=TMetafile.Create;
|
||||
FMetafile.Assign(Clipboard);
|
||||
except
|
||||
FMetafile.Free;
|
||||
end;
|
||||
//files
|
||||
if Clipboard.HasFormat(CF_HDROP) then begin
|
||||
Clipboard.Open;
|
||||
Data := GetClipboardData(CF_HDROP);
|
||||
if Data <> 0 then begin
|
||||
p := PChar(GlobalLock(Data));
|
||||
Count:=DragQueryFile(HDROP(p), $FFFFFFFF, nil, 0);
|
||||
for i:=0 to Count-1 do begin
|
||||
DragQueryFile(HDROP(p), i, @Buffer, SizeOf(Buffer));
|
||||
if strlen(PChar(@Buffer)) > 0 then FFiles.Add(PChar(@Buffer));
|
||||
end;
|
||||
GlobalUnlock(Data);
|
||||
end;
|
||||
Clipboard.Close;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
@ -58,30 +58,30 @@
|
||||
<DelphiCompile Include="GUIBase.dpk">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\Base.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\cxLibraryD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\cxTreeListD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dbrtl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxBarD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxBarExtItemsD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxComnD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxGDIPlusD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxLayoutControlD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxPSCoreD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxPScxCommonD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxPScxGrid6LnkD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxPsPrVwAdvD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\dxThemeD11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\frx11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\frxe11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\fs11.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\JvAppFrmD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\JvCtrlsD11R.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\rtl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\vcl.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\vcldb.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\vcljpg.dcp" />
|
||||
<DCCReference Include="..\Modulos\Pedidos a proveedor\vclx.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\Base.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\cxLibraryD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\cxTreeListD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dbrtl.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxBarD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxBarExtItemsD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxComnD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxGDIPlusD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxLayoutControlD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxPSCoreD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxPScxCommonD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxPScxGrid6LnkD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxPsPrVwAdvD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\dxThemeD11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\frx11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\frxe11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\fs11.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\JvAppFrmD11R.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\JvCtrlsD11R.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\rtl.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\vcl.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\vcldb.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\vcljpg.dcp" />
|
||||
<DCCReference Include="C:\Documents and Settings\Usuario\vclx.dcp" />
|
||||
<DCCReference Include="uDialogBase.pas">
|
||||
<Form>fDialogBase</Form>
|
||||
</DCCReference>
|
||||
|
||||
Binary file not shown.
@ -64,7 +64,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase
|
||||
DroppedDownWidth = 145
|
||||
MaxMRUCount = 0
|
||||
FontName = 'Tahoma'
|
||||
ItemIndex = 42
|
||||
ItemIndex = 39
|
||||
Options = [foTrueTypeOnly, foNoOEMFonts, foScalableOnly, foWysiWyg]
|
||||
Sorted = True
|
||||
TabOrder = 2
|
||||
@ -293,6 +293,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase
|
||||
DataBinding.FieldName = 'CONCEPTO'
|
||||
PropertiesClassName = 'TcxRichEditProperties'
|
||||
Properties.AllowObjects = True
|
||||
Properties.SelectionBar = True
|
||||
Width = 237
|
||||
end
|
||||
object cxGridViewCANTIDAD: TcxGridDBColumn
|
||||
@ -533,18 +534,21 @@ inherited frViewDetallesBase: TfrViewDetallesBase
|
||||
object actDetallesCortar: TAction
|
||||
Category = 'Editar'
|
||||
Caption = 'Cortar'
|
||||
ShortCut = 16472
|
||||
OnExecute = actDetallesCortarExecute
|
||||
OnUpdate = actDetallesCortarUpdate
|
||||
end
|
||||
object actDetallesCopiar: TAction
|
||||
Category = 'Editar'
|
||||
Caption = 'Copiar'
|
||||
ShortCut = 16451
|
||||
OnExecute = actDetallesCopiarExecute
|
||||
OnUpdate = actDetallesCopiarUpdate
|
||||
end
|
||||
object actDetallesPegar: TAction
|
||||
Category = 'Editar'
|
||||
Caption = 'Pegar'
|
||||
ShortCut = 16470
|
||||
OnExecute = actDetallesPegarExecute
|
||||
OnUpdate = actDetallesPegarUpdate
|
||||
end
|
||||
@ -583,6 +587,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase
|
||||
object actSeleccionarTodo: TAction
|
||||
Category = 'Editar'
|
||||
Caption = 'Seleccionar todo'
|
||||
ShortCut = 16449
|
||||
OnExecute = actSeleccionarTodoExecute
|
||||
OnUpdate = actSeleccionarTodoUpdate
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@ uses
|
||||
uGridStatusUtils, uControllerDetallesBase, cxCurrencyEdit,
|
||||
ExtCtrls, Grids, DBGrids, StdCtrls,
|
||||
ExtActns, StdActns, cxRichEdit, JvExStdCtrls, JvCombobox, JvColorCombo,
|
||||
TB2Item, TBX, TB2Dock, TB2Toolbar, uDAInterfaces,
|
||||
TB2Item, TBX, TB2Dock, TB2Toolbar, uDAInterfaces, cxContainer,
|
||||
Menus, cxGridCustomPopupMenu, cxGridPopupMenu;
|
||||
|
||||
type
|
||||
@ -214,6 +214,8 @@ type
|
||||
|
||||
function DarPosicionCAMPO(const Nombre:String): Integer;
|
||||
function DarListaSeleccionados: TIntegerArray;
|
||||
|
||||
procedure DoPasteText(Sender: TObject; AText: string);
|
||||
protected
|
||||
function HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean; virtual;
|
||||
function EsTipoEditable(AItem: TcxCustomGridTableItem): Boolean; virtual;
|
||||
@ -246,11 +248,40 @@ implementation
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uDMBase, uCalculosUtils, dxOffice11, uSistemaFunc, uGridClipboardUtils;
|
||||
uDMBase, uCalculosUtils, dxOffice11, uSistemaFunc, uGridClipboardUtils,
|
||||
Clipbrd;
|
||||
|
||||
type
|
||||
TOnPaste = procedure(Sender: TObject; AText: string) of object;
|
||||
|
||||
TcxMyRichEdit = class(TcxRichEdit)
|
||||
private
|
||||
FOnPaste: TOnPaste;
|
||||
FOldWndProc : TWndMethod;
|
||||
FGrid: TcxGrid;
|
||||
procedure InnerControlWindowProc(var Message: TMessage);
|
||||
procedure FInnerRichOnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
protected
|
||||
procedure DoPaste; virtual;
|
||||
procedure Initialize; override;
|
||||
procedure HookInnerControl;
|
||||
public
|
||||
procedure PasteFromClipboard; override;
|
||||
destructor Destroy; override;
|
||||
property _Grid : TcxGrid read FGrid write FGrid;
|
||||
property OnPaste: TOnPaste read FOnPaste write FOnPaste;
|
||||
end;
|
||||
|
||||
TcxMyRichEditProperties = class(TcxRichEditProperties)
|
||||
public
|
||||
class function GetContainerClass: TcxContainerClass; override;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
_FRecalculando : Boolean;
|
||||
_FRecalcular : Boolean;
|
||||
_FPegando : Boolean;
|
||||
|
||||
function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
|
||||
FontType: Integer; Data: Pointer): Integer; stdcall;
|
||||
@ -270,6 +301,7 @@ begin
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := False;
|
||||
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if _FocusedView.Controller.EditingController.IsEditing then
|
||||
@ -285,6 +317,7 @@ begin
|
||||
end;
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
HideHourglassCursor;
|
||||
|
||||
// Dejo la propiedad MultiSelect como estaba
|
||||
if bEsMultiSelect then
|
||||
@ -308,6 +341,7 @@ begin
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := False;
|
||||
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if _FocusedView.Controller.EditingController.IsEditing then
|
||||
@ -317,6 +351,7 @@ begin
|
||||
Controller.Add(FDetalles, TIPO_DETALLE_DESCUENTO);
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
HideHourglassCursor;
|
||||
|
||||
// Dejo la propiedad MultiSelect como estaba
|
||||
if bEsMultiSelect then
|
||||
@ -340,6 +375,7 @@ begin
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := False;
|
||||
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if _FocusedView.Controller.EditingController.IsEditing then
|
||||
@ -349,7 +385,8 @@ begin
|
||||
Controller.Add(FDetalles, TIPO_DETALLE_CONCEPTO);
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
|
||||
HideHourglassCursor;
|
||||
|
||||
// Dejo la propiedad MultiSelect como estaba
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := bEsMultiSelect;
|
||||
@ -366,6 +403,7 @@ begin
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := False;
|
||||
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if _FocusedView.Controller.EditingController.IsEditing then
|
||||
@ -375,7 +413,8 @@ begin
|
||||
Controller.Add(FDetalles, TIPO_DETALLE_SUBTOTAL);
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
|
||||
HideHourglassCursor;
|
||||
|
||||
// Dejo la propiedad MultiSelect como estaba
|
||||
if bEsMultiSelect then
|
||||
_FocusedView.OptionsSelection.MultiSelect := bEsMultiSelect;
|
||||
@ -398,6 +437,7 @@ begin
|
||||
if bEsMultiSelect then
|
||||
cxGridView.OptionsSelection.MultiSelect := False;
|
||||
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if _FocusedView.Controller.EditingController.IsEditing then
|
||||
@ -407,6 +447,7 @@ begin
|
||||
Controller.Add(FDetalles, TIPO_DETALLE_TITULO);
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
HideHourglassCursor;
|
||||
|
||||
// Dejo la propiedad MultiSelect como estaba
|
||||
if bEsMultiSelect then
|
||||
@ -425,6 +466,7 @@ var
|
||||
AuxTop, AuxRow:Integer;
|
||||
|
||||
begin
|
||||
ShowHourglassCursor;
|
||||
_FocusedView.BeginUpdate;
|
||||
try
|
||||
if Assigned(Controller) and Assigned(FDetalles) then
|
||||
@ -448,6 +490,7 @@ begin
|
||||
end
|
||||
finally
|
||||
_FocusedView.EndUpdate;
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
|
||||
SeleccionarFilaActual;
|
||||
@ -503,6 +546,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TfrViewDetallesBase.DoPasteText(Sender: TObject; AText: string);
|
||||
begin
|
||||
ShowMessage(AText);
|
||||
end;
|
||||
|
||||
procedure TfrViewDetallesBase.ContraerTodo;
|
||||
begin
|
||||
if Assigned(_FocusedView) then
|
||||
@ -526,7 +574,7 @@ begin
|
||||
CurEdit := Nil;
|
||||
FUpdating := False;
|
||||
// cxGridView.OptionsView.RowSeparatorColor := dmBase.StyleManager.Colors.ButtonSeparatorColor;
|
||||
|
||||
cxGridViewDESCRIPCION.PropertiesClass := TcxMyRichEditProperties;
|
||||
end;
|
||||
|
||||
procedure TfrViewDetallesBase.CustomViewDestroy(Sender: TObject);
|
||||
@ -548,7 +596,7 @@ begin
|
||||
inherited;
|
||||
cxGridView.BeginUpdate;
|
||||
try
|
||||
Case Key of
|
||||
case Key of
|
||||
VK_DOWN : begin
|
||||
//En el caso de ser la última fila hacemos un append nosotros no el grid
|
||||
//ya que se saltaria la lógica del controllerDetallesBase
|
||||
@ -580,8 +628,7 @@ begin
|
||||
: begin
|
||||
//En el caso de ser la última fila hacemos un append nosotros no el grid
|
||||
//ya que se saltaria la lógica del controllerDetallesBase
|
||||
if cxGridView.Controller.IsFinish
|
||||
and AItem.IsLast then
|
||||
if cxGridView.Controller.IsFinish and AItem.IsLast then
|
||||
begin
|
||||
Key := 0;
|
||||
if Sender.Controller.EditingController.IsEditing then
|
||||
@ -648,6 +695,15 @@ var
|
||||
ARecord: TcxCustomGridRecord;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if AEdit is TcxMyRichEdit then
|
||||
begin
|
||||
TcxMyRichEdit(AEdit).OnPaste := DoPasteText;
|
||||
TcxMyRichEdit(AEdit)._Grid := _Grid;
|
||||
end;
|
||||
|
||||
Exit; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if AEdit is TcxRichEdit then
|
||||
begin
|
||||
ARecord := AItem.FocusedCellViewInfo.GridRecord;
|
||||
@ -1068,6 +1124,7 @@ end;
|
||||
procedure TfrViewDetallesBase.actDetallesCortarExecute(Sender: TObject);
|
||||
begin
|
||||
ShowHourglassCursor;
|
||||
Application.ProcessMessages;
|
||||
try
|
||||
CortarSeleccionGridAlPortapapeles(_Grid);
|
||||
finally
|
||||
@ -1083,24 +1140,17 @@ end;
|
||||
|
||||
procedure TfrViewDetallesBase.actDetallesPegarExecute(Sender: TObject);
|
||||
begin
|
||||
{ if cxGridViewDESCRIPCION.Focused then
|
||||
TcxRichEdit(cxGridViewDESCRIPCION).PasteSpecial
|
||||
else begin}
|
||||
ShowHourglassCursor;
|
||||
try
|
||||
PegarSeleccionGridDesdePortapapeles(_Grid);
|
||||
finally
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
// end;
|
||||
ShowHourglassCursor;
|
||||
try
|
||||
PegarAlGridDesdePortapapeles(_Grid);
|
||||
finally
|
||||
HideHourglassCursor;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrViewDetallesBase.actDetallesPegarUpdate(Sender: TObject);
|
||||
begin
|
||||
inherited;
|
||||
{ if cxGridViewDESCRIPCION.Focused then
|
||||
(Sender as TAction).Enabled := True
|
||||
else}
|
||||
(Sender as TAction).Enabled := HayDatosEnPortapapeles;
|
||||
end;
|
||||
|
||||
@ -1130,8 +1180,82 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TcxMyRichEdit }
|
||||
|
||||
destructor TcxMyRichEdit.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.DoPaste;
|
||||
begin
|
||||
if Assigned(FOnPaste) then
|
||||
FOnPaste(Self, Self.Text);
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.FInnerRichOnKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if ((Shift = [ssShift]) and (Key = VK_INSERT)) then
|
||||
begin
|
||||
PasteFromClipboard;
|
||||
Key := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.HookInnerControl;
|
||||
begin
|
||||
{ Desviamos los mensajes que recibe el componente RichEdit interno de la columna
|
||||
a un procedimiento nuestro para interceptar los mensajes de pegar del portapapeles
|
||||
y así en vez de ejecutar el 'paste' por defecto de Windows,
|
||||
hacemos nuestro 'paste'.}
|
||||
FOldWndProc := InnerRich.WindowProc;
|
||||
InnerRich.WindowProc := InnerControlWindowProc;
|
||||
InnerRich.OnKeyDown := FInnerRichOnKeyDown;
|
||||
// InnerRich.PopupMenu := ;
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.Initialize;
|
||||
begin
|
||||
inherited;
|
||||
if Assigned(InnerRich) then
|
||||
HookInnerControl;
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.InnerControlWindowProc(var Message: TMessage);
|
||||
begin
|
||||
case Message.msg of
|
||||
WM_PASTE: if not _FPegando then
|
||||
PasteFromClipboard;
|
||||
else
|
||||
FOldWndProc(Message);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TcxMyRichEdit.PasteFromClipboard;
|
||||
begin
|
||||
_FPegando := True;
|
||||
try
|
||||
//if HayDatosEnPortapapeles(CF_FACTUGES) then
|
||||
PegarAlGridDesdePortapapeles(FGrid);
|
||||
//else
|
||||
//inherited;
|
||||
DoPaste;
|
||||
finally
|
||||
_FPegando := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TcxMyRichEditProperties }
|
||||
|
||||
class function TcxMyRichEditProperties.GetContainerClass: TcxContainerClass;
|
||||
begin
|
||||
Result := TcxMyRichEdit;
|
||||
end;
|
||||
|
||||
initialization
|
||||
_FRecalculando := False;
|
||||
_FRecalcular := False;
|
||||
_FRecalcular := False;
|
||||
_FPegando := False;
|
||||
|
||||
end.
|
||||
|
||||
@ -167,8 +167,11 @@ inherited frViewRichEditor: TfrViewRichEditor
|
||||
Top = 26
|
||||
Align = alClient
|
||||
ParentFont = False
|
||||
Properties.AllowObjects = True
|
||||
Properties.HideSelection = False
|
||||
Properties.ScrollBars = ssVertical
|
||||
Properties.SelectionBar = True
|
||||
Properties.StreamModes = [resmPlainRtf]
|
||||
Properties.OnChange = RichEditPropertiesChange
|
||||
Properties.OnSelectionChange = RichEditPropertiesSelectionChange
|
||||
Style.Font.Charset = DEFAULT_CHARSET
|
||||
|
||||
Loading…
Reference in New Issue
Block a user