I suppose that if you are willing to do that, you could also just write
a macro that looks for the "error" text. Even in a macro, it is not
always clear to me that a reference is bad. Even worse, sometimes the
display text does not update to indicate that the reference is broken -
LO is doing that to me right now, although it was not doing that earlier.
Consider this macro
Sub EnumerateTextFields(Optional oUseDoc)
Dim oDoc 'Document to use.
Dim oEnum 'Enumeration of the text fields.
Dim oField 'Enumerated text field.
Dim s$ 'Generic string variable.
Dim n% 'Count the number of text fields.
Dim nUnknown% 'Count the unexpected field types.
Dim bDisplayExpressions As Boolean
bDisplayExpressions = True
If IsMissing(oUseDoc) Then
oDoc = ThisComponent
Else
oDoc = oUseDoc
End If
oEnum = oDoc.getTextFields().createEnumeration()
If IsNull(oEnum) Then
Print "getTextFields().createEnumeration() returns NULL"
Exit Sub
End If
Do While oEnum.hasMoreElements()
oField = oEnum.nextElement()
If oField.supportsService("com.sun.star.text.TextField.Input") Then
REM If you update Content, use oDoc.TextFields.refresh() afterwards.
n = n + 1
s = s & "Input (" & oField.getPropertyValue("Hint") & ", " & _
oField.getPropertyValue("Content") & ")" & CHR$(10)
ElseIf oField.supportsService("com.sun.star.text.TextField.User") Then
REM You can update the text master field, but be certain to use
REM oDoc.TextFields.refresh() afterwards.
n = n + 1
s = s & "User (" & oField.TextFieldMaster.Name & ", " & _
oField.TextFieldMaster.Value & ", " & _
oField.TextFieldMaster.InstanceName & ")" & CHR$(10)
ElseIf
oField.supportsService("com.sun.star.text.TextField.PageNumber") Then
REM Ignore page number fields
ElseIf
oField.supportsService("com.sun.star.text.TextField.GetReference") Then
REM Ignore references to Listings, Tables, and Figures because I
want to.
If oField.SourceName <> "Listing" AND oField.SourceName <>
"Table" AND oField.SourceName <> "Figure" Then
n = n + 1
s = s & "Reference (" & oField.SourceName & ", " &
oField.getPresentation(False) & ")" & CHR$(10)
End If
REM If oField.CurrentPresentation contains the error reference
text.....
ElseIf
oField.supportsService("com.sun.star.text.TextField.SetExpression") Then
REM This includes things such as Tables, Listing, and Figures
REM The values will be similar to "SetExpression (Table, Table + 1)"
If bDisplayExpressions Then
n = n + 1
s = s & "SetExpression (" & oField.VariableName & ", " &
oField.Content & ")" & CHR$(10)
REM Inspect oField
End If
ElseIf
oField.supportsService("com.sun.star.text.TextField.Chapter") OR _
oField.supportsService("com.sun.star.text.TextField.DocInfo.Title") OR _
oField.supportsService("com.sun.star.text.TextField.DocInfo.ChangeDateTime")
OR _
oField.supportsService("com.sun.star.text.TextField.Bibliography") OR _
oField.supportsService("com.sun.star.text.TextField.Annotation") Then
n = n + 1
s = s & oField.getPresentation(True) & " : " &
oField.getPresentation(False) & CHR$(10)
Else
nUnknown = nUnknown + 1
n = n + 1
If nUnknown = 1 Then inspect(oField)
s = s & "Unknown : " & oField.getPresentation(True) & " : " &
oField.getPresentation(False) & CHR$(10)
End If
If n > 50 Then
MsgBox s, 0, "Text Fields"
s = ""
n = 0
End If
Loop
If n > 0 Then
MsgBox s, 0, "Text Fields"
s = ""
n = 0
End If
If nUnknown > 0 Then Print "Found " & nUnknown & " unexpected field
types"
Print "Finished"
End Sub
Do you see the line that reads
REM If oField.CurrentPresentation contains the error reference text.....
In theory, oField.CurrentPresentation contains the text displayed on the
screen and it should be an error messages. Sadly, the Master field
referenced by the text field is not cleared, which would make it much
easier to deal with :-(
On 08/08/2013 05:25 PM, Tim Lloyd wrote:
Hi, Probably not the solution you were hunting for but I create a PDF
and search for the offending text. It gets the job done in a
roundabout sort of way
Cheers
On 08/09/2013 06:47 AM, CVAlkan wrote:
My own fault of course, but sometimes I begin with with a passage
that says
something like
"See [Blah-Blah] on page [99]"
where the items in the braces are actually cross-references. Then I
later
delete whatever that was referring to without realizing something was
referencing it and end up with
"See Error: Reference source not found on page Error: Reference
source not
found."
Is there a way to search for dangling references like this in
LibreOffice? I
realize that attempting to issue a warning saying "you can't delete
what you
just tried to delete since something is referencing it" (sort of like a
relational database might do) would be fairly impractical,
particularly if
you're trying to delete a huge chunk of text, but being able to do
such a
search would be a good addition to preparation for printing and so
forth.
Thanks for any assistance.
If, by the way, no such thing exists, might that be a generally useful
enhancement request?
--
View this message in context:
http://nabble.documentfoundation.org/How-to-Find-Dangling-Cross-References-in-Writer-tp4069418.html
Sent from the Users mailing list archive at Nabble.com.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.