1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/i18n/TextConversionOption.hpp>
21 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
23 #include "scitems.hxx"
24 #include <sfx2/viewfrm.hxx>
26 #include <svl/stritem.hxx>
27 #include <svl/whiter.hxx>
28 #include <svl/zforlist.hxx>
29 #include <svl/zformat.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/request.hxx>
32 #include <vcl/msgbox.hxx>
33 #include <svx/svxdlg.hxx>
34 #include <sot/formats.hxx>
35 #include <svx/postattr.hxx>
36 #include <editeng/fontitem.hxx>
37 #include <svx/clipfmtitem.hxx>
38 #include <sfx2/passwd.hxx>
39 #include <svx/hlnkitem.hxx>
40 #include <basic/sbxcore.hxx>
41 #include <unotools/useroptions.hxx>
42 #include <vcl/waitobj.hxx>
43 #include <unotools/localedatawrapper.hxx>
47 #include "document.hxx"
48 #include "patattr.hxx"
50 #include "scresid.hxx"
51 #include "tabvwsh.hxx"
53 #include "reffind.hxx"
54 #include "uiitems.hxx"
55 #include "reffact.hxx"
56 #include "inputhdl.hxx"
57 #include "transobj.hxx"
58 #include "drwtrans.hxx"
59 #include "docfunc.hxx"
60 #include "editable.hxx"
61 #include "dpobject.hxx"
63 #include "dpgroup.hxx"
64 #include "spellparam.hxx"
66 #include "clipparam.hxx"
68 #include "dpsdbtab.hxx"
69 #include "dpshttab.hxx"
72 #include "cliputil.hxx"
73 #include "markdata.hxx"
74 #include "docpool.hxx"
75 #include "condformatdlg.hxx"
78 #include "globstr.hrc"
79 #include "scui_def.hxx"
80 #include <svx/dialogs.hrc>
81 #include "scabstdlg.hxx"
82 #include <tokenstringcontext.hxx>
83 #include <cellvalue.hxx>
84 #include <tokenarray.hxx>
85 #include <formulacell.hxx>
86 #include <gridwin.hxx>
87 #include <searchresults.hxx>
89 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
90 #include <com/sun/star/lang/XInitialization.hpp>
91 #include <com/sun/star/beans/PropertyValue.hpp>
92 #include <com/sun/star/beans/XPropertySet.hpp>
93 #include <cppuhelper/bootstrap.hxx>
94 #include <com/sun/star/i18n/TransliterationModules.hpp>
95 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
97 #include <boost/scoped_ptr.hpp>
99 using namespace ::com::sun::star
;
100 using namespace ::com::sun::star::beans
;
101 using namespace ::com::sun::star::uno
;
104 void ScCellShell::ExecuteEdit( SfxRequest
& rReq
)
106 ScModule
* pScMod
= SC_MOD();
107 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
108 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
109 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
110 sal_uInt16 nSlot
= rReq
.GetSlot();
112 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
115 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
119 case FID_DEFINE_NAME
:
122 case FID_INSERT_NAME
:
123 case SID_SPELL_DIALOG
:
124 case SID_HANGUL_HANJA_CONVERSION
:
125 case SID_OPENDLG_CONDFRMT
:
126 case SID_OPENDLG_COLORSCALE
:
127 case SID_OPENDLG_DATABAR
:
129 pScMod
->InputEnterHandler();
130 pTabViewShell
->UpdateInputHandler();
141 // insert / delete cells / rows / columns
145 pTabViewShell
->InsertCells(INS_INSROWS
);
150 pTabViewShell
->InsertCells(INS_INSCOLS
);
154 case FID_INS_CELLSDOWN
:
155 pTabViewShell
->InsertCells(INS_CELLSDOWN
);
159 case FID_INS_CELLSRIGHT
:
160 pTabViewShell
->InsertCells(INS_CELLSRIGHT
);
165 pTabViewShell
->DeleteCells( DEL_DELROWS
);
170 pTabViewShell
->DeleteCells( DEL_DELCOLS
);
176 InsCellCmd eCmd
=INS_NONE
;
180 const SfxPoolItem
* pItem
;
183 if( pReqArgs
->HasItem( FID_INS_CELL
, &pItem
) )
184 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
185 if( !aFlags
.isEmpty() )
189 case 'V': eCmd
= INS_CELLSDOWN
;break;
190 case '>': eCmd
= INS_CELLSRIGHT
;break;
191 case 'R': eCmd
= INS_INSROWS
;break;
192 case 'C': eCmd
= INS_INSCOLS
;break;
198 if ( GetViewData()->SimpleColMarked() )
200 else if ( GetViewData()->SimpleRowMarked() )
204 ScDocument
* pDoc
= GetViewData()->GetDocument();
205 bool bTheFlag
=(pDoc
->GetChangeTrack()!=NULL
);
207 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
208 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
210 boost::scoped_ptr
<AbstractScInsertCellDlg
> pDlg(pFact
->CreateScInsertCellDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_INSCELL
, bTheFlag
));
211 OSL_ENSURE(pDlg
, "Dialog create fail!");
212 if (pDlg
->Execute() == RET_OK
)
213 eCmd
= pDlg
->GetInsCellCmd();
219 pTabViewShell
->InsertCells( eCmd
);
227 case INS_CELLSDOWN
: aParam
= "V"; break;
228 case INS_CELLSRIGHT
: aParam
= ">"; break;
229 case INS_INSROWS
: aParam
= "R"; break;
230 case INS_INSCOLS
: aParam
= "C"; break;
233 // added to avoid warnings
236 rReq
.AppendItem( SfxStringItem( FID_INS_CELL
, aParam
) );
243 case FID_DELETE_CELL
:
245 DelCellCmd eCmd
= DEL_NONE
;
249 const SfxPoolItem
* pItem
;
252 if( pReqArgs
->HasItem( FID_DELETE_CELL
, &pItem
) )
253 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
254 if( !aFlags
.isEmpty() )
258 case 'U': eCmd
= DEL_CELLSUP
;break;
259 case 'L': eCmd
= DEL_CELLSLEFT
;break;
260 case 'R': eCmd
= DEL_DELROWS
;break;
261 case 'C': eCmd
= DEL_DELCOLS
;break;
267 if ( GetViewData()->SimpleColMarked() )
269 else if ( GetViewData()->SimpleRowMarked() )
274 ScDocument
* pDoc
= GetViewData()->GetDocument();
275 bool bTheFlag
=GetViewData()->IsMultiMarked() ||
276 (GetViewData()->GetSimpleArea(aRange
) == SC_MARK_SIMPLE_FILTERED
) ||
277 (pDoc
->GetChangeTrack() != NULL
);
279 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
280 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
282 boost::scoped_ptr
<AbstractScDeleteCellDlg
> pDlg(pFact
->CreateScDeleteCellDlg( pTabViewShell
->GetDialogParent(), bTheFlag
));
283 OSL_ENSURE(pDlg
, "Dialog create fail!");
285 if (pDlg
->Execute() == RET_OK
)
286 eCmd
= pDlg
->GetDelCellCmd();
290 if (eCmd
!= DEL_NONE
)
292 pTabViewShell
->DeleteCells( eCmd
);
300 case DEL_CELLSUP
: aParam
= "U"; break;
301 case DEL_CELLSLEFT
: aParam
= "L"; break;
302 case DEL_DELROWS
: aParam
= "R"; break;
303 case DEL_DELCOLS
: aParam
= "C"; break;
306 // added to avoid warnings
309 rReq
.AppendItem( SfxStringItem( FID_DELETE_CELL
, aParam
) );
317 // delete contents from cells
320 case SID_DELETE_CONTENTS
:
321 pTabViewShell
->DeleteContents( IDF_CONTENTS
);
327 sal_uInt16 nFlags
= IDF_NONE
;
329 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
331 const SfxPoolItem
* pItem
;
332 OUString
aFlags('A');
334 if( pReqArgs
->HasItem( SID_DELETE
, &pItem
) )
335 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
337 aFlags
= aFlags
.toAsciiUpperCase();
340 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
346 bCont
= false; // don't continue!
348 case 'S': nFlags
|= IDF_STRING
; break;
349 case 'V': nFlags
|= IDF_VALUE
; break;
350 case 'D': nFlags
|= IDF_DATETIME
; break;
351 case 'F': nFlags
|= IDF_FORMULA
; break;
352 case 'N': nFlags
|= IDF_NOTE
; break;
353 case 'T': nFlags
|= IDF_ATTRIB
; break;
354 case 'O': nFlags
|= IDF_OBJECTS
; break;
360 ScEditableTester
aTester( pTabViewShell
);
361 if (aTester
.IsEditable())
363 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
364 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
366 boost::scoped_ptr
<AbstractScDeleteContentsDlg
> pDlg(pFact
->CreateScDeleteContentsDlg(pTabViewShell
->GetDialogParent()));
367 OSL_ENSURE(pDlg
, "Dialog create fail!");
368 ScDocument
* pDoc
= GetViewData()->GetDocument();
369 SCTAB nTab
= GetViewData()->GetTabNo();
370 if ( pDoc
->IsTabProtected(nTab
) )
371 pDlg
->DisableObjects();
372 if (pDlg
->Execute() == RET_OK
)
374 nFlags
= pDlg
->GetDelContentsCmdBits();
378 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
381 if( nFlags
!= IDF_NONE
)
383 pTabViewShell
->DeleteContents( nFlags
);
389 if( nFlags
== IDF_ALL
)
395 if( nFlags
& IDF_STRING
) aFlags
+= "S";
396 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
397 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
398 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
399 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
400 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
401 if( nFlags
& IDF_OBJECTS
) aFlags
+= "O";
404 rReq
.AppendItem( SfxStringItem( SID_DELETE
, aFlags
) );
415 case FID_FILL_TO_BOTTOM
:
416 pTabViewShell
->FillSimple( FILL_TO_BOTTOM
);
420 case FID_FILL_TO_RIGHT
:
421 pTabViewShell
->FillSimple( FILL_TO_RIGHT
);
425 case FID_FILL_TO_TOP
:
426 pTabViewShell
->FillSimple( FILL_TO_TOP
);
430 case FID_FILL_TO_LEFT
:
431 pTabViewShell
->FillSimple( FILL_TO_LEFT
);
437 sal_uInt16 nFlags
= IDF_NONE
;
438 sal_uInt16 nFunction
= PASTE_NOFUNC
;
439 bool bSkipEmpty
= false;
440 bool bAsLink
= false;
442 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
444 const SfxPoolItem
* pItem
;
445 OUString
aFlags('A');
447 if( pReqArgs
->HasItem( FID_FILL_TAB
, &pItem
) )
448 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
450 aFlags
= aFlags
.toAsciiUpperCase();
453 for (sal_Int32 i
=0; bCont
&& i
< aFlags
.getLength(); ++i
)
459 bCont
= false; // don't continue!
461 case 'S': nFlags
|= IDF_STRING
; break;
462 case 'V': nFlags
|= IDF_VALUE
; break;
463 case 'D': nFlags
|= IDF_DATETIME
; break;
464 case 'F': nFlags
|= IDF_FORMULA
; break;
465 case 'N': nFlags
|= IDF_NOTE
; break;
466 case 'T': nFlags
|= IDF_ATTRIB
; break;
472 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
473 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
475 boost::scoped_ptr
<AbstractScInsertContentsDlg
> pDlg(pFact
->CreateScInsertContentsDlg( pTabViewShell
->GetDialogParent(),
476 0, /* nCheckDefaults */
477 &ScGlobal::GetRscString(STR_FILL_TAB
)));
478 OSL_ENSURE(pDlg
, "Dialog create fail!");
479 pDlg
->SetFillMode(true);
481 if (pDlg
->Execute() == RET_OK
)
483 nFlags
= pDlg
->GetInsContentsCmdBits();
484 nFunction
= pDlg
->GetFormulaCmdBits();
485 bSkipEmpty
= pDlg
->IsSkipEmptyCells();
486 bAsLink
= pDlg
->IsLink();
487 // there is no MoveMode with fill tabs
491 if( nFlags
!= IDF_NONE
)
493 pTabViewShell
->FillTab( nFlags
, nFunction
, bSkipEmpty
, bAsLink
);
499 if( nFlags
== IDF_ALL
)
505 if( nFlags
& IDF_STRING
) aFlags
+= "S";
506 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
507 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
508 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
509 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
510 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
513 rReq
.AppendItem( SfxStringItem( FID_FILL_TAB
, aFlags
) );
520 case FID_FILL_SERIES
:
528 sal_uInt16 nPossDir
= FDS_OPT_NONE
;
529 FillDir eFillDir
= FILL_TO_BOTTOM
;
530 FillCmd eFillCmd
= FILL_LINEAR
;
531 FillDateCmd eFillDateCmd
= FILL_DAY
;
532 double fStartVal
= MAXDOUBLE
;
534 double fMaxVal
= MAXDOUBLE
;
537 GetViewData()->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
538 nEndCol
, nEndRow
, nEndTab
);
540 if( nStartCol
!=nEndCol
)
542 nPossDir
|= FDS_OPT_HORZ
;
543 eFillDir
=FILL_TO_RIGHT
;
546 if( nStartRow
!=nEndRow
)
548 nPossDir
|= FDS_OPT_VERT
;
549 eFillDir
=FILL_TO_BOTTOM
;
552 ScDocument
* pDoc
= GetViewData()->GetDocument();
553 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
557 const SfxPoolItem
* pItem
;
558 OUString aFillDir
, aFillCmd
, aFillDateCmd
;
559 OUString aFillStep
, aFillStart
, aFillMax
;
565 if( pReqArgs
->HasItem( FID_FILL_SERIES
, &pItem
) )
566 aFillDir
= ((const SfxStringItem
*)pItem
)->GetValue();
567 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
568 aFillCmd
= ((const SfxStringItem
*)pItem
)->GetValue();
569 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
570 aFillDateCmd
= ((const SfxStringItem
*)pItem
)->GetValue();
571 if( pReqArgs
->HasItem( FN_PARAM_3
, &pItem
) )
572 aFillStep
= ((const SfxStringItem
*)pItem
)->GetValue();
573 if( pReqArgs
->HasItem( FN_PARAM_4
, &pItem
) )
574 aFillStart
= ((const SfxStringItem
*)pItem
)->GetValue();
575 if( pReqArgs
->HasItem( FN_PARAM_5
, &pItem
) )
576 aFillMax
= ((const SfxStringItem
*)pItem
)->GetValue();
578 if( !aFillDir
.isEmpty() )
579 switch( aFillDir
[0] )
581 case 'B': case 'b': eFillDir
=FILL_TO_BOTTOM
; break;
582 case 'R': case 'r': eFillDir
=FILL_TO_RIGHT
; break;
583 case 'T': case 't': eFillDir
=FILL_TO_TOP
; break;
584 case 'L': case 'l': eFillDir
=FILL_TO_LEFT
; break;
587 if( !aFillCmd
.isEmpty() )
588 switch( aFillCmd
[0] )
590 case 'S': case 's': eFillCmd
=FILL_SIMPLE
; break;
591 case 'L': case 'l': eFillCmd
=FILL_LINEAR
; break;
592 case 'G': case 'g': eFillCmd
=FILL_GROWTH
; break;
593 case 'D': case 'd': eFillCmd
=FILL_DATE
; break;
594 case 'A': case 'a': eFillCmd
=FILL_AUTO
; break;
597 if( !aFillDateCmd
.isEmpty() )
598 switch( aFillDateCmd
[0] )
600 case 'D': case 'd': eFillDateCmd
=FILL_DAY
; break;
601 case 'W': case 'w': eFillDateCmd
=FILL_WEEKDAY
; break;
602 case 'M': case 'm': eFillDateCmd
=FILL_MONTH
; break;
603 case 'Y': case 'y': eFillDateCmd
=FILL_YEAR
; break;
607 if( pFormatter
->IsNumberFormat( aFillStart
, nKey
, fTmpVal
))
611 if( pFormatter
->IsNumberFormat( aFillStep
, nKey
, fTmpVal
))
615 if( pFormatter
->IsNumberFormat( aFillMax
, nKey
, fTmpVal
))
621 else // (pReqArgs == NULL) => raise Dialog
623 sal_uInt32 nPrivFormat
;
625 pDoc
->GetNumberFormat( nStartCol
, nStartRow
, nStartTab
, nPrivFormat
);
626 pDoc
->GetCellType( nStartCol
, nStartRow
, nStartTab
,eCellType
);
627 const SvNumberformat
* pPrivEntry
= pFormatter
->GetEntry( nPrivFormat
);
630 OSL_FAIL("Numberformat not found !!!");
634 short nPrivType
= pPrivEntry
->GetType();
635 if ( ( nPrivType
& NUMBERFORMAT_DATE
)>0)
639 else if(eCellType
==CELLTYPE_STRING
)
648 // suggest default Startvalue only, when just 1 row or column
649 if ( nStartCol
== nEndCol
|| nStartRow
== nEndRow
)
651 double fInputEndVal
= 0.0;
654 pDoc
->GetInputString( nStartCol
, nStartRow
, nStartTab
, aStartStr
);
655 pDoc
->GetValue( nStartCol
, nStartRow
, nStartTab
, fStartVal
);
658 if(eFillDir
==FILL_TO_BOTTOM
&& nStartRow
< nEndRow
)
660 pDoc
->GetInputString( nStartCol
, nStartRow
+1, nStartTab
, aEndStr
);
661 if(!aEndStr
.isEmpty())
663 pDoc
->GetValue( nStartCol
, nStartRow
+1, nStartTab
, fInputEndVal
);
664 fIncVal
=fInputEndVal
-fStartVal
;
669 if(nStartCol
< nEndCol
)
671 pDoc
->GetInputString( nStartCol
+1, nStartRow
, nStartTab
, aEndStr
);
672 if(!aEndStr
.isEmpty())
674 pDoc
->GetValue( nStartCol
+1, nStartRow
, nStartTab
, fInputEndVal
);
675 fIncVal
=fInputEndVal
-fStartVal
;
679 if(eFillCmd
==FILL_DATE
)
681 Date aNullDate
= *pDoc
->GetFormatTable()->GetNullDate();
682 Date aStartDate
= aNullDate
;
683 aStartDate
+= (long)fStartVal
;
684 Date aEndDate
= aNullDate
;
685 aEndDate
+= (long)fInputEndVal
;
688 if(aStartDate
.GetYear()!=aEndDate
.GetYear())
690 eFillDateCmd
= FILL_YEAR
;
691 fTempDate
=aEndDate
.GetYear()-aStartDate
.GetYear();
693 if(aStartDate
.GetMonth()!=aEndDate
.GetMonth())
695 eFillDateCmd
= FILL_MONTH
;
696 fTempDate
=fTempDate
*12+aEndDate
.GetMonth()-aStartDate
.GetMonth();
698 if(aStartDate
.GetDay()==aEndDate
.GetDay())
704 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
705 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
707 boost::scoped_ptr
<AbstractScFillSeriesDlg
> pDlg(pFact
->CreateScFillSeriesDlg( pTabViewShell
->GetDialogParent(),
709 eFillDir
, eFillCmd
, eFillDateCmd
,
710 aStartStr
, fIncVal
, fMaxVal
,
712 OSL_ENSURE(pDlg
, "Dialog create fail!");
714 if ( nStartCol
!= nEndCol
&& nStartRow
!= nEndRow
)
716 pDlg
->SetEdStartValEnabled(false);
719 if ( pDlg
->Execute() == RET_OK
)
721 eFillDir
= pDlg
->GetFillDir();
722 eFillCmd
= pDlg
->GetFillCmd();
723 eFillDateCmd
= pDlg
->GetFillDateCmd();
725 if(eFillCmd
==FILL_AUTO
)
727 OUString aStr
= pDlg
->GetStartStr();
729 pTabViewShell
->EnterData( nStartCol
, nStartRow
, nStartTab
, aStr
);
731 fStartVal
= pDlg
->GetStart();
732 fIncVal
= pDlg
->GetStep();
733 fMaxVal
= pDlg
->GetMax();
740 //nScFillModeMouseModifier = 0; // no Ctrl/Copy
741 pTabViewShell
->FillSeries( eFillDir
, eFillCmd
, eFillDateCmd
, fStartVal
, fIncVal
, fMaxVal
);
750 case FILL_TO_BOTTOM
: aPara
= "B"; break;
751 case FILL_TO_RIGHT
: aPara
= "R"; break;
752 case FILL_TO_TOP
: aPara
= "T"; break;
753 case FILL_TO_LEFT
: aPara
= "L"; break;
756 rReq
.AppendItem( SfxStringItem( FID_FILL_SERIES
, aPara
) );
760 case FILL_SIMPLE
: aPara
= "S"; break;
761 case FILL_LINEAR
: aPara
= "L"; break;
762 case FILL_GROWTH
: aPara
= "G"; break;
763 case FILL_DATE
: aPara
= "D"; break;
764 case FILL_AUTO
: aPara
= "A"; break;
767 rReq
.AppendItem( SfxStringItem( FN_PARAM_1
, aPara
) );
769 switch( eFillDateCmd
)
771 case FILL_DAY
: aPara
= "D"; break;
772 case FILL_WEEKDAY
: aPara
= "W"; break;
773 case FILL_MONTH
: aPara
= "M"; break;
774 case FILL_YEAR
: aPara
= "Y"; break;
777 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, aPara
) );
779 sal_uLong nFormatKey
= pFormatter
->GetStandardFormat(NUMBERFORMAT_NUMBER
,
782 pFormatter
->GetOutputString( fIncVal
, nFormatKey
, aPara
, &pColor
);
783 rReq
.AppendItem( SfxStringItem( FN_PARAM_3
, aPara
) );
785 pFormatter
->GetOutputString( fStartVal
, nFormatKey
, aPara
, &pColor
);
786 rReq
.AppendItem( SfxStringItem( FN_PARAM_4
, aPara
) );
788 pFormatter
->GetOutputString( fMaxVal
, nFormatKey
, aPara
, &pColor
);
789 rReq
.AppendItem( SfxStringItem( FN_PARAM_5
, aPara
) );
803 SCTAB nStartTab
, nEndTab
;
805 GetViewData()->GetFillData( nStartCol
, nStartRow
, nEndCol
, nEndRow
);
806 SCCOL nFillCol
= GetViewData()->GetRefEndX();
807 SCROW nFillRow
= GetViewData()->GetRefEndY();
808 ScDocument
* pDoc
= GetViewData()->GetDocument();
810 if( pReqArgs
!= NULL
)
812 const SfxPoolItem
* pItem
;
814 if( pReqArgs
->HasItem( FID_FILL_AUTO
, &pItem
) )
816 ScAddress aScAddress
;
817 OUString aArg
= ((const SfxStringItem
*)pItem
)->GetValue();
819 if( aScAddress
.Parse( aArg
, pDoc
, pDoc
->GetAddressConvention() ) & SCA_VALID
)
821 nFillRow
= aScAddress
.Row();
822 nFillCol
= aScAddress
.Col();
826 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
827 nEndCol
,nEndRow
,nEndTab
);
829 else // call via mouse
831 // not in a merged cell
833 if ( nStartCol
== nEndCol
&& nStartRow
== nEndRow
)
835 SCCOL nMergeCol
= nStartCol
;
836 SCROW nMergeRow
= nStartRow
;
837 if ( GetViewData()->GetDocument()->ExtendMerge(
838 nStartCol
, nStartRow
, nMergeCol
, nMergeRow
,
839 GetViewData()->GetTabNo() ) )
841 if ( nFillCol
>= nStartCol
&& nFillCol
<= nMergeCol
&& nFillRow
== nStartRow
)
842 nFillCol
= nStartCol
;
843 if ( nFillRow
>= nStartRow
&& nFillRow
<= nMergeRow
&& nFillCol
== nStartCol
)
844 nFillRow
= nStartRow
;
849 if ( nFillCol
!= nEndCol
|| nFillRow
!= nEndRow
)
851 if ( nFillCol
==nEndCol
|| nFillRow
==nEndRow
)
853 FillDir eDir
= FILL_TO_BOTTOM
;
856 if ( nFillCol
==nEndCol
)
858 if ( nFillRow
> nEndRow
)
860 eDir
= FILL_TO_BOTTOM
;
861 nCount
= nFillRow
- nEndRow
;
863 else if ( nFillRow
< nStartRow
)
866 nCount
= nStartRow
- nFillRow
;
871 if ( nFillCol
> nEndCol
)
873 eDir
= FILL_TO_RIGHT
;
874 nCount
= nFillCol
- nEndCol
;
876 else if ( nFillCol
< nStartCol
)
879 nCount
= nStartCol
- nFillCol
;
885 pTabViewShell
->FillAuto( eDir
, nStartCol
, nStartRow
, nEndCol
, nEndRow
, nCount
);
889 ScAddress
aAdr( nFillCol
, nFillRow
, 0 );
890 OUString
aAdrStr(aAdr
.Format(SCR_ABS
, pDoc
, pDoc
->GetAddressConvention()));
892 rReq
.AppendItem( SfxStringItem( FID_FILL_AUTO
, aAdrStr
) );
900 OSL_FAIL( "Direction not unique for autofill" );
905 case FID_FILL_SINGLE_EDIT
:
906 ExecuteFillSingleEdit();
908 case SID_RANDOM_NUMBER_GENERATOR_DIALOG
:
910 sal_uInt16 nId
= ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
911 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
912 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
914 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
918 case SID_SAMPLING_DIALOG
:
920 sal_uInt16 nId
= ScSamplingDialogWrapper::GetChildWindowId();
921 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
922 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
924 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
927 case SID_DESCRIPTIVE_STATISTICS_DIALOG
:
929 sal_uInt16 nId
= ScDescriptiveStatisticsDialogWrapper::GetChildWindowId();
930 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
931 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
933 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
936 case SID_ANALYSIS_OF_VARIANCE_DIALOG
:
938 sal_uInt16 nId
= ScAnalysisOfVarianceDialogWrapper::GetChildWindowId();
939 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
940 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
942 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
945 case SID_CORRELATION_DIALOG
:
947 sal_uInt16 nId
= ScCorrelationDialogWrapper::GetChildWindowId();
948 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
949 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
951 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
954 case SID_COVARIANCE_DIALOG
:
956 sal_uInt16 nId
= ScCovarianceDialogWrapper::GetChildWindowId();
957 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
958 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
960 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
963 case SID_EXPONENTIAL_SMOOTHING_DIALOG
:
965 sal_uInt16 nId
= ScExponentialSmoothingDialogWrapper::GetChildWindowId();
966 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
967 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
969 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
972 case SID_MOVING_AVERAGE_DIALOG
:
974 sal_uInt16 nId
= ScMovingAverageDialogWrapper::GetChildWindowId();
975 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
976 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
978 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
981 case SID_TTEST_DIALOG
:
983 sal_uInt16 nId
= ScTTestDialogWrapper::GetChildWindowId();
984 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
985 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
987 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
991 case SID_FTEST_DIALOG
:
993 sal_uInt16 nId
= ScFTestDialogWrapper::GetChildWindowId();
994 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
995 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
997 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
1002 case SID_SEARCH_RESULTS_DIALOG
:
1004 const SfxPoolItem
* pItem
= NULL
;
1005 if (pReqArgs
->HasItem(SID_SEARCH_RESULTS_DIALOG
, &pItem
))
1007 bool bVisible
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1008 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1009 // The window ID should equal the slot ID, but not a biggie if it wasn't.
1010 sal_uInt16 nId
= sc::SearchResultsDlgWrapper::GetChildWindowId();
1011 pViewFrm
->SetChildWindow(nId
, bVisible
, false);
1017 // disposal (Outlines)
1018 // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
1021 case SID_OUTLINE_HIDE
:
1022 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1023 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1024 pTabViewShell
->SetDataPilotDetails( false );
1026 pTabViewShell
->HideMarkedOutlines();
1030 case SID_OUTLINE_SHOW
:
1032 ScDPObject
* pDPObj
= GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1033 GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1036 Sequence
<sheet::DataPilotFieldFilter
> aFilters
;
1037 sal_uInt16 nOrientation
;
1038 if ( pTabViewShell
->HasSelectionForDrillDown( nOrientation
) )
1040 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1041 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1043 AbstractScDPShowDetailDlg
* pDlg
= pFact
->CreateScDPShowDetailDlg(
1044 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL
, *pDPObj
, nOrientation
);
1045 OSL_ENSURE(pDlg
, "Dialog create fail!");
1046 if ( pDlg
->Execute() == RET_OK
)
1048 OUString
aNewDimName( pDlg
->GetDimensionName() );
1049 pTabViewShell
->SetDataPilotDetails( true, &aNewDimName
);
1052 else if ( !pDPObj
->IsServiceData() &&
1053 pDPObj
->GetDataFieldPositionData(
1054 ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
1056 pTabViewShell
->ShowDataPilotSourceData( *pDPObj
, aFilters
);
1058 pTabViewShell
->SetDataPilotDetails(true);
1061 pTabViewShell
->ShowMarkedOutlines();
1066 case SID_OUTLINE_MAKE
:
1068 bool bColumns
= false;
1071 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1072 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1074 ScDPNumGroupInfo aNumInfo
;
1075 aNumInfo
.mbEnable
= true;
1076 aNumInfo
.mbAutoStart
= true;
1077 aNumInfo
.mbAutoEnd
= true;
1078 sal_Int32 nParts
= 0;
1079 if ( pTabViewShell
->HasSelectionForDateGroup( aNumInfo
, nParts
) )
1081 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1082 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1083 Date
aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
1084 AbstractScDPDateGroupDlg
* pDlg
= pFact
->CreateScDPDateGroupDlg(
1085 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPDATEGROUP
,
1086 aNumInfo
, nParts
, aNullDate
);
1087 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1088 if( pDlg
->Execute() == RET_OK
)
1090 aNumInfo
= pDlg
->GetGroupInfo();
1091 pTabViewShell
->DateGroupDataPilot( aNumInfo
, pDlg
->GetDatePart() );
1094 else if ( pTabViewShell
->HasSelectionForNumGroup( aNumInfo
) )
1096 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1097 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1098 AbstractScDPNumGroupDlg
* pDlg
= pFact
->CreateScDPNumGroupDlg(
1099 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPNUMGROUP
, aNumInfo
);
1100 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1101 if( pDlg
->Execute() == RET_OK
)
1102 pTabViewShell
->NumGroupDataPilot( pDlg
->GetGroupInfo() );
1105 pTabViewShell
->GroupDataPilot();
1109 else if( pReqArgs
!= NULL
)
1111 const SfxPoolItem
* pItem
;
1114 if( pReqArgs
->HasItem( SID_OUTLINE_MAKE
, &pItem
) )
1116 OUString aCol
= ((const SfxStringItem
*)pItem
)->GetValue();
1117 aCol
= aCol
.toAsciiUpperCase();
1121 case 'R': bColumns
=false; bOk
= true;break;
1122 case 'C': bColumns
=true; bOk
= true;break;
1126 else // Dialog, when not whole rows/columns are marked
1128 if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
1130 else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
1134 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1135 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1137 boost::scoped_ptr
<AbstractScGroupDlg
> pDlg(pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), false));
1138 OSL_ENSURE(pDlg
, "Dialog create fail!");
1139 if ( pDlg
->Execute() == RET_OK
)
1140 bColumns
= pDlg
->GetColsChecked();
1147 pTabViewShell
->MakeOutline( bColumns
);
1149 if( ! rReq
.IsAPI() )
1151 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1152 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_MAKE
, aCol
) );
1159 case SID_OUTLINE_REMOVE
:
1161 bool bColumns
= false;
1164 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1165 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1167 pTabViewShell
->UngroupDataPilot();
1170 else if( pReqArgs
!= NULL
)
1172 const SfxPoolItem
* pItem
;
1175 if( pReqArgs
->HasItem( SID_OUTLINE_REMOVE
, &pItem
) )
1177 OUString aCol
= ((const SfxStringItem
*)pItem
)->GetValue();
1178 aCol
= aCol
.toAsciiUpperCase();
1182 case 'R': bColumns
=false; bOk
= true;break;
1183 case 'C': bColumns
=true; bOk
= true;break;
1187 else // Dialog only when removal for rows and columns is possible
1189 bool bColPoss
, bRowPoss
;
1190 pTabViewShell
->TestRemoveOutline( bColPoss
, bRowPoss
);
1191 if ( bColPoss
&& bRowPoss
)
1193 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1194 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1196 boost::scoped_ptr
<AbstractScGroupDlg
> pDlg(pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), true));
1197 OSL_ENSURE(pDlg
, "Dialog create fail!");
1198 if ( pDlg
->Execute() == RET_OK
)
1199 bColumns
= pDlg
->GetColsChecked();
1203 else if ( bColPoss
)
1205 else if ( bRowPoss
)
1212 pTabViewShell
->RemoveOutline( bColumns
);
1214 if( ! rReq
.IsAPI() )
1216 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1217 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE
, aCol
) );
1227 case SID_COPY
: // for graphs in DrawShell
1229 WaitObject
aWait( GetViewData()->GetDialogParent() );
1230 pTabViewShell
->CopyToClip( NULL
, false, false, true );
1232 GetViewData()->SetPasteMode( (ScPasteFlags
) (SC_PASTE_MODE
| SC_PASTE_BORDER
) );
1233 pTabViewShell
->ShowCursor();
1234 pTabViewShell
->UpdateCopySourceOverlay();
1238 case SID_CUT
: // for graphs in DrawShell
1240 WaitObject
aWait( GetViewData()->GetDialogParent() );
1241 pTabViewShell
->CutToClip( NULL
, true );
1243 GetViewData()->SetPasteMode( (ScPasteFlags
)(SC_PASTE_MODE
| SC_PASTE_BORDER
));
1244 pTabViewShell
->ShowCursor();
1245 pTabViewShell
->UpdateCopySourceOverlay();
1251 ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell
, true );
1256 case SID_CLIPBOARD_FORMAT_ITEMS
:
1258 WaitObject
aWait( GetViewData()->GetDialogParent() );
1260 sal_uLong nFormat
= 0;
1261 const SfxPoolItem
* pItem
;
1263 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
&&
1264 pItem
->ISA(SfxUInt32Item
) )
1266 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
1271 Window
* pWin
= GetViewData()->GetActiveWin();
1272 bool bCells
= ( ScTransferObj::GetOwnClipboard( pWin
) != NULL
);
1273 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1274 bool bOle
= ( nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
);
1276 if ( bCells
&& bOle
)
1277 pTabViewShell
->PasteFromSystem();
1278 else if ( bDraw
&& bOle
)
1279 pTabViewShell
->PasteDraw();
1281 pTabViewShell
->PasteFromSystem(nFormat
);
1284 //? pTabViewShell->PasteFromSystem();
1288 pTabViewShell
->CellContentChanged();
1291 case FID_INS_CELL_CONTENTS
:
1293 sal_uInt16 nFlags
= IDF_NONE
;
1294 sal_uInt16 nFunction
= PASTE_NOFUNC
;
1295 bool bSkipEmpty
= false;
1296 bool bTranspose
= false;
1297 bool bAsLink
= false;
1298 InsCellCmd eMoveMode
= INS_NONE
;
1300 Window
* pWin
= GetViewData()->GetActiveWin();
1301 ScDocument
* pDoc
= GetViewData()->GetDocument();
1302 bool bOtherDoc
= !pDoc
->IsClipboardSource();
1303 ScTransferObj
* pOwnClip
= ScTransferObj::GetOwnClipboard( pWin
);
1306 // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1307 uno::Reference
<datatransfer::XTransferable
> aOwnClipRef( pOwnClip
);
1308 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
1310 const SfxPoolItem
* pItem
;
1311 OUString
aFlags('A');
1313 if( pReqArgs
->HasItem( FID_INS_CELL_CONTENTS
, &pItem
) )
1314 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
1316 aFlags
= aFlags
.toAsciiUpperCase();
1319 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
1325 bCont
= false; // don't continue!
1327 case 'S': nFlags
|= IDF_STRING
; break;
1328 case 'V': nFlags
|= IDF_VALUE
; break;
1329 case 'D': nFlags
|= IDF_DATETIME
; break;
1330 case 'F': nFlags
|= IDF_FORMULA
; break;
1331 case 'N': nFlags
|= IDF_NOTE
; break;
1332 case 'T': nFlags
|= IDF_ATTRIB
; break;
1336 SFX_REQUEST_ARG( rReq
, pFuncItem
, SfxUInt16Item
, FN_PARAM_1
, false );
1337 SFX_REQUEST_ARG( rReq
, pSkipItem
, SfxBoolItem
, FN_PARAM_2
, false );
1338 SFX_REQUEST_ARG( rReq
, pTransposeItem
, SfxBoolItem
, FN_PARAM_3
, false );
1339 SFX_REQUEST_ARG( rReq
, pLinkItem
, SfxBoolItem
, FN_PARAM_4
, false );
1340 SFX_REQUEST_ARG( rReq
, pMoveItem
, SfxInt16Item
, FN_PARAM_5
, false );
1342 nFunction
= pFuncItem
->GetValue();
1344 bSkipEmpty
= pSkipItem
->GetValue();
1345 if ( pTransposeItem
)
1346 bTranspose
= pTransposeItem
->GetValue();
1348 bAsLink
= pLinkItem
->GetValue();
1350 eMoveMode
= (InsCellCmd
) pMoveItem
->GetValue();
1354 ScEditableTester
aTester( pTabViewShell
);
1355 if (aTester
.IsEditable())
1357 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1358 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1360 boost::scoped_ptr
<AbstractScInsertContentsDlg
> pDlg(pFact
->CreateScInsertContentsDlg(pTabViewShell
->GetDialogParent()));
1361 OSL_ENSURE(pDlg
, "Dialog create fail!");
1362 pDlg
->SetOtherDoc( bOtherDoc
);
1363 // if ChangeTrack MoveMode disable
1364 pDlg
->SetChangeTrack( pDoc
->GetChangeTrack() != NULL
);
1365 // fdo#56098 disable shift if necessary
1366 if ( !bOtherDoc
&& pOwnClip
)
1368 ScViewData
* pData
= GetViewData();
1369 if ( pData
->GetMarkData().GetTableSelect( pData
->GetTabNo() ) )
1371 SCCOL nStartX
, nEndX
, nClipStartX
, nClipSizeX
, nRangeSizeX
;
1372 SCROW nStartY
, nEndY
, nClipStartY
, nClipSizeY
, nRangeSizeY
;
1373 SCTAB nStartTab
, nEndTab
;
1374 pOwnClip
->GetDocument()->GetClipStart( nClipStartX
, nClipStartY
);
1375 pOwnClip
->GetDocument()->GetClipArea( nClipSizeX
, nClipSizeY
, true );
1377 if ( !( pData
->GetSimpleArea( nStartX
, nStartY
, nStartTab
,
1378 nEndX
, nEndY
, nEndTab
) == SC_MARK_SIMPLE
&&
1379 nStartTab
== nEndTab
) )
1381 // the destination is not a simple range,
1382 // assume the destination as the current cell
1383 nStartX
= nEndX
= pData
->GetCurX();
1384 nStartY
= nEndY
= pData
->GetCurY();
1385 nStartTab
= pData
->GetTabNo();
1387 // we now have clip- and range dimensions
1388 // the size of the destination area is the larger of the two
1389 nRangeSizeX
= nClipSizeX
>= nEndX
- nStartX
? nClipSizeX
: nEndX
- nStartX
;
1390 nRangeSizeY
= nClipSizeY
>= nEndY
- nStartY
? nClipSizeY
: nEndY
- nStartY
;
1391 // When the source and destination areas intersect things may go wrong,
1392 // especially if the area contains references. This may produce data loss
1393 // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1394 ScRange
aSource( nClipStartX
, nClipStartY
, nStartTab
,
1395 nClipStartX
+ nClipSizeX
, nClipStartY
+ nClipSizeY
, nStartTab
);
1396 ScRange
aDest( nStartX
, nStartY
, nStartTab
,
1397 nStartX
+ nRangeSizeX
, nStartY
+ nRangeSizeY
, nStartTab
);
1398 if ( pOwnClip
->GetDocument()->IsCutMode() && aSource
.Intersects( aDest
) )
1399 pDlg
->SetCellShiftDisabled( SC_CELL_SHIFT_DISABLE_DOWN
| SC_CELL_SHIFT_DISABLE_RIGHT
);
1402 //no conflict with intersecting ranges,
1403 //check if paste plus shift will fit on sheet
1404 //and disable shift-option if no fit
1405 int nDisableShiftX
= 0;
1406 int nDisableShiftY
= 0;
1408 //check if horizontal shift will fit
1409 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1410 MAXCOL
- nRangeSizeX
, nStartY
,
1411 MAXCOL
, nStartY
+ nRangeSizeY
, false ) )
1412 nDisableShiftX
= SC_CELL_SHIFT_DISABLE_RIGHT
;
1414 //check if vertical shift will fit
1415 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1416 nStartX
, MAXROW
- nRangeSizeY
,
1417 nStartX
+ nRangeSizeX
, MAXROW
, false ) )
1418 nDisableShiftY
= SC_CELL_SHIFT_DISABLE_DOWN
;
1420 if ( nDisableShiftX
|| nDisableShiftY
)
1421 pDlg
->SetCellShiftDisabled( nDisableShiftX
| nDisableShiftY
);
1425 if (pDlg
->Execute() == RET_OK
)
1427 nFlags
= pDlg
->GetInsContentsCmdBits();
1428 nFunction
= pDlg
->GetFormulaCmdBits();
1429 bSkipEmpty
= pDlg
->IsSkipEmptyCells();
1430 bTranspose
= pDlg
->IsTranspose();
1431 bAsLink
= pDlg
->IsLink();
1432 eMoveMode
= pDlg
->GetMoveMode();
1436 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
1439 if( nFlags
!= IDF_NONE
)
1442 WaitObject
aWait( GetViewData()->GetDialogParent() );
1443 if ( bAsLink
&& bOtherDoc
)
1444 pTabViewShell
->PasteFromSystem(SOT_FORMATSTR_ID_LINK
); // DDE insert
1447 pTabViewShell
->PasteFromClip( nFlags
, pOwnClip
->GetDocument(),
1448 nFunction
, bSkipEmpty
, bTranspose
, bAsLink
,
1449 eMoveMode
, IDF_NONE
, true ); // allow warning dialog
1457 if( nFlags
== IDF_ALL
)
1463 if( nFlags
& IDF_STRING
) aFlags
+= "S";
1464 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
1465 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
1466 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
1467 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
1468 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
1471 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1472 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bSkipEmpty
) );
1473 rReq
.AppendItem( SfxBoolItem( FN_PARAM_3
, bTranspose
) );
1474 rReq
.AppendItem( SfxBoolItem( FN_PARAM_4
, bAsLink
) );
1475 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, nFunction
) );
1476 rReq
.AppendItem( SfxInt16Item( FN_PARAM_5
, (sal_Int16
) eMoveMode
) );
1482 pTabViewShell
->CellContentChanged(); // => PasteFromXXX ???
1484 case SID_PASTE_ONLY_VALUE
:
1485 case SID_PASTE_ONLY_TEXT
:
1486 case SID_PASTE_ONLY_FORMULA
:
1488 Window
* pWin
= GetViewData()->GetActiveWin();
1489 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1491 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1493 if ( nSlot
== SID_PASTE_ONLY_VALUE
)
1495 else if ( nSlot
== SID_PASTE_ONLY_TEXT
)
1499 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1500 ExecuteSlot( rReq
, GetInterface() );
1501 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1502 pTabViewShell
->CellContentChanged();
1505 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1508 case SID_PASTE_SPECIAL
:
1509 // differentiate between own cell data and draw objects/external data
1510 // this makes FID_INS_CELL_CONTENTS superfluous
1512 Window
* pWin
= GetViewData()->GetActiveWin();
1514 // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1515 const SfxPoolItem
* pItem
=NULL
;
1517 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
&&
1518 pItem
->ISA(SfxUInt32Item
) )
1520 sal_uLong nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
1523 WaitObject
aWait( GetViewData()->GetDialogParent() );
1524 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1525 if ( bDraw
&& nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1526 pTabViewShell
->PasteDraw();
1528 bRet
= pTabViewShell
->PasteFromSystem(nFormat
, true); // TRUE: no error messages
1533 rReq
.SetReturnValue(SfxInt16Item(nSlot
, bRet
? 1 : 0)); // 1 = success, 0 = fail
1537 // if format is not available -> fallback to request without parameters
1543 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1545 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1546 ExecuteSlot( rReq
, GetInterface() );
1547 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1549 else // draw objects or external data
1551 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1553 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
1554 GetPossibleClipboardFormats( aFormats
);
1556 sal_uInt16 nFormatCount
= aFormats
.Count();
1559 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1560 boost::scoped_ptr
<SfxAbstractPasteDialog
> pDlg(pFact
->CreatePasteDialog( pTabViewShell
->GetDialogParent() ));
1563 for (sal_uInt16 i
=0; i
<nFormatCount
; i
++)
1565 sal_uLong nFormatId
= aFormats
.GetClipbrdFormatId( i
);
1566 OUString aName
= aFormats
.GetClipbrdFormatName( i
);
1567 // special case for paste dialog: '*' is replaced by object type
1568 if ( nFormatId
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1570 pDlg
->Insert( nFormatId
, aName
);
1573 TransferableDataHelper
aDataHelper(
1574 TransferableDataHelper::CreateFromSystemClipboard( pWin
) );
1575 sal_uLong nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
1579 WaitObject
aWait( GetViewData()->GetDialogParent() );
1580 if ( bDraw
&& nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1581 pTabViewShell
->PasteDraw();
1583 pTabViewShell
->PasteFromSystem(nFormat
);
1585 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1586 rReq
.AppendItem( SfxUInt32Item( nSlot
, nFormat
) );
1591 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1597 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1601 pTabViewShell
->CellContentChanged(); // => PasteFromSystem() ???
1608 case FID_INS_ROWBRK
:
1609 pTabViewShell
->InsertPageBreak( false );
1613 case FID_INS_COLBRK
:
1614 pTabViewShell
->InsertPageBreak( true );
1618 case FID_DEL_ROWBRK
:
1619 pTabViewShell
->DeletePageBreak( false );
1623 case FID_DEL_COLBRK
:
1624 pTabViewShell
->DeletePageBreak( true );
1628 case SID_DETECTIVE_ADD_PRED
:
1629 pTabViewShell
->DetectiveAddPred();
1633 case SID_DETECTIVE_DEL_PRED
:
1634 pTabViewShell
->DetectiveDelPred();
1638 case SID_DETECTIVE_ADD_SUCC
:
1639 pTabViewShell
->DetectiveAddSucc();
1643 case SID_DETECTIVE_DEL_SUCC
:
1644 pTabViewShell
->DetectiveDelSucc();
1648 case SID_DETECTIVE_ADD_ERR
:
1649 pTabViewShell
->DetectiveAddError();
1653 case SID_DETECTIVE_INVALID
:
1654 pTabViewShell
->DetectiveMarkInvalid();
1658 case SID_DETECTIVE_REFRESH
:
1659 pTabViewShell
->DetectiveRefresh();
1663 case SID_DETECTIVE_MARK_PRED
:
1664 pTabViewShell
->DetectiveMarkPred();
1666 case SID_DETECTIVE_MARK_SUCC
:
1667 pTabViewShell
->DetectiveMarkSucc();
1669 case SID_INSERT_CURRENT_DATE
:
1670 pTabViewShell
->InsertCurrentTime(
1671 NUMBERFORMAT_DATE
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE
));
1673 case SID_INSERT_CURRENT_TIME
:
1674 pTabViewShell
->InsertCurrentTime(
1675 NUMBERFORMAT_TIME
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME
));
1678 case SID_SPELL_DIALOG
:
1680 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
1681 if( rReq
.GetArgs() )
1682 pViewFrame
->SetChildWindow( SID_SPELL_DIALOG
,
1683 static_cast< const SfxBoolItem
& >( rReq
.GetArgs()->
1684 Get( SID_SPELL_DIALOG
) ).GetValue() );
1686 pViewFrame
->ToggleChildWindow( SID_SPELL_DIALOG
);
1688 pViewFrame
->GetBindings().Invalidate( SID_SPELL_DIALOG
);
1693 case SID_HANGUL_HANJA_CONVERSION
:
1694 pTabViewShell
->DoHangulHanjaConversion();
1697 case SID_CHINESE_CONVERSION
:
1699 //open ChineseTranslationDialog
1700 Reference
< XComponentContext
> xContext(
1701 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1704 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1707 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1708 xMCF
->createInstanceWithContext(
1709 OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
1710 , xContext
), UNO_QUERY
);
1711 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1714 // initialize dialog
1715 Reference
< awt::XWindow
> xDialogParentWindow(0);
1716 Sequence
<Any
> aSeq(1);
1717 Any
* pArray
= aSeq
.getArray();
1718 PropertyValue aParam
;
1719 aParam
.Name
= "ParentWindow";
1720 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1721 pArray
[0] <<= makeAny(aParam
);
1722 xInit
->initialize( aSeq
);
1725 sal_Int16 nDialogRet
= xDialog
->execute();
1726 if( RET_OK
== nDialogRet
)
1728 //get some parameters from the dialog
1729 bool bToSimplified
= true;
1730 bool bUseVariants
= true;
1731 bool bCommonTerms
= true;
1732 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1737 xProp
->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified
;
1738 xProp
->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants
;
1739 xProp
->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms
;
1746 //execute translation
1747 LanguageType eSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1748 LanguageType eTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1749 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1751 nOptions
|= i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1753 Font aTargetFont
= GetViewData()->GetActiveWin()->GetDefaultFont(
1754 DEFAULTFONT_CJK_SPREADSHEET
,
1755 eTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
1756 ScConversionParam
aConvParam( SC_CONVERSION_CHINESE_TRANSL
,
1757 eSourceLang
, eTargetLang
, aTargetFont
, nOptions
, false );
1758 pTabViewShell
->DoSheetConversion( aConvParam
);
1761 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1762 if( xComponent
.is() )
1763 xComponent
->dispose();
1770 pTabViewShell
->DoThesaurus();
1773 case SID_TOGGLE_REL
:
1774 pTabViewShell
->DoRefConversion();
1777 case SID_DEC_INDENT
:
1778 pTabViewShell
->ChangeIndent( false );
1780 case SID_INC_INDENT
:
1781 pTabViewShell
->ChangeIndent( true );
1786 sal_uInt16 nFlags
= pTabViewShell
->GetCreateNameFlags();
1788 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1789 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1791 boost::scoped_ptr
<AbstractScNameCreateDlg
> pDlg(pFact
->CreateScNameCreateDlg(pTabViewShell
->GetDialogParent(), nFlags
));
1792 OSL_ENSURE(pDlg
, "Dialog create fail!");
1794 if( pDlg
->Execute() )
1796 nFlags
= pDlg
->GetFlags();
1797 pTabViewShell
->CreateNames(nFlags
);
1803 case SID_CONSOLIDATE
:
1805 const SfxPoolItem
* pItem
;
1806 if ( pReqArgs
&& SFX_ITEM_SET
==
1807 pReqArgs
->GetItemState( SCITEM_CONSOLIDATEDATA
, true, &pItem
) )
1809 const ScConsolidateParam
& rParam
=
1810 ((const ScConsolidateItem
*)pItem
)->GetData();
1812 pTabViewShell
->Consolidate( rParam
);
1813 GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam
);
1817 #ifndef DISABLE_SCRIPTING
1818 else if (rReq
.IsAPI())
1819 SbxBase::SetError(SbxERR_BAD_PARAMETER
);
1824 case SID_INS_FUNCTION
:
1826 const SfxBoolItem
* pOkItem
= (const SfxBoolItem
*)&pReqArgs
->Get( SID_DLG_RETOK
);
1828 if ( pOkItem
->GetValue() ) // OK
1831 const SfxStringItem
* pSItem
= (const SfxStringItem
*)&pReqArgs
->Get( SCITEM_STRING
);
1832 const SfxBoolItem
* pMatrixItem
= (const SfxBoolItem
*) &pReqArgs
->Get( SID_DLG_MATRIX
);
1834 aFormula
+= pSItem
->GetValue();
1835 pScMod
->ActivateInputWindow( &aFormula
, pMatrixItem
->GetValue() );
1839 pScMod
->ActivateInputWindow( NULL
);
1841 rReq
.Ignore(); // only SID_ENTER_STRING is recorded
1845 case FID_DEFINE_NAME
:
1848 const SfxPoolItem
* pItem
;
1849 OUString aName
, aSymbol
, aAttrib
;
1851 if( pReqArgs
->HasItem( FID_DEFINE_NAME
, &pItem
) )
1852 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
1854 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
1855 aSymbol
= ((const SfxStringItem
*)pItem
)->GetValue();
1857 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
1858 aAttrib
= ((const SfxStringItem
*)pItem
)->GetValue();
1860 if ( !aName
.isEmpty() && !aSymbol
.isEmpty() )
1862 if (pTabViewShell
->InsertName( aName
, aSymbol
, aAttrib
))
1864 #ifndef DISABLE_SCRIPTING
1866 SbxBase::SetError( SbxERR_BAD_PARAMETER
); // Basic-error
1872 sal_uInt16 nId
= ScNameDlgWrapper::GetChildWindowId();
1873 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1874 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1876 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
1881 sal_uInt16 nId
= ScNameDefDlgWrapper::GetChildWindowId();
1882 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1883 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1885 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
1889 case SID_OPENDLG_CONDFRMT
:
1890 case SID_OPENDLG_COLORSCALE
:
1891 case SID_OPENDLG_DATABAR
:
1892 case SID_OPENDLG_ICONSET
:
1893 case SID_OPENDLG_CONDDATE
:
1896 ScRangeList aRangeList
;
1897 ScViewData
* pData
= GetViewData();
1898 pData
->GetMarkData().FillRangeListWithMarks(&aRangeList
, false);
1900 ScDocument
* pDoc
= GetViewData()->GetDocument();
1901 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
1903 //ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
1907 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
1908 if(aRangeList
.empty())
1910 ScRange
* pRange
= new ScRange(aPos
);
1911 aRangeList
.push_back(pRange
);
1915 const ScPatternAttr
* pPattern
= pDoc
->GetPattern(aPos
.Col(), aPos
.Row(), aPos
.Tab());
1916 const std::vector
<sal_uInt32
>& rCondFormats
= static_cast<const ScCondFormatItem
&>(pPattern
->GetItem(ATTR_CONDITIONAL
)).GetCondFormatData();
1917 bool bContainsCondFormat
= !rCondFormats
.empty();
1918 boost::scoped_ptr
<ScCondFormatDlg
> pCondFormatDlg
;
1919 if(bContainsCondFormat
)
1921 bool bContainsExistingCondFormat
= false;
1922 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList(aPos
.Tab());
1923 for (std::vector
<sal_uInt32
>::const_iterator itr
= rCondFormats
.begin(), itrEnd
= rCondFormats
.end();
1924 itr
!= itrEnd
; ++itr
)
1926 // check if at least one existing conditional format has the same range
1927 const ScConditionalFormat
* pCondFormat
= pList
->GetFormat(*itr
);
1931 bContainsExistingCondFormat
= true;
1932 const ScRangeList
& rCondFormatRange
= pCondFormat
->GetRange();
1933 if(rCondFormatRange
== aRangeList
)
1935 // found a matching range, edit this conditional format
1936 nKey
= pCondFormat
->GetKey();
1937 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, pCondFormat
, rCondFormatRange
, aPos
, condformat::dialog::NONE
) );
1942 // if not found a conditional format ask whether we should edit one of the existing
1943 // or should create a new overlapping conditional format
1945 if(!pCondFormatDlg
&& bContainsExistingCondFormat
)
1947 QueryBox
aBox( pTabViewShell
->GetDialogParent(), WinBits( WB_YES_NO
| WB_DEF_YES
),
1948 ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS
) );
1949 bool bEditExisting
= aBox
.Execute() == RET_YES
;
1952 // differentiate between ranges where one conditional format is defined
1953 // and several formats are defined
1954 // if we have only one => open the cond format dlg to edit it
1955 // otherwise open the manage cond format dlg
1956 if(rCondFormats
.size() == 1)
1958 const ScConditionalFormat
* pCondFormat
= pList
->GetFormat(rCondFormats
[0]);
1959 assert(pCondFormat
);
1960 const ScRangeList
& rCondFormatRange
= pCondFormat
->GetRange();
1961 nKey
= pCondFormat
->GetKey();
1962 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, pCondFormat
, rCondFormatRange
, aPos
, condformat::dialog::NONE
) );
1966 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1967 boost::scoped_ptr
<AbstractScCondFormatManagerDlg
> pDlg(pFact
->CreateScCondFormatMgrDlg( pTabViewShell
->GetDialogParent(), pDoc
, pList
, aPos
, RID_SCDLG_COND_FORMAT_MANAGER
));
1968 if(pDlg
->Execute() == RET_OK
&& pDlg
->CondFormatsChanged())
1970 ScConditionalFormatList
* pCondFormatList
= pDlg
->GetConditionalFormatList();
1971 pData
->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList
, aPos
.Tab());
1973 // we need step out here because we don't want to open the normal dialog
1979 // define an overlapping conditional format
1980 // does not need to be handled here
1988 condformat::dialog::ScCondFormatDialogType eType
= condformat::dialog::NONE
;
1991 case SID_OPENDLG_CONDFRMT
:
1992 eType
= condformat::dialog::CONDITION
;
1994 case SID_OPENDLG_COLORSCALE
:
1995 eType
= condformat::dialog::COLORSCALE
;
1997 case SID_OPENDLG_DATABAR
:
1998 eType
= condformat::dialog::DATABAR
;
2000 case SID_OPENDLG_ICONSET
:
2001 eType
= condformat::dialog::ICONSET
;
2003 case SID_OPENDLG_CONDDATE
:
2004 eType
= condformat::dialog::DATE
;
2010 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, NULL
, aRangeList
, aRangeList
.GetTopLeftCorner(), eType
) );
2014 pScMod
->SetRefDialog( nId
, true );
2016 if( pCondFormatDlg
->Execute() == RET_OK
)
2018 ScConditionalFormat
* pFormat
= pCondFormatDlg
->GetConditionalFormat();
2020 pData
->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey
, pFormat
, aPos
.Tab(), pFormat
->GetRange());
2022 pData
->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey
, NULL
, aPos
.Tab(), ScRangeList());
2025 pScMod
->SetRefDialog( nId
, false );
2031 case SID_DEFINE_COLROWNAMERANGES
:
2034 sal_uInt16 nId
= ScColRowNameRangesDlgWrapper::GetChildWindowId();
2035 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2036 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2038 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
2043 case SID_UPDATECHART
:
2049 const SfxPoolItem
* pItem
;
2051 if( pReqArgs
->HasItem( SID_UPDATECHART
, &pItem
) )
2052 bAll
= ((const SfxBoolItem
*)pItem
)->GetValue();
2055 pTabViewShell
->UpdateCharts( bAll
);
2057 if( ! rReq
.IsAPI() )
2059 rReq
.AppendItem( SfxBoolItem( SID_UPDATECHART
, bAll
) );
2069 const ScTabOpItem
& rItem
=
2070 (const ScTabOpItem
&)
2071 pReqArgs
->Get( SID_TABOP
);
2073 pTabViewShell
->TabOp( rItem
.GetData() );
2075 rReq
.Done( *pReqArgs
);
2082 const ScSolveItem
& rItem
=
2083 (const ScSolveItem
&)
2084 pReqArgs
->Get( SCITEM_SOLVEDATA
);
2086 pTabViewShell
->Solve( rItem
.GetData() );
2088 rReq
.Done( *pReqArgs
);
2092 case FID_INSERT_NAME
:
2094 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2095 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2097 boost::scoped_ptr
<AbstractScNamePasteDlg
> pDlg(pFact
->CreateScNamePasteDlg( pTabViewShell
->GetDialogParent(), GetViewData()->GetDocShell() ));
2098 OSL_ENSURE(pDlg
, "Dialog create fail!");
2099 switch( pDlg
->Execute() )
2101 case BTN_PASTE_LIST
:
2102 pTabViewShell
->InsertNameList();
2104 case BTN_PASTE_NAME
:
2106 ScInputHandler
* pHdl
= pScMod
->GetInputHdl( pTabViewShell
);
2109 // "=" in KeyEvent, switches to input-mode
2110 pScMod
->InputKeyEvent( KeyEvent('=',KeyCode()) );
2112 std::vector
<OUString
> aNames
= pDlg
->GetSelectedNames();
2113 if (!aNames
.empty())
2115 OUStringBuffer aBuffer
;
2116 for (std::vector
<OUString
>::const_iterator itr
= aNames
.begin();
2117 itr
!= aNames
.end(); ++itr
)
2119 aBuffer
.append(*itr
).append(' ');
2121 pHdl
->InsertFunction( aBuffer
.makeStringAndClear(), false ); // without "()"
2130 case SID_RANGE_NOTETEXT
:
2133 const SfxStringItem
& rTextItem
= (const SfxStringItem
&)pReqArgs
->Get( SID_RANGE_NOTETEXT
);
2135 // always cursor position
2136 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2137 pTabViewShell
->SetNoteText( aPos
, rTextItem
.GetValue() );
2142 case SID_INSERT_POSTIT
:
2145 const SvxPostItAuthorItem
& rAuthorItem
= (const SvxPostItAuthorItem
&)pReqArgs
->Get( SID_ATTR_POSTIT_AUTHOR
);
2146 const SvxPostItDateItem
& rDateItem
= (const SvxPostItDateItem
&) pReqArgs
->Get( SID_ATTR_POSTIT_DATE
);
2147 const SvxPostItTextItem
& rTextItem
= (const SvxPostItTextItem
&) pReqArgs
->Get( SID_ATTR_POSTIT_TEXT
);
2149 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2150 pTabViewShell
->ReplaceNote( aPos
, rTextItem
.GetValue(), &rAuthorItem
.GetValue(), &rDateItem
.GetValue() );
2155 pTabViewShell
->EditNote(); // note object to edit
2159 case FID_NOTE_VISIBLE
:
2161 ScDocument
* pDoc
= GetViewData()->GetDocument();
2162 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2163 if( ScPostIt
* pNote
= pDoc
->GetNote(aPos
) )
2166 const SfxPoolItem
* pItem
;
2167 if ( pReqArgs
&& (pReqArgs
->GetItemState( FID_NOTE_VISIBLE
, true, &pItem
) == SFX_ITEM_SET
) )
2168 bShow
= ((const SfxBoolItem
*) pItem
)->GetValue();
2170 bShow
= !pNote
->IsCaptionShown();
2172 pTabViewShell
->ShowNote( bShow
);
2175 rReq
.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE
, bShow
) );
2178 rBindings
.Invalidate( FID_NOTE_VISIBLE
);
2188 bool bShowNote
= nSlot
== FID_SHOW_NOTE
;
2189 ScViewData
* pData
= GetViewData();
2190 ScDocument
* pDoc
= pData
->GetDocument();
2191 ScMarkData
& rMark
= pData
->GetMarkData();
2194 if (!rMark
.IsMarked() && !rMark
.IsMultiMarked())
2196 // Check current cell
2197 ScAddress
aPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2198 if( pDoc
->GetNote(aPos
) )
2200 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2206 // Check selection range
2207 ScRangeListRef aRangesRef
;
2208 pData
->GetMultiArea(aRangesRef
);
2209 ScRangeList aRanges
= *aRangesRef
;
2210 size_t nRangeSize
= aRanges
.size();
2212 OUString aUndo
= ScGlobal::GetRscString( bShowNote
? STR_UNDO_SHOWNOTE
: STR_UNDO_HIDENOTE
);
2213 pData
->GetDocShell()->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
2215 for ( size_t i
= 0; i
< nRangeSize
; ++i
)
2217 const ScRange
* pRange
= aRanges
[i
];
2218 const SCROW nRow0
= pRange
->aStart
.Row();
2219 const SCROW nRow1
= pRange
->aEnd
.Row();
2220 const SCCOL nCol0
= pRange
->aStart
.Col();
2221 const SCCOL nCol1
= pRange
->aEnd
.Col();
2222 const SCTAB nRangeTab
= pRange
->aStart
.Tab();
2223 // Check by each cell
2224 for ( SCROW nRow
= nRow0
; nRow
<= nRow1
; ++nRow
)
2226 for ( SCCOL nCol
= nCol0
; nCol
<= nCol1
; ++nCol
)
2228 if ( pDoc
->HasNote(nCol
, nRow
, nRangeTab
) && pDoc
->IsBlockEditable( nRangeTab
, nCol
,nRow
, nCol
,nRow
) )
2230 ScAddress
aPos( nCol
, nRow
, nRangeTab
);
2231 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2238 pData
->GetDocShell()->GetUndoManager()->LeaveListAction();
2243 rBindings
.Invalidate( nSlot
);
2251 case SID_DELETE_NOTE
:
2252 pTabViewShell
->DeleteContents( IDF_NOTE
); // delete all notes in selection
2257 if( pReqArgs
!= NULL
)
2259 OUString aChars
, aFontName
;
2260 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2261 const SfxPoolItem
* pItem
= 0;
2263 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), false, &pItem
);
2266 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, pItem
);
2268 aChars
= pStringItem
->GetValue();
2269 const SfxPoolItem
* pFtItem
= NULL
;
2270 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), false, &pFtItem
);
2271 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
2273 aFontName
= pFontItem
->GetValue();
2276 if ( !aChars
.isEmpty() )
2279 pTabViewShell
->GetSelectionPattern()->GetFont( aFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2280 pTabViewShell
->GetSelectionScriptType() );
2281 if ( !aFontName
.isEmpty() )
2282 aFont
= Font( aFontName
, Size(1,1) );
2283 pTabViewShell
->InsertSpecialChar( aChars
, aFont
);
2284 if( ! rReq
.IsAPI() )
2290 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
2292 // font color doesn't matter here
2294 pTabViewShell
->GetSelectionPattern()->GetFont( aCurFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2295 pTabViewShell
->GetSelectionScriptType() );
2297 SfxAllItemSet
aSet( GetPool() );
2298 aSet
.Put( SfxBoolItem( FN_PARAM_1
, false ) );
2299 aSet
.Put( SvxFontItem( aCurFont
.GetFamily(), aCurFont
.GetName(), aCurFont
.GetStyleName(), aCurFont
.GetPitch(), aCurFont
.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT
) ) );
2301 boost::scoped_ptr
<SfxAbstractDialog
> pDlg(pFact
->CreateSfxDialog( pTabViewShell
->GetDialogParent(), aSet
,
2302 pTabViewShell
->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP
));
2304 if ( pDlg
->Execute() == RET_OK
)
2306 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pItem
, SfxStringItem
, SID_CHARMAP
, false );
2307 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, false );
2309 if ( pItem
&& pFontItem
)
2311 Font
aNewFont( pFontItem
->GetFamilyName(), pFontItem
->GetStyleName(), Size(1,1) );
2312 aNewFont
.SetCharSet( pFontItem
->GetCharSet() );
2313 aNewFont
.SetPitch( pFontItem
->GetPitch() );
2314 pTabViewShell
->InsertSpecialChar( pItem
->GetValue(), aNewFont
);
2315 rReq
.AppendItem( *pFontItem
);
2316 rReq
.AppendItem( *pItem
);
2323 case SID_SELECT_SCENARIO
:
2329 const SfxStringItem
* pItem
=
2330 (const SfxStringItem
*)&pReqArgs
->Get( SID_SELECT_SCENARIO
);
2334 pTabViewShell
->UseScenario( pItem
->GetValue() );
2335 //! why should the return value be valid?!?!
2336 rReq
.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO
, pItem
->GetValue() ) );
2347 case SID_HYPERLINK_SETLINK
:
2350 const SfxPoolItem
* pItem
;
2351 if( pReqArgs
->HasItem( SID_HYPERLINK_SETLINK
, &pItem
) )
2353 const SvxHyperlinkItem
* pHyper
= (const SvxHyperlinkItem
*) pItem
;
2354 const OUString
& rName
= pHyper
->GetName();
2355 const OUString
& rURL
= pHyper
->GetURL();
2356 const OUString
& rTarget
= pHyper
->GetTargetFrame();
2357 sal_uInt16 nType
= (sal_uInt16
) pHyper
->GetInsertMode();
2359 pTabViewShell
->InsertURL( rName
, rURL
, rTarget
, nType
);
2367 case SID_OPENDLG_CONDFRMT_MANAGER
:
2369 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2370 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2372 ScViewData
* pData
= GetViewData();
2373 ScDocument
* pDoc
= pData
->GetDocument();
2375 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
2377 pTabViewShell
->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED
);
2381 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
2383 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList( aPos
.Tab() );
2384 boost::scoped_ptr
<AbstractScCondFormatManagerDlg
> pDlg(pFact
->CreateScCondFormatMgrDlg( pTabViewShell
->GetDialogParent(), pDoc
, pList
, aPos
, RID_SCDLG_COND_FORMAT_MANAGER
));
2385 if(pDlg
->Execute() == RET_OK
&& pDlg
->CondFormatsChanged())
2387 ScConditionalFormatList
* pCondFormatList
= pDlg
->GetConditionalFormatList();
2388 pData
->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList
, aPos
.Tab());
2393 case SID_EXTERNAL_SOURCE
:
2399 sal_uLong nRefresh
=0;
2401 SFX_REQUEST_ARG( rReq
, pFile
, SfxStringItem
, SID_FILE_NAME
, false );
2402 SFX_REQUEST_ARG( rReq
, pSource
, SfxStringItem
, FN_PARAM_1
, false );
2403 if ( pFile
&& pSource
)
2405 aFile
= pFile
->GetValue();
2406 aSource
= pSource
->GetValue();
2407 SFX_REQUEST_ARG( rReq
, pFilter
, SfxStringItem
, SID_FILTER_NAME
, false );
2409 aFilter
= pFilter
->GetValue();
2410 SFX_REQUEST_ARG( rReq
, pOptions
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, false );
2412 aOptions
= pOptions
->GetValue();
2413 SFX_REQUEST_ARG( rReq
, pRefresh
, SfxUInt32Item
, FN_PARAM_2
, false );
2415 nRefresh
= pRefresh
->GetValue();
2419 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2420 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2422 delete pImpl
->m_pLinkedDlg
;
2423 pImpl
->m_pLinkedDlg
=
2424 pFact
->CreateScLinkedAreaDlg(pTabViewShell
->GetDialogParent());
2425 OSL_ENSURE(pImpl
->m_pLinkedDlg
, "Dialog create fail!");
2426 delete pImpl
->m_pRequest
;
2427 pImpl
->m_pRequest
= new SfxRequest( rReq
);
2428 pImpl
->m_pLinkedDlg
->StartExecuteModal( LINK( this, ScCellShell
, DialogClosed
) );
2432 ExecuteExternalSource( aFile
, aFilter
, aOptions
, aSource
, nRefresh
, rReq
);
2439 OSL_FAIL("incorrect slot in ExecuteEdit");
2444 void ScCellShell::ExecuteTrans( SfxRequest
& rReq
)
2446 sal_Int32 nType
= ScViewUtil::GetTransliterationType( rReq
.GetSlot() );
2449 GetViewData()->GetView()->TransliterateText( nType
);
2454 void ScCellShell::ExecuteRotateTrans( SfxRequest
& rReq
)
2456 if( rReq
.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE
)
2457 GetViewData()->GetView()->TransliterateText( m_aRotateCase
.getNextMode() );
2460 void ScCellShell::ExecuteExternalSource(
2461 const OUString
& _rFile
, const OUString
& _rFilter
, const OUString
& _rOptions
,
2462 const OUString
& _rSource
, sal_uLong _nRefresh
, SfxRequest
& _rRequest
)
2464 if ( !_rFile
.isEmpty() && !_rSource
.isEmpty() ) // filter may be empty
2469 ScViewData
* pData
= GetViewData();
2470 ScMarkData
& rMark
= pData
->GetMarkData();
2471 rMark
.MarkToSimple();
2472 if ( rMark
.IsMarked() )
2474 rMark
.GetMarkArea( aLinkRange
);
2475 bMove
= true; // insert/delete cells to fit range
2478 aLinkRange
= ScRange( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2480 pData
->GetDocFunc().InsertAreaLink( _rFile
, _rFilter
, _rOptions
, _rSource
,
2481 aLinkRange
, _nRefresh
, bMove
, false );
2490 bool isDPSourceValid(const ScDPObject
& rDPObj
)
2492 if (rDPObj
.IsImportData())
2494 // If the data type is database, check if the database is still valid.
2495 const ScImportSourceDesc
* pDesc
= rDPObj
.GetImportSourceDesc();
2499 const ScDPSaveData
* pSaveData
= rDPObj
.GetSaveData();
2500 const ScDPDimensionSaveData
* pDimData
= NULL
;
2502 pDimData
= pSaveData
->GetExistingDimensionData();
2504 const ScDPCache
* pCache
= pDesc
->CreateCache(pDimData
);
2506 // cashe creation failed, probably due to invalid connection.
2514 void ScCellShell::ExecuteDataPilotDialog()
2516 ScModule
* pScMod
= SC_MOD();
2517 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2518 ScViewData
* pData
= GetViewData();
2519 ScDocument
* pDoc
= pData
->GetDocument();
2521 ::boost::scoped_ptr
<ScDPObject
> pNewDPObject(NULL
);
2523 // ScPivot is no longer used...
2524 ScDPObject
* pDPObj
= pDoc
->GetDPAtCursor(
2525 pData
->GetCurX(), pData
->GetCurY(),
2526 pData
->GetTabNo() );
2527 if ( pDPObj
) // on an existing table?
2529 if (isDPSourceValid(*pDPObj
))
2530 pNewDPObject
.reset(new ScDPObject(*pDPObj
));
2532 else // create new table
2534 sal_uLong nSrcErrorId
= 0;
2536 // select database range or data
2537 pTabViewShell
->GetDBData( true, SC_DB_OLD
);
2538 ScMarkData
& rMark
= GetViewData()->GetMarkData();
2539 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
2540 pTabViewShell
->MarkDataArea( false );
2542 // output to cursor position for non-sheet data
2543 ScAddress
aDestPos( pData
->GetCurX(), pData
->GetCurY(),
2544 pData
->GetTabNo() );
2546 // first select type of source data
2548 bool bEnableExt
= ScDPObject::HasRegisteredSources();
2550 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2551 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2553 ::boost::scoped_ptr
<AbstractScDataPilotSourceTypeDlg
> pTypeDlg(
2554 pFact
->CreateScDataPilotSourceTypeDlg(
2555 pTabViewShell
->GetDialogParent(), bEnableExt
));
2557 // Populate named ranges (if any).
2558 ScRangeName
* pRangeName
= pDoc
->GetRangeName();
2561 ScRangeName::const_iterator itr
= pRangeName
->begin(), itrEnd
= pRangeName
->end();
2562 for (; itr
!= itrEnd
; ++itr
)
2563 pTypeDlg
->AppendNamedRange(itr
->second
->GetName());
2566 OSL_ENSURE(pTypeDlg
, "Dialog create fail!");
2567 if ( pTypeDlg
->Execute() == RET_OK
)
2569 if ( pTypeDlg
->IsExternal() )
2571 uno::Sequence
<OUString
> aSources
= ScDPObject::GetRegisteredSources();
2572 ::boost::scoped_ptr
<AbstractScDataPilotServiceDlg
> pServDlg(
2573 pFact
->CreateScDataPilotServiceDlg(
2574 pTabViewShell
->GetDialogParent(), aSources
, RID_SCDLG_DAPISERVICE
));
2576 OSL_ENSURE(pServDlg
, "Dialog create fail!");
2577 if ( pServDlg
->Execute() == RET_OK
)
2579 ScDPServiceDesc
aServDesc(
2580 pServDlg
->GetServiceName(),
2581 pServDlg
->GetParSource(),
2582 pServDlg
->GetParName(),
2583 pServDlg
->GetParUser(),
2584 pServDlg
->GetParPass() );
2585 pNewDPObject
.reset(new ScDPObject(pDoc
));
2586 pNewDPObject
->SetServiceData( aServDesc
);
2589 else if ( pTypeDlg
->IsDatabase() )
2591 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2593 ::boost::scoped_ptr
<AbstractScDataPilotDatabaseDlg
> pDataDlg(
2594 pFact
->CreateScDataPilotDatabaseDlg(
2595 pTabViewShell
->GetDialogParent()));
2597 OSL_ENSURE(pDataDlg
, "Dialog create fail!");
2598 if ( pDataDlg
->Execute() == RET_OK
)
2600 ScImportSourceDesc
aImpDesc(pDoc
);
2601 pDataDlg
->GetValues( aImpDesc
);
2602 pNewDPObject
.reset(new ScDPObject(pDoc
));
2603 pNewDPObject
->SetImportDesc( aImpDesc
);
2606 else if (pTypeDlg
->IsNamedRange())
2608 OUString aName
= pTypeDlg
->GetSelectedNamedRange();
2609 ScSheetSourceDesc
aShtDesc(pDoc
);
2610 aShtDesc
.SetRangeName(aName
);
2611 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2614 pNewDPObject
.reset(new ScDPObject(pDoc
));
2615 pNewDPObject
->SetSheetDesc(aShtDesc
);
2620 //! use database ranges (select before type dialog?)
2622 ScMarkType eType
= GetViewData()->GetSimpleArea(aRange
);
2623 if ( (eType
& SC_MARK_SIMPLE
) == SC_MARK_SIMPLE
)
2625 // Shrink the range to the data area.
2626 SCCOL nStartCol
= aRange
.aStart
.Col(), nEndCol
= aRange
.aEnd
.Col();
2627 SCROW nStartRow
= aRange
.aStart
.Row(), nEndRow
= aRange
.aEnd
.Row();
2628 if (pDoc
->ShrinkToDataArea(aRange
.aStart
.Tab(), nStartCol
, nStartRow
, nEndCol
, nEndRow
))
2630 aRange
.aStart
.SetCol(nStartCol
);
2631 aRange
.aStart
.SetRow(nStartRow
);
2632 aRange
.aEnd
.SetCol(nEndCol
);
2633 aRange
.aEnd
.SetRow(nEndRow
);
2634 rMark
.SetMarkArea(aRange
);
2635 pTabViewShell
->MarkRange(aRange
);
2639 if ( pDoc
->HasSubTotalCells( aRange
) )
2641 // confirm selection if it contains SubTotal cells
2643 QueryBox
aBox( pTabViewShell
->GetDialogParent(),
2644 WinBits(WB_YES_NO
| WB_DEF_YES
),
2645 ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL
) );
2646 if (aBox
.Execute() == RET_NO
)
2651 ScSheetSourceDesc
aShtDesc(pDoc
);
2652 aShtDesc
.SetSourceRange(aRange
);
2653 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2656 pNewDPObject
.reset(new ScDPObject(pDoc
));
2657 pNewDPObject
->SetSheetDesc( aShtDesc
);
2660 // output below source data
2661 if ( aRange
.aEnd
.Row()+2 <= MAXROW
- 4 )
2662 aDestPos
= ScAddress( aRange
.aStart
.Col(),
2663 aRange
.aEnd
.Row()+2,
2664 aRange
.aStart
.Tab() );
2672 // Error occurred during data creation. Launch an error and bail out.
2673 InfoBox
aBox(pTabViewShell
->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId
));
2679 pNewDPObject
->SetOutRange( aDestPos
);
2682 pTabViewShell
->SetDialogDPObject( pNewDPObject
.get() ); // is copied
2685 // start layout dialog
2687 sal_uInt16 nId
= ScPivotLayoutWrapper::GetChildWindowId();
2688 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2689 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2690 pScMod
->SetRefDialog( nId
, pWnd
? false : true );
2694 void ScCellShell::ExecuteXMLSourceDialog()
2696 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2700 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2704 ScModule
* pScMod
= SC_MOD();
2706 sal_uInt16 nId
= ScXMLSourceDlgWrapper::GetChildWindowId();
2707 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
2708 SfxChildWindow
* pWnd
= pViewFrame
->GetChildWindow(nId
);
2709 pScMod
->SetRefDialog(nId
, pWnd
? false : true);
2712 void ScCellShell::ExecuteSubtotals(SfxRequest
& rReq
)
2714 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2715 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2718 pTabViewShell
->DoSubTotals( ((const ScSubTotalItem
&) pArgs
->Get( SCITEM_SUBTDATA
)).
2719 GetSubTotalData() );
2724 boost::scoped_ptr
<SfxAbstractTabDialog
> pDlg
;
2725 ScSubTotalParam aSubTotalParam
;
2726 SfxItemSet
aArgSet( GetPool(), SCITEM_SUBTDATA
, SCITEM_SUBTDATA
);
2728 // Only get existing named database range.
2729 ScDBData
* pDBData
= pTabViewShell
->GetDBData(true, SC_DB_OLD
);
2732 // No existing DB data at this position. Create an
2734 pDBData
= pTabViewShell
->GetAnonymousDBData();
2736 pDBData
->GetArea(aDataRange
);
2737 pTabViewShell
->MarkRange(aDataRange
, false);
2740 pDBData
->GetSubTotalParam( aSubTotalParam
);
2741 aSubTotalParam
.bRemoveOnly
= false;
2743 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
, GetViewData(), &aSubTotalParam
) );
2744 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2745 assert(pFact
); //"ScAbstractFactory create fail
2747 pDlg
.reset(pFact
->CreateScSubTotalDlg(pTabViewShell
->GetDialogParent(), &aArgSet
));
2748 assert(pDlg
); // "Dialog create fail
2749 pDlg
->SetCurPageId(1);
2751 short bResult
= pDlg
->Execute();
2753 if ( (bResult
== RET_OK
) || (bResult
== SCRET_REMOVE
) )
2755 const SfxItemSet
* pOutSet
= NULL
;
2757 if ( bResult
== RET_OK
)
2759 pOutSet
= pDlg
->GetOutputItemSet();
2761 ((const ScSubTotalItem
&)
2762 pOutSet
->Get( SCITEM_SUBTDATA
)).
2765 else // if (bResult == SCRET_REMOVE)
2768 aSubTotalParam
.bRemoveOnly
= true;
2769 aSubTotalParam
.bReplace
= true;
2770 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
,
2772 &aSubTotalParam
) );
2775 pTabViewShell
->DoSubTotals( aSubTotalParam
);
2776 rReq
.Done( *pOutSet
);
2779 GetViewData()->GetDocShell()->CancelAutoDBRange();
2782 void ScCellShell::ExecuteFillSingleEdit()
2784 ScAddress aCurPos
= GetViewData()->GetCurPos();
2788 if (aCurPos
.Row() > 0)
2790 // Get the initial text value from the above cell.
2792 ScDocument
* pDoc
= GetViewData()->GetDocument();
2793 ScRefCellValue aCell
;
2794 ScAddress aPrevPos
= aCurPos
;
2795 aPrevPos
.IncRow(-1);
2796 aCell
.assign(*pDoc
, aPrevPos
);
2798 if (aCell
.meType
== CELLTYPE_FORMULA
)
2801 const ScTokenArray
* pCode
= aCell
.mpFormula
->GetCode();
2802 sc::TokenStringContext
aCxt(pDoc
, pDoc
->GetGrammar());
2803 aInit
+= pCode
->CreateString(aCxt
, aCurPos
);
2806 aInit
= aCell
.getString(pDoc
);
2809 SC_MOD()->SetInputMode(SC_INPUT_TABLE
, &aInit
);
2812 IMPL_LINK_NOARG(ScCellShell
, DialogClosed
)
2814 OSL_ENSURE( pImpl
->m_pLinkedDlg
, "ScCellShell::DialogClosed(): invalid request" );
2815 OSL_ENSURE( pImpl
->m_pRequest
, "ScCellShell::DialogClosed(): invalid request" );
2816 OUString sFile
, sFilter
, sOptions
, sSource
;
2817 sal_uLong nRefresh
= 0;
2819 if ( pImpl
->m_pLinkedDlg
->GetResult() == RET_OK
)
2821 sFile
= pImpl
->m_pLinkedDlg
->GetURL();
2822 sFilter
= pImpl
->m_pLinkedDlg
->GetFilter();
2823 sOptions
= pImpl
->m_pLinkedDlg
->GetOptions();
2824 sSource
= pImpl
->m_pLinkedDlg
->GetSource();
2825 nRefresh
= pImpl
->m_pLinkedDlg
->GetRefresh();
2826 if ( !sFile
.isEmpty() )
2827 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_NAME
, sFile
) );
2828 if ( !sFilter
.isEmpty() )
2829 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILTER_NAME
, sFilter
) );
2830 if ( !sOptions
.isEmpty() )
2831 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS
, sOptions
) );
2832 if ( !sSource
.isEmpty() )
2833 pImpl
->m_pRequest
->AppendItem( SfxStringItem( FN_PARAM_1
, sSource
) );
2835 pImpl
->m_pRequest
->AppendItem( SfxUInt32Item( FN_PARAM_2
, nRefresh
) );
2838 ExecuteExternalSource( sFile
, sFilter
, sOptions
, sSource
, nRefresh
, *(pImpl
->m_pRequest
) );
2842 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */