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

Generated by: LCOV version 1.10