本文整理汇总了C++中ITsStrFactoryPtr::MakeStringRgch方法的典型用法代码示例。如果您正苦于以下问题:C++ ITsStrFactoryPtr::MakeStringRgch方法的具体用法?C++ ITsStrFactoryPtr::MakeStringRgch怎么用?C++ ITsStrFactoryPtr::MakeStringRgch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITsStrFactoryPtr
的用法示例。
在下文中一共展示了ITsStrFactoryPtr::MakeStringRgch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisplayVariant
/*----------------------------------------------------------------------------------------------
DisplayVariant is used for times and enumerations.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleCustDocVc::DisplayVariant(IVwEnv * pvwenv, int tag, VARIANT v, int frag,
ITsString ** pptss)
{
BEGIN_COM_METHOD;
ChkComArgPtr(pvwenv);
ChkComOutPtr(pptss);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int ws = m_qlpi->GetDbInfo()->UserWs();
if (tag == kflidCmPerson_Gender || tag == kflidCmPerson_IsResearcher)
{
int itss = v.intVal;
int stid;
switch (tag)
{
case kflidCmPerson_Gender:
stid = kstidEnumGender;
break;
case kflidCmPerson_IsResearcher:
stid = kstidEnumNoYes;
if (itss)
itss = 1;
break;
default:
Assert(false);
break;
}
StrUni stuEnum(stid);
const wchar * pszEnum = stuEnum.Chars();
const wchar * pszEnumLim = stuEnum.Chars() + stuEnum.Length();
ITsStringPtr qtss;
//ITsStrFactoryPtr qtsf;
//qtsf.CreateInstance(CLSID_TsStrFactory);
int itssTry = 0;
while (pszEnum < pszEnumLim && itssTry <= itss)
{
const wchar * pszEnumNl = wcschr(pszEnum, '\n');
if (!pszEnumNl)
pszEnumNl = pszEnumLim;
if (itss == itssTry)
{
return qtsf->MakeStringRgch(pszEnum, (pszEnumNl - pszEnum), ws, pptss);
}
itssTry++;
pszEnum = pszEnumNl + 1;
}
// Fall-back behavior if we couldn't find a string: use the integer value.
char rgch[20];
_itoa_s(itss, rgch, 10);
StrUni stu(rgch);
return qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, pptss);
}
return SuperClass::DisplayVariant(pvwenv, tag, v, frag, pptss);
END_COM_METHOD(g_fact1, IID_IVwViewConstructor)
}
示例2: SetText
/*----------------------------------------------------------------------------------------------
Set the text of the control to be equal to ptss. If ptss is NULL, the edit box is cleared.
Message: FW_EM_SETTEXT.
----------------------------------------------------------------------------------------------*/
void TssEdit::SetText(ITsString * ptss)
{
AssertPtrN(ptss); // NULL can be used to clear string.
Assert(m_qcda);
ITsStringPtr qtss = ptss;
if (!ptss)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
CheckHr(qtsf->MakeStringRgch(L"", 0, m_wsBase, &qtss));
}
ITsStringPtr qtssOld;
CheckHr(m_qcda->get_StringProp(khvoString, ktagString, &qtssOld));
int cchOld;
CheckHr(qtssOld->get_Length(&cchOld));
CheckHr(m_qcda->CacheStringProp(khvoString, ktagString, qtss));
int cchNew;
CheckHr(qtss->get_Length(&cchNew));
// Pretend the whole length has been deleted and the whole new inserted.
CheckHr(m_qcda->PropChanged(NULL, kpctNotifyAll, khvoString, ktagString, 0, cchNew, cchOld));
OnUpdate();
::UpdateWindow(m_hwnd);
OnChange();
}
示例3: PreCreate
/*----------------------------------------------------------------------------------------------
Initialize variables prior to creating the control, i.e. create/attach a ISilDataAccess
and add TsString to cache
(may be explicitly called when created by ATL, because in this case TssEdit::Create() will
not be called)
----------------------------------------------------------------------------------------------*/
void TssEdit::PreCreate(ILgWritingSystemFactory * pwsf, int ws, ITsString * ptss,
IActionHandler * pacth)
{
AssertPtr(pwsf);
AssertPtrN(ptss);
ITsStringPtr qtss = ptss;
if (!ptss)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
CheckHr(qtsf->MakeStringRgch(L"", 0, ws, &qtss));
}
if (pacth)
{
// We want actions in this edit box to be undoable.
VwUndoDaPtr quda;
quda.Attach(NewObj VwUndoDa);
CheckHr(quda->SetActionHandler(pacth));
m_qcda.Attach(quda.Detach());
}
else
{
m_qcda.Attach(NewObj VwCacheDa);
}
m_qcda->putref_WritingSystemFactory(pwsf);
m_qcda->CacheStringProp(khvoString, ktagString, qtss);
}
示例4: InitContents
/*----------------------------------------------------------------------------------------------
This initializes the string based after the pssl and pss have been set. It takes into
account whether the view is hierarchical or not.
@param fHier
@param pnt
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::InitContents(bool fHier, PossNameType pnt)
{
Assert(m_hvoPssl); // This must be set prior to calling this method.
Assert(pnt < kpntLim);
SuperClass::Init(); // Initialize the superclass.
m_fHier = fHier;
m_pnt = pnt;
if (!m_pss)
return; // If the reference isn't set, we don't have anything to display.
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
StrUni stu;
PossListInfoPtr qpli;
PossItemInfo * ppii;
int ipss;
qtsf.CreateInstance(CLSID_TsStrFactory);
GetLpInfo()->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
ipss = qpli->GetIndexFromId(m_pss);
ppii = qpli->GetPssFromIndex(ipss);
AssertPtr(ppii);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
int ws = ppii->GetWs();
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
qpli->AddNotify(this);
}
示例5: InitNew
/*----------------------------------------------------------------------------------------------
Initialize the data from the given file, or create a new empty string.
----------------------------------------------------------------------------------------------*/
void WpDa::InitNew(StrAnsi staFileName)
{
if (staFileName == "")
{
InitNewEmpty();
return;
}
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle,stuNormal.Bstr()));
delete[] prghvoPara;
}
示例6: LoadIntoEmpty
/*----------------------------------------------------------------------------------------------
Load the data from the given file into an empty window.
----------------------------------------------------------------------------------------------*/
void WpDa::LoadIntoEmpty(StrAnsi staFileName, WpChildWnd * pwcw)
{
Assert(staFileName != "");
int ctss;
CheckHr(get_VecSize(1, kflidStText_Paragraphs, &ctss));
Assert(ctss <= 1);
Vector<StrUni> vstu;
ReadTextFromFile(staFileName, vstu);
HVO * prghvoPara = NewObj HVO[vstu.Size()];
for (int istu = 0; istu < vstu.Size(); istu++)
prghvoPara[istu] = istu + 2;
CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
int enc = 100; // replace by the right number when we figure out what it is
for (istu = 0; istu < vstu.Size(); istu++)
{
StrUni stuPara = vstu[istu];
ITsStringPtr qtss;
CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
}
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
delete[] prghvoPara;
pwcw->ChangeNumberOfStrings(vstu.Size());
}
示例7: TrackPopupWithHelp
/*----------------------------------------------------------------------------------------------
This method works like TrackPopupMenu (supplying m_hwnd as the menu argument, and the
required nulls for the last two arguments), except that if we are in what's this help mode,
it instead tries to find the 'what's this' help for the selected item and displays it. If
it does this, it also calls ToggleHelpMode when done. For it to work, the cid must identify
a string containing multi-part names from which the krstWhatsThisEnabled option can be
retrieved.
@param hMenu handle to shortcut menu
@param uFlags options
@param x horizontal position
@param y vertical position
@param wsUser user interface writing system id.
@param ptpm contains the area not to overlap (defaults to NULL)
----------------------------------------------------------------------------------------------*/
BOOL AfWnd::TrackPopupWithHelp(HMENU hMenu, UINT uFlags, int x, int y, int wsUser,
TPMPARAMS * ptpm)
{
if (AfMainWnd::InHelpMode())
{
// Trackit without notifing the parent and get the command id.
bool fReturnCmd = uFlags & TPM_RETURNCMD;
uFlags |= TPM_NONOTIFY | TPM_RETURNCMD;
// Do this BEFORE we show the menu, so it shows normally.
AfMainWnd::ToggleHelpMode();
// This is dirty trick played by Windows that works because BOOL is really a short.
BOOL cid = ::TrackPopupMenuEx(hMenu, uFlags, x, y, m_hwnd, ptpm);
StrApp staMsg;
AfUtil::GetResourceStr(krstWhatsThisEnabled, cid, staMsg);
StrUni stuMsg = staMsg;
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMsg;
qtsf->MakeStringRgch(stuMsg.Chars(), stuMsg.Length(), wsUser, &qtssMsg);
AfContextHelpWndPtr qchw;
qchw.Attach(NewObj AfContextHelpWnd);
Point pt (x, y);
qchw->Create(m_hwnd, qtssMsg, pt);
if (fReturnCmd)
return cid;
else
return cid ? TRUE : 0;
}
else
{
return ::TrackPopupMenuEx(hMenu, uFlags, x, y, m_hwnd, ptpm);
}
}
示例8: Display
/*----------------------------------------------------------------------------------------------
This is the main interesting method of displaying objects and fragments of them.
Here a text is displayed by displaying its paragraphs;
and a paragraph is displayed by invoking its style rule, making a paragraph,
and displaying its contents.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP TestStVc::Display(IVwEnv * pvwenv, HVO hvo, int frag)
{
try
{
switch(frag)
{
case kfrText:
{// BLOCK for var skip warnings
// We need to show something, since the current view code can't handle a property
// containing no boxes.
// Review JohnT: should we show an empty string or something?
// Should we prevent the occurrence of texts with no paragraphs?
int cpara = 0;
ISilDataAccessPtr qsda;
CheckHr(pvwenv->get_DataAccess(&qsda));
if (hvo)
CheckHr(qsda->get_VecSize(hvo, kflidStText_Paragraphs, &cpara));
if (!cpara)
{
// Either we have no ST object at all, or it is empty of paragraphs. The
// current view code can't handle either, so stick something in.
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMissing;
CheckHr(qtsf->MakeStringRgch(L"<no paragraphs>", 15, 0, &qtssMissing));
CheckHr(pvwenv->AddString(qtssMissing));
break;
}
CheckHr(pvwenv->AddObjVecItems(kflidStText_Paragraphs, this, kfrPara));
}
break;
case kfrPara:
{ // BLOCK
// Invoke the paragraph's style rule if any
ISilDataAccessPtr qsda;
CheckHr(pvwenv->get_DataAccess(&qsda));
ITsTextPropsPtr qttp;
CheckHr(qsda->get_UnknownProp(hvo, kflidStPara_StyleRules, IID_ITsTextProps,
(void **) &qttp));
if (qttp)
CheckHr(pvwenv->put_Props(qttp));
// And make the paragraph containing the paragraph contents.
CheckHr(pvwenv->OpenParagraph());
CheckHr(pvwenv->AddStringProp(kflidStTxtPara_Contents));
CheckHr(pvwenv->CloseParagraph());
}
break;
}
}
catch (Throwable & thr)
{
return thr.Error();
}
catch (...)
{
return WarnHr(E_FAIL);
}
return S_OK;
}
示例9: VwCustDocVc
/*----------------------------------------------------------------------------------------------
Construct the view constructor. Pass the RecordSpec of the view it is for, which allows it
to find its block specs.
ENHANCE JohnT: This is a rather low level object to know about the application and its list
of views. Should we just pass in the list of block specs?
----------------------------------------------------------------------------------------------*/
CleCustDocVc::CleCustDocVc(UserViewSpec * puvs, AfLpInfo * plpi, CleMainWnd * pcmw)
: VwCustDocVc(puvs, plpi, 0, kflidCmPossibilityList_Possibilities)
{
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
StrUni stu;
stu.Load(kstidSpaces0);
CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), m_qlpi->GetDbInfo()->UserWs(),
&m_qtssMissing));
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
// Border thickness below about 1/96 inch, a single pixel on a typical display.
CheckHr(qtpb->SetIntPropValues(ktptBorderTop, ktpvMilliPoint, kdzmpInch / 96));
// About a line (say 12 point) of white space above and below the border.
CheckHr(qtpb->SetIntPropValues(ktptPadTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptMarginTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMain));
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainLast));
qtpb.CreateInstance(CLSID_TsPropsBldr);
CheckHr(qtpb->SetIntPropValues(ktptMarginTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainFirst));
qtpb.CreateInstance(CLSID_TsPropsBldr);
// Border thickness below about 1/96 inch, a single pixel on a typical display.
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptMarginBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpMainFlat));
// And make the one for subentries.
qtpb.CreateInstance(CLSID_TsPropsBldr);
CheckHr(qtpb->SetIntPropValues(ktptPadTop, ktpvMilliPoint, 12000));
CheckHr(qtpb->SetIntPropValues(ktptBorderTop, ktpvMilliPoint, 0));
CheckHr(qtpb->SetIntPropValues(ktptMarginBottom, ktpvMilliPoint, 0));
// The value below is sort of a default for one level of indentation; it will be
// adjusted for lower levels.
CheckHr(qtpb->SetIntPropValues(ktptPadLeading, ktpvMilliPoint, kdzmpInch * 3 / 10));
CheckHr(qtpb->GetTextProps(&m_qttpSub));
CheckHr(qtpb->SetIntPropValues(ktptBorderBottom, ktpvMilliPoint, kdzmpInch / 96));
CheckHr(qtpb->SetIntPropValues(ktptPadBottom, ktpvMilliPoint, 12000));
CheckHr(qtpb->GetTextProps(&m_qttpSubLast));
m_qRecVc.Attach(NewObj CleRecVc);
m_qcmw.Attach(pcmw);
AddRefObj(pcmw);
PossListInfoPtr qpli;
m_qlpi->LoadPossList(pcmw->GetHvoPssl(), pcmw->AnalysisEnc(), &qpli);
m_hvoPssl = qpli->GetPsslId();
}
示例10: UpdateField
/*----------------------------------------------------------------------------------------------
Refresh the field from the data cache.
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::UpdateField()
{
// Get the item info from the cache.
CustViewDaPtr qcvd;
GetDataAccess(&qcvd);
AssertPtr(qcvd);
HVO hvoPss;
CheckHr(qcvd->get_ObjectProp(m_hvoObj, m_flid, &hvoPss));
m_pss = hvoPss;
// Get the string from the poss cache.
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
StrUni stu;
PossListInfoPtr qpli;
PossItemInfo * ppii;
int ipss;
qtsf.CreateInstance(CLSID_TsStrFactory);
int ws = m_ws;
if (m_pss)
{
GetLpInfo()->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
ipss = qpli->GetIndexFromId(m_pss);
if (ipss >= 0)
{
ppii = qpli->GetPssFromIndex(ipss);
AssertPtr(ppii);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
ws = ppii->GetWs();
}
}
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
// If we have an edit box, update the contents.
if (m_hwnd)
{
// Setting the property causes a recursive call to OnChange, so we want to block it
// from making a further change. (e.g., when you backspace to set the string to null
// then tab to the next field, we want it to stay null, not go to the first item in
// the list.)
m_fRecurse = true;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, (LPARAM)m_qtss.Ptr());
}
}
示例11: SharonC
/*----------------------------------------------------------------------------------------------
Initialize an empty document. It has a document object (always ID 1!) and one paragraph
containing (implicitly) an empty string. Style is set to Normal
Review SharonC(JohnT): what encoding should the empty string have??
----------------------------------------------------------------------------------------------*/
void WpDa::InitNewEmpty()
{
HVO hvoPara = 2;
CacheVecProp(1, kflidStText_Paragraphs, &hvoPara, 1);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtss;
int enc = 100;
CheckHr(qtsf->MakeStringRgch(L"", 0, enc, &qtss));
CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtss);
ITsPropsBldrPtr qtpb;
qtpb.CreateInstance(CLSID_TsPropsBldr);
StrUni stuNormal = L"Normal";
CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
}
示例12: ChooserApplied
/*----------------------------------------------------------------------------------------------
The Ok button in the list chooser has been hit. Process the results from the list chooser.
@param pplc Pointer to the dialog box being closed.
----------------------------------------------------------------------------------------------*/
void AfDeFeCliRef::ChooserApplied(PossChsrDlg * pplc)
{
// Get the output values.
StrUni stu;
ITsStringPtr qtss;
ITsStrFactoryPtr qtsf;
HVO pssId;
qtsf.CreateInstance(CLSID_TsStrFactory);
pplc->GetDialogValues(pssId);
m_pss = pssId;
m_fRecurse = true;
if (pssId)
{
PossListInfoPtr qpli;
AfLpInfo * plpi = GetLpInfo();
AssertPtr(plpi);
plpi->LoadPossList(m_hvoPssl, m_wsMagic, &qpli);
AssertPtr(qpli);
int ipss = qpli->GetIndexFromId(pssId);
PossItemInfo * ppii = qpli->GetPssFromIndex(ipss);
if (m_fHier)
ppii->GetHierName(qpli, stu, m_pnt);
else
ppii->GetName(stu, m_pnt);
int ws = ppii->GetWs();
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
m_qtss = qtss;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, (LPARAM)qtss.Ptr());
}
else
{
m_qtss = NULL;
::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, NULL);
}
// I (KenZ) don't fully understand this. But if a user enters the chooser, and opens a
// list editor from there and adds a new item, closes the list editor, checks the new
// item in the chooser, selects OK, then moves to the next record without moving from
// the field, the added item is lost. We get ksyncPossList and ksyncAddPss sync messages
// from the list editor, but for some reason we are getting an extra ksyncPossList
// message after this method completes. That extra message is calling ListChanged which
// calls UpdateField, which reloads our temporary cache from the main cache and wipes out
// the change we just made. So until we can do something better, we'll save the changes
// here to make sure the UpdateField doesn't wipe out our change.
SaveEdit();
::InvalidateRect(m_hwnd, NULL, true);
}
示例13: MakeRoot
void AfDeFeSt::MakeRoot(IVwGraphics * pvg, ILgWritingSystemFactory * pwsf, IVwRootBox ** pprootb)
{
AssertPtrN(pwsf);
*pprootb = NULL;
// Do we have a real text object? If not, make a fake one.
int cpara = 0;
ISilDataAccessPtr qsda = m_qcvd;
if (m_hvoText)
CheckHr(qsda->get_VecSize(m_hvoText, kflidStText_Paragraphs, &cpara));
if (!cpara)
{
// We make a dummy text that is complete enough to edit, in a separate data access
// object. On loss of focus, if this data access is dirty, we make corresponding
// real objects.
if (!m_hvoText)
m_hvoText = -1;
HVO hvoPara = -2;
m_qvcdMissing.CreateInstance(CLSID_VwCacheDa);
CheckHr(m_qvcdMissing->QueryInterface(IID_ISilDataAccess, (void **)&qsda));
m_qvcdMissing->CacheVecProp(m_hvoText, kflidStText_Paragraphs, &hvoPara,1);
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
ITsStringPtr qtssMissing;
CheckHr(qtsf->MakeStringRgch(L"", 0, m_ws, &qtssMissing));
m_qvcdMissing->CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtssMissing);
}
IVwRootBoxPtr qrootb;
qrootb.CreateInstance(CLSID_VwRootBox);
CheckHr(qrootb->SetSite(this)); // pass root site
int frag = kfrText;
IVwViewConstructor * pvvc = m_qstvc;
if (pwsf)
CheckHr(qsda->putref_WritingSystemFactory(pwsf));
CheckHr(qrootb->putref_DataAccess(qsda));
CheckHr(qrootb->SetRootObjects(&m_hvoText, &pvvc, &frag,
GetLpInfo()->GetAfStylesheet(), 1));
*pprootb = qrootb;
(*pprootb)->AddRef();
RecMainWnd * prmw = dynamic_cast<RecMainWnd *>(m_qadsc->MainWindow());
if (prmw)
prmw->RegisterRootBox(qrootb);
}
示例14: EndEdit
/*----------------------------------------------------------------------------------------------
Close the current editor, saving changes that were made. This also updates the the cache
if the name or abbr fields were edited, this then causing the treebar to be updated.
@param fForce True if we want to force the editor closed without making any
validity checks or saving any changes.
----------------------------------------------------------------------------------------------*/
void CleDeFeString::EndEdit(bool fForce)
{
if (fForce)
{
SuperClass::EndEdit(fForce);
return;
}
CleMainWnd * pcmw = dynamic_cast<CleMainWnd *>(MainWindow());
Assert(pcmw);
PossListInfoPtr qpli = pcmw->GetPossListInfoPtr();
int ipss = qpli->GetIndexFromId(m_hvoObj);
if (ipss < 0)
{
SuperClass::EndEdit(fForce); // Closing an old editor after an item was removed.
return;
}
PossItemInfo * ppii = qpli->GetPssFromIndex(ipss);
AssertPtr(ppii);
StrUni stu;
const OLECHAR * prgwch;
int cch;
ITsStringPtr qtss;
AssertPtr(m_qadsc->MainWindow());
AfLpInfo * plpi = m_qadsc->MainWindow()->GetLpInfo();
AssertPtr(plpi);
AfDbInfo * pdbi;
pdbi = plpi->GetDbInfo();
AssertPtr(pdbi);
int wsMagic = qpli->GetWs();
int ws = plpi->ActualWs(wsMagic);
// At this point, all strings in a PossList cache are assumed to have the same writing system.
// However, if that writing system is missing, a non-null string from a different writing system is
// loaded. Thus if FRN is the writing system for the PossList cache, we can't tell from the
// cache whether the string we are getting is FRN or ENG, or some other writing system. When
// we display strings in this editor, we show actual strings for each writing system shown.
// Suppose we are showing FRN and ENG, but FRN is missing. If a person edits the ENG
// string that is showing, the user would expect the tree to reflect this change, since
// FRN is still missing. However we can't do this at this point because we don't know
// which writing system is actually being substituted in the tree. It could actually be a GER
// string because there also wasn't an ENG string. So until we cache encodings with each
// string, the best we can do is only modify the PossList cache if the string for the
// primary writing system changed. In that case, we now have a FRN string, so it should show
// in the tree as well.
CustViewDaPtr qcvd = pcmw->MainDa();
AssertPtr(qcvd);
// Get the current primary string.
CheckHr(qcvd->get_MultiStringAlt(m_hvoObj, m_flid, ws, &qtss));
if (qtss)
{
qtss->LockText(&prgwch, &cch);
qtss->UnlockText(prgwch);
}
// Trim leading and trailing space characters.
UnicodeString ust(prgwch, cch);
ust.trim();
stu.Assign(ust.getBuffer(), ust.length());
// We don't expect to use this for anything except name or abbr.
Assert(m_flid == kflidCmPossibility_Name || m_flid == kflidCmPossibility_Abbreviation);
// We don't allow long strings.
if (stu.Length() > kcchPossNameAbbrMax) // Need constant here and the line below.
{
::MessageBeep(MB_ICONEXCLAMATION); // Beep if we truncated the length.
stu.Replace(kcchPossNameAbbrMax, stu.Length(), L"");
}
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss);
// If we changed the length, store the trimmed string.
if (cch != stu.Length())
{
// Check if the record has been edited by someone else since we first loaded the data.
HRESULT hrTemp;
if ((hrTemp = qcvd->CheckTimeStamp(m_hvoObj)) != S_OK)
{
// If it was changed and the user does not want to overwrite it, perform a refresh
// so the displayed field will revert to its original value.
CheckHr(qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1));
return;
}
// Update the value in the cache and refresh views.
CheckHr(qcvd->SetMultiStringAlt(m_hvoObj, m_flid, ws, qtss));
CheckHr(qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1));
}
//.........这里部分代码省略.........
示例15: ListChanged
/*----------------------------------------------------------------------------------------------
Something has changed in the possibility list.
----------------------------------------------------------------------------------------------*/
void RnDeFeRoleParts::ListChanged(int nAction, HVO hvoPssl, HVO hvoSrc, HVO hvoDst, int ipssSrc,
int ipssDst)
{
if (hvoPssl != m_psslRole)
{
// Process changes for people lists.
SuperClass::ListChanged(nAction, hvoPssl, hvoSrc, hvoDst, ipssSrc, ipssDst);
return;
}
// If someone deleted the role we are interested in we need to clean up.
if (hvoSrc == m_pssRole && nAction == kplnaDelete)
{
// Remove the notifier for the role list.
Assert(m_psslRole);
PossListInfoPtr qpli;
GetLpInfo()->LoadPossList(m_psslRole, m_wsMagic, &qpli);
AssertPtr(qpli);
qpli->RemoveNotify(this);
m_psslRole = 0;
m_pssRole = 0;
}
// At this point we are not getting kplnaMerged at all since we are just deleting all
// fields and recreating new ones. But at some point down the road we may want to switch
// to where we don't delete and recreate. This would be the right action to take then.
if (hvoSrc == m_pssRole && nAction == kplnaMerged)
{
// Switch to the new role.
m_pssRole = hvoDst;
}
// Now reset the label in case we changed.
// Use Participants for the unspecified editor label.
ITsStringPtr qtssName;
int wsUser = GetLpInfo()->GetDbInfo()->UserWs();
AfUtil::GetResourceTss(kstidTlsOptParticipants, wsUser, &qtssName);
ITsStringPtr qtssHelp = m_qfsp->m_qtssHelp;
ITsStrFactoryPtr qtsf;
qtsf.CreateInstance(CLSID_TsStrFactory);
if (m_pssRole)
{
PossItemInfo * ppii;
GetLpInfo()->GetPossListAndItem(m_pssRole, wsUser, &ppii, NULL);
StrUni stuName; // the Role's name
ppii->GetName(stuName, m_pnt);
qtsf->MakeStringRgch(stuName.Chars(), stuName.Length(), wsUser, &qtssName);
ITsIncStrBldrPtr qtisb;
qtisb.CreateInstance(CLSID_TsIncStrBldr);
// Add the first substring.
qtisb->AppendTsString(m_qfsp->m_qtssHelp);
// Add the second substring.
StrUni stuTemp;
stuTemp.Load(kstidRnRoledPartic_HelpA);
qtisb->AppendRgch(stuTemp.Chars(), stuTemp.Length());
// Turn bold on.
qtisb->SetIntPropValues(ktptBold, ktpvEnum, kttvForceOn);
// Add the Role's name
qtisb->AppendRgch(stuName.Chars(), stuName.Length());
// Turn bold off.
qtisb->SetIntPropValues(ktptBold, ktpvEnum, kttvOff);
// Add the third substring.
stuTemp.Load(kstidRnRoledPartic_HelpB);
qtisb->AppendRgch(stuTemp.Chars(), stuTemp.Length());
// Get the completed TsString.
qtisb->GetString(&qtssHelp);
}
m_qtssLabel = qtssName;
m_qtssHelp = qtssHelp;
// Force the label to redraw.
Rect rcLabel;
::GetClientRect(m_qadsc->Hwnd(),&rcLabel);
Rect rcEdit(m_rcClip);
if (m_hwnd)
{
// We have an open edit box, so get the correct coordinates for the client window.
::GetClientRect(m_hwnd, &rcEdit);
::MapWindowPoints(m_hwnd, m_qadsc->Hwnd(), (POINT *)&rcEdit, 2);
}
rcLabel.top = rcEdit.top;
rcLabel.bottom = rcEdit.bottom;
rcLabel.right = m_qadsc->GetTreeWidth();
::InvalidateRect(m_qadsc->Hwnd(), &rcLabel, false);
}