Mapper  0.9.0
API documentation
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
OpenOrienteering::OCAD8FileImport Class Reference

Importer for OCD version 8 files. More...

#include <ocad8_file_format_p.h>

Inheritance diagram for OpenOrienteering::OCAD8FileImport:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::OCAD8FileImport:
Collaboration graph
[legend]

Public Member Functions

 OCAD8FileImport (const QString &path, Map *map, MapView *view)
 
 ~OCAD8FileImport () override
 
void setStringEncodings (const char *narrow, const char *wide="UTF-16LE")
 
- Public Member Functions inherited from OpenOrienteering::Importer
 Importer (const QString &path, Map *map, MapView *view)
 Creates a new Importer with the given input path, map, and view. More...
 
 ~Importer () override
 Destroys this Importer. More...
 
bool loadSymbolsOnly () const noexcept
 Returns true if only symbols (and colors) are to be imported. More...
 
void setLoadSymbolsOnly (bool value)
 If set to true, importers shall import only symbols (and colors). More...
 
bool doImport ()
 Imports the map and view. More...
 
- Public Member Functions inherited from OpenOrienteering::ImportExport
 ImportExport (QIODevice *device=nullptr)
 Creates a new importer or exporter with the given IO device. More...
 
 ImportExport (const ImportExport &)=delete
 
 ImportExport (ImportExport &&)=delete
 
virtual ~ImportExport ()
 Destroys an importer or exporter. More...
 
virtual bool supportsQIODevice () const noexcept
 Returns true when the importer/exporter supports QIODevice. More...
 
QIODevicedevice () const noexcept
 Returns the input device if it has been set or created. More...
 
void setDevice (QIODevice *device)
 Sets a custom input device to be used for import. More...
 
void setOption (const QString &name, const QVariant &value)
 Sets an option in this importer or exporter. More...
 
QVariant option (const QString &name) const
 Retrieves the value of an option in this instance. More...
 
void addWarning (const QString &str)
 Adds a string to the current list of warnings. More...
 
const std::vector< QString > & warnings () const noexcept
 Returns the current list of warnings collected by this object. More...
 

Protected Member Functions

bool importImplementation () override
 Actual implementation of the import. More...
 
SymbolimportPointSymbol (const OCADPointSymbol *ocad_symbol)
 
SymbolimportLineSymbol (const OCADLineSymbol *ocad_symbol)
 
SymbolimportAreaSymbol (const OCADAreaSymbol *ocad_symbol)
 
SymbolimportTextSymbol (const OCADTextSymbol *ocad_symbol)
 
RectangleInfo * importRectSymbol (const OCADRectSymbol *ocad_symbol)
 
ObjectimportObject (const OCADObject *ocad_object, MapPart *part)
 
bool importRectangleObject (const OCADObject *ocad_object, MapPart *part, const RectangleInfo &rect)
 
virtual void importString (OCADStringEntry *entry)
 
TemplateimportTemplate (OCADCString *ocad_str)
 
OCADBackground importBackground (const QByteArray &data)
 
TemplateimportRasterTemplate (const OCADBackground &background)
 
PointSymbolimportPattern (s16 npts, OCADPoint *pts)
 
void fillCommonSymbolFields (Symbol *symbol, const OCADSymbol *ocad_symbol)
 
void setPathHolePoint (Object *object, int i)
 
void fillPathCoords (Object *object, bool is_area, u16 npts, const OCADPoint *pts)
 Translates the OCAD path given in the last two arguments into an Object. More...
 
bool fillTextPathCoords (TextObject *object, TextSymbol *symbol, u16 npts, OCADPoint *pts)
 Translates an OCAD text object path into a Mapper text object specifier, if possible. More...
 
QString convertPascalString (const char *p)
 Converts a single-byte-per-character, length-payload string to a QString. More...
 
QString convertCString (const char *p, std::size_t n, bool ignore_first_newline)
 Converts a single-byte-per-character, zero-terminated string to a QString. More...
 
