/**
         * @param in the RecordInputstream to Read the record from
         */

        public SharedFormulaRecord(RecordInputStream in1)
            : base(in1)
        {
            field_5_reserved = in1.ReadShort();
            int field_6_expression_len = in1.ReadShort();
            int nAvailableBytes = in1.Available();
            field_7_parsed_expr = LF.Utils.NPOI.SS.Formula.Formula.Read(field_6_expression_len, in1, nAvailableBytes);
        }
Example #2
0
        /**
         * Constructs a LinkedData record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public LinkedDataRecord(RecordInputStream in1)
        {
            field_1_linkType = (byte)in1.ReadByte();
            field_2_referenceType = (byte)in1.ReadByte();
            field_3_options = in1.ReadShort();
            field_4_indexNumberFmtRecord = in1.ReadShort();
            int encodedTokenLen = in1.ReadUShort();
            field_5_formulaOfLink = Formula.Read(encodedTokenLen, in1);
        }
Example #3
0
        /**
         * Constructs a Name record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */
        public NameRecord(RecordInputStream ris)
        {
            byte[] remainder = ris.ReadAllContinuedRemainder();
            ILittleEndianInput in1 = new LittleEndianByteArrayInputStream(remainder);
            field_1_option_flag                 = in1.ReadShort();
		    field_2_keyboard_shortcut           = (byte)in1.ReadByte();
		    int field_3_length_name_text        = in1.ReadByte();
		    int field_4_length_name_definition  = in1.ReadShort();
		    field_5_externSheetIndex_plus1      = in1.ReadShort();
		    field_6_sheetNumber                 = in1.ReadUShort();
		    int field_7_length_custom_menu      = in1.ReadUByte();
		    int field_8_length_description_text = in1.ReadUByte();
		    int field_9_length_help_topic_text  = in1.ReadUByte();
		    int field_10_length_status_bar_text = in1.ReadUByte();

		    //store the name in byte form if it's a built-in name
		    field_11_nameIsMultibyte = (in1.ReadByte() != 0);
		    if (IsBuiltInName) {
			    field_12_built_in_code = (byte)in1.ReadByte();
		    } else {
			    if (field_11_nameIsMultibyte) {
                    field_12_name_text = StringUtil.ReadUnicodeLE(in1, field_3_length_name_text);
			    } else {
                    field_12_name_text = StringUtil.ReadCompressedUnicode(in1, field_3_length_name_text);
			    }
		    }
          int nBytesAvailable = in1.Available() - (field_7_length_custom_menu
				+ field_8_length_description_text + field_9_length_help_topic_text + field_10_length_status_bar_text);
		    field_13_name_definition = SSFormula.Formula.Read(field_4_length_name_definition, in1, nBytesAvailable);

		    //Who says that this can only ever be compressed unicode???
            field_14_custom_menu_text = StringUtil.ReadCompressedUnicode(in1, field_7_length_custom_menu);
            field_15_description_text = StringUtil.ReadCompressedUnicode(in1, field_8_length_description_text);
            field_16_help_topic_text = StringUtil.ReadCompressedUnicode(in1, field_9_length_help_topic_text);
            field_17_status_bar_text = StringUtil.ReadCompressedUnicode(in1, field_10_length_status_bar_text);

        }
Example #4
0
        /** Creates new NameRecord */
        public NameRecord()
        {
            field_13_name_definition = SSFormula.Formula.Create(Ptg.EMPTY_PTG_ARRAY);

            field_12_name_text = "";
            field_14_custom_menu_text = "";
            field_15_description_text = "";
            field_16_help_topic_text = "";
            field_17_status_bar_text = "";
        }
