Text Services Framework
ITextStoreACP

The ITextStoreACP interface is implemented by the application and is used by the TSF manager to manipulate text streams or text stores in TSF. An application can obtain an instance of this interface with a call to the ITfDocumentMgr::CreateContext method. The interface ID is IID_ITextStoreACP.

This interface exposes text stores through an application character position (ACP) format. Applications that use an anchor-based format should use ITextStoreAnchor.

Methods in Vtable Order

The ITextStoreACP interface inherits the methods of the standard COM interface IUnknown.

In addition, ITextStoreACP defines the following methods.

ITextStoreACP methods Description
AdviseSink Identifies the sink interface of the TSF manager.
UnadviseSink Called by the application to indicate that the application no longer requires notifications from the TSF manager.
RequestLock Called by the TSF manager to provide a document lock so that the TSF manager can modify the document. This method calls the ITextStoreACPSink::OnLockGranted method to create the document lock.
GetStatus Used by the application to obtain the document status.
QueryInsert Called by an application to determine if the document can accept text at the selection or insertion point.
GetSelection Returns the character position of a text selection in a document.
SetSelection Selects text within the document.
GetText Returns information about text at a specified character position.
SetText Sets the text selection to the supplied character positions.
GetFormattedText Returns formatted text information about a specified text string.
GetEmbedded Obtains an embedded object from a document.
QueryInsertEmbedded Determines if the document can accept an embedded object through the ITextStoreACP::InsertEmbedded or the ITextStoreACP::InsertEmbeddedAtSelection methods.
InsertEmbedded Inserts an object into a document.
InsertTextAtSelection Inserts text at the insertion point or selection.
InsertEmbeddedAtSelection Inserts an IDataObject object at the insertion point or selection.
RequestSupportedAttrs Obtains the supported attributes of a document.
RequestAttrsAtPosition Obtains the attributes at the specified application character position.
RequestAttrsTransitioningAtPosition Obtains a list of attributes that begin or end at the specified application character position.
FindNextAttrTransition Determines the character position where an attribute transition occurs.
RetrieveRequestedAttrs Returns the attributes obtained by the ITextStoreACP::RequestAttrsAtPosition, TextStoreACP::RequestAttrsTransitioningAtPosition, or the ITextStoreACP::RequestSupportedAttrs methods.
GetEndACP Returns the number of characters in a document.
GetActiveView Returns a TsViewCookie data type that specifies the current active view.
GetACPFromPoint Converts a point in screen coordinates to an application character position.
GetTextExt Returns the bounding box, in screen coordinates, of the text at a specified character position.
GetScreenExt Returns the bounding box, in screen coordinates, of the display surface where the text stream is rendered.
GetWnd Returns the handle to a window that corresponds to the current document.

Example Code [C++]

The following code example demonstrates how to create a CTSFEditWnd class that implements the ITextStoreACP methods:
class CTSFEditWnd : public ITextStoreACP
{
public:
    CTSFEditWnd(HINSTANCE hInstance, HWND hwndParent);
    ~CTSFEditWnd();
   
    //IUnknown methods.
    STDMETHOD (QueryInterface)(REFIID, LPVOID*);
    STDMETHOD_ (DWORD, AddRef)();
    STDMETHOD_ (DWORD, Release)();
   
    //ITextStoreACP methods.
    STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD dwMask);
    STDMETHODIMP UnadviseSink(IUnknown *punk);
    STDMETHODIMP RequestLock(DWORD dwLockFlags, HRESULT *phrSession);
    STDMETHODIMP GetStatus(TS_STATUS *pdcs);
    STDMETHODIMP QueryInsert(LONG acpTestStart, LONG acpTestEnd, ULONG cch, LONG *pacpResultStart, LONG *pacpResultEnd);
    STDMETHODIMP GetSelection(ULONG ulIndex, ULONG ulCount, TS_SELECTION_ACP *pSelection, ULONG *pcFetched);
    STDMETHODIMP SetSelection(ULONG ulCount, const TS_SELECTION_ACP *pSelection);
    STDMETHODIMP GetText(LONG acpStart, LONG acpEnd, WCHAR *pchPlain, ULONG cchPlainReq, ULONG *pcchPlainOut, TS_RUNINFO *prgRunInfo, ULONG ulRunInfoReq, ULONG *pulRunInfoOut, LONG *pacpNext);
    STDMETHODIMP SetText(DWORD dwFlags, LONG acpStart, LONG acpEnd, const WCHAR *pchText, ULONG cch, TS_TEXTCHANGE *pChange);
    STDMETHODIMP GetFormattedText(LONG acpStart, LONG acpEnd, IDataObject **ppDataObject);
    STDMETHODIMP GetEmbedded(LONG acpPos, REFGUID rguidService, REFIID riid, IUnknown **ppunk);
    STDMETHODIMP QueryInsertEmbedded(const GUID *pguidService, const FORMATETC *pFormatEtc, BOOL *pfInsertable);
    STDMETHODIMP InsertEmbedded(DWORD dwFlags, LONG acpStart, LONG acpEnd, IDataObject *pDataObject, TS_TEXTCHANGE *pChange);
    STDMETHODIMP RequestSupportedAttrs(DWORD dwFlags, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs);
    STDMETHODIMP RequestAttrsAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
    STDMETHODIMP RequestAttrsTransitioningAtPosition(LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags);
    STDMETHODIMP FindNextAttrTransition(LONG acpStart, LONG acpHalt, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs, DWORD dwFlags, LONG *pacpNext, BOOL *pfFound, LONG *plFoundOffset);
    STDMETHODIMP RetrieveRequestedAttrs(ULONG ulCount, TS_ATTRVAL *paAttrVals, ULONG *pcFetched);
    STDMETHODIMP GetEndACP(LONG *pacp);
    STDMETHODIMP GetActiveView(TsViewCookie *pvcView);
    STDMETHODIMP GetACPFromPoint(TsViewCookie vcView, const POINT *pt, DWORD dwFlags, LONG *pacp);
    STDMETHODIMP GetTextExt(TsViewCookie vcView, LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped);
    STDMETHODIMP GetScreenExt(TsViewCookie vcView, RECT *prc);
    STDMETHODIMP GetWnd(TsViewCookie vcView, HWND *phwnd);
    STDMETHODIMP InsertTextAtSelection(DWORD dwFlags, const WCHAR *pchText, ULONG cch, LONG *pacpStart, LONG *pacpEnd, TS_TEXTCHANGE *pChange);
    STDMETHODIMP InsertEmbeddedAtSelection(DWORD dwFlags, IDataObject *pDataObject, LONG *pacpStart, LONG *pacpEnd, TS_TEXTCHANGE *pChange);
};
This interface can be obtained using the following procedure.
HRESULT hr;
ITextStoreACP *ptsiACP;
hr = punk->QueryInterface(IID_ITextStoreACP, (void **)&ptsiACP);

Requirements

Windows NT/2000/XP: Included in Windows XP.
Redistributable: Requires TSF 1.0 on Windows NT 4.0; Windows 2000; and Windows 98/Me.
Header: Declared in Textstor.idl and Textstor.h.
Library: Included as a resource in Msctf.dll.

See Also

Text Stores

Page view tracker