1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SC_XMLCHANGETRACKINGIMPORTHELPER_HXX 25 #define SC_XMLCHANGETRACKINGIMPORTHELPER_HXX 26 27 #include "chgtrack.hxx" 28 #include <list> 29 #include <com/sun/star/util/DateTime.hpp> 30 31 class ScBaseCell; 32 class ScDocument; 33 class DateTime; 34 35 struct ScMyActionInfo 36 { 37 rtl::OUString sUser; 38 rtl::OUString sComment; 39 com::sun::star::util::DateTime aDateTime; 40 }; 41 42 struct ScMyCellInfo 43 { 44 ScBaseCell* pCell; 45 rtl::OUString sFormulaAddress; 46 rtl::OUString sFormula; 47 String sInputString; 48 double fValue; 49 sal_Int32 nMatrixCols; 50 sal_Int32 nMatrixRows; 51 formula::FormulaGrammar::Grammar eGrammar; 52 sal_uInt16 nType; 53 sal_uInt8 nMatrixFlag; 54 55 ScMyCellInfo(ScBaseCell* pCell, const rtl::OUString& sFormulaAddress, const rtl::OUString& sFormula, 56 const formula::FormulaGrammar::Grammar eGrammar, const rtl::OUString& sInputString, 57 const double& fValue, const sal_uInt16 nType, const sal_uInt8 nMatrixFlag, const sal_Int32 nMatrixCols, 58 const sal_Int32 nMatrixRows); 59 ~ScMyCellInfo(); 60 61 ScBaseCell* CreateCell(ScDocument* pDoc); 62 63 private: 64 ScMyCellInfo(); // disabled 65 }; 66 67 struct ScMyDeleted 68 { 69 sal_uInt32 nID; 70 ScMyCellInfo* pCellInfo; 71 72 ScMyDeleted(); 73 ~ScMyDeleted(); 74 }; 75 76 typedef std::list<ScMyDeleted*> ScMyDeletedList; 77 78 struct ScMyGenerated 79 { 80 ScBigRange aBigRange; 81 sal_uInt32 nID; 82 ScMyCellInfo* pCellInfo; 83 84 ScMyGenerated(ScMyCellInfo* pCellInfo, const ScBigRange& aBigRange); 85 ~ScMyGenerated(); 86 }; 87 88 typedef std::list<ScMyGenerated*> ScMyGeneratedList; 89 90 struct ScMyInsertionCutOff 91 { 92 sal_uInt32 nID; 93 sal_Int32 nPosition; 94 ScMyInsertionCutOffScMyInsertionCutOff95 ScMyInsertionCutOff(const sal_uInt32 nTempID, const sal_Int32 nTempPosition) : 96 nID(nTempID), nPosition(nTempPosition) {} 97 }; 98 99 struct ScMyMoveCutOff 100 { 101 sal_uInt32 nID; 102 sal_Int32 nStartPosition; 103 sal_Int32 nEndPosition; 104 ScMyMoveCutOffScMyMoveCutOff105 ScMyMoveCutOff(const sal_uInt32 nTempID, const sal_Int32 nStartPos, const sal_Int32 nEndPos) : 106 nID(nTempID), nStartPosition(nStartPos), nEndPosition(nEndPos) {} 107 }; 108 109 typedef std::list<ScMyMoveCutOff> ScMyMoveCutOffs; 110 111 struct ScMyMoveRanges 112 { 113 ScBigRange aSourceRange; 114 ScBigRange aTargetRange; 115 ScMyMoveRangesScMyMoveRanges116 ScMyMoveRanges(const ScBigRange& aSource, const ScBigRange aTarget) : 117 aSourceRange(aSource), aTargetRange(aTarget) {} 118 }; 119 120 typedef std::list<sal_uInt32> ScMyDependencies; 121 122 struct ScMyBaseAction 123 { 124 ScMyActionInfo aInfo; 125 ScBigRange aBigRange; 126 ScMyDependencies aDependencies; 127 ScMyDeletedList aDeletedList; 128 sal_uInt32 nActionNumber; 129 sal_uInt32 nRejectingNumber; 130 sal_uInt32 nPreviousAction; 131 ScChangeActionType nActionType; 132 ScChangeActionState nActionState; 133 134 ScMyBaseAction(const ScChangeActionType nActionType); 135 virtual ~ScMyBaseAction(); 136 }; 137 138 struct ScMyInsAction : public ScMyBaseAction 139 { 140 ScMyInsAction(const ScChangeActionType nActionType); 141 ~ScMyInsAction(); 142 }; 143 144 struct ScMyDelAction : public ScMyBaseAction 145 { 146 ScMyGeneratedList aGeneratedList; 147 ScMyInsertionCutOff* pInsCutOff; 148 ScMyMoveCutOffs aMoveCutOffs; 149 sal_Int32 nD; 150 151 ScMyDelAction(const ScChangeActionType nActionType); 152 ~ScMyDelAction(); 153 }; 154 155 struct ScMyMoveAction : public ScMyBaseAction 156 { 157 ScMyGeneratedList aGeneratedList; 158 ScMyMoveRanges* pMoveRanges; 159 160 ScMyMoveAction(); 161 ~ScMyMoveAction(); 162 }; 163 164 struct ScMyContentAction : public ScMyBaseAction 165 { 166 ScMyCellInfo* pCellInfo; 167 168 ScMyContentAction(); 169 ~ScMyContentAction(); 170 }; 171 172 struct ScMyRejAction : public ScMyBaseAction 173 { 174 ScMyRejAction(); 175 ~ScMyRejAction(); 176 }; 177 178 typedef std::list<ScMyBaseAction*> ScMyActions; 179 180 class ScChangeViewSettings; 181 182 class ScXMLChangeTrackingImportHelper 183 { 184 ScStrCollection aUsers; 185 ScMyActions aActions; 186 com::sun::star::uno::Sequence<sal_Int8> aProtect; 187 ScDocument* pDoc; 188 ScChangeTrack* pTrack; 189 ScMyBaseAction* pCurrentAction; 190 rtl::OUString sIDPrefix; 191 sal_uInt32 nPrefixLength; 192 sal_Int16 nMultiSpanned; 193 sal_Int16 nMultiSpannedSlaveCount; 194 sal_Bool bChangeTrack; 195 196 private: 197 void ConvertInfo(const ScMyActionInfo& aInfo, String& rUser, DateTime& aDateTime); 198 ScChangeAction* CreateInsertAction(ScMyInsAction* pAction); 199 ScChangeAction* CreateDeleteAction(ScMyDelAction* pAction); 200 ScChangeAction* CreateMoveAction(ScMyMoveAction* pAction); 201 ScChangeAction* CreateRejectionAction(ScMyRejAction* pAction); 202 ScChangeAction* CreateContentAction(ScMyContentAction* pAction); 203 204 void CreateGeneratedActions(ScMyGeneratedList& rList); 205 206 public: 207 ScXMLChangeTrackingImportHelper(); 208 ~ScXMLChangeTrackingImportHelper(); 209 SetChangeTrack(sal_Bool bValue)210 void SetChangeTrack(sal_Bool bValue) { bChangeTrack = bValue; } SetProtection(const com::sun::star::uno::Sequence<sal_Int8> & rProtect)211 void SetProtection(const com::sun::star::uno::Sequence<sal_Int8>& rProtect) { aProtect = rProtect; } 212 void StartChangeAction(const ScChangeActionType nActionType); 213 214 sal_uInt32 GetIDFromString(const rtl::OUString& sID); 215 SetActionNumber(const sal_uInt32 nActionNumber)216 void SetActionNumber(const sal_uInt32 nActionNumber) { pCurrentAction->nActionNumber = nActionNumber; } SetActionState(const ScChangeActionState nActionState)217 void SetActionState(const ScChangeActionState nActionState) { pCurrentAction->nActionState = nActionState; } SetRejectingNumber(const sal_uInt32 nRejectingNumber)218 void SetRejectingNumber(const sal_uInt32 nRejectingNumber) { pCurrentAction->nRejectingNumber = nRejectingNumber; } 219 void SetActionInfo(const ScMyActionInfo& aInfo); SetBigRange(const ScBigRange & aBigRange)220 void SetBigRange(const ScBigRange& aBigRange) { pCurrentAction->aBigRange = aBigRange; } 221 void SetPreviousChange(const sal_uInt32 nPreviousAction, ScMyCellInfo* pCellInfo); 222 void SetPosition(const sal_Int32 nPosition, const sal_Int32 nCount, const sal_Int32 nTable); AddDependence(const sal_uInt32 nID)223 void AddDependence(const sal_uInt32 nID) { pCurrentAction->aDependencies.push_front(nID); } 224 void AddDeleted(const sal_uInt32 nID); 225 void AddDeleted(const sal_uInt32 nID, ScMyCellInfo* pCellInfo); 226 void SetMultiSpanned(const sal_Int16 nMultiSpanned); 227 void SetInsertionCutOff(const sal_uInt32 nID, const sal_Int32 nPosition); 228 void AddMoveCutOff(const sal_uInt32 nID, const sal_Int32 nStartPosition, const sal_Int32 nEndPosition); 229 void SetMoveRanges(const ScBigRange& aSourceRange, const ScBigRange& aTargetRange); 230 void GetMultiSpannedRange(); 231 void AddGenerated(ScMyCellInfo* pCellInfo, const ScBigRange& aBigRange); 232 233 void EndChangeAction(); 234 235 void SetDeletionDependencies(ScMyDelAction* pAction, ScChangeActionDel* pDelAct); 236 void SetMovementDependencies(ScMyMoveAction* pAction, ScChangeActionMove* pMoveAct); 237 void SetContentDependencies(ScMyContentAction* pAction, ScChangeActionContent* pActContent); 238 void SetDependencies(ScMyBaseAction* pAction); 239 240 void SetNewCell(ScMyContentAction* pAction); 241 242 void CreateChangeTrack(ScDocument* pDoc); 243 }; 244 245 #endif 246