Re: [libreoffice-users] How to Find Dangling Cross References in Writer

2013-08-12 Thread Adam Tauno Williams
On Fri, 2013-08-09 at 07:25 +1000, 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

Sadly, this is my method as well.  It is especially irritating when
using Master Documents [which link many docuemnts].  The documents *CAN*
reference each other but only that only works from the Master Document,
so refreshing the master document and generating a PDF and searching for
the text is [so far] the simplest way I have found.

Cross reference and Master Documents are the killer feature of
LibreOffice, but this is one corner where it falls down [why can't a
document 'know' in it's meta-data that it is part of a master document,
dunno, that would probably be a big deal, but it would certainly be a
boon for this feature-set].


-- 
To unsubscribe e-mail to: users+unsubscr...@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


Re: [libreoffice-users] How to Find Dangling Cross References in Writer

2013-08-08 Thread Andrew Douglas Pitonyak
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 

Re: [libreoffice-users] How to Find Dangling Cross References in Writer

2013-08-08 Thread Tim Lloyd
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.




--
To unsubscribe e-mail to: users+unsubscr...@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



[libreoffice-users] How to Find Dangling Cross References in Writer

2013-08-08 Thread CVAlkan
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.

-- 
To unsubscribe e-mail to: users+unsubscr...@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