Hello out there,
I seem to be getting a strange side effect when I modify the language text style in paragraph styles. The other styles which are not modified seem to lose their ability to modify text to which they are applied, at least the way they use to.
For example, if I start out in English:USA with four paragraph styles all based on the root paragraph style and then modify paragraph styles 1, 2 and 4 to be Spanish:Castilian, leaving style 3 to remain in English:USA, style 3 starts acting like it was changed to Spanish:Castilian, even though I can clearly see that it remains in English:USA from within the style's editing dialog. Note that I have left style 3 completely untouched, as well as the root style ("No Paragraph Style"). It's like some local override has been turned on permanently, unknown to style 3 because when it is applied to either English or Spanish locally overrided text, it shows no plus sign next to it in the style palette. Nevertheless, the styles I did change to Spanish:Castilian will show a plus sign if applied to text that is locally overrided with English:USA.
I have not touched any text, I am just manipulating paragraph styles. Do I need to do anything special to the text of the document as well? This completely baffles me because as far as I can see, I have done all that the documentation says to do. I am using IStyleUtils to create the edit style command. Is there a problem with that? Do I have to set up the command myself? Is there some idiosyncracy with the Language text style that I should be aware of?
I am including my code for changing the Language text attribute of a style. Perhaps one of you can see what I may be doing wrong or am missing:
ErrorCode CDocStyleTranslation::setStyleLanguage(UID langUID, UID theStyleID, IDataBase* theStyleDB)
{
ErrorCode theErr = kFailure;
// get our style's info to pass into the command
IStyleInfo * theStyleInfo = (IStyleInfo*)theStyleDB->QueryInstance(theStyleID, IID_ISTYLEINFO);
ASSERT(theStyleInfo);
if (!theStyleInfo)
{
return theErr;
}
PMString styleName = theStyleInfo->GetName(); // for debugging
do
{
// set the language of a new language text attribute
ITextAttrUID * newLangAttr = (ITextAttrUID*)::CreateObject(kTextAttrLanguageBoss, IID_ITEXTATTRUID);
ASSERT(newLangAttr);
if (!newLangAttr)
{
break;
}
newLangAttr->SetUIDData(langUID);
// get our style utilities directly from the UtilsBoss
IStyleUtils * styleUtils = (IStyleUtils *)UtilsBoss::QueryUtils(IID_ISTYLEUTILS);
ASSERT(styleUtils);
if (!styleUtils)
{
break;
}
// set up the command
ICommand* editLangCmd = styleUtils->CreateEditStyleCmd(theStyleInfo, newLangAttr);
ASSERT(editLangCmd);
if(!editLangCmd)
{
break;
}
// process the command
theErr = CmdUtils::ProcessCommand(editLangCmd);
// clean up
editLangCmd->Release();
styleUtils->Release();
newLangAttr->Release();
}while(false);
theStyleInfo->Release();
return theErr;
}