xref: /trunk/main/svx/source/svdraw/svdfmtf.hxx (revision 47a7c0c1)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDFMTF_HXX
25 #define _SVDFMTF_HXX
26 
27 #include <vcl/metaact.hxx>
28 #include <vcl/virdev.hxx>
29 #include <svx/svdobj.hxx>
30 
31 //************************************************************
32 //   Vorausdeklarationen
33 //************************************************************
34 
35 class SfxItemSet;
36 class SdrObjList;
37 class SdrModel;
38 class SdrPage;
39 class SdrObject;
40 class SvdProgressInfo;
41 
42 //************************************************************
43 //   Hilfsklasse SdrObjRefList
44 //************************************************************
45 
46 class SdrObjRefList
47 {
48 	Container					aList;
49 public:
50 
51 	SdrObjRefList()
52 	:	aList(1024,64,64)
53 	{}
54 
55 	void Clear() { aList.Clear(); }
56 	sal_uLong GetObjCount() const { return aList.Count(); }
57 	SdrObject* GetObj(sal_uLong nNum) const { return (SdrObject*)aList.GetObject(nNum); }
58 	SdrObject* operator[](sal_uLong nNum) const { return (SdrObject*)aList.GetObject(nNum); }
59 	void InsertObject(SdrObject* pObj, sal_uLong nPos=CONTAINER_APPEND) { aList.Insert(pObj,nPos); }
60 	void RemoveObject(sal_uLong nPos) { aList.Remove(nPos); }
61 };
62 
63 //************************************************************
64 //   Hilfsklasse ImpSdrGDIMetaFileImport
65 //************************************************************
66 
67 class ImpSdrGDIMetaFileImport
68 {
69 protected:
70 	SdrObjRefList				aTmpList;
71 	VirtualDevice				aVD;
72 	Rectangle					aScaleRect;
73 	sal_uLong						nMapScalingOfs; // ab hier nocht nicht mit MapScaling bearbeitet
74 	SfxItemSet*					pLineAttr;
75 	SfxItemSet*					pFillAttr;
76 	SfxItemSet*					pTextAttr;
77 	SdrPage*					pPage;
78 	SdrModel*					pModel;
79 	SdrLayerID					nLayer;
80 	Color						aOldLineColor;
81 	sal_Int32					nLineWidth;
82 	basegfx::B2DLineJoin		maLineJoin;
83 	com::sun::star::drawing::LineCap    maLineCap;
84 	XDash						maDash;
85 
86 	sal_Bool					bMov;
87 	sal_Bool					bSize;
88 	Point						aOfs;
89     double                      fScaleX;
90     double                      fScaleY;
91 	Fraction					aScaleX;
92 	Fraction					aScaleY;
93 
94 	sal_Bool                    bFntDirty;
95 
96 	// fuer Optimierung von (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> aus 2 mach ein
97 	sal_Bool                    bLastObjWasPolyWithoutLine;
98 	sal_Bool                    bNoLine;
99 	sal_Bool                    bNoFill;
100 
101 	// fuer Optimierung mehrerer Linien zu einer Polyline
102 	sal_Bool                    bLastObjWasLine;
103 
104     // clipregion
105     basegfx::B2DPolyPolygon     maClip;
106 
107 protected:
108     // ckeck for clip and evtl. fill maClip
109     void checkClip();
110     bool isClip() const;
111 
112     // actions
113 	void DoAction(MetaPixelAction			& rAct);
114 	void DoAction(MetaPointAction			& rAct);
115 	void DoAction(MetaLineAction			& rAct);
116 	void DoAction(MetaRectAction			& rAct);
117 	void DoAction(MetaRoundRectAction		& rAct);
118 	void DoAction(MetaEllipseAction			& rAct);
119 	void DoAction(MetaArcAction				& rAct);
120 	void DoAction(MetaPieAction				& rAct);
121 	void DoAction(MetaChordAction			& rAct);
122 	void DoAction(MetaPolyLineAction		& rAct);
123 	void DoAction(MetaPolygonAction			& rAct);
124 	void DoAction(MetaPolyPolygonAction		& rAct);
125 	void DoAction(MetaTextAction			& rAct);
126 	void DoAction(MetaTextArrayAction		& rAct);
127 	void DoAction(MetaStretchTextAction		& rAct);
128 	void DoAction(MetaBmpAction				& rAct);
129 	void DoAction(MetaBmpScaleAction		& rAct);
130 	void DoAction(MetaBmpExAction			& rAct);
131 	void DoAction(MetaBmpExScaleAction		& rAct);
132 	void DoAction(MetaHatchAction			& rAct);
133 	void DoAction(MetaLineColorAction		& rAct);
134 	void DoAction(MetaMapModeAction			& rAct);
135 	void DoAction(MetaFillColorAction		& rAct) { rAct.Execute(&aVD); }
136 	void DoAction(MetaTextColorAction		& rAct) { rAct.Execute(&aVD); }
137 	void DoAction(MetaTextFillColorAction	& rAct) { rAct.Execute(&aVD); }
138 	void DoAction(MetaFontAction			& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
139 	void DoAction(MetaTextAlignAction		& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
140 	void DoAction(MetaClipRegionAction		& rAct) { rAct.Execute(&aVD); checkClip(); }
141 	void DoAction(MetaRasterOpAction		& rAct) { rAct.Execute(&aVD); }
142 	void DoAction(MetaPushAction			& rAct) { rAct.Execute(&aVD); checkClip(); }
143 	void DoAction(MetaPopAction				& rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; checkClip(); }
144 	void DoAction(MetaMoveClipRegionAction	& rAct) { rAct.Execute(&aVD); checkClip(); }
145 	void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); checkClip(); }
146 	void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); checkClip(); }
147 	void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
148 
149 	void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
150 	void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=sal_False);
151 	void InsertObj( SdrObject* pObj, sal_Bool bScale = sal_True );
152 	void MapScaling();
153 
154 	// #i73407# reformulation to use new B2DPolygon classes
155 	bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
156 	bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
157 
158 public:
159 	ImpSdrGDIMetaFileImport(SdrModel& rModel);
160 	~ImpSdrGDIMetaFileImport();
161 	sal_uLong DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, sal_uLong nInsPos=CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
162 	void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
163 	SdrLayerID GetLayer() const { return nLayer; }
164 	void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
165 	const Rectangle& GetScaleRect() const { return aScaleRect; }
166 };
167 
168 ////////////////////////////////////////////////////////////////////////////////////////////////////
169 
170 #endif //_SVDFMTF_HXX
171 // eof
172