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 : :
30 : : #include "svdfmtf.hxx"
31 : : #include <editeng/editdata.hxx>
32 : : #include <math.h>
33 : : #include <svx/xpoly.hxx>
34 : : #include <vcl/svapp.hxx>
35 : : #include <editeng/eeitem.hxx>
36 : : #include <editeng/fhgtitem.hxx>
37 : : #include <editeng/wghtitem.hxx>
38 : : #include <editeng/postitem.hxx>
39 : : #include <editeng/udlnitem.hxx>
40 : : #include <editeng/crsditem.hxx>
41 : : #include <editeng/shdditem.hxx>
42 : : #include <svx/xlnclit.hxx>
43 : : #include <svx/xlnwtit.hxx>
44 : : #include <svx/xflclit.hxx>
45 : : #include <svx/xgrad.hxx>
46 : : #include <svx/xflgrit.hxx>
47 : : #include <editeng/fontitem.hxx>
48 : : #include <editeng/akrnitem.hxx>
49 : : #include <editeng/wrlmitem.hxx>
50 : : #include <editeng/cntritem.hxx>
51 : : #include <editeng/colritem.hxx>
52 : : #include <vcl/metric.hxx>
53 : : #include <editeng/charscaleitem.hxx>
54 : : #include <svx/xflhtit.hxx>
55 : : #include <svx/svdattr.hxx>
56 : : #include <svx/svdmodel.hxx>
57 : : #include <svx/svdpage.hxx>
58 : : #include <svx/svdobj.hxx>
59 : : #include "svx/svditext.hxx"
60 : : #include <svx/svdotext.hxx>
61 : : #include <svx/svdorect.hxx>
62 : : #include <svx/svdocirc.hxx>
63 : : #include <svx/svdograf.hxx>
64 : : #include <svx/svdopath.hxx>
65 : : #include <svx/svdetc.hxx>
66 : : #include <svl/itemset.hxx>
67 : : #include <basegfx/polygon/b2dpolygon.hxx>
68 : : #include <tools/helpers.hxx>
69 : : #include <basegfx/matrix/b2dhommatrix.hxx>
70 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
71 : : #include <svx/xlinjoit.hxx>
72 : : #include <svx/xlndsit.hxx>
73 : :
74 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
75 : :
76 : 0 : ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(SdrModel& rModel):
77 : : nMapScalingOfs(0),
78 : : pLineAttr(NULL),pFillAttr(NULL),pTextAttr(NULL),
79 : : pPage(NULL),pModel(NULL),nLayer(0),
80 : : nLineWidth(0),
81 : : maLineJoin(basegfx::B2DLINEJOIN_NONE),
82 : : maDash(XDASH_RECT, 0, 0, 0, 0, 0),
83 : : fScaleX(0.0),fScaleY(0.0),
84 : : bFntDirty(sal_True),
85 [ # # ][ # # ]: 0 : bLastObjWasPolyWithoutLine(sal_False),bNoLine(sal_False),bNoFill(sal_False),bLastObjWasLine(sal_False)
[ # # ]
86 : : {
87 [ # # ]: 0 : aVD.EnableOutput(sal_False);
88 : :
89 : : // #i111954# init to no fill and no line initially
90 [ # # ]: 0 : aVD.SetLineColor();
91 [ # # ]: 0 : aVD.SetFillColor();
92 : :
93 [ # # ]: 0 : aOldLineColor.SetRed( aVD.GetLineColor().GetRed() + 1 ); // invalidate old line color
94 [ # # ][ # # ]: 0 : pLineAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_LINE_FIRST,XATTR_LINE_LAST);
95 [ # # ][ # # ]: 0 : pFillAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
96 [ # # ][ # # ]: 0 : pTextAttr=new SfxItemSet(rModel.GetItemPool(),EE_ITEMS_START,EE_ITEMS_END);
97 : 0 : pModel=&rModel;
98 : 0 : }
99 : :
100 [ # # ]: 0 : ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
101 : : {
102 [ # # ][ # # ]: 0 : delete pLineAttr;
103 [ # # ][ # # ]: 0 : delete pFillAttr;
104 [ # # ][ # # ]: 0 : delete pTextAttr;
105 : 0 : }
106 : :
107 : 0 : sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
108 : : SdrObjList& rOL,
109 : : sal_uIntPtr nInsPos,
110 : : SvdProgressInfo *pProgrInfo)
111 : : {
112 [ # # ]: 0 : pPage = rOL.GetPage();
113 : 0 : GDIMetaFile* pTmpMtf=NULL;
114 : 0 : GDIMetaFile* pMtf = (GDIMetaFile*) &rMtf;
115 [ # # ]: 0 : size_t nActionAnz = pMtf->GetActionSize();
116 : 0 : sal_Bool bError = sal_False;
117 : :
118 : :
119 : : // setup some global scale parameters
120 : : // fScaleX, fScaleY, aScaleX, aScaleY, bMov, bSize
121 : 0 : fScaleX = fScaleY = 1.0;
122 : 0 : Size aMtfSize( pMtf->GetPrefSize() );
123 [ # # ][ # # ]: 0 : if ( aMtfSize.Width() & aMtfSize.Height() && ( aScaleRect.IsEmpty() == sal_False ) )
[ # # ][ # # ]
124 : : {
125 : 0 : aOfs = aScaleRect.TopLeft();
126 [ # # ][ # # ]: 0 : if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
127 [ # # ]: 0 : fScaleX = (double)( aScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
128 [ # # ][ # # ]: 0 : if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
129 [ # # ]: 0 : fScaleY = (double)( aScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
130 : : }
131 : :
132 [ # # ][ # # ]: 0 : bMov = aOfs.X()!=0 || aOfs.Y()!=0;
133 : 0 : bSize = sal_False;
134 : :
135 [ # # ][ # # ]: 0 : aScaleX = Fraction( 1, 1 );
136 [ # # ][ # # ]: 0 : aScaleY = Fraction( 1, 1 );
137 [ # # ][ # # ]: 0 : if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
138 : : {
139 [ # # ][ # # ]: 0 : aScaleX = Fraction( aScaleRect.GetWidth() - 1, aMtfSize.Width() );
[ # # ]
140 : 0 : bSize = sal_True;
141 : : }
142 [ # # ][ # # ]: 0 : if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
143 : : {
144 [ # # ][ # # ]: 0 : aScaleY = Fraction( aScaleRect.GetHeight() - 1, aMtfSize.Height() );
[ # # ]
145 : 0 : bSize = sal_True;
146 : : }
147 : :
148 [ # # ]: 0 : if(65000 < nActionAnz)
149 : : {
150 : 0 : nActionAnz = 65000;
151 : 0 : bError = sal_True;
152 : : }
153 : :
154 [ # # ]: 0 : if(pProgrInfo)
155 [ # # ]: 0 : pProgrInfo->SetActionCount(nActionAnz);
156 : :
157 : 0 : size_t nActionsToReport = 0;
158 : :
159 [ # # ][ # # ]: 0 : for( MetaAction* pAct = pMtf->FirstAction(); pAct; pAct = pMtf->NextAction() )
[ # # ]
160 : : {
161 [ # # # # : 0 : switch (pAct->GetType())
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
162 : : {
163 : 0 : case META_PIXEL_ACTION : DoAction((MetaPixelAction &)*pAct); break;
164 : 0 : case META_POINT_ACTION : DoAction((MetaPointAction &)*pAct); break;
165 [ # # ]: 0 : case META_LINE_ACTION : DoAction((MetaLineAction &)*pAct); break;
166 [ # # ]: 0 : case META_RECT_ACTION : DoAction((MetaRectAction &)*pAct); break;
167 [ # # ]: 0 : case META_ROUNDRECT_ACTION : DoAction((MetaRoundRectAction &)*pAct); break;
168 [ # # ]: 0 : case META_ELLIPSE_ACTION : DoAction((MetaEllipseAction &)*pAct); break;
169 [ # # ]: 0 : case META_ARC_ACTION : DoAction((MetaArcAction &)*pAct); break;
170 [ # # ]: 0 : case META_PIE_ACTION : DoAction((MetaPieAction &)*pAct); break;
171 [ # # ]: 0 : case META_CHORD_ACTION : DoAction((MetaChordAction &)*pAct); break;
172 [ # # ]: 0 : case META_POLYLINE_ACTION : DoAction((MetaPolyLineAction &)*pAct); break;
173 [ # # ]: 0 : case META_POLYGON_ACTION : DoAction((MetaPolygonAction &)*pAct); break;
174 [ # # ]: 0 : case META_POLYPOLYGON_ACTION : DoAction((MetaPolyPolygonAction &)*pAct); break;
175 [ # # ]: 0 : case META_TEXT_ACTION : DoAction((MetaTextAction &)*pAct); break;
176 [ # # ]: 0 : case META_TEXTARRAY_ACTION : DoAction((MetaTextArrayAction &)*pAct); break;
177 [ # # ]: 0 : case META_STRETCHTEXT_ACTION : DoAction((MetaStretchTextAction &)*pAct); break;
178 [ # # ]: 0 : case META_BMP_ACTION : DoAction((MetaBmpAction &)*pAct); break;
179 [ # # ]: 0 : case META_BMPSCALE_ACTION : DoAction((MetaBmpScaleAction &)*pAct); break;
180 [ # # ]: 0 : case META_BMPEX_ACTION : DoAction((MetaBmpExAction &)*pAct); break;
181 [ # # ]: 0 : case META_BMPEXSCALE_ACTION : DoAction((MetaBmpExScaleAction &)*pAct); break;
182 [ # # ]: 0 : case META_LINECOLOR_ACTION : DoAction((MetaLineColorAction &)*pAct); break;
183 [ # # ]: 0 : case META_FILLCOLOR_ACTION : DoAction((MetaFillColorAction &)*pAct); break;
184 [ # # ]: 0 : case META_TEXTCOLOR_ACTION : DoAction((MetaTextColorAction &)*pAct); break;
185 [ # # ]: 0 : case META_TEXTFILLCOLOR_ACTION : DoAction((MetaTextFillColorAction &)*pAct); break;
186 [ # # ]: 0 : case META_FONT_ACTION : DoAction((MetaFontAction &)*pAct); break;
187 [ # # ]: 0 : case META_TEXTALIGN_ACTION : DoAction((MetaTextAlignAction &)*pAct); break;
188 [ # # ]: 0 : case META_MAPMODE_ACTION : DoAction((MetaMapModeAction &)*pAct); break;
189 [ # # ]: 0 : case META_CLIPREGION_ACTION : DoAction((MetaClipRegionAction &)*pAct); break;
190 [ # # ]: 0 : case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
191 [ # # ]: 0 : case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
192 [ # # ]: 0 : case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
193 [ # # ]: 0 : case META_RASTEROP_ACTION : DoAction((MetaRasterOpAction &)*pAct); break;
194 [ # # ]: 0 : case META_PUSH_ACTION : DoAction((MetaPushAction &)*pAct); break;
195 [ # # ]: 0 : case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break;
196 [ # # ]: 0 : case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break;
197 [ # # ]: 0 : case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break;
198 [ # # ]: 0 : case META_RENDERGRAPHIC_ACTION : DoAction((MetaRenderGraphicAction &)*pAct); break;
199 : : }
200 : :
201 [ # # ]: 0 : if(pProgrInfo != NULL)
202 : : {
203 : 0 : nActionsToReport++;
204 [ # # ]: 0 : if(nActionsToReport >= 16) // update all 16 actions
205 : : {
206 [ # # ][ # # ]: 0 : if(!pProgrInfo->ReportActions(nActionsToReport))
207 : 0 : break;
208 : 0 : nActionsToReport = 0;
209 : : }
210 : : }
211 : : }
212 : :
213 [ # # ]: 0 : if(pProgrInfo != NULL)
214 : : {
215 [ # # ]: 0 : pProgrInfo->ReportActions(nActionsToReport);
216 : 0 : nActionsToReport = 0;
217 : : }
218 : :
219 : : // MapMode scaling
220 [ # # ]: 0 : MapScaling();
221 : : // scale objects to predetermined rectangle
222 : 0 : sal_uIntPtr nAnz=aTmpList.GetObjCount();
223 : :
224 : : // To calculate the progress meter, we use GetActionSize()*3.
225 : : // However, aTmpList has a lower entry count limit than GetActionSize(),
226 : : // so the actions that were assumed were too much have to be re-added.
227 [ # # ]: 0 : nActionsToReport = (pMtf->GetActionSize() - nAnz)*2;
228 : :
229 : :
230 : : // announce all currently unannounced rescales
231 [ # # ]: 0 : if(pProgrInfo)
232 : : {
233 [ # # ]: 0 : pProgrInfo->ReportRescales(nActionsToReport);
234 [ # # ]: 0 : pProgrInfo->SetInsertCount(nAnz);
235 : : }
236 : 0 : nActionsToReport = 0;
237 : :
238 : : // insert all objects cached in aTmpList now into rOL from nInsPos
239 [ # # ][ # # ]: 0 : if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
[ # # ]
240 : 0 : SdrInsertReason aReason(SDRREASON_VIEWCALL);
241 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nAnz; i++)
242 : : {
243 [ # # ]: 0 : SdrObject* pObj=aTmpList.GetObj(i);
244 [ # # ]: 0 : rOL.NbcInsertObject(pObj,nInsPos,&aReason);
245 : 0 : nInsPos++;
246 : :
247 [ # # ]: 0 : if(pProgrInfo != NULL)
248 : : {
249 : 0 : nActionsToReport++;
250 [ # # ]: 0 : if(nActionsToReport >= 32) // update all 32 actions
251 : : {
252 [ # # ]: 0 : pProgrInfo->ReportInserts(nActionsToReport);
253 : 0 : nActionsToReport = 0;
254 : : }
255 : : }
256 : : }
257 [ # # ][ # # ]: 0 : if (pTmpMtf!=NULL) delete pTmpMtf;
[ # # ]
258 : :
259 : : // report all remaining inserts for the last time
260 [ # # ]: 0 : if(pProgrInfo != NULL)
261 : : {
262 [ # # ]: 0 : pProgrInfo->ReportInserts(nActionsToReport);
263 [ # # ]: 0 : if(bError)
264 [ # # ]: 0 : pProgrInfo->ReportError();
265 : : }
266 : :
267 : 0 : return aTmpList.GetObjCount();
268 : : }
269 : :
270 : 0 : void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
271 : : {
272 : 0 : bNoLine = sal_False; bNoFill = sal_False;
273 : 0 : bool bLine = !bForceTextAttr;
274 [ # # ][ # # ]: 0 : bool bFill = (pObj==NULL) || (pObj->IsClosedObj() && !bForceTextAttr);
[ # # ]
275 [ # # ][ # # ]: 0 : bool bText = bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL);
[ # # ]
276 : :
277 [ # # ]: 0 : if ( bLine )
278 : : {
279 [ # # ]: 0 : if ( nLineWidth )
280 [ # # ]: 0 : pLineAttr->Put( XLineWidthItem( nLineWidth ) );
281 : : else
282 [ # # ]: 0 : pLineAttr->Put( XLineWidthItem( 0 ) );
283 : :
284 : 0 : aOldLineColor = aVD.GetLineColor();
285 [ # # ]: 0 : if( aVD.IsLineColor() )
286 : : {
287 [ # # ]: 0 : pLineAttr->Put(XLineStyleItem(XLINE_SOLID));
288 [ # # ][ # # ]: 0 : pLineAttr->Put(XLineColorItem(String(), aVD.GetLineColor()));
[ # # ]
289 : : }
290 : : else
291 [ # # ]: 0 : pLineAttr->Put(XLineStyleItem(XLINE_NONE));
292 : :
293 [ # # # # : 0 : switch(maLineJoin)
# ]
294 : : {
295 : : default : // basegfx::B2DLINEJOIN_NONE
296 [ # # ]: 0 : pLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
297 : 0 : break;
298 : : case basegfx::B2DLINEJOIN_MIDDLE:
299 [ # # ]: 0 : pLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
300 : 0 : break;
301 : : case basegfx::B2DLINEJOIN_BEVEL:
302 [ # # ]: 0 : pLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
303 : 0 : break;
304 : : case basegfx::B2DLINEJOIN_MITER:
305 [ # # ]: 0 : pLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
306 : 0 : break;
307 : : case basegfx::B2DLINEJOIN_ROUND:
308 [ # # ]: 0 : pLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
309 : 0 : break;
310 : : }
311 : :
312 [ # # ][ # # ]: 0 : if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
[ # # ][ # # ]
[ # # ][ # # ]
313 : : {
314 [ # # ][ # # ]: 0 : pLineAttr->Put(XLineDashItem(String(), maDash));
[ # # ]
315 : : }
316 : : else
317 : : {
318 [ # # ][ # # ]: 0 : pLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
[ # # ][ # # ]
[ # # ]
319 : : }
320 : : }
321 : : else
322 : 0 : bNoLine = sal_True;
323 : :
324 [ # # ]: 0 : if ( bFill )
325 : : {
326 [ # # ]: 0 : if( aVD.IsFillColor() )
327 : : {
328 [ # # ]: 0 : pFillAttr->Put(XFillStyleItem(XFILL_SOLID));
329 [ # # ][ # # ]: 0 : pFillAttr->Put(XFillColorItem(String(), aVD.GetFillColor()));
[ # # ]
330 : : }
331 : : else
332 [ # # ]: 0 : pFillAttr->Put(XFillStyleItem(XFILL_NONE));
333 : : }
334 : : else
335 : 0 : bNoFill = sal_True;
336 : :
337 [ # # ][ # # ]: 0 : if ( bText && bFntDirty )
338 : : {
339 [ # # ]: 0 : Font aFnt(aVD.GetFont());
340 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
341 [ # # ][ # # ]: 0 : aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
[ # # ][ # # ]
[ # # ][ # # ]
342 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
343 [ # # ][ # # ]: 0 : aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
[ # # ][ # # ]
[ # # ][ # # ]
344 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
345 [ # # ][ # # ]: 0 : aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
[ # # ][ # # ]
[ # # ][ # # ]
346 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
[ # # ][ # # ]
347 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
[ # # ][ # # ]
348 [ # # ]: 0 : sal_uInt32 nHeight = FRound(aFnt.GetSize().Height() * fScaleY);
349 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
[ # # ]
350 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
[ # # ]
351 [ # # ][ # # ]: 0 : pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
[ # # ]
352 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
[ # # ]
353 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
[ # # ][ # # ]
354 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
[ # # ][ # # ]
355 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
[ # # ][ # # ]
356 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
[ # # ][ # # ]
357 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
[ # # ][ # # ]
358 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
[ # # ][ # # ]
359 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
[ # # ][ # # ]
360 [ # # ][ # # ]: 0 : pTextAttr->Put(SvxColorItem(aFnt.GetColor(), EE_CHAR_COLOR));
[ # # ][ # # ]
361 : : //... svxfont textitem svditext
362 [ # # ]: 0 : bFntDirty=sal_False;
363 : : }
364 [ # # ]: 0 : if (pObj!=NULL)
365 : : {
366 : 0 : pObj->SetLayer(nLayer);
367 [ # # ]: 0 : if (bLine) pObj->SetMergedItemSet(*pLineAttr);
368 [ # # ]: 0 : if (bFill) pObj->SetMergedItemSet(*pFillAttr);
369 [ # # ]: 0 : if (bText)
370 : : {
371 : 0 : pObj->SetMergedItemSet(*pTextAttr);
372 [ # # ]: 0 : pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_LEFT ) );
373 : : }
374 : : }
375 : 0 : }
376 : :
377 : 0 : void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale )
378 : : {
379 [ # # ][ # # ]: 0 : if ( bScale && !aScaleRect.IsEmpty() )
[ # # ]
380 : : {
381 [ # # ]: 0 : if ( bSize )
382 [ # # ]: 0 : pObj->NbcResize( Point(), aScaleX, aScaleY );
383 [ # # ]: 0 : if ( bMov )
384 [ # # ]: 0 : pObj->NbcMove( Size( aOfs.X(), aOfs.Y() ) );
385 : : }
386 : :
387 : : // #i111954# check object for visibility
388 : : // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
389 : 0 : bool bVisible(false);
390 : :
391 [ # # ]: 0 : if(pObj->HasLineStyle())
392 : : {
393 : 0 : bVisible = true;
394 : : }
395 : :
396 [ # # ][ # # ]: 0 : if(!bVisible && pObj->HasFillStyle())
[ # # ]
397 : : {
398 : 0 : bVisible = true;
399 : : }
400 : :
401 [ # # ]: 0 : if(!bVisible)
402 : : {
403 [ # # ]: 0 : SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
404 : :
405 [ # # ][ # # ]: 0 : if(pTextObj && pTextObj->HasText())
[ # # ]
406 : : {
407 : 0 : bVisible = true;
408 : : }
409 : : }
410 : :
411 [ # # ]: 0 : if(!bVisible)
412 : : {
413 [ # # ]: 0 : SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
414 : :
415 [ # # ]: 0 : if(pGrafObj)
416 : : {
417 : : // this may be refined to check if the graphic really is visible. It
418 : : // is here to ensure that graphic objects without fill, line and text
419 : : // get created
420 : 0 : bVisible = true;
421 : : }
422 : : }
423 : :
424 [ # # ]: 0 : if(!bVisible)
425 : : {
426 : 0 : SdrObject::Free(pObj);
427 : : }
428 : : else
429 : : {
430 : 0 : aTmpList.InsertObject( pObj );
431 [ # # ][ # # ]: 0 : if ( HAS_BASE( SdrPathObj, pObj ) )
[ # # ]
432 : : {
433 : 0 : bool bClosed=pObj->IsClosedObj();
434 [ # # ][ # # ]: 0 : bLastObjWasPolyWithoutLine=bNoLine && bClosed;
435 : 0 : bLastObjWasLine=!bClosed;
436 : : }
437 : : else
438 : : {
439 : 0 : bLastObjWasPolyWithoutLine = sal_False;
440 : 0 : bLastObjWasLine = sal_False;
441 : : }
442 : : }
443 : 0 : }
444 : :
445 : : /**************************************************************************************************/
446 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/) const
447 : : {
448 : 0 : }
449 : :
450 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/) const
451 : : {
452 : 0 : }
453 : :
454 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
455 : : {
456 : : // #i73407# reformulation to use new B2DPolygon classes
457 : 0 : const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
458 : 0 : const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
459 : :
460 [ # # ]: 0 : if(!aStart.equal(aEnd))
461 : : {
462 [ # # ]: 0 : basegfx::B2DPolygon aLine;
463 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
464 : :
465 [ # # ]: 0 : aLine.append(aStart);
466 [ # # ]: 0 : aLine.append(aEnd);
467 [ # # ]: 0 : aLine.transform(aTransform);
468 : :
469 : 0 : const LineInfo& rLineInfo = rAct.GetLineInfo();
470 : 0 : const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
471 : 0 : bool bCreateLineObject(true);
472 : :
473 [ # # ][ # # ]: 0 : if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aLine))
[ # # ][ # # ]
[ # # ]
474 : : {
475 : 0 : bCreateLineObject = false;
476 : : }
477 : :
478 [ # # ]: 0 : if(bCreateLineObject)
479 : : {
480 [ # # ][ # # ]: 0 : SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
[ # # ][ # # ]
481 : 0 : nLineWidth = nNewLineWidth;
482 : 0 : maLineJoin = rLineInfo.GetLineJoin();
483 : : maDash = XDash(XDASH_RECT,
484 : 0 : rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
485 : 0 : rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
486 [ # # ]: 0 : rLineInfo.GetDistance());
487 [ # # ]: 0 : SetAttributes(pPath);
488 : 0 : nLineWidth = 0;
489 : 0 : maLineJoin = basegfx::B2DLINEJOIN_NONE;
490 [ # # ]: 0 : maDash = XDash();
491 [ # # ]: 0 : InsertObj(pPath, false);
492 [ # # ][ # # ]: 0 : }
493 : 0 : }
494 : 0 : }
495 : :
496 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
497 : : {
498 [ # # ]: 0 : SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
499 : 0 : SetAttributes(pRect);
500 : 0 : InsertObj(pRect);
501 : 0 : }
502 : :
503 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
504 : : {
505 [ # # ]: 0 : SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
506 : 0 : SetAttributes(pRect);
507 : 0 : long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
508 [ # # ]: 0 : if (nRad!=0) {
509 [ # # ]: 0 : SfxItemSet aSet(*pLineAttr->GetPool(),SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS);
510 [ # # ][ # # ]: 0 : aSet.Put(SdrEckenradiusItem(nRad));
[ # # ]
511 [ # # ][ # # ]: 0 : pRect->SetMergedItemSet(aSet);
512 : : }
513 : 0 : InsertObj(pRect);
514 : 0 : }
515 : :
516 : : /**************************************************************************************************/
517 : :
518 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
519 : : {
520 [ # # ]: 0 : SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
521 : 0 : SetAttributes(pCirc);
522 : 0 : InsertObj(pCirc);
523 : 0 : }
524 : :
525 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
526 : : {
527 [ # # ]: 0 : Point aCenter(rAct.GetRect().Center());
528 [ # # ]: 0 : long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
529 [ # # ]: 0 : long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
530 [ # # ][ # # ]: 0 : SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
531 [ # # ]: 0 : SetAttributes(pCirc);
532 [ # # ]: 0 : InsertObj(pCirc);
533 : 0 : }
534 : :
535 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
536 : : {
537 [ # # ]: 0 : Point aCenter(rAct.GetRect().Center());
538 [ # # ]: 0 : long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
539 [ # # ]: 0 : long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
540 [ # # ][ # # ]: 0 : SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
541 [ # # ]: 0 : SetAttributes(pCirc);
542 [ # # ]: 0 : InsertObj(pCirc);
543 : 0 : }
544 : :
545 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
546 : : {
547 [ # # ]: 0 : Point aCenter(rAct.GetRect().Center());
548 [ # # ]: 0 : long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
549 [ # # ]: 0 : long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
550 [ # # ][ # # ]: 0 : SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
551 [ # # ]: 0 : SetAttributes(pCirc);
552 [ # # ]: 0 : InsertObj(pCirc);
553 : 0 : }
554 : :
555 : : /**************************************************************************************************/
556 : :
557 : 0 : bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
558 : : {
559 : : // #i102706# Do not merge closed polygons
560 [ # # ]: 0 : if(rSrcPoly.isClosed())
561 : : {
562 : 0 : return false;
563 : : }
564 : :
565 : : // #i73407# reformulation to use new B2DPolygon classes
566 [ # # ][ # # ]: 0 : if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count())
[ # # ][ # # ]
567 : : {
568 : 0 : SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
569 [ # # ][ # # ]: 0 : SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
570 : :
571 [ # # ]: 0 : if(pLastPoly)
572 : : {
573 [ # # ]: 0 : if(1L == pLastPoly->GetPathPoly().count())
574 : : {
575 : 0 : bool bOk(false);
576 [ # # ]: 0 : basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
577 : :
578 : : // #i102706# Do not merge closed polygons
579 [ # # ][ # # ]: 0 : if(aDstPoly.isClosed())
580 : : {
581 : 0 : return false;
582 : : }
583 : :
584 [ # # ][ # # ]: 0 : if(aDstPoly.count())
585 : : {
586 [ # # ]: 0 : const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
587 [ # # ]: 0 : const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
588 : :
589 [ # # ][ # # ]: 0 : if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
[ # # ]
590 : : {
591 [ # # ][ # # ]: 0 : aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
592 : 0 : bOk = true;
593 : : }
594 [ # # ][ # # ]: 0 : else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
[ # # ]
595 : : {
596 [ # # ]: 0 : basegfx::B2DPolygon aNew(rSrcPoly);
597 [ # # ][ # # ]: 0 : aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
598 [ # # ]: 0 : aDstPoly = aNew;
599 [ # # ]: 0 : bOk = true;
600 : : }
601 [ # # ][ # # ]: 0 : else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
[ # # ]
602 : : {
603 [ # # ]: 0 : aDstPoly.flip();
604 [ # # ][ # # ]: 0 : aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
605 : 0 : bOk = true;
606 : : }
607 [ # # ][ # # ]: 0 : else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
[ # # ]
608 : : {
609 [ # # ]: 0 : basegfx::B2DPolygon aNew(rSrcPoly);
610 [ # # ]: 0 : aNew.flip();
611 [ # # ][ # # ]: 0 : aDstPoly.append(aNew, 1L, aNew.count() - 1L);
612 [ # # ]: 0 : bOk = true;
613 : : }
614 : : }
615 : :
616 [ # # ]: 0 : if(bOk)
617 : : {
618 [ # # ][ # # ]: 0 : pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
[ # # ]
619 : : }
620 : :
621 [ # # ]: 0 : return bOk;
622 : : }
623 : : }
624 : : }
625 : :
626 : 0 : return false;
627 : : }
628 : :
629 : 0 : bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
630 : : {
631 : : // #i73407# reformulation to use new B2DPolygon classes
632 [ # # ]: 0 : if(bLastObjWasPolyWithoutLine)
633 : : {
634 : 0 : SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
635 [ # # ][ # # ]: 0 : SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
636 : :
637 [ # # ]: 0 : if(pLastPoly)
638 : : {
639 [ # # ]: 0 : if(pLastPoly->GetPathPoly() == rPolyPolygon)
640 : : {
641 : 0 : SetAttributes(NULL);
642 : :
643 [ # # ][ # # ]: 0 : if(!bNoLine && bNoFill)
644 : : {
645 : 0 : pLastPoly->SetMergedItemSet(*pLineAttr);
646 : :
647 : 0 : return true;
648 : : }
649 : : }
650 : : }
651 : : }
652 : :
653 : 0 : return false;
654 : : }
655 : :
656 : :
657 : 0 : void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
658 : : {
659 : : // #i73407# reformulation to use new B2DPolygon classes
660 [ # # ]: 0 : basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
661 : :
662 [ # # ][ # # ]: 0 : if(aSource.count())
663 : : {
664 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
665 [ # # ][ # # ]: 0 : aSource.transform(aTransform);
666 : : }
667 : :
668 : 0 : const LineInfo& rLineInfo = rAct.GetLineInfo();
669 : 0 : const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
670 : 0 : bool bCreateLineObject(true);
671 : :
672 [ # # ][ # # ]: 0 : if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aSource))
[ # # ][ # # ]
[ # # ]
673 : : {
674 : 0 : bCreateLineObject = false;
675 : : }
676 [ # # ][ # # ]: 0 : else if(bLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
677 : : {
678 : 0 : bCreateLineObject = false;
679 : : }
680 : :
681 [ # # ]: 0 : if(bCreateLineObject)
682 : : {
683 : : SdrPathObj* pPath = new SdrPathObj(
684 [ # # ]: 0 : aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
685 [ # # ][ # # ]: 0 : basegfx::B2DPolyPolygon(aSource));
[ # # ][ # # ]
[ # # ]
686 : 0 : nLineWidth = nNewLineWidth;
687 : 0 : maLineJoin = rLineInfo.GetLineJoin();
688 : : maDash = XDash(XDASH_RECT,
689 : 0 : rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
690 : 0 : rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
691 [ # # ]: 0 : rLineInfo.GetDistance());
692 [ # # ]: 0 : SetAttributes(pPath);
693 : 0 : nLineWidth = 0;
694 : 0 : maLineJoin = basegfx::B2DLINEJOIN_NONE;
695 [ # # ]: 0 : maDash = XDash();
696 [ # # ]: 0 : InsertObj(pPath, false);
697 [ # # ]: 0 : }
698 : 0 : }
699 : :
700 : 0 : void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
701 : : {
702 : : // #i73407# reformulation to use new B2DPolygon classes
703 [ # # ]: 0 : basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
704 : :
705 [ # # ][ # # ]: 0 : if(aSource.count())
706 : : {
707 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
708 [ # # ]: 0 : aSource.transform(aTransform);
709 : :
710 [ # # ][ # # ]: 0 : if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
711 : : {
712 : : // #i73407# make sure polygon is closed, it's a filled primitive
713 [ # # ]: 0 : aSource.setClosed(true);
714 : :
715 [ # # ][ # # ]: 0 : SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
[ # # ][ # # ]
716 [ # # ]: 0 : SetAttributes(pPath);
717 [ # # ]: 0 : InsertObj(pPath, false);
718 [ # # ]: 0 : }
719 [ # # ]: 0 : }
720 : 0 : }
721 : :
722 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
723 : : {
724 : : // #i73407# reformulation to use new B2DPolygon classes
725 [ # # ]: 0 : basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
726 : :
727 [ # # ][ # # ]: 0 : if(aSource.count())
728 : : {
729 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
730 [ # # ]: 0 : aSource.transform(aTransform);
731 : :
732 [ # # ][ # # ]: 0 : if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
[ # # ][ # # ]
733 : : {
734 : : // #i73407# make sure polygon is closed, it's a filled primitive
735 [ # # ]: 0 : aSource.setClosed(true);
736 : :
737 [ # # ][ # # ]: 0 : SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
738 [ # # ]: 0 : SetAttributes(pPath);
739 [ # # ]: 0 : InsertObj(pPath, false);
740 [ # # ]: 0 : }
741 [ # # ]: 0 : }
742 : 0 : }
743 : :
744 : : /**************************************************************************************************/
745 : :
746 : 0 : void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
747 : : {
748 : : // calc text box size, add 5% to make it fit safely
749 : :
750 [ # # ]: 0 : FontMetric aFontMetric( aVD.GetFontMetric() );
751 [ # # ]: 0 : Font aFnt( aVD.GetFont() );
752 [ # # ]: 0 : FontAlign eAlg( aFnt.GetAlign() );
753 : :
754 [ # # ]: 0 : sal_Int32 nTextWidth = (sal_Int32)( aVD.GetTextWidth( rStr ) * fScaleX );
755 [ # # ]: 0 : sal_Int32 nTextHeight = (sal_Int32)( aVD.GetTextHeight() * fScaleY );
756 : :
757 : 0 : Point aPos( FRound(rPos.X() * fScaleX + aOfs.X()), FRound(rPos.Y() * fScaleY + aOfs.Y()) );
758 : 0 : Size aSize( nTextWidth, nTextHeight );
759 : :
760 [ # # ]: 0 : if ( eAlg == ALIGN_BASELINE )
761 [ # # ]: 0 : aPos.Y() -= FRound(aFontMetric.GetAscent() * fScaleY);
762 [ # # ]: 0 : else if ( eAlg == ALIGN_BOTTOM )
763 : 0 : aPos.Y() -= nTextHeight;
764 : :
765 [ # # ]: 0 : Rectangle aTextRect( aPos, aSize );
766 [ # # ][ # # ]: 0 : SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
767 : :
768 [ # # ][ # # ]: 0 : if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
[ # # ][ # # ]
769 : : {
770 [ # # ]: 0 : pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
771 [ # # ][ # # ]: 0 : pText->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
[ # # ]
772 : : // don't let the margins eat the space needed for the text
773 [ # # ][ # # ]: 0 : pText->SetMergedItem ( SdrTextUpperDistItem (0));
[ # # ]
774 [ # # ][ # # ]: 0 : pText->SetMergedItem ( SdrTextLowerDistItem (0));
[ # # ]
775 [ # # ][ # # ]: 0 : pText->SetMergedItem ( SdrTextRightDistItem (0));
[ # # ]
776 [ # # ][ # # ]: 0 : pText->SetMergedItem ( SdrTextLeftDistItem (0));
[ # # ]
777 [ # # ][ # # ]: 0 : pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
[ # # ]
778 : : }
779 : : else
780 [ # # ][ # # ]: 0 : pText->SetMergedItem( SdrTextAutoGrowWidthItem( sal_True ) );
[ # # ]
781 : :
782 [ # # ]: 0 : pText->SetModel( pModel );
783 [ # # ]: 0 : pText->SetLayer( nLayer );
784 [ # # ]: 0 : pText->NbcSetText( rStr );
785 [ # # ]: 0 : SetAttributes( pText, sal_True );
786 [ # # ]: 0 : pText->SetSnapRect( aTextRect );
787 : :
788 [ # # ][ # # ]: 0 : if (!aFnt.IsTransparent())
789 : : {
790 [ # # ]: 0 : SfxItemSet aAttr(*pFillAttr->GetPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
791 [ # # ][ # # ]: 0 : aAttr.Put(XFillStyleItem(XFILL_SOLID));
[ # # ]
792 [ # # ][ # # ]: 0 : aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
[ # # ][ # # ]
[ # # ][ # # ]
793 [ # # ][ # # ]: 0 : pText->SetMergedItemSet(aAttr);
794 : : }
795 [ # # ]: 0 : sal_uInt32 nWink = aFnt.GetOrientation();
796 [ # # ]: 0 : if ( nWink )
797 : : {
798 : 0 : nWink*=10;
799 : 0 : double a=nWink*nPi180;
800 : 0 : double nSin=sin(a);
801 : 0 : double nCos=cos(a);
802 [ # # ]: 0 : pText->NbcRotate(aPos,nWink,nSin,nCos);
803 : : }
804 [ # # ][ # # ]: 0 : InsertObj( pText, sal_False );
[ # # ]
805 : 0 : }
806 : :
807 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
808 : : {
809 [ # # ]: 0 : XubString aStr(rAct.GetText());
810 [ # # ]: 0 : aStr.Erase(0,rAct.GetIndex());
811 [ # # ]: 0 : aStr.Erase(rAct.GetLen());
812 [ # # ][ # # ]: 0 : ImportText( rAct.GetPoint(), aStr, rAct );
813 : 0 : }
814 : :
815 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
816 : : {
817 [ # # ]: 0 : XubString aStr(rAct.GetText());
818 [ # # ]: 0 : aStr.Erase(0,rAct.GetIndex());
819 [ # # ]: 0 : aStr.Erase(rAct.GetLen());
820 [ # # ][ # # ]: 0 : ImportText( rAct.GetPoint(), aStr, rAct );
821 : 0 : }
822 : :
823 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
824 : : {
825 [ # # ]: 0 : XubString aStr(rAct.GetText());
826 [ # # ]: 0 : aStr.Erase(0,rAct.GetIndex());
827 [ # # ]: 0 : aStr.Erase(rAct.GetLen());
828 [ # # ][ # # ]: 0 : ImportText( rAct.GetPoint(), aStr, rAct );
829 : 0 : }
830 : :
831 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
832 : : {
833 [ # # ][ # # ]: 0 : Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
834 : 0 : aRect.Right()++; aRect.Bottom()++;
835 [ # # ][ # # ]: 0 : SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
[ # # ][ # # ]
836 [ # # ]: 0 : InsertObj(pGraf);
837 : 0 : }
838 : :
839 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
840 : : {
841 [ # # ]: 0 : Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
842 : 0 : aRect.Right()++; aRect.Bottom()++;
843 [ # # ][ # # ]: 0 : SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
[ # # ][ # # ]
844 [ # # ]: 0 : InsertObj(pGraf);
845 : 0 : }
846 : :
847 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
848 : : {
849 [ # # ]: 0 : Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
850 : 0 : aRect.Right()++; aRect.Bottom()++;
851 [ # # ][ # # ]: 0 : SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
[ # # ][ # # ]
852 [ # # ]: 0 : InsertObj(pGraf);
853 : 0 : }
854 : :
855 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
856 : : {
857 [ # # ]: 0 : Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
858 : 0 : aRect.Right()++; aRect.Bottom()++;
859 [ # # ][ # # ]: 0 : SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
[ # # ][ # # ]
860 [ # # ]: 0 : InsertObj(pGraf);
861 : 0 : }
862 : :
863 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
864 : :
865 : 0 : void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
866 : : {
867 : : // #i73407# reformulation to use new B2DPolygon classes
868 [ # # ]: 0 : basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
869 : :
870 [ # # ][ # # ]: 0 : if(aSource.count())
871 : : {
872 [ # # ]: 0 : const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
873 [ # # ]: 0 : aSource.transform(aTransform);
874 : :
875 [ # # ][ # # ]: 0 : if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
[ # # ][ # # ]
876 : : {
877 : 0 : const Hatch& rHatch = rAct.GetHatch();
878 [ # # ][ # # ]: 0 : SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
879 : 0 : SfxItemSet aHatchAttr(pModel->GetItemPool(),
880 : : XATTR_FILLSTYLE, XATTR_FILLSTYLE,
881 [ # # ]: 0 : XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0 );
882 : : XHatchStyle eStyle;
883 : :
884 [ # # # ]: 0 : switch(rHatch.GetStyle())
885 : : {
886 : : case(HATCH_TRIPLE) :
887 : : {
888 : 0 : eStyle = XHATCH_TRIPLE;
889 : 0 : break;
890 : : }
891 : :
892 : : case(HATCH_DOUBLE) :
893 : : {
894 : 0 : eStyle = XHATCH_DOUBLE;
895 : 0 : break;
896 : : }
897 : :
898 : : default:
899 : : {
900 : 0 : eStyle = XHATCH_SINGLE;
901 : 0 : break;
902 : : }
903 : : }
904 : :
905 [ # # ]: 0 : SetAttributes(pPath);
906 [ # # ][ # # ]: 0 : aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
[ # # ]
907 [ # # ][ # # ]: 0 : aHatchAttr.Put(XFillHatchItem(&pModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
[ # # ][ # # ]
908 [ # # ]: 0 : pPath->SetMergedItemSet(aHatchAttr);
909 : :
910 [ # # ][ # # ]: 0 : InsertObj(pPath, false);
911 [ # # ]: 0 : }
912 [ # # ]: 0 : }
913 : 0 : }
914 : :
915 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
916 : :
917 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
918 : : {
919 : 0 : rAct.Execute(&aVD);
920 : 0 : }
921 : :
922 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
923 : : {
924 : 0 : MapScaling();
925 : 0 : rAct.Execute(&aVD);
926 : 0 : bLastObjWasPolyWithoutLine=sal_False;
927 : 0 : bLastObjWasLine=sal_False;
928 : 0 : }
929 : :
930 : 0 : void ImpSdrGDIMetaFileImport::MapScaling()
931 : : {
932 : 0 : sal_uInt32 i, nAnz = aTmpList.GetObjCount();
933 : 0 : const MapMode& rMap = aVD.GetMapMode();
934 : 0 : Point aMapOrg( rMap.GetOrigin() );
935 [ # # ][ # # ]: 0 : sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
936 [ # # ]: 0 : if ( bMov2 )
937 : : {
938 [ # # ]: 0 : for ( i = nMapScalingOfs; i < nAnz; i++ )
939 : : {
940 [ # # ]: 0 : SdrObject* pObj = aTmpList.GetObj(i);
941 [ # # ]: 0 : if ( bMov2 )
942 [ # # ]: 0 : pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) );
943 : : }
944 : : }
945 : 0 : nMapScalingOfs = nAnz;
946 : 0 : }
947 : :
948 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
949 : :
950 : 0 : void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
951 : : {
952 : 0 : bool aSkipComment = false;
953 : :
954 [ # # ]: 0 : if (rAct.GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")))
955 : : {
956 : 0 : MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
957 : :
958 [ # # ][ # # ]: 0 : if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
[ # # ]
959 : : {
960 : : // #i73407# reformulation to use new B2DPolygon classes
961 [ # # ]: 0 : basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
962 : :
963 [ # # ][ # # ]: 0 : if(aSource.count())
964 : : {
965 [ # # ][ # # ]: 0 : if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
[ # # ][ # # ]
966 : : {
967 : 0 : const Gradient& rGrad = pAct->GetGradient();
968 [ # # ][ # # ]: 0 : SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
969 : 0 : SfxItemSet aGradAttr(pModel->GetItemPool(),
970 : : XATTR_FILLSTYLE, XATTR_FILLSTYLE,
971 [ # # ]: 0 : XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0 );
972 [ # # ]: 0 : XGradient aXGradient;
973 : :
974 : 0 : aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
975 : 0 : aXGradient.SetStartColor(rGrad.GetStartColor());
976 : 0 : aXGradient.SetEndColor(rGrad.GetEndColor());
977 : 0 : aXGradient.SetAngle((sal_uInt16)rGrad.GetAngle());
978 : 0 : aXGradient.SetBorder(rGrad.GetBorder());
979 : 0 : aXGradient.SetXOffset(rGrad.GetOfsX());
980 : 0 : aXGradient.SetYOffset(rGrad.GetOfsY());
981 : 0 : aXGradient.SetStartIntens(rGrad.GetStartIntensity());
982 : 0 : aXGradient.SetEndIntens(rGrad.GetEndIntensity());
983 : 0 : aXGradient.SetSteps(rGrad.GetSteps());
984 : :
985 [ # # ]: 0 : if(aVD.IsLineColor())
986 : : {
987 : : // switch line off; if there was one, there will be a
988 : : // META_POLYLINE_ACTION following creating another object
989 : 0 : const Color aLineColor(aVD.GetLineColor());
990 [ # # ]: 0 : aVD.SetLineColor();
991 [ # # ]: 0 : SetAttributes(pPath);
992 [ # # ]: 0 : aVD.SetLineColor(aLineColor);
993 : : }
994 : : else
995 : : {
996 [ # # ]: 0 : SetAttributes(pPath);
997 : : }
998 : :
999 [ # # ][ # # ]: 0 : aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
[ # # ]
1000 [ # # ][ # # ]: 0 : aGradAttr.Put(XFillGradientItem(aXGradient));
[ # # ]
1001 [ # # ]: 0 : pPath->SetMergedItemSet(aGradAttr);
1002 : :
1003 [ # # ][ # # ]: 0 : InsertObj(pPath);
1004 : : }
1005 : : }
1006 : :
1007 [ # # ]: 0 : aSkipComment = true;
1008 : : }
1009 : : }
1010 : :
1011 [ # # ]: 0 : if(aSkipComment)
1012 : : {
1013 : 0 : MetaAction* pSkipAct = pMtf->NextAction();
1014 : :
1015 [ # # # # : 0 : while( pSkipAct
# # ][ # # ]
1016 : 0 : && ((pSkipAct->GetType() != META_COMMENT_ACTION )
1017 : 0 : || !(((MetaCommentAction*)pSkipAct)->GetComment().equalsIgnoreAsciiCase("XGRAD_SEQ_END"))))
1018 : : {
1019 : 0 : pSkipAct = pMtf->NextAction();
1020 : : }
1021 : : }
1022 : 0 : }
1023 : :
1024 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1025 : :
1026 : 0 : void ImpSdrGDIMetaFileImport::DoAction(MetaRenderGraphicAction& rAct)
1027 : : {
1028 [ # # ]: 0 : GDIMetaFile aMtf;
1029 : 0 : const ::vcl::RenderGraphic& rRenderGraphic = rAct.GetRenderGraphic();
1030 [ # # ]: 0 : Rectangle aRect( rAct.GetPoint(), rAct.GetSize() );
1031 : 0 : const Point aPos;
1032 [ # # ]: 0 : const Size aPrefSize( rRenderGraphic.GetPrefSize() );
1033 : :
1034 : 0 : aRect.Right()++; aRect.Bottom()++;
1035 : :
1036 [ # # ][ # # ]: 0 : aMtf.SetPrefMapMode( rRenderGraphic.GetPrefMapMode() );
1037 : 0 : aMtf.SetPrefSize( aPrefSize );
1038 [ # # ][ # # ]: 0 : aMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, rRenderGraphic ) );
[ # # ]
1039 [ # # ]: 0 : aMtf.WindStart();
1040 : :
1041 [ # # ][ # # ]: 0 : SdrGrafObj* pGraf=new SdrGrafObj( aMtf, aRect );
[ # # ][ # # ]
1042 [ # # ][ # # ]: 0 : InsertObj( pGraf );
1043 : 0 : }
1044 : :
1045 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|