Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / textformatting / TextLineBreak.cs / 1 / TextLineBreak.cs
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation
//
// File: TextLineBreak.cs
//
// Contents: Text properties and state at the point where text is broken
// by the line breaking process, which may need to be carried over
// when formatting the next line.
//
// Spec: http://team/sites/Avalon/Specs/Text%20Formatting%20API.doc
//
// Created: 12-5-2004 Niklas Borson (niklasb)
//
//-----------------------------------------------------------------------
using System;
using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using MS.Internal;
using MS.Internal.TextFormatting;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.TextFormatting
{
///
/// Text properties and state at the point where text is broken
/// by the line breaking process.
///
public sealed class TextLineBreak : IDisposable
{
private TextModifierScope _currentScope;
private SecurityCriticalDataForSet _breakRecord;
#region Constructors
///
/// Internallly construct the line break
///
internal TextLineBreak(
TextModifierScope currentScope,
SecurityCriticalDataForSet breakRecord
)
{
_currentScope = currentScope;
_breakRecord = breakRecord;
if (breakRecord.Value == IntPtr.Zero)
{
// this object does not hold unmanaged resource,
// remove it from the finalizer queue.
GC.SuppressFinalize(this);
}
}
#endregion
///
/// Finalize the line break
///
~TextLineBreak()
{
DisposeInternal(true);
}
///
/// Dispose the line break
///
public void Dispose()
{
DisposeInternal(false);
GC.SuppressFinalize(this);
}
///
/// Clone a new instance of TextLineBreak
///
///
/// Critical - as this calls unmanaged API LoCloneBreakRecord.
/// PublicOK - as it takes no parameter and retain no additional unmanaged resource.
///
[SecurityCritical]
public TextLineBreak Clone()
{
IntPtr pbreakrec = IntPtr.Zero;
if (_breakRecord.Value != IntPtr.Zero)
{
LsErr lserr = UnsafeNativeMethods.LoCloneBreakRecord(_breakRecord.Value, out pbreakrec);
if (lserr != LsErr.None)
{
TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.CloneBreakRecordFailure, lserr), lserr);
}
}
return new TextLineBreak(_currentScope, new SecurityCriticalDataForSet(pbreakrec));
}
///
/// Destroy LS unmanaged break records object inside the line break
/// managed object. The parameter flag indicates whether the call is
/// from finalizer thread or the main UI thread.
///
///
/// Critical - as this calls the setter of _breakRecord.Value which is type SecurityCriticalDataForSet.
/// _breakRecord is the value received from call to LoCreateBreaks and being passed back in
/// when building the next break. No code should have access to set it otherwise.
/// Safe - as this does not take any parameter that it passes directly to the critical function.
///
[SecurityCritical, SecurityTreatAsSafe]
private void DisposeInternal(bool finalizing)
{
if (_breakRecord.Value != IntPtr.Zero)
{
UnsafeNativeMethods.LoDisposeBreakRecord(_breakRecord.Value, finalizing);
_breakRecord.Value = IntPtr.Zero;
GC.KeepAlive(this);
}
}
///
/// Current text modifier scope, which can be null.
///
internal TextModifierScope TextModifierScope
{
get { return _currentScope; }
}
///
/// Unmanaged pointer to LS break records structure
///
internal SecurityCriticalDataForSet BreakRecord
{
get { return _breakRecord; }
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------
//
// Microsoft Windows Client Platform
// Copyright (C) Microsoft Corporation
//
// File: TextLineBreak.cs
//
// Contents: Text properties and state at the point where text is broken
// by the line breaking process, which may need to be carried over
// when formatting the next line.
//
// Spec: http://team/sites/Avalon/Specs/Text%20Formatting%20API.doc
//
// Created: 12-5-2004 Niklas Borson (niklasb)
//
//-----------------------------------------------------------------------
using System;
using System.Security;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using MS.Internal;
using MS.Internal.TextFormatting;
using SR = MS.Internal.PresentationCore.SR;
using SRID = MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.TextFormatting
{
///
/// Text properties and state at the point where text is broken
/// by the line breaking process.
///
public sealed class TextLineBreak : IDisposable
{
private TextModifierScope _currentScope;
private SecurityCriticalDataForSet _breakRecord;
#region Constructors
///
/// Internallly construct the line break
///
internal TextLineBreak(
TextModifierScope currentScope,
SecurityCriticalDataForSet breakRecord
)
{
_currentScope = currentScope;
_breakRecord = breakRecord;
if (breakRecord.Value == IntPtr.Zero)
{
// this object does not hold unmanaged resource,
// remove it from the finalizer queue.
GC.SuppressFinalize(this);
}
}
#endregion
///
/// Finalize the line break
///
~TextLineBreak()
{
DisposeInternal(true);
}
///
/// Dispose the line break
///
public void Dispose()
{
DisposeInternal(false);
GC.SuppressFinalize(this);
}
///
/// Clone a new instance of TextLineBreak
///
///
/// Critical - as this calls unmanaged API LoCloneBreakRecord.
/// PublicOK - as it takes no parameter and retain no additional unmanaged resource.
///
[SecurityCritical]
public TextLineBreak Clone()
{
IntPtr pbreakrec = IntPtr.Zero;
if (_breakRecord.Value != IntPtr.Zero)
{
LsErr lserr = UnsafeNativeMethods.LoCloneBreakRecord(_breakRecord.Value, out pbreakrec);
if (lserr != LsErr.None)
{
TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.CloneBreakRecordFailure, lserr), lserr);
}
}
return new TextLineBreak(_currentScope, new SecurityCriticalDataForSet(pbreakrec));
}
///
/// Destroy LS unmanaged break records object inside the line break
/// managed object. The parameter flag indicates whether the call is
/// from finalizer thread or the main UI thread.
///
///
/// Critical - as this calls the setter of _breakRecord.Value which is type SecurityCriticalDataForSet.
/// _breakRecord is the value received from call to LoCreateBreaks and being passed back in
/// when building the next break. No code should have access to set it otherwise.
/// Safe - as this does not take any parameter that it passes directly to the critical function.
///
[SecurityCritical, SecurityTreatAsSafe]
private void DisposeInternal(bool finalizing)
{
if (_breakRecord.Value != IntPtr.Zero)
{
UnsafeNativeMethods.LoDisposeBreakRecord(_breakRecord.Value, finalizing);
_breakRecord.Value = IntPtr.Zero;
GC.KeepAlive(this);
}
}
///
/// Current text modifier scope, which can be null.
///
internal TextModifierScope TextModifierScope
{
get { return _currentScope; }
}
///
/// Unmanaged pointer to LS break records structure
///
internal SecurityCriticalDataForSet BreakRecord
{
get { return _breakRecord; }
}
}
}
// 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
- SerializableAttribute.cs
- ExpandCollapsePattern.cs
- CircleHotSpot.cs
- ObsoleteAttribute.cs
- TextMessageEncoder.cs
- PageParserFilter.cs
- ExpressionConverter.cs
- UIAgentRequest.cs
- DBConnection.cs
- LinqDataSourceStatusEventArgs.cs
- SiteMapNode.cs
- Matrix.cs
- StrokeNodeOperations.cs
- AbstractExpressions.cs
- TransformerTypeCollection.cs
- TextElement.cs
- WebPartManager.cs
- OptimalTextSource.cs
- ObjectViewListener.cs
- GridPatternIdentifiers.cs
- IDQuery.cs
- StrokeDescriptor.cs
- BaseValidatorDesigner.cs
- coordinator.cs
- ClockGroup.cs
- MsmqHostedTransportManager.cs
- MultiplexingFormatMapping.cs
- NodeFunctions.cs
- ErrorWebPart.cs
- ListParaClient.cs
- Stream.cs
- EngineSite.cs
- PermissionToken.cs
- PropertyReferenceExtension.cs
- DefaultExpressionVisitor.cs
- SapiRecoContext.cs
- DataKey.cs
- CodeCompiler.cs
- GregorianCalendar.cs
- ToolStripRenderEventArgs.cs
- ReadOnlyHierarchicalDataSource.cs
- RawAppCommandInputReport.cs
- ValueProviderWrapper.cs
- XmlAttributeAttribute.cs
- ListViewHitTestInfo.cs
- OutputCacheModule.cs
- ExpressionList.cs
- SetStoryboardSpeedRatio.cs
- RoutedUICommand.cs
- BaseAutoFormat.cs
- Type.cs
- UpdateCompiler.cs
- Mappings.cs
- ParameterBuilder.cs
- ScrollProviderWrapper.cs
- ArithmeticException.cs
- ScriptReferenceEventArgs.cs
- Substitution.cs
- StructuredType.cs
- DataGridViewTopLeftHeaderCell.cs
- ViewRendering.cs
- ProfilePropertySettings.cs
- AngleUtil.cs
- AuthorizationContext.cs
- Stopwatch.cs
- ConstantCheck.cs
- SecurityKeyIdentifier.cs
- SortKey.cs
- QuaternionRotation3D.cs
- DrawingServices.cs
- EntityDataSourceChangedEventArgs.cs
- DateTimeFormat.cs
- TrackBar.cs
- BitmapVisualManager.cs
- Int32RectValueSerializer.cs
- CompositeDataBoundControl.cs
- Calendar.cs
- ToolStripSeparator.cs
- BrowserTree.cs
- CommandHelpers.cs
- ObjectDataSourceMethodEditor.cs
- XmlnsPrefixAttribute.cs
- CriticalHandle.cs
- IConvertible.cs
- DataGridColumnStyleMappingNameEditor.cs
- ConnectionInterfaceCollection.cs
- DataListItemEventArgs.cs
- TableRowGroup.cs
- ArgumentOutOfRangeException.cs
- HandledEventArgs.cs
- BitmapSizeOptions.cs
- DataShape.cs
- ZoomPercentageConverter.cs
- AxWrapperGen.cs
- CallbackDebugBehavior.cs
- Rules.cs
- MeshGeometry3D.cs
- LabelEditEvent.cs
- PartialList.cs
- LogicalExpressionTypeConverter.cs