xref: /AOO41X/main/sc/source/ui/view/cellsh1.cxx (revision 54628ca40d27d15cc98fe861da7fff7e60c2f7d6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 //------------------------------------------------------------------
29 
30 //svdraw.hxx
31 #define _SDR_NOITEMS
32 #define _SDR_NOTOUCH
33 #define _SDR_NOTRANSFORM
34 #define _SI_NOSBXCONTROLS
35 #define _VCONT_HXX
36 #define _SI_NOOTHERFORMS
37 #define _VCTRLS_HXX
38 #define _SI_NOCONTROL
39 #define _SETBRW_HXX
40 #define _VCBRW_HXX
41 #define _SI_NOSBXCONTROLS
42 
43 //------------------------------------------------------------------
44 #include <com/sun/star/i18n/TextConversionOption.hpp>
45 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
46 
47 #include "scitems.hxx"
48 #include <sfx2/viewfrm.hxx>
49 
50 #define _ZFORLIST_DECLARE_TABLE
51 #include <svl/stritem.hxx>
52 #include <svl/whiter.hxx>
53 #include <svl/zforlist.hxx>
54 #include <svl/zformat.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <sfx2/request.hxx>
57 #include <vcl/msgbox.hxx>
58 #include <svx/svxdlg.hxx>
59 #include <sot/formats.hxx>
60 #include <svx/postattr.hxx>
61 #include <editeng/fontitem.hxx>
62 #include <svx/clipfmtitem.hxx>
63 #include <sfx2/passwd.hxx>
64 #include <svx/hlnkitem.hxx>
65 #include <basic/sbxcore.hxx>
66 #include <unotools/useroptions.hxx>
67 #include <vcl/waitobj.hxx>
68 #include <unotools/localedatawrapper.hxx>
69 
70 #include "cellsh.hxx"
71 #include "sc.hrc"
72 #include "document.hxx"
73 #include "patattr.hxx"
74 #include "scmod.hxx"
75 #include "scresid.hxx"
76 #include "tabvwsh.hxx"
77 //CHINA001 #include "inscldlg.hxx"
78 //CHINA001 #include "inscodlg.hxx"
79 //CHINA001 #include "delcldlg.hxx"
80 //CHINA001 #include "delcodlg.hxx"
81 //CHINA001 #include "filldlg.hxx"
82 //CHINA001 #include "groupdlg.hxx"
83 #include "impex.hxx"
84 #include "reffind.hxx"
85 //CHINA001 #include "namecrea.hxx"
86 #include "uiitems.hxx"
87 #include "reffact.hxx"
88 //CHINA001 #include "namepast.hxx"
89 #include "inputhdl.hxx"
90 #include "transobj.hxx"
91 #include "drwtrans.hxx"
92 //CHINA001 #include "linkarea.hxx"
93 #include "docfunc.hxx"
94 #include "editable.hxx"
95 #include "dpobject.hxx"
96 #include "dpsave.hxx"
97 #include "dpgroup.hxx"      // for ScDPNumGroupInfo
98 #include "spellparam.hxx"
99 #include "postit.hxx"
100 #include "clipparam.hxx"
101 
102 #include "globstr.hrc"
103 #include "scui_def.hxx" //CHINA001
104 #include <svx/svxdlg.hxx> //CHINA001
105 #include <svx/dialogs.hrc> //CHINA001
106 #include "scabstdlg.hxx" //CHINA001
107 #define IS_AVAILABLE(WhichId,ppItem) \
108     (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
109 
110 #define C2U(cChar)  rtl::OUString::createFromAscii(cChar)
111 
112 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
113 #include <com/sun/star/lang/XInitialization.hpp>
114 #include <com/sun/star/beans/PropertyValue.hpp>
115 #include <com/sun/star/beans/XPropertySet.hpp>
116 #include <cppuhelper/bootstrap.hxx>
117 
118 using namespace ::com::sun::star;
119 using namespace ::com::sun::star::beans;
120 using namespace ::com::sun::star::uno;
121 
122 //------------------------------------------------------------------
123 void ScCellShell::ExecuteEdit( SfxRequest& rReq )
124 {
125     ScModule*           pScMod      = SC_MOD();
126     ScTabViewShell* pTabViewShell   = GetViewData()->GetViewShell();
127     SfxBindings&        rBindings   = pTabViewShell->GetViewFrame()->GetBindings();
128     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
129     sal_uInt16              nSlot       = rReq.GetSlot();
130 
131     pTabViewShell->HideListBox();                   // Autofilter-DropDown-Listbox
132 
133                                     // Eingabe beenden
134     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
135     {
136         switch ( nSlot )
137         {
138             case FID_DEFINE_NAME:
139             case FID_USE_NAME:
140             case FID_INSERT_NAME:
141             case SID_SPELL_DIALOG:
142             case SID_HANGUL_HANJA_CONVERSION:
143 
144             pScMod->InputEnterHandler();
145             pTabViewShell->UpdateInputHandler();
146             break;
147 
148             default:
149             break;
150         }
151     }
152 
153     switch ( nSlot )
154     {
155         //
156         //  Einfuegen / Loeschen von Zellen / Zeilen / Spalten
157         //
158 
159         case FID_INS_ROW:
160             pTabViewShell->InsertCells(INS_INSROWS);
161             rReq.Done();
162             break;
163 
164         case FID_INS_COLUMN:
165             pTabViewShell->InsertCells(INS_INSCOLS);
166             rReq.Done();
167             break;
168 
169         case FID_INS_CELLSDOWN:
170             pTabViewShell->InsertCells(INS_CELLSDOWN);
171             rReq.Done();
172             break;
173 
174         case FID_INS_CELLSRIGHT:
175             pTabViewShell->InsertCells(INS_CELLSRIGHT);
176             rReq.Done();
177             break;
178 
179         case SID_DEL_ROWS:
180             pTabViewShell->DeleteCells( DEL_DELROWS );
181             rReq.Done();
182             break;
183 
184         case SID_DEL_COLS:
185             pTabViewShell->DeleteCells( DEL_DELCOLS );
186             rReq.Done();
187             break;
188 
189         case FID_INS_CELL:
190             {
191                 InsCellCmd eCmd=INS_NONE;
192 
193                 if ( pReqArgs )
194                 {
195                     const SfxPoolItem* pItem;
196                     String aFlags;
197 
198                     if( IS_AVAILABLE( FID_INS_CELL, &pItem ) )
199                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
200                     if( aFlags.Len() )
201                     {
202                         switch( aFlags.GetChar(0) )
203                         {
204                             case 'V': eCmd = INS_CELLSDOWN ;break;
205                             case '>': eCmd = INS_CELLSRIGHT ;break;
206                             case 'R': eCmd = INS_INSROWS ;break;
207                             case 'C': eCmd = INS_INSCOLS ;break;
208                         }
209                     }
210                 }
211                 else
212                 {
213                     if ( GetViewData()->SimpleColMarked() )
214                         eCmd = INS_INSCOLS;
215                     else if ( GetViewData()->SimpleRowMarked() )
216                         eCmd = INS_INSROWS;
217                     else
218                     {
219                         ScDocument* pDoc = GetViewData()->GetDocument();
220                         sal_Bool bTheFlag=(pDoc->GetChangeTrack()!=NULL);
221 
222 //CHINA001                      ScInsertCellDlg* pDlg = new ScInsertCellDlg( pTabViewShell->GetDialogParent(),
223 //CHINA001                      bTheFlag);
224                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
225                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
226 
227                         AbstractScInsertCellDlg* pDlg = pFact->CreateScInsertCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_INSCELL, bTheFlag);
228                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
229                         if (pDlg->Execute() == RET_OK)
230                             eCmd = pDlg->GetInsCellCmd();
231                         delete pDlg;
232                     }
233                 }
234 
235                 if (eCmd!=INS_NONE)
236                 {
237                     pTabViewShell->InsertCells( eCmd );
238 
239                     if( ! rReq.IsAPI() )
240                     {
241                         String aParam;
242 
243                         switch( eCmd )
244                         {
245                             case INS_CELLSDOWN: aParam='V'; break;
246                             case INS_CELLSRIGHT: aParam='>'; break;
247                             case INS_INSROWS: aParam='R'; break;
248                             case INS_INSCOLS: aParam='C'; break;
249                             default:
250                             {
251                                 // added to avoid warnings
252                             }
253                         }
254                         rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
255                         rReq.Done();
256                     }
257                 }
258             }
259             break;
260 
261         case FID_DELETE_CELL:
262             {
263                 DelCellCmd eCmd = DEL_NONE;
264 
265                 if ( pReqArgs )
266                 {
267                     const SfxPoolItem* pItem;
268                     String aFlags;
269 
270                     if( IS_AVAILABLE( FID_DELETE_CELL, &pItem ) )
271                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
272                     if( aFlags.Len() )
273                     {
274                         switch( aFlags.GetChar(0) )
275                         {
276                             case 'U': eCmd = DEL_CELLSUP ;break;
277                             case 'L': eCmd = DEL_CELLSLEFT ;break;
278                             case 'R': eCmd = DEL_DELROWS ;break;
279                             case 'C': eCmd = DEL_DELCOLS ;break;
280                         }
281                     }
282                 }
283                 else
284                 {
285                     if ( GetViewData()->SimpleColMarked() )
286                         eCmd = DEL_DELCOLS;
287                     else if ( GetViewData()->SimpleRowMarked() )
288                         eCmd = DEL_DELROWS;
289                     else
290                     {
291                         ScRange aRange;
292                         ScDocument* pDoc = GetViewData()->GetDocument();
293                         sal_Bool bTheFlag=GetViewData()->IsMultiMarked() ||
294                             (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) ||
295                             (pDoc->GetChangeTrack() != NULL);
296 
297                         //CHINA001 ScDeleteCellDlg* pDlg = new ScDeleteCellDlg(
298                         //CHINA001      pTabViewShell->GetDialogParent(),bTheFlag);
299                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
300                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
301 
302                         AbstractScDeleteCellDlg* pDlg = pFact->CreateScDeleteCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCELL, bTheFlag );
303                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
304 
305                         if (pDlg->Execute() == RET_OK)
306                             eCmd = pDlg->GetDelCellCmd();
307                         delete pDlg;
308                     }
309                 }
310 
311                 if (eCmd != DEL_NONE )
312                 {
313                     pTabViewShell->DeleteCells( eCmd );
314 
315                     if( ! rReq.IsAPI() )
316                     {
317                         String aParam;
318 
319                         switch( eCmd )
320                         {
321                             case DEL_CELLSUP: aParam='U'; break;
322                             case DEL_CELLSLEFT: aParam='L'; break;
323                             case DEL_DELROWS: aParam='R'; break;
324                             case DEL_DELCOLS: aParam='C'; break;
325                             default:
326                             {
327                                 // added to avoid warnings
328                             }
329                         }
330                         rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
331                         rReq.Done();
332                     }
333                 }
334             }
335             break;
336 
337         //
338         //  Inhalte von Zellen loeschen
339         //
340 
341         case SID_DELETE_CONTENTS:
342             pTabViewShell->DeleteContents( IDF_CONTENTS );
343             rReq.Done();
344             break;
345 
346         case SID_DELETE:
347             {
348                 sal_uInt16  nFlags = IDF_NONE;
349 
350                 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
351                 {
352                     const   SfxPoolItem* pItem;
353                     String  aFlags = 'A';
354 
355                     if( IS_AVAILABLE( SID_DELETE, &pItem ) )
356                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
357 
358                     aFlags.ToUpperAscii();
359                     sal_Bool    bCont = sal_True;
360 
361                     for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
362                     {
363                         switch( aFlags.GetChar(i) )
364                         {
365                             case 'A': // Alle
366                             nFlags |= IDF_ALL;
367                             bCont = sal_False; // nicht mehr weitermachen!
368                             break;
369                             case 'S': nFlags |= IDF_STRING; break;
370                             case 'V': nFlags |= IDF_VALUE; break;
371                             case 'D': nFlags |= IDF_DATETIME; break;
372                             case 'F': nFlags |= IDF_FORMULA; break;
373                             case 'N': nFlags |= IDF_NOTE; break;
374                             case 'T': nFlags |= IDF_ATTRIB; break;
375                             case 'O': nFlags |= IDF_OBJECTS; break;
376                         }
377                     }
378                 }
379                 else
380                 {
381                     ScEditableTester aTester( pTabViewShell );
382                     if (aTester.IsEditable())
383                     {
384                         //CHINA001 ScDeleteContentsDlg* pDlg = new ScDeleteContentsDlg(     pTabViewShell->GetDialogParent() );
385                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
386                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
387 
388                         AbstractScDeleteContentsDlg* pDlg = pFact->CreateScDeleteContentsDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCONT );
389                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
390                         ScDocument* pDoc = GetViewData()->GetDocument();
391                         SCTAB nTab = GetViewData()->GetTabNo();
392                         if ( pDoc->IsTabProtected(nTab) )
393                             pDlg->DisableObjects();
394                         if (pDlg->Execute() == RET_OK)
395                         {
396                             nFlags = pDlg->GetDelContentsCmdBits();
397                         }
398                         delete pDlg;
399                     }
400                     else
401                         pTabViewShell->ErrorMessage(aTester.GetMessageId());
402                 }
403 
404                 if( nFlags != IDF_NONE )
405                 {
406                     pTabViewShell->DeleteContents( nFlags );
407 
408                     if( ! rReq.IsAPI() )
409                     {
410                         String  aFlags;
411 
412                         if( nFlags == IDF_ALL )
413                         {
414                             aFlags += 'A';
415                         }
416                         else
417                         {
418                             if( nFlags & IDF_STRING ) aFlags += 'S';
419                             if( nFlags & IDF_VALUE ) aFlags += 'V';
420                             if( nFlags & IDF_DATETIME ) aFlags += 'D';
421                             if( nFlags & IDF_FORMULA ) aFlags += 'F';
422                             if( nFlags & IDF_NOTE ) aFlags += 'N';
423                             if( nFlags & IDF_ATTRIB ) aFlags += 'T';
424                             if( nFlags & IDF_OBJECTS ) aFlags += 'O';
425                         }
426 
427                         rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) );
428                         rReq.Done();
429                     }
430                 }
431             }
432             break;
433 
434         //
435         //  Ausfuellen...
436         //
437 
438         case FID_FILL_TO_BOTTOM:
439             pTabViewShell->FillSimple( FILL_TO_BOTTOM );
440             rReq.Done();
441             break;
442 
443         case FID_FILL_TO_RIGHT:
444             pTabViewShell->FillSimple( FILL_TO_RIGHT );
445             rReq.Done();
446             break;
447 
448         case FID_FILL_TO_TOP:
449             pTabViewShell->FillSimple( FILL_TO_TOP );
450             rReq.Done();
451             break;
452 
453         case FID_FILL_TO_LEFT:
454             pTabViewShell->FillSimple( FILL_TO_LEFT );
455             rReq.Done();
456             break;
457 
458         case FID_FILL_TAB:
459             {
460                 sal_uInt16 nFlags = IDF_NONE;
461                 sal_uInt16 nFunction = PASTE_NOFUNC;
462                 sal_Bool bSkipEmpty = sal_False;
463                 sal_Bool bAsLink    = sal_False;
464 
465                 if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
466                 {
467                     const   SfxPoolItem* pItem;
468                     String  aFlags = 'A';
469 
470                     if( IS_AVAILABLE( FID_FILL_TAB, &pItem ) )
471                         aFlags = ((const SfxStringItem*)pItem)->GetValue();
472 
473                     aFlags.ToUpperAscii();
474                     sal_Bool    bCont = sal_True;
475 
476                     for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
477                     {
478                         switch( aFlags.GetChar(i) )
479                         {
480                             case 'A': // Alle
481                             nFlags |= IDF_ALL;
482                             bCont = sal_False; // nicht mehr weitermachen!
483                             break;
484                             case 'S': nFlags |= IDF_STRING; break;
485                             case 'V': nFlags |= IDF_VALUE; break;
486                             case 'D': nFlags |= IDF_DATETIME; break;
487                             case 'F': nFlags |= IDF_FORMULA; break;
488                             case 'N': nFlags |= IDF_NOTE; break;
489                             case 'T': nFlags |= IDF_ATTRIB; break;
490                         }
491                     }
492                 }
493                 else
494                 {
495 //CHINA001                  ScInsertContentsDlg* pDlg =
496 //CHINA001                  new ScInsertContentsDlg(pTabViewShell->GetDialogParent(),
497 //CHINA001                  0, /* nCheckDefaults */
498 //CHINA001                  &ScGlobal::GetRscString(STR_FILL_TAB) );
499                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
500                     DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
501 
502                     AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
503                                                                                             RID_SCDLG_INSCONT, 0, /* nCheckDefaults */
504                                                                                             &ScGlobal::GetRscString(STR_FILL_TAB));
505                     DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
506                     pDlg->SetFillMode(sal_True);
507 
508                     if (pDlg->Execute() == RET_OK)
509                     {
510                         nFlags     = pDlg->GetInsContentsCmdBits();
511                         nFunction  = pDlg->GetFormulaCmdBits();
512                         bSkipEmpty = pDlg->IsSkipEmptyCells();
513                         bAsLink    = pDlg->IsLink();
514                         //  MoveMode gibt's bei Tabelle fuellen nicht
515                     }
516                     delete pDlg;
517                 }
518 
519                 if( nFlags != IDF_NONE )
520                 {
521                     pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
522 
523                     if( ! rReq.IsAPI() )
524                     {
525                         String  aFlags;
526 
527                         if( nFlags == IDF_ALL )
528                         {
529                             aFlags += 'A';
530                         }
531                         else
532                         {
533                             if( nFlags & IDF_STRING ) aFlags += 'S';
534                             if( nFlags & IDF_VALUE ) aFlags += 'V';
535                             if( nFlags & IDF_DATETIME ) aFlags += 'D';
536                             if( nFlags & IDF_FORMULA ) aFlags += 'F';
537                             if( nFlags & IDF_NOTE ) aFlags += 'N';
538                             if( nFlags & IDF_ATTRIB ) aFlags += 'T';
539                         }
540 
541                         rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) );
542                         rReq.Done();
543                     }
544                 }
545             }
546             break;
547 
548         case FID_FILL_SERIES:
549             {
550                 SCCOL nStartCol;
551                 SCROW nStartRow;
552                 SCTAB nStartTab;
553                 SCCOL nEndCol;
554                 SCROW nEndRow;
555                 SCTAB nEndTab;
556                 sal_uInt16 nPossDir = FDS_OPT_NONE;
557                 FillDir     eFillDir     = FILL_TO_BOTTOM;
558                 FillCmd     eFillCmd     = FILL_LINEAR;
559                 FillDateCmd eFillDateCmd = FILL_DAY;
560                 double fStartVal = MAXDOUBLE;
561                 double fIncVal   = 1;
562                 double fMaxVal   = MAXDOUBLE;
563                 sal_Bool   bDoIt     = sal_False;
564 
565                 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
566                                               nEndCol, nEndRow, nEndTab );
567 
568                 if( nStartCol!=nEndCol )
569                 {
570                     nPossDir |= FDS_OPT_HORZ;
571                     eFillDir=FILL_TO_RIGHT;
572                 }
573 
574                 if( nStartRow!=nEndRow )
575                 {
576                     nPossDir |= FDS_OPT_VERT;
577                     eFillDir=FILL_TO_BOTTOM;
578                 }
579 
580                 ScDocument*      pDoc = GetViewData()->GetDocument();
581                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
582 
583                 if( pReqArgs )
584                 {
585                     const SfxPoolItem* pItem;
586                     String  aFillDir, aFillCmd, aFillDateCmd;
587                     String  aFillStep, aFillStart, aFillMax;
588                     sal_uInt32 nKey;
589                     double  fTmpVal;
590 
591                     bDoIt=sal_False;
592 
593                     if( IS_AVAILABLE( FID_FILL_SERIES, &pItem ) )
594                         aFillDir = ((const SfxStringItem*)pItem)->GetValue();
595                     if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
596                         aFillCmd = ((const SfxStringItem*)pItem)->GetValue();
597                     if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
598                         aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue();
599                     if( IS_AVAILABLE( FN_PARAM_3, &pItem ) )
600                         aFillStep = ((const SfxStringItem*)pItem)->GetValue();
601                     if( IS_AVAILABLE( FN_PARAM_4, &pItem ) )
602                         aFillStart = ((const SfxStringItem*)pItem)->GetValue();
603                     if( IS_AVAILABLE( FN_PARAM_5, &pItem ) )
604                         aFillMax = ((const SfxStringItem*)pItem)->GetValue();
605 
606                     if( aFillDir.Len() )
607                         switch( aFillDir.GetChar(0) )
608                         {
609                             case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break;
610                             case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break;
611                             case 'T': case 't': eFillDir=FILL_TO_TOP; break;
612                             case 'L': case 'l': eFillDir=FILL_TO_LEFT; break;
613                         }
614 
615                     if( aFillCmd.Len() )
616                         switch( aFillCmd.GetChar(0) )
617                         {
618                             case 'S': case 's': eFillCmd=FILL_SIMPLE; break;
619                             case 'L': case 'l': eFillCmd=FILL_LINEAR; break;
620                             case 'G': case 'g': eFillCmd=FILL_GROWTH; break;
621                             case 'D': case 'd': eFillCmd=FILL_DATE; break;
622                             case 'A': case 'a': eFillCmd=FILL_AUTO; break;
623                         }
624 
625                     if( aFillDateCmd.Len() )
626                         switch( aFillDateCmd.GetChar(0) )
627                         {
628                             case 'D': case 'd': eFillDateCmd=FILL_DAY; break;
629                             case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break;
630                             case 'M': case 'm': eFillDateCmd=FILL_MONTH; break;
631                             case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break;
632                         }
633 
634                     nKey = 0;
635                     if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal ))
636                         fStartVal = fTmpVal;
637 
638                     nKey = 0;
639                     if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal ))
640                         fIncVal = fTmpVal;
641 
642                     nKey = 0;
643                     if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal ))
644                         fMaxVal = fTmpVal;
645 
646                     bDoIt   = sal_True;
647 
648                 }
649                 else // (pReqArgs == NULL) => Dialog hochziehen
650                 {
651                     //
652                     sal_uInt32 nPrivFormat;
653                     CellType eCellType;
654                     pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
655                     pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType );
656                     const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat );
657                     if (!pPrivEntry)
658                     {
659                         DBG_ERROR("Zahlformat nicht gefunden !!!");
660                     }
661                     else
662                     {
663                         short nPrivType = pPrivEntry->GetType();
664                         if ( ( nPrivType & NUMBERFORMAT_DATE)>0)
665                         {
666                            eFillCmd=FILL_DATE;
667                         }
668                         else if(eCellType==CELLTYPE_STRING)
669                         {
670                            eFillCmd=FILL_AUTO;
671                         }
672                     }
673 
674                     //
675                     String aStartStr;
676 
677                     //  Startwert nur vorbelegen, wenn nur 1 Zeile oder Spalte:
678                     if ( nStartCol == nEndCol || nStartRow == nEndRow )
679                     {
680                         double fInputEndVal = 0.0;
681                         String aEndStr;
682 
683                         pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
684                         pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
685 
686 
687                         if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
688                         {
689                             pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
690                             if(aEndStr.Len()>0)
691                             {
692                                 pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
693                                 fIncVal=fInputEndVal-fStartVal;
694                             }
695                         }
696                         else
697                         {
698                             if(nStartCol < nEndCol)
699                             {
700                                 pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
701                                 if(aEndStr.Len()>0)
702                                 {
703                                     pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
704                                     fIncVal=fInputEndVal-fStartVal;
705                                 }
706                             }
707                         }
708                         if(eFillCmd==FILL_DATE)
709                         {
710                             Date aNullDate = *pDoc->GetFormatTable()->GetNullDate();
711                             Date aStartDate = aNullDate;
712                             aStartDate+= (long)fStartVal;
713                             Date aEndDate = aNullDate;
714                             aEndDate+= (long)fInputEndVal;
715                             double fTempDate=0;
716 
717                             if(aStartDate.GetYear()!=aEndDate.GetYear())
718                             {
719                                 eFillDateCmd = FILL_YEAR;
720                                 fTempDate=aEndDate.GetYear()-aStartDate.GetYear();
721                             }
722                             if(aStartDate.GetMonth()!=aEndDate.GetMonth())
723                             {
724                                 eFillDateCmd = FILL_MONTH;
725                                 fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth();
726                             }
727                             if(aStartDate.GetDay()==aEndDate.GetDay())
728                             {
729                                 fIncVal=fTempDate;
730                             }
731                         }
732                     }
733 //CHINA001                  ScFillSeriesDlg* pDlg = new ScFillSeriesDlg(
734 //CHINA001                  pTabViewShell->GetDialogParent(), *pDoc,
735 //CHINA001                  eFillDir, eFillCmd, eFillDateCmd,
736 //CHINA001                  aStartStr, fIncVal, fMaxVal,
737 //CHINA001                  nPossDir);
738                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
739                     DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
740 
741                     AbstractScFillSeriesDlg* pDlg = pFact->CreateScFillSeriesDlg( pTabViewShell->GetDialogParent(),
742                                                             *pDoc,
743                                                             eFillDir, eFillCmd, eFillDateCmd,
744                                                             aStartStr, fIncVal, fMaxVal,
745                                                             nPossDir,
746                                                             RID_SCDLG_FILLSERIES);
747                     DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
748 
749                     if ( nStartCol != nEndCol && nStartRow != nEndRow )
750                     {
751                         pDlg->SetEdStartValEnabled(sal_False);
752                     }
753 
754                     if ( pDlg->Execute() == RET_OK )
755                     {
756                         eFillDir        = pDlg->GetFillDir();
757                         eFillCmd        = pDlg->GetFillCmd();
758                         eFillDateCmd    = pDlg->GetFillDateCmd();
759 
760                         if(eFillCmd==FILL_AUTO)
761                         {
762                             String aStr=pDlg->GetStartStr();
763                             if(aStr.Len()>0)
764                                 pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr );
765                         }
766                         fStartVal       = pDlg->GetStart();
767                         fIncVal         = pDlg->GetStep();
768                         fMaxVal         = pDlg->GetMax();
769                         bDoIt           = sal_True;
770                     }
771                     delete pDlg;
772                 }
773 
774                 if( bDoIt )
775                 {
776                     //nScFillModeMouseModifier = 0; // kein Ctrl/Copy
777                     pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal );
778 
779                     if( ! rReq.IsAPI() )
780                     {
781                         String  aPara;
782                         Color*  pColor=0;
783 
784                         switch( eFillDir )
785                         {
786                             case FILL_TO_BOTTOM:    aPara = 'B'; break;
787                             case FILL_TO_RIGHT:     aPara = 'R'; break;
788                             case FILL_TO_TOP:       aPara = 'T'; break;
789                             case FILL_TO_LEFT:      aPara = 'L'; break;
790                             default: aPara.Erase(); break;
791                         }
792                         rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) );
793 
794                         switch( eFillCmd )
795                         {
796                             case FILL_SIMPLE:       aPara = 'S'; break;
797                             case FILL_LINEAR:       aPara = 'L'; break;
798                             case FILL_GROWTH:       aPara = 'G'; break;
799                             case FILL_DATE:         aPara = 'D'; break;
800                             case FILL_AUTO:         aPara = 'A'; break;
801                             default: aPara.Erase(); break;
802                         }
803                         rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) );
804 
805                         switch( eFillDateCmd )
806                         {
807                             case FILL_DAY:          aPara = 'D'; break;
808                             case FILL_WEEKDAY:      aPara = 'W'; break;
809                             case FILL_MONTH:        aPara = 'M'; break;
810                             case FILL_YEAR:         aPara = 'Y'; break;
811                             default: aPara.Erase(); break;
812                         }
813                         rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) );
814 
815                         sal_uLong nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER,
816                                     ScGlobal::eLnge );
817 
818                         pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor );
819                         rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) );
820 
821                         pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor );
822                         rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) );
823 
824                         pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor );
825                         rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) );
826 
827                         rReq.Done();
828                     }
829                 }
830             }
831             break;
832 
833         case FID_FILL_AUTO:
834             {
835                 SCCOL nStartCol;
836                 SCROW nStartRow;
837                 SCCOL nEndCol;
838                 SCROW nEndRow;
839                 SCTAB nStartTab, nEndTab;
840 
841                 GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
842                 SCCOL nFillCol = GetViewData()->GetRefEndX();
843                 SCROW nFillRow = GetViewData()->GetRefEndY();
844                 ScDocument* pDoc = GetViewData()->GetDocument();
845 
846                 if( pReqArgs != NULL )
847                 {
848                     const SfxPoolItem* pItem;
849 
850                     if( IS_AVAILABLE( FID_FILL_AUTO, &pItem ) )
851                     {
852                         ScAddress aScAddress;
853                         String aArg = ((const SfxStringItem*)pItem)->GetValue();
854 
855                         if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID )
856                         {
857                             nFillRow = aScAddress.Row();
858                             nFillCol = aScAddress.Col();
859                         }
860                     }
861 
862                     GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
863                                               nEndCol,nEndRow,nEndTab );
864                 }
865                 else    // Aufruf per Maus
866                 {
867                     //  #55284# nicht innerhalb einer zusammengefassten Zelle
868 
869                     if ( nStartCol == nEndCol && nStartRow == nEndRow )
870                     {
871                         SCCOL nMergeCol = nStartCol;
872                         SCROW nMergeRow = nStartRow;
873                         if ( GetViewData()->GetDocument()->ExtendMerge(
874                                 nStartCol, nStartRow, nMergeCol, nMergeRow,
875                                 GetViewData()->GetTabNo() ) )
876                         {
877                             if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow )
878                                 nFillCol = nStartCol;
879                             if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol )
880                                 nFillRow = nStartRow;
881                         }
882                     }
883                 }
884 
885                 if ( nFillCol != nEndCol || nFillRow != nEndRow )
886                 {
887                     if ( nFillCol==nEndCol || nFillRow==nEndRow )
888                     {
889                         FillDir eDir = FILL_TO_BOTTOM;
890                         SCCOLROW nCount = 0;
891 
892                         if ( nFillCol==nEndCol )
893                         {
894                             if ( nFillRow > nEndRow )
895                             {
896                                 eDir = FILL_TO_BOTTOM;
897                                 nCount = nFillRow - nEndRow;
898                             }
899                             else if ( nFillRow < nStartRow )
900                             {
901                                 eDir = FILL_TO_TOP;
902                                 nCount = nStartRow - nFillRow;
903                             }
904                         }
905                         else
906                         {
907                             if ( nFillCol > nEndCol )
908                             {
909                                 eDir = FILL_TO_RIGHT;
910                                 nCount = nFillCol - nEndCol;
911                             }
912                             else if ( nFillCol < nStartCol )
913                             {
914                                 eDir = FILL_TO_LEFT;
915                                 nCount = nStartCol - nFillCol;
916                             }
917                         }
918 
919                         if ( nCount != 0)
920                         {
921                             pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount );
922 
923                             if( ! rReq.IsAPI() )
924                             {
925                                 String  aAdrStr;
926                                 ScAddress aAdr( nFillCol, nFillRow, 0 );
927                                 aAdr.Format( aAdrStr, SCR_ABS, pDoc, pDoc->GetAddressConvention() );
928 
929                                 rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) );
930                                 rReq.Done();
931                             }
932                         }
933 
934                     }
935                     else
936                     {
937                         DBG_ERROR( "Richtung nicht eindeutig fuer AutoFill" );
938                     }
939                 }
940             }
941             break;
942 
943         //
944         //  Gliederung (Outlines)
945         //  SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
946         //
947 
948         case SID_OUTLINE_HIDE:
949             if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
950                                     GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
951                 pTabViewShell->SetDataPilotDetails( sal_False );
952             else
953                 pTabViewShell->HideMarkedOutlines();
954             rReq.Done();
955             break;
956 
957         case SID_OUTLINE_SHOW:
958             {
959                 ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
960                                     GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
961                 if ( pDPObj )
962                 {
963                     Sequence<sheet::DataPilotFieldFilter> aFilters;
964                     sal_uInt16 nOrientation;
965                     if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
966                     {
967                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
968                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
969 
970                         AbstractScDPShowDetailDlg* pDlg = pFact->CreateScDPShowDetailDlg(
971                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL, *pDPObj, nOrientation );
972                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
973                         if ( pDlg->Execute() == RET_OK )
974                         {
975                             String aNewDimName( pDlg->GetDimensionName() );
976                             pTabViewShell->SetDataPilotDetails( sal_True, &aNewDimName );
977                         }
978                     }
979                     else if ( !pDPObj->IsServiceData() &&
980                                pDPObj->GetDataFieldPositionData(
981                                    ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
982                                    aFilters ) )
983                         pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
984                     else
985                         pTabViewShell->SetDataPilotDetails( sal_True );
986                 }
987                 else
988                     pTabViewShell->ShowMarkedOutlines();
989                 rReq.Done();
990             }
991             break;
992 
993         case SID_OUTLINE_MAKE:
994             {
995                 sal_Bool bColumns = sal_False;
996                 sal_Bool bOk = sal_True;
997 
998                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
999                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1000                 {
1001                     ScDPNumGroupInfo aNumInfo;
1002                     aNumInfo.Enable    = sal_True;
1003                     aNumInfo.AutoStart = sal_True;
1004                     aNumInfo.AutoEnd   = sal_True;
1005                     sal_Int32 nParts = 0;
1006                     if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
1007                     {
1008                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1009                         DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
1010                         Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
1011                         AbstractScDPDateGroupDlg* pDlg = pFact->CreateScDPDateGroupDlg(
1012                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPDATEGROUP,
1013                             aNumInfo, nParts, aNullDate );
1014                         DBG_ASSERT( pDlg, "Dialog create fail!" );
1015                         if( pDlg->Execute() == RET_OK )
1016                         {
1017                             aNumInfo = pDlg->GetGroupInfo();
1018                             pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() );
1019                         }
1020                     }
1021                     else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) )
1022                     {
1023                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1024                         DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
1025                         AbstractScDPNumGroupDlg* pDlg = pFact->CreateScDPNumGroupDlg(
1026                             pTabViewShell->GetDialogParent(), RID_SCDLG_DPNUMGROUP, aNumInfo );
1027                         DBG_ASSERT( pDlg, "Dialog create fail!" );
1028                         if( pDlg->Execute() == RET_OK )
1029                             pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() );
1030                     }
1031                     else
1032                         pTabViewShell->GroupDataPilot();
1033 
1034                     bOk = sal_False;
1035                 }
1036                 else if( pReqArgs != NULL )
1037                 {
1038                     const SfxPoolItem* pItem;
1039                     bOk = sal_False;
1040 
1041                     if( IS_AVAILABLE( SID_OUTLINE_MAKE, &pItem ) )
1042                     {
1043                         String aCol = ((const SfxStringItem*)pItem)->GetValue();
1044                         aCol.ToUpperAscii();
1045 
1046                         switch( aCol.GetChar(0) )
1047                         {
1048                             case 'R': bColumns=sal_False; bOk = sal_True;break;
1049                             case 'C': bColumns=sal_True; bOk = sal_True;break;
1050                         }
1051                     }
1052                 }
1053                 else            // Dialog, wenn nicht ganze Zeilen/Spalten markiert
1054                 {
1055                     if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
1056                         bColumns = sal_True;
1057                     else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
1058                         bColumns = sal_False;
1059                     else
1060                     {
1061 //CHINA001                      ScGroupDlg* pDlg = new ScGroupDlg(pTabViewShell->GetDialogParent(),
1062 //CHINA001                      RID_SCDLG_GRP_MAKE, sal_False );
1063                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1064                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1065 
1066                         AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_MAKE, RID_SCDLG_GRP_MAKE,sal_False);
1067                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1068                         if ( pDlg->Execute() == RET_OK )
1069                             bColumns = pDlg->GetColsChecked();
1070                         else
1071                             bOk = sal_False;
1072                         delete pDlg;
1073                     }
1074                 }
1075                 if (bOk)
1076                 {
1077                     pTabViewShell->MakeOutline( bColumns );
1078 
1079                     if( ! rReq.IsAPI() )
1080                     {
1081                         String aCol = bColumns ? 'C' : 'R';
1082                         rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
1083                         rReq.Done();
1084                     }
1085                 }
1086             }
1087             break;
1088 
1089         case SID_OUTLINE_REMOVE:
1090             {
1091                 sal_Bool bColumns = sal_False;
1092                 sal_Bool bOk = sal_True;
1093 
1094                 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1095                                         GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1096                 {
1097                     pTabViewShell->UngroupDataPilot();
1098                     bOk = sal_False;
1099                 }
1100                 else if( pReqArgs != NULL )
1101                 {
1102                     const SfxPoolItem* pItem;
1103                     bOk = sal_False;
1104 
1105                     if( IS_AVAILABLE( SID_OUTLINE_REMOVE, &pItem ) )
1106                     {
1107                         String aCol = ((const SfxStringItem*)pItem)->GetValue();
1108                         aCol.ToUpperAscii();
1109 
1110                         switch( aCol.GetChar(0) )
1111                         {
1112                             case 'R': bColumns=sal_False; bOk = sal_True;break;
1113                             case 'C': bColumns=sal_True; bOk = sal_True;break;
1114                         }
1115                     }
1116                 }
1117                 else            // Dialog nur, wenn Aufheben fuer Zeilen und Spalten moeglich
1118                 {
1119                     sal_Bool bColPoss, bRowPoss;
1120                     pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
1121                     if ( bColPoss && bRowPoss )
1122                     {
1123                         //CHINA001 ScGroupDlg* pDlg = new ScGroupDlg(   pTabViewShell->GetDialogParent(),
1124                         //CHINA001                                  RID_SCDLG_GRP_KILL, sal_True );
1125                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1126                         DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1127 
1128                         AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_KILL, RID_SCDLG_GRP_KILL,sal_True);
1129                         DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1130                         if ( pDlg->Execute() == RET_OK )
1131                             bColumns = pDlg->GetColsChecked();
1132                         else
1133                             bOk = sal_False;
1134                         delete pDlg;
1135                     }
1136                     else if ( bColPoss )
1137                         bColumns = sal_True;
1138                     else if ( bRowPoss )
1139                         bColumns = sal_False;
1140                     else
1141                         bOk = sal_False;
1142                 }
1143                 if (bOk)
1144                 {
1145                     pTabViewShell->RemoveOutline( bColumns );
1146 
1147                     if( ! rReq.IsAPI() )
1148                     {
1149                         String aCol = bColumns ? 'C' : 'R';
1150                         rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
1151                         rReq.Done();
1152                     }
1153                 }
1154             }
1155             break;
1156 
1157         //
1158         //  Clipboard
1159         //
1160 
1161         case SID_COPY:              // fuer Grafiken in DrawShell
1162             {
1163                 WaitObject aWait( GetViewData()->GetDialogParent() );
1164                 pTabViewShell->CopyToClip( NULL, sal_False, sal_False, sal_True );
1165                 rReq.Done();
1166             }
1167             break;
1168 
1169         case SID_CUT:               // fuer Grafiken in DrawShell
1170             {
1171                 WaitObject aWait( GetViewData()->GetDialogParent() );
1172                 pTabViewShell->CutToClip( NULL, sal_True );
1173                 rReq.Done();
1174             }
1175             break;
1176 
1177         case SID_PASTE:
1178             {
1179                 PasteFromClipboard ( GetViewData(), pTabViewShell, true );
1180                 rReq.Done();
1181             }
1182             break;
1183 
1184         case SID_CLIPBOARD_FORMAT_ITEMS:
1185             {
1186                 WaitObject aWait( GetViewData()->GetDialogParent() );
1187 
1188                 sal_uLong nFormat = 0;
1189                 const SfxPoolItem* pItem;
1190                 if ( pReqArgs &&
1191                      pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
1192                      pItem->ISA(SfxUInt32Item) )
1193                 {
1194                     nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
1195                 }
1196 
1197                 if ( nFormat )
1198                 {
1199                     Window* pWin = GetViewData()->GetActiveWin();
1200                     sal_Bool bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != NULL );
1201                     sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
1202                     sal_Bool bOle = ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE );
1203 
1204                     if ( bCells && bOle )
1205                         pTabViewShell->PasteFromSystem();
1206                     else if ( bDraw && bOle )
1207                         pTabViewShell->PasteDraw();
1208                     else
1209                         pTabViewShell->PasteFromSystem(nFormat);
1210                 }
1211                 //?else
1212                 //? pTabViewShell->PasteFromSystem();
1213 
1214                 rReq.Done();
1215             }
1216             pTabViewShell->CellContentChanged();
1217             break;
1218 
1219         case FID_INS_CELL_CONTENTS:
1220             {
1221                 sal_uInt16 nFlags = IDF_NONE;
1222                 sal_uInt16 nFunction = PASTE_NOFUNC;
1223                 sal_Bool bSkipEmpty = sal_False;
1224                 sal_Bool bTranspose = sal_False;
1225                 sal_Bool bAsLink    = sal_False;
1226                 InsCellCmd eMoveMode = INS_NONE;
1227 
1228                 Window* pWin = GetViewData()->GetActiveWin();
1229                 ScDocument* pDoc = GetViewData()->GetDocument();
1230                 sal_Bool bOtherDoc = !pDoc->IsClipboardSource();
1231                 ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
1232                 if ( pOwnClip )
1233                 {
1234                     // #129384# keep a reference in case the clipboard is changed during dialog or PasteFromClip
1235                     uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
1236                     if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
1237                     {
1238                         const   SfxPoolItem* pItem;
1239                         String  aFlags = 'A';
1240 
1241                         if( IS_AVAILABLE( FID_INS_CELL_CONTENTS, &pItem ) )
1242                             aFlags = ((const SfxStringItem*)pItem)->GetValue();
1243 
1244                         aFlags.ToUpperAscii();
1245                         sal_Bool    bCont = sal_True;
1246 
1247                         for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
1248                         {
1249                             switch( aFlags.GetChar(i) )
1250                             {
1251                                 case 'A': // Alle
1252                                 nFlags |= IDF_ALL;
1253                                 bCont = sal_False; // nicht mehr weitermachen!
1254                                 break;
1255                                 case 'S': nFlags |= IDF_STRING; break;
1256                                 case 'V': nFlags |= IDF_VALUE; break;
1257                                 case 'D': nFlags |= IDF_DATETIME; break;
1258                                 case 'F': nFlags |= IDF_FORMULA; break;
1259                                 case 'N': nFlags |= IDF_NOTE; break;
1260                                 case 'T': nFlags |= IDF_ATTRIB; break;
1261                             }
1262                         }
1263 
1264                         SFX_REQUEST_ARG( rReq, pFuncItem, SfxUInt16Item, FN_PARAM_1, sal_False );
1265                         SFX_REQUEST_ARG( rReq, pSkipItem, SfxBoolItem, FN_PARAM_2, sal_False );
1266                         SFX_REQUEST_ARG( rReq, pTransposeItem, SfxBoolItem, FN_PARAM_3, sal_False );
1267                         SFX_REQUEST_ARG( rReq, pLinkItem, SfxBoolItem, FN_PARAM_4, sal_False );
1268                         SFX_REQUEST_ARG( rReq, pMoveItem, SfxInt16Item, FN_PARAM_5, sal_False );
1269                         if ( pFuncItem )
1270                             nFunction = pFuncItem->GetValue();
1271                         if ( pSkipItem )
1272                             bSkipEmpty = pSkipItem->GetValue();
1273                         if ( pTransposeItem )
1274                             bTranspose = pTransposeItem->GetValue();
1275                         if ( pLinkItem )
1276                             bAsLink = pLinkItem->GetValue();
1277                         if ( pMoveItem )
1278                             eMoveMode = (InsCellCmd) pMoveItem->GetValue();
1279                     }
1280                     else
1281                     {
1282                         ScEditableTester aTester( pTabViewShell );
1283                         if (aTester.IsEditable())
1284                         {
1285                             //CHINA001 ScInsertContentsDlg* pDlg = new ScInsertContentsDlg( pTabViewShell->GetDialogParent() );
1286                             ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1287                             DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1288 
1289                             AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
1290                                                                                                     RID_SCDLG_INSCONT);
1291                             DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1292                             pDlg->SetOtherDoc( bOtherDoc );
1293                             // #53661# bei ChangeTrack MoveMode disablen
1294                             pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL );
1295                             // #72930# cut/move references may disable shift
1296                             // directions if source and destination ranges intersect
1297                             if ( !bOtherDoc )
1298                             {
1299                                 if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() )
1300                                 {
1301                                     ScViewData* pData = GetViewData();
1302                                     if ( pData->GetMarkData().GetTableSelect(
1303                                             pData->GetTabNo() ) )
1304                                     {
1305                                         SCCOL nPosX = pData->GetCurX();
1306                                         SCROW nPosY = pData->GetCurY();
1307                                         SCCOL nClipStartX, nClipSizeX;
1308                                         SCROW  nClipStartY, nClipSizeY;
1309                                         pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
1310                                         // for CutMode, filtered rows can always be included
1311                                         pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, sal_True );
1312                                         int nDisableShift = 0;
1313                                         if ( nClipStartX <= nPosX + nClipSizeX &&
1314                                                 nPosX <= nClipStartX + nClipSizeX )
1315                                             nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
1316                                         if ( nClipStartY <= nPosY + nClipSizeY &&
1317                                                 nPosY <= nClipStartY + nClipSizeY )
1318                                             nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
1319                                         if ( nDisableShift )
1320                                             pDlg->SetCellShiftDisabled( nDisableShift );
1321                                     }
1322                                 }
1323                             }
1324                             if (pDlg->Execute() == RET_OK)
1325                             {
1326                                 nFlags     = pDlg->GetInsContentsCmdBits();
1327                                 nFunction  = pDlg->GetFormulaCmdBits();
1328                                 bSkipEmpty = pDlg->IsSkipEmptyCells();
1329                                 bTranspose = pDlg->IsTranspose();
1330                                 bAsLink    = pDlg->IsLink();
1331                                 eMoveMode  = pDlg->GetMoveMode();
1332                             }
1333                             delete pDlg;
1334                         }
1335                         else
1336                             pTabViewShell->ErrorMessage(aTester.GetMessageId());
1337                     }
1338 
1339                     if( nFlags != IDF_NONE )
1340                     {
1341                         {
1342                             WaitObject aWait( GetViewData()->GetDialogParent() );
1343                             if ( bAsLink && bOtherDoc )
1344                                 pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK);  // DDE einfuegen
1345                             else
1346                                 pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
1347                                     nFunction, bSkipEmpty, bTranspose, bAsLink,
1348                                     eMoveMode, IDF_NONE, sal_True );    // allow warning dialog
1349                         }
1350 
1351                         if( !pReqArgs )
1352                         {
1353                             String  aFlags;
1354 
1355                             if( nFlags == IDF_ALL )
1356                             {
1357                                 aFlags += 'A';
1358                             }
1359                             else
1360                             {
1361                                 if( nFlags & IDF_STRING ) aFlags += 'S';
1362                                 if( nFlags & IDF_VALUE ) aFlags += 'V';
1363                                 if( nFlags & IDF_DATETIME ) aFlags += 'D';
1364                                 if( nFlags & IDF_FORMULA ) aFlags += 'F';
1365                                 if( nFlags & IDF_NOTE ) aFlags += 'N';
1366                                 if( nFlags & IDF_ATTRIB ) aFlags += 'T';
1367                             }
1368 
1369                             rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1370                             rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
1371                             rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
1372                             rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
1373                             rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) );
1374                             rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) );
1375                             rReq.Done();
1376                         }
1377                     }
1378                 }
1379             }
1380             pTabViewShell->CellContentChanged();        // => PasteFromXXX ???
1381             break;
1382 
1383         case SID_PASTE_SPECIAL:
1384             // Unterscheidung, ob eigene oder fremde Daten,
1385             // dadurch FID_INS_CELL_CONTENTS ueberfluessig
1386             {
1387                 Window* pWin = GetViewData()->GetActiveWin();
1388 
1389                 //  Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)"
1390                 const SfxPoolItem* pItem=NULL;
1391                 if ( pReqArgs &&
1392                      pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
1393                      pItem->ISA(SfxUInt32Item) )
1394                 {
1395                     sal_uLong nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
1396                     sal_Bool bRet=sal_True;
1397                     {
1398                         WaitObject aWait( GetViewData()->GetDialogParent() );
1399                         sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
1400                         if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
1401                             pTabViewShell->PasteDraw();
1402                         else
1403                             bRet = pTabViewShell->PasteFromSystem(nFormat, sal_True);       // TRUE: keine Fehlermeldungen
1404                     }
1405 
1406                     if ( bRet )
1407                     {
1408                         rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler
1409                         rReq.Done();
1410                     }
1411                     else
1412                         // if format is not available -> fallback to request without parameters
1413                         pItem = NULL;
1414                 }
1415 
1416                 if ( !pItem )
1417                 {
1418                     if ( ScTransferObj::GetOwnClipboard( pWin ) )  // own cell data
1419                     {
1420                         rReq.SetSlot( FID_INS_CELL_CONTENTS );
1421                         ExecuteSlot( rReq, GetInterface() );
1422                         rReq.SetReturnValue(SfxInt16Item(nSlot, 1));    // 1 = Erfolg
1423                     }
1424                     else                                    // Zeichenobjekte oder fremde Daten
1425                     {
1426                         sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
1427 
1428                         SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1429                         GetPossibleClipboardFormats( aFormats );
1430 
1431                         sal_uInt16 nFormatCount = aFormats.Count();
1432                         if ( nFormatCount )
1433                         {
1434                             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1435                             SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() );
1436                             if ( pDlg )
1437                             {
1438                             for (sal_uInt16 i=0; i<nFormatCount; i++)
1439                             {
1440                                 sal_uLong nFormatId = aFormats.GetClipbrdFormatId( i );
1441                                 String aName = aFormats.GetClipbrdFormatName( i );
1442                                 // special case for paste dialog: '*' is replaced by object type
1443                                 if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
1444                                     aName.Assign((sal_Unicode)'*');
1445                                 pDlg->Insert( nFormatId, aName );
1446                             }
1447 
1448                             TransferableDataHelper aDataHelper(
1449                                 TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
1450                             sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
1451                             if (nFormat > 0)
1452                             {
1453                                 {
1454                                     WaitObject aWait( GetViewData()->GetDialogParent() );
1455                                     if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
1456                                         pTabViewShell->PasteDraw();
1457                                     else
1458                                         pTabViewShell->PasteFromSystem(nFormat);
1459                                 }
1460                                 rReq.SetReturnValue(SfxInt16Item(nSlot, 1));    // 1 = Erfolg
1461                                 rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) );
1462                                 rReq.Done();
1463                             }
1464                             else
1465                             {
1466                                 rReq.SetReturnValue(SfxInt16Item(nSlot, 0));    // 0 = Fehler
1467                                 rReq.Ignore();
1468                             }
1469 
1470                             delete pDlg;
1471                             }
1472                         }
1473                         else
1474                             rReq.SetReturnValue(SfxInt16Item(nSlot, 0));        // 0 = Fehler
1475                     }
1476                 }
1477             }
1478             pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
1479             break;
1480 
1481         //
1482         //  sonstiges
1483         //
1484 
1485         case FID_INS_ROWBRK:
1486             pTabViewShell->InsertPageBreak( sal_False );
1487             rReq.Done();
1488             break;
1489 
1490         case FID_INS_COLBRK:
1491             pTabViewShell->InsertPageBreak( sal_True );
1492             rReq.Done();
1493             break;
1494 
1495         case FID_DEL_ROWBRK:
1496             pTabViewShell->DeletePageBreak( sal_False );
1497             rReq.Done();
1498             break;
1499 
1500         case FID_DEL_COLBRK:
1501             pTabViewShell->DeletePageBreak( sal_True );
1502             rReq.Done();
1503             break;
1504 
1505         case SID_DETECTIVE_ADD_PRED:
1506             pTabViewShell->DetectiveAddPred();
1507             rReq.Done();
1508             break;
1509 
1510         case SID_DETECTIVE_DEL_PRED:
1511             pTabViewShell->DetectiveDelPred();
1512             rReq.Done();
1513             break;
1514 
1515         case SID_DETECTIVE_ADD_SUCC:
1516             pTabViewShell->DetectiveAddSucc();
1517             rReq.Done();
1518             break;
1519 
1520         case SID_DETECTIVE_DEL_SUCC:
1521             pTabViewShell->DetectiveDelSucc();
1522             rReq.Done();
1523             break;
1524 
1525         case SID_DETECTIVE_ADD_ERR:
1526             pTabViewShell->DetectiveAddError();
1527             rReq.Done();
1528             break;
1529 
1530         case SID_DETECTIVE_INVALID:
1531             pTabViewShell->DetectiveMarkInvalid();
1532             rReq.Done();
1533             break;
1534 
1535         case SID_DETECTIVE_REFRESH:
1536             pTabViewShell->DetectiveRefresh();
1537             rReq.Done();
1538             break;
1539 
1540         case SID_SPELL_DIALOG:
1541 //           pTabViewShell->DoSpellingChecker();
1542             {
1543                 SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1544                 if( rReq.GetArgs() )
1545                     pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
1546                         static_cast< const SfxBoolItem& >( rReq.GetArgs()->
1547                             Get( SID_SPELL_DIALOG ) ).GetValue() );
1548                 else
1549                     pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
1550 
1551                 pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
1552                 rReq.Ignore();
1553             }
1554             break;
1555 
1556         case SID_HANGUL_HANJA_CONVERSION:
1557             pTabViewShell->DoHangulHanjaConversion();
1558             break;
1559 
1560         case SID_CHINESE_CONVERSION:
1561             {
1562                 //open ChineseTranslationDialog
1563                 Reference< XComponentContext > xContext(
1564                     ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1565                 if(xContext.is())
1566                 {
1567                     Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1568                     if(xMCF.is())
1569                     {
1570                         Reference< ui::dialogs::XExecutableDialog > xDialog(
1571                                 xMCF->createInstanceWithContext(
1572                                     rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
1573                                     , xContext), UNO_QUERY);
1574                         Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1575                         if( xInit.is() )
1576                         {
1577                             //  initialize dialog
1578                             Reference< awt::XWindow > xDialogParentWindow(0);
1579                             Sequence<Any> aSeq(1);
1580                             Any* pArray = aSeq.getArray();
1581                             PropertyValue aParam;
1582                             aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
1583                             aParam.Value <<= makeAny(xDialogParentWindow);
1584                             pArray[0] <<= makeAny(aParam);
1585                             xInit->initialize( aSeq );
1586 
1587                             //execute dialog
1588                             sal_Int16 nDialogRet = xDialog->execute();
1589                             if( RET_OK == nDialogRet )
1590                             {
1591                                 //get some parameters from the dialog
1592                                 sal_Bool bToSimplified = sal_True;
1593                                 sal_Bool bUseVariants = sal_True;
1594                                 sal_Bool bCommonTerms = sal_True;
1595                                 Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
1596                                 if( xProp.is() )
1597                                 {
1598                                     try
1599                                     {
1600                                         xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
1601                                         xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
1602                                         xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
1603                                     }
1604                                     catch( Exception& )
1605                                     {
1606                                     }
1607                                 }
1608 
1609                                 //execute translation
1610                                 LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
1611                                 LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
1612                                 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1613                                 if( !bCommonTerms )
1614                                     nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1615 
1616                                 Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont(
1617                                                     DEFAULTFONT_CJK_SPREADSHEET,
1618                                                     eTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
1619                                 ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
1620                                     eSourceLang, eTargetLang, aTargetFont, nOptions, false );
1621                                 pTabViewShell->DoSheetConversion( aConvParam );
1622                             }
1623                         }
1624                         Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1625                         if( xComponent.is() )
1626                             xComponent->dispose();
1627                     }
1628                 }
1629             }
1630             break;
1631 
1632         case SID_THESAURUS:
1633             pTabViewShell->DoThesaurus();
1634             break;
1635 
1636         case SID_TOGGLE_REL:
1637             pTabViewShell->DoRefConversion();
1638             break;
1639 
1640         case SID_DEC_INDENT:
1641             pTabViewShell->ChangeIndent( sal_False );
1642             break;
1643         case SID_INC_INDENT:
1644             pTabViewShell->ChangeIndent( sal_True );
1645             break;
1646 
1647         case FID_USE_NAME:
1648             {
1649                 sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags();
1650 
1651                 //CHINA001 ScNameCreateDlg* pDlg = new ScNameCreateDlg(     pTabViewShell->GetDialogParent(), nFlags );
1652                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1653                 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1654 
1655                 AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE );
1656                 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1657 
1658                 if( pDlg->Execute() )
1659                 {
1660                     nFlags = pDlg->GetFlags();
1661                     pTabViewShell->CreateNames(nFlags);
1662                     rReq.Done();
1663                 }
1664                 delete pDlg;
1665             }
1666             break;
1667 
1668         case SID_CONSOLIDATE:
1669             {
1670                 const SfxPoolItem* pItem;
1671                 if ( pReqArgs && SFX_ITEM_SET ==
1672                         pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, sal_True, &pItem ) )
1673                 {
1674                     const ScConsolidateParam& rParam =
1675                             ((const ScConsolidateItem*)pItem)->GetData();
1676 
1677                     pTabViewShell->Consolidate( rParam );
1678                     GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
1679 
1680                     rReq.Done();
1681                 }
1682                 else if (rReq.IsAPI())
1683                     SbxBase::SetError(SbxERR_BAD_PARAMETER);
1684             }
1685             break;
1686 
1687         case SID_INS_FUNCTION:
1688             {
1689                 const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK );
1690 
1691 //              pScMod->SetFunctionDlg( NULL );
1692 
1693                 if ( pOkItem->GetValue() )      // OK
1694                 {
1695                     String               aFormula;
1696                     const SfxStringItem* pSItem      = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING );
1697                     const SfxBoolItem*   pMatrixItem = (const SfxBoolItem*)  &pReqArgs->Get( SID_DLG_MATRIX );
1698 
1699                     aFormula += pSItem->GetValue();
1700                     pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
1701                 }
1702                 else                            // CANCEL
1703                 {
1704                     pScMod->ActivateInputWindow( NULL );
1705                 }
1706                 rReq.Ignore();      // only SID_ENTER_STRING is recorded
1707             }
1708             break;
1709 
1710         case FID_DEFINE_NAME:
1711             if ( pReqArgs )
1712             {
1713                 const SfxPoolItem* pItem;
1714                 String  aName, aSymbol, aAttrib;
1715 
1716                 if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) )
1717                     aName = ((const SfxStringItem*)pItem)->GetValue();
1718 
1719                 if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
1720                     aSymbol = ((const SfxStringItem*)pItem)->GetValue();
1721 
1722                 if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
1723                     aAttrib = ((const SfxStringItem*)pItem)->GetValue();
1724 
1725                 if ( aName.Len() && aSymbol.Len() )
1726                 {
1727                     if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
1728                         rReq.Done();
1729                     else
1730                         SbxBase::SetError( SbxERR_BAD_PARAMETER );  // Basic-Fehler
1731                 }
1732             }
1733             else
1734             {
1735                 sal_uInt16          nId  = ScNameDlgWrapper::GetChildWindowId();
1736                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1737                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1738 
1739                 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1740             }
1741             break;
1742 
1743         case SID_DEFINE_COLROWNAMERANGES:
1744             {
1745 
1746                 sal_uInt16          nId  = ScColRowNameRangesDlgWrapper::GetChildWindowId();
1747                 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1748                 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1749 
1750                 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1751 
1752             }
1753             break;
1754 
1755         case SID_UPDATECHART:
1756             {
1757                 sal_Bool bAll = sal_False;
1758 
1759                 if( pReqArgs )
1760                 {
1761                     const SfxPoolItem* pItem;
1762 
1763                     if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) )
1764                         bAll = ((const SfxBoolItem*)pItem)->GetValue();
1765                 }
1766 
1767                 pTabViewShell->UpdateCharts( bAll );
1768 
1769                 if( ! rReq.IsAPI() )
1770                 {
1771                     rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
1772                     rReq.Done();
1773                 }
1774             }
1775             break;
1776 
1777 
1778         case SID_TABOP:
1779             if (pReqArgs)
1780             {
1781                 const ScTabOpItem& rItem =
1782                         (const ScTabOpItem&)
1783                             pReqArgs->Get( SID_TABOP );
1784 
1785                 pTabViewShell->TabOp( rItem.GetData() );
1786 
1787                 rReq.Done( *pReqArgs );
1788             }
1789             break;
1790 
1791         case SID_SOLVE:
1792             if (pReqArgs)
1793             {
1794                 const ScSolveItem& rItem =
1795                         (const ScSolveItem&)
1796                             pReqArgs->Get( SCITEM_SOLVEDATA );
1797 
1798                 pTabViewShell->Solve( rItem.GetData() );
1799 
1800                 rReq.Done( *pReqArgs );
1801             }
1802             break;
1803 
1804         case FID_INSERT_NAME:
1805             {
1806                 ScDocument*     pDoc = GetViewData()->GetDocument();
1807                 //CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg(   pTabViewShell->GetDialogParent(), pDoc->GetRangeName() );
1808                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1809                 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1810 
1811                 AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE );
1812                 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1813                 switch( pDlg->Execute() )
1814                 {
1815                     case BTN_PASTE_LIST:
1816                         pTabViewShell->InsertNameList();
1817                         break;
1818                     case BTN_PASTE_NAME:
1819                         {
1820                             ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
1821                             if (pHdl)
1822                             {
1823                                 //  das "=" per Key-Event, schaltet in den Eingabe-Modus
1824                                 pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
1825 
1826                                 String aName = pDlg->GetSelectedName();
1827                                 pHdl->InsertFunction( aName, sal_False );       // ohne "()"
1828                             }
1829                         }
1830                         break;
1831                 }
1832                 delete pDlg;
1833             }
1834             break;
1835 
1836         case SID_RANGE_NOTETEXT:
1837             if (pReqArgs)
1838             {
1839                 const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT );
1840 
1841                 //  #43343# immer Cursorposition
1842                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1843                 pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
1844                 rReq.Done();
1845             }
1846             break;
1847 
1848         case SID_INSERT_POSTIT:
1849             if ( pReqArgs )
1850             {
1851                 const SvxPostItAuthorItem&  rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR );
1852                 const SvxPostItDateItem&    rDateItem   = (const SvxPostItDateItem&)  pReqArgs->Get( SID_ATTR_POSTIT_DATE );
1853                 const SvxPostItTextItem&    rTextItem   = (const SvxPostItTextItem&)  pReqArgs->Get( SID_ATTR_POSTIT_TEXT );
1854 
1855                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1856                 pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() );
1857                 rReq.Done();
1858             }
1859             else
1860             {
1861                 pTabViewShell->EditNote();                  // Zeichenobjekt zum Editieren
1862             }
1863             break;
1864 
1865         case FID_NOTE_VISIBLE:
1866             {
1867                 ScDocument* pDoc = GetViewData()->GetDocument();
1868                 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1869                 if( ScPostIt* pNote = pDoc->GetNote( aPos ) )
1870                 {
1871                     bool bShow;
1872                     const SfxPoolItem* pItem;
1873                     if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, sal_True, &pItem ) == SFX_ITEM_SET) )
1874                         bShow = ((const SfxBoolItem*) pItem)->GetValue();
1875                     else
1876                         bShow = !pNote->IsCaptionShown();
1877 
1878                     pTabViewShell->ShowNote( bShow );
1879 
1880                     if (!pReqArgs)
1881                         rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
1882 
1883                     rReq.Done();
1884                     rBindings.Invalidate( FID_NOTE_VISIBLE );
1885                 }
1886                 else
1887                     rReq.Ignore();
1888             }
1889             break;
1890 
1891         case SID_DELETE_NOTE:
1892             pTabViewShell->DeleteContents( IDF_NOTE );      // delete all notes in selection
1893             rReq.Done();
1894             break;
1895 
1896         case SID_CHARMAP:
1897             if( pReqArgs != NULL )
1898             {
1899                 String aChars, aFontName;
1900                 const SfxItemSet *pArgs = rReq.GetArgs();
1901                 const SfxPoolItem* pItem = 0;
1902                 if ( pArgs )
1903                     pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
1904                 if ( pItem )
1905                 {
1906                     const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem );
1907                     if ( pStringItem )
1908                         aChars = pStringItem->GetValue();
1909                     const SfxPoolItem* pFtItem = NULL;
1910                     pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
1911                     const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
1912                     if ( pFontItem )
1913                         aFontName = pFontItem->GetValue();
1914                 }
1915 
1916                 if ( aChars.Len() )
1917                 {
1918                     Font aFont;
1919                     pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
1920                                                                 pTabViewShell->GetSelectionScriptType() );
1921                     if ( aFontName.Len() )
1922                         aFont = Font( aFontName, Size(1,1) );
1923                     pTabViewShell->InsertSpecialChar( aChars, aFont );
1924                     if( ! rReq.IsAPI() )
1925                         rReq.Done();
1926                 }
1927             }
1928             else
1929             {
1930                 //CHINA001 SvxCharacterMap* pDlg = new SvxCharacterMap(     pTabViewShell->GetDialogParent(), sal_False );
1931                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1932 
1933                 // font color doesn't matter here
1934                 Font             aCurFont;
1935                 pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
1936                                                                 pTabViewShell->GetSelectionScriptType() );
1937 
1938                 SfxAllItemSet aSet( GetPool() );
1939                 aSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
1940                 aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
1941 
1942                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
1943                     pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
1944 
1945                 if ( pDlg->Execute() == RET_OK )
1946                 {
1947                     SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False );
1948                     SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
1949 
1950                     if ( pItem && pFontItem )
1951                     {
1952                         Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) );
1953                         aNewFont.SetCharSet( pFontItem->GetCharSet() );
1954                         aNewFont.SetPitch( pFontItem->GetPitch() );
1955                         pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont );
1956                         rReq.AppendItem( *pFontItem );
1957                         rReq.AppendItem( *pItem );
1958                         rReq.Done();
1959                     }
1960                 }
1961                 delete pDlg;
1962             }
1963             break;
1964 
1965         case SID_SELECT_SCENARIO:
1966             {
1967                 // Testing
1968 
1969                 if ( pReqArgs )
1970                 {
1971                     const SfxStringItem* pItem =
1972                         (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO );
1973 
1974                     if( pItem )
1975                     {
1976                         pTabViewShell->UseScenario( pItem->GetValue() );
1977                         //! wofuer soll der Return-Wert gut sein?!?!
1978                         rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
1979                         rReq.Done();
1980                     }
1981                     else
1982                     {
1983                         DBG_ERROR("NULL");
1984                     }
1985                 }
1986             }
1987             break;
1988 
1989         case SID_HYPERLINK_SETLINK:
1990             if( pReqArgs )
1991             {
1992                 const SfxPoolItem* pItem;
1993                 if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) )
1994                 {
1995                     const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
1996                     const String& rName   = pHyper->GetName();
1997                     const String& rURL    = pHyper->GetURL();
1998                     const String& rTarget = pHyper->GetTargetFrame();
1999                     sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode();
2000 
2001                     pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
2002                     rReq.Done();
2003                 }
2004                 else
2005                     rReq.Ignore();
2006             }
2007             break;
2008 
2009         case FID_CONDITIONAL_FORMAT:
2010             if( pReqArgs )
2011             {
2012                 const SfxPoolItem* pItem;
2013                 if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) )
2014                 {
2015                     // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
2016                     // hat wieder zurueckschalten:
2017                     if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() )
2018                     {
2019                         pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() );
2020                         pTabViewShell->PaintExtras();
2021                     }
2022 
2023                     const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem;
2024                     pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() );
2025                     rReq.Done();
2026                 }
2027             }
2028             break;
2029 
2030         case SID_EXTERNAL_SOURCE:
2031             {
2032                 String aFile;
2033                 String aFilter;
2034                 String aOptions;
2035                 String aSource;
2036                 sal_uLong nRefresh=0;
2037 
2038                 SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, sal_False );
2039                 SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, sal_False );
2040                 if ( pFile && pSource )
2041                 {
2042                     aFile = pFile->GetValue();
2043                     aSource = pSource->GetValue();
2044                     SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, sal_False );
2045                     if ( pFilter )
2046                         aFilter = pFilter->GetValue();
2047                     SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
2048                     if ( pOptions )
2049                         aOptions = pOptions->GetValue();
2050                     SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, sal_False );
2051                     if ( pRefresh )
2052                         nRefresh = pRefresh->GetValue();
2053                 }
2054                 else
2055                 {
2056                     //CHINA001 ScLinkedAreaDlg* pDlg = new ScLinkedAreaDlg( pTabViewShell->GetDialogParent() );
2057                     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
2058                     DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
2059 
2060                     delete pImpl->m_pLinkedDlg;
2061                     pImpl->m_pLinkedDlg =
2062                         pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(),
2063                                                       RID_SCDLG_LINKAREA);
2064                     DBG_ASSERT(pImpl->m_pLinkedDlg, "Dialog create fail!");//CHINA001
2065                     delete pImpl->m_pRequest;
2066                     pImpl->m_pRequest = new SfxRequest( rReq );
2067                     pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
2068                     return;
2069                 }
2070 
2071                 ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
2072             }
2073             break;
2074 
2075         //
2076         //
2077         //
2078 
2079         default:
2080             DBG_ERROR("falscher Slot bei ExecuteEdit");
2081             break;
2082     }
2083 }
2084 
2085 void ScCellShell::ExecuteTrans( SfxRequest& rReq )
2086 {
2087     sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
2088     if ( nType )
2089     {
2090         GetViewData()->GetView()->TransliterateText( nType );
2091         rReq.Done();
2092     }
2093 }
2094 
2095 void ScCellShell::ExecuteExternalSource(
2096     const String& _rFile, const String& _rFilter, const String& _rOptions,
2097     const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
2098 {
2099     if ( _rFile.Len() && _rSource.Len() )         // filter may be empty
2100     {
2101         ScRange aLinkRange;
2102         sal_Bool bMove = sal_False;
2103 
2104         ScViewData* pData = GetViewData();
2105         ScMarkData& rMark = pData->GetMarkData();
2106         rMark.MarkToSimple();
2107         if ( rMark.IsMarked() )
2108         {
2109             rMark.GetMarkArea( aLinkRange );
2110             bMove = sal_True;                       // insert/delete cells to fit range
2111         }
2112         else
2113             aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2114 
2115         ScDocFunc aFunc(*pData->GetDocShell());
2116         aFunc.InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
2117                                 aLinkRange, _nRefresh, bMove, sal_False );
2118         _rRequest.Done();
2119     }
2120     else
2121         _rRequest.Ignore();
2122 }
2123 
2124 IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
2125 {
2126     DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
2127     DBG_ASSERT( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" );
2128     String sFile, sFilter, sOptions, sSource;
2129     sal_uLong nRefresh = 0;
2130 
2131     if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
2132     {
2133         sFile = pImpl->m_pLinkedDlg->GetURL();
2134         sFilter = pImpl->m_pLinkedDlg->GetFilter();
2135         sOptions = pImpl->m_pLinkedDlg->GetOptions();
2136         sSource = pImpl->m_pLinkedDlg->GetSource();
2137         nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
2138         if ( sFile.Len() )
2139             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
2140         if ( sFilter.Len() )
2141             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
2142         if ( sOptions.Len() )
2143             pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2144         if ( sSource.Len() )
2145             pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
2146         if ( nRefresh )
2147             pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
2148     }
2149 
2150     ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
2151     return 0;
2152 }
2153 
2154 void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
2155 {
2156     Window* pWin = pViewData->GetActiveWin();
2157     ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
2158     ScDocument* pThisDoc = pViewData->GetDocument();
2159     ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
2160                          pViewData->GetCurY(), pViewData->GetTabNo() );
2161     if ( pOwnClip && pDPObj )
2162     {
2163         // paste from Calc into DataPilot table: sort (similar to drag & drop)
2164 
2165         ScDocument* pClipDoc = pOwnClip->GetDocument();
2166         SCTAB nSourceTab = pOwnClip->GetVisibleTab();
2167 
2168         SCCOL nClipStartX;
2169         SCROW nClipStartY;
2170         SCCOL nClipEndX;
2171         SCROW nClipEndY;
2172         pClipDoc->GetClipStart( nClipStartX, nClipStartY );
2173         pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True );
2174         nClipEndX = nClipEndX + nClipStartX;
2175         nClipEndY = nClipEndY + nClipStartY;   // GetClipArea returns the difference
2176 
2177         ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
2178         sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
2179         if ( !bDone )
2180             pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
2181     }
2182     else
2183     {
2184         // normal paste
2185         WaitObject aWait( pViewData->GetDialogParent() );
2186         if (!pOwnClip)
2187             pTabViewShell->PasteFromSystem();
2188         else
2189         {
2190             ScDocument* pClipDoc = pOwnClip->GetDocument();
2191             sal_uInt16 nFlags = IDF_ALL;
2192             if (pClipDoc->GetClipParam().isMultiRange())
2193                 // For multi-range paste, we paste values by default.
2194                 nFlags &= ~IDF_FORMULA;
2195 
2196             pTabViewShell->PasteFromClip( nFlags, pClipDoc,
2197                     PASTE_NOFUNC, sal_False, sal_False, sal_False, INS_NONE, IDF_NONE,
2198                     bShowDialog );      // allow warning dialog
2199         }
2200     }
2201     pTabViewShell->CellContentChanged();        // => PasteFromSystem() ???
2202 }
2203