Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Input / DefaultTextStoreTextComposition.cs / 1 / DefaultTextStoreTextComposition.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: DefaultTextStoreTextComposition class is the composition
// object for the input in DefaultTextStore.
// Cicero's composition injected to DefaulteTextStore is
// represent by this DefaultTextStoreTextComposition.
// This has custom Complete method to control
// Cicero's composiiton.
//
// History:
// 04/01/2004 : yutakas created
//
//---------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Threading;
using System.Windows;
using System.Security;
using MS.Win32;
namespace System.Windows.Input
{
///
/// DefaultTextStoreTextComposition class implements Complete for
/// the composition in DefaultTextStore.
///
internal class DefaultTextStoreTextComposition : TextComposition
{
//-----------------------------------------------------
//
// ctor
//
//-----------------------------------------------------
///
/// ctor
///
///
/// Critical - calls base ctor - which in turn stores the inputmanager that's critical.
///
[SecurityCritical]
internal DefaultTextStoreTextComposition(InputManager inputManager, IInputElement source, string text, TextCompositionAutoComplete autoComplete) : base(inputManager, source, text, autoComplete)
{
}
//------------------------------------------------------
//
// Public Interface Methods
//
//-----------------------------------------------------
///
/// Finalize the composition.
/// This does not call base.Complete() because TextComposition.Complete()
/// will call TextServicesManager.CompleteComposition() directly to generate TextCompositionEvent.
/// We finalize Cicero's composition and DefaultTextStore will automatically
/// generate the proper TextComposition events.
///
///
/// Critical: This completes the composition and in doing so calls GetTransitionaryContext which gives it ITfContext
/// TreatAsSafe: The context is not exposed, neither are the other members
///
[SecurityCritical,SecurityTreatAsSafe]
public override void Complete()
{
// VerifyAccess();
UnsafeNativeMethods.ITfContext context = GetTransitoryContext();
UnsafeNativeMethods.ITfContextOwnerCompositionServices compositionService = context as UnsafeNativeMethods.ITfContextOwnerCompositionServices;
UnsafeNativeMethods.ITfCompositionView composition = GetComposition(context);
if (composition != null)
{
// Terminate composition if there is a composition view.
compositionService.TerminateComposition(composition);
Marshal.ReleaseComObject(composition);
}
Marshal.ReleaseComObject(context);
}
//------------------------------------------------------
//
// private Methods
//
//------------------------------------------------------
///
/// Get the base ITfContext of the transitory document.
///
///
/// Critical: This exposes ITfContext which has unsecure methods
///
[SecurityCritical]
private UnsafeNativeMethods.ITfContext GetTransitoryContext()
{
DefaultTextStore defaultTextStore = DefaultTextStore.Current;
UnsafeNativeMethods.ITfDocumentMgr doc = defaultTextStore.TransitoryDocumentManager;
UnsafeNativeMethods.ITfContext context;
doc.GetBase(out context);
Marshal.ReleaseComObject(doc);
return context;
}
///
/// Get ITfContextView of the context.
///
///
/// Critical: calls Marshal.ReleaseComObject which has a LinkDemand
/// TreatAsSafe: can't pass in arbitrary COM object to release
///
[SecurityCritical, SecurityTreatAsSafe]
private UnsafeNativeMethods.ITfCompositionView GetComposition(UnsafeNativeMethods.ITfContext context)
{
UnsafeNativeMethods.ITfContextComposition contextComposition;
UnsafeNativeMethods.IEnumITfCompositionView enumCompositionView;
UnsafeNativeMethods.ITfCompositionView[] compositionViews = new UnsafeNativeMethods.ITfCompositionView[1];
int fetched;
contextComposition = (UnsafeNativeMethods.ITfContextComposition)context;
contextComposition.EnumCompositions(out enumCompositionView);
enumCompositionView.Next(1, compositionViews, out fetched);
Marshal.ReleaseComObject(enumCompositionView);
return compositionViews[0];
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: DefaultTextStoreTextComposition class is the composition
// object for the input in DefaultTextStore.
// Cicero's composition injected to DefaulteTextStore is
// represent by this DefaultTextStoreTextComposition.
// This has custom Complete method to control
// Cicero's composiiton.
//
// History:
// 04/01/2004 : yutakas created
//
//---------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Threading;
using System.Windows;
using System.Security;
using MS.Win32;
namespace System.Windows.Input
{
///
/// DefaultTextStoreTextComposition class implements Complete for
/// the composition in DefaultTextStore.
///
internal class DefaultTextStoreTextComposition : TextComposition
{
//-----------------------------------------------------
//
// ctor
//
//-----------------------------------------------------
///
/// ctor
///
///
/// Critical - calls base ctor - which in turn stores the inputmanager that's critical.
///
[SecurityCritical]
internal DefaultTextStoreTextComposition(InputManager inputManager, IInputElement source, string text, TextCompositionAutoComplete autoComplete) : base(inputManager, source, text, autoComplete)
{
}
//------------------------------------------------------
//
// Public Interface Methods
//
//-----------------------------------------------------
///
/// Finalize the composition.
/// This does not call base.Complete() because TextComposition.Complete()
/// will call TextServicesManager.CompleteComposition() directly to generate TextCompositionEvent.
/// We finalize Cicero's composition and DefaultTextStore will automatically
/// generate the proper TextComposition events.
///
///
/// Critical: This completes the composition and in doing so calls GetTransitionaryContext which gives it ITfContext
/// TreatAsSafe: The context is not exposed, neither are the other members
///
[SecurityCritical,SecurityTreatAsSafe]
public override void Complete()
{
// VerifyAccess();
UnsafeNativeMethods.ITfContext context = GetTransitoryContext();
UnsafeNativeMethods.ITfContextOwnerCompositionServices compositionService = context as UnsafeNativeMethods.ITfContextOwnerCompositionServices;
UnsafeNativeMethods.ITfCompositionView composition = GetComposition(context);
if (composition != null)
{
// Terminate composition if there is a composition view.
compositionService.TerminateComposition(composition);
Marshal.ReleaseComObject(composition);
}
Marshal.ReleaseComObject(context);
}
//------------------------------------------------------
//
// private Methods
//
//------------------------------------------------------
///
/// Get the base ITfContext of the transitory document.
///
///
/// Critical: This exposes ITfContext which has unsecure methods
///
[SecurityCritical]
private UnsafeNativeMethods.ITfContext GetTransitoryContext()
{
DefaultTextStore defaultTextStore = DefaultTextStore.Current;
UnsafeNativeMethods.ITfDocumentMgr doc = defaultTextStore.TransitoryDocumentManager;
UnsafeNativeMethods.ITfContext context;
doc.GetBase(out context);
Marshal.ReleaseComObject(doc);
return context;
}
///
/// Get ITfContextView of the context.
///
///
/// Critical: calls Marshal.ReleaseComObject which has a LinkDemand
/// TreatAsSafe: can't pass in arbitrary COM object to release
///
[SecurityCritical, SecurityTreatAsSafe]
private UnsafeNativeMethods.ITfCompositionView GetComposition(UnsafeNativeMethods.ITfContext context)
{
UnsafeNativeMethods.ITfContextComposition contextComposition;
UnsafeNativeMethods.IEnumITfCompositionView enumCompositionView;
UnsafeNativeMethods.ITfCompositionView[] compositionViews = new UnsafeNativeMethods.ITfCompositionView[1];
int fetched;
contextComposition = (UnsafeNativeMethods.ITfContextComposition)context;
contextComposition.EnumCompositions(out enumCompositionView);
enumCompositionView.Next(1, compositionViews, out fetched);
Marshal.ReleaseComObject(enumCompositionView);
return compositionViews[0];
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MouseGestureConverter.cs
- DataSetUtil.cs
- ToolStripSplitButton.cs
- ReadOnlyObservableCollection.cs
- Shared.cs
- SettingsPropertyCollection.cs
- ZipIOCentralDirectoryFileHeader.cs
- MasterPageBuildProvider.cs
- TrackingValidationObjectDictionary.cs
- COM2ExtendedBrowsingHandler.cs
- DataServiceExpressionVisitor.cs
- DataGridColumn.cs
- DetailsViewRow.cs
- ProcessMonitor.cs
- ColorTransformHelper.cs
- ListViewGroup.cs
- SizeAnimation.cs
- ColorMap.cs
- PropertyEmitter.cs
- SqlUnionizer.cs
- ExpanderAutomationPeer.cs
- ScriptRegistrationManager.cs
- SafeNativeMethodsMilCoreApi.cs
- GridViewRow.cs
- DataRelation.cs
- SynchronizedInputProviderWrapper.cs
- HitTestDrawingContextWalker.cs
- CultureInfo.cs
- DataSourceHelper.cs
- ControlBuilder.cs
- DataColumnChangeEvent.cs
- QilFunction.cs
- OutKeywords.cs
- PhysicalFontFamily.cs
- ExpressionValueEditor.cs
- XmlEncodedRawTextWriter.cs
- FlowDocumentPageViewerAutomationPeer.cs
- SplitContainer.cs
- BypassElementCollection.cs
- LinqDataSourceValidationException.cs
- InsufficientMemoryException.cs
- WebScriptEndpoint.cs
- FormsAuthentication.cs
- AssociationSetEnd.cs
- OciEnlistContext.cs
- LinqDataSource.cs
- SByteConverter.cs
- input.cs
- CheckableControlBaseAdapter.cs
- TextTrailingCharacterEllipsis.cs
- PropertyEmitter.cs
- ScrollableControl.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- EventManager.cs
- CssClassPropertyAttribute.cs
- WebPartDisplayModeCancelEventArgs.cs
- Path.cs
- RtfToXamlReader.cs
- LocatorPart.cs
- OptionalColumn.cs
- RtType.cs
- QueryHandler.cs
- KeyConverter.cs
- ContextDataSourceView.cs
- IndentedWriter.cs
- PointAnimation.cs
- ConnectorDragDropGlyph.cs
- EdmItemCollection.cs
- RichTextBoxDesigner.cs
- CustomSignedXml.cs
- PopupEventArgs.cs
- PropertyDescriptorCollection.cs
- BooleanAnimationUsingKeyFrames.cs
- SimplePropertyEntry.cs
- StateRuntime.cs
- ContentElement.cs
- TextServicesManager.cs
- BuildManager.cs
- HtmlSelect.cs
- CalendarItem.cs
- MeasurementDCInfo.cs
- XmlSchemaDatatype.cs
- SettingsAttributes.cs
- PartialList.cs
- ParameterReplacerVisitor.cs
- OleDbException.cs
- FileSystemWatcher.cs
- CapabilitiesAssignment.cs
- GeneralTransformCollection.cs
- BinaryObjectReader.cs
- CatalogPartChrome.cs
- DynamicPropertyHolder.cs
- ZeroOpNode.cs
- ChannelBuilder.cs
- XMLSchema.cs
- MemberProjectedSlot.cs
- RequestBringIntoViewEventArgs.cs
- SpecialFolderEnumConverter.cs
- __ConsoleStream.cs
- ClientSideProviderDescription.cs