Question
how to change language both document and the styles
I tried to find and change wrong language(s) in the document with new one.
most of the paragraph ranges contain overrides so at the beginning language in the styles should be replaced to new one and then overrided context.
as far as I figure out the following code does not change the language
////find
//IFindChangeOptions::SearchMode searchMode = IFindChangeOptions::kTextSearch;
InterfacePtr<ICommand> formatCmd(CmdUtils::CreateCommand(kFindChangeFormatCmdBoss));
if (formatCmd == nil)
return;
InterfacePtr<IFindChangeFormatCmdData> formatCmdData(formatCmd, IID_IFINDCHANGEFORMATCMDDATA);
if (formatCmdData == nil)
return;
// old
InterfacePtr<IAttrReport> oldLanguage(TextAttrHelper::CreateTextAttribute<ITextAttrUID, ITextAttrUID::ValueType>(kTextAttrLanguageBoss, langUID));
if (oldLanguage == nil){
return;
}
// new
InterfacePtr<IAttrReport> destLanguage(TextAttrHelper::CreateTextAttribute<ITextAttrUID, ITextAttrUID::ValueType>(kTextAttrLanguageBoss, destLangUID));
if (destLanguage == nil){
return;
}
AttributeBossList findAttributeList;
findAttributeList.ApplyAttribute(oldLanguage);
AttributeBossList changeAttributeList;
changeAttributeList.ApplyAttribute(destLanguage);
formatCmdData->ClearFindAttributeBossList();
formatCmdData->ApplyFindAttributeBossList(&findAttributeList);
formatCmdData->ApplyChangeAttributeBossList(&changeAttributeList);
ErrorCode status = CmdUtils::ProcessCommand( formatCmd ) ;
if (status != kSuccess) {
return;
}
// search
InterfacePtr<IFindChangeService> findChangeService((IFindChangeService*)::CreateObject(kFindChangeServiceBoss, IID_IFINDCHANGSERVICE));
if (!findChangeService)
{
return;
}
auto db = ::GetUIDRef(document).GetDataBase();
auto foundObject = ::UIDRef(db, langUID);
///
IFindChangeService::FindChangeResult findStatus = findChangeService->SearchObject(foundObject, kTrue /*!fInitialized*/);
findChangeService->ReplaceObject();
