/// <summary> /// Exports the active sheet of the the associated xls workbook to a file. /// </summary> /// <remarks> /// This method is a shortcut for calling <see cref="BeginExport(Stream)"/>/ <see cref="ExportSheet()"/>/<see cref="EndExport()"/>. /// </remarks> /// <param name="fileName">File to export.</param> public void Export(string fileName) { try { FileMode fm = FileMode.CreateNew; if (AllowOverwritingFiles) { fm = FileMode.Create; } using (FileStream f = new FileStream(fileName, fm, FileAccess.Write)) { Export(f); } } catch (IOException) { //Don't delete the file in an io exception. It might be because allowoverwritefiles was false, and the file existed. throw; } catch { FlxUtils.TryDelete(fileName); throw; } }
internal override bool VerifyPass(string Password, TEncryptionParameters EncParams, TEncryptionKey Key) { if (!base.VerifyPass(Password, EncParams, Key)) { return(false); } Key.CalcKey(TStandardEncryptionKey.BlockKey, null); byte[] DecriptedVerifier; byte[] DecriptedVerifierHash; using (AesManaged Engine = TEncryptionUtils.CreateEngine(EncParams)) { using (ICryptoTransform Decryptor = Engine.CreateDecryptor(Key.Key, Key.IV)) { DecriptedVerifier = DecryptBytes(EncryptedVerifier, Decryptor, -1); DecriptedVerifierHash = DecryptBytes(EncryptedVerifierHash, Decryptor, -1); } } using (HashAlgorithm hasher = TEncryptionKey.CreateHasher()) { byte[] DecriptedVerifierHash2 = hasher.ComputeHash(DecriptedVerifier); if (!FlxUtils.CompareMem(DecriptedVerifierHash, 0, DecriptedVerifierHash2, 0, VerifierHashSizeBytes)) { return(false); } } return(true); }
public override int CompareTo(object obj) { int Result = base.CompareTo(obj); if (Result != 0) { return(Result); } TPdfType2Function o2 = obj as TPdfType2Function; Debug.Assert(o2 != null, "The object should be a TPdfType0Function, this has been checked in base Compare"); Result = FlxUtils.CompareArray(C0, o2.C0); if (Result != 0) { return(Result); } Result = FlxUtils.CompareArray(C1, o2.C1); if (Result != 0) { return(Result); } Result = N.CompareTo(o2.N); if (Result != 0) { return(Result); } return(Result); }
public override int CompareTo(object obj) { int Result = base.CompareTo(obj); if (Result != 0) { return(Result); } TPdfType0Function o2 = obj as TPdfType0Function; Debug.Assert(o2 != null, "The object should be a TPdfType0Function, this has been checked in base Compare"); Result = FlxUtils.CompareArray(Data, o2.Data); if (Result != 0) { return(Result); } Result = FlxUtils.CompareArray(Size, o2.Size); if (Result != 0) { return(Result); } Result = BitsPerSample.CompareTo(o2.BitsPerSample); if (Result != 0) { return(Result); } return(Result); }
public virtual int CompareTo(object obj) { //Remember not to compare FunctionObjId TPdfFunction o2 = obj as TPdfFunction; if (o2 == null) { return(1); } int Result = FunctionType.CompareTo(o2.FunctionType); if (Result != 0) { return(Result); } Result = FlxUtils.CompareArray(Domain, o2.Domain); if (Result != 0) { return(Result); } Result = FlxUtils.CompareArray(Range, o2.Range); if (Result != 0) { return(Result); } return(0); }
/// <summary> /// Creates the headers for a multipart MIME file. This must be the first method to call in order to create a MIME file. /// After this, you need to call <see cref="AddPartHeader"/> and start adding the parts of the message, and you <b>always</b> /// need to end the message by calling <see cref="EndMultiPartMessage"/>. /// </summary> /// <param name="message"></param> /// <param name="multipartType">Type of multipart for this file.</param> /// <param name="contentType">Type of the header as defined in the MIME standard, e.g. "text/plain", "text/html", etc. This is the type of the main part on a related message. Set it to null if there is no main part.</param> /// <param name="contentLocation">The location for the whole mime file. null if you do not want to set a location. for this to work in ie/opera, etc, this should be something like "file:///filename.ext"</param> public void CreateMultiPartMessage(TextWriter message, TMultipartType multipartType, string contentType, Uri contentLocation) { //IsMailNewsSave does not seem to be working in mono 1.2.5.1 if (!FlxUtils.IsMonoRunning() && !message.Encoding.IsMailNewsSave) { FlxMessages.ThrowException(FlxErr.ErrInvalidEncodingForMIME, message.Encoding.EncodingName); } WriteLine(message, "MIME-Version: 1.0"); //Encoding on the contentLocation must be done ONLY in the header. //QEncode has problems with OPERA 9, it will not recognize it. //if (contentLocation != null) WriteLine(message, "Content-Location: " + QEncode(contentLocation, TQEncodeMetaInfo.OnlyIfNeeded)); if (contentLocation != null) { WriteLine(message, "Content-Location: " + contentLocation.AbsoluteUri); //Use AbsoluteUri instead of ToString() so unicode characters are escaped. } string MType = "related"; switch (multipartType) { case TMultipartType.Alternative: MType = "alternative"; break; case TMultipartType.Mixed: MType = "mixed"; break; case TMultipartType.Digest: MType = "digest"; break; case TMultipartType.Signed: MType = "signed"; break; } WriteLine(message, "Content-Type: multipart/" + MType + ";"); if (contentType != null) { WriteLine(message, "\ttype = \"" + contentType + "\";"); } Boundary = GetBoundary(); WriteLine(message, "\tboundary = \"" + Boundary + "\""); WriteLine(message); WriteLine(message, "This is a multi-part message in MIME format."); WriteLine(message); Write(message, "--" + Boundary); }
public override int CompareTo(object obj) { int Result = base.CompareTo(obj); if (Result != 0) { return(Result); } TPdfType3Function o2 = obj as TPdfType3Function; Debug.Assert(o2 != null, "The object should be a TPdfType0Function, this has been checked in base Compare"); Result = Functions.Length.CompareTo(o2.Functions.Length); if (Result != 0) { return(Result); } for (int i = 0; i < Functions.Length; i++) { Result = Functions[i].CompareTo(o2.Functions[i]); if (Result != 0) { return(Result); } } Result = FlxUtils.CompareArray(Bounds, o2.Bounds); if (Result != 0) { return(Result); } Result = FlxUtils.CompareArray(Encode, o2.Encode); if (Result != 0) { return(Result); } return(Result); }
internal override bool VerifyPass(string Password, TEncryptionParameters EncParams, TEncryptionKey Key) { if (!base.VerifyPass(Password, EncParams, Key)) { return(false); } using (AesManaged Engine = TEncryptionUtils.CreateEngine(EncParams)) { byte[] DecriptedVerifierHashInput; Key.CalcKey(TAgileEncryptionKey.VerifierHashInputBlockKey, null); using (ICryptoTransform Decryptor = Engine.CreateDecryptor(Key.Key, Key.IV)) { DecriptedVerifierHashInput = DecryptBytes(EncryptedVerifierHashInput, Decryptor, Key.Salt.Length); //this is the value padded to a blocksize multiple. We want only the Salt.Length initial bytes. DecriptedVerifierHashInput = Key.Hash(DecriptedVerifierHashInput); } byte[] DecriptedVerifierHashValue; Key.CalcKey(TAgileEncryptionKey.VerifierHashValueBlockKey, null); using (ICryptoTransform Decryptor = Engine.CreateDecryptor(Key.Key, Key.IV)) { DecriptedVerifierHashValue = DecryptBytes(EncryptedVerifierHashValue, Decryptor, DecriptedVerifierHashInput.Length); //this is the 20 byte value of the hash + 12 "0" so it goes up to 32. (32 is 2*blocksize) } if (!FlxUtils.CompareMem(DecriptedVerifierHashValue, DecriptedVerifierHashInput)) { return(false); } byte[] DecriptedKeyValue; Key.CalcKey(TAgileEncryptionKey.VerifierKeyValueBlockKey, null); using (ICryptoTransform Decryptor = Engine.CreateDecryptor(Key.Key, Key.IV)) { DecriptedKeyValue = DecryptBytes(EncryptedKeyValue, Decryptor, Key.KeySizeInBytes); } Key.Key = DecriptedKeyValue; } return(true); }