LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviews9.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 405 0.2 %
Date: 2015-06-13 12:38:46 Functions: 2 5 40.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 <config_features.h>
      21             : 
      22             : #include "DrawViewShell.hxx"
      23             : #include <vcl/wrkwin.hxx>
      24             : #include <svx/xgrad.hxx>
      25             : #include <svx/svdpagv.hxx>
      26             : #include <svx/xlnwtit.hxx>
      27             : #include <svx/xlndsit.hxx>
      28             : #include <svx/xflhtit.hxx>
      29             : #include <svx/xflgrit.hxx>
      30             : #include <svx/xlnclit.hxx>
      31             : #include <svx/xflclit.hxx>
      32             : #include <sfx2/bindings.hxx>
      33             : 
      34             : #include <sfx2/dispatch.hxx>
      35             : #include <svl/intitem.hxx>
      36             : #include <sfx2/app.hxx>
      37             : #include <sfx2/request.hxx>
      38             : #include <svl/stritem.hxx>
      39             : #include <svx/svxids.hrc>
      40             : #include <svx/xtable.hxx>
      41             : #include <svx/gallery.hxx>
      42             : #include <vcl/graph.hxx>
      43             : #include <svx/svdograf.hxx>
      44             : #include <svx/svdoole2.hxx>
      45             : #include <sot/storage.hxx>
      46             : #include <svl/whiter.hxx>
      47             : #include <basic/sbstar.hxx>
      48             : 
      49             : #include <sfx2/viewfrm.hxx>
      50             : 
      51             : #include "app.hrc"
      52             : #include "strings.hrc"
      53             : #include "Window.hxx"
      54             : #include "drawdoc.hxx"
      55             : #include "drawview.hxx"
      56             : #include "DrawDocShell.hxx"
      57             : #include "sdresid.hxx"
      58             : #include "fupoor.hxx"
      59             : 
      60             : #include <svx/galleryitem.hxx>
      61             : #include <com/sun/star/gallery/GalleryItemType.hpp>
      62             : #include <com/sun/star/drawing/LineStyle.hpp>
      63             : #include <boost/scoped_ptr.hpp>
      64             : 
      65             : using namespace com::sun::star;
      66             : 
      67             : namespace sd {
      68             : 
      69           0 : void DrawViewShell::ExecGallery(SfxRequest& rReq)
      70             : {
      71             :     // nothing is executed during a slide show!
      72           0 :     if(HasCurrentFunction(SID_PRESENTATION))
      73           0 :         return;
      74             : 
      75           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      76             : 
      77           0 :     SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, false );
      78           0 :     if ( !pGalleryItem )
      79           0 :         return;
      80             : 
      81           0 :     GetDocSh()->SetWaitCursor( true );
      82             : 
      83           0 :     sal_Int8 nType( pGalleryItem->GetType() );
      84             :     // insert graphic
      85           0 :     if (nType == com::sun::star::gallery::GalleryItemType::GRAPHIC)
      86             :     {
      87           0 :         Graphic aGraphic( pGalleryItem->GetGraphic() );
      88             : 
      89             :         // reduce size if necessary
      90           0 :         ScopedVclPtrInstance< Window > aWindow(GetActiveWindow());
      91           0 :         aWindow->SetMapMode(aGraphic.GetPrefMapMode());
      92           0 :         Size aSizePix = aWindow->LogicToPixel(aGraphic.GetPrefSize());
      93           0 :         aWindow->SetMapMode( MapMode(MAP_100TH_MM) );
      94           0 :         Size aSize = aWindow->PixelToLogic(aSizePix);
      95             : 
      96             :         // constrain size to page size if necessary
      97           0 :         SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
      98           0 :         Size aPageSize = pPage->GetSize();
      99           0 :         aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
     100           0 :         aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
     101             : 
     102             :         // If the image is too large we make it fit into the page
     103           0 :         if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width()   > aPageSize.Width() ) ) &&
     104           0 :             aSize.Height() && aPageSize.Height() )
     105             :         {
     106           0 :             float fGrfWH =  (float)aSize.Width() /
     107           0 :                             (float)aSize.Height();
     108           0 :             float fWinWH =  (float)aPageSize.Width() /
     109           0 :                             (float)aPageSize.Height();
     110             : 
     111             :             // constrain size to page size if necessary
     112           0 :             if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
     113             :             {
     114           0 :                 aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
     115           0 :                 aSize.Height()= aPageSize.Height();
     116             :             }
     117             :             else
     118             :             {
     119           0 :                 aSize.Width() = aPageSize.Width();
     120           0 :                 aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
     121             :             }
     122             :         }
     123             : 
     124             :         // set output rectangle for graphic
     125           0 :         Point aPnt ((aPageSize.Width()  - aSize.Width())  / 2,
     126           0 :                     (aPageSize.Height() - aSize.Height()) / 2);
     127           0 :         aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
     128           0 :         Rectangle aRect (aPnt, aSize);
     129             : 
     130           0 :         SdrGrafObj* pGrafObj = NULL;
     131             : 
     132           0 :         bool bInsertNewObject = true;
     133             : 
     134           0 :         if ( mpDrawView->AreObjectsMarked() )
     135             :         {
     136             :             // is there a empty graphic object?
     137           0 :             const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
     138             : 
     139           0 :             if (rMarkList.GetMarkCount() == 1)
     140             :             {
     141           0 :                 SdrMark* pMark = rMarkList.GetMark(0);
     142           0 :                 SdrObject* pObj = pMark->GetMarkedSdrObj();
     143             : 
     144           0 :                 if (pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF)
     145             :                 {
     146           0 :                     pGrafObj = static_cast<SdrGrafObj*>(pObj);
     147             : 
     148           0 :                     if( pGrafObj->IsEmptyPresObj() )
     149             :                     {
     150             :                         // the empty graphic object gets a new graphic
     151           0 :                         bInsertNewObject = false;
     152             : 
     153           0 :                         SdrGrafObj* pNewGrafObj = pGrafObj->Clone();
     154           0 :                         pNewGrafObj->SetEmptyPresObj(false);
     155           0 :                         pNewGrafObj->SetOutlinerParaObject(NULL);
     156           0 :                         pNewGrafObj->SetGraphic(aGraphic);
     157             : 
     158           0 :                         OUString aStr(mpDrawView->GetDescriptionOfMarkedObjects());
     159           0 :                         aStr += " " + SD_RESSTR(STR_UNDO_REPLACE);
     160           0 :                         mpDrawView->BegUndo(aStr);
     161           0 :                         SdrPageView* pPV = mpDrawView->GetSdrPageView();
     162           0 :                         mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj);
     163           0 :                         mpDrawView->EndUndo();
     164             :                     }
     165             :                 }
     166             :             }
     167             :         }
     168             : 
     169           0 :         if( bInsertNewObject )
     170             :         {
     171           0 :             pGrafObj = new SdrGrafObj(aGraphic, aRect);
     172           0 :             SdrPageView* pPV = mpDrawView->GetSdrPageView();
     173           0 :             mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER);
     174           0 :         }
     175             :     }
     176             :     // insert sound
     177           0 :     else if( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
     178             :     {
     179           0 :         const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
     180           0 :         GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON, &aMediaURLItem, 0L );
     181             :     }
     182             : 
     183           0 :     GetDocSh()->SetWaitCursor( false );
     184             : }
     185             : 
     186             : /**
     187             :  * Edit macros for attribute configuration
     188             :  */
     189             : 
     190             : /* the work flow to adjust the attributes is nearly everywhere the same
     191             :    1. read existing attributes
     192             :    2. read parameter from the basic-set
     193             :    3. delete selected item from the attribute-set
     194             :    4. create new attribute-item
     195             :    5. insert item into set      */
     196           0 : void DrawViewShell::AttrExec (SfxRequest &rReq)
     197             : {
     198             :     // nothing is executed during a slide show!
     199           0 :     if(HasCurrentFunction(SID_PRESENTATION))
     200           0 :         return;
     201             : 
     202           0 :     CheckLineTo (rReq);
     203             : 
     204           0 :     SfxBindings&    rBindings = GetViewFrame()->GetBindings();
     205           0 :     boost::scoped_ptr<SfxItemSet> pAttr(new SfxItemSet ( GetDoc()->GetPool() ));
     206             : 
     207           0 :     GetView()->GetAttributes( *pAttr );
     208           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     209             : 
     210           0 :     switch (rReq.GetSlot ())
     211             :     {
     212             :         // set new fill-style
     213             :         case SID_SETFILLSTYLE :
     214           0 :             if (pArgs)
     215           0 :                 if (pArgs->Count () == 1)
     216             :                 {
     217           0 :                     SFX_REQUEST_ARG (rReq, pFillStyle, SfxUInt32Item, ID_VAL_STYLE, false);
     218           0 :                     if (CHECK_RANGE (drawing::FillStyle_NONE, (sal_Int32)pFillStyle->GetValue (), drawing::FillStyle_BITMAP))
     219             :                     {
     220           0 :                         pAttr->ClearItem (XATTR_FILLSTYLE);
     221           0 :                         pAttr->Put (XFillStyleItem ((drawing::FillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE);
     222           0 :                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     223             :                     }
     224             : #if HAVE_FEATURE_SCRIPTING
     225           0 :                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     226             : #endif
     227           0 :                     break;
     228             :                 }
     229             : #if HAVE_FEATURE_SCRIPTING
     230           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     231             : #endif
     232           0 :             break;
     233             : 
     234             :         // determine new line style
     235             :         case SID_SETLINESTYLE :
     236           0 :             if (pArgs)
     237           0 :                 if (pArgs->Count () == 1)
     238             :                 {
     239           0 :                     SFX_REQUEST_ARG (rReq, pLineStyle, SfxUInt32Item, ID_VAL_STYLE, false);
     240           0 :                     if (CHECK_RANGE (drawing::LineStyle_NONE, (sal_Int32)pLineStyle->GetValue (), drawing::LineStyle_DASH))
     241             :                     {
     242           0 :                         pAttr->ClearItem (XATTR_LINESTYLE);
     243           0 :                         pAttr->Put (XLineStyleItem ((drawing::LineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE);
     244           0 :                         rBindings.Invalidate (SID_ATTR_LINE_STYLE);
     245             :                     }
     246             : #if HAVE_FEATURE_SCRIPTING
     247           0 :                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     248             : #endif
     249           0 :                     break;
     250             :                 }
     251             : #if HAVE_FEATURE_SCRIPTING
     252           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     253             : #endif
     254           0 :             break;
     255             : 
     256             :         // set line width
     257             :         case SID_SETLINEWIDTH :
     258           0 :             if (pArgs)
     259           0 :                 if (pArgs->Count () == 1)
     260             :                 {
     261           0 :                     SFX_REQUEST_ARG (rReq, pLineWidth, SfxUInt32Item, ID_VAL_WIDTH, false);
     262           0 :                     pAttr->ClearItem (XATTR_LINEWIDTH);
     263           0 :                     pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH);
     264           0 :                     rBindings.Invalidate (SID_ATTR_LINE_WIDTH);
     265           0 :                     break;
     266             :                 }
     267             : #if HAVE_FEATURE_SCRIPTING
     268           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     269             : #endif
     270           0 :             break;
     271             : 
     272             :         case SID_SETFILLCOLOR :
     273           0 :             if (pArgs)
     274           0 :                 if (pArgs->Count () == 3)
     275             :                 {
     276           0 :                     SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, false);
     277           0 :                     SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, false);
     278           0 :                     SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, false);
     279             : 
     280           0 :                     pAttr->ClearItem (XATTR_FILLCOLOR);
     281           0 :                     pAttr->ClearItem (XATTR_FILLSTYLE);
     282           0 :                     pAttr->Put (XFillColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
     283           0 :                                                            (sal_uInt8) pGreen->GetValue (),
     284           0 :                                                            (sal_uInt8) pBlue->GetValue ())),
     285           0 :                                 XATTR_FILLCOLOR);
     286           0 :                     pAttr->Put (XFillStyleItem (drawing::FillStyle_SOLID), XATTR_FILLSTYLE);
     287           0 :                     rBindings.Invalidate (SID_ATTR_FILL_COLOR);
     288           0 :                     rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     289           0 :                     break;
     290             :                 }
     291             : #if HAVE_FEATURE_SCRIPTING
     292           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     293             : #endif
     294           0 :             break;
     295             : 
     296             :         case SID_SETLINECOLOR :
     297           0 :             if (pArgs)
     298           0 :                 if (pArgs->Count () == 3)
     299             :                 {
     300           0 :                     SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, false);
     301           0 :                     SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, false);
     302           0 :                     SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, false);
     303             : 
     304           0 :                     pAttr->ClearItem (XATTR_LINECOLOR);
     305           0 :                     pAttr->Put (XLineColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
     306           0 :                                                            (sal_uInt8) pGreen->GetValue (),
     307           0 :                                                            (sal_uInt8) pBlue->GetValue ())),
     308           0 :                                 XATTR_LINECOLOR);
     309           0 :                     rBindings.Invalidate (SID_ATTR_LINE_COLOR);
     310           0 :                     break;
     311             :                 }
     312             : #if HAVE_FEATURE_SCRIPTING
     313           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     314             : #endif
     315           0 :             break;
     316             : 
     317             :         case SID_SETGRADSTARTCOLOR :
     318             :         case SID_SETGRADENDCOLOR :
     319           0 :             if (pArgs)
     320           0 :                 if (pArgs->Count () == 4)
     321             :                 {
     322           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     323           0 :                     SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, false);
     324           0 :                     SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, false);
     325           0 :                     SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, false);
     326             : 
     327           0 :                     XGradientListRef pGradientList = GetDoc()->GetGradientList ();
     328           0 :                     long          nCounts        = pGradientList->Count ();
     329           0 :                     Color         aColor ((sal_uInt8) pRed->GetValue (),
     330           0 :                                           (sal_uInt8) pGreen->GetValue (),
     331           0 :                                           (sal_uInt8) pBlue->GetValue ());
     332             :                     long i;
     333             : 
     334           0 :                     pAttr->ClearItem (XATTR_FILLGRADIENT);
     335           0 :                     pAttr->ClearItem (XATTR_FILLSTYLE);
     336             : 
     337           0 :                     for ( i = 0; i < nCounts; i ++)
     338             :                     {
     339           0 :                         XGradientEntry *pEntry = pGradientList->GetGradient (i);
     340             : 
     341           0 :                         if (pEntry->GetName () == pName->GetValue ())
     342             :                         {
     343           0 :                             XGradient aGradient(pEntry->GetGradient());
     344             : 
     345           0 :                             if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) aGradient.SetStartColor (aColor);
     346           0 :                             else aGradient.SetEndColor (aColor);
     347             : 
     348           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
     349           0 :                             pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
     350           0 :                             break;
     351             :                         }
     352             :                     }
     353             : 
     354           0 :                     if (i >= nCounts)
     355             :                     {
     356           0 :                         Color aBlack (0, 0, 0);
     357           0 :                         XGradient aGradient ((rReq.GetSlot () == SID_SETGRADSTARTCOLOR)
     358             :                                                  ? aColor
     359             :                                                  : aBlack,
     360           0 :                                              (rReq.GetSlot () == SID_SETGRADENDCOLOR)
     361             :                                                  ? aColor
     362           0 :                                                  : aBlack);
     363             : 
     364           0 :                         GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
     365             : 
     366           0 :                         pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
     367           0 :                         pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
     368             :                     }
     369             : 
     370           0 :                     rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     371           0 :                     rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
     372           0 :                     break;
     373             :                 }
     374             : #if HAVE_FEATURE_SCRIPTING
     375           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     376             : #endif
     377           0 :             break;
     378             : 
     379             :         case SID_SETHATCHCOLOR :
     380           0 :             if (pArgs)
     381           0 :                 if (pArgs->Count () == 4)
     382             :                 {
     383           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     384           0 :                     SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, false);
     385           0 :                     SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, false);
     386           0 :                     SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, false);
     387             : 
     388           0 :                     XHatchListRef pHatchList = GetDoc()->GetHatchList ();
     389           0 :                     long       nCounts     = pHatchList->Count ();
     390           0 :                     Color      aColor ((sal_uInt8) pRed->GetValue (),
     391           0 :                                        (sal_uInt8) pGreen->GetValue (),
     392           0 :                                        (sal_uInt8) pBlue->GetValue ());
     393             :                     long i;
     394             : 
     395           0 :                     pAttr->ClearItem (XATTR_FILLHATCH);
     396           0 :                     pAttr->ClearItem (XATTR_FILLSTYLE);
     397             : 
     398           0 :                     for ( i = 0; i < nCounts; i ++)
     399             :                     {
     400           0 :                         XHatchEntry *pEntry = pHatchList->GetHatch (i);
     401             : 
     402           0 :                         if (pEntry->GetName () == pName->GetValue ())
     403             :                         {
     404           0 :                             XHatch aHatch(pEntry->GetHatch());
     405             : 
     406           0 :                             aHatch.SetColor (aColor);
     407             : 
     408           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
     409           0 :                             pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
     410           0 :                             break;
     411             :                         }
     412             :                     }
     413             : 
     414           0 :                     if (i >= nCounts)
     415             :                     {
     416           0 :                         XHatch aHatch (aColor);
     417             : 
     418           0 :                         GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
     419             : 
     420           0 :                         pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
     421           0 :                         pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
     422             :                     }
     423             : 
     424           0 :                     rBindings.Invalidate (SID_ATTR_FILL_HATCH);
     425           0 :                     rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     426           0 :                     break;
     427             :                 }
     428             : #if HAVE_FEATURE_SCRIPTING
     429           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     430             : #endif
     431           0 :             break;
     432             : 
     433             :         // configuration for line-dash
     434             :         case SID_DASH :
     435           0 :             if (pArgs)
     436           0 :                 if (pArgs->Count () == 7)
     437             :                 {
     438           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     439           0 :                     SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, false);
     440           0 :                     SFX_REQUEST_ARG (rReq, pDots, SfxUInt32Item, ID_VAL_DOTS, false);
     441           0 :                     SFX_REQUEST_ARG (rReq, pDotLen, SfxUInt32Item, ID_VAL_DOTLEN, false);
     442           0 :                     SFX_REQUEST_ARG (rReq, pDashes, SfxUInt32Item, ID_VAL_DASHES, false);
     443           0 :                     SFX_REQUEST_ARG (rReq, pDashLen, SfxUInt32Item, ID_VAL_DASHLEN, false);
     444           0 :                     SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, false);
     445             : 
     446           0 :                     if (CHECK_RANGE (css::drawing::DashStyle_RECT, (sal_Int32)pStyle->GetValue (), css::drawing::DashStyle_ROUNDRELATIVE))
     447             :                     {
     448           0 :                         XDash aNewDash ((css::drawing::DashStyle) pStyle->GetValue (), (short) pDots->GetValue (), pDotLen->GetValue (),
     449           0 :                                         (short) pDashes->GetValue (), pDashLen->GetValue (), pDistance->GetValue ());
     450             : 
     451           0 :                         pAttr->ClearItem (XATTR_LINEDASH);
     452           0 :                         pAttr->ClearItem (XATTR_LINESTYLE);
     453             : 
     454           0 :                         XDashListRef pDashList = GetDoc()->GetDashList();
     455           0 :                         long       nCounts    = pDashList->Count ();
     456           0 :                         XDashEntry *pEntry    = new XDashEntry (aNewDash, pName->GetValue ());
     457             :                         long i;
     458             : 
     459           0 :                         for ( i = 0; i < nCounts; i++ )
     460           0 :                             if (pDashList->GetDash (i)->GetName () == pName->GetValue ())
     461           0 :                                 break;
     462             : 
     463           0 :                         if (i < nCounts)
     464           0 :                             pDashList->Replace (pEntry, i);
     465             :                         else
     466           0 :                             pDashList->Insert (pEntry);
     467             : 
     468           0 :                         pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH);
     469           0 :                         pAttr->Put (XLineStyleItem (drawing::LineStyle_DASH), XATTR_LINESTYLE);
     470           0 :                         rBindings.Invalidate (SID_ATTR_LINE_DASH);
     471           0 :                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     472             :                     }
     473             : #if HAVE_FEATURE_SCRIPTING
     474           0 :                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     475             : #endif
     476           0 :                     break;
     477             :                 }
     478             : #if HAVE_FEATURE_SCRIPTING
     479           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     480             : #endif
     481           0 :             break;
     482             : 
     483             :         // configuration for gradients
     484             :         case SID_GRADIENT :
     485           0 :             if (pArgs)
     486           0 :                 if (pArgs->Count () == 8)
     487             :                 {
     488           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     489           0 :                     SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, false);
     490           0 :                     SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, false);
     491           0 :                     SFX_REQUEST_ARG (rReq, pBorder, SfxUInt32Item, ID_VAL_BORDER, false);
     492           0 :                     SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, false);
     493           0 :                     SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, false);
     494           0 :                     SFX_REQUEST_ARG (rReq, pStart, SfxUInt32Item, ID_VAL_STARTINTENS, false);
     495           0 :                     SFX_REQUEST_ARG (rReq, pEnd, SfxUInt32Item, ID_VAL_ENDINTENS, false);
     496             : 
     497           0 :                     if (CHECK_RANGE (css::awt::GradientStyle_LINEAR, (sal_Int32)pStyle->GetValue (), css::awt::GradientStyle_RECT) &&
     498           0 :                         CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360) &&
     499           0 :                         CHECK_RANGE (0, (sal_Int32)pBorder->GetValue (), 100) &&
     500           0 :                         CHECK_RANGE (0, (sal_Int32)pCenterX->GetValue (), 100) &&
     501           0 :                         CHECK_RANGE (0, (sal_Int32)pCenterY->GetValue (), 100) &&
     502           0 :                         CHECK_RANGE (0, (sal_Int32)pStart->GetValue (), 100) &&
     503           0 :                         CHECK_RANGE (0, (sal_Int32)pEnd->GetValue (), 100))
     504             :                     {
     505           0 :                         pAttr->ClearItem (XATTR_FILLGRADIENT);
     506           0 :                         pAttr->ClearItem (XATTR_FILLSTYLE);
     507             : 
     508           0 :                         XGradientListRef pGradientList = GetDoc()->GetGradientList ();
     509           0 :                         long           nCounts        = pGradientList->Count ();
     510             :                         long i;
     511             : 
     512           0 :                         for ( i = 0; i < nCounts; i++ )
     513             :                         {
     514           0 :                             XGradientEntry *pEntry = pGradientList->GetGradient (i);
     515             : 
     516           0 :                             if (pEntry->GetName () == pName->GetValue ())
     517             :                             {
     518           0 :                                 XGradient aGradient(pEntry->GetGradient());
     519             : 
     520           0 :                                 aGradient.SetGradientStyle ((css::awt::GradientStyle) pStyle->GetValue ());
     521           0 :                                 aGradient.SetAngle (pAngle->GetValue () * 10);
     522           0 :                                 aGradient.SetBorder ((short) pBorder->GetValue ());
     523           0 :                                 aGradient.SetXOffset ((short) pCenterX->GetValue ());
     524           0 :                                 aGradient.SetYOffset ((short) pCenterY->GetValue ());
     525           0 :                                 aGradient.SetStartIntens ((short) pStart->GetValue ());
     526           0 :                                 aGradient.SetEndIntens ((short) pEnd->GetValue ());
     527             : 
     528           0 :                                 pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
     529           0 :                                 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
     530           0 :                                 break;
     531             :                             }
     532             :                         }
     533             : 
     534           0 :                         if (i >= nCounts)
     535             :                         {
     536           0 :                             Color aBlack (0, 0, 0);
     537           0 :                             XGradient aGradient (aBlack, aBlack, (css::awt::GradientStyle) pStyle->GetValue (),
     538           0 :                                                  pAngle->GetValue () * 10, (short) pCenterX->GetValue (),
     539           0 :                                                  (short) pCenterY->GetValue (), (short) pBorder->GetValue (),
     540           0 :                                                  (short) pStart->GetValue (), (short) pEnd->GetValue ());
     541             : 
     542           0 :                             pGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
     543           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
     544           0 :                             pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
     545             :                         }
     546             : 
     547           0 :                         rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
     548           0 :                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     549             :                     }
     550             : #if HAVE_FEATURE_SCRIPTING
     551           0 :                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     552             : #endif
     553           0 :                     break;
     554             :                 }
     555             : #if HAVE_FEATURE_SCRIPTING
     556           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     557             : #endif
     558           0 :             break;
     559             : 
     560             :         // configuration for hatch
     561             :         case SID_HATCH :
     562           0 :             if (pArgs)
     563           0 :                 if (pArgs->Count () == 4)
     564             :                 {
     565           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     566           0 :                     SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, false);
     567           0 :                     SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, false);
     568           0 :                     SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, false);
     569             : 
     570           0 :                     if (CHECK_RANGE (css::drawing::HatchStyle_SINGLE, (sal_Int32)pStyle->GetValue (), css::drawing::HatchStyle_TRIPLE) &&
     571           0 :                         CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360))
     572             :                     {
     573           0 :                         pAttr->ClearItem (XATTR_FILLHATCH);
     574           0 :                         pAttr->ClearItem (XATTR_FILLSTYLE);
     575             : 
     576           0 :                         XHatchListRef pHatchList = GetDoc()->GetHatchList ();
     577           0 :                         long       nCounts     = pHatchList->Count ();
     578             :                         long i;
     579             : 
     580           0 :                         for ( i = 0; i < nCounts; i++ )
     581             :                         {
     582           0 :                             XHatchEntry *pEntry = pHatchList->GetHatch (i);
     583             : 
     584           0 :                             if (pEntry->GetName () == pName->GetValue ())
     585             :                             {
     586           0 :                                 XHatch aHatch(pEntry->GetHatch());
     587             : 
     588           0 :                                 aHatch.SetHatchStyle ((css::drawing::HatchStyle) pStyle->GetValue ());
     589           0 :                                 aHatch.SetDistance (pDistance->GetValue ());
     590           0 :                                 aHatch.SetAngle (pAngle->GetValue () * 10);
     591             : 
     592           0 :                                 pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
     593           0 :                                 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
     594           0 :                                 break;
     595             :                             }
     596             :                         }
     597             : 
     598           0 :                         if (i >= nCounts)
     599             :                         {
     600           0 :                             Color  aBlack (0, 0, 0);
     601           0 :                             XHatch aHatch (aBlack, (css::drawing::HatchStyle) pStyle->GetValue (), pDistance->GetValue (),
     602           0 :                                            pAngle->GetValue () * 10);
     603             : 
     604           0 :                             pHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
     605           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
     606           0 :                             pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
     607             :                         }
     608             : 
     609           0 :                         rBindings.Invalidate (SID_ATTR_FILL_HATCH);
     610           0 :                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     611             :                     }
     612             : #if HAVE_FEATURE_SCRIPTING
     613           0 :                     else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
     614             : #endif
     615           0 :                     break;
     616             :                 }
     617             : #if HAVE_FEATURE_SCRIPTING
     618           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     619             : #endif
     620           0 :             break;
     621             : 
     622             :         case SID_SELECTGRADIENT :
     623           0 :             if (pArgs)
     624           0 :                 if (pArgs->Count () == 1)
     625             :                 {
     626           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     627             : 
     628           0 :                     XGradientListRef pGradientList = GetDoc()->GetGradientList ();
     629           0 :                     long           nCounts        = pGradientList->Count ();
     630             : 
     631           0 :                     for (long i = 0;
     632             :                               i < nCounts;
     633             :                               i ++)
     634             :                     {
     635           0 :                         XGradientEntry *pEntry = pGradientList->GetGradient (i);
     636             : 
     637           0 :                         if (pEntry->GetName () == pName->GetValue ())
     638             :                         {
     639           0 :                             pAttr->ClearItem (XATTR_FILLGRADIENT);
     640           0 :                             pAttr->ClearItem (XATTR_FILLSTYLE);
     641           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
     642           0 :                             pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT);
     643             : 
     644           0 :                             rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
     645           0 :                             rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     646           0 :                             break;
     647             :                         }
     648             :                     }
     649             : 
     650           0 :                     break;
     651             :                 }
     652             : #if HAVE_FEATURE_SCRIPTING
     653           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     654             : #endif
     655           0 :             break;
     656             : 
     657             :         case SID_SELECTHATCH :
     658           0 :             if (pArgs)
     659           0 :                 if (pArgs->Count () == 1)
     660             :                 {
     661           0 :                     SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, false);
     662             : 
     663           0 :                     XHatchListRef pHatchList = GetDoc()->GetHatchList ();
     664           0 :                     long       nCounts     = pHatchList->Count ();
     665             : 
     666           0 :                     for (long i = 0;
     667             :                               i < nCounts;
     668             :                               i ++)
     669             :                     {
     670           0 :                         XHatchEntry *pEntry = pHatchList->GetHatch (i);
     671             : 
     672           0 :                         if (pEntry->GetName () == pName->GetValue ())
     673             :                         {
     674           0 :                             pAttr->ClearItem (XATTR_FILLHATCH);
     675           0 :                             pAttr->ClearItem (XATTR_FILLSTYLE);
     676           0 :                             pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
     677           0 :                             pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH);
     678             : 
     679           0 :                             rBindings.Invalidate (SID_ATTR_FILL_HATCH);
     680           0 :                             rBindings.Invalidate (SID_ATTR_FILL_STYLE);
     681           0 :                             break;
     682             :                         }
     683             :                     }
     684             : 
     685           0 :                     break;
     686             :                 }
     687             : #if HAVE_FEATURE_SCRIPTING
     688           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     689             : #endif
     690           0 :             break;
     691             : 
     692             :         case SID_UNSELECT :
     693           0 :             mpDrawView->UnmarkAll ();
     694           0 :             break;
     695             : 
     696             :         case SID_GETRED :
     697           0 :             if (pArgs)
     698           0 :                 if (pArgs->Count () == 1)
     699             :                 {
     700           0 :                     break;
     701             :                 }
     702             : #if HAVE_FEATURE_SCRIPTING
     703           0 :             StarBASIC::FatalError (SbERR_WRONG_ARGS);
     704             : #endif
     705           0 :             break;
     706             : 
     707             : /*        case SID_SETFONTFAMILYNAME :
     708             :         case SID_SETFONTSTYLENAME :
     709             :         case SID_SETFONTFAMILY :
     710             :         case SID_SETFONTPITCH :
     711             :         case SID_SETFONTCHARSET :
     712             :         case SID_SETFONTPOSTURE :
     713             :         case SID_SETFONTWEIGHT :
     714             :         case SID_SETFONTUNDERLINE :
     715             :         case SID_SETFONTCROSSEDOUT :
     716             :         case SID_SETFONTSHADOWED :
     717             :         case SID_SETFONTCONTOUR :
     718             :         case SID_SETFONTCOLOR :
     719             :         case SID_SETFONTLANGUAGE :
     720             :         case SID_SETFONTWORDLINE :
     721             :         case SID_SETFONTCASEMAP :
     722             :         case SID_SETFONTESCAPE :
     723             :         case SID_SETFONTKERNING :
     724             :             break;*/
     725             : 
     726             :         default :
     727             :             ;
     728             :     }
     729             : 
     730           0 :     mpDrawView->SetAttributes (*const_cast<const SfxItemSet *>(pAttr.get()));
     731           0 :     rReq.Ignore ();
     732             : }
     733             : 
     734             : /**
     735             :  * Edit macros for attribute configuration
     736             :  */
     737           0 : void DrawViewShell::AttrState (SfxItemSet& rSet)
     738             : {
     739           0 :     SfxWhichIter     aIter (rSet);
     740           0 :     sal_uInt16           nWhich = aIter.FirstWhich ();
     741           0 :     SfxItemSet aAttr( GetDoc()->GetPool() );
     742           0 :     mpDrawView->GetAttributes( aAttr );
     743             : 
     744           0 :     while (nWhich)
     745             :     {
     746           0 :         switch (nWhich)
     747             :         {
     748             :             case SID_GETFILLSTYLE :
     749             :             {
     750           0 :                 const XFillStyleItem &rFillStyleItem = static_cast<const XFillStyleItem &>(aAttr.Get (XATTR_FILLSTYLE));
     751             : 
     752           0 :                 rSet.Put (SfxUInt32Item (nWhich, (long) rFillStyleItem.GetValue ()));
     753           0 :                 break;
     754             :             }
     755             : 
     756             :             case SID_GETLINESTYLE :
     757             :             {
     758           0 :                 const XLineStyleItem &rLineStyleItem = static_cast<const XLineStyleItem &>( aAttr.Get (XATTR_LINESTYLE) );
     759             : 
     760           0 :                 rSet.Put (SfxUInt32Item (nWhich, (long) rLineStyleItem.GetValue ()));
     761           0 :                 break;
     762             :             }
     763             : 
     764             :             case SID_GETLINEWIDTH :
     765             :             {
     766           0 :                 const XLineWidthItem &rLineWidthItem = static_cast<const XLineWidthItem &>( aAttr.Get (XATTR_LINEWIDTH) );
     767             : 
     768           0 :                 rSet.Put (SfxUInt32Item (nWhich, (long) rLineWidthItem.GetValue ()));
     769           0 :                 break;
     770             :             }
     771             : 
     772             :             case SID_GETGREEN :
     773             :             case SID_GETRED :
     774             :             case SID_GETBLUE :
     775             :             {
     776           0 :                 const SfxUInt32Item &rWhatKind = static_cast<const SfxUInt32Item &>( rSet.Get (ID_VAL_WHATKIND) );
     777           0 :                 Color               aColor;
     778             : 
     779           0 :                 switch (rWhatKind.GetValue ())
     780             :                 {
     781             :                     case 1 :
     782             :                     {
     783           0 :                         const XLineColorItem &rLineColorItem = static_cast<const XLineColorItem &>( aAttr.Get (XATTR_LINECOLOR) );
     784             : 
     785           0 :                         aColor = rLineColorItem.GetColorValue ();
     786           0 :                         break;
     787             :                     }
     788             : 
     789             :                     case 2 :
     790             :                     {
     791           0 :                         const XFillColorItem &rFillColorItem = static_cast<const XFillColorItem &>( aAttr.Get (XATTR_FILLCOLOR) );
     792             : 
     793           0 :                         aColor = rFillColorItem.GetColorValue ();
     794           0 :                         break;
     795             :                     }
     796             : 
     797             :                     case 3 :
     798             :                     case 4 :
     799             :                     {
     800           0 :                         const XFillGradientItem &rFillGradientItem = static_cast<const XFillGradientItem &>( aAttr.Get (XATTR_FILLGRADIENT) );
     801           0 :                         const XGradient         &rGradient         = rFillGradientItem.GetGradientValue ();
     802             : 
     803           0 :                         aColor = (rWhatKind.GetValue () == 3)
     804             :                                     ? rGradient.GetStartColor ()
     805           0 :                                     : rGradient.GetEndColor ();
     806           0 :                         break;
     807             :                     }
     808             : 
     809             :                     case 5:
     810             :                     {
     811           0 :                         const XFillHatchItem &rFillHatchItem = static_cast<const XFillHatchItem &>( aAttr.Get (XATTR_FILLHATCH) );
     812           0 :                         const XHatch         &rHatch         = rFillHatchItem.GetHatchValue ();
     813             : 
     814           0 :                         aColor = rHatch.GetColor ();
     815           0 :                         break;
     816             :                     }
     817             : 
     818             :                     default :
     819             :                         ;
     820             :                 }
     821             : 
     822             :                 rSet.Put (SfxUInt32Item (nWhich, (long) ((nWhich == SID_GETRED)
     823           0 :                                                              ? aColor.GetRed ()
     824             :                                                              : (nWhich == SID_GETGREEN)
     825           0 :                                                                    ? aColor.GetGreen ()
     826           0 :                                                                    : aColor.GetBlue ())));
     827           0 :                 break;
     828             :             }
     829             : 
     830             :             default :
     831             :                 ;
     832             :         }
     833             : 
     834           0 :         nWhich = aIter.NextWhich ();
     835           0 :     }
     836           0 : }
     837             : 
     838          66 : } // end of namespace sd
     839             : 
     840             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11