0
Problem modifying language text attribute in a style
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/td-p/1330585
Jan 30, 2007
Jan 30, 2007
Copy link to clipboard
Copied
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;
}
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;
}
TOPICS
SDK
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330586#M282041
Jan 30, 2007
Jan 30, 2007
Copy link to clipboard
Copied
Hi John,
Have you checked if you have a character style applied that specifies that language?
Regards,
Eugenio Andres
Have you checked if you have a character style applied that specifies that language?
Regards,
Eugenio Andres
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
HopkinsJD
AUTHOR
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330587#M282042
Jan 30, 2007
Jan 30, 2007
Copy link to clipboard
Copied
Well Hello Eugenio,
Thanks for responding. There are no character styles in the document (aside from the root of course) and no local text overrides that have been applied to any text.
Regards,
John
Thanks for responding. There are no character styles in the document (aside from the root of course) and no local text overrides that have been applied to any text.
Regards,
John
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330588#M282043
Jan 31, 2007
Jan 31, 2007
Copy link to clipboard
Copied
Is it possible that the paragraph style's NextStyle attribute is interfering?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330589#M282044
Jan 31, 2007
Jan 31, 2007
Copy link to clipboard
Copied
Also..<br />I found that I had to be careful while doing this as InDesign would crash if I set the language to one where hyphenation was not supported (e.g. kLanguageGaelic, unless it was included later).<br />To get around this, I restricted the assignment to ones that passed the following test:<br /><br />>InterfacePtr<ILanguageList>appLanguageList((ILanguageList*)::QuerySessionPreferences(IID_ILANGUAGELIST));<br />InterfacePtr<const ILanguage>appLanguage(appLanguageList->QueryLanguageByID(TheLanguageID));<br />InterfacePtr<const IVendorList>hyphVendor(appLanguage, IID_IHYPHVENDORLIST);<br />if (hyphVendor->GetVendorCount() > 0)<br />...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
HopkinsJD
AUTHOR
New Here
,
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330590#M282045
Jan 31, 2007
Jan 31, 2007
Copy link to clipboard
Copied
I don't see how the Next Style attribute would be interacting here. The styles in my test file are all set to [same style] for the Next Style attribute. Plus, I have only one paragraph in the test file.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
HopkinsJD
AUTHOR
New Here
,
LATEST
/t5/indesign-discussions/problem-modifying-language-text-attribute-in-a-style/m-p/1330591#M282046
Jan 31, 2007
Jan 31, 2007
Copy link to clipboard
Copied
Well, I am testing to make sure that I'm using a language that exists in the workspace and though it's different from what you suggested, Jackeen, I think it is viable. The following is an extract of my code which provides some context for my "setStyleLanguage" function above. See what you think.<br /><br />bool16 CDocStyleTranslation::translateParaStyles(LDSLanguage& theLang)<br />{<br /> bool16 succeeded = kFalse;<br /> <br /> // get Adobe's language name from our language database record<br /> langID theLangIDs = theLang.getLangID();<br /> PMString langName(theLangIDs.AdobeName.c_str());<br /><br /> do<br /> {<br /> // does this language exist in inDesign's language list?<br /> bool16 langExists = kFalse;<br /> <br /> InterfacePtr<ILanguageList> docLangList(this, UseDefaultIID());<br /> ASSERT(docLangList);<br /> if (!docLangList)<br /> {<br /> break;<br /> }<br /> <br /> // (if langName is not included in InDesigns list of languages, <br /> ILanguage* theIDLang = docLangList->QueryLanguage(langName); // the InDesign Language<br /> if (!theIDLang)<br /> {<br /> // the attribute will be set to [No Language])<br /> theIDLang = docLangList->QueryNthLanguage(0);<br /> }<br /> else <br /> {<br /> langExists = kTrue;<br /> }<br /> ASSERT(theIDLang);<br /> if (!theIDLang)<br /> {<br /> break;<br /> }<br /> <br /> // find out the UID for the language<br /> UID langUID;<br /> InterfacePtr<IPMPersist> langPersist(theIDLang, UseDefaultIID());<br /> ASSERT(langPersist);<br /> if (!langPersist)<br /> {<br /> break;<br /> }<br /> langUID = langPersist->GetUID(); <br /> theIDLang->Release();<br /> <br /> // march through our paragraph styles and "translate" them<br /> InterfacePtr<IStyleNameTable> paraStylTbl(this, IID_IPARASTYLENAMETABLE);<br /> ASSERT(paraStylTbl);<br /> if (!paraStylTbl)<br /> {<br /> break;<br /> }<br /> <br /> InterfacePtr<IPMPersist> docPersist(this, UseDefaultIID());<br /> ASSERT(docPersist);<br /> if (!docPersist)<br /> {<br /> break;<br /> }<br /> <br /> IDataBase * paraStylDB = docPersist->GetDataBase();<br /> <br /> for (int32 i = 1; i < paraStylTbl->GetNumStyles(); i++) // do not translate the root<br /> {<br /> // retrieve each style's translation settings<br /> UID theStyleID = paraStylTbl->GetNthStyle(i);<br /> <br /> InterfacePtr<IStyleTranSettings> theStyleTranSet(paraStylDB, theStyleID, UseDefaultIID());<br /> ASSERT(theStyleTranSet);<br /> if (!theStyleTranSet)<br /> {<br /> break;<br /> }<br /> ParaStylTranSettings pstSet = theStyleTranSet->getParaStylTranSettings();<br /> <br /> // based on the style translation settings and the language's info, do the following:<br /> <br /> if (pstSet.transOpt != kDontTranslate)<br /> {<br /> // translate the language<br /> setStyleLanguage(langUID, theStyleID, paraStylDB);<br /> <br />...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

