Highlighted

how to change language both document and the styles

New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

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();

 

TOPICS
SDK

Views

49

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

how to change language both document and the styles

New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

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();

 

TOPICS
SDK

Views

50

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 03, 2020 0
Adobe Community Professional ,
Sep 07, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 07, 2020 0
New Here ,
Sep 08, 2020

Copy link to clipboard

Copied

Dear Mike;

Thanks for your reply. I can make it by using javascript.

I have been developing a tool with c++ plug-in sdk. I can change the styles in document but can not change the language overrides on context.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 08, 2020 0