Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <vcl/bitmapex.hxx>
21 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
22 : #include <com/sun/star/drawing/LineStyle.hpp>
23 : #include <com/sun/star/drawing/LineDash.hpp>
24 : #include <com/sun/star/drawing/FillStyle.hpp>
25 : #include <com/sun/star/drawing/Hatch.hpp>
26 : #include <com/sun/star/awt/FontDescriptor.hpp>
27 : #include <com/sun/star/awt/FontWeight.hpp>
28 : #include <com/sun/star/awt/FontUnderline.hpp>
29 : #include <com/sun/star/drawing/XShapeGrouper.hpp>
30 : #include <com/sun/star/drawing/CircleKind.hpp>
31 : #include <com/sun/star/awt/XBitmap.hpp>
32 : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
33 : #include <com/sun/star/drawing/PointSequence.hpp>
34 : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
35 : #include <com/sun/star/drawing/FlagSequence.hpp>
36 : #include <com/sun/star/drawing/ShapeCollection.hpp>
37 : #include <com/sun/star/drawing/TextAdjust.hpp>
38 : #include <com/sun/star/text/XText.hpp>
39 : #include <com/sun/star/text/XTextRange.hpp>
40 : #include <com/sun/star/style/HorizontalAlignment.hpp>
41 :
42 : #include <comphelper/processfactory.hxx>
43 : #include <toolkit/helper/vclunohelper.hxx>
44 :
45 : #include "main.hxx"
46 : #include "outact.hxx"
47 :
48 : using namespace ::com::sun::star;
49 :
50 : // ---------------------------------------------------------------
51 :
52 0 : CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XModel > & rModel ) :
53 : CGMOutAct ( rCGM ),
54 0 : nFinalTextCount ( 0 )
55 : {
56 0 : sal_Bool bStatRet = sal_False;
57 :
58 0 : if ( mpCGM->mbStatus )
59 : {
60 0 : uno::Reference< drawing::XDrawPagesSupplier > aDrawPageSup( rModel, uno::UNO_QUERY );
61 0 : if( aDrawPageSup.is() )
62 : {
63 0 : maXDrawPages = aDrawPageSup->getDrawPages();
64 0 : if ( maXDrawPages.is() )
65 : {
66 0 : maXServiceManagerSC = comphelper::getProcessServiceFactory();
67 0 : if ( maXServiceManagerSC.is() )
68 : {
69 0 : uno::Any aAny( rModel->queryInterface( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) ));
70 0 : if( aAny >>= maXMultiServiceFactory )
71 : {
72 0 : maXDrawPage = *(uno::Reference< drawing::XDrawPage > *)maXDrawPages->getByIndex( 0 ).getValue();
73 0 : if ( ImplInitPage() )
74 0 : bStatRet = sal_True;
75 0 : }
76 : }
77 : }
78 : }
79 0 : mpCGM->mbStatus = bStatRet;
80 : }
81 0 : };
82 :
83 : // ---------------------------------------------------------------
84 :
85 0 : sal_Bool CGMImpressOutAct::ImplInitPage()
86 : {
87 0 : sal_Bool bStatRet = sal_False;
88 0 : if( maXDrawPage.is() )
89 : {
90 0 : maXShapes = uno::Reference< drawing::XShapes >( maXDrawPage, uno::UNO_QUERY );
91 0 : if ( maXShapes.is() )
92 : {
93 0 : bStatRet = sal_True;
94 : }
95 : }
96 0 : return bStatRet;
97 : }
98 :
99 : // ---------------------------------------------------------------
100 :
101 0 : sal_Bool CGMImpressOutAct::ImplCreateShape( const ::rtl::OUString& rType )
102 : {
103 0 : uno::Reference< uno::XInterface > xNewShape( maXMultiServiceFactory->createInstance( rType ) );
104 0 : maXShape = uno::Reference< drawing::XShape >( xNewShape, uno::UNO_QUERY );
105 0 : maXPropSet = uno::Reference< beans::XPropertySet >( xNewShape, uno::UNO_QUERY );
106 0 : if ( maXShape.is() && maXPropSet.is() )
107 : {
108 0 : maXShapes->add( maXShape );
109 0 : return sal_True;
110 : }
111 0 : return sal_False;
112 : }
113 :
114 : // ---------------------------------------------------------------
115 :
116 0 : void CGMImpressOutAct::ImplSetOrientation( FloatPoint& rRefPoint, double& rOrientation )
117 : {
118 0 : uno::Any aAny;
119 0 : aAny <<= (sal_Int32)rRefPoint.X;
120 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotationPointX" )), aAny );
121 0 : aAny <<= (sal_Int32)rRefPoint.Y;
122 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotationPointY" )), aAny );
123 0 : aAny <<= (sal_Int32)( rOrientation * 100.0 );
124 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" )), aAny );
125 0 : }
126 :
127 : // ---------------------------------------------------------------
128 :
129 0 : void CGMImpressOutAct::ImplSetLineBundle()
130 : {
131 0 : uno::Any aAny;
132 : drawing::LineStyle eLS;
133 :
134 : sal_uInt32 nLineColor;
135 : LineType eLineType;
136 : double fLineWidth;
137 :
138 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINECOLOR )
139 0 : nLineColor = mpCGM->pElement->pLineBundle->GetColor();
140 : else
141 0 : nLineColor = mpCGM->pElement->aLineBundle.GetColor();
142 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINETYPE )
143 0 : eLineType = mpCGM->pElement->pLineBundle->eLineType;
144 : else
145 0 : eLineType = mpCGM->pElement->aLineBundle.eLineType;
146 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINEWIDTH )
147 0 : fLineWidth = mpCGM->pElement->pLineBundle->nLineWidth;
148 : else
149 0 : fLineWidth = mpCGM->pElement->aLineBundle.nLineWidth;
150 :
151 0 : aAny <<= (sal_Int32)nLineColor;
152 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), aAny );
153 :
154 0 : aAny <<= (sal_Int32)fLineWidth;
155 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" )), aAny );
156 :
157 0 : switch( eLineType )
158 : {
159 : case LT_NONE :
160 0 : eLS = drawing::LineStyle_NONE;
161 0 : break;
162 : case LT_DASH :
163 : case LT_DOT :
164 : case LT_DASHDOT :
165 : case LT_DOTDOTSPACE :
166 : case LT_LONGDASH :
167 : case LT_DASHDASHDOT :
168 0 : eLS = drawing::LineStyle_DASH;
169 0 : break;
170 : case LT_SOLID :
171 : default:
172 0 : eLS = drawing::LineStyle_SOLID;
173 0 : break;
174 : }
175 0 : aAny <<= eLS;
176 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" )), aAny );
177 0 : if ( eLS == drawing::LineStyle_DASH )
178 : {
179 0 : drawing::LineDash aLineDash( drawing::DashStyle_RECTRELATIVE, 1, 50, 3, 33, 100 );
180 0 : aAny <<= aLineDash;
181 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" )), aAny );
182 0 : }
183 0 : };
184 :
185 : // ---------------------------------------------------------------
186 :
187 0 : void CGMImpressOutAct::ImplSetFillBundle()
188 : {
189 :
190 0 : uno::Any aAny;
191 : drawing::LineStyle eLS;
192 : drawing::FillStyle eFS;
193 :
194 0 : sal_uInt32 nEdgeColor = 0;
195 : EdgeType eEdgeType;
196 0 : double fEdgeWidth = 0;
197 :
198 : sal_uInt32 nFillColor;
199 : FillInteriorStyle eFillStyle;
200 : sal_uInt32 nHatchIndex;
201 :
202 0 : if ( mpCGM->pElement->eEdgeVisibility == EV_ON )
203 : {
204 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGETYPE )
205 0 : eEdgeType = mpCGM->pElement->pEdgeBundle->eEdgeType;
206 : else
207 0 : eEdgeType = mpCGM->pElement->aEdgeBundle.eEdgeType;
208 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGEWIDTH )
209 0 : fEdgeWidth = mpCGM->pElement->pEdgeBundle->nEdgeWidth;
210 : else
211 0 : fEdgeWidth = mpCGM->pElement->aEdgeBundle.nEdgeWidth;
212 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_EDGECOLOR )
213 0 : nEdgeColor = mpCGM->pElement->pEdgeBundle->GetColor();
214 : else
215 0 : nEdgeColor = mpCGM->pElement->aEdgeBundle.GetColor();
216 : }
217 : else
218 0 : eEdgeType = ET_NONE;
219 :
220 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLINTERIORSTYLE )
221 0 : eFillStyle = mpCGM->pElement->pFillBundle->eFillInteriorStyle;
222 : else
223 0 : eFillStyle = mpCGM->pElement->aFillBundle.eFillInteriorStyle;
224 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_FILLCOLOR )
225 0 : nFillColor = mpCGM->pElement->pFillBundle->GetColor();
226 : else
227 0 : nFillColor = mpCGM->pElement->aFillBundle.GetColor();
228 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_HATCHINDEX )
229 0 : nHatchIndex = (sal_uInt32)mpCGM->pElement->pFillBundle->nFillHatchIndex;
230 : else
231 0 : nHatchIndex = (sal_uInt32)mpCGM->pElement->aFillBundle.nFillHatchIndex;
232 :
233 0 : aAny <<= (sal_Int32)nFillColor;
234 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" )), aAny );
235 :
236 0 : switch ( eFillStyle )
237 : {
238 : case FIS_HATCH :
239 : {
240 0 : if ( nHatchIndex == 0 )
241 0 : eFS = drawing::FillStyle_NONE;
242 : else
243 0 : eFS = drawing::FillStyle_HATCH;
244 : }
245 0 : break;
246 : case FIS_PATTERN :
247 : case FIS_SOLID :
248 : {
249 0 : eFS = drawing::FillStyle_SOLID;
250 : }
251 0 : break;
252 :
253 : case FIS_GEOPATTERN :
254 : {
255 0 : if ( mpCGM->pElement->eTransparency == T_ON )
256 0 : nFillColor = mpCGM->pElement->nAuxiliaryColor;
257 0 : eFS = drawing::FillStyle_NONE;
258 : }
259 0 : break;
260 :
261 : case FIS_INTERPOLATED :
262 : case FIS_GRADIENT :
263 : {
264 0 : eFS = drawing::FillStyle_GRADIENT;
265 : }
266 0 : break;
267 :
268 : case FIS_HOLLOW :
269 : case FIS_EMPTY :
270 : default:
271 : {
272 0 : eFS = drawing::FillStyle_NONE;
273 : }
274 : }
275 :
276 0 : if ( mpCGM->mnAct4PostReset & ACT4_GRADIENT_ACTION )
277 0 : eFS = drawing::FillStyle_GRADIENT;
278 :
279 0 : if ( eFS == drawing::FillStyle_GRADIENT )
280 : {
281 0 : aAny <<= *mpGradient;
282 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" )), aAny );
283 : }
284 0 : aAny <<= eFS;
285 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )), aAny );
286 :
287 0 : eLS = drawing::LineStyle_NONE;
288 0 : if ( eFillStyle == FIS_HOLLOW )
289 : {
290 0 : eLS = drawing::LineStyle_SOLID;
291 0 : aAny <<= (sal_Int32)nFillColor;
292 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), aAny );
293 0 : aAny <<= (sal_Int32)0;
294 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" )), aAny );
295 : }
296 0 : else if ( eEdgeType != ET_NONE )
297 : {
298 0 : aAny <<= (sal_Int32)nEdgeColor;
299 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), aAny );
300 :
301 0 : aAny <<= (sal_Int32)fEdgeWidth;
302 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" )), aAny );
303 :
304 : switch( eEdgeType )
305 : {
306 : case ET_DASH :
307 : case ET_DOT :
308 : case ET_DASHDOT :
309 : case ET_DASHDOTDOT :
310 : case ET_DOTDOTSPACE :
311 : case ET_LONGDASH :
312 : case ET_DASHDASHDOT :
313 : default: // case ET_SOLID :
314 : {
315 0 : eLS = drawing::LineStyle_SOLID;
316 : }
317 0 : break;
318 : }
319 : }
320 :
321 0 : aAny <<= eLS;
322 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" )), aAny );
323 :
324 0 : if ( eFS == drawing::FillStyle_HATCH )
325 : {
326 0 : drawing::Hatch aHatch;
327 :
328 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_LINECOLOR )
329 0 : aHatch.Color = nFillColor;
330 : else
331 0 : aHatch.Color = nFillColor;
332 0 : if ( mpCGM->pElement->maHatchMap.find( nHatchIndex ) != mpCGM->pElement->maHatchMap.end() )
333 : {
334 0 : HatchEntry& rHatchEntry = mpCGM->pElement->maHatchMap[ nHatchIndex ];
335 0 : switch ( rHatchEntry.HatchStyle )
336 : {
337 0 : case 0 : aHatch.Style = drawing::HatchStyle_SINGLE; break;
338 0 : case 1 : aHatch.Style = drawing::HatchStyle_DOUBLE; break;
339 0 : case 2 : aHatch.Style = drawing::HatchStyle_TRIPLE; break;
340 : }
341 0 : aHatch.Distance = rHatchEntry.HatchDistance;
342 0 : aHatch.Angle = rHatchEntry.HatchAngle;
343 : }
344 : else
345 : {
346 0 : aHatch.Style = drawing::HatchStyle_TRIPLE;
347 0 : aHatch.Distance = 10 * ( nHatchIndex & 0x1f ) | 100;
348 0 : aHatch.Angle = 15 * ( ( nHatchIndex & 0x1f ) - 5 );
349 : }
350 0 : aAny <<= aHatch;
351 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" )), aAny );
352 0 : }
353 0 : };
354 :
355 : // ---------------------------------------------------------------
356 :
357 0 : void CGMImpressOutAct::ImplSetTextBundle( const uno::Reference< beans::XPropertySet > & rProperty )
358 : {
359 0 : uno::Any aAny;
360 : sal_uInt32 nTextFontIndex;
361 : sal_uInt32 nTextColor;
362 :
363 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTFONTINDEX )
364 0 : nTextFontIndex = mpCGM->pElement->pTextBundle->nTextFontIndex;
365 : else
366 0 : nTextFontIndex = mpCGM->pElement->aTextBundle.nTextFontIndex;
367 0 : if ( mpCGM->pElement->nAspectSourceFlags & ASF_TEXTCOLOR )
368 0 : nTextColor = mpCGM->pElement->pTextBundle->GetColor();
369 : else
370 0 : nTextColor = mpCGM->pElement->aTextBundle.GetColor();
371 :
372 0 : aAny <<= (sal_Int32)nTextColor;
373 0 : rProperty->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" )), aAny );
374 :
375 0 : sal_uInt32 nFontType = 0;
376 0 : awt::FontDescriptor aFontDescriptor;
377 0 : FontEntry* pFontEntry = mpCGM->pElement->aFontList.GetFontEntry( nTextFontIndex );
378 0 : if ( pFontEntry )
379 : {
380 0 : nFontType = pFontEntry->nFontType;
381 0 : aFontDescriptor.Name = rtl::OUString::createFromAscii( (const char*)pFontEntry->pFontName );
382 : }
383 0 : aFontDescriptor.Height = ( sal_Int16 )( ( mpCGM->pElement->nCharacterHeight * (double)1.50 ) );
384 0 : if ( nFontType & 1 )
385 0 : aFontDescriptor.Slant = awt::FontSlant_ITALIC;
386 0 : if ( nFontType & 2 )
387 0 : aFontDescriptor.Weight = awt::FontWeight::BOLD;
388 : else
389 0 : aFontDescriptor.Weight = awt::FontWeight::NORMAL;
390 :
391 0 : if ( mpCGM->pElement->eUnderlineMode != UM_OFF )
392 : {
393 0 : aFontDescriptor.Underline = awt::FontUnderline::SINGLE;
394 : }
395 0 : aAny <<= aFontDescriptor;
396 0 : rProperty->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontDescriptor" )), aAny );
397 0 : };
398 :
399 : // ---------------------------------------------------------------
400 :
401 0 : void CGMImpressOutAct::InsertPage()
402 : {
403 0 : if ( mnCurrentPage ) // eine seite ist immer vorhanden, deshalb wird die erste Seite ausgelassen
404 : {
405 0 : uno::Reference< drawing::XDrawPage > xPage( maXDrawPages->insertNewByIndex( 0xffff ), uno::UNO_QUERY );
406 0 : maXDrawPage = xPage;
407 0 : if ( ImplInitPage() == sal_False )
408 0 : mpCGM->mbStatus = sal_False;
409 : }
410 0 : mnCurrentPage++;
411 0 : };
412 :
413 : // ---------------------------------------------------------------
414 :
415 0 : void CGMImpressOutAct::BeginGroup()
416 : {
417 0 : if ( mnGroupLevel < CGM_OUTACT_MAX_GROUP_LEVEL )
418 : {
419 0 : mpGroupLevel[ mnGroupLevel ] = maXShapes->getCount();
420 : }
421 0 : mnGroupLevel++;
422 0 : mnGroupActCount = mpCGM->mnActCount;
423 0 : };
424 :
425 : // ---------------------------------------------------------------
426 :
427 0 : void CGMImpressOutAct::EndGroup()
428 : {
429 0 : if ( mnGroupLevel ) // preserve overflow
430 0 : mnGroupLevel--;
431 0 : if ( mnGroupLevel < CGM_OUTACT_MAX_GROUP_LEVEL )
432 : {
433 0 : sal_uInt32 mnFirstIndex = mpGroupLevel[ mnGroupLevel ];
434 0 : if ( mnFirstIndex == 0xffffffff )
435 0 : mnFirstIndex = 0;
436 0 : sal_uInt32 mnCurrentCount = maXShapes->getCount();
437 0 : if ( ( mnCurrentCount - mnFirstIndex ) > 1 )
438 : {
439 0 : uno::Reference< drawing::XShapeGrouper > aXShapeGrouper;
440 0 : uno::Any aAny( maXDrawPage->queryInterface( ::getCppuType(((const uno::Reference< drawing::XShapeGrouper >*)0) )));
441 0 : if( aAny >>= aXShapeGrouper )
442 : {
443 : uno::Reference< drawing::XShapes > aXShapes(
444 0 : drawing::ShapeCollection::create(comphelper::getComponentContext(maXServiceManagerSC)) );
445 0 : for ( sal_uInt32 i = mnFirstIndex; i < mnCurrentCount; i++ )
446 : {
447 0 : uno::Reference< drawing::XShape > aXShape = *(uno::Reference< drawing::XShape > *)maXShapes->getByIndex( i ).getValue();
448 0 : if (aXShape.is() )
449 : {
450 0 : aXShapes->add( aXShape );
451 : }
452 0 : }
453 0 : uno::Reference< drawing::XShapeGroup > aXShapeGroup = aXShapeGrouper->group( aXShapes );
454 0 : }
455 : }
456 : }
457 0 : };
458 :
459 : // ---------------------------------------------------------------
460 :
461 0 : void CGMImpressOutAct::EndGrouping()
462 : {
463 0 : while ( mnGroupLevel )
464 : {
465 0 : EndGroup();
466 : }
467 0 : }
468 :
469 : // ---------------------------------------------------------------
470 :
471 0 : void CGMImpressOutAct::DrawRectangle( FloatRect& rFloatRect )
472 : {
473 0 : if ( mnGroupActCount != ( mpCGM->mnActCount - 1 ) ) // POWERPOINT HACK !!!
474 : {
475 0 : if ( ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.RectangleShape" )) ) )
476 : {
477 0 : awt::Size aSize( (long)(rFloatRect.Right - rFloatRect.Left ), (long)(rFloatRect.Bottom-rFloatRect.Top ) );
478 0 : maXShape->setSize( aSize );
479 0 : maXShape->setPosition( awt::Point( (long)rFloatRect.Left, (long)rFloatRect.Top ) );
480 0 : ImplSetFillBundle();
481 : }
482 : }
483 0 : };
484 :
485 : // ---------------------------------------------------------------
486 :
487 0 : void CGMImpressOutAct::DrawEllipse( FloatPoint& rCenter, FloatPoint& rSize, double& rOrientation )
488 : {
489 0 : if ( ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.EllipseShape" )) ) )
490 : {
491 0 : drawing::CircleKind eCircleKind = drawing::CircleKind_FULL;
492 0 : uno::Any aAny( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
493 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CircleKind" )), aAny );
494 :
495 0 : long nXSize = (long)( rSize.X * 2.0 ); // Merkwuerdigkes Verhalten bei einer awt::Size von 0
496 0 : long nYSize = (long)( rSize.Y * 2.0 );
497 0 : if ( nXSize < 1 )
498 0 : nXSize = 1;
499 0 : if ( nYSize < 1 )
500 0 : nYSize = 1;
501 0 : maXShape->setSize( awt::Size( nXSize, nYSize ) );
502 0 : maXShape->setPosition( awt::Point( (long)( rCenter.X - rSize.X ), (long)( rCenter.Y - rSize.Y ) ) );
503 :
504 0 : if ( rOrientation != 0 )
505 : {
506 0 : ImplSetOrientation( rCenter, rOrientation );
507 : }
508 0 : ImplSetFillBundle();
509 : }
510 0 : };
511 :
512 : // ---------------------------------------------------------------
513 :
514 0 : void CGMImpressOutAct::DrawEllipticalArc( FloatPoint& rCenter, FloatPoint& rSize, double& rOrientation,
515 : sal_uInt32 nType, double& fStartAngle, double& fEndAngle )
516 : {
517 0 : if ( ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.EllipseShape" )) ) )
518 : {
519 0 : uno::Any aAny;
520 : drawing::CircleKind eCircleKind;
521 :
522 :
523 0 : long nXSize = (long)( rSize.X * 2.0 ); // Merkwuerdigkes Verhalten bei einer awt::Size von 0
524 0 : long nYSize = (long)( rSize.Y * 2.0 );
525 0 : if ( nXSize < 1 )
526 0 : nXSize = 1;
527 0 : if ( nYSize < 1 )
528 0 : nYSize = 1;
529 :
530 0 : maXShape->setSize( awt::Size ( nXSize, nYSize ) );
531 :
532 0 : if ( rOrientation != 0 )
533 : {
534 0 : fStartAngle += rOrientation;
535 0 : if ( fStartAngle >= 360 )
536 0 : fStartAngle -= 360;
537 0 : fEndAngle += rOrientation;
538 0 : if ( fEndAngle >= 360 )
539 0 : fEndAngle -= 360;
540 : }
541 0 : switch( nType )
542 : {
543 0 : case 0 : eCircleKind = drawing::CircleKind_SECTION; break;
544 0 : case 1 : eCircleKind = drawing::CircleKind_CUT; break;
545 0 : case 2 : eCircleKind = drawing::CircleKind_ARC; break;
546 0 : default : eCircleKind = drawing::CircleKind_FULL; break;
547 : }
548 0 : if ( (long)fStartAngle == (long)fEndAngle )
549 : {
550 0 : eCircleKind = drawing::CircleKind_FULL;
551 0 : aAny.setValue( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
552 : }
553 : else
554 : {
555 0 : aAny.setValue( &eCircleKind, ::getCppuType((const drawing::CircleKind*)0) );
556 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CircleKind" )), aAny );
557 0 : aAny <<= (sal_Int32)( (long)( fStartAngle * 100 ) );
558 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CircleStartAngle" )), aAny );
559 0 : aAny <<= (sal_Int32)( (long)( fEndAngle * 100 ) );
560 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CircleEndAngle" )), aAny );
561 : }
562 0 : maXShape->setPosition( awt::Point( (long)( rCenter.X - rSize.X ), (long)( rCenter.Y - rSize.Y ) ) );
563 0 : if ( rOrientation != 0 )
564 : {
565 0 : ImplSetOrientation( rCenter, rOrientation );
566 : }
567 0 : if ( eCircleKind == drawing::CircleKind_ARC )
568 : {
569 0 : ImplSetLineBundle();
570 : }
571 : else
572 : {
573 0 : ImplSetFillBundle();
574 0 : if ( nType == 2 )
575 : {
576 0 : ImplSetLineBundle();
577 0 : drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
578 0 : aAny.setValue( &eFillStyle, ::getCppuType((const drawing::FillStyle*)0) );
579 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )), aAny );
580 : }
581 0 : }
582 : }
583 0 : };
584 :
585 : // ---------------------------------------------------------------
586 :
587 0 : void CGMImpressOutAct::DrawBitmap( CGMBitmapDescriptor* pBmpDesc )
588 : {
589 0 : if ( pBmpDesc->mbStatus && pBmpDesc->mpBitmap )
590 : {
591 0 : FloatPoint aOrigin = pBmpDesc->mnOrigin;
592 0 : double fdx = pBmpDesc->mndx;
593 0 : double fdy = pBmpDesc->mndy;
594 :
595 0 : sal_uInt32 nMirr = BMP_MIRROR_NONE;
596 0 : if ( pBmpDesc->mbVMirror )
597 0 : nMirr |= BMP_MIRROR_VERT;
598 0 : if ( pBmpDesc->mbHMirror )
599 0 : nMirr |= BMP_MIRROR_HORZ;
600 0 : if ( nMirr != BMP_MIRROR_NONE )
601 0 : pBmpDesc->mpBitmap->Mirror( nMirr );
602 :
603 0 : mpCGM->ImplMapPoint( aOrigin );
604 0 : mpCGM->ImplMapX( fdx );
605 0 : mpCGM->ImplMapY( fdy );
606 :
607 0 : if ( ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" )) ) )
608 : {
609 0 : maXShape->setSize( awt::Size( (long)fdx, (long)fdy ) );
610 0 : maXShape->setPosition( awt::Point( (long)aOrigin.X, (long)aOrigin.Y ) );
611 :
612 0 : if ( pBmpDesc->mnOrientation != 0 )
613 : {
614 0 : ImplSetOrientation( aOrigin, pBmpDesc->mnOrientation );
615 : }
616 :
617 0 : uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( BitmapEx( *( pBmpDesc->mpBitmap ) ) ) );
618 0 : uno::Any aAny;
619 0 : aAny <<= xBitmap;
620 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicObjectFillBitmap" )), aAny );
621 :
622 : }
623 : }
624 0 : };
625 :
626 : // ---------------------------------------------------------------
627 :
628 0 : void CGMImpressOutAct::DrawPolygon( Polygon& rPoly )
629 : {
630 0 : sal_uInt16 nPoints = rPoly.GetSize();
631 :
632 0 : if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PolyPolygonShape" )) ) )
633 : {
634 0 : drawing::PointSequenceSequence aRetval;
635 :
636 : // Polygone innerhalb vrobereiten
637 0 : aRetval.realloc( 1 );
638 :
639 : // Zeiger auf aeussere Arrays holen
640 0 : drawing::PointSequence* pOuterSequence = aRetval.getArray();
641 :
642 : // Platz in Arrays schaffen
643 0 : pOuterSequence->realloc((sal_Int32)nPoints);
644 :
645 : // Pointer auf arrays holen
646 0 : awt::Point* pInnerSequence = pOuterSequence->getArray();
647 :
648 0 : for( sal_uInt16 n = 0; n < nPoints; n++ )
649 0 : *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() );
650 :
651 0 : uno::Any aParam;
652 0 : aParam <<= aRetval;
653 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygon" )), aParam );
654 0 : ImplSetFillBundle();
655 : }
656 0 : };
657 :
658 :
659 : // ---------------------------------------------------------------
660 :
661 0 : void CGMImpressOutAct::DrawPolyLine( Polygon& rPoly )
662 : {
663 0 : sal_uInt16 nPoints = rPoly.GetSize();
664 :
665 0 : if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PolyLineShape" )) ) )
666 : {
667 0 : drawing::PointSequenceSequence aRetval;
668 :
669 : // Polygone innerhalb vrobereiten
670 0 : aRetval.realloc( 1 );
671 :
672 : // Zeiger auf aeussere Arrays holen
673 0 : drawing::PointSequence* pOuterSequence = aRetval.getArray();
674 :
675 : // Platz in Arrays schaffen
676 0 : pOuterSequence->realloc((sal_Int32)nPoints);
677 :
678 : // Pointer auf arrays holen
679 0 : awt::Point* pInnerSequence = pOuterSequence->getArray();
680 :
681 0 : for( sal_uInt16 n = 0; n < nPoints; n++ )
682 0 : *pInnerSequence++ = awt::Point( rPoly[ n ].X(), rPoly[n].Y() );
683 :
684 0 : uno::Any aParam;
685 0 : aParam <<= aRetval;
686 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygon" )), aParam );
687 0 : ImplSetLineBundle();
688 : }
689 0 : };
690 :
691 : // ---------------------------------------------------------------
692 :
693 0 : void CGMImpressOutAct::DrawPolybezier( Polygon& rPolygon )
694 : {
695 0 : sal_uInt16 nPoints = rPolygon.GetSize();
696 0 : if ( ( nPoints > 1 ) && ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.OpenBezierShape" )) ) )
697 : {
698 0 : drawing::PolyPolygonBezierCoords aRetval;
699 :
700 0 : aRetval.Coordinates.realloc( 1 );
701 0 : aRetval.Flags.realloc( 1 );
702 :
703 : // Zeiger auf aeussere Arrays holen
704 0 : drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
705 0 : drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
706 :
707 : // Platz in Arrays schaffen
708 0 : pOuterSequence->realloc( nPoints );
709 0 : pOuterFlags->realloc( nPoints );
710 :
711 0 : awt::Point* pInnerSequence = pOuterSequence->getArray();
712 0 : drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
713 :
714 0 : for( sal_uInt16 i = 0; i < nPoints; i++ )
715 : {
716 0 : *pInnerSequence++ = awt::Point( rPolygon[ i ].X(), rPolygon[ i ].Y() );
717 0 : *pInnerFlags++ = (drawing::PolygonFlags)rPolygon.GetFlags( i );
718 : }
719 0 : uno::Any aParam;
720 0 : aParam <<= aRetval;
721 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier" )), aParam );
722 0 : ImplSetLineBundle();
723 : }
724 0 : };
725 :
726 : // ---------------------------------------------------------------
727 :
728 0 : void CGMImpressOutAct::DrawPolyPolygon( PolyPolygon& rPolyPolygon )
729 : {
730 0 : sal_uInt32 nNumPolys = rPolyPolygon.Count();
731 0 : if ( nNumPolys && ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ClosedBezierShape" )) ) )
732 : {
733 0 : drawing::PolyPolygonBezierCoords aRetval;
734 :
735 : // Polygone innerhalb vrobereiten
736 0 : aRetval.Coordinates.realloc((sal_Int32)nNumPolys);
737 0 : aRetval.Flags.realloc((sal_Int32)nNumPolys);
738 :
739 : // Zeiger auf aeussere Arrays holen
740 0 : drawing::PointSequence* pOuterSequence = aRetval.Coordinates.getArray();
741 0 : drawing::FlagSequence* pOuterFlags = aRetval.Flags.getArray();
742 :
743 0 : for( sal_uInt16 a = 0; a < nNumPolys; a++ )
744 : {
745 0 : Polygon aPolygon( rPolyPolygon.GetObject( a ) );
746 0 : sal_uInt32 nNumPoints = aPolygon.GetSize();
747 :
748 : // Platz in Arrays schaffen
749 0 : pOuterSequence->realloc((sal_Int32)nNumPoints);
750 0 : pOuterFlags->realloc((sal_Int32)nNumPoints);
751 :
752 : // Pointer auf arrays holen
753 0 : awt::Point* pInnerSequence = pOuterSequence->getArray();
754 0 : drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
755 :
756 0 : for( sal_uInt16 b = 0; b < nNumPoints; b++ )
757 : {
758 0 : *pInnerSequence++ = awt::Point( aPolygon.GetPoint( b ).X(), aPolygon.GetPoint( b ).Y() ) ;
759 0 : *pInnerFlags++ = (drawing::PolygonFlags)aPolygon.GetFlags( b );
760 : }
761 0 : pOuterSequence++;
762 0 : pOuterFlags++;
763 0 : }
764 0 : uno::Any aParam;
765 0 : aParam <<= aRetval;
766 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PolyPolygonBezier" )), aParam);
767 0 : ImplSetFillBundle();
768 : }
769 0 : };
770 :
771 : // ---------------------------------------------------------------
772 :
773 0 : void CGMImpressOutAct::DrawText( awt::Point& rTextPos, awt::Size& rTextSize, char* pString, sal_uInt32 /*nSize*/, FinalFlag eFlag )
774 : {
775 0 : if ( ImplCreateShape( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TextShape" )) ) )
776 : {
777 0 : uno::Any aAny;
778 0 : long nWidth = rTextSize.Width;
779 0 : long nHeight = rTextSize.Height;
780 :
781 0 : awt::Point aTextPos( rTextPos );
782 0 : switch ( mpCGM->pElement->eTextAlignmentV )
783 : {
784 : case TAV_HALF :
785 : {
786 0 : aTextPos.Y -= static_cast<sal_Int32>( ( mpCGM->pElement->nCharacterHeight * 1.5 ) / 2 );
787 : }
788 0 : break;
789 :
790 : case TAV_BASE :
791 : case TAV_BOTTOM :
792 : case TAV_NORMAL :
793 0 : aTextPos.Y -= static_cast<sal_Int32>( mpCGM->pElement->nCharacterHeight * 1.5 );
794 : case TAV_TOP :
795 0 : break;
796 : case TAV_CAP:
797 : case TAV_CONT:
798 0 : break; // -Wall these two were not here.
799 : }
800 :
801 0 : if ( nWidth < 0 )
802 : {
803 0 : nWidth = -nWidth;
804 : }
805 0 : else if ( nWidth == 0 )
806 : {
807 0 : nWidth = -1;
808 : }
809 0 : if ( nHeight < 0 )
810 : {
811 0 : nHeight = -nHeight;
812 : }
813 0 : else if ( nHeight == 0 )
814 : {
815 0 : nHeight = -1;
816 : }
817 0 : maXShape->setPosition( aTextPos );
818 0 : maXShape->setSize( awt::Size( nWidth, nHeight ) );
819 0 : double nX = mpCGM->pElement->nCharacterOrientation[ 2 ];
820 0 : double nY = mpCGM->pElement->nCharacterOrientation[ 3 ];
821 0 : double nOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
822 0 : if ( nY < 0 )
823 0 : nOrientation = 360 - nOrientation;
824 :
825 0 : if ( nOrientation )
826 : {
827 0 : aAny <<= (sal_Int32)( aTextPos.X );
828 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotationPointX" )), aAny );
829 0 : aAny <<= (sal_Int32)( aTextPos.Y + nHeight );
830 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotationPointY" )), aAny );
831 0 : aAny <<= (sal_Int32)( (sal_Int32)( nOrientation * 100 ) );
832 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RotateAngle" )), aAny );
833 : }
834 0 : if ( nWidth == -1 )
835 : {
836 0 : sal_Bool bTrue( sal_True );
837 0 : aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0 ));
838 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowWidth" )), aAny );
839 :
840 : drawing::TextAdjust eTextAdjust;
841 0 : switch ( mpCGM->pElement->eTextAlignmentH )
842 : {
843 : case TAH_RIGHT :
844 0 : eTextAdjust = drawing::TextAdjust_RIGHT;
845 0 : break;
846 : case TAH_LEFT :
847 : case TAH_CONT :
848 : case TAH_NORMAL :
849 0 : eTextAdjust = drawing::TextAdjust_LEFT;
850 0 : break;
851 : case TAH_CENTER :
852 0 : eTextAdjust = drawing::TextAdjust_CENTER;
853 0 : break;
854 : }
855 0 : aAny <<= eTextAdjust;
856 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextHorizontalAdjust" )), aAny );
857 : }
858 0 : if ( nHeight == -1 )
859 : {
860 0 : sal_Bool bTrue = sal_True;
861 0 : aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0) );
862 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" )), aAny );
863 : }
864 0 : uno::Reference< text::XText > xText;
865 0 : uno::Any aFirstQuery( maXShape->queryInterface( ::getCppuType((const uno::Reference< text::XText >*)0) ));
866 0 : if( aFirstQuery >>= xText )
867 : {
868 0 : String aStr( rtl::OUString::createFromAscii( pString ) );
869 :
870 0 : uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
871 : {
872 0 : aXTextCursor->gotoEnd( sal_False );
873 0 : uno::Reference< text::XTextRange > aCursorText;
874 0 : uno::Any aSecondQuery( aXTextCursor->queryInterface( ::getCppuType((const uno::Reference< text::XTextRange >*)0) ));
875 0 : if ( aSecondQuery >>= aCursorText )
876 : {
877 0 : uno::Reference< beans::XPropertySet > aCursorPropSet;
878 :
879 0 : uno::Any aQuery( aCursorText->queryInterface( ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ));
880 0 : if( aQuery >>= aCursorPropSet )
881 : {
882 0 : if ( nWidth != -1 ) // paragraph adjusting in a valid textbox ?
883 : {
884 0 : switch ( mpCGM->pElement->eTextAlignmentH )
885 : {
886 : case TAH_RIGHT :
887 0 : aAny <<= (sal_Int16)style::HorizontalAlignment_RIGHT;
888 0 : break;
889 : case TAH_LEFT :
890 : case TAH_CONT :
891 : case TAH_NORMAL :
892 0 : aAny <<= (sal_Int16)style::HorizontalAlignment_LEFT;
893 0 : break;
894 : case TAH_CENTER :
895 0 : aAny <<= (sal_Int16)style::HorizontalAlignment_CENTER;
896 0 : break;
897 : }
898 0 : aCursorPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParaAdjust" )), aAny );
899 : }
900 0 : if ( nWidth > 0 && nHeight > 0 ) // restricted text
901 : {
902 0 : sal_Bool bTrue = sal_True;
903 0 : aAny.setValue( &bTrue, ::getCppuType((const sal_Bool*)0));
904 0 : maXPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextFitToSize" )), aAny );
905 : }
906 0 : aCursorText->setString( aStr );
907 0 : aXTextCursor->gotoEnd( sal_True );
908 0 : ImplSetTextBundle( aCursorPropSet );
909 0 : }
910 0 : }
911 0 : }
912 : }
913 0 : if ( eFlag == FF_NOT_FINAL )
914 : {
915 0 : nFinalTextCount = maXShapes->getCount();
916 0 : }
917 : }
918 0 : };
919 :
920 : // ---------------------------------------------------------------
921 :
922 0 : void CGMImpressOutAct::AppendText( char* pString, sal_uInt32 /*nSize*/, FinalFlag /*eFlag*/ )
923 : {
924 0 : if ( nFinalTextCount )
925 : {
926 0 : uno::Reference< drawing::XShape > aShape = *(uno::Reference< drawing::XShape > *)maXShapes->getByIndex( nFinalTextCount - 1 ).getValue();
927 0 : if ( aShape.is() )
928 : {
929 0 : uno::Reference< text::XText > xText;
930 0 : uno::Any aFirstQuery( aShape->queryInterface( ::getCppuType((const uno::Reference< text::XText >*)0)) );
931 0 : if( aFirstQuery >>= xText )
932 : {
933 0 : String aStr( rtl::OUString::createFromAscii( pString ) );
934 :
935 0 : uno::Reference< text::XTextCursor > aXTextCursor( xText->createTextCursor() );
936 0 : if ( aXTextCursor.is() )
937 : {
938 0 : aXTextCursor->gotoEnd( sal_False );
939 0 : uno::Reference< text::XTextRange > aCursorText;
940 0 : uno::Any aSecondQuery(aXTextCursor->queryInterface( ::getCppuType((const uno::Reference< text::XTextRange >*)0) ));
941 0 : if ( aSecondQuery >>= aCursorText )
942 : {
943 0 : uno::Reference< beans::XPropertySet > aPropSet;
944 0 : uno::Any aQuery(aCursorText->queryInterface( ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ));
945 0 : if( aQuery >>= aPropSet )
946 : {
947 0 : aCursorText->setString( aStr );
948 0 : aXTextCursor->gotoEnd( sal_True );
949 0 : ImplSetTextBundle( aPropSet );
950 0 : }
951 0 : }
952 0 : }
953 0 : }
954 0 : }
955 : }
956 0 : }
957 :
958 : // ---------------------------------------------------------------
959 : // nCount != 0 -> Append Text
960 0 : sal_uInt32 CGMImpressOutAct::DrawText( TextEntry* /*pTextEntry*/, NodeFrameSet& /*rNodeFrameSet*/, sal_uInt32 /*nObjCount*/ )
961 : {
962 0 : return 0;
963 : }
964 :
965 : // ---------------------------------------------------------------
966 :
967 0 : void CGMImpressOutAct::DrawChart()
968 : {
969 0 : }
970 :
971 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|