ErrorCode ClearOverrides ( ITextModel * textModel,
const TextIndex position,
const int32 length,
const K2::shared_ptr< AttributeBossList > & attr,
ClassID whichStrand
)
Clear paragraph alignment, character point size, leading and underline overrides using ITextModelCmds::ApplyCmd.
Parameters:
textModel of story to be changed.
position index of first character to be formatted.
length number of characters to be formatted.
attr attribute boss lists that contains the point size, leading and underline overrides we want to clear here.
whichStrand which strand this attribute overrides are to apply, it has to be either kParaAttrStrandBoss or kCharAttrStrandBoss.
Returns:
kSuccess on success, other ErrorCode otherwise.
00204 {
00205 ErrorCode status = kFailure;
00206
00207 do {
00208 ASSERT(textModel);
00209 if (!textModel) {
00210 break;
00211 }
00212 if (whichStrand != kParaAttrStrandBoss && whichStrand != kCharAttrStrandBoss) {
00213 ASSERT_FAIL("overrides only apply to either kParaAttrStrandBoss or kCharAttrStrandBoss");
00214 break;
00215 }
00216 if (position < 0 || position >= textModel->TotalLength()) {
00217 ASSERT_FAIL("position invalid");
00218 break;
00219 }
00220 if (length < 1 || length >= textModel->TotalLength()) {
00221 ASSERT_FAIL("length invalid");
00222 break;
00223 }
00224
00225 // Create a command to apply the attribute.
00226 InterfacePtr<ITextModelCmds> textModelCmds(textModel, UseDefaultIID());
00227 ASSERT(textModelCmds);
00228 if (!textModelCmds) {
00229 break;
00230 }
00231 InterfacePtr<ICommand> clearAttrCmd(textModelCmds->ClearOverridesCmd(position,
00232 length,
00233 attr,
00234 whichStrand));
00235 ASSERT(clearAttrCmd);
00236 if(clearAttrCmd == nil) {
00237 break;
00238 }
00239
00240 // Apply the attribute.
00241 status = CmdUtils::ProcessCommand(clearAttrCmd);
00242 if (status != kSuccess) {
00243 ASSERT_FAIL("ITextModelCmds::ClearOverridesCmd failed to clear attributes");
00244 break;
00245 }
00246 } while(false);
00247 return status;
00248 }