Example #5
0
        public DVRecord(int validationType, int operator1, int errorStyle, bool emptyCellAllowed,
            bool suppressDropDownArrow, bool isExplicitList,
            bool showPromptBox, String promptTitle, String promptText,
            bool showErrorBox, String errorTitle, String errorText,
            Ptg[] formula1, Ptg[] formula2,
            CellRangeAddressList regions)
        {

            int flags = 0;
            flags = opt_data_type.SetValue(flags, validationType);
            flags = opt_condition_operator.SetValue(flags, operator1);
            flags = opt_error_style.SetValue(flags, errorStyle);
            flags = opt_empty_cell_allowed.SetBoolean(flags, emptyCellAllowed);
            flags = opt_suppress_dropdown_arrow.SetBoolean(flags, suppressDropDownArrow);
            flags = opt_string_list_formula.SetBoolean(flags, isExplicitList);
            flags = opt_show_prompt_on_cell_selected.SetBoolean(flags, showPromptBox);
            flags = opt_show_error_on_invalid_value.SetBoolean(flags, showErrorBox);
            _option_flags = flags;
            _promptTitle = ResolveTitleText(promptTitle);
            _promptText = ResolveTitleText(promptText);
            _errorTitle = ResolveTitleText(errorTitle);
            _errorText = ResolveTitleText(errorText);
            _formula1 = LF.Utils.NPOI.SS.Formula.Formula.Create(formula1);
            _formula2 = LF.Utils.NPOI.SS.Formula.Formula.Create(formula2);
            _regions = regions;
        }
Example #6
0
        /**
         * Constructs a DV record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public DVRecord(RecordInputStream in1)
        {
            _option_flags = in1.ReadInt();

            _promptTitle = ReadUnicodeString(in1);
            _errorTitle = ReadUnicodeString(in1);
            _promptText = ReadUnicodeString(in1);
            _errorText = ReadUnicodeString(in1);

            int field_size_first_formula = in1.ReadUShort();
            _not_used_1 = in1.ReadShort();

            //read first formula data condition
            _formula1 = LF.Utils.NPOI.SS.Formula.Formula.Read(field_size_first_formula, in1);

            int field_size_sec_formula = in1.ReadUShort();
            _not_used_2 = in1.ReadShort();

            //read sec formula data condition
            _formula2 = LF.Utils.NPOI.SS.Formula.Formula.Read(field_size_sec_formula, in1);

            //read cell range address list with all affected ranges
            _regions = new CellRangeAddressList(in1);
        }
        public ExternalNameRecord(RecordInputStream in1)
        {
            field_1_option_flag = in1.ReadShort();
            field_2_ixals = in1.ReadShort();
            field_3_not_used = in1.ReadShort();
            int numChars = in1.ReadUByte();
            field_4_name = StringUtil.ReadUnicodeString(in1, numChars);

            // the record body can take different forms.
            // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag
            if (!IsOLELink && !IsStdDocumentNameIdentifier)
            {
                // another switch: the fWantAdvise bit specifies whether the body describes
                // an external defined name or a DDE data item
                if (IsAutomaticLink)
                {
                    if (in1.Available() > 0)
                    {
                        //body specifies DDE data item
                        int nColumns = in1.ReadUByte() + 1;
                        int nRows = in1.ReadShort() + 1;

                        int totalCount = nRows * nColumns;
                        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
                        _nColumns = nColumns;
                        _nRows = nRows;
                    }
                }
                else
                {
                    //body specifies an external defined name
                    int formulaLen = in1.ReadUShort();
                    field_5_name_definition = Formula.Read(formulaLen, in1);
                }
            }
            //int nameLength = in1.ReadUByte();
            //int multibyteFlag = in1.ReadUByte();
            //if (multibyteFlag == 0)
            //{
            //    field_4_name = in1.ReadCompressedUnicode(nameLength);
            //}
            //else
            //{
            //    field_4_name = in1.ReadUnicodeLEString(nameLength);
            //}
            //if (!HasFormula)
            //{
            //    if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink)
            //    {
            //        // both need to be incremented
            //        int nColumns = in1.ReadUByte() + 1;
            //        int nRows = in1.ReadShort() + 1;

            //        int totalCount = nRows * nColumns;
            //        _ddeValues = ConstantValueParser.Parse(in1, totalCount);
            //        _nColumns = nColumns;
            //        _nRows = nRows;
            //    }

            //    if (in1.Remaining > 0)
            //    {
            //        throw ReadFail("Some Unread data (is formula present?)");
            //    }
            //    field_5_name_definition = null;
            //    return;
            //}
            //int nBytesRemaining = in1.Available();
            //if (in1.Remaining <= 0)
            //{
            //    throw ReadFail("Ran out of record data trying to read formula.");
            //}
            //short formulaLen = in1.ReadShort();
            //nBytesRemaining -= 2;
            //field_5_name_definition = LF.Utils.NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining);
        }
 public void SetParsedExpression(Ptg[] ptgs)
 {
     field_5_name_definition = Formula.Create(ptgs);
 }
 private SharedFormulaRecord(CellRangeAddress8Bit range):
     base(range)
 {
     field_7_parsed_expr = Formula.Create(Ptg.EMPTY_PTG_ARRAY);
 }
Example #10
0
 public bool IsSame(Formula other)
 {
     return Arrays.Equals(_byteEncoding, other._byteEncoding);
 }
Example #11
0
 /**
  * Gets the {@link Ptg} array from the supplied {@link Formula}. 
  * Handles <code>null</code>s OK.
  * 
  * @param formula may be <code>null</code>
  * @return possibly <code>null</code> (if the supplied <c>formula</c> is <code>null</code>)
  */
 public static Ptg[] GetTokens(Formula formula)
 {
     if (formula == null)
     {
         return null;
     }
     return formula.Tokens;
 }
