LCOV - code coverage report
Current view: top level - sc/source/ui/view - cellsh1.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1491 0.1 %
Date: 2015-06-13 12:38:46 Functions: 2 13 15.4 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11