LCOV - code coverage report
Current view: top level - filter/source/graphicfilter/icgm - actimpr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 502 0.0 %
Date: 2014-04-14 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10