Development/Aw080 documentation/Other changes

From The Document Foundation Wiki
Jump to: navigation, search

Branch aw080

This page is part of the documentation for the aw080 branch for the Apache OpenOffice project (incubating). The main page can be found here

Other changes

Changes that apply to cleanup of old stuff, better readability and/or functionality and speed.

Old RTTI removed and replaced with standard C++ RTTI

The classic OpenOffice RTTI, defined ca. 18 years ago since C++ had none at that time (defined in rtti.h) was not very reliable, it is completely removed and replaced in aw080. When replacing it I found a lot of errors since it had to be defined in a derived class by a macro (TYPEINFO) in the definition and implemented by a macro, too (TYPEINIT_FACTORY, TYPEINIT). This was not reliably done over derivated hierarchies, thus the corresponding calls to use it (ISA, HAS_BASE, PTR_CAST) were also unreliable and often did not represent the true (or not all) C++ derivations. I found one case where a wrong definition was used in the class definition/implementation, probably as a hack to avoid one of these problems and to show wrong derivations by purpose. All usages were replaced, the file rtti.h was moved to binfilter which as single exception was not adapted (what would simply be dangerous). All other usages were changed to use dynamic_cast and/or static_cast and the usual C++ RTTI type definitions.

The old RTTI mechanisms were also used in the half-automated slot definitions of the applications, thus I had to adapt the slot definition compiler accordingly. It was also used heavily in Writer model node travelling, also adapted completely to more modern and reliable C++ RTTI mechanisms.

All usages of old list classes in Drawinglayer adapted to STL

Wherever possible I replaced the old tooling list classes with STL mechanisms and adapted the code accordingly. The DrawingLayer in aw080 is pretty much free of the old list classes. These still exist and it maybe another project to completely remove these (this is not trivial since the tools lists have special functionality with a currently remembered entry which is used sometimes).

Removed unused/very simple Item types

Quite some Items could be identified to not being needed anymore. I also removed a lot of very simple Item definitions which were not really needed and replaced them with their base types (e.g. a lot of items derived from the basic bool type can just be set/get and used using the basic type and the slot ID). This significantly reduces the number of symbols defined by svx.

Selection mechanism for SdrObject at SdrView completely rewritten

The selection mechanism holding SdrObjects at the views was quite unsafe. This leads still to many situations where there are still objects in the selection which were removed or even deleted already, a reason for many crashes. The classes for holding and maintaining the selection were completely isolated form the view classses. They use STL mechanisms (sets) now which are sorted and also avoid double selected objects by definition. All non-reading (non-const) accesses to the selection at the views were isolated and reduced to a minimum to guarantee safe handling. Quite some changes were needed to do so, but it coud be done. The controller part of DrawingLayer still will need a redefinition after aw080, but security and stability will already be increased.

All mechanisms working on selections wre adapted accordingly. There exist many methods in many view implementations in the applications which are based on the view's selection, all were adapted to the safer mechanism. As an example, most usages were somehow iterating over the selection while at the same time changing it. Many diverse mechanisms to avoid problems with this were in place, most the result of old fixes. Most of these could be adapted to get the current selection at method entry and delete it at the view, cleanly working on the SdrObjectVector (based on STL) fetched from the view as selection and building a new one containing the new slection. At method exit, either the old (when no change was made) or the new one is set as new selection in one single call. This also avoids too much broadcasting over selection changes, another source of common errors.

All SdrView classes cleaned up

I secured the whole SdrView derivated hierarchy, all constructors were corrected (member initialization). Neraly all constructors were reduced to a single one. The hierarchy from SdrPaintView up to SdrView is a single entity, thus the internal constructors went all to protected mode. Cases where in-between classes were incarnated were corrected. All members of all SdrView hierarchy classes were identified, evtl. renamed to make them unique and better readable and adapted to hungarian notation (leading m*) added.

Most of the methods at the SdrView hierarchy were checked and also updated. Many were removed, some replaced. Inlines (obviously from earlyer changes where no one wanted to get incompatible) were removed and replaced with the real calls. Methods which need not to be virtual were made non-virtual. Names were corrected and adapted to make calls more readable and self-explaining. A lot of parameters were removed since they were no longer needed or could be avoided with better mechanisms. Also cleaned up and checked all friend declarations to create more safety.

OrdNums for SdrObjects and SdrPages secured/reimplemented

The OrdNums at SdrObjects which describe the position of the SdrObject in the parent class (list or Page) were on demand refreshed in an unsecure way, many instances triggered it by hand or called it directly. This is now secured and centralized, only one explicit friend method used in a single place is now allowed to do that changes. This also was an ongoing root of errors. Also renamed all usages to NavigationPosition to increase readability/understandability. The same has happened to PageNumbers in the SdrPage class hierarchy.

Many base classes of DrawingLayer are now based on boost::noncopyable

