protected override void Dispose(bool disposing) { try { if (disposing) { if (SourceForFilteredData != null) { TCompactFramework.DisposeDataView(SourceForFilteredData); } SourceForFilteredData = null; if (SortedFilteredData != null) { TCompactFramework.DisposeDataView(SortedFilteredData); } SortedFilteredData = null; if (FilteredData != null && FilteredDataNeedsDispose) { TCompactFramework.DisposeDataTable(FilteredData); } FilteredData = null; } } finally { //last call. base.Dispose(disposing); } }
public override VirtualDataTable FilterData(string newDataName, string rowFilter) { if (string.IsNullOrEmpty(rowFilter)) { return(new TAdoDotNetDataTable(newDataName, this, Data, false)); } DataTable FilteredData = null; try { DataView dv = new DataView(Data, rowFilter, String.Empty, DataViewRowState.CurrentRows); try { FilteredData = Data.Clone(); //create a copy of the filtered data. foreach (DataRowView rv in dv) { FilteredData.ImportRow(rv.Row); } } finally { TCompactFramework.DisposeDataView(dv); } return(new TAdoDotNetDataTable(newDataName, this, FilteredData, true, OriginalTable)); } catch { if (FilteredData != null) { TCompactFramework.DisposeDataTable(FilteredData); } throw; } }
internal TFileSharingRecord(bool aRecommendReadOnly, string aPassword, string aUser, bool PassIsHash) : base((int)xlr.FILESHARING, new byte[0]) { if (aUser == null) { aUser = String.Empty; } TExcelString Xs = new TExcelString(TStrLenLength.is16bits, aUser, null, false); Data = new byte[4 + Xs.TotalSize()]; RecommendReadOnly = aRecommendReadOnly; if (PassIsHash) { if (aPassword == null || aPassword.Length == 0) { SetWord(2, 0); } else { if (aPassword.Length <= 4) //we will only use standard pass, which is what Excel 2010 uses. { SetWord(2, TCompactFramework.HexToNumber(aPassword)); } } } else { SetPassword(aPassword); } Xs.CopyToPtr(Data, 4); }
protected override void Dispose(bool disposing) { try { //only managed resources if (disposing) { if (DataNeedsDispose && Data != null) { TCompactFramework.DisposeDataTable(Data); } Data = null; foreach (TLookupCache dv in LookupDataViews.Values) { dv.Dispose(); } LookupDataViews = null; } } finally { //last call. base.Dispose(disposing); } }
private static string[] CreateConfigTagsParams() { ResourceManager rm = new ResourceManager("FlexCel.Report.ConfigTagNames", Assembly.GetExecutingAssembly()); string[] Result = new string[64]; //bigger just in case foreach (ConfigTagEnum tag in TCompactFramework.EnumGetValues(typeof(ConfigTagEnum))) { Result[(int)tag] = rm.GetString("P" + tag.ToString().ToUpper(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); Debug.Assert(Result[(int)tag] != null); } return(Result); }
private static Dictionary <string, ApplyFormatTagEnum> CreateApplyFormatTags() { ResourceManager rm = new ResourceManager("FlexCel.Report.ConfigTagNames", Assembly.GetExecutingAssembly()); Dictionary <string, ApplyFormatTagEnum> Result = new Dictionary <string, ApplyFormatTagEnum>(StringComparer.InvariantCultureIgnoreCase); foreach (ApplyFormatTagEnum tag in TCompactFramework.EnumGetValues(typeof(ApplyFormatTagEnum))) { string s = rm.GetString("Format." + tag.ToString().ToUpper(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); Debug.Assert(s != null); Result[s] = tag; } return(Result); }
private static string[] InitTokens() { ResourceManager rm = new ResourceManager("FlexCel.Pdf.pdftokens", Assembly.GetExecutingAssembly()); Array TokenList = TCompactFramework.EnumGetValues(typeof(TPdfToken)); string[] Result = new string[300]; foreach (TPdfToken Token in TokenList) { string s = rm.GetString(Token.ToString()); Result[(int)Token] = s; } return(Result); }
internal static TEscherBSERecord Convert(byte[] Data, TXlsImgType DataType, TEscherDwgGroupCache DwgGroupCache, TEscherDwgCache DwgCache) { byte[] BSEHeader = TCompactFramework.GetBSEHeader(Data, (int)TBSEHeader.length, (int)TBSEHeader.rgbUid); using (MemoryStream BlipData = new MemoryStream()) { //Common header BlipData.Write(BSEHeader, (int)TBSEHeader.rgbUid, (int)TBSEHeader.tag - (int)TBSEHeader.rgbUid); // Specific info if ((DataType == TXlsImgType.Jpeg) || (DataType == TXlsImgType.Png)) { LoadDataBitmap(Data, DataType, BlipData); } else if (DataType == TXlsImgType.Bmp) { LoadDataBmp(Data, DataType, BlipData); } else { LoadDataWMF(Data, DataType, BlipData); } BSEHeader[(int)TBSEHeader.btWin32] = (byte)XlsEscherConsts.XlsImgConv(DataType); BSEHeader[(int)TBSEHeader.btMacOS] = (byte)msoblip.PICT; BitOps.SetWord(BSEHeader, (int)TBSEHeader.tag, 0xFF); BitOps.SetCardinal(BSEHeader, (int)TBSEHeader.size, BlipData.Length + XlsEscherConsts.SizeOfTEscherRecordHeader); BitOps.SetCardinal(BSEHeader, (int)TBSEHeader.cRef, 0); BitOps.SetCardinal(BSEHeader, (int)TBSEHeader.foDelay, 0); TEscherRecordHeader Eh = new TEscherRecordHeader(); Eh.Id = (int)Msofbt.BSE; Eh.Pre = 2 + ((int)XlsEscherConsts.XlsImgConv(DataType) << 4); Eh.Size = BitOps.GetCardinal(BSEHeader, (int)TBSEHeader.size) + BSEHeader.Length; TEscherBSERecord Result = new TEscherBSERecord(Eh, DwgGroupCache, DwgCache, DwgGroupCache.BStore); TEscherRecordHeader BlipHeader = new TEscherRecordHeader(); BlipHeader.Id = (int)XlsEscherConsts.XlsBlipHeaderConv(DataType); BlipHeader.Pre = (int)XlsEscherConsts.XlsBlipSignConv(DataType) << 4; BlipHeader.Size = BlipData.Length; BlipData.Position = 0; Result.CopyFromData(BSEHeader, BlipHeader, BlipData); return(Result); } }
internal TEscherOPTRecord FindObjByShapeId(string shapeId) { long SpId; FillNotLoaded(); if (!TCompactFramework.TryParse(shapeId, out SpId)) { return(null); } TEscherOPTRecord Result; if (!OptsByShapeId.TryGetValue(SpId, out Result)) { return(null); } return(Result); }
public override VirtualDataTable GetDistinct(string newDataName, int[] filterFields) { DataColumn[] SortFields = GetSortFields(Data, filterFields); #if (FRAMEWORK20) if (Data.CaseSensitive) //this does not seem to work on non case sensitives { DataTable NewData20 = null; try { DataView dv = new DataView(Data); try { string[] Columns = new string[SortFields.Length]; for (int i = 0; i < Columns.Length; i++) { Columns[i] = SortFields[i].ColumnName; } NewData20 = dv.ToTable(Data.TableName, true, Columns); } finally { TCompactFramework.DisposeDataView(dv); } return(new TAdoDotNetDataTable(newDataName, this, NewData20, true, OriginalTable)); } catch { TCompactFramework.DisposeDataTable(NewData20); throw; } } #endif string Sort = GetSortString(SortFields); DataTable NewData = new DataTable(); try { NewData.Locale = Data.Locale; NewData.CaseSensitive = Data.CaseSensitive; CopyColumns(SortFields, NewData); DataView dv = new DataView(Data, String.Empty, Sort, DataViewRowState.CurrentRows); try { object[] LastRow = null; NewData.BeginLoadData(); foreach (DataRowView dr in dv) { CopyRow(SortFields, dr, NewData, ref LastRow); } NewData.EndLoadData(); } finally { TCompactFramework.DisposeDataView(dv); } return(new TAdoDotNetDataTable(newDataName, this, NewData, true, OriginalTable)); } catch { TCompactFramework.DisposeDataTable(NewData); throw; } }
private object GetOneProperty(TOle2File Ole2File, int PropType) { if ((PropType & (int)TPropertyTypes.VT_VECTOR) != 0) { byte[] i4 = new byte[4]; Ole2File.Read(i4, i4.Length); object[] Vector = new object[BitOps.GetInt32(i4, 0)]; for (int i = 0; i < Vector.Length; i++) { Vector[i] = GetOneProperty(Ole2File, PropType & ~(int)TPropertyTypes.VT_VECTOR); } return(Vector); } switch ((TPropertyTypes)(PropType & 0xFF)) { case TPropertyTypes.VT_EMPTY: return(null); case TPropertyTypes.VT_I2: byte[] i2 = new byte[2]; Ole2File.Read(i2, i2.Length); return(BitConverter.ToInt16(i2, 0)); case TPropertyTypes.VT_UI2: //This is not really suported, but we need to convert the CodePage to a Signed int. byte[] ui2 = new byte[2]; Ole2File.Read(ui2, ui2.Length); return((Int32)BitConverter.ToUInt16(ui2, 0)); case TPropertyTypes.VT_I4: byte[] i4 = new byte[4]; Ole2File.Read(i4, i4.Length); return(BitOps.GetInt32(i4, 0)); case TPropertyTypes.VT_R4: byte[] d4 = new byte[4]; Ole2File.Read(d4, d4.Length); return(BitConverter.ToSingle(d4, 0)); case TPropertyTypes.VT_R8: byte[] d8 = new byte[8]; Ole2File.Read(d8, d8.Length); return(BitConverter.ToDouble(d8, 0)); case TPropertyTypes.VT_CY: byte[] cy = new byte[8]; Ole2File.Read(cy, cy.Length); return(TCompactFramework.DecimalFromOACurrency(BitConverter.ToInt64(cy, 0))); case TPropertyTypes.VT_DATE: byte[] dd = new byte[8]; Ole2File.Read(dd, dd.Length); DateTime Dt; if (!FlxDateTime.TryFromOADate(BitConverter.ToDouble(dd, 0), false, out Dt)) { return(DateTime.MinValue); } return(Dt.Date); case TPropertyTypes.VT_BSTR: byte[] sl = new byte[4]; Ole2File.Read(sl, sl.Length); UInt32 StrLen = BitConverter.ToUInt32(sl, 0); if (StrLen <= 1) { return(String.Empty); //StrLen includes the trailing #0 } byte[] Str = new byte[StrLen - 1]; Ole2File.Read(Str, Str.Length); Ole2File.SeekForward(Ole2File.Position + 1); //go over the 0 byte. This is needed for vectors/arrays. return(new TUnconvertedString(Str, false)); case TPropertyTypes.VT_BOOL: byte[] bl = new byte[2]; Ole2File.Read(bl, bl.Length); return(BitConverter.ToInt16(bl, 0) == 0? false: true); case TPropertyTypes.VT_VARIANT: byte[] VariantTypeArray = new byte[4]; Ole2File.Read(VariantTypeArray, VariantTypeArray.Length); Int32 VariantType = BitOps.GetInt32(VariantTypeArray, 0); return(GetOneProperty(Ole2File, VariantType)); case TPropertyTypes.VT_I8: byte[] i8 = new byte[8]; Ole2File.Read(i8, i8.Length); return(BitConverter.ToInt64(i8, 0)); case TPropertyTypes.VT_LPSTR: byte[] sl2 = new byte[4]; Ole2File.Read(sl2, sl2.Length); UInt32 StrLen2 = BitConverter.ToUInt32(sl2, 0); if (StrLen2 <= 1) { return(String.Empty); //StrLen includes the trailing #0 } byte[] Str2 = new byte[StrLen2 - 1]; Ole2File.Read(Str2, Str2.Length); Ole2File.SeekForward(Ole2File.Position + 1); //go over the 0 byte. This is needed for vectors/arrays. return(new TUnconvertedString(Str2, false)); case TPropertyTypes.VT_LPWSTR: byte[] sl3 = new byte[4]; Ole2File.Read(sl3, sl3.Length); UInt32 StrLen3 = BitConverter.ToUInt32(sl3, 0); if (StrLen3 <= 1) { return(String.Empty); //StrLen includes the trailing #0 } byte[] Str3 = new byte[(StrLen3 - 1) * 2]; Ole2File.SeekForward(Ole2File.Position + 2); //go over the 0 byte. This is needed for vectors/arrays. Ole2File.Read(Str3, Str3.Length); return(new TUnconvertedString(Str3, true)); case TPropertyTypes.VT_FILETIME: byte[] ft = new byte[8]; Ole2File.Read(ft, ft.Length); return(DateTime.FromFileTime(BitConverter.ToInt64(ft, 0))); case TPropertyTypes.VT_BLOB: byte[] blb = new byte[4]; Ole2File.Read(blb, blb.Length); UInt32 BlobLen = BitConverter.ToUInt32(blb, 0); if (BlobLen <= 0) { return(new byte[0]); //BlobLen does not includes trailing #0 } byte[] Blob = new byte[BlobLen]; Ole2File.Read(Blob, Blob.Length); return(Blob); } return(null); //Not a supported type. }