| 971 | } |
| 972 | |
| 973 | int Document::Redo() { |
| 974 | int newPos = -1; |
| 975 | CheckReadOnly(); |
| 976 | if ((enteredModification == 0) && (cb.IsCollectingUndo())) { |
| 977 | enteredModification++; |
| 978 | if (!cb.IsReadOnly()) { |
| 979 | bool startSavePoint = cb.IsSavePoint(); |
| 980 | bool multiLine = false; |
| 981 | int steps = cb.StartRedo(); |
| 982 | for (int step = 0; step < steps; step++) { |
| 983 | const int prevLinesTotal = LinesTotal(); |
| 984 | const Action &action = cb.GetRedoStep(); |
| 985 | if (action.at == insertAction) { |
| 986 | NotifyModified(DocModification( |
| 987 | SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); |
| 988 | } else if (action.at == containerAction) { |
| 989 | DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_REDO); |
| 990 | dm.token = action.position; |
| 991 | NotifyModified(dm); |
| 992 | } else { |
| 993 | NotifyModified(DocModification( |
| 994 | SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); |
| 995 | } |
| 996 | cb.PerformRedoStep(); |
| 997 | if (action.at != containerAction) { |
| 998 | ModifiedAt(action.position); |
| 999 | newPos = action.position; |
| 1000 | } |
| 1001 | |
| 1002 | int modFlags = SC_PERFORMED_REDO; |
| 1003 | if (action.at == insertAction) { |
| 1004 | newPos += action.lenData; |
| 1005 | modFlags |= SC_MOD_INSERTTEXT; |
| 1006 | } else if (action.at == removeAction) { |
| 1007 | modFlags |= SC_MOD_DELETETEXT; |
| 1008 | } |
| 1009 | if (steps > 1) |
| 1010 | modFlags |= SC_MULTISTEPUNDOREDO; |
| 1011 | const int linesAdded = LinesTotal() - prevLinesTotal; |
| 1012 | if (linesAdded != 0) |
| 1013 | multiLine = true; |
| 1014 | if (step == steps - 1) { |
| 1015 | modFlags |= SC_LASTSTEPINUNDOREDO; |
| 1016 | if (multiLine) |
| 1017 | modFlags |= SC_MULTILINEUNDOREDO; |
| 1018 | } |
| 1019 | NotifyModified( |
| 1020 | DocModification(modFlags, action.position, action.lenData, |
| 1021 | linesAdded, action.data)); |
| 1022 | } |
| 1023 | |
| 1024 | bool endSavePoint = cb.IsSavePoint(); |
| 1025 | if (startSavePoint != endSavePoint) |
| 1026 | NotifySavePoint(endSavePoint); |
| 1027 | } |
| 1028 | enteredModification--; |
| 1029 | } |
| 1030 | return newPos; |
nothing calls this directly
no test coverage detected