QString convertWideCString (const char *p, std::size_t n, bool ignore_first_newline)
 Converts a two-byte-per-character, zero-terminated string to a QString. More...
 
float convertRotation (int angle)
 
void convertPoint (MapCoord &c, s32 ocad_x, s32 ocad_y)
 
qint32 convertSize (int ocad_size)
 
const MapColorconvertColor (int color)
 
double convertTemplateScale (double ocad_scale)
 
- Protected Member Functions inherited from OpenOrienteering::Importer
virtual void prepare ()
 Event handler called from doImport() to prepare the import process. More...
 
virtual void validate ()
 Event handler called from doImport() to complete to postprocess imported data. More...
 
virtual void importFailed ()
 Event handler called from doImport() to complete to cleanup a failed import attempt. More...
 

Static Protected Member Functions

static bool isRasterImageFile (const QString &filename)
 

Friends

class OcdFileImport
 

Additional Inherited Members

- Protected Attributes inherited from OpenOrienteering::Importer
const QString path
 The input path. More...
 
Map *const map
 The Map to import or export. More...
 
MapView *const view
 The MapView to import or export. More...
 

Detailed Description

Importer for OCD version 8 files.

Constructor & Destructor Documentation

◆ OCAD8FileImport()

OpenOrienteering::OCAD8FileImport::OCAD8FileImport ( const QString path,
Map map,
MapView view 
)

◆ ~OCAD8FileImport()

OpenOrienteering::OCAD8FileImport::~OCAD8FileImport ( )
override

Member Function Documentation

◆ convertColor()

const MapColor * OpenOrienteering::OCAD8FileImport::convertColor ( int  color)
protected

◆ convertCString()

QString OpenOrienteering::OCAD8FileImport::convertCString ( const char *  p,
std::size_t  n,
bool  ignore_first_newline 
)
protected

Converts a single-byte-per-character, zero-terminated string to a QString.

The byte sequence will be: C0 C1 C2 C3 ... 00. n describes the maximum length (in bytes) that will be scanned for a zero terminator; if none is found, the string will be truncated at that location.

◆ convertPascalString()

QString OpenOrienteering::OCAD8FileImport::convertPascalString ( const char *  p)
protected

Converts a single-byte-per-character, length-payload string to a QString.

The byte sequence will be: LEN C0 C1 C2 C3...

Obviously this will only hold up to 255 characters. By default, we interpret the bytes using Windows-1252, as that's the most likely candidate for OCAD files in the wild.

◆ convertPoint()

void OpenOrienteering::OCAD8FileImport::convertPoint ( MapCoord c,
s32  ocad_x,
s32  ocad_y 
)
protected

◆ convertRotation()

float OpenOrienteering::OCAD8FileImport::convertRotation ( int  angle)
protected

◆ convertSize()

qint32 OpenOrienteering::OCAD8FileImport::convertSize ( int  ocad_size)
protected

◆ convertTemplateScale()

double OpenOrienteering::OCAD8FileImport::convertTemplateScale ( double  ocad_scale)
protected

◆ convertWideCString()

QString OpenOrienteering::OCAD8FileImport::convertWideCString ( const char *  p,
std::size_t  n,
bool  ignore_first_newline 
)
protected

Converts a two-byte-per-character, zero-terminated string to a QString.

By default, we interpret the bytes using UTF-16LE, as that's the most likely candidate for OCAD files in the wild.

The byte sequence will be: L0 H0 L1 H1 L2 H2... 00 00. n describes the maximum length (in bytes) that will be scanned for a zero terminator; if none is found, the string will be truncated at that location.

◆ fillCommonSymbolFields()

void OpenOrienteering::OCAD8FileImport::fillCommonSymbolFields ( Symbol symbol,
const OCADSymbol *  ocad_symbol 
)
protected

◆ fillPathCoords()

