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 //------------------------------------------------------------------
ExecuteEdit(SfxRequest & rReq)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 )
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 pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, sal_True );
1311 int nDisableShift = 0;
1312 if ( MAXCOL <= nPosX + nClipSizeX )
1313 nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
1314 if ( MAXROW <= nPosY + nClipSizeY )
1315 nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
1316 if ( nDisableShift )
1317 pDlg->SetCellShiftDisabled( nDisableShift );
1318 }
1319 }
1320 }
1321 if (pDlg->Execute() == RET_OK)
1322 {
1323 nFlags = pDlg->GetInsContentsCmdBits();
1324 nFunction = pDlg->GetFormulaCmdBits();
1325 bSkipEmpty = pDlg->IsSkipEmptyCells();
1326 bTranspose = pDlg->IsTranspose();
1327 bAsLink = pDlg->IsLink();
1328 eMoveMode = pDlg->GetMoveMode();
1329 }
1330 delete pDlg;
1331 }
1332 else
1333 pTabViewShell->ErrorMessage(aTester.GetMessageId());
1334 }
1335
1336 if( nFlags != IDF_NONE )
1337 {
1338 {
1339 WaitObject aWait( GetViewData()->GetDialogParent() );
1340 if ( bAsLink && bOtherDoc )
1341 pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK); // DDE einfuegen
1342 else
1343 pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
1344 nFunction, bSkipEmpty, bTranspose, bAsLink,
1345 eMoveMode, IDF_NONE, sal_True ); // allow warning dialog
1346 }
1347
1348 if( !pReqArgs )
1349 {
1350 String aFlags;
1351
1352 if( nFlags == IDF_ALL )
1353 {
1354 aFlags += 'A';
1355 }
1356 else
1357 {
1358 if( nFlags & IDF_STRING ) aFlags += 'S';
1359 if( nFlags & IDF_VALUE ) aFlags += 'V';
1360 if( nFlags & IDF_DATETIME ) aFlags += 'D';
1361 if( nFlags & IDF_FORMULA ) aFlags += 'F';
1362 if( nFlags & IDF_NOTE ) aFlags += 'N';
1363 if( nFlags & IDF_ATTRIB ) aFlags += 'T';
1364 }
1365
1366 rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
1367 rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
1368 rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
1369 rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
1370 rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) );
1371 rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) );
1372 rReq.Done();
1373 }
1374 }
1375 }
1376 }
1377 pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
1378 break;
1379
1380 case SID_PASTE_SPECIAL:
1381 // Unterscheidung, ob eigene oder fremde Daten,
1382 // dadurch FID_INS_CELL_CONTENTS ueberfluessig
1383 {
1384 Window* pWin = GetViewData()->GetActiveWin();
1385
1386 // Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)"
1387 const SfxPoolItem* pItem=NULL;
1388 if ( pReqArgs &&
1389 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
1390 pItem->ISA(SfxUInt32Item) )
1391 {
1392 sal_uLong nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
1393 sal_Bool bRet=sal_True;
1394 {
1395 WaitObject aWait( GetViewData()->GetDialogParent() );
1396 sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
1397 if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
1398 pTabViewShell->PasteDraw();
1399 else
1400 bRet = pTabViewShell->PasteFromSystem(nFormat, sal_True); // TRUE: keine Fehlermeldungen
1401 }
1402
1403 if ( bRet )
1404 {
1405 rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler
1406 rReq.Done();
1407 }
1408 else
1409 // if format is not available -> fallback to request without parameters
1410 pItem = NULL;
1411 }
1412
1413 if ( !pItem )
1414 {
1415 if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data
1416 {
1417 rReq.SetSlot( FID_INS_CELL_CONTENTS );
1418 ExecuteSlot( rReq, GetInterface() );
1419 rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
1420 }
1421 else // Zeichenobjekte oder fremde Daten
1422 {
1423 sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
1424
1425 SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1426 GetPossibleClipboardFormats( aFormats );
1427
1428 sal_uInt16 nFormatCount = aFormats.Count();
1429 if ( nFormatCount )
1430 {
1431 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1432 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() );
1433 if ( pDlg )
1434 {
1435 for (sal_uInt16 i=0; i<nFormatCount; i++)
1436 {
1437 sal_uLong nFormatId = aFormats.GetClipbrdFormatId( i );
1438 String aName = aFormats.GetClipbrdFormatName( i );
1439 // special case for paste dialog: '*' is replaced by object type
1440 if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
1441 aName.Assign((sal_Unicode)'*');
1442 pDlg->Insert( nFormatId, aName );
1443 }
1444
1445 TransferableDataHelper aDataHelper(
1446 TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
1447 sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
1448 if (nFormat > 0)
1449 {
1450 {
1451 WaitObject aWait( GetViewData()->GetDialogParent() );
1452 if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
1453 pTabViewShell->PasteDraw();
1454 else
1455 pTabViewShell->PasteFromSystem(nFormat);
1456 }
1457 rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
1458 rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) );
1459 rReq.Done();
1460 }
1461 else
1462 {
1463 rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
1464 rReq.Ignore();
1465 }
1466
1467 delete pDlg;
1468 }
1469 }
1470 else
1471 rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
1472 }
1473 }
1474 }
1475 pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
1476 break;
1477
1478 //
1479 // sonstiges
1480 //
1481
1482 case FID_INS_ROWBRK:
1483 pTabViewShell->InsertPageBreak( sal_False );
1484 rReq.Done();
1485 break;
1486
1487 case FID_INS_COLBRK:
1488 pTabViewShell->InsertPageBreak( sal_True );
1489 rReq.Done();
1490 break;
1491
1492 case FID_DEL_ROWBRK:
1493 pTabViewShell->DeletePageBreak( sal_False );
1494 rReq.Done();
1495 break;
1496
1497 case FID_DEL_COLBRK:
1498 pTabViewShell->DeletePageBreak( sal_True );
1499 rReq.Done();
1500 break;
1501
1502 case SID_DETECTIVE_ADD_PRED:
1503 pTabViewShell->DetectiveAddPred();
1504 rReq.Done();
1505 break;
1506
1507 case SID_DETECTIVE_DEL_PRED:
1508 pTabViewShell->DetectiveDelPred();
1509 rReq.Done();
1510 break;
1511
1512 case SID_DETECTIVE_ADD_SUCC:
1513 pTabViewShell->DetectiveAddSucc();
1514 rReq.Done();
1515 break;
1516
1517 case SID_DETECTIVE_DEL_SUCC:
1518 pTabViewShell->DetectiveDelSucc();
1519 rReq.Done();
1520 break;
1521
1522 case SID_DETECTIVE_ADD_ERR:
1523 pTabViewShell->DetectiveAddError();
1524 rReq.Done();
1525 break;
1526
1527 case SID_DETECTIVE_INVALID:
1528 pTabViewShell->DetectiveMarkInvalid();
1529 rReq.Done();
1530 break;
1531
1532 case SID_DETECTIVE_REFRESH:
1533 pTabViewShell->DetectiveRefresh();
1534 rReq.Done();
1535 break;
1536
1537 case SID_SPELL_DIALOG:
1538 // pTabViewShell->DoSpellingChecker();
1539 {
1540 SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
1541 if( rReq.GetArgs() )
1542 pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
1543 static_cast< const SfxBoolItem& >( rReq.GetArgs()->
1544 Get( SID_SPELL_DIALOG ) ).GetValue() );
1545 else
1546 pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
1547
1548 pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
1549 rReq.Ignore();
1550 }
1551 break;
1552
1553 case SID_HANGUL_HANJA_CONVERSION:
1554 pTabViewShell->DoHangulHanjaConversion();
1555 break;
1556
1557 case SID_CHINESE_CONVERSION:
1558 {
1559 //open ChineseTranslationDialog
1560 Reference< XComponentContext > xContext(
1561 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1562 if(xContext.is())
1563 {
1564 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1565 if(xMCF.is())
1566 {
1567 Reference< ui::dialogs::XExecutableDialog > xDialog(
1568 xMCF->createInstanceWithContext(
1569 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
1570 , xContext), UNO_QUERY);
1571 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1572 if( xInit.is() )
1573 {
1574 // initialize dialog
1575 Reference< awt::XWindow > xDialogParentWindow(0);
1576 Sequence<Any> aSeq(1);
1577 Any* pArray = aSeq.getArray();
1578 PropertyValue aParam;
1579 aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
1580 aParam.Value <<= makeAny(xDialogParentWindow);
1581 pArray[0] <<= makeAny(aParam);
1582 xInit->initialize( aSeq );
1583
1584 //execute dialog
1585 sal_Int16 nDialogRet = xDialog->execute();
1586 if( RET_OK == nDialogRet )
1587 {
1588 //get some parameters from the dialog
1589 sal_Bool bToSimplified = sal_True;
1590 sal_Bool bUseVariants = sal_True;
1591 sal_Bool bCommonTerms = sal_True;
1592 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
1593 if( xProp.is() )
1594 {
1595 try
1596 {
1597 xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
1598 xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
1599 xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
1600 }
1601 catch( Exception& )
1602 {
1603 }
1604 }
1605
1606 //execute translation
1607 LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
1608 LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
1609 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1610 if( !bCommonTerms )
1611 nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1612
1613 Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont(
1614 DEFAULTFONT_CJK_SPREADSHEET,
1615 eTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
1616 ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
1617 eSourceLang, eTargetLang, aTargetFont, nOptions, false );
1618 pTabViewShell->DoSheetConversion( aConvParam );
1619 }
1620 }
1621 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1622 if( xComponent.is() )
1623 xComponent->dispose();
1624 }
1625 }
1626 }
1627 break;
1628
1629 case SID_THESAURUS:
1630 pTabViewShell->DoThesaurus();
1631 break;
1632
1633 case SID_TOGGLE_REL:
1634 pTabViewShell->DoRefConversion();
1635 break;
1636
1637 case SID_DEC_INDENT:
1638 pTabViewShell->ChangeIndent( sal_False );
1639 break;
1640 case SID_INC_INDENT:
1641 pTabViewShell->ChangeIndent( sal_True );
1642 break;
1643
1644 case FID_USE_NAME:
1645 {
1646 sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags();
1647
1648 //CHINA001 ScNameCreateDlg* pDlg = new ScNameCreateDlg( pTabViewShell->GetDialogParent(), nFlags );
1649 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1650 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1651
1652 AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE );
1653 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1654
1655 if( pDlg->Execute() )
1656 {
1657 nFlags = pDlg->GetFlags();
1658 pTabViewShell->CreateNames(nFlags);
1659 rReq.Done();
1660 }
1661 delete pDlg;
1662 }
1663 break;
1664
1665 case SID_CONSOLIDATE:
1666 {
1667 const SfxPoolItem* pItem;
1668 if ( pReqArgs && SFX_ITEM_SET ==
1669 pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, sal_True, &pItem ) )
1670 {
1671 const ScConsolidateParam& rParam =
1672 ((const ScConsolidateItem*)pItem)->GetData();
1673
1674 pTabViewShell->Consolidate( rParam );
1675 GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
1676
1677 rReq.Done();
1678 }
1679 else if (rReq.IsAPI())
1680 SbxBase::SetError(SbxERR_BAD_PARAMETER);
1681 }
1682 break;
1683
1684 case SID_INS_FUNCTION:
1685 {
1686 const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK );
1687
1688 // pScMod->SetFunctionDlg( NULL );
1689
1690 if ( pOkItem->GetValue() ) // OK
1691 {
1692 String aFormula;
1693 const SfxStringItem* pSItem = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING );
1694 const SfxBoolItem* pMatrixItem = (const SfxBoolItem*) &pReqArgs->Get( SID_DLG_MATRIX );
1695
1696 aFormula += pSItem->GetValue();
1697 pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
1698 }
1699 else // CANCEL
1700 {
1701 pScMod->ActivateInputWindow( NULL );
1702 }
1703 rReq.Ignore(); // only SID_ENTER_STRING is recorded
1704 }
1705 break;
1706
1707 case FID_DEFINE_NAME:
1708 if ( pReqArgs )
1709 {
1710 const SfxPoolItem* pItem;
1711 String aName, aSymbol, aAttrib;
1712
1713 if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) )
1714 aName = ((const SfxStringItem*)pItem)->GetValue();
1715
1716 if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
1717 aSymbol = ((const SfxStringItem*)pItem)->GetValue();
1718
1719 if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
1720 aAttrib = ((const SfxStringItem*)pItem)->GetValue();
1721
1722 if ( aName.Len() && aSymbol.Len() )
1723 {
1724 if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
1725 rReq.Done();
1726 else
1727 SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
1728 }
1729 }
1730 else
1731 {
1732 sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
1733 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1734 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1735
1736 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1737 }
1738 break;
1739
1740 case SID_DEFINE_COLROWNAMERANGES:
1741 {
1742
1743 sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
1744 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
1745 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
1746
1747 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1748
1749 }
1750 break;
1751
1752 case SID_UPDATECHART:
1753 {
1754 sal_Bool bAll = sal_False;
1755
1756 if( pReqArgs )
1757 {
1758 const SfxPoolItem* pItem;
1759
1760 if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) )
1761 bAll = ((const SfxBoolItem*)pItem)->GetValue();
1762 }
1763
1764 pTabViewShell->UpdateCharts( bAll );
1765
1766 if( ! rReq.IsAPI() )
1767 {
1768 rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
1769 rReq.Done();
1770 }
1771 }
1772 break;
1773
1774
1775 case SID_TABOP:
1776 if (pReqArgs)
1777 {
1778 const ScTabOpItem& rItem =
1779 (const ScTabOpItem&)
1780 pReqArgs->Get( SID_TABOP );
1781
1782 pTabViewShell->TabOp( rItem.GetData() );
1783
1784 rReq.Done( *pReqArgs );
1785 }
1786 break;
1787
1788 case SID_SOLVE:
1789 if (pReqArgs)
1790 {
1791 const ScSolveItem& rItem =
1792 (const ScSolveItem&)
1793 pReqArgs->Get( SCITEM_SOLVEDATA );
1794
1795 pTabViewShell->Solve( rItem.GetData() );
1796
1797 rReq.Done( *pReqArgs );
1798 }
1799 break;
1800
1801 case FID_INSERT_NAME:
1802 {
1803 ScDocument* pDoc = GetViewData()->GetDocument();
1804 //CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName() );
1805 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1806 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1807
1808 AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE );
1809 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1810 switch( pDlg->Execute() )
1811 {
1812 case BTN_PASTE_LIST:
1813 pTabViewShell->InsertNameList();
1814 break;
1815 case BTN_PASTE_NAME:
1816 {
1817 ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
1818 if (pHdl)
1819 {
1820 // das "=" per Key-Event, schaltet in den Eingabe-Modus
1821 pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
1822
1823 String aName = pDlg->GetSelectedName();
1824 pHdl->InsertFunction( aName, sal_False ); // ohne "()"
1825 }
1826 }
1827 break;
1828 }
1829 delete pDlg;
1830 }
1831 break;
1832
1833 case SID_RANGE_NOTETEXT:
1834 if (pReqArgs)
1835 {
1836 const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT );
1837
1838 // #43343# immer Cursorposition
1839 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1840 pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
1841 rReq.Done();
1842 }
1843 break;
1844
1845 case SID_INSERT_POSTIT:
1846 if ( pReqArgs )
1847 {
1848 const SvxPostItAuthorItem& rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR );
1849 const SvxPostItDateItem& rDateItem = (const SvxPostItDateItem&) pReqArgs->Get( SID_ATTR_POSTIT_DATE );
1850 const SvxPostItTextItem& rTextItem = (const SvxPostItTextItem&) pReqArgs->Get( SID_ATTR_POSTIT_TEXT );
1851
1852 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1853 pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() );
1854 rReq.Done();
1855 }
1856 else
1857 {
1858 pTabViewShell->EditNote(); // Zeichenobjekt zum Editieren
1859 }
1860 break;
1861
1862 case FID_NOTE_VISIBLE:
1863 {
1864 ScDocument* pDoc = GetViewData()->GetDocument();
1865 ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1866 if( ScPostIt* pNote = pDoc->GetNote( aPos ) )
1867 {
1868 bool bShow;
1869 const SfxPoolItem* pItem;
1870 if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, sal_True, &pItem ) == SFX_ITEM_SET) )
1871 bShow = ((const SfxBoolItem*) pItem)->GetValue();
1872 else
1873 bShow = !pNote->IsCaptionShown();
1874
1875 pTabViewShell->ShowNote( bShow );
1876
1877 if (!pReqArgs)
1878 rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
1879
1880 rReq.Done();
1881 rBindings.Invalidate( FID_NOTE_VISIBLE );
1882 }
1883 else
1884 rReq.Ignore();
1885 }
1886 break;
1887
1888 case SID_DELETE_NOTE:
1889 pTabViewShell->DeleteContents( IDF_NOTE ); // delete all notes in selection
1890 rReq.Done();
1891 break;
1892
1893 case SID_CHARMAP:
1894 if( pReqArgs != NULL )
1895 {
1896 String aChars, aFontName;
1897 const SfxItemSet *pArgs = rReq.GetArgs();
1898 const SfxPoolItem* pItem = 0;
1899 if ( pArgs )
1900 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
1901 if ( pItem )
1902 {
1903 const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem );
1904 if ( pStringItem )
1905 aChars = pStringItem->GetValue();
1906 const SfxPoolItem* pFtItem = NULL;
1907 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
1908 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
1909 if ( pFontItem )
1910 aFontName = pFontItem->GetValue();
1911 }
1912
1913 if ( aChars.Len() )
1914 {
1915 Font aFont;
1916 pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
1917 pTabViewShell->GetSelectionScriptType() );
1918 if ( aFontName.Len() )
1919 aFont = Font( aFontName, Size(1,1) );
1920 pTabViewShell->InsertSpecialChar( aChars, aFont );
1921 if( ! rReq.IsAPI() )
1922 rReq.Done();
1923 }
1924 }
1925 else
1926 {
1927 //CHINA001 SvxCharacterMap* pDlg = new SvxCharacterMap( pTabViewShell->GetDialogParent(), sal_False );
1928 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1929
1930 // font color doesn't matter here
1931 Font aCurFont;
1932 pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
1933 pTabViewShell->GetSelectionScriptType() );
1934
1935 SfxAllItemSet aSet( GetPool() );
1936 aSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
1937 aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
1938
1939 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
1940 pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
1941
1942 if ( pDlg->Execute() == RET_OK )
1943 {
1944 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False );
1945 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
1946
1947 if ( pItem && pFontItem )
1948 {
1949 Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) );
1950 aNewFont.SetCharSet( pFontItem->GetCharSet() );
1951 aNewFont.SetPitch( pFontItem->GetPitch() );
1952 pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont );
1953 rReq.AppendItem( *pFontItem );
1954 rReq.AppendItem( *pItem );
1955 rReq.Done();
1956 }
1957 }
1958 delete pDlg;
1959 }
1960 break;
1961
1962 case SID_SELECT_SCENARIO:
1963 {
1964 // Testing
1965
1966 if ( pReqArgs )
1967 {
1968 const SfxStringItem* pItem =
1969 (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO );
1970
1971 if( pItem )
1972 {
1973 pTabViewShell->UseScenario( pItem->GetValue() );
1974 //! wofuer soll der Return-Wert gut sein?!?!
1975 rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
1976 rReq.Done();
1977 }
1978 else
1979 {
1980 DBG_ERROR("NULL");
1981 }
1982 }
1983 }
1984 break;
1985
1986 case SID_HYPERLINK_SETLINK:
1987 if( pReqArgs )
1988 {
1989 const SfxPoolItem* pItem;
1990 if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) )
1991 {
1992 const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
1993 const String& rName = pHyper->GetName();
1994 const String& rURL = pHyper->GetURL();
1995 const String& rTarget = pHyper->GetTargetFrame();
1996 sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode();
1997
1998 pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
1999 rReq.Done();
2000 }
2001 else
2002 rReq.Ignore();
2003 }
2004 break;
2005
2006 case FID_CONDITIONAL_FORMAT:
2007 if( pReqArgs )
2008 {
2009 const SfxPoolItem* pItem;
2010 if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) )
2011 {
2012 // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
2013 // hat wieder zurueckschalten:
2014 if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() )
2015 {
2016 pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() );
2017 pTabViewShell->PaintExtras();
2018 }
2019
2020 const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem;
2021 pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() );
2022 rReq.Done();
2023 }
2024 }
2025 break;
2026
2027 case SID_EXTERNAL_SOURCE:
2028 {
2029 String aFile;
2030 String aFilter;
2031 String aOptions;
2032 String aSource;
2033 sal_uLong nRefresh=0;
2034
2035 SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, sal_False );
2036 SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, sal_False );
2037 if ( pFile && pSource )
2038 {
2039 aFile = pFile->GetValue();
2040 aSource = pSource->GetValue();
2041 SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, sal_False );
2042 if ( pFilter )
2043 aFilter = pFilter->GetValue();
2044 SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
2045 if ( pOptions )
2046 aOptions = pOptions->GetValue();
2047 SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, sal_False );
2048 if ( pRefresh )
2049 nRefresh = pRefresh->GetValue();
2050 }
2051 else
2052 {
2053 //CHINA001 ScLinkedAreaDlg* pDlg = new ScLinkedAreaDlg( pTabViewShell->GetDialogParent() );
2054 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
2055 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
2056
2057 delete pImpl->m_pLinkedDlg;
2058 pImpl->m_pLinkedDlg =
2059 pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(),
2060 RID_SCDLG_LINKAREA);
2061 DBG_ASSERT(pImpl->m_pLinkedDlg, "Dialog create fail!");//CHINA001
2062 delete pImpl->m_pRequest;
2063 pImpl->m_pRequest = new SfxRequest( rReq );
2064 pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
2065 return;
2066 }
2067
2068 ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
2069 }
2070 break;
2071
2072 //
2073 //
2074 //
2075
2076 default:
2077 DBG_ERROR("falscher Slot bei ExecuteEdit");
2078 break;
2079 }
2080 }
2081
ExecuteTrans(SfxRequest & rReq)2082 void ScCellShell::ExecuteTrans( SfxRequest& rReq )
2083 {
2084 sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
2085 if ( nType )
2086 {
2087 GetViewData()->GetView()->TransliterateText( nType );
2088 rReq.Done();
2089 }
2090 }
2091
ExecuteExternalSource(const String & _rFile,const String & _rFilter,const String & _rOptions,const String & _rSource,sal_uLong _nRefresh,SfxRequest & _rRequest)2092 void ScCellShell::ExecuteExternalSource(
2093 const String& _rFile, const String& _rFilter, const String& _rOptions,
2094 const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
2095 {
2096 if ( _rFile.Len() && _rSource.Len() ) // filter may be empty
2097 {
2098 ScRange aLinkRange;
2099 sal_Bool bMove = sal_False;
2100
2101 ScViewData* pData = GetViewData();
2102 ScMarkData& rMark = pData->GetMarkData();
2103 rMark.MarkToSimple();
2104 if ( rMark.IsMarked() )
2105 {
2106 rMark.GetMarkArea( aLinkRange );
2107 bMove = sal_True; // insert/delete cells to fit range
2108 }
2109 else
2110 aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
2111
2112 ScDocFunc aFunc(*pData->GetDocShell());
2113 aFunc.InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
2114 aLinkRange, _nRefresh, bMove, sal_False );
2115 _rRequest.Done();
2116 }
2117 else
2118 _rRequest.Ignore();
2119 }
2120
IMPL_LINK(ScCellShell,DialogClosed,AbstractScLinkedAreaDlg *,EMPTYARG)2121 IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
2122 {
2123 DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
2124 DBG_ASSERT( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" );
2125 String sFile, sFilter, sOptions, sSource;
2126 sal_uLong nRefresh = 0;
2127
2128 if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
2129 {
2130 sFile = pImpl->m_pLinkedDlg->GetURL();
2131 sFilter = pImpl->m_pLinkedDlg->GetFilter();
2132 sOptions = pImpl->m_pLinkedDlg->GetOptions();
2133 sSource = pImpl->m_pLinkedDlg->GetSource();
2134 nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
2135 if ( sFile.Len() )
2136 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
2137 if ( sFilter.Len() )
2138 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
2139 if ( sOptions.Len() )
2140 pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2141 if ( sSource.Len() )
2142 pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
2143 if ( nRefresh )
2144 pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
2145 }
2146
2147 ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
2148 return 0;
2149 }
2150
PasteFromClipboard(ScViewData * pViewData,ScTabViewShell * pTabViewShell,bool bShowDialog)2151 void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
2152 {
2153 Window* pWin = pViewData->GetActiveWin();
2154 ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
2155 ScDocument* pThisDoc = pViewData->GetDocument();
2156 ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
2157 pViewData->GetCurY(), pViewData->GetTabNo() );
2158 if ( pOwnClip && pDPObj )
2159 {
2160 // paste from Calc into DataPilot table: sort (similar to drag & drop)
2161
2162 ScDocument* pClipDoc = pOwnClip->GetDocument();
2163 SCTAB nSourceTab = pOwnClip->GetVisibleTab();
2164
2165 SCCOL nClipStartX;
2166 SCROW nClipStartY;
2167 SCCOL nClipEndX;
2168 SCROW nClipEndY;
2169 pClipDoc->GetClipStart( nClipStartX, nClipStartY );
2170 pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True );
2171 nClipEndX = nClipEndX + nClipStartX;
2172 nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference
2173
2174 ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
2175 sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
2176 if ( !bDone )
2177 pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
2178 }
2179 else
2180 {
2181 // normal paste
2182 WaitObject aWait( pViewData->GetDialogParent() );
2183 if (!pOwnClip)
2184 pTabViewShell->PasteFromSystem();
2185 else
2186 {
2187 ScDocument* pClipDoc = pOwnClip->GetDocument();
2188 sal_uInt16 nFlags = IDF_ALL;
2189 if (pClipDoc->GetClipParam().isMultiRange())
2190 // For multi-range paste, we paste values by default.
2191 nFlags &= ~IDF_FORMULA;
2192
2193 pTabViewShell->PasteFromClip( nFlags, pClipDoc,
2194 PASTE_NOFUNC, sal_False, sal_False, sal_False, INS_NONE, IDF_NONE,
2195 bShowDialog ); // allow warning dialog
2196 }
2197 }
2198 pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
2199 }
2200