Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVDFMTF_HXX
30 : : #define _SVDFMTF_HXX
31 : :
32 : : #include <tools/contnr.hxx>
33 : : #include <vcl/metaact.hxx>
34 : : #include <vcl/virdev.hxx>
35 : : #include <svx/svdobj.hxx>
36 : :
37 : : //************************************************************
38 : : // Forward Declarations
39 : : //************************************************************
40 : :
41 : : class SfxItemSet;
42 : : class SdrObjList;
43 : : class SdrModel;
44 : : class SdrPage;
45 : : class SdrObject;
46 : : class SvdProgressInfo;
47 : :
48 : : //************************************************************
49 : : // Helper Class SdrObjRefList
50 : : //************************************************************
51 : :
52 : 0 : class SdrObjRefList
53 : : {
54 : : std::vector<SdrObject*> aList;
55 : : public:
56 : :
57 : 0 : SdrObjRefList()
58 : 0 : : aList()
59 : 0 : {}
60 : :
61 : : void Clear() { aList.clear(); }
62 : 0 : sal_uLong GetObjCount() const { return aList.size(); }
63 : 0 : SdrObject* GetObj(sal_uLong nNum) const { return aList[nNum]; }
64 : : SdrObject* operator[](sal_uLong nNum) const { return aList[nNum]; }
65 : 0 : void InsertObject(SdrObject* pObj) { aList.push_back(pObj); }
66 : : void InsertObject(SdrObject* pObj, sal_uLong nPos)
67 : : {
68 : : if(nPos==CONTAINER_APPEND)
69 : : aList.push_back(pObj);
70 : : else
71 : : aList.insert(aList.begin() + nPos, pObj);
72 : : }
73 : : void RemoveObject(sal_uLong nPos) { aList.erase(aList.begin()+nPos); }
74 : : };
75 : :
76 : : //************************************************************
77 : : // Helper Class ImpSdrGDIMetaFileImport
78 : : //************************************************************
79 : :
80 : : class ImpSdrGDIMetaFileImport
81 : : {
82 : : protected:
83 : : SdrObjRefList aTmpList;
84 : : VirtualDevice aVD;
85 : : Rectangle aScaleRect;
86 : : sal_uLong nMapScalingOfs; // from here on, not edited with MapScaling
87 : : SfxItemSet* pLineAttr;
88 : : SfxItemSet* pFillAttr;
89 : : SfxItemSet* pTextAttr;
90 : : SdrPage* pPage;
91 : : SdrModel* pModel;
92 : : SdrLayerID nLayer;
93 : : Color aOldLineColor;
94 : : sal_Int32 nLineWidth;
95 : : basegfx::B2DLineJoin maLineJoin;
96 : : XDash maDash;
97 : :
98 : : sal_Bool bMov;
99 : : sal_Bool bSize;
100 : : Point aOfs;
101 : : double fScaleX;
102 : : double fScaleY;
103 : : Fraction aScaleX;
104 : : Fraction aScaleY;
105 : :
106 : : sal_Bool bFntDirty;
107 : :
108 : : // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
109 : : sal_Bool bLastObjWasPolyWithoutLine;
110 : : sal_Bool bNoLine;
111 : : sal_Bool bNoFill;
112 : :
113 : : // to optimize multiple lines into a Polyline
114 : : sal_Bool bLastObjWasLine;
115 : :
116 : : protected:
117 : : void DoAction(MetaPixelAction & rAct) const;
118 : : void DoAction(MetaPointAction & rAct) const;
119 : : void DoAction(MetaLineAction & rAct);
120 : : void DoAction(MetaRectAction & rAct);
121 : : void DoAction(MetaRoundRectAction & rAct);
122 : : void DoAction(MetaEllipseAction & rAct);
123 : : void DoAction(MetaArcAction & rAct);
124 : : void DoAction(MetaPieAction & rAct);
125 : : void DoAction(MetaChordAction & rAct);
126 : : void DoAction(MetaPolyLineAction & rAct);
127 : : void DoAction(MetaPolygonAction & rAct);
128 : : void DoAction(MetaPolyPolygonAction & rAct);
129 : : void DoAction(MetaTextAction & rAct);
130 : : void DoAction(MetaTextArrayAction & rAct);
131 : : void DoAction(MetaStretchTextAction & rAct);
132 : : void DoAction(MetaBmpAction & rAct);
133 : : void DoAction(MetaBmpScaleAction & rAct);
134 : : void DoAction(MetaBmpExAction & rAct);
135 : : void DoAction(MetaBmpExScaleAction & rAct);
136 : : void DoAction(MetaHatchAction & rAct);
137 : : void DoAction(MetaLineColorAction & rAct);
138 : : void DoAction(MetaMapModeAction & rAct);
139 : 0 : void DoAction(MetaFillColorAction & rAct) { rAct.Execute(&aVD); }
140 : 0 : void DoAction(MetaTextColorAction & rAct) { rAct.Execute(&aVD); }
141 : 0 : void DoAction(MetaTextFillColorAction & rAct) { rAct.Execute(&aVD); }
142 : 0 : void DoAction(MetaFontAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
143 : 0 : void DoAction(MetaTextAlignAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
144 : 0 : void DoAction(MetaClipRegionAction & rAct) { rAct.Execute(&aVD); }
145 : 0 : void DoAction(MetaRasterOpAction & rAct) { rAct.Execute(&aVD); }
146 : 0 : void DoAction(MetaPushAction & rAct) { rAct.Execute(&aVD); }
147 : 0 : void DoAction(MetaPopAction & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
148 : 0 : void DoAction(MetaMoveClipRegionAction & rAct) { rAct.Execute(&aVD); }
149 : 0 : void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); }
150 : 0 : void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); }
151 : : void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
152 : : void DoAction(MetaRenderGraphicAction& rAct);
153 : :
154 : : void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
155 : : void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
156 : : void InsertObj( SdrObject* pObj, sal_Bool bScale = sal_True );
157 : : void MapScaling();
158 : :
159 : : // #i73407# reformulation to use new B2DPolygon classes
160 : : bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
161 : : bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
162 : :
163 : : public:
164 : : ImpSdrGDIMetaFileImport(SdrModel& rModel);
165 : : ~ImpSdrGDIMetaFileImport();
166 : : sal_uLong DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, sal_uLong nInsPos=CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
167 : 0 : void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
168 : : SdrLayerID GetLayer() const { return nLayer; }
169 : 0 : void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
170 : : const Rectangle& GetScaleRect() const { return aScaleRect; }
171 : : };
172 : :
173 : : #endif //_SVDFMTF_HXX
174 : :
175 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|