Oh, and to be honest it shouldn't be that hard to work on.
It basically works via a Command pattern. That's because an EMF is a binary file that consists of a bunch of sequential records. The way it works is that you get an EMF+ file, and you read it from start to finish. Each record you read has a consistent header, and each different type of record does something - or stores an object (such as a pen or font).
My big idea is to use a base EmfAction class that has a function Read() that you use to read each type of record. You use EmfAction::ReadEmfAction() to read the next record from an ifstream, and it moves the file pointer to the start of the next record, and you just loop through the file like this:
The only snag was how to set state on the DeviceContext - I want the commands to read and store the state, and the DeviceContext should be passed into the command object and be manipulated by it via an Execute(DeviceContext&). But at the time I concentrated on how to read the objects.
Of course, EMF+ has a way of saving a DC's state, allows the DC be modified by subsequent records, and then the DC can be restored, so a stack of DCs needs to be established, but how to do this I'm not rightly sure yet.
I'm pretty certain though that I'm going to need to change the EmfRecord derived command records to start using a constructor where the DeviceContext object is passed in as a pointer.
It basically works via a Command pattern. That's because an EMF is a binary file that consists of a bunch of sequential records. The way it works is that you get an EMF+ file, and you read it from start to finish. Each record you read has a consistent header, and each different type of record does something - or stores an object (such as a pen or font).
My big idea is to use a base EmfAction class that has a function Read() that you use to read each type of record. You use EmfAction::ReadEmfAction() to read the next record from an ifstream, and it moves the file pointer to the start of the next record, and you just loop through the file like this:
https://cgit.freedesktop.org/libreoffice/core/diff/vcl/sourc...
The only snag was how to set state on the DeviceContext - I want the commands to read and store the state, and the DeviceContext should be passed into the command object and be manipulated by it via an Execute(DeviceContext&). But at the time I concentrated on how to read the objects.
Of course, EMF+ has a way of saving a DC's state, allows the DC be modified by subsequent records, and then the DC can be restored, so a stack of DCs needs to be established, but how to do this I'm not rightly sure yet.
I'm pretty certain though that I'm going to need to change the EmfRecord derived command records to start using a constructor where the DeviceContext object is passed in as a pointer.
The header file can be found here:
https://cgit.freedesktop.org/libreoffice/core/tree/include/v...
The record commands are implemented here:
https://cgit.freedesktop.org/libreoffice/core/tree/vcl/sourc...
As it is an initial implementation. The Read() calls are defined in the class declaration. Obviously that will need to be corrected.
The code also probably needs to be rebased, but in all honestly it is such a small change I don't think it would be too hard...