Kaydet (Commit) f9585d9d authored tarafından Jacek Wolszczak's avatar Jacek Wolszczak Kaydeden (comit) Thomas Arnhold

REPLACE j_assert with OSL_

üst 1ade0128
...@@ -188,7 +188,7 @@ public: ...@@ -188,7 +188,7 @@ public:
SmCaretPosGraphEntry* Add(SmCaretPos pos, SmCaretPosGraphEntry* Add(SmCaretPos pos,
SmCaretPosGraphEntry* left = NULL, SmCaretPosGraphEntry* left = NULL,
SmCaretPosGraphEntry* right = NULL){ SmCaretPosGraphEntry* right = NULL){
j_assert(pos.Index >= 0, "Index shouldn't be -1!"); OSL_ENSURE(pos.Index >= 0, "Index shouldn't be -1!");
return Add(SmCaretPosGraphEntry(pos, left, right)); return Add(SmCaretPosGraphEntry(pos, left, right));
} }
/** Get an iterator for this graph */ /** Get an iterator for this graph */
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#define j_assert(cond, msg) DBG_ASSERT(cond, msg)
#include "parse.hxx" #include "parse.hxx"
#include "types.hxx" #include "types.hxx"
#include "rect.hxx" #include "rect.hxx"
......
...@@ -176,7 +176,7 @@ public: ...@@ -176,7 +176,7 @@ public:
SmCaretPos2LineVisitor( OutputDevice *pDevice, SmCaretPos position ) { SmCaretPos2LineVisitor( OutputDevice *pDevice, SmCaretPos position ) {
pDev = pDevice; pDev = pDevice;
pos = position; pos = position;
j_assert( position.IsValid( ), "Cannot draw invalid position!" ); OSL_ENSURE( position.IsValid( ), "Cannot draw invalid position!" );
pos.pSelectedNode->Accept( this ); pos.pSelectedNode->Accept( this );
} }
......
...@@ -38,12 +38,12 @@ void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMov ...@@ -38,12 +38,12 @@ void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMov
case MoveLeft: case MoveLeft:
{ {
NewPos = position->Left; NewPos = position->Left;
j_assert(NewPos, "NewPos shouldn't be NULL here!"); OSL_ENSURE(NewPos, "NewPos shouldn't be NULL here!");
}break; }break;
case MoveRight: case MoveRight:
{ {
NewPos = position->Right; NewPos = position->Right;
j_assert(NewPos, "NewPos shouldn't be NULL here!"); OSL_ENSURE(NewPos, "NewPos shouldn't be NULL here!");
}break; }break;
case MoveUp: case MoveUp:
//Implementation is practically identical to MoveDown, except for a single if statement //Implementation is practically identical to MoveDown, except for a single if statement
...@@ -82,7 +82,7 @@ void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMov ...@@ -82,7 +82,7 @@ void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMov
} }
}break; }break;
default: default:
j_assert(false, "Movement direction not supported!"); OSL_FAIL("Movement direction not supported!");
} }
if(NewPos){ if(NewPos){
position = NewPos; position = NewPos;
...@@ -100,7 +100,7 @@ void SmCursor::MoveTo(OutputDevice* pDev, Point pos, bool bMoveAnchor){ ...@@ -100,7 +100,7 @@ void SmCursor::MoveTo(OutputDevice* pDev, Point pos, bool bMoveAnchor){
dbp_sq = 1; //Distance to best line squared dbp_sq = 1; //Distance to best line squared
SmCaretPosGraphIterator it = pGraph->GetIterator(); SmCaretPosGraphIterator it = pGraph->GetIterator();
while(it.Next()){ while(it.Next()){
j_assert(it->CaretPos.IsValid(), "The caret position graph may not have invalid positions!"); OSL_ENSURE(it->CaretPos.IsValid(), "The caret position graph may not have invalid positions!");
//Compute current line //Compute current line
curr_line = SmCaretPos2LineVisitor(pDev, it->CaretPos).GetResult(); curr_line = SmCaretPos2LineVisitor(pDev, it->CaretPos).GetResult();
//If we have a position compare to it //If we have a position compare to it
...@@ -160,8 +160,8 @@ void SmCursor::BuildGraph(){ ...@@ -160,8 +160,8 @@ void SmCursor::BuildGraph(){
if(!anchor) if(!anchor)
anchor = position; anchor = position;
j_assert(position->CaretPos.IsValid(), "Position must be valid"); OSL_ENSURE(position->CaretPos.IsValid(), "Position must be valid");
j_assert(anchor->CaretPos.IsValid(), "Anchor must be valid"); OSL_ENSURE(anchor->CaretPos.IsValid(), "Anchor must be valid");
} }
bool SmCursor::SetCaretPosition(SmCaretPos pos, bool moveAnchor){ bool SmCursor::SetCaretPosition(SmCaretPos pos, bool moveAnchor){
...@@ -203,7 +203,7 @@ void SmCursor::DeletePrev(OutputDevice* pDev){ ...@@ -203,7 +203,7 @@ void SmCursor::DeletePrev(OutputDevice* pDev){
BeginEdit(); BeginEdit();
//Line to merge things into, so we can delete pLine //Line to merge things into, so we can delete pLine
SmNode* pMergeLine = pLineParent->GetSubNode(nLineOffset-1); SmNode* pMergeLine = pLineParent->GetSubNode(nLineOffset-1);
j_assert(pMergeLine, "pMergeLine cannot be NULL!"); OSL_ENSURE(pMergeLine, "pMergeLine cannot be NULL!");
//Convert first line to list //Convert first line to list
SmNodeList *pLineList = NodeToList(pMergeLine); SmNodeList *pLineList = NodeToList(pMergeLine);
//Find iterator to patch //Find iterator to patch
...@@ -269,17 +269,17 @@ void SmCursor::Delete(){ ...@@ -269,17 +269,17 @@ void SmCursor::Delete(){
//Find an arbitrary selected node //Find an arbitrary selected node
SmNode* pSNode = FindSelectedNode(pTree); SmNode* pSNode = FindSelectedNode(pTree);
j_assert(pSNode != NULL, "There must be a selection when HasSelection is true!"); OSL_ENSURE(pSNode != NULL, "There must be a selection when HasSelection is true!");
//Find the topmost node of the line that holds the selection //Find the topmost node of the line that holds the selection
SmNode* pLine = FindTopMostNodeInLine(pSNode, true); SmNode* pLine = FindTopMostNodeInLine(pSNode, true);
j_assert(pLine != pTree, "Shouldn't be able to select the entire tree"); OSL_ENSURE(pLine != pTree, "Shouldn't be able to select the entire tree");
//Get the parent of the line //Get the parent of the line
SmStructureNode* pLineParent = pLine->GetParent(); SmStructureNode* pLineParent = pLine->GetParent();
//Find line offset in parent //Find line offset in parent
int nLineOffset = pLineParent->IndexOfSubNode(pLine); int nLineOffset = pLineParent->IndexOfSubNode(pLine);
j_assert(nLineOffset != -1, "pLine must be a child of it's parent!"); OSL_ENSURE(nLineOffset != -1, "pLine must be a child of it's parent!");
//Position after delete //Position after delete
SmCaretPos PosAfterDelete; SmCaretPos PosAfterDelete;
...@@ -317,7 +317,7 @@ void SmCursor::InsertNodes(SmNodeList* pNewNodes){ ...@@ -317,7 +317,7 @@ void SmCursor::InsertNodes(SmNodeList* pNewNodes){
//Find line parent and line index in parent //Find line parent and line index in parent
SmStructureNode* pLineParent = pLine->GetParent(); SmStructureNode* pLineParent = pLine->GetParent();
int nParentIndex = pLineParent->IndexOfSubNode(pLine); int nParentIndex = pLineParent->IndexOfSubNode(pLine);
j_assert(nParentIndex != -1, "pLine must be a subnode of pLineParent!"); OSL_ENSURE(nParentIndex != -1, "pLine must be a subnode of pLineParent!");
//Convert line to list //Convert line to list
SmNodeList* pLineList = NodeToList(pLine); SmNodeList* pLineList = NodeToList(pLine);
...@@ -506,7 +506,7 @@ void SmCursor::InsertSubSup(SmSubSup eSubSup) { ...@@ -506,7 +506,7 @@ void SmCursor::InsertSubSup(SmSubSup eSubSup) {
SmNode *pLine; SmNode *pLine;
if(HasSelection()) { if(HasSelection()) {
SmNode *pSNode = FindSelectedNode(pTree); SmNode *pSNode = FindSelectedNode(pTree);
j_assert(pSNode != NULL, "There must be a selected node when HasSelection is true!"); OSL_ENSURE(pSNode != NULL, "There must be a selected node when HasSelection is true!");
pLine = FindTopMostNodeInLine(pSNode, sal_True); pLine = FindTopMostNodeInLine(pSNode, sal_True);
} else } else
pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False); pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False);
...@@ -514,7 +514,7 @@ void SmCursor::InsertSubSup(SmSubSup eSubSup) { ...@@ -514,7 +514,7 @@ void SmCursor::InsertSubSup(SmSubSup eSubSup) {
//Find Parent and offset in parent //Find Parent and offset in parent
SmStructureNode *pLineParent = pLine->GetParent(); SmStructureNode *pLineParent = pLine->GetParent();
int nParentIndex = pLineParent->IndexOfSubNode(pLine); int nParentIndex = pLineParent->IndexOfSubNode(pLine);
j_assert(nParentIndex != -1, "pLine must be a subnode of pLineParent!"); OSL_ENSURE(nParentIndex != -1, "pLine must be a subnode of pLineParent!");
//TODO: Consider handling special cases where parent is an SmOperNode, //TODO: Consider handling special cases where parent is an SmOperNode,
// Maybe this method should be able to add limits to an SmOperNode... // Maybe this method should be able to add limits to an SmOperNode...
...@@ -677,7 +677,7 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) { ...@@ -677,7 +677,7 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) {
SmNode *pLine; SmNode *pLine;
if(HasSelection()) { if(HasSelection()) {
SmNode *pSNode = FindSelectedNode(pTree); SmNode *pSNode = FindSelectedNode(pTree);
j_assert(pSNode != NULL, "There must be a selected node if HasSelection()"); OSL_ENSURE(pSNode != NULL, "There must be a selected node if HasSelection()");
pLine = FindTopMostNodeInLine(pSNode, sal_True); pLine = FindTopMostNodeInLine(pSNode, sal_True);
} else } else
pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False); pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False);
...@@ -685,7 +685,7 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) { ...@@ -685,7 +685,7 @@ void SmCursor::InsertBrackets(SmBracketType eBracketType) {
//Find parent and offset in parent //Find parent and offset in parent
SmStructureNode *pLineParent = pLine->GetParent(); SmStructureNode *pLineParent = pLine->GetParent();
int nParentIndex = pLineParent->IndexOfSubNode(pLine); int nParentIndex = pLineParent->IndexOfSubNode(pLine);
j_assert( nParentIndex != -1, "pLine must be a subnode of pLineParent!"); OSL_ENSURE( nParentIndex != -1, "pLine must be a subnode of pLineParent!");
//Convert line to list //Convert line to list
SmNodeList *pLineList = NodeToList(pLine); SmNodeList *pLineList = NodeToList(pLine);
...@@ -813,7 +813,7 @@ bool SmCursor::InsertRow() { ...@@ -813,7 +813,7 @@ bool SmCursor::InsertRow() {
SmNode *pLine; SmNode *pLine;
if(HasSelection()) { if(HasSelection()) {
SmNode *pSNode = FindSelectedNode(pTree); SmNode *pSNode = FindSelectedNode(pTree);
j_assert(pSNode != NULL, "There must be a selected node if HasSelection()"); OSL_ENSURE(pSNode != NULL, "There must be a selected node if HasSelection()");
pLine = FindTopMostNodeInLine(pSNode, sal_True); pLine = FindTopMostNodeInLine(pSNode, sal_True);
} else } else
pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False); pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False);
...@@ -821,7 +821,7 @@ bool SmCursor::InsertRow() { ...@@ -821,7 +821,7 @@ bool SmCursor::InsertRow() {
//Find parent and offset in parent //Find parent and offset in parent
SmStructureNode *pLineParent = pLine->GetParent(); SmStructureNode *pLineParent = pLine->GetParent();
int nParentIndex = pLineParent->IndexOfSubNode(pLine); int nParentIndex = pLineParent->IndexOfSubNode(pLine);
j_assert( nParentIndex != -1, "pLine must be a subnode of pLineParent!"); OSL_ENSURE( nParentIndex != -1, "pLine must be a subnode of pLineParent!");
//Discover the context of this command //Discover the context of this command
SmTableNode *pTable = NULL; SmTableNode *pTable = NULL;
...@@ -836,7 +836,7 @@ bool SmCursor::InsertRow() { ...@@ -836,7 +836,7 @@ bool SmCursor::InsertRow() {
//NOTE: This hack might give problems if we stop ignoring SmAlignNode //NOTE: This hack might give problems if we stop ignoring SmAlignNode
pTable = (SmTableNode*)pLineParent->GetParent(); pTable = (SmTableNode*)pLineParent->GetParent();
nTableIndex = pTable->IndexOfSubNode(pLineParent); nTableIndex = pTable->IndexOfSubNode(pLineParent);
j_assert(nTableIndex != -1, "pLineParent must be a child of its parent!"); OSL_ENSURE(nTableIndex != -1, "pLineParent must be a child of its parent!");
} }
if(pLineParent->GetType() == NMATRIX) if(pLineParent->GetType() == NMATRIX)
pMatrix = (SmMatrixNode*)pLineParent; pMatrix = (SmMatrixNode*)pLineParent;
...@@ -916,7 +916,7 @@ bool SmCursor::InsertRow() { ...@@ -916,7 +916,7 @@ bool SmCursor::InsertRow() {
} }
pMatrix->SetRowCol(rows + 1, cols); pMatrix->SetRowCol(rows + 1, cols);
} else } else
j_assert(sal_False, "We must be either the context of a table or matrix!"); OSL_FAIL("We must be either the context of a table or matrix!");
//Finish editing //Finish editing
FinishEdit(pLineList, pLineParent, nParentIndex, PosAfterInsert); FinishEdit(pLineList, pLineParent, nParentIndex, PosAfterInsert);
...@@ -933,7 +933,7 @@ void SmCursor::InsertFraction() { ...@@ -933,7 +933,7 @@ void SmCursor::InsertFraction() {
SmNode *pLine; SmNode *pLine;
if(HasSelection()) { if(HasSelection()) {
SmNode *pSNode = FindSelectedNode(pTree); SmNode *pSNode = FindSelectedNode(pTree);
j_assert(pSNode != NULL, "There must be a selected node when HasSelection is true!"); OSL_ENSURE(pSNode != NULL, "There must be a selected node when HasSelection is true!");
pLine = FindTopMostNodeInLine(pSNode, sal_True); pLine = FindTopMostNodeInLine(pSNode, sal_True);
} else } else
pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False); pLine = FindTopMostNodeInLine(position->CaretPos.pSelectedNode, sal_False);
...@@ -941,7 +941,7 @@ void SmCursor::InsertFraction() { ...@@ -941,7 +941,7 @@ void SmCursor::InsertFraction() {
//Find Parent and offset in parent //Find Parent and offset in parent
SmStructureNode *pLineParent = pLine->GetParent(); SmStructureNode *pLineParent = pLine->GetParent();
int nParentIndex = pLineParent->IndexOfSubNode(pLine); int nParentIndex = pLineParent->IndexOfSubNode(pLine);
j_assert(nParentIndex != -1, "pLine must be a subnode of pLineParent!"); OSL_ENSURE(nParentIndex != -1, "pLine must be a subnode of pLineParent!");
//We begin modifying the tree here //We begin modifying the tree here
BeginEdit(); BeginEdit();
...@@ -1090,9 +1090,9 @@ void SmCursor::InsertElement(SmFormulaElement element){ ...@@ -1090,9 +1090,9 @@ void SmCursor::InsertElement(SmFormulaElement element){
pNewNode = new SmMathSymbolNode(token); pNewNode = new SmMathSymbolNode(token);
}break; }break;
default: default:
j_assert(false, "Element unknown!"); OSL_FAIL("Element unknown!");
} }
j_assert(pNewNode != NULL, "No new node was created!"); OSL_ENSURE(pNewNode != NULL, "No new node was created!");
if(!pNewNode) if(!pNewNode)
return; return;
......
...@@ -3038,7 +3038,7 @@ void SmNode::Accept(SmVisitor*){ ...@@ -3038,7 +3038,7 @@ void SmNode::Accept(SmVisitor*){
//obscure copy constructor is used... I can't find it's implementation, and //obscure copy constructor is used... I can't find it's implementation, and
//don't want to figure out how to fix it... If you want to, just delete this //don't want to figure out how to fix it... If you want to, just delete this
//method, making SmNode abstract, and see where you can an problem with that. //method, making SmNode abstract, and see where you can an problem with that.
j_assert(false, "SmNode should not be visitable!"); OSL_FAIL("SmNode should not be visitable!");
} }
void SmTableNode::Accept(SmVisitor* pVisitor) { void SmTableNode::Accept(SmVisitor* pVisitor) {
......
This diff is collapsed.
...@@ -15,9 +15,8 @@ Easy ...@@ -15,9 +15,8 @@ Easy
1. SmGraphicWindow::KeyInput relies on comparison of sal_Char, a better way must be available for CTRL+c 1. SmGraphicWindow::KeyInput relies on comparison of sal_Char, a better way must be available for CTRL+c
2. Code style (missing spaces, linebreaks and a few renames) 2. Code style (missing spaces, linebreaks and a few renames)
3. More documentation 3. More documentation
4. Replace j_assert with DBG_ASSERT (don't do this yet). 4. Remove the CreateTextFromNode methods and replace calls to it with NodeToTextVisitor
5. Remove the CreateTextFromNode methods and replace calls to it with NodeToTextVisitor 5. Extend NodeToTextVisitor to update token offsets so SmNode::GetRow and SmNode::GetColumn will work.
6. Extend NodeToTextVisitor to update token offsets so SmNode::GetRow and SmNode::GetColumn will work.
(These methods can be used to enable synchronization of caret positions between visual and non-visual editor). (These methods can be used to enable synchronization of caret positions between visual and non-visual editor).
Medium Medium
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment