void SampleInterface::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<SampleInterface> qxsi; qxsi.Attach(NewObj SampleInterface()); // ref count initialy 1 CheckHr(qxsi->QueryInterface(riid, ppv)); }
/*---------------------------------------------------------------------------------------------- Add an action to the list. ----------------------------------------------------------------------------------------------*/ void ActionHandler::AddActionAux(IUndoAction * puact) { CleanUpRedoActions(false); if (m_fStartedNext) { m_vstuUndo.Push(m_stuNextUndo); m_vstuRedo.Push(m_stuNextRedo); m_viSeqStart.Push(m_vquact.Size()); // new sequence where the action will go m_iCurrSeq = m_viSeqStart.Size() - 1; m_fStartedNext = false; } // The current action should be the last one in the stack since we just cleared all // the redo actions. Assert(m_iuactCurr == m_vquact.Size() - 1); // Marks shouldn't straddle tasks; the most recent mark should correspond to the beginning // of some task. We test for this here because it is only here that we know we have a // legitimate task with actions inside. // The test framework starts an outer level of undo, which invalidates this sanity check. // JohnT doesn't remember this check ever catching a real bug anyway! //#if _DEBUG // if (m_viMarks.Size()) // { // int iuactTopMark = m_viMarks[m_viMarks.Size() - 1]; // int iSeq; // for (iSeq = 0; iSeq < m_viSeqStart.Size(); iSeq++) // { // if (m_viSeqStart[iSeq] == iuactTopMark) // break; // } // Assert(iSeq < m_viSeqStart.Size()); // die if we didn't find such a sequence // } //#endif // _DEBUG // Add an action to the stack m_vquact.Push(puact); m_iuactCurr = m_vquact.Size() - 1; ComBool f; CheckHr(puact->IsDataChange(&f)); if (f) { // We've added something real to the current action; that makes it one that // can be continued, if something wants to after closing it. m_fCanContinueTask = true; m_fDataChangeAction = true; } //::OutputDebugStringA("After AddActionAux\n"); //StrAnsi sta; //sta.Format("depth = %d; m_fStartedNext = %d; action %d of %d; seq %d of %d; marks %d%n", // m_nDepth, m_fStartedNext, m_iuactCurr, m_vquact.Size(), m_iCurrSeq, m_viSeqStart.Size(), m_viMarks.Size()); //::OutputDebugStringA(sta.Chars()); }
/*---------------------------------------------------------------------------------------------- This static method creates a new LgTsDataObject object. ----------------------------------------------------------------------------------------------*/ void LgTsDataObject::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<LgTsDataObject> qtsdo; qtsdo.Attach(NewObj LgTsDataObject); // ref count initialy 1 CheckHr(qtsdo->QueryInterface(riid, ppv)); }
void RomRenderEngine::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<RomRenderEngine> qrre; qrre.Attach(NewObj RomRenderEngine()); // ref count initialy 1 CheckHr(qrre->QueryInterface(riid, ppv)); }
void LgKeymanHandler::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<LgKeymanHandler> qlkh; qlkh.Attach(NewObj LgKeymanHandler()); // ref count initialy 1 CheckHr(qlkh->QueryInterface(riid, ppv)); }
void LgCodePageEnumerator::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<LgCodePageEnumerator> qlcpe; qlcpe.Attach(NewObj LgCodePageEnumerator()); // ref count initialy 1 CheckHr(qlcpe->QueryInterface(riid, ppv)); }
/*---------------------------------------------------------------------------------------------- Static method to create an instance of FwDbMergeStyles. ----------------------------------------------------------------------------------------------*/ void FwDbMergeStyles::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<FwDbMergeStyles> qzfwst; qzfwst.Attach(NewObj FwDbMergeStyles()); // ref count initially 1 CheckHr(qzfwst->QueryInterface(riid, ppv)); }
void LgInputMethodEditor::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<LgInputMethodEditor> qime; qime.Attach(NewObj LgInputMethodEditor()); // ref count initialy 1 CheckHr(qime->QueryInterface(riid, ppv)); }
void VwInvertedRootBox::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<VwInvertedRootBox> qrootb; qrootb.Attach(NewObj VwInvertedRootBox()); // ref count initialy 1 CheckHr(qrootb->QueryInterface(riid, ppv)); }
void AfFwTool::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); ComSmartPtr<AfFwTool> qaft; qaft.Attach(NewObj AfFwTool()); // ref count initialy 1 CheckHr(qaft->QueryInterface(riid, ppv)); }
/*---------------------------------------------------------------------------------------------- @return true if any changes have been made. ----------------------------------------------------------------------------------------------*/ bool AfDeFeCliRef::IsDirty() { if (!m_hwnd) return false; // Editor not active. HVO hvoOrig; CustViewDaPtr qcvd; GetDataAccess(&qcvd); AssertPtr(qcvd); CheckHr(qcvd->get_ObjectProp(m_hvoObj, m_flid, &hvoOrig)); return hvoOrig != m_pss; }
/*---------------------------------------------------------------------------------------------- Check the requirments of the FldSpec, and verify that data in the field meets the requirement. It returns: kFTReqNotReq if the all requirements are met. kFTReqWs if data is missing, but it is encouraged. kFTReqReq if data is missing, but it is required. ----------------------------------------------------------------------------------------------*/ FldReq AfDeFeSt::HasRequiredData() { if (m_qfsp->m_fRequired == kFTReqNotReq) return kFTReqNotReq; CustViewDaPtr qcvd; GetDataAccess(&qcvd); AssertPtr(qcvd); bool fEmpty = true; ITsStringPtr qtss; int cch = 0; HVO hvoPara; int iPara; if (!m_hvoText) goto LExit; int cPara; CheckHr(qcvd->get_VecSize(m_hvoText, kflidStText_Paragraphs, &cPara)); if (!cPara) goto LExit; // Make sure at least some paragraph has data. for (iPara = 0; iPara < cPara; ++iPara) { CheckHr(qcvd->get_VecItem(m_hvoText, kflidStText_Paragraphs, iPara, &hvoPara)); // At some point we may need to handle something other than StTxtPara. CheckHr(qcvd->get_StringProp(hvoPara, kflidStTxtPara_Contents, &qtss)); if (qtss) CheckHr(qtss->get_Length(&cch)); if (cch) break; // Have a valid string } fEmpty = iPara == cPara; LExit: if (fEmpty) return m_qfsp->m_fRequired; else return kFTReqNotReq; }
//:>******************************************************************************************** //:> DbColSpec - IUnknown methods //:>******************************************************************************************** void DbColSpec::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) { ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); } ComSmartPtr<DbColSpec> qzdcs; qzdcs.Attach(NewObj DbColSpec()); // ref count initially 1 CheckHr(qzdcs->QueryInterface(riid, ppv)); }
/*---------------------------------------------------------------------------------------------- Return the what's-this help string for the Date Dialog ellipsis button. @param pt not used. @param pptss Address of a pointer to an ITsString COM object for returning the help string. @return true. ----------------------------------------------------------------------------------------------*/ bool AfDeFeEdBoxBut::DeButton::GetHelpStrFromPt(Point pt, ITsString ** pptss) { AssertPtr(pptss); StrApp str; str.Load(kstidEllipsisBtnDateWhatsThisHelp); // No context help available ITsStrFactoryPtr qtsf; qtsf.CreateInstance(CLSID_TsStrFactory); StrUni stu(str); CheckHr(qtsf->MakeString(stu.Bstr(), m_pdee->UserWs(), pptss)); return true; }
/*---------------------------------------------------------------------------------------------- End editing with a temporary data cache by clearing stuff out down to the mark created by BeginTempEdit. This can be called any number of times. If a mark is not in progress, it does nothing. @return ----------------------------------------------------------------------------------------------*/ IActionHandler * AfDeFeEdBoxBut::EndTempEdit() { // Get your action handler. CustViewDaPtr qcvd; GetDataAccess(&qcvd); IActionHandlerPtr qacth; CheckHr(qcvd->GetActionHandler(&qacth)); // Clear out any temporary Undo items relating to this window. if (m_hMark) { // Calling DiscardToMark() when the depth is greater than zero crashes. (See DN-786.) int nDepth; CheckHr(qacth->get_CurrentDepth(&nDepth)); if (nDepth == 0) { CheckHr(qacth->DiscardToMark(0)); m_hMark = 0; } } return qacth; }
void ViewTest2::TestMakeTextSelection() { VwSelLevInfo vsli; vsli.ihvo=-1; vsli.cpropPrevious = 0; vsli.tag = kflidStText_Paragraphs; m_psts->Output(" FUNCTION: MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, " "25, 0, false, 2))\n"); CheckHr(m_qrootb->MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, 25, 0, false, 2)); m_psts->Output("\n Now Testing DestroySelection()\n"); CheckHr(m_qrootb->DestroySelection()); m_psts->Output(" FUNCTION: MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, " "25, 0, false, 0))\n"); CheckHr(m_qrootb->MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, 25, 0, false, 0)); m_psts->Output(" FUNCTION: MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, " "25, 0, false, 0))\n"); CheckHr(m_qrootb->MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, 25, 0, false, 0)); m_psts->Output("MULTIPLE ENTRY"); m_psts->Output(" FUNCTION: MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 25, " "75, 0, false, 1))\n"); CheckHr(m_qrootb->MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 25, 75, 0, false, 1)); m_psts->Output(" FUNCTION: MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, " "25, 0, false, -1))\n"); CheckHr(m_qrootb->MakeTextSelection(0, 1, &vsli, kflidStTxtPara_Contents, 0, 5, 25, 0, false, -1)); }
/*---------------------------------------------------------------------------------------------- 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(); }
/*---------------------------------------------------------------------------------------------- Draw to the given clip rectangle. @param hdc @param rcpClip the given clip rectangle TODO: use views code to display the field contents! ----------------------------------------------------------------------------------------------*/ void AfDeFeEdBoxBut::Draw(HDC hdc, const Rect & rcpClip) { Assert(hdc); int ws; SmartBstr sbstr; if (m_qtss) { CheckHr(m_qtss->get_Text(&sbstr)); int nVar; ITsTextPropsPtr qttp; CheckHr(m_qtss->get_PropertiesAt(0, &qttp)); CheckHr(qttp->GetIntPropValues(ktptWs, &nVar, &ws)); MakeCharProps(ws); CreateFont(); } AfGfx::FillSolidRect(hdc, rcpClip, m_chrp.clrBack); COLORREF clrBgOld = AfGfx::SetBkColor(hdc, m_chrp.clrBack); COLORREF clrFgOld = AfGfx::SetTextColor(hdc, m_chrp.clrFore); HFONT hfontOld = AfGdi::SelectObjectFont(hdc, m_hfont); #if 1 UINT uAlignPrev = ::GetTextAlign(hdc); if (m_fRtl) { ::SetTextAlign(hdc, (uAlignPrev & ~(TA_CENTER|TA_LEFT)) | TA_RIGHT | TA_RTLREADING); ::TextOutW(hdc, rcpClip.right - 19, rcpClip.top + 1, sbstr.Chars(), sbstr.Length()); } else { ::SetTextAlign(hdc, (uAlignPrev & ~(TA_CENTER|TA_RIGHT)) | TA_LEFT); ::TextOutW(hdc, rcpClip.left + 2, rcpClip.top + 1, sbstr.Chars(), sbstr.Length()); } ::SetTextAlign(hdc, uAlignPrev); #else ::TextOutW(hdc, rcpClip.left + 2, rcpClip.top + 1, sbstr.Chars(), sbstr.Length()); #endif AfGdi::SelectObjectFont(hdc, hfontOld, AfGdi::OLD); AfGfx::SetBkColor(hdc, clrBgOld); AfGfx::SetTextColor(hdc, clrFgOld); }
void DebugReport::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) { ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); } ComSmartPtr<DebugReport> qdbr; // Ref count initially 1 qdbr.Attach(NewObj DebugReport()); CheckHr(qdbr->QueryInterface(riid, ppv)); }
void ActionHandler::CreateCom(IUnknown *punkCtl, REFIID riid, void ** ppv) { AssertPtr(ppv); Assert(!*ppv); if (punkCtl) { ThrowHr(WarnHr(CLASS_E_NOAGGREGATION)); } ComSmartPtr<ActionHandler> qzacth; // Ref count initially 1 qzacth.Attach(NewObj ActionHandler()); CheckHr(qzacth->QueryInterface(riid, ppv)); }
/*---------------------------------------------------------------------------------------------- Selects a range of characters. Message: EM_SETSEL. ----------------------------------------------------------------------------------------------*/ void TssEdit::SetSel(int ichAnchor, int ichEnd) { Assert(m_qrootb); int cch = 0; ITsStringPtr qtss; CheckHr(m_qcda->get_StringProp(khvoString, ktagString, &qtss)); if (qtss) CheckHr(qtss->get_Length(&cch)); if (ichAnchor < 0) ichAnchor = cch; if (ichEnd < 0) ichEnd = cch; if (ichAnchor > cch) ichAnchor = cch; // This can happen; apparently when a tab brings the focus to this window, Windows passes // a large number rather than -1 to set the end of the range. if (ichEnd > cch) ichEnd = cch; CheckHr(m_qrootb->MakeTextSelection(0, 0, NULL, ktagString, 0, ichAnchor, ichEnd, 0, true, -1, NULL, true, NULL)); }
void ViewTest2::WrapOnTyping(char *pchinput, int _cchBackspace, int _cchDelForward, char *_chFirst, RECT _rcSrc, RECT _rcDst) { OLECHAR oleChar = _chFirst[0]; SmartBstr _bstrInput = StrUni(pchinput).Bstr(); m_psts->OutputFormat(" FUNCTION: OnTyping(m_qvg, \"%s\", %d, %d, '%s', {%d,%d,%d,%d}, " "{%d,%d,%d,%d})\n", pchinput, _cchBackspace, _cchDelForward, _chFirst, _rcSrc.left, _rcSrc.top, _rcSrc.right, _rcSrc.bottom, _rcDst.left, _rcDst.top, _rcDst.right, _rcDst.bottom); CheckHr(m_qrootb->OnTyping(m_qvg, _bstrInput, _cchBackspace, _cchDelForward, oleChar, _rcSrc, _rcDst)); }
void ViewTest1::TestGuid() { OLECHAR rgchGuid[9] = L"B8A6E680"; OLECHAR rgchGuid2[9]; // Send NULL pointers HRESULT hr = m_qxvoTest->put_Guid(NULL); if (!FAILED(hr)) Failure("Call to function put_Guid(NULL) should have returned an error"); hr = m_qxvoTest->get_Guid(NULL); if (!FAILED(hr)) Failure("Call to function get_Guid(NULL) should have returned an error"); // Valid test CheckHr(m_qxvoTest->put_Guid(rgchGuid)); CheckHr(m_qxvoTest->get_Guid(rgchGuid2)); // Compare the two guids and report, result should be > or < 0 if (wcscmp(rgchGuid, rgchGuid2)) Failure("Guid function returned wrong result"); }
/*---------------------------------------------------------------------------------------------- Return the size of the text, in points. Not part of ITextSource interface; specific to FwGrTxtSrc. ----------------------------------------------------------------------------------------------*/ float FwGrTxtSrc::GetFontSize(int ich) { LgCharRenderProps lgchrp; int ichMinBogus, ichLimBogus; GrResult res = (GrResult)m_qts->GetCharProps(ich, &lgchrp, &ichMinBogus, &ichLimBogus); int dympHeight = lgchrp.dympHeight; if(lgchrp.ssv != kssvOff) { // psuedo device context works since we are getting proportions which are invariant HDC hdc = ::CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL); IVwGraphicsWin32Ptr qvgW; qvgW.CreateInstance(CLSID_VwGraphicsWin32); qvgW->Initialize(hdc); IVwGraphicsPtr qvg; CheckHr(qvgW->QueryInterface(IID_IVwGraphics, (void **) &qvg)); CheckHr(qvg->SetupGraphics(&lgchrp)); int dSizeNumerator = 1; int dSizeDenominator = 1; if (lgchrp.ssv == kssvSuper) { CheckHr(qvg->GetSuperscriptHeightRatio(&dSizeNumerator, &dSizeDenominator)); } else if (lgchrp.ssv == kssvSub) { CheckHr(qvg->GetSubscriptHeightRatio(&dSizeNumerator, &dSizeDenominator)); } dympHeight = gr::GrEngine::GrIntMulDiv(dympHeight, dSizeNumerator, dSizeDenominator); qvgW.Clear(); qvg.Clear(); ::DeleteDC(hdc); } return (float)(dympHeight / 1000); }
/*---------------------------------------------------------------------------------------------- Turn off the keyman keyboard ----------------------------------------------------------------------------------------------*/ void TurnOffKeymanKbd(BSTR * pbstrActiveKeymanKbd) { // It seems sometimes to be necessary to explicitly turn Keyman off, though it's not // supposed to be. One reason is that on loss of focus, C# code loses track of the // current keyboard, so *pbstrActiveKeymanKbd cannot be relied on. //if (BstrLen(*pbstrActiveKeymanKbd)) ILgKeymanHandlerPtr qkh; qkh.CreateInstance(CLSID_LgKeymanHandler); CheckHr(qkh->put_ActiveKeyboardName(NULL)); if (*pbstrActiveKeymanKbd) ::SysFreeString(*pbstrActiveKeymanKbd); *pbstrActiveKeymanKbd = NULL; }
int main(int argc, char** argv) { try { #ifdef WIN32 DllMain(0, DLL_PROCESS_ATTACH, 0); #endif IClassFactory* pFact = 0; CheckHr(DllGetClassObject(CLSID_TestGenericFactory, IID_IClassFactory, (void**)&pFact)); IUnknown* pTest = 0; CheckHr(pFact->CreateInstance(0, IID_IUnknown, (void**)&pTest)); pFact->Release(); pTest->Release(); #ifdef WIN32 return DllMain(0, DLL_PROCESS_DETACH, 0) ? 0 : 1; #else return 0; #endif } catch (Throwable& thr) { std::cerr << "Failed HRESULT: " << thr.Error() << "\n"; } catch (std::exception& e) { std::cerr << "Exception: " << e.what() << "\n"; } catch (...) { std::cerr << "Unknown Exception:\n"; } return 2; }
/*---------------------------------------------------------------------------------------------- Save changes that have been made to the current editor. @return true if edit saved successfully ----------------------------------------------------------------------------------------------*/ bool AfDeFeCliRef::SaveEdit() { if (m_fDelFromDialog) { m_fDelFromDialog = false; return true; } EndTempEdit(); if (IsDirty()) { CustViewDaPtr qcvd; GetDataAccess(&qcvd); AssertPtr(qcvd); // Check if the record has been edited by someone else since we first loaded the data. HRESULT hr; CheckHr(hr = qcvd->CheckTimeStamp(m_hvoObj)); if (hr != 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 it's original value. m_qadsc->UpdateAllDEWindows(m_hvoObj, m_flid); qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1); } else { // Update the value in the cache and refresh views. BeginChangesToLabel(); qcvd->SetObjProp(m_hvoObj, m_flid, m_pss); m_qadsc->UpdateAllDEWindows(m_hvoObj, m_flid); qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1); CheckHr(qcvd->EndUndoTask()); } } // We need to leave in a state that cancels undo actions since this may be called // without actually closing the edit box. BeginTempEdit(); return true; }
/*---------------------------------------------------------------------------------------------- ${IActionHandler#Rollback} ----------------------------------------------------------------------------------------------*/ STDMETHODIMP ActionHandler::Rollback(int nDepth) { BEGIN_COM_METHOD; if (m_nDepth > 0) { CheckHr(EndUndoTask()); m_nDepth = nDepth; // make sure we have something to undo if (m_iCurrSeq >= 0 && m_fDataChangeAction) { UndoResult ures; CheckHr(Undo(&ures)); // REVIEW (TimS): What should we do if the undo fails? if (ures == kuresError || ures == kuresFailed) { return E_FAIL; } CleanUpRedoActions(true); } } return S_OK; END_COM_METHOD(g_factActh, IID_IActionHandler); }
/*---------------------------------------------------------------------------------------------- Replace the current selection with the specified text. Message: FW_EM_REPLACESEL. ----------------------------------------------------------------------------------------------*/ void TssEdit::ReplaceSel(ITsString * ptss) { AssertPtr(ptss); AssertPtr(m_qrootb); IVwSelectionPtr qvwsel; CheckHr(m_qrootb->get_Selection(&qvwsel)); if (!qvwsel) { // If there's not a selection, try to create one at the beginning of the string! CheckHr(m_qrootb->MakeTextSelection(0, 0, NULL, ktagString, 0, 0, 0, 0, true, -1, NULL, true, &qvwsel)); if (!qvwsel) return; } CheckHr(qvwsel->ReplaceWithTsString(ptss)); // ReplaceWithTsString should handle this (JohnT, 8-22-01). //CheckHr(m_qcda->PropChanged(NULL, kpctNotifyAll, khvoString, ktagString, 0, 0, 0)); OnUpdate(); ::UpdateWindow(m_hwnd); OnChange(); }
/*---------------------------------------------------------------------------------------------- Determine how to kern the glyphs to get a justified effect. Return kresFalse if we can't achieve the desired width. ----------------------------------------------------------------------------------------------*/ GrResult FwGrJustifier::adjustGlyphWidths(gr::GraphiteProcess * pgproc, int iGlyphMin, int iGlyphLim, float dxCurrentWidth, float dxDesiredWidth) { gr::GrEngine * pgreng = dynamic_cast<gr::GrEngine *>(pgproc); FwGraphiteProcess fgje; fgje.SetProcess(pgreng); FwGraphiteProcess * pfgje = &fgje; IJustifyingRendererPtr qjrend; CheckHr(pfgje->QueryInterface(IID_IJustifyingRenderer, (void **)&qjrend)); return (GrResult)m_qjus->AdjustGlyphWidths(qjrend, iGlyphMin, iGlyphLim, dxCurrentWidth, dxDesiredWidth); }