Since 1.5.1688, the image duplicates control is performed automatically when dragging a image on a page of an edition: if the wire image already appears on some pages of the current edition, the list of all pages (up to specified maximum number of pages) is shown as below:
Click Yes to place another copy of the image in the same edition, or click No to abort placing.
Note: this check does not include other editions, but just the current one.
In Ted.VB, UtilsBase class, there's a new function: " <summary>Check if an image is used in an edition</summary> " <param name="ImageId">The image id</param> " <param name="EditionIds">The list of edition ids</param> " <param name="pages">"x"; "0" (return all pages list), "x" = return first x pages) - updates to list of "x" pages where the imageid is used</param> " <returns>True if the image is used in the edition, false otherwise</returns>
Public Shared Function IsImageUsedInEdition(ImageId As Integer, ByVal EditionIds As IList(Of Integer), ByRef pages As String) As Boolean 'v2 on 10/Jan/13 by BS 'example: utilbase.IsImageUsedInEdition(21345, new integer() {55535}, pages) Dim nPages As Integer = 0 Dim iPages As Integer = 0 If IsNumeric(pages) Then ' we want list of first 'pages' nPages = CInt(pages) End If pages = ""
Dim login As ILogin = Editorial.EditorialLogin.GetLogin() ' load the dests of the wire image to see if it has already been cropped Dim obj As IList(Of GenericAccessObj) = login.GetAccessObjs(New Integer() {ImageId}, New ObjLoadDesc(ObjLoadMode.None, ObjLoadExtra.Dests)) If Not obj Is Nothing Then Dim dests As ObjCopyActions = CType(obj(0).GetExtra(ObjLoadExtra.Dests), ObjCopyActions) If Not dests Is Nothing Then ' for each created img load it and check if it is linked to the specified edition ' note: if the same image has been cropped many times, dests.count will be number of those crops, and dest.objectid will be the same Dim bIsFirst As Boolean = True Dim iOldId = 0 For Each dest As ObjCopyAction In dests If dest.ObjectId > 0 Then ' this is because archived images may have dests that have been deleted - to id is expected to be 0 Dim objs As IList(Of GenericAccessObj) = login.GetAccessObjs(New Integer() {dest.ObjectId}, New ObjLoadDesc(New String() {"pageLayers"}, ObjLoadExtra.None)) If Not objs Is Nothing Then Try Dim img As imgObj = New imgObj(objs(0)) If Not img.pageLayersAttr Is Nothing Then For Each entry As linkObjectObj.pageLayersEntry In img.pageLayersAttr If EditionIds.Contains(entry.editionRefAttr) = True Then If InStr(pages, entry.descriptionAttr) = 0 Then iPages += 1 End If If nPages = 0 Then ' we want all pages If InStr(pages, entry.descriptionAttr) = 0 Then pages = pages & entry.descriptionAttr & vbCrLf End If Else If iPages <= nPages Then If InStr(pages, entry.descriptionAttr) = 0 Then pages = pages & entry.descriptionAttr & vbCrLf End If Else If pages <> "" Then Return True End If End If
End If Next End If Catch End Try End If End If
Next End If End If If pages <> "" Then Return True Else Return False End If End Function
Moreover, in Ted.vb, EdConfig class, there's this new function: Public Shared ReadOnly Property glbMaxLinkedPages As String ' 10/Jan/13 (BS); max number of pages returned in a string by IsImageUsedInEdition Get Return GetDef("glbMaxLinkedPages", "10") End Get End Property
This allows to define the maximum number of pages that are listed (to avoid to get a list of 100+ pages). The default value, if no override is specified in the EditorialConfig is 10 pages, otherwise, the specified value is used. The syntax for the EditorialConfig line is usual: <Item Name="glbMaxLinkedPages " Value="3" />
The "0" value is a special one: it will list all the pages. Be aware that high number of pages can clutter the screen message. In OnDrop in Page.vb there are two places where the call appears:
If selectedObject.IsKindOf("image") Then If iKeyPressed = 3 Then ' shift+CTRL places image with no cropping (added by BS on 9/May/2012) 'Check if an image is used in an edition (added by BS and VV on 10/Jan/13) Dim pages As String = EdConfig.glbMaxLinkedPages If UtilsBase.IsImageUsedInEdition(selectedObject.Id, New Integer() {Page.GetPageEditionId}, pages) = True Then Dim hasBusyCursor As Boolean = False If Not bc Is Nothing Then hasBusyCursor = True bc.Dispose() bc = Nothing End If Dim e As MsgBoxResult = MsgBox(String.Format(My.Resources.IDS_IsImageUsedInEdition, pages, EdConfig.glbMaxLinkedPages), MsgBoxStyle.YesNo, m_Label) If e = MsgBoxResult.No Then If Not bc Is Nothing Then bc.Dispose() bc = Nothing End If Return effects <> DragDropEffects.None End If If hasBusyCursor Then bc = New WinUI.Controls.BusyCursor End If End If
objectId = AddInUtils.AssetToEditorial(selectedObject.Id) ' convert image to img If objectId = DBDesc.InvalidId Then Continue For ' return on top if convert failed …. Else 'check the mimetype to skip the pdf object Dim objAttributes As IGenericAttrObj = UtilsBase.GetAttributes(selectedObject.Id) If objAttributes.Data.Mime.StartsWith("image") _ And Not objAttributes.Data.Mime.Contains("pdf") Then
'Check if an image is used in an edition (added by BS and VV on 10/Jan/13) Dim pages As String = EdConfig.glbMaxLinkedPages If UtilsBase.IsImageUsedInEdition(selectedObject.Id, New Integer() {Page.GetPageEditionId}, pages) = True Then If Not bc Is Nothing Then bc.Dispose() bc = Nothing End If Dim e As MsgBoxResult = MsgBox(String.Format(My.Resources.IDS_IsImageUsedInEdition, pages, EdConfig.glbMaxLinkedPages), MsgBoxStyle.YesNo, m_Label) If e = MsgBoxResult.No Then If Not bc Is Nothing Then bc.Dispose() bc = Nothing End If Return effects <> DragDropEffects.None End If End If
'don't use the busy cursor If Not bc Is Nothing Then bc.Dispose() bc = Nothing End If Dim autoclose As GNClient.AutoCloseMode = GNClient.AutoCloseMode.No
Moreover, there's a new resource string in Fred resources:
|