BumpCurArt Script

Build 1501 on 14/Nov/2017  This topic last edited on: 9/May/2012, at 13:02

Description

Moves all the shapes of the current article to the pasteboard and recreates the empty objects on the current position.

Used to replace current article with another article, keeping shapes.

Syntax

BumpCurArt

Example

If res = 2 Then BumpCurArt() : LinkDroppedArticle(selectedobject)

Code

Public Sub BumpCurArt()

    ' moves all the shapes of the current article to the pasteboard and recreated (imperfectly) the empty objects on the current position

    ' v2: ungroups temporarily if grouped

    ' it assumes that all objects linked to the current article are selected

    If Not Page.HasSelection Then Return

    Using New WinUI.Controls.BusyCursor

      FredApp.DisableDraw = True

      Dim bWasGrouped As Boolean = False

      If Page.ObjTestGrouped Then

        Page.ObjUngroupEx(False)

        bWasGrouped = True

      End If

      Dim ao = PushSelectionEx(False)  ' store selection in the array

      If bWasGrouped Then Page.ObjGroup()

      Dim ao1 = ao

      ' move object out

      ObjMoveTo(ao(0, 11) + Page.GetPageWidth, Page.GetSelectionY)

      ' recreate geometry

      For t = 1 To ao(0, 0)

        Select Case ao(t, 6)

          Case POK.oFrame

            Page.AddFrameEx(ao(t, 1), ao(t, 2), ao(t, 3), ao(t, 4), ao(t, 5))

            Page.ObjSetTypeName(ao(t, 41))

            ' missing color

          Case POK.oBitmap

            Page.AddImageEx(ao(t, 1), ao(t, 2), ao(t, 3), ao(t, 4), ao(t, 5), 0, 0, 0, 0, 0, "")

            Page.ObjSetTypeName(ao(t, 41))

          Case POK.oRule

            Page.AddHRuleEx(ao(t, 1), ao(t, 2), ao(t, 3), ao(t, 5))

            ' missing color

          Case POK.oBox

            Page.AddBoxEx(ao(t, 1), ao(t, 2), ao(t, 3), ao(t, 4), ao(t, 5))

            ' missing color

          Case POK.oElli

            Page.AddElliEx(ao(t, 1), ao(t, 2), ao(t, 3), ao(t, 4), ao(t, 5))

            ' missing color

        End Select

        Page.ObjSetZOrder(ao(t, 7))

        ao(t, 0) = Page.GetSelectedId

      Next

      PopSelection(ao)

      FredApp.DisableDraw = False

    End Using

  End Sub