/// <summary>
 /// Get DublinCore Metadata of supported file formats using IDublinCore Interface.
 /// Feature is supported in version 18.5 or greater of the API
 /// </summary>
 public static void GetDublinCoreMetadataUsingIDublinCore()
 {
     try
     {
         string[] files = Directory.GetFiles(XMPFilesDirectory);
         foreach (string file in files)
         {
             try
             {
                 using (FormatBase format = FormatFactory.RecognizeFormat(file))
                 {
                     IDublinCore dublinCoreContainer = format as IDublinCore;
                     if (dublinCoreContainer != null)
                     {
                         DublinCoreMetadata dublinCoreMetadata = dublinCoreContainer.GetDublinCore();
                         if (dublinCoreMetadata != null)
                         {
                             Console.WriteLine(dublinCoreMetadata.Creator);
                             Console.WriteLine(dublinCoreMetadata.Format);
                             Console.WriteLine(dublinCoreMetadata.Subject);
                         }
                     }
                 }
             }
             catch
             {
                 Console.WriteLine("Could not load {0}", file);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
        public static FogInfo Read(FormatBase input)
        {
            FogInfo temp = new FogInfo();

            Stuffer.Stuff(temp, input, "FogInfo", true);
            return(temp);
        }
Exemplo n.º 3
0
        //ExEnd:ApplyLicense

        //ExStart:FormatRecognizer
        /// <summary>
        /// Gets directory name and recognizes format of files in that directory
        /// </summary>
        /// <param name="directorPath">Directory path</param>
        public static void GetFileFormats(string directorPath)
        {
            try
            {
                // path to the document
                directorPath = Common.MapSourceFilePath(directorPath);

                // get array of files inside directory
                string[] files = Directory.GetFiles(directorPath);

                foreach (string path in files)
                {
                    // recognize file by it's signature
                    FormatBase format = FormatFactory.RecognizeFormat(path);

                    if (format != null)
                    {
                        Console.WriteLine("File: {0}, type: {1}", Path.GetFileName(path), format.Type);
                    }
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
Exemplo n.º 4
0
        /**
         * Constructor
         */

        public DataFormatter(CultureInfo culture)
        {
            currentCulture = culture;
            formats        = new Dictionary <object, object>();

            // init built-in Formats

            FormatBase zipFormat = ZipPlusFourFormat.instance;

            AddFormat("00000\\-0000", zipFormat);
            AddFormat("00000-0000", zipFormat);

            FormatBase phoneFormat = PhoneFormat.instance;

            // allow for FormatBase string variations
            AddFormat("[<=9999999]###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("[<=9999999]###-####;(###) ###-####", phoneFormat);
            AddFormat("###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("###-####;(###) ###-####", phoneFormat);

            FormatBase ssnFormat = SSNFormat.instance;

            AddFormat("000\\-00\\-0000", ssnFormat);
            AddFormat("000-00-0000", ssnFormat);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Takes manufacturer as input and returns photos made on particular camera
        /// </summary>
        /// <param name="manufacturer">Camera manufacturer name</param>
        public void FilterByCameraManufacturer(string manufacturer)
        {
            // Map directory in source folder
            string sourceDirectoryPath = Common.MapSourceFilePath(this.PhotosDirectory);

            // get jpeg files
            string[] files = Directory.GetFiles(sourceDirectoryPath, "*.jpg");

            List <string> result = new List <string>();

            foreach (string path in files)
            {
                // recognize file
                FormatBase format = FormatFactory.RecognizeFormat(path);

                // casting to JpegFormat
                if (format is JpegFormat)
                {
                    JpegFormat jpeg = (JpegFormat)format;

                    // get exif data
                    JpegExifInfo exif = (JpegExifInfo)jpeg.GetExifInfo();

                    if (exif != null)
                    {
                        if (string.Compare(exif.Make, manufacturer, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            // add file path to list
                            result.Add(Path.GetFileName(path));
                        }
                    }
                }
            }
            Console.WriteLine(string.Join("\n", result));
        }
Exemplo n.º 6
0
        private void ShowIssues(TabItem tabItem)
        {
            if (model == null)
            {
                return;
            }

            FormatBase fmt = GetFormatFromTab(tabItem);

            if (fmt != null)
            {
                model.SetGuiIssues(fmt.Issues);
            }
            else
            {
                model.SetGuiIssues(model.Data.Issues);
            }

            model.Data.NotifyPropertyChanged("GuiIssues");

            if (diagsList.Items.Count > 1)
            {
                diagsList.ScrollIntoView(diagsList.Items[diagsList.Items.Count - 1]);
            }
        }
Exemplo n.º 7
0
        /**
         * Constructor
         */
        public DataFormatter(CultureInfo culture)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            formats = new Hashtable();

            // init built-in Formats

            FormatBase zipFormat = ZipPlusFourFormat.instance;

            AddFormat("00000\\-0000", zipFormat);
            AddFormat("00000-0000", zipFormat);

            FormatBase phoneFormat = PhoneFormat.instance;

            // allow for FormatBase string variations
            AddFormat("[<=9999999]###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("[<=9999999]###-####;(###) ###-####", phoneFormat);
            AddFormat("###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("###-####;(###) ###-####", phoneFormat);

            FormatBase ssnFormat = SSNFormat.instance;

            AddFormat("000\\-00\\-0000", ssnFormat);
            AddFormat("000-00-0000", ssnFormat);
        }
Exemplo n.º 8
0
    void FormatBase.OnChange(FormatBase A_0, int A_1)
    {
        int num = A_1;

        if (num > 0x9ce)
        {
            if (num > 0xa28)
            {
                if (((num != 0xa32) && (num != 0xa3c)) && (num != 0xa46))
                {
                    return;
                }
            }
            else
            {
                switch (num)
                {
                case 0x9d8:
                case 0x9e2:
                    goto Label_0082;
                }
                if (num != 0xa28)
                {
                    return;
                }
            }
            this.method_138().IsDefault = false;
            return;
        }
        if (num <= 0x8fc)
        {
            if (((num != 0x8e8) && (num != 0x8f2)) && (num != 0x8fc))
            {
                return;
            }
        }
        else
        {
            switch (num)
            {
            case 0x906:
            case 0x908:
                goto Label_0054;

            case 0x907:
                return;

            case 0x9c4:
            case 0x9ce:
                goto Label_0082;
            }
            return;
        }
Label_0054:
        this.method_50().IsDefault = false;
        return;

Label_0082:
        this.method_139().IsDefault = false;
    }
Exemplo n.º 9
0
            public override void ReportFormat(FormatBase fb, bool logErrorsToFile = false)
            {
                base.ReportFormat(fb);

                if (logErrorsToFile && fb.Issues.HasError)
                {
                    try
                    {
                        using (var sw = new StreamWriter(Data.CurrentDirectory + Path.DirectorySeparatorChar
                                                         + Data.NoncompliantName, false, new UTF8Encoding(true)))
                        {
                            var dn = Path.GetDirectoryName(fb.Path);

                            sw.WriteLine($"Diagnostics by the vitriolic {Data.Product} v{Data.ProductVersion}:");
                            sw.WriteLine();
                            sw.Write(dn);
                            sw.WriteLine(Path.DirectorySeparatorChar);
                            sw.WriteLine(fb.Name);
                            sw.WriteLine();

                            foreach (var issue in fb.Issues.Items)
                            {
                                var severity = issue.Level;
                                var prefix   = severity < Severity.Warning? "  " : severity == Severity.Warning? "  Warning: " : "* Error: ";
                                sw.Write(prefix);
                                sw.WriteLine(issue.Message);
                            }
                        }
                    }
                    catch (UnauthorizedAccessException)
                    { /* discard */ }
                }
Exemplo n.º 10
0
        public void Test_Ico_Misnamed()
        {
            var model = new Diags.Model(null);

            var fn   = @"Targets\Singles\DutchIco.jpeg";
            var file = new FileInfo(fn);

            bool       isKnown;
            FileFormat actual;
            var        fs  = new FileStream(fn, FileMode.Open);
            var        fmt = FormatBase.CreateModel(model.Data.FileFormats.Items, fs, fn, 0, 0, null, out isKnown, out actual);
            var        fb  = fmt.Data;

            Assert.IsNotNull(fmt);
            Assert.IsTrue(fb.Issues.MaxSeverity == Severity.Warning);
            Assert.AreEqual(1, fb.Issues.Items.Count);
            Assert.IsInstanceOfType(fmt, typeof(IcoFormat.Model));
            Assert.AreEqual("ico", actual.PrimaryName);

            Assert.AreEqual(1, fb.Issues.RepairableCount);

            string errMsg = fmt.IssueModel.Repair(0);

            Assert.AreEqual(0, fb.Issues.RepairableCount);
            Assert.IsNull(errMsg);
        }
Exemplo n.º 11
0
        /**
         * Constructor
         */
        public DataFormatter(CultureInfo culture, bool localeIsAdapting, bool emulateCSV)
        {
            this.localeIsAdapting = true;
            this.currentCulture   = culture;
            //localeChangedObservable.addObserver(this);
            // localeIsAdapting must be true prior to this first checkForLocaleChange call.
            //localeChangedObservable.checkForLocaleChange(culture);
            // set localeIsAdapting so subsequent checks perform correctly
            // (whether a specific locale was provided to this DataFormatter or DataFormatter should
            // adapt to the current user locale as the locale changes)
            this.localeIsAdapting = localeIsAdapting;
            this.emulateCSV       = emulateCSV;
            formats = new Hashtable();

            // init built-in Formats
            FormatBase zipFormat = ZipPlusFourFormat.instance;

            AddFormat("00000\\-0000", zipFormat);
            AddFormat("00000-0000", zipFormat);

            FormatBase phoneFormat = PhoneFormat.instance;

            // allow for FormatBase string variations
            AddFormat("[<=9999999]###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("[<=9999999]###-####;(###) ###-####", phoneFormat);
            AddFormat("###\\-####;\\(###\\)\\ ###\\-####", phoneFormat);
            AddFormat("###-####;(###) ###-####", phoneFormat);

            FormatBase ssnFormat = SSNFormat.instance;

            AddFormat("000\\-00\\-0000", ssnFormat);
            AddFormat("000-00-0000", ssnFormat);
        }
Exemplo n.º 12
0
        private FormatBase GetFormat(double cellValue, int formatIndex, String formatStr)
        {
            // Excel's # with value 0 will output empty where Java will output 0. This hack removes the # from the format.
            if (emulateCsv && cellValue == 0.0 && formatStr.Contains("#") && !formatStr.Contains("0"))
            {
                formatStr = formatStr.Replace("#", "");
            }
            FormatBase format = (FormatBase)formats[formatStr];

            if (format != null)
            {
                return(format);
            }
            if (formatStr.Equals("General"))
            {
                if (DataFormatter.IsWholeNumber(cellValue))
                {
                    return(generalWholeNumFormat);
                }
                return(generalDecimalNumFormat);
            }
            format             = CreateFormat(cellValue, formatIndex, formatStr);
            formats[formatStr] = format;
            return(format);
        }
Exemplo n.º 13
0
            public void ReportFormat(FormatBase fb)
            {
                reportScope = Data.Scope;
                IList <string> report = fb.GetReportHeader(reportScope);

                if (reportScope == Granularity.Detail)
                {
                    fb.GetReportDetail(report);
                    Data.OnMessageSend(String.Empty, Severity.NoIssue);
                }
                else if (reportScope > Granularity.Terse)
                {
                    if (Data.Response == Interaction.PromptToRepair && fb.Issues.RepairableCount > 0)
                    {
                        reportScope = Granularity.Terse;
                    }
                }

                foreach (var lx in report)
                {
                    Data.OnMessageSend(lx);
                }

                reportHasWarn    = false;
                reportHasErr     = false;
                reportIssueIndex = 0;
                ReportIssues(fb.Issues);
            }
Exemplo n.º 14
0
        internal override void CopyPropertiesTo(FormatBase destFormat)
        {
            MarginsF sf = destFormat as MarginsF;

            if (base.HasKey(1))
            {
                sf.Left = this.Left;
            }
            if (base.HasKey(2))
            {
                sf.Right = this.Right;
            }
            if (base.HasKey(4))
            {
                sf.Bottom = this.Bottom;
            }
            if (base.HasKey(3))
            {
                sf.Top = this.Top;
            }
            if (base.HasKey(5))
            {
                sf.Gutter = this.Gutter;
            }
        }
Exemplo n.º 15
0
        public static GroupInformation Read(FormatBase input)
        {
            GroupInformation temp = new GroupInformation();

            Stuffer.Stuff(temp, input, "GroupInformation", true);
            return(temp);
        }
Exemplo n.º 16
0
            public void RefreshTab(FormatBase fmt)
            {
                if (fmt is M3uFormat m3u)
                {
                    Data.M3u = m3u;
                }
                else if (fmt is Mp3Format mp3)
                {
                    Data.Mp3 = mp3;
                }
                else if (fmt is OggFormat ogg)
                {
                    Data.Ogg = ogg;
                }
                else if (fmt is Sha1Format sha1)
                {
                    Data.Sha1 = sha1;
                }
                else if (fmt is Md5Format md5)
                {
                    Data.Md5 = md5;
                }

                TabInfo ti = Data.tabInfo[fmt.ValidNames[0]];

                Data.CurrentTabNumber = ti.TabPosition;

                Data.RaisePropertyChangedEvent(null);
            }
Exemplo n.º 17
0
 /**
  * Performs Excel-style date formatting, using the
  *  supplied Date and format
  */
 private String PerformDateFormatting(DateTime d, FormatBase dateFormat)
 {
     if (dateFormat != null)
     {
         return(dateFormat.Format(d));
     }
     return(defaultDateformat.Format(d));
 }
Exemplo n.º 18
0
 /**
  * Performs Excel-style date formatting, using the
  *  supplied Date and format
  */
 private String PerformDateFormatting(DateTime d, FormatBase dateFormat)
 {
     if (dateFormat != null)
     {
         return(dateFormat.Format(d, currentCulture));
     }
     return(d.ToString());
 }
Exemplo n.º 19
0
 internal Class14(FormatBase A_0, int A_1) : base(A_0, A_1)
 {
     this.frameDividerPositionType_0 = FrameDividerPositionType.Relative;
     this.int_8                = 1;
     this.class906_0           = new Class906();
     this.color_0              = Color.Empty;
     this.framesetBorderType_0 = FramesetBorderType.Simple;
 }
Exemplo n.º 20
0
            private FormatBase.Model CheckFile(Stream stream, string path, Hashes hashFlags, out FileFormat trueFormat, out Severity resultCode)
            {
                FormatBase.Model fmtModel = null;
                try
                {
                    fmtModel = FormatBase.Model.Create(stream, path, hashFlags, Data.ValidationFlags, Data.Filter, out trueFormat);
                }
#pragma warning disable 0168
                catch (Exception ex)
#pragma warning restore 0168
                {
#if DEBUG
                    throw;
#else
                    Data.OnMessageSend("Exception: " + ex.Message.TrimEnd(null), Severity.Fatal);
                    ++Data.TotalErrors;
                    trueFormat = null;
                    resultCode = Severity.Fatal;
                    return(null);
#endif
                }

                if (fmtModel == null)
                {
                    if (Data.Scope <= Granularity.Verbose)
                    {
                        if (Data.Scope == Granularity.Verbose && Data.IsDigestForm)
                        {
                            Data.OnMessageSend("; " + Data.CurrentFile, Severity.NoIssue);
                        }
                        Data.OnMessageSend("Unknown extension ignored.", Severity.Trivia);
                    }
                    stream.Dispose();
                    resultCode = Severity.NoIssue;
                    return(null);
                }

                FormatBase fmt = fmtModel.Data;

                ++Data.TotalFiles;
                if (trueFormat != null)
                {
                    ++trueFormat.TrueTotal;
                    if (fmt.IsBadHeader)
                    {
                        ++trueFormat.TotalHeaderErrors;
                    }
                    if (fmt.IsBadData)
                    {
                        ++trueFormat.TotalDataErrors;
                    }
                }

                fmtModel.IssueModel.Escalate(Data.WarnEscalator, Data.ErrEscalator);
                ReportFormat(fmt);
                resultCode = fmt.Issues.MaxSeverity;
                return(fmtModel);
            }
Exemplo n.º 21
0
 internal static bool ParseTextToDateTime(string text, FormatBase format, out DateTime value)
 {
     value = DateTime.MinValue;
     if (format is DateFormat)
     {
         return(DateTime.TryParse(text, CultureInfo.CurrentCulture.DateTimeFormat, DateTimeStyles.None, out value));
     }
     return(false);
 }
Exemplo n.º 22
0
 public static bool ParseTextToDecimal(string text, FormatBase format, out decimal value)
 {
     value = 0;
     if (format is NumberFormat || format is CurrencyFormat)
     {
         return(decimal.TryParse(text, NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat, out value));
     }
     return(false);
 }
Exemplo n.º 23
0
        /**
         * Creates a new date formatter with the given specification.
         *
         * @param format The format.
         */
        public CellDateFormatter(String format)
            : base(format)
        {
            DatePartHandler partHandler = new DatePartHandler(this);
            StringBuilder   descBuf     = CellFormatPart.ParseFormat(format,
                                                                     CellFormatType.DATE, partHandler);

            partHandler.Finish(descBuf);
            dateFmt = new SimpleDateFormat(descBuf.ToString());
        }
Exemplo n.º 24
0
        /**
         * Formats the given raw cell value, based on the supplied
         *  format index and string, according to excel style rules.
         * @see #formatCellValue(Cell)
         */
        public String FormatRawCellContents(double value, int formatIndex, String formatString, bool use1904Windowing)
        {
            // Is it a date?
            if (DateUtil.IsADateFormat(formatIndex, formatString))
            {
                if (DateUtil.IsValidExcelDate(value))
                {
                    FormatBase dateFormat = GetFormat(value, formatIndex, formatString);

                    if (dateFormat is ExcelStyleDateFormatter)
                    {
                        // Hint about the raw excel value
                        ((ExcelStyleDateFormatter)dateFormat).SetDateToBeFormatted(value);
                    }

                    DateTime d = DateUtil.GetJavaDate(value, use1904Windowing);
                    return(PerformDateFormatting(d, dateFormat));
                }

                // RK: Invalid dates are 255 #s.
                if (emulateCSV)
                {
                    return(invalidDateTimeString);
                }
            }
            // else Number
            FormatBase numberFormat = GetFormat(value, formatIndex, formatString);

            if (numberFormat == null)
            {
                return(value.ToString(currentCulture));
            }
            // When formatting 'value', double to text to BigDecimal produces more
            // accurate results than double to Double in JDK8 (as compared to
            // previous versions). However, if the value contains E notation, this
            // would expand the values, which we do not want, so revert to
            // original method.
            String result;
            String textValue = NumberToTextConverter.ToText(value);

            if (textValue.IndexOf('E') > -1)
            {
                result = numberFormat.Format(value);
            }
            else
            {
                result = numberFormat.Format(textValue);
            }
            // Complete scientific notation by adding the missing +.
            if (result.Contains("E") && !result.Contains("E-"))
            {
                result = result.Replace("E", "E+");
            }
            return(result);
        }
        /// <summary>
        /// Takes author name and removes metadata in files created by specified author
        /// </summary>
        /// <param name="authorName">Author name</param>
        public void RemoveMetadataByAuthor(string authorName)
        {
            // Map directory in source folder
            string sourceDirectoryPath = Common.MapSourceFilePath(this.DocumentsPath);

            // get files presented in target directory
            string[] files = Directory.GetFiles(sourceDirectoryPath);

            foreach (string path in files)
            {
                // recognize format
                using (FormatBase format = FormatFactory.RecognizeFormat(path))
                {
                    // initialize DocFormat
                    DocFormat docFormat = format as DocFormat;
                    if (docFormat != null)
                    {
                        // get document properties
                        DocMetadata properties = docFormat.DocumentProperties;

                        // check if author is the same
                        if (string.Equals(properties.Author, authorName, StringComparison.OrdinalIgnoreCase))
                        {
                            // remove comments
                            docFormat.ClearComments();

                            List <string> customKeys = new List <string>();

                            // find all custom keys
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    customKeys.Add(keyValuePair.Key);
                                }
                            }

                            // and remove all of them
                            foreach (string key in customKeys)
                            {
                                properties.Remove(key);
                            }
                            //====== yet to change things =========================
                            // and commit changes
                            string fileName       = Path.GetFileName(path);
                            string outputFilePath = Common.MapDestinationFilePath(this.DocumentsPath + "/" + fileName);
                            docFormat.Save(outputFilePath);
                            //=====================================================
                        }
                    }
                }
            }

            Console.WriteLine("Press any key to exit.");
        }
Exemplo n.º 26
0
        /**
         * Returns the Formatted value of an Excel date as a <c>String</c> based
         * on the cell's <c>DataFormat</c>. i.e. "Thursday, January 02, 2003"
         * , "01/02/2003" , "02-Jan" , etc.
         *
         * @param cell The cell
         * @return a Formatted date string
         */
        private String GetFormattedDateString(ICell cell)
        {
            FormatBase dateFormat = GetFormat(cell);
            DateTime   d          = cell.DateCellValue;

            if (dateFormat != null)
            {
                return(dateFormat.Format(d, currentCulture));
            }
            return(d.ToString());
        }
Exemplo n.º 27
0
        /**
         * Returns the Formatted value of an Excel number as a <tt>String</tt>
         * based on the cell's <c>DataFormat</c>. Supported Formats include
         * currency, percents, decimals, phone number, SSN, etc.:
         * "61.54%", "$100.00", "(800) 555-1234".
         *
         * @param cell The cell
         * @return a Formatted number string
         */
        private String GetFormattedNumberString(HSSFCell cell)
        {
            FormatBase numberFormat = GetFormat(cell);
            double     d            = cell.NumericCellValue;

            if (numberFormat == null)
            {
                return(d.ToString());
            }
            return(numberFormat.Format(d));
        }
Exemplo n.º 28
0
            public void ShowContents()
            {
                TabInfo.Model tiModel = Data.tiModels[Data.CurrentTabNumber];
                FormatBase    fmt     = tiModel.GetFormatBase();

                if (Object.ReferenceEquals(fmt, Data.BaseFormat))
                {
                    Data.BaseFormat = null;
                }
                Data.BaseFormat = fmt;
            }
Exemplo n.º 29
0
        /**
         * Returns the Formatted value of an Excel date as a <tt>String</tt> based
         * on the cell's <c>DataFormat</c>. i.e. "Thursday, January 02, 2003"
         * , "01/02/2003" , "02-Jan" , etc.
         *
         * @param cell The cell
         * @return a Formatted date string
         */
        private String GetFormattedDateString(HSSFCell cell)
        {
            FormatBase dateFormat = GetFormat(cell);
            DateTime   d          = cell.DateCellValue;

            if (dateFormat != null)
            {
                return(dateFormat.Format(d));
            }
            return(d.ToString());
        }
Exemplo n.º 30
0
        /**
         * Returns the Formatted value of an Excel number as a <c>String</c>
         * based on the cell's <c>DataFormat</c>. Supported Formats include
         * currency, percents, decimals, phone number, SSN, etc.:
         * "61.54%", "$100.00", "(800) 555-1234".
         *
         * @param cell The cell
         * @return a Formatted number string
         */

        private string GetFormattedNumberString(ICell cell)
        {
            FormatBase numberFormat = GetFormat(cell);
            double     d            = cell.NumericCellValue;

            if (numberFormat == null)
            {
                return(d.ToString(currentCulture));
            }
            return(numberFormat.Format(d, currentCulture));
        }
Exemplo n.º 31
0
 public static FacePosition Read(FormatBase input)
 {
     return new FacePosition(input.readUInt16(), input.readUInt16(), input.readUInt16());
 }
Exemplo n.º 32
0
 /**
  * Creates a new date formatter with the given specification.
  *
  * @param format The format.
  */
 public CellDateFormatter(String format)
     : base(format)
 {
     ;
     DatePartHandler partHandler = new DatePartHandler(this);
     StringBuilder descBuf = CellFormatPart.ParseFormat(format,
             CellFormatType.DATE, partHandler);
     partHandler.Finish(descBuf);
     dateFmt = new SimpleDateFormat(descBuf.ToString());
 }
Exemplo n.º 33
0
    /**
 * Performs Excel-style date formatting, using the
 *  supplied Date and format
 */
    private String PerformDateFormatting(DateTime d, FormatBase dateFormat)
    {
        if (dateFormat != null)
        {
            return dateFormat.Format(d);
        }
        return d.ToString();
    }
Exemplo n.º 34
0
 /**
  * 
  * Sets a default number FormatBase to be used when the Excel FormatBase cannot be
  * Parsed successfully. <b>Note:</b> This is a fall back for when an error
  * occurs while parsing an Excel number FormatBase pattern. This will not
  * affect cells with the <em>General</em> FormatBase.
  * 
  * 
  * The value that will be passed to the FormatBase's FormatBase method (specified
  * by <c>java.text.FormatBase#FormatBase</c>) will be a double value from a
  * numeric cell. Therefore the code in the FormatBase method should expect a
  * <c>Number</c> value.
  * 
  *
  * @param FormatBase A FormatBase instance to be used as a default
  * @see java.text.FormatBase#FormatBase
  */
 public void SetDefaultNumberFormat(FormatBase format)
 {
     IEnumerator itr = formats.Keys.GetEnumerator();
     while (itr.MoveNext())
     {
         string key = (string)itr.Current;
         if (formats[key] == generalDecimalNumFormat
                 || formats[key] == generalWholeNumFormat)
         {
             formats[key] = format;
         }
     }
     defaultNumFormat = format;
 }
Exemplo n.º 35
0
 /**
  * Adds a new FormatBase to the available formats.
  * 
  * The value that will be passed to the FormatBase's FormatBase method (specified
  * by <c>java.text.FormatBase#FormatBase</c>) will be a double value from a
  * numeric cell. Therefore the code in the FormatBase method should expect a
  * <c>Number</c> value.
  * 
  * @param excelformatStr The data FormatBase string
  * @param FormatBase A FormatBase instance
  */
 public void AddFormat(String excelformatStr, FormatBase format)
 {
     formats[excelformatStr] = format;
 }
Exemplo n.º 36
0
 public static FaceInfo Read(FormatBase input)
 {
     return new FaceInfo(input.readUInt8(), input.readUInt8());
 }