To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=48286


User andrewb changed the following:

                  What    |Old value                 |New value
================================================================================
            Ever confirmed|                          |1
--------------------------------------------------------------------------------
                    Status|UNCONFIRMED               |NEW
--------------------------------------------------------------------------------
                  Keywords|                          |oooqa
--------------------------------------------------------------------------------




------- Additional comments from [EMAIL PROTECTED] Wed Nov 23 08:43:12 -0800 
2005 -------
Like this?


Sub MakeNamedBookmark
' acb 14/5/05 to work round a lasting irritation
dim ODoc, OText, bm, oTC
dim oVCursor, defaultName,checkedname
dim bmNames() as string
        oDoc = thisComponent
        oVCursor = oDoc.currentcontroller.getViewCursor()
        defaultName=oVCursor.getString()
        oTC=oDoc.getText.createTextCursorByRange(OVCursor)
        ' catch the case where the bookmark has no length
        ' in which case it will be the word under the cursor
        ' though could just as well be a sentence or anything
        if len(defaultname)=0 then 
                oTC.goToStartofWord(FALSE)
                oTC.gotoNextWord(TRUE)
                defaultname=oTC.getString()
        end if
        checkedname=MakeSafeBookmarkName(defaultname)
        bm=oDoc.createInstance("com.sun.star.text.Bookmark")
        bm.setName(checkedname)
        oDoc.getText().insertTextContent(oTC,bm,TRUE)
'       Xray.Xray(oTC.getText())
        oTC.CharUnderlineColor=RGB(0,130,0)
        oTC.CharUnderlineHasColor=TRUE
        oTC.CharUnderline=com.sun.star.awt.FontUnderline.DOUBLEWAVE
end Sub

Function MakeSafeBookmarkName(sText)
'get first six words of selected text
'excluding non-filename characters
'modified slightly for bookmark routine

dim sBMname as string
dim nSpaces,i as integer
dim Testchar as string
Testchar=""
sBMname=""
nSpaces =0
    for i=1 to len(sText)
        Testchar=Mid(sText,i,1)
      Select Case Testchar
              Case chr(10),chr(13) ' eol: stop altogether
                        exit for
              Case ":", "?", "\", "/", "[", chr(9), "(", "!",chr(34),"]","'" ' 
invalid char: skip
                      sBMname=sBMname
              Case " " ' a space!
                        nSpaces=nSpaces+1
                        sBMname=sBMname & Testchar
                        if nSpaces = 6 then
                                exit for
                        end if ' six words in a file name surely enough
              Case Else
                        sBMname=sBMname & testchar
      End Select
    next i
MakeSafeBookMarkName=sBMname
End Function


---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to