Apache OpenOffice (AOO) Bugzilla – Issue 48286
Automatic Bookmark title from selection
Last modified: 2013-02-07 22:35:02 UTC
It would be cool to be able to select a word, then add a bookmark, and the bookmark title be filled in from the selection.
Reassigned to requirements.
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
OpenOffice.org Issue Tracker - Feedback Request. The Issue you raised is currently assigned to 'Requirements' pending review, but has not been updated within the last 2+ years. Please consider re-testing with one of the latest versions of OOo, as the problem(s) may have already been addressed. Either use the recent stable version: http://download.openoffice.org/index.html or consider trying the new OOo 3 BETA (still in testing): http://download.openoffice.org/3.0beta/ Please report back the outcome so this Issue may be Closed or Progressed as necessary - otherwise it may be Resolved as Invalid in the future. You may also wish to search for (and note) any duplicates of this Issue that may have advanced further by checking the Issue Tracker: http://www.openoffice.org/issues/query.cgi Many thanks, Andrew Cleaning-up and Closing old Issues as part of: ~ The Grand Bug Squash, pre v3 ~ http://marketing.openoffice.org/3.0/announcementbeta.html
*** Issue 97284 has been marked as a duplicate of this issue. ***