Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
™
“Office Basic Source Code Management” is created by imacat (Yang Shih-Ching),and licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
™
imacat / Yang Shih-Ching
● Taiwan OpenOffice/LibreOffice community● Apache OpenOffice PMC● Women in FOSS in Taiwan
™
OpenOffice Basic is cool!
™
It connects programmingwith everybody’s daily routines.
™
I create Basic toolkit applicationsfor all kinds of jobs.
™
For example,
™
Accounting Sheet
™
Meet-up Sign Book
™
Mosaic Spreadsheet
™
Geometrical Paintings
™
Piano
™
Christmas Tree
™
Pokémon GO IV Calculator
™
But still,OpenOffice Basic sucks!
™
I lost all my Basic macroswhen I reinstall my system,
if I forget to export them.
™
I cannot synchronizing my Basic macrosamong my office PC, my home PC,
and my laptopunless I keep export and import
everything, everyday.
™
Finally, Basic IDE sucks.
™
And the macros are exported XML files,which I cannot work with directly.
XML
</>
™
This means I cannot do complicated thingsthat Basic IDE does not support.
Things like…
™
…regular expression search and replace,
/\w+@\w+(\.\w+)+/
/\w+@\w+(\.\w+)+/
/\w+@\w+(\.\w+)+/
/\w+@\w+(\.\w+)+/
™
…looking into all the occurrence of somethingfor code refactoring,
grep -r "getNumUsers" *.*
grep -r "getNumUsers" *.*
grep -r "getNumUsers" *.*
grep -r "getNumUsers" *.*
™
…and many, many more.
™
So, I wonder:Can I write Basic macros
outside of Basic IDE?
™
What do I needif I want to write Basic macros
outside of Basic IDE?
™
I can keep a source directory.Whenever I update my macro sources,I copy-and-paste them into Basic IDE.
™
But this doesn’t make things easier.
™
Or I can create a tool to do this.Whenever I update my macro sources,it copy-and-pastes them into Basic IDE.
™
To do this,I need to be able
to read and update the Basic macros.
™
This reminds me ofsomething similar I’d done before.
™
Calc Mosaichttp://sf.net/p/calcmosaic
™
In Calc Mosaic,after all the mosaic sheets are created,
Basic macros are inserted to play these sheets.
™
Document Basic Macro Storage
● The document Basic macro storage is the BasicLibraries attribute of the OfficeDocument object.
OfficeDocumentOfficeDocument
BasicLibrariesBasicLibraries
Basic LibraryBasic Library
Basic Module (String)Basic Module (String)
doc_libs = doc.getPropertyValue("BasicLibraries")
™
System and UserBasic Macro Storage
● But the system and user Basic macros arestored together at a different location, theApplicationScriptLibraryContainer service.
ApplicationApplication
ApplicationScriptLibraryContainerApplicationScriptLibraryContainer
Basic LibraryBasic Library
Basic Module (String)Basic Module (String)
app_libs = service_manager.createInstance(
"com.sun.star.script.ApplicationScriptLibraryContainer")
™
Basic Library Storage
● ApplicationScriptLibraryContainer has the XNameAccess interface.– Use hasByName() to check if a library exist.
– Use getByName() to obtain a library.
ApplicationApplication
Basic LibraryBasic Library
Basic Module (String)Basic Module (String)
ApplicationScriptLibraryContainerApplicationScriptLibraryContainer
™
Basic Library
● The Basic library is an XNameContainer.– Use getByName() to obtain a module.
– Use replaceByName() to update a module.
– Use insertByName() to add a module.
– Use removeByName() to delete a module.
ApplicationApplication
ApplicationScriptLibraryContainerApplicationScriptLibraryContainer
Basic Module (String)Basic Module (String)
Basic LibraryBasic Library
™
Basic Module
● The Basic module obtained with the previousgetByName() is a String that contains one ormore Basic subroutines as Basic macros.
ApplicationApplication
ApplicationScriptLibraryContainerApplicationScriptLibraryContainer
Basic LibraryBasic Library
Basic Module (String)Basic Module (String)
™
The logic is simple.
™
Synchronize BetweenFiles and Basic Storage
™
Update Basic Modules(Upload / Check In)
● Add the missing Basic modules.● Replace the updated Basic modules.● Delete the obsoleted Basic modules.
™
Update Source Files(Download / Check Out)
● Add the missing source files.● Replace the updated source files.● Delete the obsoleted source files.
™
(obasync Demonstration)
™
So,what’s so good
to leave Basic IDE?
™
Developers can store the source fileswith cloud sync servicescloud sync services,
and access their source files EVERYWHERE!
™
Developers can apply version control systemversion control systemto manage their source files.
CVSCVS
™
Developers can host their projectshost their projectson common project hosting services.
™
Developers can apply build toolsbuild toolsto automate extension packaging,
unit tests, and releases.
makemake
™
In addition, with the build tools,we can establish
project layout rulesproject layout rules and templatestemplatesto simplify and automate project management.
makemake
™
Take my Pokémon GO IV Calculatorfor example.
™
Pokémon GO IV Calculator
● It is entirely in my folder.– I work seamlessly on my PC and my laptop.
™
Pokémon GO IV Calculator
● It is entirely in my folder.– I work seamlessly on my PC and my laptop.
– I do not worry if my hard disk dies.
™
Pokémon GO IV Calculator
● It is entirely in my folder.– I work seamlessly on my PC and my laptop.
– I do not worry if my hard disk dies.
● I use for version control.
™
Pokémon GO IV Calculator
● It is entirely in my folder.– I work seamlessly on my PC and my laptop.
– I do not worry if my hard disk dies.
● I use for version control.● I host my project on .
™
Pokémon GO IV Calculator
● It is entirely in my folder.– I work seamlessly on my PC and my laptop.
– I do not worry if my hard disk dies.
● I use for version control.● I host my project on .
● I use with a build.xml and afixed project template to build and release.
™
Pokémon GO IV CalculatorProject Structure
rootroot PokemonGoIVPokemonGoIV
oxtoxt META-INFMETA-INF
PokemonGoIVPokemonGoIV
pkg-descpkg-desc
Main.vb, …etc.
Addons.xcu
description.xml
build.xml
README
VERSION
Main.vb, …etc.manifest.xml
pkg-description.txt
Main.xba, …etc.
™
Try obasync!PyPI: https://pypi.python.org/pypi/obasyncGitHub: https://github.com/imacat/obasync
™
Thank you.Any questions?