void OpenOrienteering::OCAD8FileImport::fillPathCoords ( Object object,
bool  is_area,
u16  npts,
const OCADPoint *  pts 
)
protected

Translates the OCAD path given in the last two arguments into an Object.

◆ fillTextPathCoords()

bool OpenOrienteering::OCAD8FileImport::fillTextPathCoords ( TextObject object,
TextSymbol symbol,
u16  npts,
OCADPoint *  pts 
)
protected

Translates an OCAD text object path into a Mapper text object specifier, if possible.

If successful, sets either 1 or 2 coordinates in the text object and returns true. If the OCAD path was not importable, leaves the TextObject alone and returns false.

◆ importAreaSymbol()

Symbol * OpenOrienteering::OCAD8FileImport::importAreaSymbol ( const OCADAreaSymbol *  ocad_symbol)
protected

◆ importBackground()

OCADBackground OpenOrienteering::OCAD8FileImport::importBackground ( const QByteArray data)
protected

◆ importImplementation()

bool OpenOrienteering::OCAD8FileImport::importImplementation ( )
overrideprotectedvirtual

Actual implementation of the import.

This function shall read the input and populate the map and view from it. Importers which support input from QIODevice should use the device(). They must not open or close this device.

If information might be lost in the process, a message shall be recorded by calling addWarning() with a translated, useful description of the issue. If a fatal error is encountered, then this method may either throw an exception, or log an error message with addWarning() and return false. The line between errors and warnings is somewhat of a judgement call on the part of the author, but generally an Importer should not succeed unless the map is populated sufficiently to be useful.

Implements OpenOrienteering::Importer.

◆ importLineSymbol()

Symbol * OpenOrienteering::OCAD8FileImport::importLineSymbol ( const OCADLineSymbol *  ocad_symbol)
protected

◆ importObject()

Object * OpenOrienteering::OCAD8FileImport::importObject ( const OCADObject *  ocad_object,
MapPart part 
)
protected

◆ importPattern()

PointSymbol * OpenOrienteering::OCAD8FileImport::importPattern ( s16  npts,
OCADPoint *  pts 
)
protected

◆ importPointSymbol()

Symbol * OpenOrienteering::OCAD8FileImport::importPointSymbol ( const OCADPointSymbol *  ocad_symbol)
protected

◆ importRasterTemplate()

Template * OpenOrienteering::OCAD8FileImport::importRasterTemplate ( const OCADBackground background)
protected
Deprecated:
Replaced by Template importTemplate(OCADCString string).

◆ importRectangleObject()

bool OpenOrienteering::OCAD8FileImport::importRectangleObject ( const OCADObject *  ocad_object,
MapPart part,
const RectangleInfo &  rect 
)
protected

◆ importRectSymbol()

OCAD8FileImport::RectangleInfo * OpenOrienteering::OCAD8FileImport::importRectSymbol ( const OCADRectSymbol *  ocad_symbol)
protected

◆ importString()

void OpenOrienteering::OCAD8FileImport::importString ( OCADStringEntry *  entry)
protectedvirtual

◆ importTemplate()

Template * OpenOrienteering::OCAD8FileImport::importTemplate ( OCADCString *  ocad_str)
protected

◆ importTextSymbol()

Symbol * OpenOrienteering::OCAD8FileImport::importTextSymbol ( const OCADTextSymbol *  ocad_symbol)
protected

◆ isRasterImageFile()

bool OpenOrienteering::OCAD8FileImport::isRasterImageFile ( const QString filename)
staticprotected

◆ setPathHolePoint()

void OpenOrienteering::OCAD8FileImport::setPathHolePoint ( Object object,
int  i 
)
protected

◆ setStringEncodings()

void OpenOrienteering::OCAD8FileImport::setStringEncodings ( const char *  narrow,
const char *  wide = "UTF-16LE" 
)

Friends And Related Function Documentation

◆ OcdFileImport

friend class OcdFileImport
friend

The documentation for this class was generated from the following files: