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 #pragma once
#define SVMENUMS_H
/**
Namespace for StarView Metafile (SVM) classes
*/
namespace MetaFile namespace MetaFile
{ {
/**
Action types
See the SPEC Section 2.1.1.1
*/
enum ActionType enum ActionType
{ {
META_NULL_ACTION = 0, META_NULL_ACTION = 0,
...@@ -69,13 +61,8 @@ namespace MetaFile ...@@ -69,13 +61,8 @@ namespace MetaFile
META_COMMENT_ACTION = 512 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 enum MtfType
{ {
MTF_CONVERSION_NONE = 0, MTF_CONVERSION_NONE = 0,
...@@ -83,17 +70,6 @@ namespace MetaFile ...@@ -83,17 +70,6 @@ namespace MetaFile
MTF_CONVERSION_8BIT_GREYS = 2 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_NONE = 0x00000000,
...@@ -103,6 +79,3 @@ namespace MetaFile ...@@ -103,6 +79,3 @@ namespace MetaFile
} }
#endif
// Own
#include "SvmFile.h" #include "SvmFile.h"
#include <string> #include <string>
...@@ -9,13 +8,10 @@ ...@@ -9,13 +8,10 @@
#ifdef _DEBUG #ifdef _DEBUG
#include <iostream> #include <iostream>
#endif #endif
// MetaFile
#include "SvmEnums.h" #include "SvmEnums.h"
#include "SvmObjects.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 #define DEBUG_CSvmParser 0
namespace MetaFile namespace MetaFile
...@@ -360,15 +356,9 @@ void CSvmFile::Read_META_SETMAPMODE() ...@@ -360,15 +356,9 @@ void CSvmFile::Read_META_SETMAPMODE()
{ {
MapMode mapMode; MapMode mapMode;
m_oStream >> 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); m_pDC->SetMapMode(mapMode);
UpdateOutputDC(); UpdateOutputDC();
} }
void CSvmFile::Read_META_TEXT_A() void CSvmFile::Read_META_TEXT_A()
......
/* This file is part of the Calligra project #pragma once
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
#include "SvmPlayer.h" #include "SvmPlayer.h"
...@@ -519,5 +499,3 @@ class CSvmFile : virtual public IMetaFileBase ...@@ -519,5 +499,3 @@ class CSvmFile : virtual public IMetaFileBase
}; };
#endif
...@@ -203,11 +203,11 @@ CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p) ...@@ -203,11 +203,11 @@ CDataStream& operator>>(CDataStream &stream, TSvmPolygon &p)
} }
CDataStream& operator>>(CDataStream &stream, TSvmColor &c) CDataStream& operator>>(CDataStream &stream, TSvmColor &c)
{ {
stream >> c.r;
stream >> c.g;
stream >> c.b; stream >> c.b;
unsigned char reserv; stream >> c.g;
stream >> reserv; stream >> c.r;
stream >> c.a;
return stream; return stream;
} }
......
...@@ -68,6 +68,15 @@ struct TSvmSize ...@@ -68,6 +68,15 @@ struct TSvmSize
unsigned int cx; unsigned int cx;
unsigned int cy; 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 struct MapMode
{ {
MapMode(); MapMode();
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "SvmFile.h" #include "SvmFile.h"
// MetaFile // MetaFile
#include "SvmEnums.h" #include "SvmEnums.h"
#include "SvmObjects.h" #include "SvmObjects.h"
...@@ -79,9 +78,6 @@ void CSvmPlayer::Clear() ...@@ -79,9 +78,6 @@ void CSvmPlayer::Clear()
m_vAvailableIndexes.clear(); m_vAvailableIndexes.clear();
InitStockObjects(); InitStockObjects();
SelectObject(0x00000000); // BLACK_PEN
SelectObject(0x00000001); // WHITE_BRUSH
} }
void CSvmPlayer::SelectObject(unsigned short ushIndex) void CSvmPlayer::SelectObject(unsigned short ushIndex)
{ {
...@@ -171,10 +167,12 @@ void CSvmPlayer::RegisterObject(CSvmObjectBase* pObject) ...@@ -171,10 +167,12 @@ void CSvmPlayer::RegisterObject(CSvmObjectBase* pObject)
if (ushIndex == m_ushIndex) if (ushIndex == m_ushIndex)
m_ushIndex++; m_ushIndex++;
SelectObject(m_ushIndex-1);
} }
void CSvmPlayer::InitStockObjects() void CSvmPlayer::InitStockObjects()
{ {
InitStockBrush(false, 0x40, 0x40, 0x40); InitStockBrush(false, 79, 129, 189); //default OnlyOffice
InitStockPen(false, 0x00, 0x00, 0x00); InitStockPen(false, 0x00, 0x00, 0x00);
} }
void CSvmPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b) 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 ...@@ -213,7 +211,7 @@ void CSvmPlayer::InitStockPen(bool bNull, unsigned char r, unsigned char g, u
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
CSvmDC::CSvmDC() CSvmDC::CSvmDC()
{ {
m_ulMapMode = MM_TEXT; m_ulMapMode = MAP_POINT;
m_pBrush = NULL; m_pBrush = NULL;
m_pPen = NULL; m_pPen = NULL;
m_pFont = NULL; m_pFont = NULL;
...@@ -270,56 +268,60 @@ CSvmDC* CSvmDC::Copy() ...@@ -270,56 +268,60 @@ CSvmDC* CSvmDC::Copy()
} }
void CSvmDC::SetMapMode(MapMode & mapMode) void CSvmDC::SetMapMode(MapMode & mapMode)
{ {
m_ulMapMode = mapMode.isSimple ? MM_TWIPS : MM_TWIPS; m_ulMapMode = (ESvmMapUnit)mapMode.unit;
switch (m_ulMapMode) switch (m_ulMapMode)
{ {
case MM_TEXT: // 1 unit = 1pt case MAP_MM: // 1 unit = 1 mm
{
SetPixelWidth(1);
SetPixelHeight(1);
break;
}
case MM_LOMETRIC: // 1 unit = 0.1mm
{ {
double dPixel = 0.1 * 72 / 25.4; double dPixel = 1. * 72 / 25.4;
SetPixelWidth(dPixel); SetPixelWidth(dPixel);
SetPixelHeight(dPixel); SetPixelHeight(dPixel);
break; }break;
} case MAP_CM: // 1 unit = 1 cm = 10 mm
case MM_HIMETRIC: // 1 unit = 0.01mm
{ {
double dPixel = 0.01 * 72 / 25.4; double dPixel = 10. * 72 / 25.4;
SetPixelWidth(dPixel); SetPixelWidth(dPixel);
SetPixelHeight(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; break;
} case MAP_INCH: // 1 unit = 1 inch
case MM_LOENGLISH: // 1 unit = 0.01 inch
{ {
double dPixel = 0.01 * 72; double dPixel = 1. * 72;
SetPixelWidth(dPixel); SetPixelWidth(dPixel);
SetPixelHeight(dPixel); SetPixelHeight(dPixel);
break; }break;
} case MAP_POINT:
case MM_HIENGLISH: // 1 unit = 0.001 inch
{ {
double dPixel = 0.001 * 72; SetPixelWidth(1);
SetPixelWidth(dPixel); SetPixelHeight(1);
SetPixelHeight(dPixel); }break;
break; case MAP_TWIP: // 1 unit = 1/1440 inch
}
case MM_TWIPS: // 1 unit = 1/1440 inch
{ {
SetPixelWidth(0.05); SetPixelWidth(0.05);
SetPixelHeight(0.05); SetPixelHeight(0.05);
break; }break;
} case MAP_PIXEL:
case MM_ISOTROPIC:
case MM_ANISOTROPIC:
{ {
double dPixel = 1. * 3. /4.;
SetPixelWidth(dPixel);
SetPixelHeight(dPixel);
}break;
case MAP_SYSFONT:
case MAP_APPFONT:
//
break;
case MAP_RELATIVE:
UpdatePixelMetrics(); UpdatePixelMetrics();
break; break;
} case MAP_LASTENUMDUMMY:
break;
} }
} }
...@@ -452,12 +454,14 @@ void CSvmDC::SetWindowOrigin(TSvmPoint& oPoint) ...@@ -452,12 +454,14 @@ void CSvmDC::SetWindowOrigin(TSvmPoint& oPoint)
{ {
m_oWindow.lX = oPoint.x; m_oWindow.lX = oPoint.x;
m_oWindow.lY = oPoint.y; m_oWindow.lY = oPoint.y;
UpdatePixelMetrics(); UpdatePixelMetrics();
} }
void CSvmDC::SetWindowExtents(TSvmSize& oPoint) void CSvmDC::SetWindowExtents(TSvmSize& oPoint)
{ {
m_oWindow.ulW = oPoint.cx; m_oWindow.ulW = oPoint.cx;
m_oWindow.ulH = oPoint.cy; m_oWindow.ulH = oPoint.cy;
UpdatePixelMetrics(); UpdatePixelMetrics();
} }
TSvmWindow* CSvmDC::GetWindow() TSvmWindow* CSvmDC::GetWindow()
...@@ -468,12 +472,14 @@ void CSvmDC::SetViewportOrigin(TSvmPoint& oPoint) ...@@ -468,12 +472,14 @@ void CSvmDC::SetViewportOrigin(TSvmPoint& oPoint)
{ {
m_oViewport.lX = oPoint.x; m_oViewport.lX = oPoint.x;
m_oViewport.lY = oPoint.y; m_oViewport.lY = oPoint.y;
UpdatePixelMetrics(); UpdatePixelMetrics();
} }
void CSvmDC::SetViewportExtents(TSvmSize& oPoint) void CSvmDC::SetViewportExtents(TSvmSize& oPoint)
{ {
m_oViewport.ulW = oPoint.cx; m_oViewport.ulW = oPoint.cx;
m_oViewport.ulH = oPoint.cy; m_oViewport.ulH = oPoint.cy;
UpdatePixelMetrics(); UpdatePixelMetrics();
} }
TSvmWindow* CSvmDC::GetViewport() TSvmWindow* CSvmDC::GetViewport()
......
#pragma once
#ifndef CSvmPlayer_H
#define CSvmPlayer_H
#include "SvmEnums.h" #include "SvmEnums.h"
#include "SvmObjects.h" #include "SvmObjects.h"
...@@ -111,7 +108,7 @@ private: ...@@ -111,7 +108,7 @@ private:
private: private:
unsigned int m_ulMapMode; ESvmMapUnit m_ulMapMode;
CSvmBrush* m_pBrush; CSvmBrush* m_pBrush;
CSvmPen* m_pPen; CSvmPen* m_pPen;
CSvmFont* m_pFont; CSvmFont* m_pFont;
...@@ -136,6 +133,3 @@ private: ...@@ -136,6 +133,3 @@ private:
}; };
} }
\ No newline at end of file
#endif
...@@ -491,7 +491,7 @@ ...@@ -491,7 +491,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" 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)" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;$(NOINHERIT)"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" 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