[Solved] Taking note and tagging format

Discuss the word processor

[Solved] Taking note and tagging format

Postby StefArma » Wed Feb 22, 2017 11:43 pm

Greetings community,

As first post i would like to introduce myself as well: I'm Stef, 25, Italian(I prefer english speaking communities), pharmacy student, PC gamer, guitar/music lover.

I always take notes by PC and tried different ways to achieve good and easy-reading text among which the best is Google Docs cooperating with multiple users (one write, another correct, another format). Anyway it happends i'm by myself and writing at speech speed + formatting might be hard.
In my point of view, format is more about tagging different kind of elements inside my text rather than paragraph defining. I make myself clear: a biochemistry text might include substrate, enzymes, co-enzyme, products, reading and visually recognizing each of them is lovely when reviewing on the train back home.
our well known friends:
Ctrl+b = bold,
Ctrl+i = italic,
Ctrl+u = underline
then going deep you can meet custom shortcut like i like to set: (Tools, Costumize, Keyboard)
ctr+w = increase fontsize,
ctrl+s = lower fontsize
ctrl+shift+w = uppercase
ctrl+shift+s = lowercare
however i'm looking for more... i'm thinking about tagging before word. Example: @substrate !enzyme §substrate in the end find and format the whole word after my tag in the way i want.

Probably my research should move on addons, anyway i trust forums and here's my point.

Every tip is very appreciated,
regards,
Stef
Last edited by StefArma on Sat Feb 25, 2017 7:35 pm, edited 1 time in total.
Open office 4.1.3 - Win7 Pro 64 bit
User avatar
StefArma
 
Posts: 2
Joined: Wed Feb 22, 2017 10:24 pm

Re: Taking note and tagging format

Postby Zizi64 » Fri Feb 24, 2017 10:59 pm

Using the direct (manual) formatting feature is not an effective method for text editing. Use the Styles instead of the direct formatting.
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.5 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.2; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7904
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Taking note and tagging format

Postby Hagar Delest » Sat Feb 25, 2017 1:09 pm

I think that the best method is to use the regular expressions (regex). The process would be:
- Write your text with your own tags (to be checked with the regex possibilities but you may have to start and end the string with the tag, the start only might not be enough to select the correct string).
- Afterward, use the Search & Replace feature to select your strings and apply the desired formatting. You can use character styles for that, you'll see that it's indeed a powerful feature to reformat your whole document at once.

You can have a list of the regex in your document to just copy-paste them in the dialog. However, for your use, I think it's definitively worth learning a little about macros. I use such kind of macro myself that search and replace for strings to be changed. With a single keystroke to launch the macro, once all the search and replace strings list are set, the changes will be done automatically at once. Quite time saving.

Don't hesitate to have a look at the macro forum, there are plenty of code snippets you could use.

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the edit button if your issue has been fixed.
AOO 4.1.6 on Xubuntu 19.04 and 4.1.5 on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28458
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Taking note and tagging format

Postby Hagar Delest » Sat Feb 25, 2017 7:37 pm

Here is a proposal. I let you discover the code and adapt it. Nothing very complicated.
You need to tag strings with a start and end tag like: here is the @string to be formatted@ in the text.
You have to code the formatting of your character styles. But if existing, it is not changed. So you can create a template with the existing styles already defined by the standard AOO interface.
I've used the method that apply the formatting with a FindAll routine because it does not work with the ReplaceAttributes routine. There may be a bug with the application of the character style (works fine for other attributes like font weight, ...).

You can add tags. You've to add them in the search variable and add a Case in the select case routine.

You have to call the macro with the menu Tools>Macros>Organize Macros>OpenOffice Basic and then Run Tag_My_Notes
Code: Select all   Expand viewCollapse view
Sub Tag_My_Notes
Dim sSearchTag(5) as String    ' Number of tags
Dim sReplaceTag(5) as String   ' Number of tags
Dim n, i as long
Dim oDoc, oReplace, oStyleChar, oCharStyles as object
Dim sCharStyle as string
oDoc = ThisComponent

' Declare here your Character styles
' Created if not existing
' If existing, the style is not modified
oCharStyles = oDoc.styleFamilies.getByName("CharacterStyles")

sCharStyle = ".substrate"
If Not oCharStyles.hasByName(sCharStyle) Then
   oCharStyles.insertByName(sCharStyle, oDoc.createInstance("com.sun.star.style.CharacterStyle"))
   oStyleChar = thisComponent.StyleFamilies.getByName("CharacterStyles").getByName(sCharStyle)
   oStyleChar.CharColor = RGB(255, 0, 0)
   oStyleChar.CharUnderline = 1
   oStyleChar.CharWeight = 100
   oStyleChar.CharBackColor = RGB(200, 200, 200)
End If

sCharStyle = ".enzyme"
If Not oCharStyles.hasByName(sCharStyle) Then
   oCharStyles.insertByName(sCharStyle, oDoc.createInstance("com.sun.star.style.CharacterStyle"))
   oStyleChar = thisComponent.StyleFamilies.getByName("CharacterStyles").getByName(sCharStyle)
   oStyleChar.CharColor = RGB(0, 0, 255)
   oStyleChar.CharWeight = 150
End If

sCharStyle = ".product"
If Not oCharStyles.hasByName(sCharStyle) Then
   oCharStyles.insertByName(sCharStyle, oDoc.createInstance("com.sun.star.style.CharacterStyle"))
   oStyleChar = thisComponent.StyleFamilies.getByName("CharacterStyles").getByName(sCharStyle)
   oStyleChar.CharColor = RGB(0, 255, 0)
End If

' Find the tagged strings & replace by the content (remove the tags)
sSearchTag() = Array("@([^@]*)@", "!([^!]*)!", "§([^§]*)§")
sReplaceTag() = Array("$1", "$1", "$1") ' As many "$1" as tags to be replaced
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.SearchRegularExpression = True
For n = LBound(sSearchTag()) To UBound(sSearchTag())
   oReplace.SearchString = sSearchTag(n)
   ' Find all the hits and change their character styles
   sTarget = ThisComponent.findAll(oReplace)
   For i = 0 To sTarget.count-1
      sFoundText = sTarget.getByIndex(i)
      Select Case sSearchTag(n)
      Case "@([^@]*)@":
         sCharName = ".substrate"
      Case "!([^!]*)!":
         sCharName = ".enzyme"
      Case "§([^§]*)§":
         sCharName = ".product"
      End Select
      sFoundText.CharStyleName = sCharName
   Next i
   ' Replace the hits by removing the tags
   oReplace.ReplaceString = sReplaceTag(n)
   ThisComponent.ReplaceAll(oReplace)
Next n
End Sub

Please add [Solved] at the beginning of the title in your first post (top of the topic) with the edit button if your issue has been fixed.
AOO 4.1.6 on Xubuntu 19.04 and 4.1.5 on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28458
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] Taking note and tagging format

Postby StefArma » Sat Feb 25, 2017 7:55 pm

Wow thanks a lot! This is a very nice template and i can edit cases to adapt it to each of my works!
Open office 4.1.3 - Win7 Pro 64 bit
User avatar
StefArma
 
Posts: 2
Joined: Wed Feb 22, 2017 10:24 pm


Return to Writer

Who is online

Users browsing this forum: Majestic-12 [Bot] and 17 guests