Example #12
0
        public CFRuleRecord(RecordInputStream in1)
        {
            field_1_condition_type = (byte)in1.ReadByte();
            field_2_comparison_operator = (byte)in1.ReadByte();
            int field_3_formula1_len = in1.ReadUShort();
            int field_4_formula2_len = in1.ReadUShort();
            field_5_options = in1.ReadInt();
            field_6_not_used = in1.ReadShort();

            if (ContainsFontFormattingBlock)
            {
                fontFormatting = new FontFormatting(in1);
            }

            if (ContainsBorderFormattingBlock)
            {
                borderFormatting = new BorderFormatting(in1);
            }

            if (ContainsPatternFormattingBlock)
            {
                patternFormatting = new PatternFormatting(in1);
            }
            field_17_formula1 = FR.Formula.Read(field_3_formula1_len, in1);
            field_18_formula2 = FR.Formula.Read(field_4_formula2_len, in1);
	}
Example #13
0
 private CFRuleRecord(byte conditionType, ComparisonOperator comparisonOperation, Ptg[] formula1, Ptg[] formula2)
     :this(conditionType, comparisonOperation)
 {
     
     //field_1_condition_type = CONDITION_TYPE_CELL_VALUE_IS;
     //field_2_comparison_operator = (byte)comparisonOperation;
     field_17_formula1 = FR.Formula.Create(formula1);
     field_18_formula2 = FR.Formula.Create(formula2);
 }
Example #14
0
        /** Creates new CFRuleRecord */
        private CFRuleRecord(byte conditionType, ComparisonOperator comparisonOperation)
        {
            field_1_condition_type = conditionType;
            field_2_comparison_operator =(byte) comparisonOperation;

            // Set modification flags to 1: by default options are not modified
            field_5_options = modificationBits.SetValue(field_5_options, -1);
            // Set formatting block flags to 0 (no formatting blocks)
            field_5_options = fmtBlockBits.SetValue(field_5_options, 0);
            field_5_options = Undocumented.Clear(field_5_options);

            //TODO:: check what's this field used for
            field_6_not_used = unchecked((short)0x8002); // Excel seems to Write this value, but it doesn't seem to care what it Reads
            fontFormatting = null;
            //field_8_align_text_break = 0;
            //field_9_align_text_rotation_angle = 0;
            //field_10_align_indentation = 0;
            //field_11_relative_indentation = 0;
            //field_12_not_used = 0;
            borderFormatting = null;
            patternFormatting = null;
            field_17_formula1 = FR.Formula.Create(Ptg.EMPTY_PTG_ARRAY);
            field_18_formula2 = FR.Formula.Create(Ptg.EMPTY_PTG_ARRAY);
        }