Пример #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the row/cell information of the current selection.
		/// </summary>
		/// <param name="vwsel"></param>
		/// <param name="iLevel"></param>
		/// <param name="iBox"></param>
		/// <param name="iTableBox"></param>
		/// <param name="cTableBoxes"></param>
		/// <param name="iTableLevel"></param>
		/// <param name="iCellBox"></param>
		/// <param name="cCellBoxes"></param>
		/// <param name="iCellLevel"></param>
		/// ------------------------------------------------------------------------------------
		internal static void GetCurrentTableCellInfo(IVwSelection vwsel, out int iLevel, out int iBox, out int iTableBox, out int cTableBoxes, out int iTableLevel, out int iCellBox, out int cCellBoxes, out int iCellLevel)
		{
			int cBoxes = -1;
			iBox = -1;
			iTableBox = -1;
			cTableBoxes = -1;
			iTableLevel = -1;
			int iRowBox = -1;
			int cRowBoxes = -1;
			int iRowLevel = -1;
			iCellBox = -1;
			cCellBoxes = -1;
			iCellLevel = -1;
			// Find the current table cell and advance to the next one, possibly on the
			// next or previous row.
			int cLevels = vwsel.get_BoxDepth(true);
			VwBoxType vbt = VwBoxType.kvbtUnknown;
			for (iLevel = 0; iLevel < cLevels; ++iLevel)
			{
				cBoxes = vwsel.get_BoxCount(true, iLevel);
				iBox = vwsel.get_BoxIndex(true, iLevel);
				vbt = vwsel.get_BoxType(true, iLevel);
				switch (vbt)
				{
					case VwBoxType.kvbtTable:
						// Note that the layout should one (visible) row per "table", and
						// stacks the "table" boxes to form the visual table.  See JohnT
						// for an explanation of this nonintuitive use of tables and rows.
						// At least, i think JohnT knows why -- maybe it's RandyR?
						iTableBox = iBox;
						cTableBoxes = cBoxes;
						iTableLevel = iLevel;
						break;
					case VwBoxType.kvbtTableRow:
						iRowBox = iBox;
						cRowBoxes = cBoxes;
						iRowLevel = iLevel;
						break;
					case VwBoxType.kvbtTableCell:
						iCellBox = iBox;
						cCellBoxes = cBoxes;
						iCellLevel = iLevel;
						break;
				}
			}
			// Some simple sanity checking.
			Debug.Assert(cBoxes != -1);
			Debug.Assert(iBox != -1);
			Debug.Assert(iTableBox != -1);
			Debug.Assert(cTableBoxes != -1);
			Debug.Assert(iTableLevel != -1);
			Debug.Assert(iRowBox != -1);
			Debug.Assert(cRowBoxes != -1);
			Debug.Assert(iRowLevel != -1);
			Debug.Assert(iCellBox != -1);
			Debug.Assert(cCellBoxes != -1);
			Debug.Assert(iCellLevel != -1);
		}