"use strict";

(
	/**
	 * @param {Window} window
	 * @param {undefined} undefined
	 */
	function ( window, undefined) {


		if (!window["Asc"]) {window["Asc"] = {};}
		var prot;

		/** @constructor */
		function asc_CCellFlag(m, s, w, t, l) {
			this.merge = !!m;
			this.shrinkToFit = !!s;
			this.wrapText = !!w;
			this.selectionType = t;
			this.lockText = !!l;
		}

		asc_CCellFlag.prototype = {
			asc_getMerge: function() { return this.merge; },
			asc_getShrinkToFit: function() { return this.shrinkToFit; },
			asc_getWrapText: function() { return this.wrapText; },
			asc_getSelectionType: function() { return this.selectionType; },
			asc_getLockText: function() { return this.lockText; }
		};

		window["Asc"].asc_CCellFlag = window["Asc"]["asc_CCellFlag"] = asc_CCellFlag;
		prot = asc_CCellFlag.prototype;

		prot["asc_getMerge"] = prot.asc_getMerge;
		prot["asc_getShrinkToFit"] = prot.asc_getShrinkToFit;
		prot["asc_getWrapText"] = prot.asc_getWrapText;
		prot["asc_getSelectionType"] = prot.asc_getSelectionType;
		prot["asc_getLockText"] = prot.asc_getLockText;

		/** @constructor */
		function asc_CFont(name, size, color, b, i, u, s, sub, sup) {
			this.name = name !== undefined ? name : "Arial";
			this.size = size !== undefined ? size : 10;
			this.color = color !== undefined ? color : null;
			this.bold = !!b;
			this.italic = !!i;
			this.underline = !!u;
			this.strikeout = !!s;
			this.subscript = !!sub;
			this.superscript = !!sup;
		}

		asc_CFont.prototype = {
			asc_getName: function () { return this.name; },
			asc_getSize: function () { return this.size; },
			asc_getBold: function () { return this.bold; },
			asc_getItalic: function () { return this.italic; },
			asc_getUnderline: function () { return this.underline; },
			asc_getStrikeout: function () { return this.strikeout; },
			asc_getSubscript: function () { return this.subscript; },
			asc_getSuperscript: function () { return this.superscript; },
			asc_getColor: function () { return this.color; }
		};

		window["Asc"].asc_CFont = window["Asc"]["asc_CFont"] = asc_CFont;
		prot = asc_CFont.prototype;

		prot["asc_getName"]			= prot.asc_getName;
		prot["asc_getSize"]			= prot.asc_getSize;
		prot["asc_getBold"]			= prot.asc_getBold;
		prot["asc_getItalic"]		= prot.asc_getItalic;
		prot["asc_getUnderline"]	= prot.asc_getUnderline;
		prot["asc_getStrikeout"]	= prot.asc_getStrikeout;
		prot["asc_getSubscript"]	= prot.asc_getSubscript;
		prot["asc_getSuperscript"]	= prot.asc_getSuperscript;
		prot["asc_getColor"]		= prot.asc_getColor;

		/** @constructor */
		function asc_CFill(color) {
			this.color = color !== undefined ? color : null;
		}

		asc_CFill.prototype = {
			asc_getColor: function() { return this.color; }
		};

		window["Asc"].asc_CFill = window["Asc"]["asc_CFill"] = asc_CFill;
		prot = asc_CFill.prototype;

		prot["asc_getColor"] = prot.asc_getColor;

		/** @constructor */
		function asc_CBorder(style, color) {
			// ToDo заглушка для создания border-а
			if (typeof style === "string") {
				switch (style) {
					case "thin"		: this.style = c_oAscBorderStyles.Thin; break;
					case "medium"	: this.style = c_oAscBorderStyles.Medium; break;
					case "thick"	: this.style = c_oAscBorderStyles.Thick; break;
					default			: this.style = c_oAscBorderStyles.None; break;
				}
			} else {
				this.style = style !== undefined ? style : c_oAscBorderStyles.None;
			}
			this.color = color !== undefined ? color : null;
		}

		asc_CBorder.prototype = {
			asc_getStyle: function() { return this.style; },
			asc_getColor: function() { return this.color; }
		};

		window["Asc"].asc_CBorder = window["Asc"]["asc_CBorder"] = asc_CBorder;
		prot = asc_CBorder.prototype;

		prot["asc_getStyle"] = prot.asc_getStyle;
		prot["asc_getColor"] = prot.asc_getColor;

		/** @constructor */
		function asc_CBorders() {
			this.left = null;
			this.top = null;
			this.right = null;
			this.bottom = null;
			this.diagDown = null;
			this.diagUp = null;
		}

		asc_CBorders.prototype = {
			asc_getLeft: function() { return this.left; },
			asc_getTop: function() { return this.top; },
			asc_getRight: function() { return this.right; },
			asc_getBottom: function() { return this.bottom; },
			asc_getDiagDown: function() { return this.diagDown; },
			asc_getDiagUp: function() { return this.diagUp; }
		};

		window["Asc"].asc_CBorders = window["Asc"]["asc_CBorders"] = asc_CBorders;
		prot = asc_CBorders.prototype;

		prot["asc_getLeft"]		= prot.asc_getLeft;
		prot["asc_getTop"]		= prot.asc_getTop;
		prot["asc_getRight"]	= prot.asc_getRight;
		prot["asc_getBottom"]	= prot.asc_getBottom;
		prot["asc_getDiagDown"]	= prot.asc_getDiagDown;
		prot["asc_getDiagUp"]	= prot.asc_getDiagUp;

		/** @constructor */
		function asc_CCellInfo() {
			this.name = null;
			this.formula = "";
			this.text = "";
			this.halign = "left";
			this.valign = "top";
			this.flags = null;
			this.font = null;
			this.fill = null;
			this.border = null;
			this.innertext = null;
			this.numFormat = null;
			this.hyperlink = null;
			this.comments = [];
			this.isLocked = false;
			this.isFormatTable = false;	// Нужен для disable возможности делать merge
			this.tableStyleName = null;
			this.styleName = null;
			this.numFormatType = null;
			this.angle = null;
			this.clearFilter = false;	// Кнопка очистить фильтр: false - disable, true - pressed button
			this.isAutoFilter = false;	// Кнопка автофильтр (также влияет на formatTable и Sort). Возможные состояния:
										// - null - мы в пересечении с таблицой (но не полностью в ней)
										// - true/false - когда мы полностью в таблице или вне ее (true/false в зависимости от того применен фильтр или нет)
		}

		asc_CCellInfo.prototype = {
			asc_getName: function(){ return this.name; },
			asc_getFormula: function() { return this.formula; },
			asc_getText: function(){ return this.text; },
			asc_getHorAlign: function(){ return this.halign; },
			asc_getVertAlign: function(){ return this.valign; },
			asc_getFlags: function(){ return this.flags; },
			asc_getFont: function(){ return this.font; },
			asc_getFill: function(){ return this.fill; },
			asc_getBorders: function(){ return this.border; },
			asc_getInnerText: function(){ return this.innertext; },
			asc_getNumFormat: function(){ return this.numFormat; },
			asc_getHyperlink: function(){ return this.hyperlink; },
			asc_getComments: function(){ return this.comments; },
			asc_getLocked: function(){ return this.isLocked; },
			asc_getIsFormatTable: function () { return this.isFormatTable; },
			asc_getTableStyleName: function () { return this.tableStyleName; },
			asc_getStyleName: function () { return this.styleName; },
			asc_getNumFormatType: function(){ return this.numFormatType; },
			asc_getAngle: function () { return this.angle; },
			asc_getClearFilter: function () { return this.clearFilter; },
			asc_getIsAutoFilter: function () { return this.isAutoFilter; }
		};

		window["Asc"].asc_CCellInfo = window["Asc"]["asc_CCellInfo"] = asc_CCellInfo;
		prot = asc_CCellInfo.prototype;

		prot["asc_getName"]				= prot.asc_getName;
		prot["asc_getFormula"]			= prot.asc_getFormula;
		prot["asc_getText"]				= prot.asc_getText;
		prot["asc_getHorAlign"]			= prot.asc_getHorAlign;
		prot["asc_getVertAlign"]		= prot.asc_getVertAlign;
		prot["asc_getFlags"]			= prot.asc_getFlags;
		prot["asc_getFont"]				= prot.asc_getFont;
		prot["asc_getFill"]				= prot.asc_getFill;
		prot["asc_getBorders"]			= prot.asc_getBorders;
		prot["asc_getInnerText"]		= prot.asc_getInnerText;
		prot["asc_getNumFormat"]		= prot.asc_getNumFormat;
		prot["asc_getHyperlink"]		= prot.asc_getHyperlink;
		prot["asc_getComments"]			= prot.asc_getComments;
		prot["asc_getLocked"]			= prot.asc_getLocked;
		prot["asc_getIsFormatTable"]	= prot.asc_getIsFormatTable;
		prot["asc_getTableStyleName"]	= prot.asc_getTableStyleName;
		prot["asc_getStyleName"]		= prot.asc_getStyleName;
		prot["asc_getNumFormatType"]	= prot.asc_getNumFormatType;
		prot["asc_getAngle"]			= prot.asc_getAngle;
		prot["asc_getClearFilter"]	    = prot.asc_getClearFilter;
		prot["asc_getIsAutoFilter"]	    = prot.asc_getIsAutoFilter;

		/** @constructor */
        function asc_CDefName(n, r, s, t) {
            this.Name = n;
            this.LocalSheetId = s;
            this.Ref = r;
            this.isTable = t;
        }

        asc_CDefName.prototype = {
            asc_getName: function(){return this.Name;},
            asc_getScope: function(){return this.LocalSheetId;},
            asc_getRef: function(){return this.Ref;},
            asc_getIsTable: function(){return this.isTable;}
        };

        window["Asc"].asc_CDefName = window["Asc"]["asc_CDefName"] = asc_CDefName;
        prot = asc_CDefName.prototype;

        prot["asc_getName"]				= prot.asc_getName;
        prot["asc_getScope"]			= prot.asc_getScope;
        prot["asc_getRef"]				= prot.asc_getRef;
        prot["asc_getIsTable"]		    = prot.asc_getIsTable;

	}
)(window);