LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - cellsh1.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1324 0.1 %
Date: 2012-12-17 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 <iostream>
      21             : 
      22             : #include <com/sun/star/i18n/TextConversionOption.hpp>
      23             : #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
      24             : 
      25             : #include "scitems.hxx"
      26             : #include <sfx2/viewfrm.hxx>
      27             : 
      28             : #include <svl/stritem.hxx>
      29             : #include <svl/whiter.hxx>
      30             : #include <svl/zforlist.hxx>
      31             : #include <svl/zformat.hxx>
      32             : #include <sfx2/dispatch.hxx>
      33             : #include <sfx2/request.hxx>
      34             : #include <vcl/msgbox.hxx>
      35             : #include <svx/svxdlg.hxx>
      36             : #include <sot/formats.hxx>
      37             : #include <svx/postattr.hxx>
      38             : #include <editeng/fontitem.hxx>
      39             : #include <svx/clipfmtitem.hxx>
      40             : #include <sfx2/passwd.hxx>
      41             : #include <svx/hlnkitem.hxx>
      42             : #include <basic/sbxcore.hxx>
      43             : #include <unotools/useroptions.hxx>
      44             : #include <vcl/waitobj.hxx>
      45             : #include <unotools/localedatawrapper.hxx>
      46             : 
      47             : #include "cellsh.hxx"
      48             : #include "sc.hrc"
      49             : #include "document.hxx"
      50             : #include "patattr.hxx"
      51             : #include "scmod.hxx"
      52             : #include "scresid.hxx"
      53             : #include "tabvwsh.hxx"
      54             : #include "impex.hxx"
      55             : #include "reffind.hxx"
      56             : #include "uiitems.hxx"
      57             : #include "reffact.hxx"
      58             : #include "inputhdl.hxx"
      59             : #include "transobj.hxx"
      60             : #include "drwtrans.hxx"
      61             : #include "docfunc.hxx"
      62             : #include "editable.hxx"
      63             : #include "dpobject.hxx"
      64             : #include "dpsave.hxx"
      65             : #include "dpgroup.hxx"      // for ScDPNumGroupInfo
      66             : #include "spellparam.hxx"
      67             : #include "postit.hxx"
      68             : #include "clipparam.hxx"
      69             : #include "pivot.hxx"
      70             : #include "dpsdbtab.hxx"     // ScImportSourceDesc
      71             : #include "dpshttab.hxx"     // ScSheetSourceDesc
      72             : #include "dbdata.hxx"
      73             : #include "docsh.hxx"
      74             : #include "cliputil.hxx"
      75             : #include "markdata.hxx"
      76             : #include "docpool.hxx"
      77             : #include "condformatdlg.hxx"
      78             : #include "attrib.hxx"
      79             : 
      80             : #include "globstr.hrc"
      81             : #include "scui_def.hxx"
      82             : #include <svx/dialogs.hrc>
      83             : #include "scabstdlg.hxx"
      84             : 
      85             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      86             : #include <com/sun/star/lang/XInitialization.hpp>
      87             : #include <com/sun/star/beans/PropertyValue.hpp>
      88             : #include <com/sun/star/beans/XPropertySet.hpp>
      89             : #include <cppuhelper/bootstrap.hxx>
      90             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      91             : #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
      92             : 
      93             : #include <boost/scoped_ptr.hpp>
      94             : 
      95             : using namespace ::com::sun::star;
      96             : using namespace ::com::sun::star::beans;
      97             : using namespace ::com::sun::star::uno;
      98             : using ::rtl::OUString;
      99             : 
     100             : //------------------------------------------------------------------
     101           0 : void ScCellShell::ExecuteEdit( SfxRequest& rReq )
     102             : {
     103           0 :     ScModule*           pScMod      = SC_MOD();
     104           0 :     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
     105           0 :     SfxBindings&        rBindings   = pTabViewShell->GetViewFrame()->GetBindings();
     106           0 :     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
     107           0 :     sal_uInt16              nSlot       = rReq.GetSlot();
     108             : 
     109           0 :     pTabViewShell->HideListBox();                   // Autofilter-DropDown-Listbox
     110             : 
     111             :     // finish input
     112           0 :     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
     113             :     {
     114           0 :         switch ( nSlot )
     115             :         {
     116             :             case FID_DEFINE_NAME:
     117             :             case FID_ADD_NAME:
     118             :             case FID_USE_NAME:
     119             :             case FID_INSERT_NAME:
     120             :             case SID_SPELL_DIALOG:
     121             :             case SID_HANGUL_HANJA_CONVERSION:
     122             :             case SID_OPENDLG_CONDFRMT:
     123             :             case SID_OPENDLG_COLORSCALE:
     124             :             case SID_OPENDLG_DATABAR:
     125             : 
     126           0 :             pScMod->InputEnterHandler();
     127           0 :             pTabViewShell->UpdateInputHandler();
     128           0 :             break;
     129             : 
     130             :             default:
     131           0 :             break;
     132             :         }
     133             :     }
     134             : 
     135           0 :     switch ( nSlot )
     136             :     {
     137             :         //
     138             :         //  insert / delete cells / rows / columns
     139             :         //
     140             : 
     141             :         case FID_INS_ROW:
     142           0 :             pTabViewShell->InsertCells(INS_INSROWS);
     143           0 :             rReq.Done();
     144           0 :             break;
     145             : 
     146             :         case FID_INS_COLUMN:
     147           0 :             pTabViewShell->InsertCells(INS_INSCOLS);
     148           0 :             rReq.Done();
     149           0 :             break;
     150             : 
     151             :         case FID_INS_CELLSDOWN:
     152           0 :             pTabViewShell->InsertCells(INS_CELLSDOWN);
     153           0 :             rReq.Done();
     154           0 :             break;
     155             : 
     156             :         case FID_INS_CELLSRIGHT:
     157           0 :             pTabViewShell->InsertCells(INS_CELLSRIGHT);
     158           0 :             rReq.Done();
     159           0 :             break;
     160             : 
     161             :         case SID_DEL_ROWS:
     162           0 :             pTabViewShell->DeleteCells( DEL_DELROWS );
     163           0 :             rReq.Done();
     164           0 :             break;
     165             : 
     166             :         case SID_DEL_COLS:
     167           0 :             pTabViewShell->DeleteCells( DEL_DELCOLS );
     168           0 :             rReq.Done();
     169           0 :             break;
     170             : 
     171             :         case FID_INS_CELL:
     172             :             {
     173           0 :                 InsCellCmd eCmd=INS_NONE;
     174             : 
     175           0 :                 if ( pReqArgs )
     176             :                 {
     177             :                     const SfxPoolItem* pItem;
     178           0 :                     String aFlags;
     179             : 
     180           0 :                     if( pReqArgs->HasItem( FID_INS_CELL, &pItem ) )
     181           0 :                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
     182           0 :                     if( aFlags.Len() )
     183             :                     {
     184           0 :                         switch( aFlags.GetChar(0) )
     185             :                         {
     186           0 :                             case 'V': eCmd = INS_CELLSDOWN ;break;
     187           0 :                             case '>': eCmd = INS_CELLSRIGHT ;break;
     188           0 :                             case 'R': eCmd = INS_INSROWS ;break;
     189           0 :                             case 'C': eCmd = INS_INSCOLS ;break;
     190             :                         }
     191           0 :                     }
     192             :                 }
     193             :                 else
     194             :                 {
     195           0 :                     if ( GetViewData()->SimpleColMarked() )
     196           0 :                         eCmd = INS_INSCOLS;
     197           0 :                     else if ( GetViewData()->SimpleRowMarked() )
     198           0 :                         eCmd = INS_INSROWS;
     199             :                     else
     200             :                     {
     201           0 :                         ScDocument* pDoc = GetViewData()->GetDocument();
     202           0 :                         sal_Bool bTheFlag=(pDoc->GetChangeTrack()!=NULL);
     203             : 
     204           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     205             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     206             : 
     207           0 :                         AbstractScInsertCellDlg* pDlg = pFact->CreateScInsertCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_INSCELL, bTheFlag);
     208             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
     209           0 :                         if (pDlg->Execute() == RET_OK)
     210           0 :                             eCmd = pDlg->GetInsCellCmd();
     211           0 :                         delete pDlg;
     212             :                     }
     213             :                 }
     214             : 
     215           0 :                 if (eCmd!=INS_NONE)
     216             :                 {
     217           0 :                     pTabViewShell->InsertCells( eCmd );
     218             : 
     219           0 :                     if( ! rReq.IsAPI() )
     220             :                     {
     221           0 :                         String aParam;
     222             : 
     223           0 :                         switch( eCmd )
     224             :                         {
     225           0 :                             case INS_CELLSDOWN: aParam='V'; break;
     226           0 :                             case INS_CELLSRIGHT: aParam='>'; break;
     227           0 :                             case INS_INSROWS: aParam='R'; break;
     228           0 :                             case INS_INSCOLS: aParam='C'; break;
     229             :                             default:
     230             :                             {
     231             :                                 // added to avoid warnings
     232             :                             }
     233             :                         }
     234           0 :                         rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
     235           0 :                         rReq.Done();
     236             :                     }
     237             :                 }
     238             :             }
     239           0 :             break;
     240             : 
     241             :         case FID_DELETE_CELL:
     242             :             {
     243           0 :                 DelCellCmd eCmd = DEL_NONE;
     244             : 
     245           0 :                 if ( pReqArgs )
     246             :                 {
     247             :                     const SfxPoolItem* pItem;
     248           0 :                     String aFlags;
     249             : 
     250           0 :                     if( pReqArgs->HasItem( FID_DELETE_CELL, &pItem ) )
     251           0 :                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
     252           0 :                     if( aFlags.Len() )
     253             :                     {
     254           0 :                         switch( aFlags.GetChar(0) )
     255             :                         {
     256           0 :                             case 'U': eCmd = DEL_CELLSUP ;break;
     257           0 :                             case 'L': eCmd = DEL_CELLSLEFT ;break;
     258           0 :                             case 'R': eCmd = DEL_DELROWS ;break;
     259           0 :                             case 'C': eCmd = DEL_DELCOLS ;break;
     260             :                         }
     261           0 :                     }
     262             :                 }
     263             :                 else
     264             :                 {
     265           0 :                     if ( GetViewData()->SimpleColMarked() )
     266           0 :                         eCmd = DEL_DELCOLS;
     267           0 :                     else if ( GetViewData()->SimpleRowMarked() )
     268           0 :                         eCmd = DEL_DELROWS;
     269             :                     else
     270             :                     {
     271           0 :                         ScRange aRange;
     272           0 :                         ScDocument* pDoc = GetViewData()->GetDocument();
     273           0 :                         sal_Bool bTheFlag=GetViewData()->IsMultiMarked() ||
     274           0 :                             (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) ||
     275           0 :                             (pDoc->GetChangeTrack() != NULL);
     276             : 
     277           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     278             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     279             : 
     280           0 :                         AbstractScDeleteCellDlg* pDlg = pFact->CreateScDeleteCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCELL, bTheFlag );
     281             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
     282             : 
     283           0 :                         if (pDlg->Execute() == RET_OK)
     284           0 :                             eCmd = pDlg->GetDelCellCmd();
     285           0 :                         delete pDlg;
     286             :                     }
     287             :                 }
     288             : 
     289           0 :                 if (eCmd != DEL_NONE )
     290             :                 {
     291           0 :                     pTabViewShell->DeleteCells( eCmd );
     292             : 
     293           0 :                     if( ! rReq.IsAPI() )
     294             :                     {
     295           0 :                         String aParam;
     296             : 
     297           0 :                         switch( eCmd )
     298             :                         {
     299           0 :                             case DEL_CELLSUP: aParam='U'; break;
     300           0 :                             case DEL_CELLSLEFT: aParam='L'; break;
     301           0 :                             case DEL_DELROWS: aParam='R'; break;
     302           0 :                             case DEL_DELCOLS: aParam='C'; break;
     303             :                             default:
     304             :                             {
     305             :                                 // added to avoid warnings
     306             :                             }
     307             :                         }
     308           0 :                         rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
     309           0 :                         rReq.Done();
     310             :                     }
     311             :                 }
     312             :             }
     313           0 :             break;
     314             : 
     315             :         //
     316             :         //  delete contents from cells
     317             :         //
     318             : 
     319             :         case SID_DELETE_CONTENTS:
     320           0 :             pTabViewShell->DeleteContents( IDF_CONTENTS );
     321           0 :             rReq.Done();
     322           0 :             break;
     323             : 
     324             :         case SID_DELETE:
     325             :             {
     326           0 :                 sal_uInt16  nFlags = IDF_NONE;
     327             : 
     328           0 :                 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
     329             :                 {
     330             :                     const   SfxPoolItem* pItem;
     331           0 :                     String  aFlags = rtl::OUString('A');
     332             : 
     333           0 :                     if( pReqArgs->HasItem( SID_DELETE, &pItem ) )
     334           0 :                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
     335             : 
     336           0 :                     aFlags.ToUpperAscii();
     337           0 :                     sal_Bool    bCont = sal_True;
     338             : 
     339           0 :                     for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
     340             :                     {
     341           0 :                         switch( aFlags.GetChar(i) )
     342             :                         {
     343             :                             case 'A': // all
     344           0 :                             nFlags |= IDF_ALL;
     345           0 :                             bCont = false; // don't continue!
     346           0 :                             break;
     347           0 :                             case 'S': nFlags |= IDF_STRING; break;
     348           0 :                             case 'V': nFlags |= IDF_VALUE; break;
     349           0 :                             case 'D': nFlags |= IDF_DATETIME; break;
     350           0 :                             case 'F': nFlags |= IDF_FORMULA; break;
     351           0 :                             case 'N': nFlags |= IDF_NOTE; break;
     352           0 :                             case 'T': nFlags |= IDF_ATTRIB; break;
     353           0 :                             case 'O': nFlags |= IDF_OBJECTS; break;
     354             :                         }
     355           0 :                     }
     356             :                 }
     357             :                 else
     358             :                 {
     359           0 :                     ScEditableTester aTester( pTabViewShell );
     360           0 :                     if (aTester.IsEditable())
     361             :                     {
     362           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     363             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     364             : 
     365           0 :                         AbstractScDeleteContentsDlg* pDlg = pFact->CreateScDeleteContentsDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCONT );
     366             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
     367           0 :                         ScDocument* pDoc = GetViewData()->GetDocument();
     368           0 :                         SCTAB nTab = GetViewData()->GetTabNo();
     369           0 :                         if ( pDoc->IsTabProtected(nTab) )
     370           0 :                             pDlg->DisableObjects();
     371           0 :                         if (pDlg->Execute() == RET_OK)
     372             :                         {
     373           0 :                             nFlags = pDlg->GetDelContentsCmdBits();
     374             :                         }
     375           0 :                         delete pDlg;
     376             :                     }
     377             :                     else
     378           0 :                         pTabViewShell->ErrorMessage(aTester.GetMessageId());
     379             :                 }
     380             : 
     381           0 :                 if( nFlags != IDF_NONE )
     382             :                 {
     383           0 :                     pTabViewShell->DeleteContents( nFlags );
     384             : 
     385           0 :                     if( ! rReq.IsAPI() )
     386             :                     {
     387           0 :                         String  aFlags;
     388             : 
     389           0 :                         if( nFlags == IDF_ALL )
     390             :                         {
     391           0 :                             aFlags += 'A';
     392             :                         }
     393             :                         else
     394             :                         {
     395           0 :                             if( nFlags & IDF_STRING ) aFlags += 'S';
     396           0 :                             if( nFlags & IDF_VALUE ) aFlags += 'V';
     397           0 :                             if( nFlags & IDF_DATETIME ) aFlags += 'D';
     398           0 :                             if( nFlags & IDF_FORMULA ) aFlags += 'F';
     399           0 :                             if( nFlags & IDF_NOTE ) aFlags += 'N';
     400           0 :                             if( nFlags & IDF_ATTRIB ) aFlags += 'T';
     401           0 :                             if( nFlags & IDF_OBJECTS ) aFlags += 'O';
     402             :                         }
     403             : 
     404           0 :                         rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) );
     405           0 :                         rReq.Done();
     406             :                     }
     407             :                 }
     408             :             }
     409           0 :             break;
     410             : 
     411             :         //
     412             :         //  fill...
     413             :         //
     414             : 
     415             :         case FID_FILL_TO_BOTTOM:
     416           0 :             pTabViewShell->FillSimple( FILL_TO_BOTTOM );
     417           0 :             rReq.Done();
     418           0 :             break;
     419             : 
     420             :         case FID_FILL_TO_RIGHT:
     421           0 :             pTabViewShell->FillSimple( FILL_TO_RIGHT );
     422           0 :             rReq.Done();
     423           0 :             break;
     424             : 
     425             :         case FID_FILL_TO_TOP:
     426           0 :             pTabViewShell->FillSimple( FILL_TO_TOP );
     427           0 :             rReq.Done();
     428           0 :             break;
     429             : 
     430             :         case FID_FILL_TO_LEFT:
     431           0 :             pTabViewShell->FillSimple( FILL_TO_LEFT );
     432           0 :             rReq.Done();
     433           0 :             break;
     434             : 
     435             :         case FID_FILL_TAB:
     436             :             {
     437           0 :                 sal_uInt16 nFlags = IDF_NONE;
     438           0 :                 sal_uInt16 nFunction = PASTE_NOFUNC;
     439           0 :                 sal_Bool bSkipEmpty = false;
     440           0 :                 sal_Bool bAsLink    = false;
     441             : 
     442           0 :                 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
     443             :                 {
     444             :                     const   SfxPoolItem* pItem;
     445           0 :                     String  aFlags = rtl::OUString('A');
     446             : 
     447           0 :                     if( pReqArgs->HasItem( FID_FILL_TAB, &pItem ) )
     448           0 :                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
     449             : 
     450           0 :                     aFlags.ToUpperAscii();
     451           0 :                     sal_Bool    bCont = sal_True;
     452             : 
     453           0 :                     for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
     454             :                     {
     455           0 :                         switch( aFlags.GetChar(i) )
     456             :                         {
     457             :                             case 'A': // all
     458           0 :                             nFlags |= IDF_ALL;
     459           0 :                             bCont = false; // don't continue!
     460           0 :                             break;
     461           0 :                             case 'S': nFlags |= IDF_STRING; break;
     462           0 :                             case 'V': nFlags |= IDF_VALUE; break;
     463           0 :                             case 'D': nFlags |= IDF_DATETIME; break;
     464           0 :                             case 'F': nFlags |= IDF_FORMULA; break;
     465           0 :                             case 'N': nFlags |= IDF_NOTE; break;
     466           0 :                             case 'T': nFlags |= IDF_ATTRIB; break;
     467             :                         }
     468           0 :                     }
     469             :                 }
     470             :                 else
     471             :                 {
     472           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     473             :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     474             : 
     475             :                     AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
     476             :                                                                                             RID_SCDLG_INSCONT, 0, /* nCheckDefaults */
     477           0 :                                                                                             &ScGlobal::GetRscString(STR_FILL_TAB));
     478             :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     479           0 :                     pDlg->SetFillMode(true);
     480             : 
     481           0 :                     if (pDlg->Execute() == RET_OK)
     482             :                     {
     483           0 :                         nFlags     = pDlg->GetInsContentsCmdBits();
     484           0 :                         nFunction  = pDlg->GetFormulaCmdBits();
     485           0 :                         bSkipEmpty = pDlg->IsSkipEmptyCells();
     486           0 :                         bAsLink    = pDlg->IsLink();
     487             :                         //  there is no MoveMode with fill tabs
     488             :                     }
     489           0 :                     delete pDlg;
     490             :                 }
     491             : 
     492           0 :                 if( nFlags != IDF_NONE )
     493             :                 {
     494           0 :                     pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
     495             : 
     496           0 :                     if( ! rReq.IsAPI() )
     497             :                     {
     498           0 :                         String  aFlags;
     499             : 
     500           0 :                         if( nFlags == IDF_ALL )
     501             :                         {
     502           0 :                             aFlags += 'A';
     503             :                         }
     504             :                         else
     505             :                         {
     506           0 :                             if( nFlags & IDF_STRING ) aFlags += 'S';
     507           0 :                             if( nFlags & IDF_VALUE ) aFlags += 'V';
     508           0 :                             if( nFlags & IDF_DATETIME ) aFlags += 'D';
     509           0 :                             if( nFlags & IDF_FORMULA ) aFlags += 'F';
     510           0 :                             if( nFlags & IDF_NOTE ) aFlags += 'N';
     511           0 :                             if( nFlags & IDF_ATTRIB ) aFlags += 'T';
     512             :                         }
     513             : 
     514           0 :                         rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) );
     515           0 :                         rReq.Done();
     516             :                     }
     517             :                 }
     518             :             }
     519           0 :             break;
     520             : 
     521             :         case FID_FILL_SERIES:
     522             :             {
     523             :                 SCCOL nStartCol;
     524             :                 SCROW nStartRow;
     525             :                 SCTAB nStartTab;
     526             :                 SCCOL nEndCol;
     527             :                 SCROW nEndRow;
     528             :                 SCTAB nEndTab;
     529           0 :                 sal_uInt16 nPossDir = FDS_OPT_NONE;
     530           0 :                 FillDir     eFillDir     = FILL_TO_BOTTOM;
     531           0 :                 FillCmd     eFillCmd     = FILL_LINEAR;
     532           0 :                 FillDateCmd eFillDateCmd = FILL_DAY;
     533           0 :                 double fStartVal = MAXDOUBLE;
     534           0 :                 double fIncVal   = 1;
     535           0 :                 double fMaxVal   = MAXDOUBLE;
     536           0 :                 sal_Bool   bDoIt     = false;
     537             : 
     538             :                 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
     539           0 :                                               nEndCol, nEndRow, nEndTab );
     540             : 
     541           0 :                 if( nStartCol!=nEndCol )
     542             :                 {
     543           0 :                     nPossDir |= FDS_OPT_HORZ;
     544           0 :                     eFillDir=FILL_TO_RIGHT;
     545             :                 }
     546             : 
     547           0 :                 if( nStartRow!=nEndRow )
     548             :                 {
     549           0 :                     nPossDir |= FDS_OPT_VERT;
     550           0 :                     eFillDir=FILL_TO_BOTTOM;
     551             :                 }
     552             : 
     553           0 :                 ScDocument*      pDoc = GetViewData()->GetDocument();
     554           0 :                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     555             : 
     556           0 :                 if( pReqArgs )
     557             :                 {
     558             :                     const SfxPoolItem* pItem;
     559           0 :                     String  aFillDir, aFillCmd, aFillDateCmd;
     560           0 :                     String  aFillStep, aFillStart, aFillMax;
     561             :                     sal_uInt32 nKey;
     562             :                     double  fTmpVal;
     563             : 
     564           0 :                     bDoIt=false;
     565             : 
     566           0 :                     if( pReqArgs->HasItem( FID_FILL_SERIES, &pItem ) )
     567           0 :                         aFillDir = ((const SfxStringItem*)pItem)->GetValue();
     568           0 :                     if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
     569           0 :                         aFillCmd = ((const SfxStringItem*)pItem)->GetValue();
     570           0 :                     if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
     571           0 :                         aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue();
     572           0 :                     if( pReqArgs->HasItem( FN_PARAM_3, &pItem ) )
     573           0 :                         aFillStep = ((const SfxStringItem*)pItem)->GetValue();
     574           0 :                     if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
     575           0 :                         aFillStart = ((const SfxStringItem*)pItem)->GetValue();
     576           0 :                     if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) )
     577           0 :                         aFillMax = ((const SfxStringItem*)pItem)->GetValue();
     578             : 
     579           0 :                     if( aFillDir.Len() )
     580           0 :                         switch( aFillDir.GetChar(0) )
     581             :                         {
     582           0 :                             case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break;
     583           0 :                             case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break;
     584           0 :                             case 'T': case 't': eFillDir=FILL_TO_TOP; break;
     585           0 :                             case 'L': case 'l': eFillDir=FILL_TO_LEFT; break;
     586             :                         }
     587             : 
     588           0 :                     if( aFillCmd.Len() )
     589           0 :                         switch( aFillCmd.GetChar(0) )
     590             :                         {
     591           0 :                             case 'S': case 's': eFillCmd=FILL_SIMPLE; break;
     592           0 :                             case 'L': case 'l': eFillCmd=FILL_LINEAR; break;
     593           0 :                             case 'G': case 'g': eFillCmd=FILL_GROWTH; break;
     594           0 :                             case 'D': case 'd': eFillCmd=FILL_DATE; break;
     595           0 :                             case 'A': case 'a': eFillCmd=FILL_AUTO; break;
     596             :                         }
     597             : 
     598           0 :                     if( aFillDateCmd.Len() )
     599           0 :                         switch( aFillDateCmd.GetChar(0) )
     600             :                         {
     601           0 :                             case 'D': case 'd': eFillDateCmd=FILL_DAY; break;
     602           0 :                             case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break;
     603           0 :                             case 'M': case 'm': eFillDateCmd=FILL_MONTH; break;
     604           0 :                             case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break;
     605             :                         }
     606             : 
     607           0 :                     nKey = 0;
     608           0 :                     if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal ))
     609           0 :                         fStartVal = fTmpVal;
     610             : 
     611           0 :                     nKey = 0;
     612           0 :                     if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal ))
     613           0 :                         fIncVal = fTmpVal;
     614             : 
     615           0 :                     nKey = 0;
     616           0 :                     if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal ))
     617           0 :                         fMaxVal = fTmpVal;
     618             : 
     619           0 :                     bDoIt   = sal_True;
     620             : 
     621             :                 }
     622             :                 else // (pReqArgs == NULL) => raise Dialog
     623             :                 {
     624             :                     sal_uInt32 nPrivFormat;
     625             :                     CellType eCellType;
     626           0 :                     pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
     627           0 :                     pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType );
     628           0 :                     const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat );
     629           0 :                     if (!pPrivEntry)
     630             :                     {
     631             :                         OSL_FAIL("Numberformat not found !!!");
     632             :                     }
     633             :                     else
     634             :                     {
     635           0 :                         short nPrivType = pPrivEntry->GetType();
     636           0 :                         if ( ( nPrivType & NUMBERFORMAT_DATE)>0)
     637             :                         {
     638           0 :                            eFillCmd=FILL_DATE;
     639             :                         }
     640           0 :                         else if(eCellType==CELLTYPE_STRING)
     641             :                         {
     642           0 :                            eFillCmd=FILL_AUTO;
     643             :                         }
     644             :                     }
     645             : 
     646             :                     //
     647           0 :                     String aStartStr;
     648             : 
     649             :                     //  suggest default Startvalue only, when just 1 row or column
     650           0 :                     if ( nStartCol == nEndCol || nStartRow == nEndRow )
     651             :                     {
     652           0 :                         double fInputEndVal = 0.0;
     653           0 :                         String aEndStr;
     654             : 
     655           0 :                         pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
     656           0 :                         pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
     657             : 
     658             : 
     659           0 :                         if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
     660             :                         {
     661           0 :                             pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
     662           0 :                             if(aEndStr.Len()>0)
     663             :                             {
     664           0 :                                 pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
     665           0 :                                 fIncVal=fInputEndVal-fStartVal;
     666             :                             }
     667             :                         }
     668             :                         else
     669             :                         {
     670           0 :                             if(nStartCol < nEndCol)
     671             :                             {
     672           0 :                                 pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
     673           0 :                                 if(aEndStr.Len()>0)
     674             :                                 {
     675           0 :                                     pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
     676           0 :                                     fIncVal=fInputEndVal-fStartVal;
     677             :                                 }
     678             :                             }
     679             :                         }
     680           0 :                         if(eFillCmd==FILL_DATE)
     681             :                         {
     682           0 :                             Date aNullDate = *pDoc->GetFormatTable()->GetNullDate();
     683           0 :                             Date aStartDate = aNullDate;
     684           0 :                             aStartDate+= (long)fStartVal;
     685           0 :                             Date aEndDate = aNullDate;
     686           0 :                             aEndDate+= (long)fInputEndVal;
     687           0 :                             double fTempDate=0;
     688             : 
     689           0 :                             if(aStartDate.GetYear()!=aEndDate.GetYear())
     690             :                             {
     691           0 :                                 eFillDateCmd = FILL_YEAR;
     692           0 :                                 fTempDate=aEndDate.GetYear()-aStartDate.GetYear();
     693             :                             }
     694           0 :                             if(aStartDate.GetMonth()!=aEndDate.GetMonth())
     695             :                             {
     696           0 :                                 eFillDateCmd = FILL_MONTH;
     697           0 :                                 fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth();
     698             :                             }
     699           0 :                             if(aStartDate.GetDay()==aEndDate.GetDay())
     700             :                             {
     701           0 :                                 fIncVal=fTempDate;
     702             :                             }
     703           0 :                         }
     704             :                     }
     705           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     706             :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     707             : 
     708             :                     AbstractScFillSeriesDlg* pDlg = pFact->CreateScFillSeriesDlg( pTabViewShell->GetDialogParent(),
     709             :                                                             *pDoc,
     710             :                                                             eFillDir, eFillCmd, eFillDateCmd,
     711             :                                                             aStartStr, fIncVal, fMaxVal,
     712             :                                                             nPossDir,
     713           0 :                                                             RID_SCDLG_FILLSERIES);
     714             :                     OSL_ENSURE(pDlg, "Dialog create fail!");
     715             : 
     716           0 :                     if ( nStartCol != nEndCol && nStartRow != nEndRow )
     717             :                     {
     718           0 :                         pDlg->SetEdStartValEnabled(false);
     719             :                     }
     720             : 
     721           0 :                     if ( pDlg->Execute() == RET_OK )
     722             :                     {
     723           0 :                         eFillDir        = pDlg->GetFillDir();
     724           0 :                         eFillCmd        = pDlg->GetFillCmd();
     725           0 :                         eFillDateCmd    = pDlg->GetFillDateCmd();
     726             : 
     727           0 :                         if(eFillCmd==FILL_AUTO)
     728             :                         {
     729           0 :                             String aStr=pDlg->GetStartStr();
     730           0 :                             if(aStr.Len()>0)
     731           0 :                                 pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr );
     732             :                         }
     733           0 :                         fStartVal       = pDlg->GetStart();
     734           0 :                         fIncVal         = pDlg->GetStep();
     735           0 :                         fMaxVal         = pDlg->GetMax();
     736           0 :                         bDoIt           = sal_True;
     737             :                     }
     738           0 :                     delete pDlg;
     739             :                 }
     740             : 
     741           0 :                 if( bDoIt )
     742             :                 {
     743             :                     //nScFillModeMouseModifier = 0; // no Ctrl/Copy
     744           0 :                     pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal );
     745             : 
     746           0 :                     if( ! rReq.IsAPI() )
     747             :                     {
     748           0 :                         String  aPara;
     749           0 :                         Color*  pColor=0;
     750             : 
     751           0 :                         switch( eFillDir )
     752             :                         {
     753           0 :                             case FILL_TO_BOTTOM:    aPara = 'B'; break;
     754           0 :                             case FILL_TO_RIGHT:     aPara = 'R'; break;
     755           0 :                             case FILL_TO_TOP:       aPara = 'T'; break;
     756           0 :                             case FILL_TO_LEFT:      aPara = 'L'; break;
     757           0 :                             default: aPara.Erase(); break;
     758             :                         }
     759           0 :                         rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) );
     760             : 
     761           0 :                         switch( eFillCmd )
     762             :                         {
     763           0 :                             case FILL_SIMPLE:       aPara = 'S'; break;
     764           0 :                             case FILL_LINEAR:       aPara = 'L'; break;
     765           0 :                             case FILL_GROWTH:       aPara = 'G'; break;
     766           0 :                             case FILL_DATE:         aPara = 'D'; break;
     767           0 :                             case FILL_AUTO:         aPara = 'A'; break;
     768           0 :                             default: aPara.Erase(); break;
     769             :                         }
     770           0 :                         rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) );
     771             : 
     772           0 :                         switch( eFillDateCmd )
     773             :                         {
     774           0 :                             case FILL_DAY:          aPara = 'D'; break;
     775           0 :                             case FILL_WEEKDAY:      aPara = 'W'; break;
     776           0 :                             case FILL_MONTH:        aPara = 'M'; break;
     777           0 :                             case FILL_YEAR:         aPara = 'Y'; break;
     778           0 :                             default: aPara.Erase(); break;
     779             :                         }
     780           0 :                         rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) );
     781             : 
     782             :                         sal_uLong nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER,
     783           0 :                                     ScGlobal::eLnge );
     784             : 
     785           0 :                         pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor );
     786           0 :                         rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) );
     787             : 
     788           0 :                         pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor );
     789           0 :                         rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) );
     790             : 
     791           0 :                         pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor );
     792           0 :                         rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) );
     793             : 
     794           0 :                         rReq.Done();
     795             :                     }
     796             :                 }
     797             :             }
     798           0 :             break;
     799             : 
     800             :         case FID_FILL_AUTO:
     801             :             {
     802             :                 SCCOL nStartCol;
     803             :                 SCROW nStartRow;
     804             :                 SCCOL nEndCol;
     805             :                 SCROW nEndRow;
     806             :                 SCTAB nStartTab, nEndTab;
     807             : 
     808           0 :                 GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
     809           0 :                 SCCOL nFillCol = GetViewData()->GetRefEndX();
     810           0 :                 SCROW nFillRow = GetViewData()->GetRefEndY();
     811           0 :                 ScDocument* pDoc = GetViewData()->GetDocument();
     812             : 
     813           0 :                 if( pReqArgs != NULL )
     814             :                 {
     815             :                     const SfxPoolItem* pItem;
     816             : 
     817           0 :                     if( pReqArgs->HasItem( FID_FILL_AUTO, &pItem ) )
     818             :                     {
     819           0 :                         ScAddress aScAddress;
     820           0 :                         String aArg = ((const SfxStringItem*)pItem)->GetValue();
     821             : 
     822           0 :                         if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID )
     823             :                         {
     824           0 :                             nFillRow = aScAddress.Row();
     825           0 :                             nFillCol = aScAddress.Col();
     826           0 :                         }
     827             :                     }
     828             : 
     829             :                     GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
     830           0 :                                               nEndCol,nEndRow,nEndTab );
     831             :                 }
     832             :                 else    // call via mouse
     833             :                 {
     834             :                     //  not in a merged cell
     835             : 
     836           0 :                     if ( nStartCol == nEndCol && nStartRow == nEndRow )
     837             :                     {
     838           0 :                         SCCOL nMergeCol = nStartCol;
     839           0 :                         SCROW nMergeRow = nStartRow;
     840           0 :                         if ( GetViewData()->GetDocument()->ExtendMerge(
     841             :                                 nStartCol, nStartRow, nMergeCol, nMergeRow,
     842           0 :                                 GetViewData()->GetTabNo() ) )
     843             :                         {
     844           0 :                             if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow )
     845           0 :                                 nFillCol = nStartCol;
     846           0 :                             if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol )
     847           0 :                                 nFillRow = nStartRow;
     848             :                         }
     849             :                     }
     850             :                 }
     851             : 
     852           0 :                 if ( nFillCol != nEndCol || nFillRow != nEndRow )
     853             :                 {
     854           0 :                     if ( nFillCol==nEndCol || nFillRow==nEndRow )
     855             :                     {
     856           0 :                         FillDir eDir = FILL_TO_BOTTOM;
     857           0 :                         SCCOLROW nCount = 0;
     858             : 
     859           0 :                         if ( nFillCol==nEndCol )
     860             :                         {
     861           0 :                             if ( nFillRow > nEndRow )
     862             :                             {
     863           0 :                                 eDir = FILL_TO_BOTTOM;
     864           0 :                                 nCount = nFillRow - nEndRow;
     865             :                             }
     866           0 :                             else if ( nFillRow < nStartRow )
     867             :                             {
     868           0 :                                 eDir = FILL_TO_TOP;
     869           0 :                                 nCount = nStartRow - nFillRow;
     870             :                             }
     871             :                         }
     872             :                         else
     873             :                         {
     874           0 :                             if ( nFillCol > nEndCol )
     875             :                             {
     876           0 :                                 eDir = FILL_TO_RIGHT;
     877           0 :                                 nCount = nFillCol - nEndCol;
     878             :                             }
     879           0 :                             else if ( nFillCol < nStartCol )
     880             :                             {
     881           0 :                                 eDir = FILL_TO_LEFT;
     882           0 :                                 nCount = nStartCol - nFillCol;
     883             :                             }
     884             :                         }
     885             : 
     886           0 :                         if ( nCount != 0)
     887             :                         {
     888           0 :                             pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount );
     889             : 
     890           0 :                             if( ! rReq.IsAPI() )
     891             :                             {
     892           0 :                                 String  aAdrStr;
     893           0 :                                 ScAddress aAdr( nFillCol, nFillRow, 0 );
     894           0 :                                 aAdr.Format( aAdrStr, SCR_ABS, pDoc, pDoc->GetAddressConvention() );
     895             : 
     896           0 :                                 rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) );
     897           0 :                                 rReq.Done();
     898             :                             }
     899             :                         }
     900             : 
     901             :                     }
     902             :                     else
     903             :                     {
     904             :                         OSL_FAIL( "Direction not unique for autofill" );
     905             :                     }
     906             :                 }
     907             :             }
     908           0 :             break;
     909             : 
     910             :         //
     911             :         //  disposal (Outlines)
     912             :         //  SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
     913             :         //
     914             : 
     915             :         case SID_OUTLINE_HIDE:
     916           0 :             if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     917           0 :                                     GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     918           0 :                 pTabViewShell->SetDataPilotDetails( false );
     919             :             else
     920           0 :                 pTabViewShell->HideMarkedOutlines();
     921           0 :             rReq.Done();
     922           0 :             break;
     923             : 
     924             :         case SID_OUTLINE_SHOW:
     925             :             {
     926           0 :                 ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     927           0 :                                     GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
     928           0 :                 if ( pDPObj )
     929             :                 {
     930           0 :                     Sequence<sheet::DataPilotFieldFilter> aFilters;
     931             :                     sal_uInt16 nOrientation;
     932           0 :                     if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
     933             :                     {
     934           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     935             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     936             : 
     937             :                         AbstractScDPShowDetailDlg* pDlg = pFact->CreateScDPShowDetailDlg(
     938           0 :                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL, *pDPObj, nOrientation );
     939             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
     940           0 :                         if ( pDlg->Execute() == RET_OK )
     941             :                         {
     942           0 :                             rtl::OUString aNewDimName( pDlg->GetDimensionName() );
     943           0 :                             pTabViewShell->SetDataPilotDetails( true, &aNewDimName );
     944             :                         }
     945             :                     }
     946           0 :                     else if ( !pDPObj->IsServiceData() &&
     947             :                                pDPObj->GetDataFieldPositionData(
     948           0 :                                    ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
     949           0 :                                    aFilters ) )
     950           0 :                         pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
     951             :                     else
     952           0 :                         pTabViewShell->SetDataPilotDetails(true);
     953             :                 }
     954             :                 else
     955           0 :                     pTabViewShell->ShowMarkedOutlines();
     956           0 :                 rReq.Done();
     957             :             }
     958           0 :             break;
     959             : 
     960             :         case SID_OUTLINE_MAKE:
     961             :             {
     962           0 :                 sal_Bool bColumns = false;
     963           0 :                 sal_Bool bOk = sal_True;
     964             : 
     965           0 :                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
     966           0 :                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
     967             :                 {
     968           0 :                     ScDPNumGroupInfo aNumInfo;
     969           0 :                     aNumInfo.mbEnable    = true;
     970           0 :                     aNumInfo.mbAutoStart = true;
     971           0 :                     aNumInfo.mbAutoEnd   = true;
     972           0 :                     sal_Int32 nParts = 0;
     973           0 :                     if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
     974             :                     {
     975           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     976             :                         OSL_ENSURE( pFact, "ScAbstractFactory create fail!" );
     977           0 :                         Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
     978             :                         AbstractScDPDateGroupDlg* pDlg = pFact->CreateScDPDateGroupDlg(
     979             :                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPDATEGROUP,
     980           0 :                             aNumInfo, nParts, aNullDate );
     981             :                         OSL_ENSURE( pDlg, "Dialog create fail!" );
     982           0 :                         if( pDlg->Execute() == RET_OK )
     983             :                         {
     984           0 :                             aNumInfo = pDlg->GetGroupInfo();
     985           0 :                             pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() );
     986             :                         }
     987             :                     }
     988           0 :                     else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) )
     989             :                     {
     990           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     991             :                         OSL_ENSURE( pFact, "ScAbstractFactory create fail!" );
     992             :                         AbstractScDPNumGroupDlg* pDlg = pFact->CreateScDPNumGroupDlg(
     993           0 :                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPNUMGROUP, aNumInfo );
     994             :                         OSL_ENSURE( pDlg, "Dialog create fail!" );
     995           0 :                         if( pDlg->Execute() == RET_OK )
     996           0 :                             pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() );
     997             :                     }
     998             :                     else
     999           0 :                         pTabViewShell->GroupDataPilot();
    1000             : 
    1001           0 :                     bOk = false;
    1002             :                 }
    1003           0 :                 else if( pReqArgs != NULL )
    1004             :                 {
    1005             :                     const SfxPoolItem* pItem;
    1006           0 :                     bOk = false;
    1007             : 
    1008           0 :                     if( pReqArgs->HasItem( SID_OUTLINE_MAKE, &pItem ) )
    1009             :                     {
    1010           0 :                         String aCol = ((const SfxStringItem*)pItem)->GetValue();
    1011           0 :                         aCol.ToUpperAscii();
    1012             : 
    1013           0 :                         switch( aCol.GetChar(0) )
    1014             :                         {
    1015           0 :                             case 'R': bColumns=false; bOk = sal_True;break;
    1016           0 :                             case 'C': bColumns=sal_True; bOk = sal_True;break;
    1017           0 :                         }
    1018             :                     }
    1019             :                 }
    1020             :                 else            // Dialog, when not whole rows/columns are marked
    1021             :                 {
    1022           0 :                     if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
    1023           0 :                         bColumns = sal_True;
    1024           0 :                     else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
    1025           0 :                         bColumns = false;
    1026             :                     else
    1027             :                     {
    1028           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1029             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    1030             : 
    1031           0 :                         AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_MAKE, RID_SCDLG_GRP_MAKE,false);
    1032             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
    1033           0 :                         if ( pDlg->Execute() == RET_OK )
    1034           0 :                             bColumns = pDlg->GetColsChecked();
    1035             :                         else
    1036           0 :                             bOk = false;
    1037           0 :                         delete pDlg;
    1038             :                     }
    1039             :                 }
    1040           0 :                 if (bOk)
    1041             :                 {
    1042           0 :                     pTabViewShell->MakeOutline( bColumns );
    1043             : 
    1044           0 :                     if( ! rReq.IsAPI() )
    1045             :                     {
    1046           0 :                         rtl::OUString aCol = bColumns ? rtl::OUString('C') : rtl::OUString('R');
    1047           0 :                         rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
    1048           0 :                         rReq.Done();
    1049             :                     }
    1050             :                 }
    1051             :             }
    1052           0 :             break;
    1053             : 
    1054             :         case SID_OUTLINE_REMOVE:
    1055             :             {
    1056           0 :                 sal_Bool bColumns = false;
    1057           0 :                 sal_Bool bOk = sal_True;
    1058             : 
    1059           0 :                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
    1060           0 :                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
    1061             :                 {
    1062           0 :                     pTabViewShell->UngroupDataPilot();
    1063           0 :                     bOk = false;
    1064             :                 }
    1065           0 :                 else if( pReqArgs != NULL )
    1066             :                 {
    1067             :                     const SfxPoolItem* pItem;
    1068           0 :                     bOk = false;
    1069             : 
    1070           0 :                     if( pReqArgs->HasItem( SID_OUTLINE_REMOVE, &pItem ) )
    1071             :                     {
    1072           0 :                         String aCol = ((const SfxStringItem*)pItem)->GetValue();
    1073           0 :                         aCol.ToUpperAscii();
    1074             : 
    1075           0 :                         switch( aCol.GetChar(0) )
    1076             :                         {
    1077           0 :                             case 'R': bColumns=false; bOk = sal_True;break;
    1078           0 :                             case 'C': bColumns=sal_True; bOk = sal_True;break;
    1079           0 :                         }
    1080             :                     }
    1081             :                 }
    1082             :                 else            // Dialog only when removal for rows and columns is possible
    1083             :                 {
    1084             :                     sal_Bool bColPoss, bRowPoss;
    1085           0 :                     pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
    1086           0 :                     if ( bColPoss && bRowPoss )
    1087             :                     {
    1088           0 :                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1089             :                         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    1090             : 
    1091           0 :                         AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_KILL, RID_SCDLG_GRP_KILL,true);
    1092             :                         OSL_ENSURE(pDlg, "Dialog create fail!");
    1093           0 :                         if ( pDlg->Execute() == RET_OK )
    1094           0 :                             bColumns = pDlg->GetColsChecked();
    1095             :                         else
    1096           0 :                             bOk = false;
    1097           0 :                         delete pDlg;
    1098             :                     }
    1099           0 :                     else if ( bColPoss )
    1100           0 :                         bColumns = sal_True;
    1101           0 :                     else if ( bRowPoss )
    1102           0 :                         bColumns = false;
    1103             :                     else
    1104           0 :                         bOk = false;
    1105             :                 }
    1106           0 :                 if (bOk)
    1107             :                 {
    1108           0 :                     pTabViewShell->RemoveOutline( bColumns );
    1109             : 
    1110           0 :                     if( ! rReq.IsAPI() )
    1111             :                     {
    1112           0 :                         rtl::OUString aCol = bColumns ? rtl::OUString('C') : rtl::OUString('R');
    1113           0 :                         rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
    1114           0 :                         rReq.Done();
    1115             :                     }
    1116             :                 }
    1117             :             }
    1118           0 :             break;
    1119             : 
    1120             :         //
    1121             :         //  Clipboard
    1122             :         //
    1123             : 
    1124             : 
    1125             :         case SID_COPY:              // for graphs in DrawShell
    1126             :             {
    1127           0 :                 WaitObject aWait( GetViewData()->GetDialogParent() );
    1128           0 :                 pTabViewShell->CopyToClip( NULL, false, false, true );
    1129           0 :                 rReq.Done();
    1130           0 :                 GetViewData()->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) );
    1131           0 :                 pTabViewShell->ShowCursor();
    1132           0 :                 pTabViewShell->UpdateCopySourceOverlay();
    1133             :             }
    1134           0 :             break;
    1135             : 
    1136             :         case SID_CUT:               // for graphs in DrawShell
    1137             :             {
    1138           0 :                 WaitObject aWait( GetViewData()->GetDialogParent() );
    1139           0 :                 pTabViewShell->CutToClip( NULL, true );
    1140           0 :                 rReq.Done();
    1141           0 :                 GetViewData()->SetPasteMode( (ScPasteFlags)(SC_PASTE_MODE | SC_PASTE_BORDER));
    1142           0 :                 pTabViewShell->ShowCursor();
    1143           0 :                 pTabViewShell->UpdateCopySourceOverlay();
    1144             :             }
    1145           0 :             break;
    1146             : 
    1147             :         case SID_PASTE:
    1148             :             {
    1149           0 :                 ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true );
    1150           0 :                 rReq.Done();
    1151             :             }
    1152           0 :             break;
    1153             : 
    1154             :         case SID_CLIPBOARD_FORMAT_ITEMS:
    1155             :             {
    1156           0 :                 WaitObject aWait( GetViewData()->GetDialogParent() );
    1157             : 
    1158           0 :                 sal_uLong nFormat = 0;
    1159             :                 const SfxPoolItem* pItem;
    1160           0 :                 if ( pReqArgs &&
    1161           0 :                      pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
    1162           0 :                      pItem->ISA(SfxUInt32Item) )
    1163             :                 {
    1164           0 :                     nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
    1165             :                 }
    1166             : 
    1167           0 :                 if ( nFormat )
    1168             :                 {
    1169           0 :                     Window* pWin = GetViewData()->GetActiveWin();
    1170           0 :                     sal_Bool bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != NULL );
    1171           0 :                     sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
    1172           0 :                     sal_Bool bOle = ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE );
    1173             : 
    1174           0 :                     if ( bCells && bOle )
    1175           0 :                         pTabViewShell->PasteFromSystem();
    1176           0 :                     else if ( bDraw && bOle )
    1177           0 :                         pTabViewShell->PasteDraw();
    1178             :                     else
    1179           0 :                         pTabViewShell->PasteFromSystem(nFormat);
    1180             :                 }
    1181             :                 //?else
    1182             :                 //? pTabViewShell->PasteFromSystem();
    1183             : 
    1184           0 :                 rReq.Done();
    1185             :             }
    1186           0 :             pTabViewShell->CellContentChanged();
    1187           0 :             break;
    1188             : 
    1189             :         case FID_INS_CELL_CONTENTS:
    1190             :             {
    1191           0 :                 sal_uInt16 nFlags = IDF_NONE;
    1192           0 :                 sal_uInt16 nFunction = PASTE_NOFUNC;
    1193           0 :                 sal_Bool bSkipEmpty = false;
    1194           0 :                 sal_Bool bTranspose = false;
    1195           0 :                 sal_Bool bAsLink    = false;
    1196           0 :                 InsCellCmd eMoveMode = INS_NONE;
    1197             : 
    1198           0 :                 Window* pWin = GetViewData()->GetActiveWin();
    1199           0 :                 ScDocument* pDoc = GetViewData()->GetDocument();
    1200           0 :                 sal_Bool bOtherDoc = !pDoc->IsClipboardSource();
    1201           0 :                 ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
    1202           0 :                 if ( pOwnClip )
    1203             :                 {
    1204             :                     // keep a reference in case the clipboard is changed during dialog or PasteFromClip
    1205           0 :                     uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
    1206           0 :                     if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
    1207             :                     {
    1208             :                         const   SfxPoolItem* pItem;
    1209           0 :                         String  aFlags = rtl::OUString('A');
    1210             : 
    1211           0 :                         if( pReqArgs->HasItem( FID_INS_CELL_CONTENTS, &pItem ) )
    1212           0 :                             aFlags = ((const SfxStringItem*)pItem)->GetValue();
    1213             : 
    1214           0 :                         aFlags.ToUpperAscii();
    1215           0 :                         sal_Bool    bCont = sal_True;
    1216             : 
    1217           0 :                         for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
    1218             :                         {
    1219           0 :                             switch( aFlags.GetChar(i) )
    1220             :                             {
    1221             :                                 case 'A': // all
    1222           0 :                                 nFlags |= IDF_ALL;
    1223           0 :                                 bCont = false; // don't continue!
    1224           0 :                                 break;
    1225           0 :                                 case 'S': nFlags |= IDF_STRING; break;
    1226           0 :                                 case 'V': nFlags |= IDF_VALUE; break;
    1227           0 :                                 case 'D': nFlags |= IDF_DATETIME; break;
    1228           0 :                                 case 'F': nFlags |= IDF_FORMULA; break;
    1229           0 :                                 case 'N': nFlags |= IDF_NOTE; break;
    1230           0 :                                 case 'T': nFlags |= IDF_ATTRIB; break;
    1231             :                             }
    1232             :                         }
    1233             : 
    1234           0 :                         SFX_REQUEST_ARG( rReq, pFuncItem, SfxUInt16Item, FN_PARAM_1, false );
    1235           0 :                         SFX_REQUEST_ARG( rReq, pSkipItem, SfxBoolItem, FN_PARAM_2, false );
    1236           0 :                         SFX_REQUEST_ARG( rReq, pTransposeItem, SfxBoolItem, FN_PARAM_3, false );
    1237           0 :                         SFX_REQUEST_ARG( rReq, pLinkItem, SfxBoolItem, FN_PARAM_4, false );
    1238           0 :                         SFX_REQUEST_ARG( rReq, pMoveItem, SfxInt16Item, FN_PARAM_5, false );
    1239           0 :                         if ( pFuncItem )
    1240           0 :                             nFunction = pFuncItem->GetValue();
    1241           0 :                         if ( pSkipItem )
    1242           0 :                             bSkipEmpty = pSkipItem->GetValue();
    1243           0 :                         if ( pTransposeItem )
    1244           0 :                             bTranspose = pTransposeItem->GetValue();
    1245           0 :                         if ( pLinkItem )
    1246           0 :                             bAsLink = pLinkItem->GetValue();
    1247           0 :                         if ( pMoveItem )
    1248           0 :                             eMoveMode = (InsCellCmd) pMoveItem->GetValue();
    1249             :                     }
    1250             :                     else
    1251             :                     {
    1252           0 :                         ScEditableTester aTester( pTabViewShell );
    1253           0 :                         if (aTester.IsEditable())
    1254             :                         {
    1255           0 :                             ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1256             :                             OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    1257             : 
    1258             :                             AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
    1259           0 :                                                                                                     RID_SCDLG_INSCONT);
    1260             :                             OSL_ENSURE(pDlg, "Dialog create fail!");
    1261           0 :                             pDlg->SetOtherDoc( bOtherDoc );
    1262             :                             // if ChangeTrack MoveMode disable
    1263           0 :                             pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL );
    1264             :                             // cut/move references may disable shift
    1265             :                             // directions if source and destination ranges intersect
    1266           0 :                             if ( !bOtherDoc )
    1267             :                             {
    1268           0 :                                 if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() )
    1269             :                                 {
    1270           0 :                                     ScViewData* pData = GetViewData();
    1271           0 :                                     if ( pData->GetMarkData().GetTableSelect(
    1272           0 :                                             pData->GetTabNo() ) )
    1273             :                                     {
    1274           0 :                                         SCCOL nPosX = pData->GetCurX();
    1275           0 :                                         SCROW nPosY = pData->GetCurY();
    1276             :                                         SCCOL nClipStartX, nClipSizeX;
    1277             :                                         SCROW  nClipStartY, nClipSizeY;
    1278           0 :                                         pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
    1279             :                                         // for CutMode, filtered rows can always be included
    1280           0 :                                         pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, sal_True );
    1281           0 :                                         int nDisableShift = 0;
    1282           0 :                                         if ( nClipStartX <= nPosX + nClipSizeX &&
    1283             :                                                 nPosX <= nClipStartX + nClipSizeX )
    1284           0 :                                             nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
    1285           0 :                                         if ( nClipStartY <= nPosY + nClipSizeY &&
    1286             :                                                 nPosY <= nClipStartY + nClipSizeY )
    1287           0 :                                             nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
    1288           0 :                                         if ( nDisableShift )
    1289           0 :                                             pDlg->SetCellShiftDisabled( nDisableShift );
    1290             :                                     }
    1291             :                                 }
    1292             :                             }
    1293           0 :                             if (pDlg->Execute() == RET_OK)
    1294             :                             {
    1295           0 :                                 nFlags     = pDlg->GetInsContentsCmdBits();
    1296           0 :                                 nFunction  = pDlg->GetFormulaCmdBits();
    1297           0 :                                 bSkipEmpty = pDlg->IsSkipEmptyCells();
    1298           0 :                                 bTranspose = pDlg->IsTranspose();
    1299           0 :                                 bAsLink    = pDlg->IsLink();
    1300           0 :                                 eMoveMode  = pDlg->GetMoveMode();
    1301             :                             }
    1302           0 :                             delete pDlg;
    1303             :                         }
    1304             :                         else
    1305           0 :                             pTabViewShell->ErrorMessage(aTester.GetMessageId());
    1306             :                     }
    1307             : 
    1308           0 :                     if( nFlags != IDF_NONE )
    1309             :                     {
    1310             :                         {
    1311           0 :                             WaitObject aWait( GetViewData()->GetDialogParent() );
    1312           0 :                             if ( bAsLink && bOtherDoc )
    1313           0 :                                 pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK);  // DDE insert
    1314             :                             else
    1315             :                             {
    1316             :                                 pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
    1317             :                                     nFunction, bSkipEmpty, bTranspose, bAsLink,
    1318           0 :                                     eMoveMode, IDF_NONE, sal_True );    // allow warning dialog
    1319           0 :                             }
    1320             :                         }
    1321             : 
    1322           0 :                         if( !pReqArgs )
    1323             :                         {
    1324           0 :                             String  aFlags;
    1325             : 
    1326           0 :                             if( nFlags == IDF_ALL )
    1327             :                             {
    1328           0 :                                 aFlags += 'A';
    1329             :                             }
    1330             :                             else
    1331             :                             {
    1332           0 :                                 if( nFlags & IDF_STRING ) aFlags += 'S';
    1333           0 :                                 if( nFlags & IDF_VALUE ) aFlags += 'V';
    1334           0 :                                 if( nFlags & IDF_DATETIME ) aFlags += 'D';
    1335           0 :                                 if( nFlags & IDF_FORMULA ) aFlags += 'F';
    1336           0 :                                 if( nFlags & IDF_NOTE ) aFlags += 'N';
    1337           0 :                                 if( nFlags & IDF_ATTRIB ) aFlags += 'T';
    1338             :                             }
    1339             : 
    1340           0 :                             rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
    1341           0 :                             rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
    1342           0 :                             rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
    1343           0 :                             rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
    1344           0 :                             rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) );
    1345           0 :                             rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) );
    1346           0 :                             rReq.Done();
    1347             :                         }
    1348           0 :                     }
    1349             :                 }
    1350             :             }
    1351           0 :             pTabViewShell->CellContentChanged();        // => PasteFromXXX ???
    1352           0 :             break;
    1353             :         case SID_PASTE_ONLY_VALUE:
    1354             :         case SID_PASTE_ONLY_TEXT:
    1355             :         case SID_PASTE_ONLY_FORMULA:
    1356             :         {
    1357           0 :             Window* pWin = GetViewData()->GetActiveWin();
    1358           0 :             if ( ScTransferObj::GetOwnClipboard( pWin ) )  // own cell data
    1359             :             {
    1360           0 :                 rReq.SetSlot( FID_INS_CELL_CONTENTS );
    1361           0 :                 rtl::OUString aFlags;
    1362           0 :                 if ( nSlot == SID_PASTE_ONLY_VALUE )
    1363           0 :                     aFlags = "V";
    1364           0 :                 else if ( nSlot == SID_PASTE_ONLY_TEXT )
    1365           0 :                     aFlags = "S";
    1366             :                 else
    1367           0 :                     aFlags = "F";
    1368           0 :                 rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
    1369           0 :                 ExecuteSlot( rReq, GetInterface() );
    1370           0 :                 rReq.SetReturnValue(SfxInt16Item(nSlot, 1));    // 1 = success
    1371           0 :                 pTabViewShell->CellContentChanged();
    1372             :             }
    1373             :             else
    1374           0 :                 rReq.SetReturnValue(SfxInt16Item(nSlot, 0));        // 0 = fail
    1375           0 :             break;
    1376             :         }
    1377             :         case SID_PASTE_SPECIAL:
    1378             :             // differentiate between own cell data and draw objects/external data
    1379             :             // this makes FID_INS_CELL_CONTENTS superfluous
    1380             :             {
    1381           0 :                 Window* pWin = GetViewData()->GetActiveWin();
    1382             : 
    1383             :                 //  Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
    1384           0 :                 const SfxPoolItem* pItem=NULL;
    1385           0 :                 if ( pReqArgs &&
    1386           0 :                      pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
    1387           0 :                      pItem->ISA(SfxUInt32Item) )
    1388             :                 {
    1389           0 :                     sal_uLong nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
    1390           0 :                     sal_Bool bRet=sal_True;
    1391             :                     {
    1392           0 :                         WaitObject aWait( GetViewData()->GetDialogParent() );
    1393           0 :                         sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
    1394           0 :                         if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
    1395           0 :                             pTabViewShell->PasteDraw();
    1396             :                         else
    1397           0 :                             bRet = pTabViewShell->PasteFromSystem(nFormat, sal_True);       // TRUE: no error messages
    1398             :                     }
    1399             : 
    1400           0 :                     if ( bRet )
    1401             :                     {
    1402           0 :                         rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = success, 0 = fail
    1403           0 :                         rReq.Done();
    1404             :                     }
    1405             :                     else
    1406             :                         // if format is not available -> fallback to request without parameters
    1407           0 :                         pItem = NULL;
    1408             :                 }
    1409             : 
    1410           0 :                 if ( !pItem )
    1411             :                 {
    1412           0 :                     if ( ScTransferObj::GetOwnClipboard( pWin ) )  // own cell data
    1413             :                     {
    1414           0 :                         rReq.SetSlot( FID_INS_CELL_CONTENTS );
    1415           0 :                         ExecuteSlot( rReq, GetInterface() );
    1416           0 :                         rReq.SetReturnValue(SfxInt16Item(nSlot, 1));    // 1 = success
    1417             :                     }
    1418             :                     else                                    // draw objects or external data
    1419             :                     {
    1420           0 :                         sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
    1421             : 
    1422           0 :                         SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
    1423           0 :                         GetPossibleClipboardFormats( aFormats );
    1424             : 
    1425           0 :                         sal_uInt16 nFormatCount = aFormats.Count();
    1426           0 :                         if ( nFormatCount )
    1427             :                         {
    1428           0 :                             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    1429           0 :                             SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() );
    1430           0 :                             if ( pDlg )
    1431             :                             {
    1432           0 :                             for (sal_uInt16 i=0; i<nFormatCount; i++)
    1433             :                             {
    1434           0 :                                 sal_uLong nFormatId = aFormats.GetClipbrdFormatId( i );
    1435           0 :                                 String aName = aFormats.GetClipbrdFormatName( i );
    1436             :                                 // special case for paste dialog: '*' is replaced by object type
    1437           0 :                                 if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
    1438           0 :                                     aName.Assign((sal_Unicode)'*');
    1439           0 :                                 pDlg->Insert( nFormatId, aName );
    1440           0 :                             }
    1441             : 
    1442             :                             TransferableDataHelper aDataHelper(
    1443           0 :                                 TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
    1444           0 :                             sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
    1445           0 :                             if (nFormat > 0)
    1446             :                             {
    1447             :                                 {
    1448           0 :                                     WaitObject aWait( GetViewData()->GetDialogParent() );
    1449           0 :                                     if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
    1450           0 :                                         pTabViewShell->PasteDraw();
    1451             :                                     else
    1452           0 :                                         pTabViewShell->PasteFromSystem(nFormat);
    1453             :                                 }
    1454           0 :                                 rReq.SetReturnValue(SfxInt16Item(nSlot, 1));    // 1 = success
    1455           0 :                                 rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) );
    1456           0 :                                 rReq.Done();
    1457             :                             }
    1458             :                             else
    1459             :                             {
    1460           0 :                                 rReq.SetReturnValue(SfxInt16Item(nSlot, 0));    // 0 = fail
    1461           0 :                                 rReq.Ignore();
    1462             :                             }
    1463             : 
    1464           0 :                             delete pDlg;
    1465             :                             }
    1466             :                         }
    1467             :                         else
    1468           0 :                             rReq.SetReturnValue(SfxInt16Item(nSlot, 0));        // 0 = fail
    1469             :                     }
    1470             :                 }
    1471             :             }
    1472           0 :             pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
    1473           0 :             break;
    1474             : 
    1475             :         //
    1476             :         //  other
    1477             :         //
    1478             : 
    1479             :         case FID_INS_ROWBRK:
    1480           0 :             pTabViewShell->InsertPageBreak( false );
    1481           0 :             rReq.Done();
    1482           0 :             break;
    1483             : 
    1484             :         case FID_INS_COLBRK:
    1485           0 :             pTabViewShell->InsertPageBreak( sal_True );
    1486           0 :             rReq.Done();
    1487           0 :             break;
    1488             : 
    1489             :         case FID_DEL_ROWBRK:
    1490           0 :             pTabViewShell->DeletePageBreak( false );
    1491           0 :             rReq.Done();
    1492           0 :             break;
    1493             : 
    1494             :         case FID_DEL_COLBRK:
    1495           0 :             pTabViewShell->DeletePageBreak( sal_True );
    1496           0 :             rReq.Done();
    1497           0 :             break;
    1498             : 
    1499             :         case SID_DETECTIVE_ADD_PRED:
    1500           0 :             pTabViewShell->DetectiveAddPred();
    1501           0 :             rReq.Done();
    1502           0 :             break;
    1503             : 
    1504             :         case SID_DETECTIVE_DEL_PRED:
    1505           0 :             pTabViewShell->DetectiveDelPred();
    1506           0 :             rReq.Done();
    1507           0 :             break;
    1508             : 
    1509             :         case SID_DETECTIVE_ADD_SUCC:
    1510           0 :             pTabViewShell->DetectiveAddSucc();
    1511           0 :             rReq.Done();
    1512           0 :             break;
    1513             : 
    1514             :         case SID_DETECTIVE_DEL_SUCC:
    1515           0 :             pTabViewShell->DetectiveDelSucc();
    1516           0 :             rReq.Done();
    1517           0 :             break;
    1518             : 
    1519             :         case SID_DETECTIVE_ADD_ERR:
    1520           0 :             pTabViewShell->DetectiveAddError();
    1521           0 :             rReq.Done();
    1522           0 :             break;
    1523             : 
    1524             :         case SID_DETECTIVE_INVALID:
    1525           0 :             pTabViewShell->DetectiveMarkInvalid();
    1526           0 :             rReq.Done();
    1527           0 :             break;
    1528             : 
    1529             :         case SID_DETECTIVE_REFRESH:
    1530           0 :             pTabViewShell->DetectiveRefresh();
    1531           0 :             rReq.Done();
    1532           0 :             break;
    1533             : 
    1534             :         case SID_DETECTIVE_MARK_PRED:
    1535           0 :             pTabViewShell->DetectiveMarkPred();
    1536           0 :             break;
    1537             :         case SID_DETECTIVE_MARK_SUCC:
    1538           0 :             pTabViewShell->DetectiveMarkSucc();
    1539           0 :             break;
    1540             :         case SID_INSERT_CURRENT_DATE:
    1541             :             pTabViewShell->InsertCurrentTime(
    1542           0 :                 NUMBERFORMAT_DATE, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE));
    1543           0 :             break;
    1544             :         case SID_INSERT_CURRENT_TIME:
    1545             :             pTabViewShell->InsertCurrentTime(
    1546           0 :                 NUMBERFORMAT_TIME, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME));
    1547           0 :             break;
    1548             : 
    1549             :         case SID_SPELL_DIALOG:
    1550             :             {
    1551           0 :                 SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
    1552           0 :                 if( rReq.GetArgs() )
    1553             :                     pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
    1554           0 :                         static_cast< const SfxBoolItem& >( rReq.GetArgs()->
    1555           0 :                             Get( SID_SPELL_DIALOG ) ).GetValue() );
    1556             :                 else
    1557           0 :                     pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
    1558             : 
    1559           0 :                 pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
    1560           0 :                 rReq.Ignore();
    1561             :             }
    1562           0 :             break;
    1563             : 
    1564             :         case SID_HANGUL_HANJA_CONVERSION:
    1565           0 :             pTabViewShell->DoHangulHanjaConversion();
    1566           0 :             break;
    1567             : 
    1568             :         case SID_CHINESE_CONVERSION:
    1569             :             {
    1570             :                 //open ChineseTranslationDialog
    1571             :                 Reference< XComponentContext > xContext(
    1572           0 :                     ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
    1573           0 :                 if(xContext.is())
    1574             :                 {
    1575           0 :                     Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
    1576           0 :                     if(xMCF.is())
    1577             :                     {
    1578             :                         Reference< ui::dialogs::XExecutableDialog > xDialog(
    1579           0 :                                 xMCF->createInstanceWithContext(
    1580             :                                     rtl::OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
    1581           0 :                                     , xContext), UNO_QUERY);
    1582           0 :                         Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
    1583           0 :                         if( xInit.is() )
    1584             :                         {
    1585             :                             //  initialize dialog
    1586           0 :                             Reference< awt::XWindow > xDialogParentWindow(0);
    1587           0 :                             Sequence<Any> aSeq(1);
    1588           0 :                             Any* pArray = aSeq.getArray();
    1589           0 :                             PropertyValue aParam;
    1590           0 :                             aParam.Name = rtl::OUString("ParentWindow");
    1591           0 :                             aParam.Value <<= makeAny(xDialogParentWindow);
    1592           0 :                             pArray[0] <<= makeAny(aParam);
    1593           0 :                             xInit->initialize( aSeq );
    1594             : 
    1595             :                             //execute dialog
    1596           0 :                             sal_Int16 nDialogRet = xDialog->execute();
    1597           0 :                             if( RET_OK == nDialogRet )
    1598             :                             {
    1599             :                                 //get some parameters from the dialog
    1600           0 :                                 sal_Bool bToSimplified = sal_True;
    1601           0 :                                 sal_Bool bUseVariants = sal_True;
    1602           0 :                                 sal_Bool bCommonTerms = sal_True;
    1603           0 :                                 Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
    1604           0 :                                 if( xProp.is() )
    1605             :                                 {
    1606             :                                     try
    1607             :                                     {
    1608           0 :                                         xProp->getPropertyValue( rtl::OUString("IsDirectionToSimplified") ) >>= bToSimplified;
    1609           0 :                                         xProp->getPropertyValue( rtl::OUString("IsUseCharacterVariants") ) >>= bUseVariants;
    1610           0 :                                         xProp->getPropertyValue( rtl::OUString("IsTranslateCommonTerms") ) >>= bCommonTerms;
    1611             :                                     }
    1612           0 :                                     catch( Exception& )
    1613             :                                     {
    1614             :                                     }
    1615             :                                 }
    1616             : 
    1617             :                                 //execute translation
    1618           0 :                                 LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
    1619           0 :                                 LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
    1620           0 :                                 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
    1621           0 :                                 if( !bCommonTerms )
    1622           0 :                                     nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
    1623             : 
    1624           0 :                                 Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont(
    1625             :                                                     DEFAULTFONT_CJK_SPREADSHEET,
    1626           0 :                                                     eTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
    1627             :                                 ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
    1628           0 :                                     eSourceLang, eTargetLang, aTargetFont, nOptions, false );
    1629           0 :                                 pTabViewShell->DoSheetConversion( aConvParam );
    1630           0 :                             }
    1631             :                         }
    1632           0 :                         Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
    1633           0 :                         if( xComponent.is() )
    1634           0 :                             xComponent->dispose();
    1635           0 :                     }
    1636           0 :                 }
    1637             :             }
    1638           0 :             break;
    1639             : 
    1640             :         case SID_THESAURUS:
    1641           0 :             pTabViewShell->DoThesaurus();
    1642           0 :             break;
    1643             : 
    1644             :         case SID_TOGGLE_REL:
    1645           0 :             pTabViewShell->DoRefConversion();
    1646           0 :             break;
    1647             : 
    1648             :         case SID_DEC_INDENT:
    1649           0 :             pTabViewShell->ChangeIndent( false );
    1650           0 :             break;
    1651             :         case SID_INC_INDENT:
    1652           0 :             pTabViewShell->ChangeIndent( sal_True );
    1653           0 :             break;
    1654             : 
    1655             :         case FID_USE_NAME:
    1656             :             {
    1657           0 :                 sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags();
    1658             : 
    1659           0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1660             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    1661             : 
    1662           0 :                 AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE );
    1663             :                 OSL_ENSURE(pDlg, "Dialog create fail!");
    1664             : 
    1665           0 :                 if( pDlg->Execute() )
    1666             :                 {
    1667           0 :                     nFlags = pDlg->GetFlags();
    1668           0 :                     pTabViewShell->CreateNames(nFlags);
    1669           0 :                     rReq.Done();
    1670             :                 }
    1671           0 :                 delete pDlg;
    1672             :             }
    1673           0 :             break;
    1674             : 
    1675             :         case SID_CONSOLIDATE:
    1676             :             {
    1677             :                 const SfxPoolItem* pItem;
    1678           0 :                 if ( pReqArgs && SFX_ITEM_SET ==
    1679           0 :                         pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, sal_True, &pItem ) )
    1680             :                 {
    1681             :                     const ScConsolidateParam& rParam =
    1682           0 :                             ((const ScConsolidateItem*)pItem)->GetData();
    1683             : 
    1684           0 :                     pTabViewShell->Consolidate( rParam );
    1685           0 :                     GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
    1686             : 
    1687           0 :                     rReq.Done();
    1688             :                 }
    1689             : #ifndef DISABLE_SCRIPTING
    1690           0 :                 else if (rReq.IsAPI())
    1691           0 :                     SbxBase::SetError(SbxERR_BAD_PARAMETER);
    1692             : #endif
    1693             :             }
    1694           0 :             break;
    1695             : 
    1696             :         case SID_INS_FUNCTION:
    1697             :             {
    1698           0 :                 const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK );
    1699             : 
    1700           0 :                 if ( pOkItem->GetValue() )      // OK
    1701             :                 {
    1702           0 :                     String               aFormula;
    1703           0 :                     const SfxStringItem* pSItem      = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING );
    1704           0 :                     const SfxBoolItem*   pMatrixItem = (const SfxBoolItem*)  &pReqArgs->Get( SID_DLG_MATRIX );
    1705             : 
    1706           0 :                     aFormula += pSItem->GetValue();
    1707           0 :                     pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
    1708             :                 }
    1709             :                 else                            // CANCEL
    1710             :                 {
    1711           0 :                     pScMod->ActivateInputWindow( NULL );
    1712             :                 }
    1713           0 :                 rReq.Ignore();      // only SID_ENTER_STRING is recorded
    1714             :             }
    1715           0 :             break;
    1716             : 
    1717             :         case FID_DEFINE_NAME:
    1718           0 :             if ( pReqArgs )
    1719             :             {
    1720             :                 const SfxPoolItem* pItem;
    1721           0 :                 String  aName, aSymbol, aAttrib;
    1722             : 
    1723           0 :                 if( pReqArgs->HasItem( FID_DEFINE_NAME, &pItem ) )
    1724           0 :                     aName = ((const SfxStringItem*)pItem)->GetValue();
    1725             : 
    1726           0 :                 if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
    1727           0 :                     aSymbol = ((const SfxStringItem*)pItem)->GetValue();
    1728             : 
    1729           0 :                 if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
    1730           0 :                     aAttrib = ((const SfxStringItem*)pItem)->GetValue();
    1731             : 
    1732           0 :                 if ( aName.Len() && aSymbol.Len() )
    1733             :                 {
    1734           0 :                     if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
    1735           0 :                         rReq.Done();
    1736             : #ifndef DISABLE_SCRIPTING
    1737             :                     else
    1738           0 :                         SbxBase::SetError( SbxERR_BAD_PARAMETER );  // Basic-error
    1739             : #endif
    1740           0 :                 }
    1741             :             }
    1742             :             else
    1743             :             {
    1744           0 :                 sal_uInt16          nId  = ScNameDlgWrapper::GetChildWindowId();
    1745           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
    1746           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
    1747             : 
    1748           0 :                 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
    1749             :             }
    1750           0 :             break;
    1751             :         case FID_ADD_NAME:
    1752             :             {
    1753           0 :                 sal_uInt16          nId  = ScNameDefDlgWrapper::GetChildWindowId();
    1754           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
    1755           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
    1756             : 
    1757           0 :                 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
    1758             :             }
    1759           0 :             break;
    1760             : 
    1761             :         case SID_OPENDLG_CONDFRMT:
    1762             :         case SID_OPENDLG_COLORSCALE:
    1763             :         case SID_OPENDLG_DATABAR:
    1764             :             {
    1765             : 
    1766           0 :                 ScRangeList aRangeList;
    1767           0 :                 ScViewData* pData = GetViewData();
    1768           0 :                 pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
    1769             : 
    1770           0 :                 ScDocument* pDoc = GetViewData()->GetDocument();
    1771           0 :                 if(pDoc->IsTabProtected(pData->GetTabNo()))
    1772             :                 {
    1773             :                     //ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
    1774             :                     break;
    1775             :                 }
    1776             : 
    1777           0 :                 ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
    1778           0 :                 if(aRangeList.empty())
    1779             :                 {
    1780           0 :                     ScRange* pRange = new ScRange(aPos);
    1781           0 :                     aRangeList.push_back(pRange);
    1782             :                 }
    1783             : 
    1784           0 :                 sal_Int32 nKey = 0;
    1785           0 :                 const ScPatternAttr* pPattern = pDoc->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
    1786           0 :                 const std::vector<sal_uInt32>& rCondFormats = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
    1787           0 :                 bool bContainsCondFormat = !rCondFormats.empty();
    1788           0 :                 boost::scoped_ptr<ScCondFormatDlg> pCondFormatDlg;
    1789           0 :                 if(bContainsCondFormat)
    1790             :                 {
    1791           0 :                     ScConditionalFormatList* pList = pDoc->GetCondFormList(aPos.Tab());
    1792           0 :                     for (std::vector<sal_uInt32>::const_iterator itr = rCondFormats.begin(), itrEnd = rCondFormats.end();
    1793             :                                             itr != itrEnd; ++itr)
    1794             :                     {
    1795             :                         // check if at least one existing conditional format has the same range
    1796           0 :                         const ScConditionalFormat* pCondFormat = pList->GetFormat(*itr);
    1797           0 :                         const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
    1798           0 :                         if(rCondFormatRange == aRangeList)
    1799             :                         {
    1800             :                             // found a matching range, edit this conditional format
    1801           0 :                             nKey = pCondFormat->GetKey();
    1802           0 :                             pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) );
    1803             :                         }
    1804             :                     }
    1805             : 
    1806             :                     // if not found a conditional format ask whether we should edit one of the existing
    1807             :                     // or should create a new overlapping conditional format
    1808             : 
    1809           0 :                     if(!pCondFormatDlg)
    1810             :                     {
    1811             :                         QueryBox aBox( pTabViewShell->GetDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
    1812           0 :                                ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS) );
    1813           0 :                         bool bEditExisting = aBox.Execute() == RET_YES;
    1814           0 :                         if(bEditExisting)
    1815             :                         {
    1816             :                             // differentiate between ranges where one conditional format is defined
    1817             :                             // and several formats are defined
    1818             :                             // if we have only one => open the cond format dlg to edit it
    1819             :                             // otherwise open the manage cond format dlg
    1820           0 :                             if(rCondFormats.size() == 1)
    1821             :                             {
    1822           0 :                                 const ScConditionalFormat* pCondFormat = pList->GetFormat(rCondFormats[0]);
    1823             :                                 assert(pCondFormat);
    1824           0 :                                 const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
    1825           0 :                                 pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE ) );
    1826             :                             }
    1827             :                             else
    1828             :                             {
    1829           0 :                                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1830           0 :                                 boost::scoped_ptr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER));
    1831           0 :                                 if(pDlg->Execute() == RET_OK && pDlg->CondFormatsChanged())
    1832             :                                 {
    1833           0 :                                     ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
    1834           0 :                                     pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
    1835             :                                 }
    1836             :                                 // we need step out here because we don't want to open the normal dialog
    1837           0 :                                 break;
    1838             :                             }
    1839             :                         }
    1840             :                         else
    1841             :                         {
    1842             :                             // define an overlapping conditional format
    1843             :                             // does not need to be handled here
    1844           0 :                         }
    1845             : 
    1846             :                     }
    1847             :                 }
    1848             : 
    1849           0 :                 if(!pCondFormatDlg)
    1850             :                 {
    1851           0 :                     condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE;
    1852           0 :                     switch(nSlot)
    1853             :                     {
    1854             :                         case SID_OPENDLG_CONDFRMT:
    1855           0 :                             eType = condformat::dialog::CONDITION;
    1856           0 :                             break;
    1857             :                         case SID_OPENDLG_COLORSCALE:
    1858           0 :                             eType = condformat::dialog::COLORSCALE;
    1859           0 :                             break;
    1860             :                         case SID_OPENDLG_DATABAR:
    1861           0 :                             eType = condformat::dialog::DATABAR;
    1862           0 :                             break;
    1863             :                         default:
    1864           0 :                             break;
    1865             :                     }
    1866           0 :                     pCondFormatDlg.reset( new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), eType ) );
    1867             :                 }
    1868             : 
    1869           0 :                 sal_uInt16 nId = 1;
    1870           0 :                 pScMod->SetRefDialog( nId, true );
    1871             : 
    1872           0 :                 if( pCondFormatDlg->Execute() == RET_OK )
    1873             :                 {
    1874           0 :                     ScConditionalFormat* pFormat = pCondFormatDlg->GetConditionalFormat();
    1875           0 :                     pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, aPos.Tab(), pFormat->GetRange());
    1876             :                 }
    1877             : 
    1878           0 :                 pScMod->SetRefDialog( nId, false );
    1879             : 
    1880             : 
    1881             :             }
    1882           0 :             break;
    1883             : 
    1884             :         case SID_DEFINE_COLROWNAMERANGES:
    1885             :             {
    1886             : 
    1887           0 :                 sal_uInt16          nId  = ScColRowNameRangesDlgWrapper::GetChildWindowId();
    1888           0 :                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
    1889           0 :                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
    1890             : 
    1891           0 :                 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
    1892             : 
    1893             :             }
    1894           0 :             break;
    1895             : 
    1896             :         case SID_UPDATECHART:
    1897             :             {
    1898           0 :                 sal_Bool bAll = false;
    1899             : 
    1900           0 :                 if( pReqArgs )
    1901             :                 {
    1902             :                     const SfxPoolItem* pItem;
    1903             : 
    1904           0 :                     if( pReqArgs->HasItem( SID_UPDATECHART, &pItem ) )
    1905           0 :                         bAll = ((const SfxBoolItem*)pItem)->GetValue();
    1906             :                 }
    1907             : 
    1908           0 :                 pTabViewShell->UpdateCharts( bAll );
    1909             : 
    1910           0 :                 if( ! rReq.IsAPI() )
    1911             :                 {
    1912           0 :                     rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
    1913           0 :                     rReq.Done();
    1914             :                 }
    1915             :             }
    1916           0 :             break;
    1917             : 
    1918             : 
    1919             :         case SID_TABOP:
    1920           0 :             if (pReqArgs)
    1921             :             {
    1922             :                 const ScTabOpItem& rItem =
    1923             :                         (const ScTabOpItem&)
    1924           0 :                             pReqArgs->Get( SID_TABOP );
    1925             : 
    1926           0 :                 pTabViewShell->TabOp( rItem.GetData() );
    1927             : 
    1928           0 :                 rReq.Done( *pReqArgs );
    1929             :             }
    1930           0 :             break;
    1931             : 
    1932             :         case SID_SOLVE:
    1933           0 :             if (pReqArgs)
    1934             :             {
    1935             :                 const ScSolveItem& rItem =
    1936             :                         (const ScSolveItem&)
    1937           0 :                             pReqArgs->Get( SCITEM_SOLVEDATA );
    1938             : 
    1939           0 :                 pTabViewShell->Solve( rItem.GetData() );
    1940             : 
    1941           0 :                 rReq.Done( *pReqArgs );
    1942             :             }
    1943           0 :             break;
    1944             : 
    1945             :         case FID_INSERT_NAME:
    1946             :             {
    1947           0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    1948             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    1949             : 
    1950           0 :                 AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), GetViewData()->GetDocShell(), RID_SCDLG_NAMES_PASTE );
    1951             :                 OSL_ENSURE(pDlg, "Dialog create fail!");
    1952           0 :                 switch( pDlg->Execute() )
    1953             :                 {
    1954             :                     case BTN_PASTE_LIST:
    1955           0 :                         pTabViewShell->InsertNameList();
    1956           0 :                         break;
    1957             :                     case BTN_PASTE_NAME:
    1958             :                         {
    1959           0 :                             ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
    1960           0 :                             if (pHdl)
    1961             :                             {
    1962             :                                 //  "=" in KeyEvent, switches to input-mode
    1963           0 :                                 pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
    1964             : 
    1965           0 :                                 std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames();
    1966           0 :                                 if (!aNames.empty())
    1967             :                                 {
    1968           0 :                                     rtl::OUStringBuffer aBuffer;
    1969           0 :                                     for (std::vector<rtl::OUString>::const_iterator itr = aNames.begin();
    1970           0 :                                             itr != aNames.end(); ++itr)
    1971             :                                     {
    1972           0 :                                         aBuffer.append(*itr).append(' ');
    1973             :                                     }
    1974           0 :                                     pHdl->InsertFunction( aBuffer.makeStringAndClear(), false );       // without "()"
    1975           0 :                                 }
    1976             :                             }
    1977             :                         }
    1978           0 :                         break;
    1979             :                 }
    1980           0 :                 delete pDlg;
    1981             :             }
    1982           0 :             break;
    1983             : 
    1984             :         case SID_RANGE_NOTETEXT:
    1985           0 :             if (pReqArgs)
    1986             :             {
    1987           0 :                 const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT );
    1988             : 
    1989             :                 //  always cursor position
    1990           0 :                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    1991           0 :                 pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
    1992           0 :                 rReq.Done();
    1993             :             }
    1994           0 :             break;
    1995             : 
    1996             :         case SID_INSERT_POSTIT:
    1997           0 :             if ( pReqArgs )
    1998             :             {
    1999           0 :                 const SvxPostItAuthorItem&  rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR );
    2000           0 :                 const SvxPostItDateItem&    rDateItem   = (const SvxPostItDateItem&)  pReqArgs->Get( SID_ATTR_POSTIT_DATE );
    2001           0 :                 const SvxPostItTextItem&    rTextItem   = (const SvxPostItTextItem&)  pReqArgs->Get( SID_ATTR_POSTIT_TEXT );
    2002             : 
    2003           0 :                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    2004           0 :                 pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() );
    2005           0 :                 rReq.Done();
    2006             :             }
    2007             :             else
    2008             :             {
    2009           0 :                 pTabViewShell->EditNote();                  // note object to edit
    2010             :             }
    2011           0 :             break;
    2012             : 
    2013             :         case FID_NOTE_VISIBLE:
    2014             :             {
    2015           0 :                 ScDocument* pDoc = GetViewData()->GetDocument();
    2016           0 :                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    2017           0 :                 if( ScPostIt* pNote = pDoc->GetNotes( aPos.Tab() )->findByAddress(aPos) )
    2018             :                 {
    2019             :                     bool bShow;
    2020             :                     const SfxPoolItem* pItem;
    2021           0 :                     if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, sal_True, &pItem ) == SFX_ITEM_SET) )
    2022           0 :                         bShow = ((const SfxBoolItem*) pItem)->GetValue();
    2023             :                     else
    2024           0 :                         bShow = !pNote->IsCaptionShown();
    2025             : 
    2026           0 :                     pTabViewShell->ShowNote( bShow );
    2027             : 
    2028           0 :                     if (!pReqArgs)
    2029           0 :                         rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
    2030             : 
    2031           0 :                     rReq.Done();
    2032           0 :                     rBindings.Invalidate( FID_NOTE_VISIBLE );
    2033             :                 }
    2034             :                 else
    2035           0 :                     rReq.Ignore();
    2036             :             }
    2037           0 :             break;
    2038             : 
    2039             :         case SID_DELETE_NOTE:
    2040           0 :             pTabViewShell->DeleteContents( IDF_NOTE );      // delete all notes in selection
    2041           0 :             rReq.Done();
    2042           0 :             break;
    2043             : 
    2044             :         case SID_CHARMAP:
    2045           0 :             if( pReqArgs != NULL )
    2046             :             {
    2047           0 :                 String aChars, aFontName;
    2048           0 :                 const SfxItemSet *pArgs = rReq.GetArgs();
    2049           0 :                 const SfxPoolItem* pItem = 0;
    2050           0 :                 if ( pArgs )
    2051           0 :                     pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
    2052           0 :                 if ( pItem )
    2053             :                 {
    2054           0 :                     const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem );
    2055           0 :                     if ( pStringItem )
    2056           0 :                         aChars = pStringItem->GetValue();
    2057           0 :                     const SfxPoolItem* pFtItem = NULL;
    2058           0 :                     pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
    2059           0 :                     const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
    2060           0 :                     if ( pFontItem )
    2061           0 :                         aFontName = pFontItem->GetValue();
    2062             :                 }
    2063             : 
    2064           0 :                 if ( aChars.Len() )
    2065             :                 {
    2066           0 :                     Font aFont;
    2067             :                     pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
    2068           0 :                                                                 pTabViewShell->GetSelectionScriptType() );
    2069           0 :                     if ( aFontName.Len() )
    2070           0 :                         aFont = Font( aFontName, Size(1,1) );
    2071           0 :                     pTabViewShell->InsertSpecialChar( aChars, aFont );
    2072           0 :                     if( ! rReq.IsAPI() )
    2073           0 :                         rReq.Done();
    2074           0 :                 }
    2075             :             }
    2076             :             else
    2077             :             {
    2078           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    2079             : 
    2080             :                 // font color doesn't matter here
    2081           0 :                 Font             aCurFont;
    2082             :                 pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
    2083           0 :                                                                 pTabViewShell->GetSelectionScriptType() );
    2084             : 
    2085           0 :                 SfxAllItemSet aSet( GetPool() );
    2086           0 :                 aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
    2087           0 :                 aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
    2088             : 
    2089             :                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
    2090           0 :                     pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
    2091             : 
    2092           0 :                 if ( pDlg->Execute() == RET_OK )
    2093             :                 {
    2094           0 :                     SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, false );
    2095           0 :                     SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
    2096             : 
    2097           0 :                     if ( pItem && pFontItem )
    2098             :                     {
    2099           0 :                         Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) );
    2100           0 :                         aNewFont.SetCharSet( pFontItem->GetCharSet() );
    2101           0 :                         aNewFont.SetPitch( pFontItem->GetPitch() );
    2102           0 :                         pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont );
    2103           0 :                         rReq.AppendItem( *pFontItem );
    2104           0 :                         rReq.AppendItem( *pItem );
    2105           0 :                         rReq.Done();
    2106             :                     }
    2107             :                 }
    2108           0 :                 delete pDlg;
    2109             :             }
    2110           0 :             break;
    2111             : 
    2112             :         case SID_SELECT_SCENARIO:
    2113             :             {
    2114             :                 // Testing
    2115             : 
    2116           0 :                 if ( pReqArgs )
    2117             :                 {
    2118             :                     const SfxStringItem* pItem =
    2119           0 :                         (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO );
    2120             : 
    2121           0 :                     if( pItem )
    2122             :                     {
    2123           0 :                         pTabViewShell->UseScenario( pItem->GetValue() );
    2124             :                         //! why should the return value be valid?!?!
    2125           0 :                         rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
    2126           0 :                         rReq.Done();
    2127             :                     }
    2128             :                     else
    2129             :                     {
    2130             :                         OSL_FAIL("NULL");
    2131             :                     }
    2132             :                 }
    2133             :             }
    2134           0 :             break;
    2135             : 
    2136             :         case SID_HYPERLINK_SETLINK:
    2137           0 :             if( pReqArgs )
    2138             :             {
    2139             :                 const SfxPoolItem* pItem;
    2140           0 :                 if( pReqArgs->HasItem( SID_HYPERLINK_SETLINK, &pItem ) )
    2141             :                 {
    2142           0 :                     const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
    2143           0 :                     const String& rName   = pHyper->GetName();
    2144           0 :                     const String& rURL    = pHyper->GetURL();
    2145           0 :                     const String& rTarget = pHyper->GetTargetFrame();
    2146           0 :                     sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode();
    2147             : 
    2148           0 :                     pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
    2149           0 :                     rReq.Done();
    2150             :                 }
    2151             :                 else
    2152           0 :                     rReq.Ignore();
    2153             :             }
    2154           0 :             break;
    2155             : 
    2156             :         case SID_OPENDLG_CONDFRMT_MANAGER:
    2157             :             {
    2158           0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2159             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2160             : 
    2161           0 :                 ScViewData* pData = GetViewData();
    2162           0 :                 ScDocument* pDoc = pData->GetDocument();
    2163             : 
    2164           0 :                 if(pDoc->IsTabProtected(pData->GetTabNo()))
    2165             :                 {
    2166           0 :                     pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
    2167             :                     break;
    2168             :                 }
    2169             : 
    2170           0 :                 ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
    2171             : 
    2172           0 :                 ScConditionalFormatList* pList = pDoc->GetCondFormList( aPos.Tab() );
    2173           0 :                 boost::scoped_ptr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER));
    2174           0 :                 if(pDlg->Execute() == RET_OK && pDlg->CondFormatsChanged())
    2175             :                 {
    2176           0 :                     ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
    2177           0 :                     pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
    2178           0 :                 }
    2179             :             }
    2180           0 :             break;
    2181             : 
    2182             :         case SID_EXTERNAL_SOURCE:
    2183             :             {
    2184           0 :                 String aFile;
    2185           0 :                 String aFilter;
    2186           0 :                 String aOptions;
    2187           0 :                 String aSource;
    2188           0 :                 sal_uLong nRefresh=0;
    2189             : 
    2190           0 :                 SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, false );
    2191           0 :                 SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, false );
    2192           0 :                 if ( pFile && pSource )
    2193             :                 {
    2194           0 :                     aFile = pFile->GetValue();
    2195           0 :                     aSource = pSource->GetValue();
    2196           0 :                     SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, false );
    2197           0 :                     if ( pFilter )
    2198           0 :                         aFilter = pFilter->GetValue();
    2199           0 :                     SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, false );
    2200           0 :                     if ( pOptions )
    2201           0 :                         aOptions = pOptions->GetValue();
    2202           0 :                     SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, false );
    2203           0 :                     if ( pRefresh )
    2204           0 :                         nRefresh = pRefresh->GetValue();
    2205             :                 }
    2206             :                 else
    2207             :                 {
    2208           0 :                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2209             :                     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2210             : 
    2211           0 :                     delete pImpl->m_pLinkedDlg;
    2212             :                     pImpl->m_pLinkedDlg =
    2213             :                         pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(),
    2214           0 :                                                       RID_SCDLG_LINKAREA);
    2215             :                     OSL_ENSURE(pImpl->m_pLinkedDlg, "Dialog create fail!");
    2216           0 :                     delete pImpl->m_pRequest;
    2217           0 :                     pImpl->m_pRequest = new SfxRequest( rReq );
    2218           0 :                     pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
    2219           0 :                     return;
    2220             :                 }
    2221             : 
    2222           0 :                 ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
    2223             :             }
    2224           0 :             break;
    2225             : 
    2226             :         //
    2227             :         //
    2228             :         //
    2229             : 
    2230             :         default:
    2231             :             OSL_FAIL("incorrect slot in ExecuteEdit");
    2232           0 :             break;
    2233             :     }
    2234             : }
    2235             : 
    2236           0 : void ScCellShell::ExecuteTrans( SfxRequest& rReq )
    2237             : {
    2238           0 :     sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
    2239           0 :     if ( nType )
    2240             :     {
    2241           0 :         GetViewData()->GetView()->TransliterateText( nType );
    2242           0 :         rReq.Done();
    2243             :     }
    2244           0 : }
    2245             : 
    2246           0 : void ScCellShell::ExecuteRotateTrans( SfxRequest& rReq )
    2247             : {
    2248           0 :     if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
    2249           0 :         GetViewData()->GetView()->TransliterateText( m_aRotateCase.getNextMode() );
    2250           0 : }
    2251             : 
    2252           0 : void ScCellShell::ExecuteExternalSource(
    2253             :     const String& _rFile, const String& _rFilter, const String& _rOptions,
    2254             :     const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
    2255             : {
    2256           0 :     if ( _rFile.Len() && _rSource.Len() )         // filter may be empty
    2257             :     {
    2258           0 :         ScRange aLinkRange;
    2259           0 :         sal_Bool bMove = false;
    2260             : 
    2261           0 :         ScViewData* pData = GetViewData();
    2262           0 :         ScMarkData& rMark = pData->GetMarkData();
    2263           0 :         rMark.MarkToSimple();
    2264           0 :         if ( rMark.IsMarked() )
    2265             :         {
    2266           0 :             rMark.GetMarkArea( aLinkRange );
    2267           0 :             bMove = sal_True;                       // insert/delete cells to fit range
    2268             :         }
    2269             :         else
    2270           0 :             aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
    2271             : 
    2272           0 :         pData->GetDocFunc().InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
    2273           0 :                                             aLinkRange, _nRefresh, bMove, false );
    2274           0 :         _rRequest.Done();
    2275             :     }
    2276             :     else
    2277           0 :         _rRequest.Ignore();
    2278           0 : }
    2279             : 
    2280             : namespace {
    2281             : 
    2282           0 : bool isDPSourceValid(const ScDPObject& rDPObj)
    2283             : {
    2284           0 :     if (rDPObj.IsImportData())
    2285             :     {
    2286             :         // If the data type is database, check if the database is still valid.
    2287           0 :         const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
    2288           0 :         if (!pDesc)
    2289           0 :             return false;
    2290             : 
    2291           0 :         const ScDPSaveData* pSaveData = rDPObj.GetSaveData();
    2292           0 :         const ScDPDimensionSaveData* pDimData = NULL;
    2293           0 :         if (pSaveData)
    2294           0 :             pDimData = pSaveData->GetExistingDimensionData();
    2295             : 
    2296           0 :         const ScDPCache* pCache = pDesc->CreateCache(pDimData);
    2297           0 :         if (!pCache)
    2298             :             // cashe creation failed, probably due to invalid connection.
    2299           0 :             return false;
    2300             :     }
    2301           0 :     return true;
    2302             : }
    2303             : 
    2304             : }
    2305             : 
    2306           0 : void ScCellShell::ExecuteDataPilotDialog()
    2307             : {
    2308           0 :     ScModule* pScMod = SC_MOD();
    2309           0 :     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
    2310           0 :     ScViewData* pData = GetViewData();
    2311           0 :     ScDocument* pDoc = pData->GetDocument();
    2312             : 
    2313           0 :     ::boost::scoped_ptr<ScDPObject> pNewDPObject(NULL);
    2314             : 
    2315             :     // ScPivot is no longer used...
    2316             :     ScDPObject* pDPObj = pDoc->GetDPAtCursor(
    2317           0 :                                 pData->GetCurX(), pData->GetCurY(),
    2318           0 :                                 pData->GetTabNo() );
    2319           0 :     if ( pDPObj )   // on an existing table?
    2320             :     {
    2321           0 :         if (isDPSourceValid(*pDPObj))
    2322           0 :             pNewDPObject.reset(new ScDPObject(*pDPObj));
    2323             :     }
    2324             :     else            // create new table
    2325             :     {
    2326           0 :         sal_uLong nSrcErrorId = 0;
    2327             : 
    2328             :         //  select database range or data
    2329           0 :         pTabViewShell->GetDBData( true, SC_DB_OLD );
    2330           0 :         ScMarkData& rMark = GetViewData()->GetMarkData();
    2331           0 :         if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
    2332           0 :             pTabViewShell->MarkDataArea( false );
    2333             : 
    2334             :         //  output to cursor position for non-sheet data
    2335           0 :         ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
    2336           0 :                                 pData->GetTabNo() );
    2337             : 
    2338             :         //  first select type of source data
    2339             : 
    2340           0 :         bool bEnableExt = ScDPObject::HasRegisteredSources();
    2341             : 
    2342           0 :         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2343             :         OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2344             : 
    2345             :         ::boost::scoped_ptr<AbstractScDataPilotSourceTypeDlg> pTypeDlg(
    2346             :             pFact->CreateScDataPilotSourceTypeDlg(
    2347           0 :                 pTabViewShell->GetDialogParent(), bEnableExt, RID_SCDLG_DAPITYPE));
    2348             : 
    2349             :         // Populate named ranges (if any).
    2350           0 :         ScRangeName* pRangeName = pDoc->GetRangeName();
    2351           0 :         if (pRangeName)
    2352             :         {
    2353           0 :             ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
    2354           0 :             for (; itr != itrEnd; ++itr)
    2355           0 :                 pTypeDlg->AppendNamedRange(itr->second->GetName());
    2356             :         }
    2357             : 
    2358             :         OSL_ENSURE(pTypeDlg, "Dialog create fail!");
    2359           0 :         if ( pTypeDlg->Execute() == RET_OK )
    2360             :         {
    2361           0 :             if ( pTypeDlg->IsExternal() )
    2362             :             {
    2363           0 :                 uno::Sequence<rtl::OUString> aSources = ScDPObject::GetRegisteredSources();
    2364             :                 ::boost::scoped_ptr<AbstractScDataPilotServiceDlg> pServDlg(
    2365             :                     pFact->CreateScDataPilotServiceDlg(
    2366           0 :                         pTabViewShell->GetDialogParent(), aSources, RID_SCDLG_DAPISERVICE));
    2367             : 
    2368             :                 OSL_ENSURE(pServDlg, "Dialog create fail!");
    2369           0 :                 if ( pServDlg->Execute() == RET_OK )
    2370             :                 {
    2371             :                     ScDPServiceDesc aServDesc(
    2372           0 :                             pServDlg->GetServiceName(),
    2373           0 :                             pServDlg->GetParSource(),
    2374           0 :                             pServDlg->GetParName(),
    2375           0 :                             pServDlg->GetParUser(),
    2376           0 :                             pServDlg->GetParPass() );
    2377           0 :                     pNewDPObject.reset(new ScDPObject(pDoc));
    2378           0 :                     pNewDPObject->SetServiceData( aServDesc );
    2379           0 :                 }
    2380             :             }
    2381           0 :             else if ( pTypeDlg->IsDatabase() )
    2382             :             {
    2383             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2384             : 
    2385             :                 ::boost::scoped_ptr<AbstractScDataPilotDatabaseDlg> pDataDlg(
    2386             :                     pFact->CreateScDataPilotDatabaseDlg(
    2387           0 :                         pTabViewShell->GetDialogParent(), RID_SCDLG_DAPIDATA));
    2388             : 
    2389             :                 OSL_ENSURE(pDataDlg, "Dialog create fail!");
    2390           0 :                 if ( pDataDlg->Execute() == RET_OK )
    2391             :                 {
    2392           0 :                     ScImportSourceDesc aImpDesc(pDoc);
    2393           0 :                     pDataDlg->GetValues( aImpDesc );
    2394           0 :                     pNewDPObject.reset(new ScDPObject(pDoc));
    2395           0 :                     pNewDPObject->SetImportDesc( aImpDesc );
    2396           0 :                 }
    2397             :             }
    2398           0 :             else if (pTypeDlg->IsNamedRange())
    2399             :             {
    2400           0 :                 OUString aName = pTypeDlg->GetSelectedNamedRange();
    2401           0 :                 ScSheetSourceDesc aShtDesc(pDoc);
    2402           0 :                 aShtDesc.SetRangeName(aName);
    2403           0 :                 nSrcErrorId = aShtDesc.CheckSourceRange();
    2404           0 :                 if (!nSrcErrorId)
    2405             :                 {
    2406           0 :                     pNewDPObject.reset(new ScDPObject(pDoc));
    2407           0 :                     pNewDPObject->SetSheetDesc(aShtDesc);
    2408           0 :                 }
    2409             :             }
    2410             :             else        // selection
    2411             :             {
    2412             :                 //! use database ranges (select before type dialog?)
    2413           0 :                 ScRange aRange;
    2414           0 :                 ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
    2415           0 :                 if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
    2416             :                 {
    2417             :                     // Shrink the range to the data area.
    2418           0 :                     SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
    2419           0 :                     SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
    2420           0 :                     if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
    2421             :                     {
    2422           0 :                         aRange.aStart.SetCol(nStartCol);
    2423           0 :                         aRange.aStart.SetRow(nStartRow);
    2424           0 :                         aRange.aEnd.SetCol(nEndCol);
    2425           0 :                         aRange.aEnd.SetRow(nEndRow);
    2426           0 :                         rMark.SetMarkArea(aRange);
    2427           0 :                         pTabViewShell->MarkRange(aRange);
    2428             :                     }
    2429             : 
    2430           0 :                     bool bOK = true;
    2431           0 :                     if ( pDoc->HasSubTotalCells( aRange ) )
    2432             :                     {
    2433             :                         //  confirm selection if it contains SubTotal cells
    2434             : 
    2435             :                         QueryBox aBox( pTabViewShell->GetDialogParent(),
    2436             :                                         WinBits(WB_YES_NO | WB_DEF_YES),
    2437           0 :                                         ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) );
    2438           0 :                         if (aBox.Execute() == RET_NO)
    2439           0 :                             bOK = false;
    2440             :                     }
    2441           0 :                     if (bOK)
    2442             :                     {
    2443           0 :                         ScSheetSourceDesc aShtDesc(pDoc);
    2444           0 :                         aShtDesc.SetSourceRange(aRange);
    2445           0 :                         nSrcErrorId = aShtDesc.CheckSourceRange();
    2446           0 :                         if (!nSrcErrorId)
    2447             :                         {
    2448           0 :                             pNewDPObject.reset(new ScDPObject(pDoc));
    2449           0 :                             pNewDPObject->SetSheetDesc( aShtDesc );
    2450             :                         }
    2451             : 
    2452             :                         //  output below source data
    2453           0 :                         if ( aRange.aEnd.Row()+2 <= MAXROW - 4 )
    2454           0 :                             aDestPos = ScAddress( aRange.aStart.Col(),
    2455           0 :                                                     aRange.aEnd.Row()+2,
    2456           0 :                                                     aRange.aStart.Tab() );
    2457             :                     }
    2458             :                 }
    2459             :             }
    2460             :         }
    2461             : 
    2462           0 :         if (nSrcErrorId)
    2463             :         {
    2464             :             // Error occurred during data creation.  Launch an error and bail out.
    2465           0 :             InfoBox aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId));
    2466           0 :             aBox.Execute();
    2467           0 :             return;
    2468             :         }
    2469             : 
    2470           0 :         if ( pNewDPObject )
    2471           0 :             pNewDPObject->SetOutRange( aDestPos );
    2472             :     }
    2473             : 
    2474           0 :     pTabViewShell->SetDialogDPObject( pNewDPObject.get() );   // is copied
    2475           0 :     if ( pNewDPObject )
    2476             :     {
    2477             :         //  start layout dialog
    2478             : 
    2479           0 :         sal_uInt16 nId  = ScPivotLayoutWrapper::GetChildWindowId();
    2480           0 :         SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
    2481           0 :         SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
    2482           0 :         pScMod->SetRefDialog( nId, pWnd ? false : true );
    2483           0 :     }
    2484             : }
    2485             : 
    2486           0 : void ScCellShell::ExecuteXMLSourceDialog()
    2487             : {
    2488           0 :     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2489           0 :     if (!pFact)
    2490           0 :         return;
    2491             : 
    2492           0 :     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
    2493           0 :     if (!pTabViewShell)
    2494           0 :         return;
    2495             : 
    2496           0 :     ScModule* pScMod = SC_MOD();
    2497             : 
    2498           0 :     sal_uInt16 nId = ScXMLSourceDlgWrapper::GetChildWindowId();
    2499           0 :     SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
    2500           0 :     SfxChildWindow* pWnd = pViewFrame->GetChildWindow(nId);
    2501           0 :     pScMod->SetRefDialog(nId, pWnd ? false : true);
    2502             : }
    2503             : 
    2504           0 : void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
    2505             : {
    2506           0 :     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
    2507           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
    2508           0 :     if ( pArgs )
    2509             :     {
    2510           0 :         pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
    2511           0 :                         GetSubTotalData() );
    2512           0 :         rReq.Done();
    2513             :         return;
    2514             :     }
    2515             : 
    2516           0 :     SfxAbstractTabDialog * pDlg = NULL;
    2517           0 :     ScSubTotalParam aSubTotalParam;
    2518           0 :     SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
    2519             : 
    2520             :     // Only get existing named database range.
    2521           0 :     ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD);
    2522           0 :     if (!pDBData)
    2523             :     {
    2524             :         // No existing DB data at this position.  Create an
    2525             :         // anonymous DB.
    2526           0 :         pDBData = pTabViewShell->GetAnonymousDBData();
    2527           0 :         ScRange aDataRange;
    2528           0 :         pDBData->GetArea(aDataRange);
    2529           0 :         pTabViewShell->MarkRange(aDataRange, false);
    2530             :     }
    2531           0 :     if (!pDBData)
    2532             :         return;
    2533             : 
    2534           0 :     pDBData->GetSubTotalParam( aSubTotalParam );
    2535           0 :     aSubTotalParam.bRemoveOnly = false;
    2536             : 
    2537           0 :     aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
    2538           0 :     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2539             :     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2540             : 
    2541           0 :     pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
    2542             :     OSL_ENSURE(pDlg, "Dialog create fail!");
    2543           0 :     pDlg->SetCurPageId(1);
    2544             : 
    2545           0 :     short bResult = pDlg->Execute();
    2546             : 
    2547           0 :     if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
    2548             :     {
    2549           0 :         const SfxItemSet* pOutSet = NULL;
    2550             : 
    2551           0 :         if ( bResult == RET_OK )
    2552             :         {
    2553           0 :             pOutSet = pDlg->GetOutputItemSet();
    2554             :             aSubTotalParam =
    2555             :                 ((const ScSubTotalItem&)
    2556           0 :                     pOutSet->Get( SCITEM_SUBTDATA )).
    2557           0 :                         GetSubTotalData();
    2558             :         }
    2559             :         else // if (bResult == SCRET_REMOVE)
    2560             :         {
    2561           0 :             pOutSet = &aArgSet;
    2562           0 :             aSubTotalParam.bRemoveOnly = sal_True;
    2563           0 :             aSubTotalParam.bReplace    = sal_True;
    2564             :             aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
    2565             :                                          GetViewData(),
    2566           0 :                                          &aSubTotalParam ) );
    2567             :         }
    2568             : 
    2569           0 :         pTabViewShell->DoSubTotals( aSubTotalParam );
    2570           0 :         rReq.Done( *pOutSet );
    2571             :     }
    2572             :     else
    2573           0 :         GetViewData()->GetDocShell()->CancelAutoDBRange();
    2574             : 
    2575           0 :     delete pDlg;
    2576             : }
    2577             : 
    2578           0 : IMPL_LINK_NOARG(ScCellShell, DialogClosed)
    2579             : {
    2580             :     OSL_ENSURE( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
    2581             :     OSL_ENSURE( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" );
    2582           0 :     String sFile, sFilter, sOptions, sSource;
    2583           0 :     sal_uLong nRefresh = 0;
    2584             : 
    2585           0 :     if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
    2586             :     {
    2587           0 :         sFile = pImpl->m_pLinkedDlg->GetURL();
    2588           0 :         sFilter = pImpl->m_pLinkedDlg->GetFilter();
    2589           0 :         sOptions = pImpl->m_pLinkedDlg->GetOptions();
    2590           0 :         sSource = pImpl->m_pLinkedDlg->GetSource();
    2591           0 :         nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
    2592           0 :         if ( sFile.Len() )
    2593           0 :             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
    2594           0 :         if ( sFilter.Len() )
    2595           0 :             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
    2596           0 :         if ( sOptions.Len() )
    2597           0 :             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
    2598           0 :         if ( sSource.Len() )
    2599           0 :             pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
    2600           0 :         if ( nRefresh )
    2601           0 :             pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
    2602             :     }
    2603             : 
    2604           0 :     ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
    2605           0 :     return 0;
    2606         102 : }
    2607             : 
    2608             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10