/*---------------------------------------------------------------------------------------------- Return the ISO-639-3 language code, cast to an unsigned int. ----------------------------------------------------------------------------------------------*/ isocode FwGrTxtSrc::getLanguage(toffset ich) { LgCharRenderProps lgchrp; int ichMinBogus, ichLimBogus; GrResult res = (GrResult)m_qts->GetCharProps(GrToVwOffset(ich), &lgchrp, &ichMinBogus, &ichLimBogus); int ws = lgchrp.ws; ILgWritingSystemFactoryPtr qwsf; ILgWritingSystemPtr qws; CheckHr(m_qts->GetWsFactory(&qwsf)); AssertPtr(qwsf); CheckHr(qwsf->get_EngineOrNull(ws, &qws)); isocode code; if (!qws) { memset(code.rgch, 0, sizeof(char) * 4); return code; } SmartBstr bstrLang; CheckHr(qws->get_ISO3(&bstrLang)); for (int i = 0; i < 4; i++) code.rgch[i] = (char)(i >= bstrLang.Length() ? 0 : bstrLang[i]); return code; }
/*---------------------------------------------------------------------------------------------- Return the ISO-639-3 language code, cast to an unsigned int. ----------------------------------------------------------------------------------------------*/ isocode FwGrTxtSrc::getLanguage(toffset ich) { LgCharRenderProps lgchrp; int ichMinBogus, ichLimBogus; GrResult res = (GrResult)m_qts->GetCharProps(GrToVwOffset(ich), &lgchrp, &ichMinBogus, &ichLimBogus); int ws = lgchrp.ws; ILgWritingSystemFactoryPtr qwsf; IWritingSystemPtr qws; CheckHr(m_qts->GetWsFactory(&qwsf)); if (qwsf) { CheckHr(qwsf->get_EngineOrNull(ws, &qws)); } else { qwsf.CreateInstance(CLSID_LgWritingSystemFactory); // Get the memory-based factory. CheckHr(qwsf->get_EngineOrNull(ws, &qws)); } isocode code; if (!qws) { memset(code.rgch, 0, sizeof(char) * 4); return code; } SmartBstr bstrLang, bstrScript, bstrCountry, bstrVariant; CheckHr(qws->GetIcuLocaleParts(&bstrLang, &bstrScript, &bstrCountry, &bstrVariant)); for (int i = 0; i < 4; i++) code.rgch[i] = (char)(i >= bstrLang.Length() ? 0 : bstrLang[i]); return code; }
/*---------------------------------------------------------------------------------------------- Initialize font after superclass initialization is done. ----------------------------------------------------------------------------------------------*/ void AfDeFeEdBoxBut::Init() { Assert(m_hvoObj); // Initialize should have been called first. CreateFont(); ILgWritingSystemFactoryPtr qwsf; IWritingSystemPtr qws; GetLpInfo()->GetDbInfo()->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); ComBool fRTL = FALSE; CheckHr(qwsf->get_EngineOrNull(m_ws, &qws)); if (qws) CheckHr(qws->get_RightToLeft(&fRTL)); m_fRtl = bool(fRTL); }
/*---------------------------------------------------------------------------------------------- Initialize the list of encodings from the writing system factory. ----------------------------------------------------------------------------------------------*/ void WpFormatWsDlg::InitEncList() { int cws; ILgWritingSystemFactoryPtr qwsf; qwsf.CreateInstance(CLSID_LgWritingSystemFactory); // Get the memory-based factory. CheckHr(qwsf->get_NumberOfWs(&cws)); int * prgenc = NewObj int[cws]; CheckHr(qwsf->GetWritingSystems(prgenc)); int wsUser; CheckHr(qwsf->get_UserWs(&wsUser)); for (int iws = 0; iws < cws; iws++) { if (prgenc[iws] == 0) continue; IWritingSystemPtr qws; CheckHr(qwsf->get_Engine(prgenc[iws], &qws)); if (!qws) continue; // Generate the name to use for the writing system. SmartBstr sbstr; CheckHr(qws->get_UiName(wsUser, &sbstr)); if (!sbstr) continue; StrUni stu(sbstr.Chars()); StrApp str = stu; m_vws.Push(prgenc[iws]); m_vstr.Push(str); } Assert(m_vws.Size() == m_vstr.Size()); // Sort the encodings by name. for (iws = 0; iws < m_vws.Size() - 1; iws++) { for (int iws2 = iws + 1; iws2 < m_vws.Size(); iws2++) { if (m_vstr[iws] > m_vstr[iws2]) { StrApp strTmp = m_vstr[iws]; int encTmp = m_vws[iws]; m_vstr[iws] = m_vstr[iws2]; m_vws[iws] = m_vws[iws2]; m_vstr[iws2] = strTmp; m_vws[iws2] = encTmp; } } if (m_vws[iws] == m_wsInit) m_iwsInit = iws; } delete[] prgenc; }
/*---------------------------------------------------------------------------------------------- Set the values for the dialog controls based on the style styi. @param vwsProj Union of the current Vernacular and Analysis encodings for the project. ----------------------------------------------------------------------------------------------*/ void FmtGenDlg::SetDialogValues(StyleInfo & styi, Vector<int> & vwsProj) { // During SetDialogValues we never need to handle loss of focus in the name control, // because if anything needed to be done about updating that, it was done during // GetDialogValues, which is always called before SetDialogValues. We need to suppress it // because during this call the current style index and the current value of the control // may not agree: the purpose of this method is to update the control from the new style. // The normal loss-of-focus code is trying to synchronize in the opposite direction, and // can cause problems, for example, when we are disabling the control. For example: // - Disabling the window causes it to lose focus if it previously had focus. // - There is a kill focus event that tries to make the contents of the box agree with // the name of the current style. // - when this method is called, the old style is still the current one, so if we // already changed the text in the box, we wind up trying to rename the old style // to the name of the 'provided' style and produce a name conflict error. try { m_vwsProj = vwsProj; StrApp strDesc; m_fSuppressLossOfFocus = true; StrApp strName = styi.m_stuName; StrApp strTemp; // Temporary string. bool fProtectedStyle = m_pafsd->IsStyleProtected(styi.m_stuName); // Name edit box. ::SetDlgItemText(m_hwnd, kctidFgEdName, strName.Chars()); // Diable the control for styles originally provided by FieldWorks. ::EnableWindow(m_hwndName, !fProtectedStyle); // Style type ltext. switch (styi.m_st) { case kstParagraph: strTemp.Load(kstidParagraph); break; case kstCharacter: strTemp.Load(kstidCharacter); break; default: Assert(false); // Should not happen. } ::SetWindowText(m_hwndType, strTemp.Chars()); // Update the "next" and "basedOn" comboboxes LoadNextStyleCombobox(styi); SetNextStyleComboboxValue(styi); LoadBasedOnStyleCombobox(styi); SetBasedOnStyleComboboxValue(styi); // ENHANCE LarryW(JohnT): When shortcut is implemented initialize the value instead. ::EnableWindow(m_hwndShortcut, false); // Disables it. // ************************************** m_vesi.Clear(); strDesc = m_pafsd->GetNameOfStyle(styi.m_hvoBasedOn); strDesc.Append(" + "); ITsTextProps * pttp = styi.m_qttp; if (pttp) { StrApp strT; StrAppBuf strb; // a temp, used for making strings with units // Add default font info bool fFirstPart = true; SmartBstr sbstr; CheckHr(pttp->GetStrPropValue(ktptFontFamily, &sbstr)); StrUni stuFont(sbstr.Chars()); AppendDescPart(strDesc, FwStyledText::FontStringMarkupToUi(false, stuFont), fFirstPart); int val, var; CheckHr(pttp->GetIntPropValues(ktptFontSize, &var, &val)); if (var != -1) { AfUtil::MakeMsrStr (val , knpt, &strb); AppendDescPart(strDesc, strb, fFirstPart); } CheckHr(pttp->GetIntPropValues(ktptBold, &var, &val)); if (val == kttvForceOn || val == kttvInvert) AppendDescPart(strDesc, kstidBold, fFirstPart); CheckHr(pttp->GetIntPropValues(ktptItalic, &var, &val)); if (val == kttvForceOn || val == kttvInvert) AppendDescPart(strDesc, kstidItalic, fFirstPart); CheckHr(pttp->GetIntPropValues(ktptSuperscript, &var, &val)); if (val == kssvSuper) AppendDescPart(strDesc, kstidFfdSuperscript, fFirstPart); else if (val == kssvSub) AppendDescPart(strDesc, kstidFfdSubscript, fFirstPart); AppendTextIs(strDesc, (COLORREF)ReadValOrNinch(pttp, ktptForeColor), (COLORREF)ReadValOrNinch(pttp, ktptBackColor), fFirstPart); AppendUnderlineInfo(strDesc, (COLORREF)ReadValOrNinch(pttp, ktptUnderColor), ReadValOrNinch(pttp, ktptUnderline), fFirstPart); AppendOffsetInfo(strDesc, ReadValOrNinch(pttp, ktptOffset), fFirstPart); // Add info about other tabs int nDir = ReadValOrNinch(pttp, ktptRightToLeft); AddIf(strDesc, nDir == 0, kstidLeftToRight, fFirstPart); AddIf(strDesc, nDir == 1, kstidRightToLeft, fFirstPart); static const Keyval rgkeyvals[] = { {ktalLeading, kstidFpAlignLead}, {ktalLeft, kstidFpAlignLeft}, {ktalCenter, kstidFpAlignCenter}, {ktalRight, kstidFpAlignRight}, {ktalTrailing, kstidFpAlignTrail}, {ktalJustify, kstidFpAlignJustify}, //TODO: support when in use. {0, 0} }; AddFromList(strDesc, ReadValOrNinch(pttp, ktptAlign), rgkeyvals, fFirstPart); int nLeadIndent = ReadValOrNinch(pttp, ktptLeadingIndent); int nTrailIndent = ReadValOrNinch(pttp, ktptTrailingIndent); int nFirstIndent = ReadValOrNinch(pttp, ktptFirstIndent); if (nLeadIndent != knNinch || nTrailIndent != knNinch || nFirstIndent != knNinch) { AppendDescPart(strDesc, kstidIndentColon, fFirstPart); AppendMeasurement(strDesc, nLeadIndent, m_nMsrSys, kstidLeadingFmt); if (nFirstIndent != knNinch) { if (nFirstIndent < 0) AppendMeasurement(strDesc, -nFirstIndent, m_nMsrSys, kstidHangingFmt); else AppendMeasurement(strDesc, nFirstIndent, m_nMsrSys, kstidFirstLineFmt); } AppendMeasurement(strDesc, nTrailIndent, m_nMsrSys, kstidTrailingFmt); } // line spacing CheckHr(pttp->GetIntPropValues(ktptLineHeight, &var, &val)); StrApp strSpacing; StrApp strFmt; if (var == ktpvMilliPoint) { if (val < 0) strFmt.Load(kstidFpLsExactFmt); else strFmt.Load(kstidFpLsAtLeastFmt); StrAppBuf strb; AfUtil::MakeMsrStr (val , knpt, &strb); strSpacing.Format(strFmt.Chars(), strb.Chars()); } else if (var == ktpvRelative) { if (val >= kdenTextPropRel * 2) strSpacing.Load(kstidFpLsDouble); else if (val >= kdenTextPropRel * 3 / 2) strSpacing.Load(kstidFpLs15Lines); else strSpacing.Load(kstidFpLsSingle); } if (strSpacing.Length() != 0) { strFmt.Load(kstidLineSpacingFmt); strT.Format(strFmt.Chars(), strSpacing.Chars()); AppendDescPart(strDesc, strT, fFirstPart); } int mpBefore = ReadValOrNinch(pttp, ktptSpaceBefore); int mpAfter = ReadValOrNinch(pttp, ktptSpaceAfter); if (mpBefore != knNinch || mpAfter != knNinch) { AppendDescPart(strDesc, kstidSpace, fFirstPart); AppendMeasurement(strDesc, mpBefore, knpt, kstidBeforeFmt); AppendMeasurement(strDesc, mpAfter, knpt, kstidAfterFmt); } int bulnum = ReadValOrNinch(pttp, ktptBulNumScheme); AddIf(strDesc, bulnum >= kvbnBulletBase && bulnum < kvbnBulletMax, kstidBulleted, fFirstPart); AddIf(strDesc, bulnum >= kvbnNumberBase && bulnum < kvbnNumberMax, kstidNumbered, fFirstPart); int mpBTop = ReadValOrNinch(pttp, ktptBorderTop); int mpBB = ReadValOrNinch(pttp, ktptBorderBottom); int mpBL = ReadValOrNinch(pttp, ktptBorderLeading); int mpBTr = ReadValOrNinch(pttp, ktptBorderTrailing); if (mpBTop != knNinch || mpBB != knNinch || mpBL != knNinch || mpBTr != knNinch) { AppendDescPart(strDesc, kstidBorderColon, fFirstPart); int clrBorder = ReadValOrNinch(pttp, ktptBorderColor); bool fFirstBorder = true; if (clrBorder != knNinch) { StrApp strClr; strClr.Load(g_ct.GetColorRid(g_ct.GetIndexFromColor(clrBorder))); strDesc.Append(strClr.Chars()); fFirstBorder = false; } AppendBorderInfo(strDesc, mpBTop, kstidTopBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBB, kstidBottomBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBL, kstidLeadingBdrFmt, fFirstBorder); AppendBorderInfo(strDesc, mpBTr, kstidTrailingBdrFmt, fFirstBorder); } // Add info about writing-system overrides of font info. Vector<int> vwsSoFar; // Get the appropropriate writing system factory. ILgWritingSystemFactoryPtr qwsf; AssertPtr(m_pafsd); m_pafsd->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); //- IWritingSystemPtr qws; // Each iteration of this loop processes information about one writing system. SmartBstr sbstrCharStyles; CheckHr(pttp->GetStrPropValue(kspWsStyle, &sbstrCharStyles)); if (sbstrCharStyles.Length()) { FwStyledText::DecodeFontPropsString(sbstrCharStyles, m_vesi, vwsSoFar); SmartBstr sbstrWs; StrApp strWs; int wsUser; CheckHr(qwsf->get_UserWs(&wsUser)); SmartBstr sbstrAbbr; for (int iesi = 0; iesi < m_vesi.Size(); iesi++) { WsStyleInfo & esi = m_vesi[iesi]; if (vwsSoFar[iesi] == 0) continue; // Ignore writing system set to 0. fFirstPart = true; StrApp strT; StrApp strT2; strT.Format(_T("\n")); // Use the abbreviation in the user ws if it exists. // else try for an abbreviation in each ws in m_vwsProj in turn, // else use the ICU locale name as a last resort. IWritingSystemPtr qws; CheckHr(qwsf->GetStrFromWs(vwsSoFar[iesi], &sbstrWs)); CheckHr(qwsf->get_Engine(sbstrWs, &qws)); CheckHr(qws->get_Abbr(wsUser, &sbstrAbbr)); if (sbstrAbbr.Length() == 0) { for (int iws = 0; iws < m_vwsProj.Size(); ++iws) { CheckHr(qws->get_Abbr(m_vwsProj[iws], &sbstrAbbr)); if (sbstrAbbr.Length() != 0) break; } } if (sbstrAbbr.Length() == 0) strWs.Assign(sbstrWs.Chars(), sbstrWs.Length()); else strWs.Assign(sbstrAbbr.Chars(), sbstrAbbr.Length()); strT2.Format(_T("%s: "), strWs.Chars()); if (strT2 == _T("___: ")) strT2.Load(kctidFgUnknown); strT.Append(strT2); strDesc.Append (strT); AppendDescPart(strDesc, FwStyledText::FontStringMarkupToUi(false, esi.m_stuFontFamily), fFirstPart); if (esi.m_mpSize != knNinch) { AfUtil::MakeMsrStr (esi.m_mpSize , knpt, &strb); AppendDescPart(strDesc, strb, fFirstPart); } if (esi.m_fBold == kttvForceOn || esi.m_fBold == kttvInvert) AppendDescPart(strDesc, kstidBold, fFirstPart); if (esi.m_fItalic == kttvForceOn || esi.m_fItalic == kttvInvert) AppendDescPart(strDesc, kstidItalic, fFirstPart); if (esi.m_ssv == kssvSuper) AppendDescPart(strDesc, kstidFfdSuperscript, fFirstPart); else if (esi.m_ssv == kssvSub) AppendDescPart(strDesc, kstidFfdSubscript, fFirstPart); AppendTextIs(strDesc, esi.m_clrFore, esi.m_clrBack, fFirstPart); AppendUnderlineInfo(strDesc, esi.m_clrUnder, esi.m_unt, fFirstPart); AppendOffsetInfo(strDesc, esi.m_mpOffset, fFirstPart); } // 'for' loop } } ::SetDlgItemText(m_hwnd, kctidFgDescription, strDesc.Chars()); // ************************************** } catch(...) { m_fSuppressLossOfFocus = false; throw; } m_fSuppressLossOfFocus = false; } //:> FmtGenDlg::SetDialogValues.
/*---------------------------------------------------------------------------------------------- Make an edit box to allow editing. hwnd is the parent hwnd. rc is the size of the child window. Store the hwnd and return true. @param hwnd @param rc @param dxpCursor @param fTopCursor @param tpte @return true if successful TODO: To handle extra long field contents (and RTL?) the button cannot be a child of the edit control, because they must occupy seperate rectangles inside the field proper. ----------------------------------------------------------------------------------------------*/ bool AfDeFeEdBoxBut::BeginEdit(HWND hwnd, Rect &rc, int dxpCursor, bool fTopCursor, TptEditable tpte) { if (!SuperClass::BeginEdit(hwnd, rc, dxpCursor, fTopCursor)) return false; DeEditPtr qde; qde.Create(); qde->SetEditable(tpte); qde->m_pdee = this; IActionHandler * pacth = BeginTempEdit(); ILgWritingSystemFactoryPtr qwsf; GetLpInfo()->GetDbInfo()->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); #if 1 int nRet = 0; ComBool fRTL = FALSE; IWritingSystemPtr qws; CheckHr(qwsf->get_EngineOrNull(m_ws, &qws)); if (qws) CheckHr(qws->get_RightToLeft(&fRTL)); if (fRTL) qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_RIGHT | ES_AUTOHSCROLL, NULL, m_qtss, qwsf, m_ws, pacth); else #endif qde->Create(hwnd, kwidEditChild, WS_CHILD | ES_LEFT | ES_AUTOHSCROLL, NULL, m_qtss, qwsf, m_ws, pacth); m_hwnd = qde->Hwnd(); Rect rcT(rc.left + 2, rc.top + 1, rc.right, rc.bottom); nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width(), rcT.Height(), true); #if 99-99 Rect rcParentClient; Rect rcParent; ::GetClientRect(hwnd, &rcParentClient); ::GetWindowRect(hwnd, &rcParent); Rect rcEdit; Rect rcEditClient; ::GetWindowRect(m_hwnd, &rcEdit); ::GetClientRect(m_hwnd, &rcEditClient); #endif Rect rcTb; ::GetClientRect(m_hwnd, &rcTb); rcTb.left = rcTb.right - 16; rcTb.bottom = rcTb.top + Min((int)rcTb.bottom - (int)rcTb.top, (int)kdxpButtonHeight); WndCreateStruct wcsButton; wcsButton.InitChild(_T("BUTTON"), m_hwnd, kwidEditChild); wcsButton.style |= WS_VISIBLE | BS_OWNERDRAW; wcsButton.SetRect(rcTb); DeButtonPtr qdb; qdb.Create(); qdb->CreateAndSubclassHwnd(wcsButton); qdb->m_pdee = this; m_hwndButton = qdb->Hwnd(); #if 1-1 // Resize the edit control window to exclude the button nRet = ::MoveWindow(m_hwnd, rcT.left, rcT.top, rcT.Width() - 18, rcT.Height(), true); #endif // Add text to the window. ::SendMessage(m_hwnd, FW_EM_SETSTYLE, m_chrp.clrBack, (LPARAM)&m_qfsp->m_stuSty); ::SendMessage(m_hwnd, EM_SETMARGINS, EC_RIGHTMARGIN | EC_LEFTMARGIN, MAKELPARAM(0, 18)); ::ShowWindow(m_hwnd, SW_SHOW); //::SendMessage(m_hwnd, WM_SETFONT, (WPARAM)::GetStockObject(DEFAULT_GUI_FONT), 0); // Foreground/background colors are set via WM_CTLCOLOREDIT in AfDeFeWnd. // Set cursor to desired offset. //int ich; //ich = LOWORD(::SendMessage(m_hwnd, EM_CHARFROMPOS, 0, dxpCursor)); // For some reason the above always comes back with -1 instead of the correct index. // Is this a bug in TssEdit or am I doing something wrong? //::SendMessage(m_hwnd, EM_SETSEL, ich, ich); //::mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); // Send LButton to place cursor in edit ctrl. #if 99-99 Rect rcEditNew; Rect rcEditNewClient; Rect rcBut; Rect rcButClient; ::GetWindowRect(m_hwnd, &rcEditNew); ::GetClientRect(m_hwnd, &rcEditNewClient); ::GetWindowRect(m_hwndButton, &rcBut); ::GetClientRect(m_hwndButton, &rcButClient); #endif return true; }
/*---------------------------------------------------------------------------------------------- Check to see if the edit box has valid data. if so return true. If not then put up a message to the user, then return false. ----------------------------------------------------------------------------------------------*/ bool CleDeFeString::IsOkToClose(bool fWarn) { CleMainWnd * pcmw = dynamic_cast<CleMainWnd *>(m_qadsc->MainWindow()); Assert(pcmw); IVwSelectionPtr qvwsel; CheckHr(m_qrootb->get_Selection(&qvwsel)); if (qvwsel) { ComBool fOk; CheckHr(qvwsel->Commit(&fOk)); } PossListInfoPtr qpli = pcmw->GetPossListInfoPtr(); int ipss = qpli->GetIndexFromId(m_hvoObj); StrUni stuNew; const OLECHAR * prgwch; int cch; ITsStringPtr qtss; CustViewDaPtr qcvd; GetDataAccess(&qcvd); AssertPtr(qcvd); int ws = m_qsvc->WritingSystems()[0]; CheckHr(qcvd->get_MultiStringAlt(m_hvoObj, m_flid, ws, &qtss)); Assert(qtss); qtss->LockText(&prgwch, &cch); qtss->UnlockText(prgwch); // Trim leading and trailing space characters. UnicodeString ust(prgwch, cch); ust.trim(); stuNew.Assign(ust.getBuffer(), ust.length()); // Obtain pointer to IOleDbEncap interface. IOleDbEncapPtr qode; IOleDbCommandPtr qodc; StrUni stuSql; ComBool fIsNull; ComBool fMoreRows; AssertPtr(m_qadsc->MainWindow()); AfLpInfo * plpi = m_qadsc->MainWindow()->GetLpInfo(); AssertPtr(plpi); AfDbInfo * pdbi = plpi->GetDbInfo(); AssertPtr(pdbi); pdbi->GetDbAccess(&qode); AssertPtr(qode); CheckHr(qode->CreateCommand(&qodc)); int cpii = qpli->GetCount(); if ((m_flid == kflidCmPossibility_Name) || (m_flid == kflidCmPossibility_Abbreviation)) { // Make sure it does not have a ":" or a " - " in the string int ich = stuNew.FindStr(L":"); StrUni stuTmp; bool fFixed = false; while (ich > 0) { stuNew.Replace(ich,ich + 1,"-"); fFixed = true; ich = stuNew.FindStr(L":"); } ich = stuNew.FindStr(L" - "); while (ich > 0) { stuNew.Replace(ich,ich + 3,"-"); fFixed = true; ich = stuNew.FindStr(L" - "); } if (fFixed) { if (fWarn) { ITsStrFactoryPtr qtsf; qtsf.CreateInstance(CLSID_TsStrFactory); qtsf->MakeStringRgch(stuNew.Chars(), stuNew.Length(), pcmw->UserWs(), &qtss); CheckHr(qcvd->SetMultiStringAlt(m_hvoObj, m_flid, ws, qtss)); CheckHr(qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1)); StrApp strMsg(kstidFixedStr); StrApp strTitle(kstidFixedStrTitle); ::MessageBox(m_hwnd, strMsg.Chars(), strTitle.Chars(), MB_OK | MB_ICONINFORMATION); } return false; } } if (qpli->GetAllowDup()) return true; ILgWritingSystemFactoryPtr qwsf; pdbi->GetLgWritingSystemFactory(&qwsf); AssertPtr(qwsf); switch (m_flid) { case kflidCmPossibility_Name: { for (int ipii = 0; ipii < cpii; ipii++) { if (ipii == ipss) continue; PossItemInfo * ppii = qpli->GetPssFromIndex(ipii); AssertPtr(ppii); StrUni stu; ppii->GetName(stu, kpntName); if (stu == stuNew) { stuSql.Format(L"select ws from CmPossibility_Name " L"where obj = %d and ws = %d", ppii->GetPssId(), ws); CheckHr(qode->CreateCommand(&qodc)); CheckHr(qodc->ExecCommand(stuSql.Bstr(), knSqlStmtSelectWithOneRowset)); CheckHr(qodc->GetRowset(0)); CheckHr(qodc->NextRow(&fMoreRows)); if (fMoreRows) { if (fWarn) { // this name already exists IWritingSystemPtr qws; CheckHr(qwsf->get_EngineOrNull(ws, &qws)); AssertPtr(qws); SmartBstr sbstr; qws->get_Name(ws, &sbstr); StrUni stu(kstidDupItemName); StrUni stuMsg; stuMsg.Format(stu,sbstr.Chars()); StrApp str(stuMsg); StrApp strTitle(kstidDupItemTitle); ::MessageBox(m_hwnd, str.Chars(), strTitle.Chars(), MB_OK | MB_ICONINFORMATION); } return false; } } } break; } case kflidCmPossibility_Abbreviation: { for (int ipii = 0; ipii < cpii; ipii++) { if (ipii == ipss) continue; PossItemInfo * ppii = qpli->GetPssFromIndex(ipii); AssertPtr(ppii); StrUni stu; ppii->GetName(stu, kpntAbbreviation); if (stu == stuNew) { stuSql.Format(L"select ws from CmPossibility_Abbreviation " L"where obj = %d and ws = %d", ppii->GetPssId(), ws); CheckHr(qode->CreateCommand(&qodc)); CheckHr(qodc->ExecCommand(stuSql.Bstr(), knSqlStmtSelectWithOneRowset)); CheckHr(qodc->GetRowset(0)); CheckHr(qodc->NextRow(&fMoreRows)); if (fMoreRows) { if (fWarn) { // this abbreviation already exists IWritingSystemPtr qws; CheckHr(qwsf->get_EngineOrNull(ws, &qws)); AssertPtr(qws); SmartBstr sbstr; qws->get_Name(ws, &sbstr); StrUni stu(kstidDupItemAbbr); StrUni stuMsg; stuMsg.Format(stu,sbstr.Chars()); StrApp str(stuMsg); StrApp strTitle(kstidDupItemTitle); ::MessageBox(m_hwnd, str.Chars(), strTitle.Chars(), MB_OK | MB_ICONINFORMATION); } return false; } } } break; } } return true; }