All Openoffice Document to Uppercase using basic - openoffice.org

Let be
text msklakkdkdkdklalksksla
an openoffice document
How I can convert all strings of an openoffice document to Uppercase strings using openoffice basic (programing language similiar to visual basic)?

OpenOffice StarBasic has a (runtime) function UCase, which returns a given string in all upper case.
So, to change a (Writer!) document to upper case, someone can use a one-liner:
ThisComponent.Text.setString( UCase(ThisComponent.Text.String) )

Related

jsPDF doesn't show certain letters properly (ū)

I am trying to create a PDF File to export using jsPDF library. In one of the lines I am trying to write a word that contains this 'ū' letter,
doc.text('Hūla', 20, 30);
However, when doing so the exported file doesn't contain this letter but instead it becomes
'H k l a' with spaces in between and a k instead of the ū.
What can I do in order to have this printed properly?
The solution was to use a font that supports this. I had to try multiple ones in order to get it working with this letter ū (it is not a specific language)
The font was Amiri. It also supported the Arabic font.

how to tokenize/parse/search&replace document by font AND font style in LibreOffice Writer?

I need to update a bilingual dictionary written in Writer by first parsing all entries into their parts e.g.
main word (font 1, bold)
foreign equivalent transliterated (font 1, italic)
foreign equivalent (font 2, bold)
part of speech (font 1, italic)
Each line of the document is the main word followed by the parts listed above, each separated by a space or punctuation.
I need to automate the process of walking through the whole file, line by line, and place a delimiter between each part, ignoring spaces and punctuation, so I can mass import it into a Calc file. In other words, "each part" is a sequence of character (ignoring spaces and punctuation) that have the same font AND font-style.
I have tried the standard Search&Replace feature, and AltSearch extension, but neither are able to complete the task. The main problem is I am not able to write a search query that says:
Find: consecutive characters with the same font AND font_style, ignore spaces and punctuation
Replace: term found above + "delimiter"
Any suggestions how I can write a script for this, or if an existing tool can solve the problem?
Thanks!
Pseudo code for desired effect:
var delimiter = "|"
Go to beginning of document
While not end of document do:
var $currLine = get line from doc
var $currChar = get next character which is not space or punctuation;
var $font = currChar.font
var $font_style - currChar.font_style (e.g. bold, italic, normal)
While not end of line do:
$currChar = next character which is not space or punctuation;
if (currChar.font != $font || currChar.font_style != $font_style) { // font or style has changed
print $delimiter
$font = currChar.font
$font_style - currChar.font_style (e.g. bold, italic, normal)
}
end While
end While
Here are tips for each of the things your pseudocode does.
First, the easiest way to move line by line is with the TextViewCursor, although it is slow. Notice the XLineCursor section. For the while loop, oVC.goDown() will return false when the end of the document is reached. (oVC is our variable for the TextViewCursor).
Get each character by calling oVC.goRight(0, False) to deselect followed by oVC.goRight(1, True) to select. Then the selected value is obtained by oVC.getString(). To ignore space and punctuation, perhaps use python's isalnum() or the re module.
To determine the font of the character, call oVC.getPropertyValue(attr). Values for attr could simply be CharAutoStyleName and CharStyleName to check for any changes in formatting.
Or grab a list of specific properties such as 'CharFontFamily', 'CharFontFamilyAsian', 'CharFontFamilyComplex', 'CharFontPitch', 'CharFontPitchAsian' etc. Character properties are described at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Formatting.
To insert the delimiter into the text: oVC.getText().insertString(oVC, "|", 0).
This python code from github shows how to do most of these things, although you'll need to read through it to find the relevant parts.
Alternatively, instead of using the LibreOffice API, unzip the .odt file and parse content.xml with a script.

Objective C: How to extract part of a String (e.g. start with 'src=')

I have a string as shown below
NSString *imagesource=#"<img src="http://edge.shop.com/edge.shop.com/ccimg.shop.com/250000/255300/255316/products/1142702303.jpg" title="Marley Coffee&reg; Mystic Morning Organic Ground Coffee" alt="Marley Coffee&reg;";
How can I select only the text starting with 'src=' (and ends with a space), in this case the source of the image
You can use a regular expression, check out this question which explains how to do it.
How to write regular expressions in Objective C (NSRegularExpression)?

URL Escape in Uppercase

I have a requirement to escape a string with url information but also some special characters such as '<'.
Using cl_http_utility=>escape_url this translates to '%3c'. However due to our backend webserver, it is unable to recognize this as special character and takes the value literally. What it does recognize as special character is '%3C' (C is upper case). Also if one checks http://www.w3schools.com/tags/ref_urlencode.asp it shows the value with all caps as the proper encoding.
I guess my question is is there an alternative to cl_http_utility=>escape_url that does essentially the same thing except outputs the value in upper case?
Thanks.
Use the string function.
l_escaped = escape( val = l_unescaped
format = cl_abap_format=>e_url ).
Other possible formats are e_url_full, e_uri, e_uri_full, and a bunch of xml/json stuff too. The string function escape is documented pretty well, demo programs and all.

printfn not producing expected results for international (non-latin) characters

I have the following program:
let txt = "إتصالات"
printfn "Text is: %s" txt
0 // return an integer exit code
The value of txt is being set to some Arabic characters. When I run the program what is being displayed on the console is a bunch of question marks rather than the characters. In the Visual Studio 2012 debugger the correct characters are being displayed for the txt variable.
What am I doing wrong and how does one properly display international characters?
According to How to write unicode chars to console? you need to set the OutputEncoding property on the console, like this:
System.Console.OutputEncoding <- System.Text.Encoding.Unicode
let txt = "إتصالات"
printfn "Text is: %s" txt
0 // return an integer exit code
The answer for that question is worth reading though, because it also describes why you need to change your console font to really make this work, and also how to do it.
Here are some additional links with more information:
Necessary criteria for fonts to be available in a command window (this is for Windows 2000 and may not entirely apply to Windows 8, but it should give you a good idea of what to look for in a font).
Windows Console and TrueType Fonts shows how to add new fonts to the console.
Anyone who says the console can't do Unicode isn't as smart as they think they are has some background information about writing Unicode text to the console.
Update: Since the Arabic text in the example renders just fine here on StackOverflow, I peeked at the CSS to see which fonts they're using to render preformatted text. Using that list and the Windows Character Map tool (Start -> All Programs -> Accessories -> System Tools -> Character Map), I've found the Courier New font (which ships with Windows) supports Arabic characters. If you use the registry hack in the "Windows Console and TrueType Fonts" link (above), you should be able to add Courier New as a font you can use in the console.

Resources