Adding a Dummy Text Feature to OpenOffice.org Writer
Productivity Sauce
Every now and then, I need to fill a blank OpenOffice.org Writer document with dummy text. While OpenOffice.org comes with a built-in feature that allows you to do that (type dt and press the F3 function key), it generates only one paragraph at a time and doesn't allow you to specify your own dummy text. So instead of the built-in dummy text feature, I used to use the Magenta Lorem Ipsum Generator extension that pulls dummy text from the lipsum.com Web site. It is, indeed, a nifty solution, but since it requires an Internet connection to do its magic, it's not of much use when I work off-line. So I wrote a simple macro that inserts dummy text into the current OpenOffice.org Writer document. The macro pulls text from the dummy.txt plain text file which you should prepare beforehand and place in the OpenOffice.org user directory ( e.g., /home/USER/.openoffice.org/3/user where USER is your actual user name). The text file should contain a few paragraphs of whatever dummy text you want to use. Make sure that the text doesn't contain empty paragraphs. Now copy the macro below, choose Tools | Macros | Organize macros | OpenOffice.org Basic, open the Module1 item in the Standard library for editing and paste the code.
Sub DummyText() Dim ParaNo as Integer ThisDoc=ThisComponent ThisText=ThisDoc.Text TheCursor=ThisText.createTextCursor SubstService = CreateUnoService("com.sun.star.util.PathSubstitution") UserPath = SubstService.substituteVariables("$(user)", true) DummyTxt = UserPath + "/dummy.txt" f1 = FreeFile() Open DummyTxt for Input as #f1 ParaNo=InputBox("Number of Paragraphs:", "Input") ParaCounter=0 Do while ParaCounter<ParaNo Line Input #f1, s TheCursor.String=s+Chr(13)+Chr(13) TheCursor.collapseToEnd ParaCounter=ParaCounter+1 Loop Close #f1 End Sub
Save the macro, close the OpenOffice.org Basic editor, and you are good to go. If setting up the macro manually is not your cup of tea, you'll be pleased to learn that this macro has been rolled into the latest release of the Writer's Tools extension. However, the Dummy Text tool is not available in the Writer's Tools main menu, so you have to add it to an existing OpenOffice.org menu. To do this, choose Tools | Customize, select the desired menu from the Menu drop-down list, press the Add button, navigate to OpenOffice.org Macros | My Macros | WriterTools | _Hidden, select the DummyText macro, and press Add. That's it. Now you can use the macro to insert dummy text into Writer documents.
Comments
comments powered by DisqusSubscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
How to do something similar without OpenOffice
(the ODF scripting category on the same website contains other examples of the same technique applied to spreadsheets and presentations.)