Issue 48286 - Automatic Bookmark title from selection
Summary: Automatic Bookmark title from selection
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: editing (show other issues)
Version: 680m95
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: oooqa
: 97284 (view as issue list)
Depends on:
Blocks:
 
Reported: 2005-04-27 17:33 UTC by richardsugg
Modified: 2013-02-07 22:35 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description richardsugg 2005-04-27 17:33:08 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.
Comment 1 michael.ruess 2005-04-28 07:40:28 UTC
Reassigned to requirements.
Comment 2 ingenstans 2005-11-23 16:43:12 UTC
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
Comment 3 ace_dent 2008-05-16 01:40:33 UTC
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
Comment 4 michael.ruess 2009-02-12 15:55:24 UTC
*** Issue 97284 has been marked as a duplicate of this issue. ***