Most classes in the DrawigLayer Model are now derived from the boost::noncopyable class to securely avoid unwanted (evtl. implicit) cloning of these. This includes the whole SdrObject hierarchy, the SdrObjList/SdrPage hierarchy and others.

SdrHint reimplemented/redefined

The SdrBaseHint used for SdrObject change broadcasting got simplified, all unused types of broadcasts removed. All places using boroadcasts adapted, many simplified or removed, too. In some cases broadcasting could be completely avoided and a more intelligent automatic mechanism being used, mainly when insterting/removing SdrObjects. There is also a class now (SdrObjectChangeBroadcaster) which supports broadcasting better by doing it on destruction time. Adapted all broadcasts to make use of this.

SdrObjectUser mechanism removed

The SdrObjectUser mechanism which existed to allow classes using SdrObjects to register and to react on it's (unexpected) deletion was completely removed and all usages were adapted to use the already existing broadcasting mechanism.

EditEngine changes

The EditEngine, the tooling used for layouting and editing text in DrawingLayer did not really fit into the overlay mechanisms offered by previous changes because it was implemented to only work on Windows (the class Window from Vcl) directly. The overlay used to speedup and avoid flicker uses a virtual device. This means that in older offices each time text edit started the buffering using overlay had to be replaced by unbuffered viewing and vice-versa at text edit ending. In aw080 I changed EditEngine to be able to paint to OutputDevices of any kind, the Window part is only used for the interactive part while editing (key input), thus separating the view and controller part.

This change is already in the trunk as bugfix, extracted for this from aw080. It is also the preparation to use Primitives for EditEngine painting in edit mode in the future. This will also allow using the selection schemata already used in Writer and Calc, using the system's default selection color in a transparent shaded fashion and to get rid of the XOR selection painting. It also removes the necessity to paint a background for expanding text editing in a 'guessed' background color (it's calculation was always unreliable).

Mirroring of CustomShapes

Only one existing SdrShape has the ability – despite having no transformations – to remember that it's mirrored, it's the CustomShape. This was necessary and the guy implementing it had to do some heavy coding to get it working. With transformations this extra code can be removed (and is already in aw080), but will need thorough testing for functionality, especially in MS imports/exports.

SdrVirtObj isolated and moved to Writer

The SdrVirtObj (used as a kind of proxy for repeating existing SdrObjects) is only used from Writer, I moved it there exclusively to have it out of the way for further DrawingLayer changes in svx (it does not fit in any working concept anyways, the plans to solve problems with SdrObject handling longtime in Writer will not use it).

SdrVirtObj usage in Writer and corresponding offset to anchor revamped

Despite it is only used in Writer, it is hosting an offset to the anchor of the Writer model. This offset and it's calculation was highly blurred with old stuff. I completely sorted out the stuff happening and reduced it to the needed stuff. Changed/adapted the in/exports in Writer accordingly and tested it.

Many methods renamed to self-explanatory names

Often it is complicated to grep the office code for some method defined for a specific class. This makes cleanup and redefiition work pretty complicated. I have renamed many methods to more unique, self-explanatory names, e.g. GetModel() which is available on many classes is now split into getSdrModelFromSdrObjList, getSdrModelFromSdrView, getSdrModelFromSdrObject and others.

Many varaiable exchanges in methods changed to reference

A common cause for errors are null-pointers and not checking them, in most cases because it makes no sense to not have the needed object handy in the current context. This can often be avoided by not passing the object to a method by pointer, but by reference. This makes clear that this method is only to be called with an existing object and the method itself often gets much easier to implement, read and understand. One exampe is the SdrObject construction which now takes a reference to a SdrModel and a reference to a basegfx::B2DHomMatrix. I changed many methods in this direction and adapted the callers. In nearly all of the cases the overall handling became simpler and safer, in the rest checking for object existence before calling functionality which relies on the object is better anyways.

SdrView has a delayed notify mechanism

One of the reasons the broadcast mechanisms are expensive is that every change is broadcasted immediately. For aw080 I added a buffered, delayed notification for all actions on SdrViews. e.g. when 1000 objects get moved, there are no 1000 broadcasts disrupting the work in progress, but only a collected one when the action is done.

No insert reason needed for object construction

Inserting a SdrObject to a SdrPage or at a SdrView needed a insert reason in the current office. I redesinged the logic using this, so this is no longer needed.

FASTBOOL removed in aw080

Usage of FASTBOOL completely removed on aw080, except for binfilter module. As you might guess, there were places to be found where it was misused to hand over values except true and false, e.g. '2' and others, these were corrected and removed.

SdrObject Attribute handling simplified

In the current office there are mechanisms to handle attribute changes when a SdrModel changes from one SdrModel to another. This was necessary to repair various aspects, e.g. unique name necessities and others. Since a SdrObject in aw080 can no longer change it's SdrModel during lifetime this complicated and error-prone mechanisms are no longer needed and are removed. When now cloning SdrObjects to another SdrMopdel these mechanisms are in place anyways since they always also corrected on pure insertion.