LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/func - fulinend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 61 1.6 %
Date: 2012-12-27 Functions: 2 12 16.7 %
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 "fulinend.hxx"
      21             : #include <svx/xtable.hxx>
      22             : #include <svx/svxdlg.hxx>
      23             : #include <svx/dialogs.hrc>
      24             : #include <svx/svdobj.hxx>
      25             : #include <svx/svdopath.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : 
      28             : #include "strings.hrc"
      29             : #include "ViewShell.hxx"
      30             : #include "helpids.h"
      31             : #include "sdresid.hxx"
      32             : #include "drawdoc.hxx"
      33             : #include "View.hxx"
      34             : #include "Window.hxx"
      35             : 
      36             : namespace sd {
      37             : 
      38             : #define BITMAP_WIDTH  32
      39             : #define BITMAP_HEIGHT 12
      40             : 
      41           0 : TYPEINIT1( FuLineEnd, FuPoor );
      42             : 
      43             : /*************************************************************************
      44             : |*
      45             : |* Konstruktor
      46             : |*
      47             : \************************************************************************/
      48             : 
      49           0 : FuLineEnd::FuLineEnd(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
      50             :                     SdDrawDocument* pDoc, SfxRequest& rReq)
      51           0 :     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      52             : {
      53           0 : }
      54             : 
      55           0 : FunctionReference FuLineEnd::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      56             : {
      57           0 :     FunctionReference xFunc( new FuLineEnd( pViewSh, pWin, pView, pDoc, rReq ) );
      58           0 :     xFunc->DoExecute(rReq);
      59           0 :     return xFunc;
      60             : }
      61             : 
      62           0 : void FuLineEnd::DoExecute( SfxRequest& )
      63             : {
      64           0 :     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
      65             : 
      66           0 :     if( rMarkList.GetMarkCount() == 1 )
      67             :     {
      68           0 :         const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
      69             :         const SdrObject* pNewObj;
      70           0 :         SdrObject* pConvPolyObj = NULL;
      71             : 
      72           0 :         if( pObj->ISA( SdrPathObj ) )
      73             :         {
      74           0 :             pNewObj = pObj;
      75             :         }
      76             :         else
      77             :         {
      78           0 :             SdrObjTransformInfoRec aInfoRec;
      79           0 :             pObj->TakeObjInfo( aInfoRec );
      80             : 
      81           0 :             if( aInfoRec.bCanConvToPath &&
      82           0 :                 pObj->GetObjInventor() == SdrInventor &&
      83           0 :                 pObj->GetObjIdentifier() != OBJ_GRUP )
      84             :                 // bCanConvToPath ist bei Gruppenobjekten sal_True,
      85             :                 // stuerzt aber bei ConvertToPathObj() ab !
      86             :             {
      87           0 :                 pNewObj = pConvPolyObj = pObj->ConvertToPolyObj( sal_True, sal_False );
      88             : 
      89           0 :                 if( !pNewObj || !pNewObj->ISA( SdrPathObj ) )
      90             :                     return; // Abbruch, zusaetzliche Sicherheit, die bei
      91             :                             // Gruppenobjekten aber nichts bringt.
      92             :             }
      93             :             else return; // Abbruch
      94             :         }
      95             : 
      96           0 :         const ::basegfx::B2DPolyPolygon aPolyPolygon = ( (SdrPathObj*) pNewObj )->GetPathPoly();
      97             : 
      98             :         // Loeschen des angelegten PolyObjektes
      99           0 :         SdrObject::Free( pConvPolyObj );
     100             : 
     101           0 :         XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
     102             :         XLineEndEntry* pEntry;
     103             : 
     104           0 :         String aNewName( SdResId( STR_LINEEND ) );
     105           0 :         String aDesc( SdResId( STR_DESC_LINEEND ) );
     106           0 :         String aName;
     107             : 
     108           0 :         long nCount = pLineEndList->Count();
     109           0 :         long j = 1;
     110           0 :         sal_Bool bDifferent = sal_False;
     111             : 
     112           0 :         while( !bDifferent )
     113             :         {
     114           0 :             aName = aNewName;
     115           0 :             aName.Append( sal_Unicode(' ') );
     116           0 :             aName.Append( UniString::CreateFromInt32( j++ ) );
     117           0 :             bDifferent = sal_True;
     118           0 :             for( long i = 0; i < nCount && bDifferent; i++ )
     119             :             {
     120           0 :                 if( aName == pLineEndList->GetLineEnd( i )->GetName() )
     121           0 :                     bDifferent = sal_False;
     122             :             }
     123             :         }
     124             : 
     125           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     126           0 :         AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( NULL, aName, aDesc ) : 0;
     127             : 
     128           0 :         if( pDlg )
     129             :         {
     130           0 :             pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND );
     131             : 
     132           0 :             if( pDlg->Execute() == RET_OK )
     133             :             {
     134           0 :                 pDlg->GetName( aName );
     135           0 :                 bDifferent = sal_True;
     136             : 
     137           0 :                 for( long i = 0; i < nCount && bDifferent; i++ )
     138             :                 {
     139           0 :                     if( aName == pLineEndList->GetLineEnd( i )->GetName() )
     140           0 :                         bDifferent = sal_False;
     141             :                 }
     142             : 
     143           0 :                 if( bDifferent )
     144             :                 {
     145           0 :                     pEntry = new XLineEndEntry( aPolyPolygon, aName );
     146           0 :                     pLineEndList->Insert( pEntry, LIST_APPEND);
     147             :                 }
     148             :                 else
     149             :                 {
     150           0 :                     String aStr(SdResId( STR_WARN_NAME_DUPLICATE ));
     151             :                     WarningBox aWarningBox( mpWindow, WinBits( WB_OK ),
     152           0 :                          aStr );
     153           0 :                     aWarningBox.Execute();
     154             :                 }
     155             :             }
     156             :         }
     157           0 :         delete pDlg;
     158             :     }
     159             : }
     160             : 
     161           0 : void FuLineEnd::Activate()
     162             : {
     163           0 : }
     164             : 
     165           0 : void FuLineEnd::Deactivate()
     166             : {
     167           0 : }
     168             : 
     169           9 : } // end of namespace sd
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10