xref: /AOO41X/main/svx/source/svdraw/svdfmtf.hxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
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 protected:
105     void DoAction(MetaPixelAction           & rAct);
106     void DoAction(MetaPointAction           & rAct);
107     void DoAction(MetaLineAction            & rAct);
108     void DoAction(MetaRectAction            & rAct);
109     void DoAction(MetaRoundRectAction       & rAct);
110     void DoAction(MetaEllipseAction         & rAct);
111     void DoAction(MetaArcAction             & rAct);
112     void DoAction(MetaPieAction             & rAct);
113     void DoAction(MetaChordAction           & rAct);
114     void DoAction(MetaPolyLineAction        & rAct);
115     void DoAction(MetaPolygonAction         & rAct);
116     void DoAction(MetaPolyPolygonAction     & rAct);
117     void DoAction(MetaTextAction            & rAct);
118     void DoAction(MetaTextArrayAction       & rAct);
119     void DoAction(MetaStretchTextAction     & rAct);
120     void DoAction(MetaBmpAction             & rAct);
121     void DoAction(MetaBmpScaleAction        & rAct);
122     void DoAction(MetaBmpExAction           & rAct);
123     void DoAction(MetaBmpExScaleAction      & rAct);
124     void DoAction(MetaHatchAction           & rAct);
125     void DoAction(MetaLineColorAction       & rAct);
126     void DoAction(MetaMapModeAction         & rAct);
127     void DoAction(MetaFillColorAction       & rAct) { rAct.Execute(&aVD); }
128     void DoAction(MetaTextColorAction       & rAct) { rAct.Execute(&aVD); }
129     void DoAction(MetaTextFillColorAction   & rAct) { rAct.Execute(&aVD); }
130     void DoAction(MetaFontAction            & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
131     void DoAction(MetaTextAlignAction       & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
132     void DoAction(MetaClipRegionAction      & rAct) { rAct.Execute(&aVD); }
133     void DoAction(MetaRasterOpAction        & rAct) { rAct.Execute(&aVD); }
134     void DoAction(MetaPushAction            & rAct) { rAct.Execute(&aVD); }
135     void DoAction(MetaPopAction             & rAct) { rAct.Execute(&aVD); bFntDirty=sal_True; }
136     void DoAction(MetaMoveClipRegionAction  & rAct) { rAct.Execute(&aVD); }
137     void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); }
138     void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); }
139     void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
140 
141     void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
142     void SetAttributes(SdrObject* pObj, FASTBOOL bForceTextAttr=sal_False);
143     void InsertObj( SdrObject* pObj, sal_Bool bScale = sal_True );
144     void MapScaling();
145 
146     // #i73407# reformulation to use new B2DPolygon classes
147     bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
148     bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
149 
150 public:
151     ImpSdrGDIMetaFileImport(SdrModel& rModel);
152     ~ImpSdrGDIMetaFileImport();
153     sal_uLong DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, sal_uLong nInsPos=CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
154     void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
155     SdrLayerID GetLayer() const { return nLayer; }
156     void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
157     const Rectangle& GetScaleRect() const { return aScaleRect; }
158 };
159 
160 ////////////////////////////////////////////////////////////////////////////////////////////////////
161 
162 #endif //_SVDFMTF_HXX
163 // eof
164