Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / 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 : [....] 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
- MediaCommands.cs
- DecimalKeyFrameCollection.cs
- XPathEmptyIterator.cs
- SmiTypedGetterSetter.cs
- MemberAccessException.cs
- CodeCommentStatement.cs
- DoubleAnimationUsingKeyFrames.cs
- HitTestParameters.cs
- XmlSchemaSimpleTypeList.cs
- DPAPIProtectedConfigurationProvider.cs
- XmlSchema.cs
- CallbackDebugBehavior.cs
- MappingMetadataHelper.cs
- QueryOptionExpression.cs
- EventLogPermissionEntry.cs
- FormsAuthenticationTicket.cs
- CanExecuteRoutedEventArgs.cs
- StorageComplexTypeMapping.cs
- ModelUtilities.cs
- FactoryMaker.cs
- CodeBinaryOperatorExpression.cs
- XmlCDATASection.cs
- RenderData.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- RegexGroup.cs
- SQLDoubleStorage.cs
- ImageSource.cs
- TrackingAnnotationCollection.cs
- FocusTracker.cs
- Operator.cs
- SqlBulkCopyColumnMappingCollection.cs
- BindingValueChangedEventArgs.cs
- DefinitionUpdate.cs
- ThemeableAttribute.cs
- XmlSerializerAssemblyAttribute.cs
- ServiceSecurityContext.cs
- Stylus.cs
- ConfigurationManagerHelperFactory.cs
- NullableConverter.cs
- EdmToObjectNamespaceMap.cs
- DateTimePickerDesigner.cs
- EntityReference.cs
- RoleManagerSection.cs
- QilXmlWriter.cs
- Viewport3DVisual.cs
- MissingMemberException.cs
- oledbconnectionstring.cs
- InputLanguageCollection.cs
- DataRecordInternal.cs
- ReaderContextStackData.cs
- SetStateDesigner.cs
- XmlWriter.cs
- DerivedKeyCachingSecurityTokenSerializer.cs
- BaseAsyncResult.cs
- TableSectionStyle.cs
- AuthenticationModuleElementCollection.cs
- PanelStyle.cs
- diagnosticsswitches.cs
- HttpRawResponse.cs
- EnterpriseServicesHelper.cs
- ConfigurationException.cs
- COMException.cs
- TreeNodeStyleCollection.cs
- RtfFormatStack.cs
- CacheModeConverter.cs
- Pointer.cs
- MergeFilterQuery.cs
- CompModHelpers.cs
- ColorTransform.cs
- ThreadStartException.cs
- OleDbWrapper.cs
- JavaScriptObjectDeserializer.cs
- UnrecognizedPolicyAssertionElement.cs
- PerformanceCounterCategory.cs
- ComponentResourceKey.cs
- TableLayoutSettingsTypeConverter.cs
- TypefaceMetricsCache.cs
- DelegatingTypeDescriptionProvider.cs
- ChangeNode.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- Padding.cs
- DataList.cs
- UnsafeNativeMethodsTablet.cs
- TreeNodeBinding.cs
- XmlDataImplementation.cs
- KeyEvent.cs
- SqlFactory.cs
- SoapExtensionTypeElementCollection.cs
- RadioButton.cs
- TypeDependencyAttribute.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- FormClosedEvent.cs
- SystemIcmpV4Statistics.cs
- DiscreteKeyFrames.cs
- CacheForPrimitiveTypes.cs
- Journaling.cs
- RemotingException.cs
- AnimationStorage.cs
- WebProxyScriptElement.cs
- CardSpaceShim.cs