LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fuins2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 356 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 886 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      30                 :            : #include <com/sun/star/embed/Aspects.hpp>
      31                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      32                 :            : 
      33                 :            : //------------------------------------------------------------------------
      34                 :            : 
      35                 :            : #include <toolkit/helper/vclunohelper.hxx>
      36                 :            : #include <sot/exchange.hxx>
      37                 :            : #include <svl/globalnameitem.hxx>
      38                 :            : #include <sfx2/viewfrm.hxx>
      39                 :            : #include <sfx2/docfile.hxx>
      40                 :            : #include <svl/stritem.hxx>
      41                 :            : #include <svx/svdoole2.hxx>
      42                 :            : #include <svx/pfiledlg.hxx>
      43                 :            : #include <tools/urlobj.hxx>
      44                 :            : #include <vcl/msgbox.hxx>
      45                 :            : #include <svl/urihelper.hxx>
      46                 :            : #include <unotools/moduleoptions.hxx>
      47                 :            : #include <svtools/insdlg.hxx>
      48                 :            : #include <svtools/soerr.hxx>
      49                 :            : #include <svx/svxdlg.hxx>
      50                 :            : #include <sot/clsids.hxx>
      51                 :            : #include <svx/svdpagv.hxx>
      52                 :            : #include <svx/svdpage.hxx>
      53                 :            : #include <svx/svdundo.hxx>
      54                 :            : #include <sfx2/msgpool.hxx>
      55                 :            : #include <scmod.hxx>
      56                 :            : 
      57                 :            : // BM/IHA --
      58                 :            : #include <cppuhelper/component_context.hxx>
      59                 :            : #include <comphelper/processfactory.hxx>
      60                 :            : #include <comphelper/storagehelper.hxx>
      61                 :            : #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
      62                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      63                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      64                 :            : #include <com/sun/star/chart2/data/XDataProvider.hpp>
      65                 :            : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
      66                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      67                 :            : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      68                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      69                 :            : #include <com/sun/star/frame/XModel.hpp>
      70                 :            : #include <com/sun/star/chart/ChartDataRowSource.hpp>
      71                 :            : #include <cppuhelper/bootstrap.hxx>
      72                 :            : 
      73                 :            : using namespace ::com::sun::star;
      74                 :            : // BM/IHA --
      75                 :            : 
      76                 :            : // erAck
      77                 :            : #include "chart2uno.hxx"
      78                 :            : // erAck
      79                 :            : 
      80                 :            : #include "fuinsert.hxx"
      81                 :            : #include "tabvwsh.hxx"
      82                 :            : #include "sc.hrc"
      83                 :            : #include "chartarr.hxx"
      84                 :            : #include "docsh.hxx"
      85                 :            : #include "document.hxx"
      86                 :            : #include "undotab.hxx"
      87                 :            : #include "chartlis.hxx"
      88                 :            : #include "uiitems.hxx"
      89                 :            : #include "globstr.hrc"
      90                 :            : #include "drawview.hxx"
      91                 :            : #include "markdata.hxx"
      92                 :            : 
      93                 :            : extern SdrObject* pSkipPaintObj;            // output.cxx - dieses Objekt nicht zeichnen
      94                 :            : 
      95                 :            : namespace {
      96                 :            : 
      97                 :          0 : void lcl_ChartInit( const uno::Reference < embed::XEmbeddedObject >& xObj, ScViewData* pViewData,
      98                 :            :                     const rtl::OUString& rRangeParam )
      99                 :            : {
     100                 :          0 :     ScDocShell* pDocShell = pViewData->GetDocShell();
     101                 :          0 :     ScDocument* pScDoc = pDocShell->GetDocument();
     102                 :            : 
     103                 :          0 :     rtl::OUString aRangeString( rRangeParam );
     104         [ #  # ]:          0 :     if ( aRangeString.isEmpty() )
     105                 :            :     {
     106                 :          0 :         SCCOL nCol1 = 0;
     107                 :          0 :         SCROW nRow1 = 0;
     108                 :          0 :         SCTAB nTab1 = 0;
     109                 :          0 :         SCCOL nCol2 = 0;
     110                 :          0 :         SCROW nRow2 = 0;
     111                 :          0 :         SCTAB nTab2 = 0;
     112                 :            : 
     113         [ #  # ]:          0 :         ScMarkData& rMark = pViewData->GetMarkData();
     114         [ #  # ]:          0 :         if ( !rMark.IsMarked() )
     115         [ #  # ]:          0 :             pViewData->GetView()->MarkDataArea( true );
     116                 :            : 
     117 [ #  # ][ #  # ]:          0 :         if ( pViewData->GetSimpleArea( nCol1,nRow1,nTab1, nCol2,nRow2,nTab2 ) == SC_MARK_SIMPLE )
     118                 :            :         {
     119                 :          0 :             PutInOrder( nCol1, nCol2 );
     120                 :          0 :             PutInOrder( nRow1, nRow2 );
     121 [ #  # ][ #  # ]:          0 :             if ( nCol2>nCol1 || nRow2>nRow1 )
     122                 :            :             {
     123         [ #  # ]:          0 :                 ScDocument* pDoc = pViewData->GetDocument();
     124         [ #  # ]:          0 :                 pDoc->LimitChartArea( nTab1, nCol1,nRow1, nCol2,nRow2 );
     125                 :            : 
     126                 :          0 :                 ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
     127         [ #  # ]:          0 :                 aRange.Format( aRangeString, SCR_ABS_3D, pScDoc );
     128                 :            :             }
     129                 :            :         }
     130                 :            :     }
     131                 :            : 
     132         [ #  # ]:          0 :     if ( !aRangeString.isEmpty() )
     133                 :            :     {
     134                 :            :         // connect to Calc data (if no range string, leave chart alone, with its own data)
     135                 :            : 
     136                 :          0 :         uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
     137         [ #  # ]:          0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
     138         [ #  # ]:          0 :         if( xCompSupp.is())
     139 [ #  # ][ #  # ]:          0 :             xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
     140                 :            :         OSL_ASSERT( xReceiver.is());
     141         [ #  # ]:          0 :         if( xReceiver.is() )
     142                 :            :         {
     143 [ #  # ][ #  # ]:          0 :             uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( pScDoc );
                 [ #  # ]
     144 [ #  # ][ #  # ]:          0 :             xReceiver->attachDataProvider( xDataProvider );
     145                 :            : 
     146 [ #  # ][ #  # ]:          0 :             uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY );
     147 [ #  # ][ #  # ]:          0 :             xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
     148                 :            : 
     149                 :            :             // Same behavior as with old chart: Always assume data series in columns
     150                 :          0 :             chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
     151                 :          0 :             bool bHasCategories = false;
     152                 :          0 :             bool bFirstCellAsLabel = false;
     153                 :            : 
     154                 :            :             // use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
     155 [ #  # ][ #  # ]:          0 :             ScRangeListRef aRangeListRef( new ScRangeList );
     156 [ #  # ][ #  # ]:          0 :             aRangeListRef->Parse( aRangeString, pScDoc, SCA_VALID, pScDoc->GetAddressConvention() );
         [ #  # ][ #  # ]
     157 [ #  # ][ #  # ]:          0 :             if ( !aRangeListRef->empty() )
     158                 :            :             {
     159         [ #  # ]:          0 :                 pScDoc->LimitChartIfAll( aRangeListRef );               // limit whole columns/rows to used area
     160                 :            : 
     161                 :            :                 // update string from modified ranges.  The ranges must be in the current formula syntax.
     162         [ #  # ]:          0 :                 String aTmpStr;
     163 [ #  # ][ #  # ]:          0 :                 aRangeListRef->Format( aTmpStr, SCR_ABS_3D, pScDoc, pScDoc->GetAddressConvention() );
     164         [ #  # ]:          0 :                 aRangeString = aTmpStr;
     165                 :            : 
     166         [ #  # ]:          0 :                 ScChartPositioner aChartPositioner( pScDoc, aRangeListRef );
     167         [ #  # ]:          0 :                 const ScChartPositionMap* pPositionMap( aChartPositioner.GetPositionMap() );
     168         [ #  # ]:          0 :                 if( pPositionMap )
     169                 :            :                 {
     170                 :          0 :                     SCSIZE nRowCount = pPositionMap->GetRowCount();
     171         [ #  # ]:          0 :                     if( 1==nRowCount )
     172                 :          0 :                         eDataRowSource = chart::ChartDataRowSource_ROWS;
     173                 :            :                 }
     174         [ #  # ]:          0 :                 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
     175                 :            :                 {
     176                 :          0 :                     bHasCategories = aChartPositioner.HasRowHeaders();
     177                 :          0 :                     bFirstCellAsLabel = aChartPositioner.HasColHeaders();
     178                 :            :                 }
     179                 :            :                 else    // in case the default is changed
     180                 :            :                 {
     181                 :          0 :                     bHasCategories = aChartPositioner.HasColHeaders();
     182                 :          0 :                     bFirstCellAsLabel = aChartPositioner.HasRowHeaders();
     183 [ #  # ][ #  # ]:          0 :                 }
     184                 :            :             }
     185                 :            : 
     186         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aArgs( 4 );
     187         [ #  # ]:          0 :             aArgs[0] = beans::PropertyValue(
     188                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1,
     189 [ #  # ][ #  # ]:          0 :                 uno::makeAny( aRangeString ), beans::PropertyState_DIRECT_VALUE );
     190         [ #  # ]:          0 :             aArgs[1] = beans::PropertyValue(
     191                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1,
     192 [ #  # ][ #  # ]:          0 :                 uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
     193         [ #  # ]:          0 :             aArgs[2] = beans::PropertyValue(
     194                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1,
     195 [ #  # ][ #  # ]:          0 :                 uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
     196         [ #  # ]:          0 :             aArgs[3] = beans::PropertyValue(
     197                 :            :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1,
     198 [ #  # ][ #  # ]:          0 :                 uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
     199 [ #  # ][ #  # ]:          0 :             xReceiver->setArguments( aArgs );
         [ #  # ][ #  # ]
     200                 :            : 
     201                 :            :             // don't create chart listener here (range may be modified in chart dialog)
     202                 :          0 :         }
     203                 :          0 :     }
     204                 :          0 : }
     205                 :            : 
     206                 :            : }
     207                 :            : 
     208                 :            : /*************************************************************************
     209                 :            : |*
     210                 :            : |* FuInsertOLE::Konstruktor
     211                 :            : |*
     212                 :            : \************************************************************************/
     213                 :            : 
     214                 :          0 : FuInsertOLE::FuInsertOLE(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
     215                 :            :            SdrModel* pDoc, SfxRequest& rReq)
     216                 :          0 :     : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
     217                 :            : {
     218 [ #  # ][ #  # ]:          0 :     if( ! rReq.IsAPI() )
     219         [ #  # ]:          0 :         rReq.Done();
     220                 :            : 
     221                 :            :     //! hier DLL's initalisieren, damit die Factories existieren?
     222                 :            : 
     223                 :          0 :     uno::Reference < embed::XEmbeddedObject > xObj;
     224         [ #  # ]:          0 :     uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
     225                 :          0 :     sal_Bool bIsFromFile = false;
     226                 :          0 :     ::rtl::OUString aName;
     227                 :            : 
     228                 :          0 :     sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     229                 :          0 :     ::rtl::OUString aIconMediaType;
     230                 :          0 :     uno::Reference< io::XInputStream > xIconMetaFile;
     231                 :            : 
     232                 :            : 
     233                 :          0 :     sal_uInt16 nSlot = rReq.GetSlot();
     234 [ #  # ][ #  # ]:          0 :     SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, false );
     235 [ #  # ][ #  # ]:          0 :     if ( nSlot == SID_INSERT_OBJECT && pNameItem )
     236                 :            :     {
     237         [ #  # ]:          0 :         SvGlobalName aClassName = pNameItem->GetValue();
     238 [ #  # ][ #  # ]:          0 :         xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     239                 :            :     }
     240         [ #  # ]:          0 :     else if ( nSlot == SID_INSERT_SMATH )
     241                 :            :     {
     242 [ #  # ][ #  # ]:          0 :         if ( SvtModuleOptions().IsMath() )
         [ #  # ][ #  # ]
     243                 :            :         {
     244                 :          0 :             nSlot = SID_INSERT_OBJECT;
     245 [ #  # ][ #  # ]:          0 :             xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SM_CLASSID_60 ).GetByteSequence(), aName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     246 [ #  # ][ #  # ]:          0 :             rReq.AppendItem( SfxGlobalNameItem( SID_INSERT_OBJECT, SvGlobalName( SO3_SM_CLASSID_60 ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     247                 :            :         }
     248                 :            :     }
     249                 :            :     else
     250                 :            :     {
     251         [ #  # ]:          0 :         SvObjectServerList aServerLst;
     252   [ #  #  #  # ]:          0 :         switch ( nSlot )
     253                 :            :         {
     254                 :            :             case SID_INSERT_OBJECT :
     255         [ #  # ]:          0 :                 aServerLst.FillInsertObjects();
     256 [ #  # ][ #  # ]:          0 :                 aServerLst.Remove( ScDocShell::Factory().GetClassId() );   // Starcalc nicht anzeigen
                 [ #  # ]
     257                 :            :                 //TODO/LATER: currently no inserting of ClassId into SfxRequest!
     258                 :            :             case SID_INSERT_PLUGIN :
     259                 :            :             case SID_INSERT_FLOATINGFRAME :
     260                 :            :             {
     261         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     262                 :            :                 SfxAbstractInsertObjectDialog* pDlg =
     263         [ #  # ]:          0 :                         pFact->CreateInsertObjectDialog( pViewShell->GetWindow(), SC_MOD()->GetSlotPool()->GetSlot(nSlot)->GetCommandString(),
     264 [ #  # ][ #  # ]:          0 :                         xStorage, &aServerLst );
         [ #  # ][ #  # ]
     265         [ #  # ]:          0 :                 if ( pDlg )
     266                 :            :                 {
     267         [ #  # ]:          0 :                     pDlg->Execute();
     268 [ #  # ][ #  # ]:          0 :                     xObj = pDlg->GetObject();
     269                 :            : 
     270 [ #  # ][ #  # ]:          0 :                     xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
     271         [ #  # ]:          0 :                     if ( xIconMetaFile.is() )
     272                 :          0 :                         nAspect = embed::Aspects::MSOLE_ICON;
     273                 :            : 
     274         [ #  # ]:          0 :                     if ( xObj.is() )
     275 [ #  # ][ #  # ]:          0 :                         pViewSh->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
                 [ #  # ]
     276                 :            :                     // damit DrawShell eingeschaltet wird (Objekt aktivieren ist unnoetig):
     277         [ #  # ]:          0 :                     bIsFromFile = !pDlg->IsCreateNew();
     278 [ #  # ][ #  # ]:          0 :                     DELETEZ( pDlg );
     279                 :            :                 }
     280                 :            : 
     281                 :          0 :                 break;
     282                 :            :             }
     283                 :            :             case SID_INSERT_SOUND :
     284                 :            :             case SID_INSERT_VIDEO :
     285                 :            :             {
     286                 :            :                 // create special filedialog for plugins
     287         [ #  # ]:          0 :                 SvxPluginFileDlg aPluginFileDialog(pWin, nSlot);
     288                 :            : 
     289                 :            :                 // open filedlg
     290 [ #  # ][ #  # ]:          0 :                 if ( ERRCODE_NONE == aPluginFileDialog.Execute() )
     291                 :            :                 {
     292                 :            :                     // get URL
     293         [ #  # ]:          0 :                     INetURLObject aURL;
     294                 :          0 :                     aURL.SetSmartProtocol( INET_PROT_FILE );
     295 [ #  # ][ #  # ]:          0 :                     if ( aURL.SetURL( aPluginFileDialog.GetPath() ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     296                 :            :                     {
     297                 :            :                         // create a plugin object
     298                 :          0 :                         ::rtl::OUString aObjName;
     299         [ #  # ]:          0 :                         SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
     300         [ #  # ]:          0 :                         comphelper::EmbeddedObjectContainer aCnt( xStorage );
     301 [ #  # ][ #  # ]:          0 :                         xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aObjName );
         [ #  # ][ #  # ]
     302 [ #  # ][ #  # ]:          0 :                         if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) )
         [ #  # ][ #  # ]
     303                 :            :                         {
     304                 :            :                             // set properties from dialog
     305 [ #  # ][ #  # ]:          0 :                             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
     306         [ #  # ]:          0 :                             if ( xSet.is() )
     307                 :            :                             {
     308         [ #  # ]:          0 :                                 xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PluginURL")),
     309 [ #  # ][ #  # ]:          0 :                                         uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
         [ #  # ][ #  # ]
     310                 :          0 :                             }
     311 [ #  # ][ #  # ]:          0 :                         }
     312                 :            :                     }
     313                 :            :                     else
     314                 :            :                     {
     315                 :            :                         OSL_FAIL("Invalid URL!");
     316                 :            :                         //! error message
     317                 :            :                         //! can this happen???
     318         [ #  # ]:          0 :                     }
     319         [ #  # ]:          0 :                 }
     320                 :            :             }
     321         [ #  # ]:          0 :         }
     322                 :            :     }
     323                 :            : 
     324                 :            :     //  SvInsertObjectDialog (alles in einem Dialog) wird nicht mehr benutzt
     325         [ #  # ]:          0 :     if (xObj.is())
     326                 :            :     {
     327         [ #  # ]:          0 :         pView->UnmarkAll();
     328                 :            : 
     329                 :            :         try
     330                 :            :         {
     331         [ #  # ]:          0 :             ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
     332                 :          0 :             Size aSize;
     333         [ #  # ]:          0 :             MapMode aMap100( MAP_100TH_MM );
     334                 :          0 :             MapUnit aMapUnit = MAP_100TH_MM;
     335                 :            : 
     336         [ #  # ]:          0 :             if ( nAspect == embed::Aspects::MSOLE_ICON )
     337                 :            :             {
     338         [ #  # ]:          0 :                 aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType );
     339         [ #  # ]:          0 :                 aSize = aObjRef.GetSize( &aMap100 );
     340                 :            :             }
     341                 :            :             else
     342                 :            :             {
     343                 :          0 :                 awt::Size aSz;
     344                 :            :                 try
     345                 :            :                 {
     346 [ #  # ][ #  # ]:          0 :                     aSz = xObj->getVisualAreaSize( nAspect );
     347                 :            :                 }
     348         [ #  # ]:          0 :                 catch( embed::NoVisualAreaSizeException& )
     349                 :            :                 {
     350                 :            :                     // the default size will be set later
     351                 :            :                 }
     352                 :            : 
     353                 :          0 :                 aSize = Size( aSz.Width, aSz.Height );
     354                 :            : 
     355 [ #  # ][ #  # ]:          0 :                 aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
                 [ #  # ]
     356 [ #  # ][ #  # ]:          0 :                 if (aSize.Height() == 0 || aSize.Width() == 0)
                 [ #  # ]
     357                 :            :                 {
     358                 :            :                     // Rechteck mit ausgewogenem Kantenverhaeltnis
     359                 :          0 :                     aSize.Width() = 5000;
     360                 :          0 :                     aSize.Height() = 5000;
     361 [ #  # ][ #  # ]:          0 :                     Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit );
         [ #  # ][ #  # ]
                 [ #  # ]
     362                 :          0 :                     aSz.Width = aTmp.Width();
     363                 :          0 :                     aSz.Height = aTmp.Height();
     364 [ #  # ][ #  # ]:          0 :                     xObj->setVisualAreaSize( nAspect, aSz );
     365                 :            : 
     366                 :            :                     //  re-convert aSize to 1/100th mm to avoid rounding errors in comparison below
     367                 :            :                     aSize = Window::LogicToLogic( aTmp,
     368 [ #  # ][ #  # ]:          0 :                                     MapMode( aMapUnit ), aMap100 );
                 [ #  # ]
     369                 :            :                 }
     370                 :            :                 else
     371                 :            :                     aSize = Window::LogicToLogic( aSize,
     372 [ #  # ][ #  # ]:          0 :                                     MapMode( aMapUnit ), aMap100 );
                 [ #  # ]
     373                 :            :             }
     374                 :            : 
     375                 :            :             //  Chart initialisieren ?
     376 [ #  # ][ #  # ]:          0 :             if ( SvtModuleOptions().IsChart() && SotExchange::IsChart( SvGlobalName( xObj->getClassID() ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
     377         [ #  # ]:          0 :                 lcl_ChartInit( xObj, pViewSh->GetViewData(), rtl::OUString() );
     378                 :            : 
     379                 :          0 :             ScViewData* pData = pViewSh->GetViewData();
     380                 :            : 
     381         [ #  # ]:          0 :             Point aPnt = pViewSh->GetInsertPos();
     382 [ #  # ][ #  # ]:          0 :             if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
                 [ #  # ]
     383                 :          0 :                 aPnt.X() -= aSize.Width();      // move position to left edge
     384         [ #  # ]:          0 :             Rectangle aRect (aPnt, aSize);
     385 [ #  # ][ #  # ]:          0 :             SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect);
         [ #  # ][ #  # ]
     386                 :            : 
     387                 :            :                 // Dieses Objekt nicht vor dem Aktivieren zeichnen
     388                 :            :                 // (in MarkListHasChanged kommt ein Update)
     389         [ #  # ]:          0 :             if (!bIsFromFile)
     390                 :          0 :                 pSkipPaintObj = pObj;
     391                 :            : 
     392                 :          0 :             SdrPageView* pPV = pView->GetSdrPageView();
     393         [ #  # ]:          0 :             pView->InsertObjectAtView(pObj, *pPV);
     394                 :            : 
     395         [ #  # ]:          0 :             if ( nAspect != embed::Aspects::MSOLE_ICON )
     396                 :            :             {
     397                 :            :                 //  Math objects change their object size during InsertObject.
     398                 :            :                 //  New size must be set in SdrObject, or a wrong scale will be set at
     399                 :            :                 //  ActivateObject.
     400                 :            : 
     401                 :            :                 try
     402                 :            :                 {
     403 [ #  # ][ #  # ]:          0 :                     awt::Size aSz = xObj->getVisualAreaSize( nAspect );
     404                 :            : 
     405                 :          0 :                     Size aNewSize( aSz.Width, aSz.Height );
     406 [ #  # ][ #  # ]:          0 :                     aNewSize = OutputDevice::LogicToLogic( aNewSize, aMapUnit, MAP_100TH_MM );
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     407                 :            : 
     408         [ #  # ]:          0 :                     if ( aNewSize != aSize )
     409                 :            :                     {
     410         [ #  # ]:          0 :                         aRect.SetSize( aNewSize );
     411         [ #  # ]:          0 :                         pObj->SetLogicRect( aRect );
     412                 :            :                     }
     413                 :            :                 }
     414         [ #  # ]:          0 :                 catch( embed::NoVisualAreaSizeException& )
     415                 :            :                 {}
     416                 :            :             }
     417                 :            : 
     418 [ #  # ][ #  # ]:          0 :             if ( !rReq.IsAPI() )
     419                 :            :             {
     420                 :            :                 // XXX Activate aus Makro ist toedlich !!! ???
     421         [ #  # ]:          0 :                 if (bIsFromFile)
     422                 :            :                 {
     423                 :            :                     // Objekt ist selektiert, also Draw-Shell aktivieren
     424         [ #  # ]:          0 :                     pViewShell->SetDrawShell( true );
     425                 :            :                 }
     426                 :            :                 else
     427                 :            :                 {
     428         [ #  # ]:          0 :                     pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW );
     429                 :          0 :                     pSkipPaintObj = NULL;
     430                 :            :                 }
     431                 :            :             }
     432                 :            : 
     433 [ #  # ][ #  # ]:          0 :             rReq.Done();
         [ #  # ][ #  # ]
     434                 :            :         }
     435         [ #  # ]:          0 :         catch( uno::Exception& )
     436                 :            :         {
     437                 :            :             OSL_FAIL( "May need error handling here!\n" );
     438                 :            :         }
     439                 :            :     }
     440                 :            :     else
     441         [ #  # ]:          0 :         rReq.Ignore();
     442                 :          0 : }
     443                 :            : 
     444                 :            : /*************************************************************************
     445                 :            : |*
     446                 :            : |* FuInsertOLE::Destruktor
     447                 :            : |*
     448                 :            : \************************************************************************/
     449                 :            : 
     450                 :          0 : FuInsertOLE::~FuInsertOLE()
     451                 :            : {
     452         [ #  # ]:          0 : }
     453                 :            : 
     454                 :            : /*************************************************************************
     455                 :            : |*
     456                 :            : |* FuInsertOLE::Function aktivieren
     457                 :            : |*
     458                 :            : \************************************************************************/
     459                 :            : 
     460                 :          0 : void FuInsertOLE::Activate()
     461                 :            : {
     462                 :          0 :     FuPoor::Activate();
     463                 :          0 : }
     464                 :            : 
     465                 :            : /*************************************************************************
     466                 :            : |*
     467                 :            : |* FuInsertOLE::Function deaktivieren
     468                 :            : |*
     469                 :            : \************************************************************************/
     470                 :            : 
     471                 :          0 : void FuInsertOLE::Deactivate()
     472                 :            : {
     473                 :          0 :     FuPoor::Deactivate();
     474                 :          0 : }
     475                 :            : 
     476                 :            : /*************************************************************************
     477                 :            : |*
     478                 :            : |* FuInsertChart::Konstruktor
     479                 :            : |*
     480                 :            : \************************************************************************/
     481                 :            : 
     482                 :          0 : FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
     483                 :            :            SdrModel* pDoc, SfxRequest& rReq)
     484                 :          0 :     : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
     485                 :            : {
     486                 :          0 :     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
     487                 :            : 
     488 [ #  # ][ #  # ]:          0 :     if( ! rReq.IsAPI() )
     489         [ #  # ]:          0 :         rReq.Done();
     490                 :            : 
     491 [ #  # ][ #  # ]:          0 :     if( SvtModuleOptions().IsChart() )
         [ #  # ][ #  # ]
     492                 :            :     {
     493                 :            :         // ----------------------------------------
     494                 :            :         // BM/IHA --
     495                 :            : 
     496                 :            :         // get range
     497                 :          0 :         ::rtl::OUString aRangeString;
     498                 :          0 :         ScRange aPositionRange;             // cell range for chart positioning
     499         [ #  # ]:          0 :         if( pReqArgs )
     500                 :            :         {
     501                 :            :             const SfxPoolItem* pItem;
     502 [ #  # ][ #  # ]:          0 :             if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) )
     503         [ #  # ]:          0 :             aRangeString = ::rtl::OUString( ((const SfxStringItem*)pItem)->GetValue());
     504                 :            : 
     505         [ #  # ]:          0 :             aPositionRange = pViewSh->GetViewData()->GetCurPos();
     506                 :            :         }
     507                 :            :         else
     508                 :            :         {
     509         [ #  # ]:          0 :             ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData();
     510                 :          0 :             bool bAutomaticMark = false;
     511 [ #  # ][ #  # ]:          0 :             if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
                 [ #  # ]
     512                 :            :             {
     513         [ #  # ]:          0 :                 pViewSh->GetViewData()->GetView()->MarkDataArea( sal_True );
     514                 :          0 :                 bAutomaticMark = true;
     515                 :            :             }
     516                 :            : 
     517         [ #  # ]:          0 :             ScMarkData aMultiMark( rMark );
     518         [ #  # ]:          0 :             aMultiMark.MarkToMulti();
     519                 :            : 
     520         [ #  # ]:          0 :             ScRangeList aRanges;
     521         [ #  # ]:          0 :             aMultiMark.FillRangeListWithMarks( &aRanges, false );
     522         [ #  # ]:          0 :             String aStr;
     523         [ #  # ]:          0 :             ScDocument* pDocument = pViewSh->GetViewData()->GetDocument();
     524 [ #  # ][ #  # ]:          0 :             aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() );
     525         [ #  # ]:          0 :             aRangeString = aStr;
     526                 :            : 
     527                 :            :             // get "total" range for positioning
     528 [ #  # ][ #  # ]:          0 :             if ( !aRanges.empty() )
     529                 :            :             {
     530         [ #  # ]:          0 :                 aPositionRange = *aRanges[ 0 ];
     531 [ #  # ][ #  # ]:          0 :                 for ( size_t i = 1, nCount = aRanges.size(); i < nCount; ++i )
     532                 :            :                 {
     533 [ #  # ][ #  # ]:          0 :                     aPositionRange.ExtendTo( *aRanges[ i ] );
     534                 :            :                 }
     535                 :            :             }
     536                 :            : 
     537         [ #  # ]:          0 :             if(bAutomaticMark)
     538 [ #  # ][ #  # ]:          0 :                 pViewSh->GetViewData()->GetView()->Unmark();
         [ #  # ][ #  # ]
     539                 :            :         }
     540                 :            : 
     541                 :            :         // ----------------------------------------
     542                 :            :         // adapted old code
     543         [ #  # ]:          0 :         pView->UnmarkAll();
     544                 :            : 
     545                 :          0 :         ::rtl::OUString aName;
     546                 :          0 :         const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
     547                 :            : 
     548                 :            :         uno::Reference < embed::XEmbeddedObject > xObj =
     549 [ #  # ][ #  # ]:          0 :             pViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     550                 :            : 
     551                 :          0 :         uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
     552         [ #  # ]:          0 :         uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
     553         [ #  # ]:          0 :         if( xCompSupp.is())
     554 [ #  # ][ #  # ]:          0 :             xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
     555                 :            : 
     556                 :            :         // lock the model to suppress any internal updates
     557         [ #  # ]:          0 :         uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
     558         [ #  # ]:          0 :         if( xChartModel.is() )
     559 [ #  # ][ #  # ]:          0 :             xChartModel->lockControllers();
     560                 :            : 
     561                 :          0 :         ScRangeListRef aDummy;
     562         [ #  # ]:          0 :         Rectangle aMarkDest;
     563                 :            :         SCTAB nMarkTab;
     564         [ #  # ]:          0 :         sal_Bool bDrawRect = pViewShell->GetChartArea( aDummy, aMarkDest, nMarkTab );
     565                 :            : 
     566                 :            :         //  Objekt-Groesse
     567 [ #  # ][ #  # ]:          0 :         awt::Size aSz = xObj->getVisualAreaSize( nAspect );
     568                 :          0 :         Size aSize( aSz.Width, aSz.Height );
     569                 :            : 
     570 [ #  # ][ #  # ]:          0 :         MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
                 [ #  # ]
     571                 :            : 
     572                 :          0 :         sal_Bool bSizeCh = false;
     573 [ #  # ][ #  # ]:          0 :         if (bDrawRect && !aMarkDest.IsEmpty())
         [ #  # ][ #  # ]
     574                 :            :         {
     575         [ #  # ]:          0 :             aSize = aMarkDest.GetSize();
     576                 :          0 :             bSizeCh = sal_True;
     577                 :            :         }
     578 [ #  # ][ #  # ]:          0 :         if (aSize.Height() <= 0 || aSize.Width() <= 0)
                 [ #  # ]
     579                 :            :         {
     580                 :          0 :             aSize.Width() = 5000;
     581                 :          0 :             aSize.Height() = 5000;
     582                 :          0 :             bSizeCh = sal_True;
     583                 :            :         }
     584         [ #  # ]:          0 :         if (bSizeCh)
     585                 :            :         {
     586 [ #  # ][ #  # ]:          0 :             aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     587                 :          0 :             aSz.Width = aSize.Width();
     588                 :          0 :             aSz.Height = aSize.Height();
     589 [ #  # ][ #  # ]:          0 :             xObj->setVisualAreaSize( nAspect, aSz );
     590                 :            :         }
     591                 :            : 
     592                 :          0 :         ScViewData* pData = pViewSh->GetViewData();
     593                 :          0 :         ScDocShell* pScDocSh = pData->GetDocShell();
     594                 :          0 :         ScDocument* pScDoc   = pScDocSh->GetDocument();
     595                 :          0 :         sal_Bool bUndo (pScDoc->IsUndoEnabled());
     596                 :            : 
     597         [ #  # ]:          0 :         if( pReqArgs )
     598                 :            :         {
     599                 :            :             const SfxPoolItem* pItem;
     600                 :          0 :             sal_uInt16 nToTable = 0;
     601                 :            : 
     602 [ #  # ][ #  # ]:          0 :             if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
     603                 :            :             {
     604 [ #  # ][ #  # ]:          0 :                 if ( pItem->ISA( SfxUInt16Item ) )
                 [ #  # ]
     605                 :          0 :                     nToTable = ((const SfxUInt16Item*)pItem)->GetValue();
     606 [ #  # ][ #  # ]:          0 :                 else if ( pItem->ISA( SfxBoolItem ) )
                 [ #  # ]
     607                 :            :                 {
     608                 :            :                     //  in der idl fuer Basic steht FN_PARAM_4 als SfxBoolItem
     609                 :            :                     //  -> wenn gesetzt, neue Tabelle, sonst aktuelle Tabelle
     610                 :            : 
     611         [ #  # ]:          0 :                     if ( ((const SfxBoolItem*)pItem)->GetValue() )
     612         [ #  # ]:          0 :                         nToTable = static_cast<sal_uInt16>(pScDoc->GetTableCount());
     613                 :            :                     else
     614                 :          0 :                         nToTable = static_cast<sal_uInt16>(pData->GetTabNo());
     615                 :            :                 }
     616                 :            :             }
     617                 :            :             else
     618                 :            :             {
     619         [ #  # ]:          0 :                 if (bDrawRect)
     620                 :          0 :                     nToTable = static_cast<sal_uInt16>(nMarkTab);
     621 [ #  # ][ #  # ]:          0 :                 rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) );
                 [ #  # ]
     622                 :            :             }
     623                 :            : 
     624                 :            :             // auf neue Tabelle ausgeben?
     625 [ #  # ][ #  # ]:          0 :             if ( nToTable == pScDoc->GetTableCount() )
     626                 :            :             {
     627                 :            :                 // dann los...
     628                 :          0 :                 rtl::OUString      aTabName;
     629         [ #  # ]:          0 :                 SCTAB       nNewTab = pScDoc->GetTableCount();
     630                 :            : 
     631         [ #  # ]:          0 :                 pScDoc->CreateValidTabName( aTabName );
     632                 :            : 
     633 [ #  # ][ #  # ]:          0 :                 if ( pScDoc->InsertTab( nNewTab, aTabName ) )
     634                 :            :                 {
     635                 :          0 :                     sal_Bool bAppend = sal_True;
     636                 :            : 
     637         [ #  # ]:          0 :                     if (bUndo)
     638                 :            :                     {
     639         [ #  # ]:          0 :                         pScDocSh->GetUndoManager()->AddUndoAction(
     640                 :            :                             new ScUndoInsertTab( pScDocSh, nNewTab,
     641 [ #  # ][ #  # ]:          0 :                                                  bAppend, aTabName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     642                 :            :                     }
     643                 :            : 
     644 [ #  # ][ #  # ]:          0 :                     pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) );
                 [ #  # ]
     645         [ #  # ]:          0 :                     pViewSh->SetTabNo( nNewTab, sal_True );
     646         [ #  # ]:          0 :                     pScDocSh->PostPaintExtras();            //! erst hinterher ???
     647                 :            :                 }
     648                 :            :                 else
     649                 :            :                 {
     650                 :            :                     OSL_FAIL( "Could not create new table :-/" );
     651                 :          0 :                 }
     652                 :            :             }
     653         [ #  # ]:          0 :             else if ( nToTable != pData->GetTabNo() )
     654                 :            :             {
     655         [ #  # ]:          0 :                 pViewSh->SetTabNo( nToTable, sal_True );
     656                 :            :             }
     657                 :            :         }
     658                 :            : 
     659         [ #  # ]:          0 :         lcl_ChartInit( xObj, pData, aRangeString );         // set source range, auto-detect column/row headers
     660                 :            : 
     661                 :            :         //  Objekt-Position
     662                 :            : 
     663                 :          0 :         Point aStart;
     664         [ #  # ]:          0 :         if ( bDrawRect )
     665                 :          0 :             aStart = aMarkDest.TopLeft();                       // marked by hand
     666                 :            :         else
     667                 :            :         {
     668                 :            :             // get chart position (from window size and data range)
     669         [ #  # ]:          0 :             aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
     670                 :            :         }
     671                 :            : 
     672         [ #  # ]:          0 :         Rectangle aRect (aStart, aSize);
     673 [ #  # ][ #  # ]:          0 :         SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     674                 :            : 
     675                 :            :         // Dieses Objekt nicht vor dem Aktivieren zeichnen
     676                 :            :         // (in MarkListHasChanged kommt ein Update)
     677                 :          0 :         pSkipPaintObj = pObj;
     678                 :            : 
     679                 :          0 :         SdrPageView* pPV = pView->GetSdrPageView();
     680                 :            : 
     681                 :            : //        pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immidiate redraw and asks the chart for a visual representation
     682                 :            : 
     683                 :            :         // use the page instead of the view to insert, so no undo action is created yet
     684                 :          0 :         SdrPage* pInsPage = pPV->GetPage();
     685         [ #  # ]:          0 :         pInsPage->InsertObject( pObj );
     686         [ #  # ]:          0 :         pView->UnmarkAllObj();
     687         [ #  # ]:          0 :         pView->MarkObj( pObj, pPV );
     688                 :          0 :         bool bAddUndo = true;               // add undo action later, unless the dialog is canceled
     689                 :            : 
     690 [ #  # ][ #  # ]:          0 :         if (rReq.IsAPI())
     691                 :            :         {
     692         [ #  # ]:          0 :             if( xChartModel.is() )
     693 [ #  # ][ #  # ]:          0 :                 xChartModel->unlockControllers();
     694                 :            :         }
     695                 :            :         else
     696                 :            :         {
     697                 :            :             //the controller will be unlocked by the dialog when the dialog is told to do so
     698                 :            : 
     699                 :            :             // only activate object if not called via API (e.g. macro)
     700         [ #  # ]:          0 :             pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW );
     701                 :            : 
     702                 :            :             //open wizard
     703                 :            :             //@todo get context from calc if that has one
     704                 :            :             uno::Reference< uno::XComponentContext > xContext(
     705         [ #  # ]:          0 :                 ::cppu::defaultBootstrap_InitialComponentContext() );
     706         [ #  # ]:          0 :             if(xContext.is())
     707                 :            :             {
     708 [ #  # ][ #  # ]:          0 :                 uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
     709         [ #  # ]:          0 :                 if(xMCF.is())
     710                 :            :                 {
     711                 :            :                     uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
     712         [ #  # ]:          0 :                         xMCF->createInstanceWithContext(
     713                 :            :                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.WizardDialog"))
     714 [ #  # ][ #  # ]:          0 :                             , xContext), uno::UNO_QUERY);
                 [ #  # ]
     715         [ #  # ]:          0 :                     uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
     716 [ #  # ][ #  # ]:          0 :                     if( xChartModel.is() && xInit.is() )
                 [ #  # ]
     717                 :            :                     {
     718         [ #  # ]:          0 :                         uno::Reference< awt::XWindow > xDialogParentWindow(0);
     719                 :            :                         //  initialize dialog
     720         [ #  # ]:          0 :                         uno::Sequence<uno::Any> aSeq(2);
     721         [ #  # ]:          0 :                         uno::Any* pArray = aSeq.getArray();
     722                 :          0 :                         beans::PropertyValue aParam1;
     723         [ #  # ]:          0 :                         aParam1.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow"));
     724 [ #  # ][ #  # ]:          0 :                         aParam1.Value <<= uno::makeAny(xDialogParentWindow);
     725                 :          0 :                         beans::PropertyValue aParam2;
     726         [ #  # ]:          0 :                         aParam2.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ChartModel"));
     727 [ #  # ][ #  # ]:          0 :                         aParam2.Value <<= uno::makeAny(xChartModel);
     728 [ #  # ][ #  # ]:          0 :                         pArray[0] <<= uno::makeAny(aParam1);
     729 [ #  # ][ #  # ]:          0 :                         pArray[1] <<= uno::makeAny(aParam2);
     730 [ #  # ][ #  # ]:          0 :                         xInit->initialize( aSeq );
     731                 :            : 
     732                 :            :                         // try to set the dialog's position so it doesn't hide the chart
     733         [ #  # ]:          0 :                         uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY );
     734         [ #  # ]:          0 :                         if ( xDialogProps.is() )
     735                 :            :                         {
     736                 :            :                             try
     737                 :            :                             {
     738                 :            :                                 //get dialog size:
     739                 :          0 :                                 awt::Size aDialogAWTSize;
     740   [ #  #  #  # ]:          0 :                                 if( xDialogProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size")) )
     741 [ #  # ][ #  # ]:          0 :                                     >>= aDialogAWTSize )
                 [ #  # ]
     742                 :            :                                 {
     743                 :          0 :                                     Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height );
     744 [ #  # ][ #  # ]:          0 :                                     if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 )
                 [ #  # ]
     745                 :            :                                     {
     746                 :            :                                         //calculate and set new position
     747         [ #  # ]:          0 :                                         Point aDialogPos = pViewShell->GetChartDialogPos( aDialogSize, aRect );
     748         [ #  # ]:          0 :                                         xDialogProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Position")),
     749 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
                 [ #  # ]
     750                 :            :                                     }
     751                 :            :                                 }
     752                 :            :                                 //tell the dialog to unlock controller
     753         [ #  # ]:          0 :                                 xDialogProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UnlockControllersOnExecute")),
     754 [ #  # ][ #  # ]:          0 :                                             uno::makeAny( sal_True ) );
         [ #  # ][ #  # ]
     755                 :            : 
     756                 :            :                             }
     757         [ #  # ]:          0 :                             catch( uno::Exception& )
     758                 :            :                             {
     759                 :            :                                 OSL_FAIL( "Chart wizard couldn't be positioned automatically\n" );
     760                 :            :                             }
     761                 :            :                         }
     762                 :            : 
     763 [ #  # ][ #  # ]:          0 :                         sal_Int16 nDialogRet = xDialog->execute();
     764         [ #  # ]:          0 :                         if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
     765                 :            :                         {
     766                 :            :                             // leave OLE inplace mode and unmark
     767                 :            :                             OSL_ASSERT( pViewShell );
     768                 :            :                             OSL_ASSERT( pView );
     769         [ #  # ]:          0 :                             pViewShell->DeactivateOle();
     770         [ #  # ]:          0 :                             pView->UnmarkAll();
     771                 :            : 
     772                 :            :                             // old page view pointer is invalid after switching sheets
     773                 :          0 :                             pPV = pView->GetSdrPageView();
     774                 :            : 
     775                 :            :                             // remove the chart
     776                 :            :                             OSL_ASSERT( pPV );
     777                 :          0 :                             SdrPage * pPage( pPV->GetPage());
     778                 :            :                             OSL_ASSERT( pPage );
     779                 :            :                             OSL_ASSERT( pObj );
     780         [ #  # ]:          0 :                             if( pPage )
     781 [ #  # ][ #  # ]:          0 :                                 pPage->RemoveObject( pObj->GetOrdNum());
     782                 :            : 
     783                 :          0 :                             bAddUndo = false;       // don't create the undo action for inserting
     784                 :            : 
     785                 :            :                             // leave the draw shell
     786         [ #  # ]:          0 :                             pViewShell->SetDrawShell( false );
     787                 :            :                         }
     788                 :            :                         else
     789                 :            :                         {
     790                 :            :                             OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK );
     791                 :            :                             //@todo maybe move chart to different table
     792         [ #  # ]:          0 :                         }
     793                 :            :                     }
     794         [ #  # ]:          0 :                     uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
     795         [ #  # ]:          0 :                     if( xComponent.is())
     796 [ #  # ][ #  # ]:          0 :                         xComponent->dispose();
     797                 :          0 :                 }
     798                 :          0 :             }
     799                 :            :         }
     800                 :            : 
     801         [ #  # ]:          0 :         if ( bAddUndo )
     802                 :            :         {
     803                 :            :             // add undo action the same way as in SdrEditView::InsertObjectAtView
     804                 :            :             // (using UndoActionHdl etc.)
     805 [ #  # ][ #  # ]:          0 :             pView->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
                 [ #  # ]
     806         [ #  # ]:          0 :         }
     807                 :            : 
     808                 :            :         // BM/IHA --
     809                 :            :     }
     810                 :          0 : }
     811                 :            : 
     812                 :            : /*************************************************************************
     813                 :            : |*
     814                 :            : |* FuInsertChart::Destruktor
     815                 :            : |*
     816                 :            : \************************************************************************/
     817                 :            : 
     818                 :          0 : FuInsertChart::~FuInsertChart()
     819                 :            : {
     820         [ #  # ]:          0 : }
     821                 :            : 
     822                 :            : /*************************************************************************
     823                 :            : |*
     824                 :            : |* FuInsertChart::Function aktivieren
     825                 :            : |*
     826                 :            : \************************************************************************/
     827                 :            : 
     828                 :          0 : void FuInsertChart::Activate()
     829                 :            : {
     830                 :          0 :     FuPoor::Activate();
     831                 :          0 : }
     832                 :            : 
     833                 :            : /*************************************************************************
     834                 :            : |*
     835                 :            : |* FuInsertChart::Function deaktivieren
     836                 :            : |*
     837                 :            : \************************************************************************/
     838                 :            : 
     839                 :          0 : void FuInsertChart::Deactivate()
     840                 :            : {
     841                 :          0 :     FuPoor::Deactivate();
     842                 :          0 : }
     843                 :            : 
     844                 :            : 
     845                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10