NS_IMETHODIMP HTMLEditor::RefreshInlineTableEditingUI() { nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mInlineEditedCell); if (!htmlElement) { return NS_ERROR_NULL_POINTER; } int32_t xCell, yCell, wCell, hCell; GetElementOrigin(mInlineEditedCell, xCell, yCell); nsresult rv = htmlElement->GetOffsetWidth(&wCell); NS_ENSURE_SUCCESS(rv, rv); rv = htmlElement->GetOffsetHeight(&hCell); NS_ENSURE_SUCCESS(rv, rv); int32_t xHoriz = xCell + wCell/2; int32_t yVert = yCell + hCell/2; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); int32_t rowCount, colCount; rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton); #ifdef DISABLE_TABLE_DELETION if (colCount== 1) { mRemoveColumnButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, NS_LITERAL_STRING("hidden"), true); } else { if (mRemoveColumnButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) { mRemoveColumnButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class); } #endif SetAnonymousElementPosition(xHoriz-4, yCell-7, mRemoveColumnButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xHoriz+6, yCell-7, mAddColumnAfterButton); SetAnonymousElementPosition(xCell-7, yVert-10, mAddRowBeforeButton); #ifdef DISABLE_TABLE_DELETION if (rowCount== 1) { mRemoveRowButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, NS_LITERAL_STRING("hidden"), true); } else { if (mRemoveRowButton->HasAttr(kNameSpaceID_None, nsGkAtoms::_class)) { mRemoveRowButton->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true); } #endif SetAnonymousElementPosition(xCell-7, yVert-4, mRemoveRowButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xCell-7, yVert+6, mAddRowAfterButton); return NS_OK; }
uint32 ReadScriptDescriptor::GetTableSize(const string& table_name) { uint32 size = 0; OpenTable(table_name); size = GetTableSize(); CloseTable(); return size; }
NS_IMETHODIMP HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement) { NS_ENSURE_ARG_POINTER(aElement); bool anonElement = false; if (aElement && NS_SUCCEEDED(aElement->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)) && anonElement) { nsAutoString anonclass; nsresult rv = aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass); NS_ENSURE_SUCCESS(rv, rv); if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) return NS_OK; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); int32_t rowCount, colCount; rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); bool hideUI = false; bool hideResizersWithInlineTableUI = (GetAsDOMNode(mResizedObject) == tableElement); if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) InsertTableColumn(1, false); else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) InsertTableColumn(1, true); else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) InsertTableRow(1, false); else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) InsertTableRow(1, true); else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { DeleteTableColumn(1); #ifndef DISABLE_TABLE_DELETION hideUI = (colCount == 1); #endif } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { DeleteTableRow(1); #ifndef DISABLE_TABLE_DELETION hideUI = (rowCount == 1); #endif } else return NS_OK; if (hideUI) { HideInlineTableEditingUI(); if (hideResizersWithInlineTableUI) HideResizers(); } } return NS_OK; }
uint32 ReadScriptDescriptor::GetTableSize(const std::string &table_name) { uint32 size = 0; if (OpenTable(table_name)) { size = GetTableSize(); CloseTable(); } return size; }
nsresult HTMLEditor::DoInlineTableEditingAction(const Element& aElement) { nsAutoString anonclass; aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_anonclass, anonclass); if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) { return NS_OK; } RefPtr<Element> tableElement = GetEnclosingTable(mInlineEditedCell); int32_t rowCount, colCount; nsresult rv = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(rv, rv); bool hideUI = false; bool hideResizersWithInlineTableUI = (mResizedObject == tableElement); if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) { InsertTableColumn(1, false); } else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) { InsertTableColumn(1, true); } else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) { InsertTableRow(1, false); } else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) { InsertTableRow(1, true); } else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { DeleteTableColumn(1); #ifndef DISABLE_TABLE_DELETION hideUI = (colCount == 1); #endif } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { DeleteTableRow(1); #ifndef DISABLE_TABLE_DELETION hideUI = (rowCount == 1); #endif } else { return NS_OK; } // InsertTableRow might causes reframe if (Destroyed()) { return NS_OK; } if (hideUI) { HideInlineTableEditingUI(); if (hideResizersWithInlineTableUI) { HideResizers(); } } return NS_OK; }
uint32 ReadScriptDescriptor::GetTableSize(int32 table_name) { uint32 size = 0; if (OpenTable(table_name)) { size = GetTableSize(); CloseTable(); } return size; }
nsIFrame* nsMathMLmtableOuterFrame::GetRowFrameAt(nsPresContext* aPresContext, PRInt32 aRowIndex) { PRInt32 rowCount, colCount; GetTableSize(rowCount, colCount); // Negative indices mean to find upwards from the end. if (aRowIndex < 0) { aRowIndex = rowCount + aRowIndex; } // aRowIndex is 1-based, so convert it to a 0-based index --aRowIndex; // if our inner table says that the index is valid, find the row now if (0 <= aRowIndex && aRowIndex <= rowCount) { nsIFrame* tableFrame = mFrames.FirstChild(); if (!tableFrame || tableFrame->GetType() != nsGkAtoms::tableFrame) return nsnull; nsIFrame* rgFrame = tableFrame->GetFirstChild(nsnull); if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame) return nsnull; nsTableIterator rowIter(*rgFrame); nsIFrame* rowFrame = rowIter.First(); for ( ; rowFrame; rowFrame = rowIter.Next()) { if (aRowIndex == 0) { DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW); if (rowFrame->GetType() != nsGkAtoms::tableRowFrame) return nsnull; return rowFrame; } --aRowIndex; } } return nsnull; }
NS_IMETHODIMP nsHTMLEditor::RefreshInlineTableEditingUI() { nsCOMPtr<nsIDOMNSHTMLElement> nsElement = do_QueryInterface(mInlineEditedCell); if (!nsElement) {return NS_ERROR_NULL_POINTER; } PRInt32 xCell, yCell, wCell, hCell; GetElementOrigin(mInlineEditedCell, xCell, yCell); nsresult res = nsElement->GetOffsetWidth(&wCell); NS_ENSURE_SUCCESS(res, res); res = nsElement->GetOffsetHeight(&hCell); NS_ENSURE_SUCCESS(res, res); PRInt32 xHoriz = xCell + wCell/2; PRInt32 yVert = yCell + hCell/2; nsCOMPtr<nsIDOMNode> tableNode = GetEnclosingTable(mInlineEditedCell); nsCOMPtr<nsIDOMElement> tableElement = do_QueryInterface(tableNode); PRInt32 rowCount, colCount; res = GetTableSize(tableElement, &rowCount, &colCount); NS_ENSURE_SUCCESS(res, res); SetAnonymousElementPosition(xHoriz-10, yCell-7, mAddColumnBeforeButton); #ifdef DISABLE_TABLE_DELETION NS_NAMED_LITERAL_STRING(classStr, "class"); if (colCount== 1) { mRemoveColumnButton->SetAttribute(classStr, NS_LITERAL_STRING("hidden")); } else { PRBool hasClass = PR_FALSE; res = mRemoveColumnButton->HasAttribute(classStr, &hasClass); if (NS_SUCCEEDED(res) && hasClass) mRemoveColumnButton->RemoveAttribute(classStr); #endif SetAnonymousElementPosition(xHoriz-4, yCell-7, mRemoveColumnButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xHoriz+6, yCell-7, mAddColumnAfterButton); SetAnonymousElementPosition(xCell-7, yVert-10, mAddRowBeforeButton); #ifdef DISABLE_TABLE_DELETION if (rowCount== 1) { mRemoveRowButton->SetAttribute(classStr, NS_LITERAL_STRING("hidden")); } else { PRBool hasClass = PR_FALSE; res = mRemoveRowButton->HasAttribute(classStr, &hasClass); if (NS_SUCCEEDED(res) && hasClass) mRemoveRowButton->RemoveAttribute(classStr); #endif SetAnonymousElementPosition(xCell-7, yVert-4, mRemoveRowButton); #ifdef DISABLE_TABLE_DELETION } #endif SetAnonymousElementPosition(xCell-7, yVert+6, mAddRowAfterButton); return NS_OK; }
int CIFEventCraftWin::GetEventCraftFormula() { int i, j, k, itemIdx; int itemTableIdx1, itemTableIdx2, checkedNumber; int numSourceItem, checkedItem[MAX_EVENT_CRAFT_ITEM], checkedIdx[MAX_EVENT_CRAFT_ITEM]; item_t *sourceItem; numSourceItem = 0; for( i = 0; i < MAX_EVENT_CRAFT_ITEM; i ++ ) { if( g_cgv.myCharacterInfo->craftSourceInventory[i] < 0 ) continue; sourceItem = &g_cgv.myCharacterInfo->item[g_cgv.myCharacterInfo->craftSourceInventory[i]]; checkedIdx[numSourceItem] = i; numSourceItem ++; } if( numSourceItem == 0 ) return -1; for( i = 0; i < GetTableSize(); i ++ ) { itemCraftTable_t *pData = Get(i); if(pData == NULL) break; if( numSourceItem != pData->numSourceItem ) continue; checkedNumber = numSourceItem; for( j = 0; j < MAX_EVENT_CRAFT_ITEM; j ++ ) { checkedItem[j] = false; } for( j = 0; j < MAX_EVENT_CRAFT_ITEM; j ++ ) { for( k = 0; k < numSourceItem; k ++ ) { if( checkedItem[k] ) continue; itemIdx = g_cgv.myCharacterInfo->craftSourceInventory[checkedIdx[k]]; sourceItem = &g_cgv.myCharacterInfo->item[itemIdx]; itemTableIdx1 = sourceItem->itemTableIdx; itemTableIdx2 = pData->sourceItem[j].itemIndex; if( itemTableIdx1 != itemTableIdx2 ) continue; if( g_itemTable[itemTableIdx1].stackFlag && g_itemTable[itemTableIdx2].stackFlag ) { if( pData->sourceItem[j].itemCount != sourceItem->durability + 1 ) continue; } break; } if( k == numSourceItem ) break; checkedItem[k] = true; checkedNumber --; } if( checkedNumber == 0 ) { return i; } } return -1; }