Ejemplo n.º 1
0
 /// <summary>
 /// Get main TextSegment
 /// </summary>
 /// <param name="nmSegment">
 /// OUT: name of the main text segment for this section
 /// </param>
 internal void GetMainTextSegment(
     out IntPtr nmSegment)
 {
     if (_mainTextSegment == null)
     {
         // Create the main text segment
         _mainTextSegment = new ContainerParagraph(Element, _structuralCache);
     }
     nmSegment = _mainTextSegment.Handle;
 }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------
        //
        //  PTS callbacks
        //
        //-------------------------------------------------------------------

        #region PTS callbacks

        //-------------------------------------------------------------------
        // GetParaProperties
        //-------------------------------------------------------------------
        internal override void GetParaProperties(
            ref PTS.FSPAP fspap)                // OUT: paragraph properties
        {
            GetParaProperties(ref fspap, false);
            fspap.idobj = PtsHost.SubpageParagraphId;
            // Create the main text segment
            if (_mainTextSegment == null)
            {
                _mainTextSegment = new ContainerParagraph(_element, _structuralCache);
            }
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------
        //
        //  PTS callbacks
        //
        //-------------------------------------------------------------------

        #region PTS callbacks

        //-------------------------------------------------------------------
        // CreateParaclient
        //-------------------------------------------------------------------
        internal override void CreateParaclient(
            out IntPtr paraClientHandle)        // OUT: opaque to PTS paragraph client
        {
#pragma warning disable 6518
            // Disable PRESharp warning 6518. FloaterParaClient is an UnmamangedHandle, that adds itself
            // to HandleMapper that holds a reference to it. PTS manages lifetime of this object, and
            // calls DestroyParaclient to get rid of it. DestroyParaclient will call Dispose() on the object
            // and remove it from HandleMapper.
            FloaterParaClient paraClient = new FloaterParaClient(this);
            paraClientHandle = paraClient.Handle;
#pragma warning restore 6518

            // Create the main text segment
            if (_mainTextSegment == null)
            {
                _mainTextSegment = new ContainerParagraph(Element, StructuralCache);
            }
        }
 /// <summary>
 /// Constructor. 
 /// </summary>
 /// <param name="paragraph">
 /// Paragraph associated with this object.
 /// </param>
 internal ContainerParaClient(ContainerParagraph paragraph) : base(paragraph)
 {
 }
        //-------------------------------------------------------------------
        // GetParaProperties
        //-------------------------------------------------------------------
        internal override void CreateParaclient(
            out IntPtr paraClientHandle)        // OUT: opaque to PTS paragraph client
        {
#pragma warning disable 6518
            // Disable PRESharp warning 6518. FigureParaClient is an UnmamangedHandle, that adds itself
            // to HandleMapper that holds a reference to it. PTS manages lifetime of this object, and 
            // calls DestroyParaclient to get rid of it. DestroyParaclient will call Dispose() on the object
            // and remove it from HandleMapper.
            FigureParaClient paraClient =  new FigureParaClient(this);
            paraClientHandle = paraClient.Handle;
#pragma warning restore 6518

            // Create the main text segment
            if (_mainTextSegment == null)
            {
                _mainTextSegment = new ContainerParagraph(Element, StructuralCache);
            }
        }
        //-------------------------------------------------------------------
        //
        //  PTS callbacks
        //
        //-------------------------------------------------------------------

        #region PTS callbacks

        //-------------------------------------------------------------------
        // GetParaProperties
        //-------------------------------------------------------------------
        internal override void GetParaProperties(
            ref PTS.FSPAP fspap)                // OUT: paragraph properties
        {
            GetParaProperties(ref fspap, false);
            fspap.idobj = PtsHost.SubpageParagraphId;
            // Create the main text segment
            if (_mainTextSegment == null)
            {
                _mainTextSegment = new ContainerParagraph(_element, _structuralCache);
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="paragraph">
 /// Paragraph associated with this object.
 /// </param>
 internal ContainerParaClient(ContainerParagraph paragraph) : base(paragraph)
 {
 }
        //-------------------------------------------------------------------
        //
        //  Private Methods
        //
        //-------------------------------------------------------------------

        #region Private Methods

        // ------------------------------------------------------------------
        // Determine paragraph type at the current tree position and create it.
        // If going out of scope, return null.
        //
        // Paragraph type is determined using following:
        // (1) if textPointer points to Text, TextParagraph
        // (2) if textPointer points to ElementEnd (end of TextElement):
        //     * if the same as Owner, NULL if fEmptyOk, TextPara otherwise
        // (3) if textPointer points to ElementStart (start of TextElement):
        //     * if block, ContainerParagraph
        //     * if inline, TextParagraph
        // (4) if textPointer points to UIElement:
        //     * if block, UIElementParagraph
        //     * if inline, TextParagraph
        // (5) if textPointer points to TextContainer.End, NULL
        // ------------------------------------------------------------------
        protected virtual BaseParagraph GetParagraph(ITextPointer textPointer, bool fEmptyOk)
        {
            BaseParagraph paragraph = null;

            switch (textPointer.GetPointerContext(LogicalDirection.Forward))
            {
                case TextPointerContext.Text:
                    // Text paragraph

                    // WORKAROUND FOR SCHEMA VALIDATION
                    if(textPointer.TextContainer.Start.CompareTo(textPointer) > 0)
                    {
                        if(!(Element is TextElement) || ((TextElement)Element).ContentStart != textPointer)
                        {
                            throw new InvalidOperationException(SR.Get(SRID.TextSchema_TextIsNotAllowedInThisContext, Element.GetType().Name));
                        }
                    }

                    paragraph = new TextParagraph(Element, StructuralCache);
                    break;

                case TextPointerContext.ElementEnd:
                    // The end of TextElement
                    Invariant.Assert(textPointer is TextPointer);
                    Invariant.Assert(Element == ((TextPointer)textPointer).Parent);

                    if(!fEmptyOk)
                    {
                        paragraph = new TextParagraph(Element, StructuralCache);
                    }
                    break;

                case TextPointerContext.ElementStart:
                    // The beginning of TextElement
                    // * if block, ContainerParagraph
                    // * if inline, TextParagraph
                    Debug.Assert(textPointer is TextPointer);
                    TextElement element = ((TextPointer)textPointer).GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
                    if (element is List)
                    {
                        paragraph = new ListParagraph(element, StructuralCache);
                    }
                    else if (element is Table)
                    {
                        paragraph = new TableParagraph(element, StructuralCache);
                    }
                    else if (element is BlockUIContainer)
                    {
                        paragraph = new UIElementParagraph(element, StructuralCache);
                    }
                    else if (element is Block || element is ListItem)
                    {
                        paragraph = new ContainerParagraph(element, StructuralCache);
                    }
                    else if (element is Inline) // Note this includes AnchoredBlocks - intentionally
                    {
                        paragraph = new TextParagraph(Element, StructuralCache);
                    }
                    else
                    {
                        // The only remaining TextElement classes are: TableRowGroup, TableRow, TableCell
                        // which should never go here.
                        Invariant.Assert(false);
                    }
                    break;

                case TextPointerContext.EmbeddedElement:
                    // Embedded UIElements are always part of TextParagraph.
                    // There is no possibility to make UIElement a block.
                    paragraph = new TextParagraph(Element, StructuralCache);
                    break;

                case TextPointerContext.None:
                    // End of tree case.
                    Invariant.Assert(textPointer.CompareTo(textPointer.TextContainer.End) == 0);

                    if (!fEmptyOk)
                    {
                        paragraph = new TextParagraph(Element, StructuralCache);
                    }
                    break;
            }

            if (paragraph != null)
            {
                StructuralCache.CurrentFormatContext.DependentMax = (TextPointer) textPointer;
            }

            return paragraph;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Get main TextSegment
 /// </summary>
 /// <param name="nmSegment">
 /// OUT: name of the main text segment for this section
 /// </param>
 internal void GetMainTextSegment(
     out IntPtr nmSegment)           
 {
     if (_mainTextSegment == null)
     {
         // Create the main text segment
         _mainTextSegment = new ContainerParagraph(Element, _structuralCache);
     }
     nmSegment = _mainTextSegment.Handle;
 }
        // Token: 0x060067A3 RID: 26531 RVA: 0x001D08E0 File Offset: 0x001CEAE0
        protected virtual BaseParagraph GetParagraph(ITextPointer textPointer, bool fEmptyOk)
        {
            BaseParagraph baseParagraph = null;

            switch (textPointer.GetPointerContext(LogicalDirection.Forward))
            {
            case TextPointerContext.None:
                Invariant.Assert(textPointer.CompareTo(textPointer.TextContainer.End) == 0);
                if (!fEmptyOk)
                {
                    baseParagraph = new TextParagraph(base.Element, base.StructuralCache);
                }
                break;

            case TextPointerContext.Text:
                if (textPointer.TextContainer.Start.CompareTo(textPointer) > 0 && (!(base.Element is TextElement) || ((TextElement)base.Element).ContentStart != textPointer))
                {
                    throw new InvalidOperationException(SR.Get("TextSchema_TextIsNotAllowedInThisContext", new object[]
                    {
                        base.Element.GetType().Name
                    }));
                }
                baseParagraph = new TextParagraph(base.Element, base.StructuralCache);
                break;

            case TextPointerContext.EmbeddedElement:
                baseParagraph = new TextParagraph(base.Element, base.StructuralCache);
                break;

            case TextPointerContext.ElementStart:
            {
                TextElement adjacentElementFromOuterPosition = ((TextPointer)textPointer).GetAdjacentElementFromOuterPosition(LogicalDirection.Forward);
                if (adjacentElementFromOuterPosition is List)
                {
                    baseParagraph = new ListParagraph(adjacentElementFromOuterPosition, base.StructuralCache);
                }
                else if (adjacentElementFromOuterPosition is Table)
                {
                    baseParagraph = new TableParagraph(adjacentElementFromOuterPosition, base.StructuralCache);
                }
                else if (adjacentElementFromOuterPosition is BlockUIContainer)
                {
                    baseParagraph = new UIElementParagraph(adjacentElementFromOuterPosition, base.StructuralCache);
                }
                else if (adjacentElementFromOuterPosition is Block || adjacentElementFromOuterPosition is ListItem)
                {
                    baseParagraph = new ContainerParagraph(adjacentElementFromOuterPosition, base.StructuralCache);
                }
                else if (adjacentElementFromOuterPosition is Inline)
                {
                    baseParagraph = new TextParagraph(base.Element, base.StructuralCache);
                }
                else
                {
                    Invariant.Assert(false);
                }
                break;
            }

            case TextPointerContext.ElementEnd:
                Invariant.Assert(textPointer is TextPointer);
                Invariant.Assert(base.Element == ((TextPointer)textPointer).Parent);
                if (!fEmptyOk)
                {
                    baseParagraph = new TextParagraph(base.Element, base.StructuralCache);
                }
                break;
            }
            if (baseParagraph != null)
            {
                base.StructuralCache.CurrentFormatContext.DependentMax = (TextPointer)textPointer;
            }
            return(baseParagraph);
        }