LibreOffice Guide 12
LibreOffice Guide 12
This is a
necessary first step, so click Yes. Then you can move the object handles to produce the desired
effect. See the Draw Guide Chapter 4 Changing Object Attributes for more information on how to
distort an object.
Duplication
Duplication makes copies of an object while applying a set of changes such as color or rotation to
the duplicates that are created.
1) Click on an object or group of objects and go to Edit > Duplicate on the Menu bar or use
the keyboard shortcut Shift+F3 to open the Duplicate dialog (Figure 206).
Combining objects
Combining objects is a permanent merging of objects that creates a new object. The original
objects are no longer available as individual entities and cannot be edited as individual objects.
Any editing of a combined object affects all the objects that were used when combination was
carried out.
Select several objects, then go to Modify > Combine on the Menu bar, or right-click on the objects
and select Combine from the context menu, or use the keyboard shortcut Ctrl+Shift+K.
After you have selected your objects, the Merge, Subtract, and Intersect functions also become
available so that you can create a new object from your selected objects. See the Draw Guide
Chapter 5 Combining Multiple Objects for more information on these functions.
Exporting graphics
Draw saves graphics and images in the open source format *.odg. To save a graphic or the entire
file in another format, use File > Export and select a format from the list displayed. The graphic
formats that Draw can export and save to are listed in Appendix B Open Source, Open Standards,
OpenDocument in this guide.
You can also export Draw files to HTML, XHTML, PDF, or Flash. PDF export for modules of
LibreOffice is described in Chapter 10 Printing, Exporting, and E-mailing of this guide.
HTML export uses a conversion wizard that creates as many web pages as there are pages in
your Draw document. You can optionally choose to display pages in frames with a navigator and
set an index page. For more information, see Chapter 12 Creating Web Pages in this guide.
Note
LibreOffice uses the terms Data Source and Database to refer to the same thing,
which could be a database such as MySQL or dBase or a spreadsheet or text
document holding data.
A database consists of a number of fields that contain the individual pieces of data. Each table of
the database is a group of fields. When creating a table, you also determine the characteristics of
each field within it. Forms are for data entry into the fields of one or more tables which have been
associated with the form. They can also be used for viewing fields from one or more tables
associated with the form. A query creates a new table from the existing tables based upon how you
create the query. A report organizes the information from the fields of a query into a document
according to your requirements.
Note
LibreOffice Base uses the HSQL database engine. All of the files created by this
engine, including the database forms, are kept in one zipped file.
Caution
To use Base, you need to use a Java Runtime Environment (JRE). Please go to Tools
> Options > LibreOffice > Advanced to select a JRE from those installed on your
computer.
If a JRE is not already installed, you will need to download and install one. For
Windows, you need to get Java from www.java.com. For Linux, you can download it
from the same website or you can use openjdk-7-jre, available from the repository of
your Linux version. Mac OS X users can install a JRE from Apple Inc.
Base creates relational databases. This makes it fairly easy to create a database in which the
fields of the database have relationships with each other.
For example: Consider a database for a library. It will contain a field for the names of the authors
and another field for the names of the books. There is an obvious relationship between the authors
and the books they have written. The library may contain more than one book by the same author.
This is what is known as a one-to-many relationship: one author and more than one book. Most if
not all the relationships in such a database are one-to-many relationships.
Consider an employment database for the same library. One of the fields contains the names of
the employees while others contain the social security numbers, and other personal data. The
relationship between the names and social security numbers is one-to-one: only one social security
number for each name.
If you are acquainted with mathematical sets, a relational database can easily be explained in
terms of sets: elements, subsets, unions, and intersections. The fields of a database are the
Planning a database
The first step in creating a database is to ask yourself many questions. Write them down, and
leave some space between the questions to write the answers later. At least some of the answers
should seem obvious after you take some time to think.
You may have to go through this process a few times before everything becomes clear in your
mind and on paper. Using a text document for these questions and answers makes it easier to
move the questions around, add additional questions, or change the answers.
Here are some of the questions and answers I developed before I created a database for
automobile expenses. I had an idea of what I wanted before I started, but as I began asking
questions and listing the answers, I discovered that I needed additional tables and fields.
What are the fields going to be? My expenses divided into three broad areas: fuel purchases,
maintenance, and vacations. The annual cost for the cars license plate and drivers license every
four years did not fit into any of these. It will be a table of its own: license fees.
What fields fit the fuel purchases area? Date purchased, odometer reading, fuel cost, fuel quantity,
and payment method for it. (Fuel economy need not be included, as it can be calculated using a
query.)
What fields fit the maintenance area? Date of service, odometer reading, type of service, cost of
service, and next scheduled service of this type (for example, for oil changes, list when the next oil
change should be). But it would be nice if there was a way to write notes. So a field for notes was
added to the list.
What fields fit the vacations area? Date, odometer reading, fuel (including all the fields of the fuel
table), food (including meals and snacks), motel, total tolls, and miscellaneous. Since these
purchases are made by one of two bank cards or with cash, I want a field to state which payment
type was used for each item.
What fields fit into the food category? Breakfast, lunch, supper, and snacks seem to fit. Do I list all
the snacks individually or list the total cost for snacks for the day? I chose to divide snacks into two
fields: number of snacks and total cost of snacks. I also need a payment type for each of these:
breakfast, lunch, supper, and total cost of snacks.
What are the fields that are common to more than one area? Date appears in all of the areas as
does odometer reading and payment type.
How will I use this information about these three fields? While on vacation, I want the expenses for
each day to be listed together. The date fields suggest a relationship between the vacation table
and the dates in each of these tables: fuel and food, This means that the date fields in these tables
will be linked as we create the database.
The type of payment includes two bank cards and cash. So we will create a table with a field for
the type of payment and use it in list boxes in the forms.
Tip
While we have listed fields we will create in the tables of the database, there is one
more field that may be needed in a table: the field for the primary key, an identifier
unique to each record. In some tables, a suitable field for the primary key has already
been listed. In other tables such as the payment type, an additional field for the primary
key must be created.
Note
In Writer, the F4 key opens and closes the Data Source window containing the list of
registered databases. In Calc, press Ctrl+Shift+F4 to open the Data Source window. If
a database is not registered, this window will not contain it, so you cannot access the
database in Writer or Calc.
Save the new database with the name Automobile. This opens the Automobile LibreOffice Base
window. Figure 211 shows part of this window.
Tip
Every time the Automobile database is opened, the Automobile LibreOffice Base
window opens. Changes can then be made to the database. The title for this window is
always <database name> LibreOffice Base.
For example, when you create your first table, you must save it before you can close it.
This makes it part of the database in memory. But it is only when you save the
database file that the table is written to disk.
Note
Database files in Open Document Format are stored with the *.odb extension. This file
format is actually a container of all elements of the database, including forms, reports,
tables, and the data itself. The same format can also store a connection to an external
database server instead of the local data, for example, to access a MySQL or
PostgresSQL database server in your network.
Caution
Every table requires a Primary key field. (What this field does will be explained later.)
We will use this field to number our entries and want that number to automatically
increase as we add each entry.
Note
If any of these fields requires a mandatory entry, set Entry required to Yes. A blank field
will then not be allowed. In general, only set Entry required to Yes if something must
always be put in that field. By default, Entry required is set to No.
Note
In Base the maximum length of each field must be specified on creation. It is not easy
to change this later, so if in doubt specify a greater length. Base uses VARCHAR as the
field format for text fields. This format uses only the actual number of characters in a
field up to the limit set, so a field containing 20 characters will occupy only 20
characters even if the limit is set at 100. Two album titles containing 25 and 32
characters respectively will use space for 25 and 32 characters and not 100 characters.
Note
Each field has a Field Type, which must be specified. Types include text, integer, date,
and decimal. If the field is going to have general information in it (for example, a name
or a description), use text. If the field will always contain a number (for example, a
price), the type should be decimal or another numerical field. The wizard picks the right
field type, so to get an idea of how this works, see what the wizard has chosen for
different fields.
The simplest method is to assign a unique number to each one: number the first
person 1, the second 2, and so on. Each entry has one number and every number is
different, so it is easy to say record ID 172. This is the option chosen here:
CollectionID is just a number assigned automatically by Base to each record of this
table.
Caution
Once tables have been created using the wizard, and data has been entered, editing a
table should be very limited. You can add or delete fields, but adding a field requires you
to enter the data for that one field for every existing record with an entry for that field.
Deleting a field deletes all the data once contained in that field. Changing the field type
of a field can lead to data being lost either partially or completely. When creating a new
table, it pays to create the fields with the correct names, length, and format before you
add any data.
Deleting a table removes all of the data contained in every field of the table. Unless you
are sure, do not delete a table.
Note
While the Field type and formatting are different in Design View, the concepts are the
same as in the Wizard.
The first table to be created is Fuel. Its fields are FuelID, Date, FuelCost, FuelQuantity, Odometer,
and PaymentType.
1) Click Create Table in Design View (which opens the Table Design dialog).
2) FuelID field: Type FuelID as the first Field Name. Press the Tab key to move to the Field
Type column. Select Integer [INTEGER] as the Field Type from the drop down list. (The
default setting is Text [VARCHAR].)
Tip
A shortcut for selecting from the Field Type drop down list: press the key for the first
letter of the choice. You can cycle through the choices for a given letter by repeatedly
pressing that key.
Tip
Certain of the Integer filed types (Integer and BigInt for example) have an AutoValue
Field Property. When using one of these field types, your selection of Yes for the
AutoValue value automatically makes the field the primary key.
Primary keys for any other field type must be selected by right-clicking the rectangle
before the field and selecting Primary key in the context menu.
e) To access additional formatting options, click the ellipse button () to the right of the
Format example field.
Description can be any of the categories listed in the figure below, or can be left blank.
4) To save and close the table, select File > Save. Name the table Fuel. Close the Fuel table.
5) In the main database window, click the Save button.
Tip
As you create your own databases, you will also need to determine if tables are related
and how.
Tip
The primary key can contain more than one field. (Its foreign key1 will contain the same
number of fields.) If this were the case in Figure 219, the other fields of the primary field
for the Fuel table would be listed under Date. The corresponding fields of the foreign
key would be listed under Vacations. Detailed information about this is in the Base
Guide.
1 A field in a table that stores values of the primary key of records in another table.
In our database, payments for food or fuel might be made from one of two credit cards (Dan or
Kevin) or in cash, so these would be the available options for all boxes that contain payments.
To create a list box, we first need to create a small, separate table containing the options. This is
then linked to the corresponding field in the form. The topic is dealt with in detail in the Base User
Guide and will not be pursued further here.