Commit 6ed592a6 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

SvmFile new

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62706 954022d7-b5bf-4e40-9824-e11837661b57
parent a5188a04
/*
Copyright 2009 Inge Wallin <inge@lysator.liu.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CSvmAbstractPlayer_H
#define CSvmAbstractPlayer_H
#include "SvmEnums.h"
#include "SvmStructs.h"
#include "SvmGraphicsContext.h"
class TPoint;
class TRect;
class TPolygon;
class TString;
/**
\file
Primary definitions for SVM output backend
*/
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile
{
/**
Abstract output strategy for SVM Parser
*/
class CSvmAbstractPlayer
{
public:
CSvmAbstractPlayer() {};
virtual ~CSvmAbstractPlayer() {};
/**
Initialisation routine
\param header the SVM Header record
*/
virtual void init(const SvmHeader &header) = 0;
/**
Cleanup routine
This function is called when the painting is done. Any
initializations that are done in init() can be undone here if
necessary.
\param header the SVM Header record
*/
virtual void cleanup( /*const Header *header*/ ) = 0;
/**
Close-out routine
*/
virtual void eof() = 0;
virtual void rect( SvmGraphicsContext &context, const TRect &rect ) = 0;
/**
Handler META_POLYLINE_ACTION
This action type specifies how to output a multi-segment line
(unfilled polyline).
\param context the graphics context to be used when drawing the polyline
\param polygon the sequence of points that describe the line
\note the line is not meant to be closed (i.e. do not connect
the last point to the first point) or filled.
*/
virtual void polyLine(SvmGraphicsContext &context, const TPolygon &polyline) = 0;
virtual void polygon(SvmGraphicsContext &context, const TPolygon &polygon) = 0;
virtual void textArray(SvmGraphicsContext &context,
const TPoint &point, const std::wstring & string) = 0;
};
}
#endif
#ifndef SVMENUMS_H
#define SVMENUMS_H
#pragma once
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile
{
/**
Action types
See the SPEC Section 2.1.1.1
*/
enum ActionType
{
META_NULL_ACTION = 0,
......@@ -69,13 +61,8 @@ namespace MetaFile
META_COMMENT_ACTION = 512
};
#define META_LAST_ACTION 153 //META_SVG_SOMETHING_ACTION
#define META_LAST_ACTION 153
/**
Mtf (FIXME)
See the SPEC Section 2.1.1.2
*/
enum MtfType
{
MTF_CONVERSION_NONE = 0,
......@@ -83,18 +70,7 @@ namespace MetaFile
MTF_CONVERSION_8BIT_GREYS = 2
};
// ----------------------------------------------------------------
// Flags
// ----------------------------------------------------------------
/**
Mirror flags
See the SPEC Section 2.1.2.1
*/
enum MtfMirrorType
enum MtfMirrorType
{
MTF_MIRROR_NONE = 0x00000000,
MTF_MIRROR_HORZ = 0x00000001,
......@@ -103,6 +79,3 @@ namespace MetaFile
}
#endif
// Own
#include "SvmFile.h"
#include <string>
......@@ -9,13 +8,10 @@
#ifdef _DEBUG
#include <iostream>
#endif
// MetaFile
#include "SvmEnums.h"
#include "SvmObjects.h"
// 0 - No debug
// 1 - Print a lot of debug info
// 2 - Just print all the records instead of parsing them
#define DEBUG_CSvmParser 0
namespace MetaFile
......@@ -360,15 +356,9 @@ void CSvmFile::Read_META_SETMAPMODE()
{
MapMode mapMode;
m_oStream >> mapMode;
////kDebug(31000) << "mapMode:" << "Origin" << mContext.mapMode.origin
// << "scaleX"
// << mContext.mapMode.scaleX.numerator << mContext.mapMode.scaleX.numerator
// << (qreal(mContext.mapMode.scaleX.numerator) / mContext.mapMode.scaleX.numerator)
// << "scaleY"
// << mContext.mapMode.scaleY.numerator << mContext.mapMode.scaleY.numerator
// << (qreal(mContext.mapMode.scaleX.numerator) / mContext.mapMode.scaleX.numerator);
m_pDC->SetMapMode(mapMode);
UpdateOutputDC();
}
void CSvmFile::Read_META_TEXT_A()
......
/* This file is part of the Calligra project
Copyright 2011 Inge Wallin <inge@lysator.liu.se>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SVMPARSER_H
#define SVMPARSER_H
#pragma once
#include "SvmPlayer.h"
......@@ -519,5 +499,3 @@ class CSvmFile : virtual public IMetaFileBase
};
#endif
......@@ -203,11 +203,11 @@ CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p)
}
CDataStream& operator>>(CDataStream &stream, TSvmColor &c)
{
stream >> c.r;
stream >> c.g;
stream >> c.b;
unsigned char reserv;
stream >> reserv;
stream >> c.g;
stream >> c.r;
stream >> c.a;
return stream;
}
......
......@@ -68,6 +68,15 @@ struct TSvmSize
unsigned int cx;
unsigned int cy;
};
enum ESvmMapUnit
{
MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM,
MAP_1000TH_INCH, MAP_100TH_INCH, MAP_10TH_INCH, MAP_INCH,
MAP_POINT, MAP_TWIP, MAP_PIXEL, MAP_SYSFONT, MAP_APPFONT,
MAP_RELATIVE, /*MAP_REALAPPFONT,*/ MAP_LASTENUMDUMMY
};
struct MapMode
{
MapMode();
......
......@@ -3,7 +3,6 @@
#include "SvmFile.h"
// MetaFile
#include "SvmEnums.h"
#include "SvmObjects.h"
......@@ -79,9 +78,6 @@ void CSvmPlayer::Clear()
m_vAvailableIndexes.clear();
InitStockObjects();
SelectObject(0x00000000); // BLACK_PEN
SelectObject(0x00000001); // WHITE_BRUSH
}
void CSvmPlayer::SelectObject(unsigned short ushIndex)
{
......@@ -171,10 +167,12 @@ void CSvmPlayer::RegisterObject(CSvmObjectBase* pObject)
if (ushIndex == m_ushIndex)
m_ushIndex++;
SelectObject(m_ushIndex-1);
}
void CSvmPlayer::InitStockObjects()
{
InitStockBrush(false, 0x40, 0x40, 0x40);
InitStockBrush(false, 79, 129, 189); //default OnlyOffice
InitStockPen(false, 0x00, 0x00, 0x00);
}
void CSvmPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b)
......@@ -213,7 +211,7 @@ void CSvmPlayer::InitStockPen(bool bNull, unsigned char r, unsigned char g, u
//----------------------------------------------------------------------------------------
CSvmDC::CSvmDC()
{
m_ulMapMode = MM_TEXT;
m_ulMapMode = MAP_POINT;
m_pBrush = NULL;
m_pPen = NULL;
m_pFont = NULL;
......@@ -270,56 +268,60 @@ CSvmDC* CSvmDC::Copy()
}
void CSvmDC::SetMapMode(MapMode & mapMode)
{
m_ulMapMode = mapMode.isSimple ? MM_TWIPS : MM_TWIPS;
m_ulMapMode = (ESvmMapUnit)mapMode.unit;
switch (m_ulMapMode)
{
case MM_TEXT: // 1 unit = 1pt
{
SetPixelWidth(1);
SetPixelHeight(1);
break;
}
case MM_LOMETRIC: // 1 unit = 0.1mm
{
double dPixel = 0.1 * 72 / 25.4;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
break;
}
case MM_HIMETRIC: // 1 unit = 0.01mm
{
double dPixel = 0.01 * 72 / 25.4;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
break;
}
case MM_LOENGLISH: // 1 unit = 0.01 inch
{
double dPixel = 0.01 * 72;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
break;
}
case MM_HIENGLISH: // 1 unit = 0.001 inch
{
double dPixel = 0.001 * 72;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
break;
}
case MM_TWIPS: // 1 unit = 1/1440 inch
{
SetPixelWidth(0.05);
SetPixelHeight(0.05);
break;
}
case MM_ISOTROPIC:
case MM_ANISOTROPIC:
{
UpdatePixelMetrics();
break;
}
case MAP_MM: // 1 unit = 1 mm
{
double dPixel = 1. * 72 / 25.4;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
}break;
case MAP_CM: // 1 unit = 1 cm = 10 mm
{
double dPixel = 10. * 72 / 25.4;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
}break;
case MAP_100TH_MM:
case MAP_10TH_MM:
case MAP_1000TH_INCH:
case MAP_100TH_INCH:
case MAP_10TH_INCH:
//
break;
case MAP_INCH: // 1 unit = 1 inch
{
double dPixel = 1. * 72;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
}break;
case MAP_POINT:
{
SetPixelWidth(1);
SetPixelHeight(1);
}break;
case MAP_TWIP: // 1 unit = 1/1440 inch
{
SetPixelWidth(0.05);
SetPixelHeight(0.05);
}break;
case MAP_PIXEL:
{
double dPixel = 1. * 3. /4.;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
}break;
case MAP_SYSFONT:
case MAP_APPFONT:
//
break;
case MAP_RELATIVE:
UpdatePixelMetrics();
break;
case MAP_LASTENUMDUMMY:
break;
}
}
......@@ -452,12 +454,14 @@ void CSvmDC::SetWindowOrigin(TSvmPoint& oPoint)
{
m_oWindow.lX = oPoint.x;
m_oWindow.lY = oPoint.y;
UpdatePixelMetrics();
}
void CSvmDC::SetWindowExtents(TSvmSize& oPoint)
{
m_oWindow.ulW = oPoint.cx;
m_oWindow.ulH = oPoint.cy;
UpdatePixelMetrics();
}
TSvmWindow* CSvmDC::GetWindow()
......@@ -468,12 +472,14 @@ void CSvmDC::SetViewportOrigin(TSvmPoint& oPoint)
{
m_oViewport.lX = oPoint.x;
m_oViewport.lY = oPoint.y;
UpdatePixelMetrics();
}
void CSvmDC::SetViewportExtents(TSvmSize& oPoint)
{
m_oViewport.ulW = oPoint.cx;
m_oViewport.ulH = oPoint.cy;
UpdatePixelMetrics();
}
TSvmWindow* CSvmDC::GetViewport()
......
#ifndef CSvmPlayer_H
#define CSvmPlayer_H
#pragma once
#include "SvmEnums.h"
#include "SvmObjects.h"
......@@ -111,7 +108,7 @@ private:
private:
unsigned int m_ulMapMode;
ESvmMapUnit m_ulMapMode;
CSvmBrush* m_pBrush;
CSvmPen* m_pPen;
CSvmFont* m_pFont;
......@@ -135,7 +132,4 @@ private:
unsigned int m_unArcDirection;
};
}
#endif
}
\ No newline at end of file
......@@ -491,7 +491,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
AdditionalIncludeDirectories="&quot;../freetype-2.5.2/include&quot;;&quot;../agg-2.4/include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;$(NOINHERIT)"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment