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"
83 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
84 #include <com/sun/star/lang/XInitialization.hpp>
85 #include <com/sun/star/beans/PropertyValue.hpp>
86 #include <com/sun/star/beans/XPropertySet.hpp>
87 #include <cppuhelper/bootstrap.hxx>
88 #include <com/sun/star/i18n/TransliterationModules.hpp>
89 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
91 #include <boost/scoped_ptr.hpp>
93 using namespace ::com::sun::star
;
94 using namespace ::com::sun::star::beans
;
95 using namespace ::com::sun::star::uno
;
97 //------------------------------------------------------------------
98 void ScCellShell::ExecuteEdit( SfxRequest
& rReq
)
100 ScModule
* pScMod
= SC_MOD();
101 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
102 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
103 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
104 sal_uInt16 nSlot
= rReq
.GetSlot();
106 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
109 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
113 case FID_DEFINE_NAME
:
116 case FID_INSERT_NAME
:
117 case SID_SPELL_DIALOG
:
118 case SID_HANGUL_HANJA_CONVERSION
:
119 case SID_OPENDLG_CONDFRMT
:
120 case SID_OPENDLG_COLORSCALE
:
121 case SID_OPENDLG_DATABAR
:
123 pScMod
->InputEnterHandler();
124 pTabViewShell
->UpdateInputHandler();
135 // insert / delete cells / rows / columns
139 pTabViewShell
->InsertCells(INS_INSROWS
);
144 pTabViewShell
->InsertCells(INS_INSCOLS
);
148 case FID_INS_CELLSDOWN
:
149 pTabViewShell
->InsertCells(INS_CELLSDOWN
);
153 case FID_INS_CELLSRIGHT
:
154 pTabViewShell
->InsertCells(INS_CELLSRIGHT
);
159 pTabViewShell
->DeleteCells( DEL_DELROWS
);
164 pTabViewShell
->DeleteCells( DEL_DELCOLS
);
170 InsCellCmd eCmd
=INS_NONE
;
174 const SfxPoolItem
* pItem
;
177 if( pReqArgs
->HasItem( FID_INS_CELL
, &pItem
) )
178 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
179 if( !aFlags
.isEmpty() )
183 case 'V': eCmd
= INS_CELLSDOWN
;break;
184 case '>': eCmd
= INS_CELLSRIGHT
;break;
185 case 'R': eCmd
= INS_INSROWS
;break;
186 case 'C': eCmd
= INS_INSCOLS
;break;
192 if ( GetViewData()->SimpleColMarked() )
194 else if ( GetViewData()->SimpleRowMarked() )
198 ScDocument
* pDoc
= GetViewData()->GetDocument();
199 sal_Bool bTheFlag
=(pDoc
->GetChangeTrack()!=NULL
);
201 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
202 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
204 AbstractScInsertCellDlg
* pDlg
= pFact
->CreateScInsertCellDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_INSCELL
, bTheFlag
);
205 OSL_ENSURE(pDlg
, "Dialog create fail!");
206 if (pDlg
->Execute() == RET_OK
)
207 eCmd
= pDlg
->GetInsCellCmd();
214 pTabViewShell
->InsertCells( eCmd
);
222 case INS_CELLSDOWN
: aParam
= "V"; break;
223 case INS_CELLSRIGHT
: aParam
= ">"; break;
224 case INS_INSROWS
: aParam
= "R"; break;
225 case INS_INSCOLS
: aParam
= "C"; break;
228 // added to avoid warnings
231 rReq
.AppendItem( SfxStringItem( FID_INS_CELL
, aParam
) );
238 case FID_DELETE_CELL
:
240 DelCellCmd eCmd
= DEL_NONE
;
244 const SfxPoolItem
* pItem
;
247 if( pReqArgs
->HasItem( FID_DELETE_CELL
, &pItem
) )
248 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
249 if( !aFlags
.isEmpty() )
253 case 'U': eCmd
= DEL_CELLSUP
;break;
254 case 'L': eCmd
= DEL_CELLSLEFT
;break;
255 case 'R': eCmd
= DEL_DELROWS
;break;
256 case 'C': eCmd
= DEL_DELCOLS
;break;
262 if ( GetViewData()->SimpleColMarked() )
264 else if ( GetViewData()->SimpleRowMarked() )
269 ScDocument
* pDoc
= GetViewData()->GetDocument();
270 bool bTheFlag
=GetViewData()->IsMultiMarked() ||
271 (GetViewData()->GetSimpleArea(aRange
) == SC_MARK_SIMPLE_FILTERED
) ||
272 (pDoc
->GetChangeTrack() != NULL
);
274 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
275 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
277 AbstractScDeleteCellDlg
* pDlg
= pFact
->CreateScDeleteCellDlg( pTabViewShell
->GetDialogParent(), bTheFlag
);
278 OSL_ENSURE(pDlg
, "Dialog create fail!");
280 if (pDlg
->Execute() == RET_OK
)
281 eCmd
= pDlg
->GetDelCellCmd();
286 if (eCmd
!= DEL_NONE
)
288 pTabViewShell
->DeleteCells( eCmd
);
296 case DEL_CELLSUP
: aParam
= "U"; break;
297 case DEL_CELLSLEFT
: aParam
= "L"; break;
298 case DEL_DELROWS
: aParam
= "R"; break;
299 case DEL_DELCOLS
: aParam
= "C"; break;
302 // added to avoid warnings
305 rReq
.AppendItem( SfxStringItem( FID_DELETE_CELL
, aParam
) );
313 // delete contents from cells
316 case SID_DELETE_CONTENTS
:
317 pTabViewShell
->DeleteContents( IDF_CONTENTS
);
323 sal_uInt16 nFlags
= IDF_NONE
;
325 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
327 const SfxPoolItem
* pItem
;
328 OUString
aFlags('A');
330 if( pReqArgs
->HasItem( SID_DELETE
, &pItem
) )
331 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
333 aFlags
= aFlags
.toAsciiUpperCase();
334 sal_Bool bCont
= sal_True
;
336 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
342 bCont
= false; // don't continue!
344 case 'S': nFlags
|= IDF_STRING
; break;
345 case 'V': nFlags
|= IDF_VALUE
; break;
346 case 'D': nFlags
|= IDF_DATETIME
; break;
347 case 'F': nFlags
|= IDF_FORMULA
; break;
348 case 'N': nFlags
|= IDF_NOTE
; break;
349 case 'T': nFlags
|= IDF_ATTRIB
; break;
350 case 'O': nFlags
|= IDF_OBJECTS
; break;
356 ScEditableTester
aTester( pTabViewShell
);
357 if (aTester
.IsEditable())
359 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
360 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
362 AbstractScDeleteContentsDlg
* pDlg
= pFact
->CreateScDeleteContentsDlg(pTabViewShell
->GetDialogParent());
363 OSL_ENSURE(pDlg
, "Dialog create fail!");
364 ScDocument
* pDoc
= GetViewData()->GetDocument();
365 SCTAB nTab
= GetViewData()->GetTabNo();
366 if ( pDoc
->IsTabProtected(nTab
) )
367 pDlg
->DisableObjects();
368 if (pDlg
->Execute() == RET_OK
)
370 nFlags
= pDlg
->GetDelContentsCmdBits();
375 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
378 if( nFlags
!= IDF_NONE
)
380 pTabViewShell
->DeleteContents( nFlags
);
386 if( nFlags
== IDF_ALL
)
392 if( nFlags
& IDF_STRING
) aFlags
+= "S";
393 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
394 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
395 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
396 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
397 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
398 if( nFlags
& IDF_OBJECTS
) aFlags
+= "O";
401 rReq
.AppendItem( SfxStringItem( SID_DELETE
, aFlags
) );
412 case FID_FILL_TO_BOTTOM
:
413 pTabViewShell
->FillSimple( FILL_TO_BOTTOM
);
417 case FID_FILL_TO_RIGHT
:
418 pTabViewShell
->FillSimple( FILL_TO_RIGHT
);
422 case FID_FILL_TO_TOP
:
423 pTabViewShell
->FillSimple( FILL_TO_TOP
);
427 case FID_FILL_TO_LEFT
:
428 pTabViewShell
->FillSimple( FILL_TO_LEFT
);
434 sal_uInt16 nFlags
= IDF_NONE
;
435 sal_uInt16 nFunction
= PASTE_NOFUNC
;
436 sal_Bool bSkipEmpty
= false;
437 sal_Bool bAsLink
= false;
439 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
441 const SfxPoolItem
* pItem
;
442 OUString
aFlags('A');
444 if( pReqArgs
->HasItem( FID_FILL_TAB
, &pItem
) )
445 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
447 aFlags
= aFlags
.toAsciiUpperCase();
448 sal_Bool bCont
= sal_True
;
450 for (sal_Int32 i
=0; bCont
&& i
< aFlags
.getLength(); ++i
)
456 bCont
= false; // don't continue!
458 case 'S': nFlags
|= IDF_STRING
; break;
459 case 'V': nFlags
|= IDF_VALUE
; break;
460 case 'D': nFlags
|= IDF_DATETIME
; break;
461 case 'F': nFlags
|= IDF_FORMULA
; break;
462 case 'N': nFlags
|= IDF_NOTE
; break;
463 case 'T': nFlags
|= IDF_ATTRIB
; break;
469 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
470 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
472 AbstractScInsertContentsDlg
* pDlg
= pFact
->CreateScInsertContentsDlg( pTabViewShell
->GetDialogParent(),
473 RID_SCDLG_INSCONT
, 0, /* nCheckDefaults */
474 &ScGlobal::GetRscString(STR_FILL_TAB
));
475 OSL_ENSURE(pDlg
, "Dialog create fail!");
476 pDlg
->SetFillMode(true);
478 if (pDlg
->Execute() == RET_OK
)
480 nFlags
= pDlg
->GetInsContentsCmdBits();
481 nFunction
= pDlg
->GetFormulaCmdBits();
482 bSkipEmpty
= pDlg
->IsSkipEmptyCells();
483 bAsLink
= pDlg
->IsLink();
484 // there is no MoveMode with fill tabs
489 if( nFlags
!= IDF_NONE
)
491 pTabViewShell
->FillTab( nFlags
, nFunction
, bSkipEmpty
, bAsLink
);
497 if( nFlags
== IDF_ALL
)
503 if( nFlags
& IDF_STRING
) aFlags
+= "S";
504 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
505 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
506 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
507 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
508 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
511 rReq
.AppendItem( SfxStringItem( FID_FILL_TAB
, aFlags
) );
518 case FID_FILL_SERIES
:
526 sal_uInt16 nPossDir
= FDS_OPT_NONE
;
527 FillDir eFillDir
= FILL_TO_BOTTOM
;
528 FillCmd eFillCmd
= FILL_LINEAR
;
529 FillDateCmd eFillDateCmd
= FILL_DAY
;
530 double fStartVal
= MAXDOUBLE
;
532 double fMaxVal
= MAXDOUBLE
;
533 sal_Bool bDoIt
= false;
535 GetViewData()->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
536 nEndCol
, nEndRow
, nEndTab
);
538 if( nStartCol
!=nEndCol
)
540 nPossDir
|= FDS_OPT_HORZ
;
541 eFillDir
=FILL_TO_RIGHT
;
544 if( nStartRow
!=nEndRow
)
546 nPossDir
|= FDS_OPT_VERT
;
547 eFillDir
=FILL_TO_BOTTOM
;
550 ScDocument
* pDoc
= GetViewData()->GetDocument();
551 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
555 const SfxPoolItem
* pItem
;
556 OUString aFillDir
, aFillCmd
, aFillDateCmd
;
557 OUString aFillStep
, aFillStart
, aFillMax
;
563 if( pReqArgs
->HasItem( FID_FILL_SERIES
, &pItem
) )
564 aFillDir
= ((const SfxStringItem
*)pItem
)->GetValue();
565 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
566 aFillCmd
= ((const SfxStringItem
*)pItem
)->GetValue();
567 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
568 aFillDateCmd
= ((const SfxStringItem
*)pItem
)->GetValue();
569 if( pReqArgs
->HasItem( FN_PARAM_3
, &pItem
) )
570 aFillStep
= ((const SfxStringItem
*)pItem
)->GetValue();
571 if( pReqArgs
->HasItem( FN_PARAM_4
, &pItem
) )
572 aFillStart
= ((const SfxStringItem
*)pItem
)->GetValue();
573 if( pReqArgs
->HasItem( FN_PARAM_5
, &pItem
) )
574 aFillMax
= ((const SfxStringItem
*)pItem
)->GetValue();
576 if( !aFillDir
.isEmpty() )
577 switch( aFillDir
[0] )
579 case 'B': case 'b': eFillDir
=FILL_TO_BOTTOM
; break;
580 case 'R': case 'r': eFillDir
=FILL_TO_RIGHT
; break;
581 case 'T': case 't': eFillDir
=FILL_TO_TOP
; break;
582 case 'L': case 'l': eFillDir
=FILL_TO_LEFT
; break;
585 if( !aFillCmd
.isEmpty() )
586 switch( aFillCmd
[0] )
588 case 'S': case 's': eFillCmd
=FILL_SIMPLE
; break;
589 case 'L': case 'l': eFillCmd
=FILL_LINEAR
; break;
590 case 'G': case 'g': eFillCmd
=FILL_GROWTH
; break;
591 case 'D': case 'd': eFillCmd
=FILL_DATE
; break;
592 case 'A': case 'a': eFillCmd
=FILL_AUTO
; break;
595 if( !aFillDateCmd
.isEmpty() )
596 switch( aFillDateCmd
[0] )
598 case 'D': case 'd': eFillDateCmd
=FILL_DAY
; break;
599 case 'W': case 'w': eFillDateCmd
=FILL_WEEKDAY
; break;
600 case 'M': case 'm': eFillDateCmd
=FILL_MONTH
; break;
601 case 'Y': case 'y': eFillDateCmd
=FILL_YEAR
; break;
605 if( pFormatter
->IsNumberFormat( aFillStart
, nKey
, fTmpVal
))
609 if( pFormatter
->IsNumberFormat( aFillStep
, nKey
, fTmpVal
))
613 if( pFormatter
->IsNumberFormat( aFillMax
, nKey
, fTmpVal
))
619 else // (pReqArgs == NULL) => raise Dialog
621 sal_uInt32 nPrivFormat
;
623 pDoc
->GetNumberFormat( nStartCol
, nStartRow
, nStartTab
, nPrivFormat
);
624 pDoc
->GetCellType( nStartCol
, nStartRow
, nStartTab
,eCellType
);
625 const SvNumberformat
* pPrivEntry
= pFormatter
->GetEntry( nPrivFormat
);
628 OSL_FAIL("Numberformat not found !!!");
632 short nPrivType
= pPrivEntry
->GetType();
633 if ( ( nPrivType
& NUMBERFORMAT_DATE
)>0)
637 else if(eCellType
==CELLTYPE_STRING
)
646 // suggest default Startvalue only, when just 1 row or column
647 if ( nStartCol
== nEndCol
|| nStartRow
== nEndRow
)
649 double fInputEndVal
= 0.0;
652 pDoc
->GetInputString( nStartCol
, nStartRow
, nStartTab
, aStartStr
);
653 pDoc
->GetValue( nStartCol
, nStartRow
, nStartTab
, fStartVal
);
656 if(eFillDir
==FILL_TO_BOTTOM
&& nStartRow
< nEndRow
)
658 pDoc
->GetInputString( nStartCol
, nStartRow
+1, nStartTab
, aEndStr
);
659 if(!aEndStr
.isEmpty())
661 pDoc
->GetValue( nStartCol
, nStartRow
+1, nStartTab
, fInputEndVal
);
662 fIncVal
=fInputEndVal
-fStartVal
;
667 if(nStartCol
< nEndCol
)
669 pDoc
->GetInputString( nStartCol
+1, nStartRow
, nStartTab
, aEndStr
);
670 if(!aEndStr
.isEmpty())
672 pDoc
->GetValue( nStartCol
+1, nStartRow
, nStartTab
, fInputEndVal
);
673 fIncVal
=fInputEndVal
-fStartVal
;
677 if(eFillCmd
==FILL_DATE
)
679 Date aNullDate
= *pDoc
->GetFormatTable()->GetNullDate();
680 Date aStartDate
= aNullDate
;
681 aStartDate
+= (long)fStartVal
;
682 Date aEndDate
= aNullDate
;
683 aEndDate
+= (long)fInputEndVal
;
686 if(aStartDate
.GetYear()!=aEndDate
.GetYear())
688 eFillDateCmd
= FILL_YEAR
;
689 fTempDate
=aEndDate
.GetYear()-aStartDate
.GetYear();
691 if(aStartDate
.GetMonth()!=aEndDate
.GetMonth())
693 eFillDateCmd
= FILL_MONTH
;
694 fTempDate
=fTempDate
*12+aEndDate
.GetMonth()-aStartDate
.GetMonth();
696 if(aStartDate
.GetDay()==aEndDate
.GetDay())
702 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
703 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
705 AbstractScFillSeriesDlg
* pDlg
= pFact
->CreateScFillSeriesDlg( pTabViewShell
->GetDialogParent(),
707 eFillDir
, eFillCmd
, eFillDateCmd
,
708 aStartStr
, fIncVal
, fMaxVal
,
710 OSL_ENSURE(pDlg
, "Dialog create fail!");
712 if ( nStartCol
!= nEndCol
&& nStartRow
!= nEndRow
)
714 pDlg
->SetEdStartValEnabled(false);
717 if ( pDlg
->Execute() == RET_OK
)
719 eFillDir
= pDlg
->GetFillDir();
720 eFillCmd
= pDlg
->GetFillCmd();
721 eFillDateCmd
= pDlg
->GetFillDateCmd();
723 if(eFillCmd
==FILL_AUTO
)
725 OUString aStr
= pDlg
->GetStartStr();
727 pTabViewShell
->EnterData( nStartCol
, nStartRow
, nStartTab
, aStr
);
729 fStartVal
= pDlg
->GetStart();
730 fIncVal
= pDlg
->GetStep();
731 fMaxVal
= pDlg
->GetMax();
739 //nScFillModeMouseModifier = 0; // no Ctrl/Copy
740 pTabViewShell
->FillSeries( eFillDir
, eFillCmd
, eFillDateCmd
, fStartVal
, fIncVal
, fMaxVal
);
749 case FILL_TO_BOTTOM
: aPara
= "B"; break;
750 case FILL_TO_RIGHT
: aPara
= "R"; break;
751 case FILL_TO_TOP
: aPara
= "T"; break;
752 case FILL_TO_LEFT
: aPara
= "L"; break;
755 rReq
.AppendItem( SfxStringItem( FID_FILL_SERIES
, aPara
) );
759 case FILL_SIMPLE
: aPara
= "S"; break;
760 case FILL_LINEAR
: aPara
= "L"; break;
761 case FILL_GROWTH
: aPara
= "G"; break;
762 case FILL_DATE
: aPara
= "D"; break;
763 case FILL_AUTO
: aPara
= "A"; break;
766 rReq
.AppendItem( SfxStringItem( FN_PARAM_1
, aPara
) );
768 switch( eFillDateCmd
)
770 case FILL_DAY
: aPara
= "D"; break;
771 case FILL_WEEKDAY
: aPara
= "W"; break;
772 case FILL_MONTH
: aPara
= "M"; break;
773 case FILL_YEAR
: aPara
= "Y"; break;
776 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, aPara
) );
778 sal_uLong nFormatKey
= pFormatter
->GetStandardFormat(NUMBERFORMAT_NUMBER
,
781 pFormatter
->GetOutputString( fIncVal
, nFormatKey
, aPara
, &pColor
);
782 rReq
.AppendItem( SfxStringItem( FN_PARAM_3
, aPara
) );
784 pFormatter
->GetOutputString( fStartVal
, nFormatKey
, aPara
, &pColor
);
785 rReq
.AppendItem( SfxStringItem( FN_PARAM_4
, aPara
) );
787 pFormatter
->GetOutputString( fMaxVal
, nFormatKey
, aPara
, &pColor
);
788 rReq
.AppendItem( SfxStringItem( FN_PARAM_5
, aPara
) );
802 SCTAB nStartTab
, nEndTab
;
804 GetViewData()->GetFillData( nStartCol
, nStartRow
, nEndCol
, nEndRow
);
805 SCCOL nFillCol
= GetViewData()->GetRefEndX();
806 SCROW nFillRow
= GetViewData()->GetRefEndY();
807 ScDocument
* pDoc
= GetViewData()->GetDocument();
809 if( pReqArgs
!= NULL
)
811 const SfxPoolItem
* pItem
;
813 if( pReqArgs
->HasItem( FID_FILL_AUTO
, &pItem
) )
815 ScAddress aScAddress
;
816 OUString aArg
= ((const SfxStringItem
*)pItem
)->GetValue();
818 if( aScAddress
.Parse( aArg
, pDoc
, pDoc
->GetAddressConvention() ) & SCA_VALID
)
820 nFillRow
= aScAddress
.Row();
821 nFillCol
= aScAddress
.Col();
825 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
826 nEndCol
,nEndRow
,nEndTab
);
828 else // call via mouse
830 // not in a merged cell
832 if ( nStartCol
== nEndCol
&& nStartRow
== nEndRow
)
834 SCCOL nMergeCol
= nStartCol
;
835 SCROW nMergeRow
= nStartRow
;
836 if ( GetViewData()->GetDocument()->ExtendMerge(
837 nStartCol
, nStartRow
, nMergeCol
, nMergeRow
,
838 GetViewData()->GetTabNo() ) )
840 if ( nFillCol
>= nStartCol
&& nFillCol
<= nMergeCol
&& nFillRow
== nStartRow
)
841 nFillCol
= nStartCol
;
842 if ( nFillRow
>= nStartRow
&& nFillRow
<= nMergeRow
&& nFillCol
== nStartCol
)
843 nFillRow
= nStartRow
;
848 if ( nFillCol
!= nEndCol
|| nFillRow
!= nEndRow
)
850 if ( nFillCol
==nEndCol
|| nFillRow
==nEndRow
)
852 FillDir eDir
= FILL_TO_BOTTOM
;
855 if ( nFillCol
==nEndCol
)
857 if ( nFillRow
> nEndRow
)
859 eDir
= FILL_TO_BOTTOM
;
860 nCount
= nFillRow
- nEndRow
;
862 else if ( nFillRow
< nStartRow
)
865 nCount
= nStartRow
- nFillRow
;
870 if ( nFillCol
> nEndCol
)
872 eDir
= FILL_TO_RIGHT
;
873 nCount
= nFillCol
- nEndCol
;
875 else if ( nFillCol
< nStartCol
)
878 nCount
= nStartCol
- nFillCol
;
884 pTabViewShell
->FillAuto( eDir
, nStartCol
, nStartRow
, nEndCol
, nEndRow
, nCount
);
888 ScAddress
aAdr( nFillCol
, nFillRow
, 0 );
889 OUString
aAdrStr(aAdr
.Format(SCR_ABS
, pDoc
, pDoc
->GetAddressConvention()));
891 rReq
.AppendItem( SfxStringItem( FID_FILL_AUTO
, aAdrStr
) );
899 OSL_FAIL( "Direction not unique for autofill" );
904 case SID_RANDOM_NUMBER_GENERATOR_DIALOG
:
906 sal_uInt16 nId
= ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
907 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
908 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
910 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
914 case SID_SAMPLING_DIALOG
:
916 sal_uInt16 nId
= ScSamplingDialogWrapper::GetChildWindowId();
917 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
918 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
920 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
923 case SID_DESCRIPTIVE_STATISTICS_DIALOG
:
925 sal_uInt16 nId
= ScDescriptiveStatisticsDialogWrapper::GetChildWindowId();
926 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
927 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
929 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
932 case SID_ANALYSIS_OF_VARIANCE_DIALOG
:
934 sal_uInt16 nId
= ScAnalysisOfVarianceDialogWrapper::GetChildWindowId();
935 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
936 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
938 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
941 case SID_CORRELATION_DIALOG
:
943 sal_uInt16 nId
= ScCorrelationDialogWrapper::GetChildWindowId();
944 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
945 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
947 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
950 case SID_COVARIANCE_DIALOG
:
952 sal_uInt16 nId
= ScCovarianceDialogWrapper::GetChildWindowId();
953 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
954 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
956 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
959 case SID_EXPONENTIAL_SMOOTHING_DIALOG
:
961 sal_uInt16 nId
= ScExponentialSmoothingDialogWrapper::GetChildWindowId();
962 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
963 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
965 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
968 case SID_MOVING_AVERAGE_DIALOG
:
970 sal_uInt16 nId
= ScMovingAverageDialogWrapper::GetChildWindowId();
971 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
972 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
974 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
979 // disposal (Outlines)
980 // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
983 case SID_OUTLINE_HIDE
:
984 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
985 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
986 pTabViewShell
->SetDataPilotDetails( false );
988 pTabViewShell
->HideMarkedOutlines();
992 case SID_OUTLINE_SHOW
:
994 ScDPObject
* pDPObj
= GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
995 GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
998 Sequence
<sheet::DataPilotFieldFilter
> aFilters
;
999 sal_uInt16 nOrientation
;
1000 if ( pTabViewShell
->HasSelectionForDrillDown( nOrientation
) )
1002 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1003 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1005 AbstractScDPShowDetailDlg
* pDlg
= pFact
->CreateScDPShowDetailDlg(
1006 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL
, *pDPObj
, nOrientation
);
1007 OSL_ENSURE(pDlg
, "Dialog create fail!");
1008 if ( pDlg
->Execute() == RET_OK
)
1010 OUString
aNewDimName( pDlg
->GetDimensionName() );
1011 pTabViewShell
->SetDataPilotDetails( true, &aNewDimName
);
1014 else if ( !pDPObj
->IsServiceData() &&
1015 pDPObj
->GetDataFieldPositionData(
1016 ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
1018 pTabViewShell
->ShowDataPilotSourceData( *pDPObj
, aFilters
);
1020 pTabViewShell
->SetDataPilotDetails(true);
1023 pTabViewShell
->ShowMarkedOutlines();
1028 case SID_OUTLINE_MAKE
:
1030 sal_Bool bColumns
= false;
1031 sal_Bool bOk
= sal_True
;
1033 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1034 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1036 ScDPNumGroupInfo aNumInfo
;
1037 aNumInfo
.mbEnable
= true;
1038 aNumInfo
.mbAutoStart
= true;
1039 aNumInfo
.mbAutoEnd
= true;
1040 sal_Int32 nParts
= 0;
1041 if ( pTabViewShell
->HasSelectionForDateGroup( aNumInfo
, nParts
) )
1043 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1044 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1045 Date
aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
1046 AbstractScDPDateGroupDlg
* pDlg
= pFact
->CreateScDPDateGroupDlg(
1047 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPDATEGROUP
,
1048 aNumInfo
, nParts
, aNullDate
);
1049 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1050 if( pDlg
->Execute() == RET_OK
)
1052 aNumInfo
= pDlg
->GetGroupInfo();
1053 pTabViewShell
->DateGroupDataPilot( aNumInfo
, pDlg
->GetDatePart() );
1056 else if ( pTabViewShell
->HasSelectionForNumGroup( aNumInfo
) )
1058 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1059 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1060 AbstractScDPNumGroupDlg
* pDlg
= pFact
->CreateScDPNumGroupDlg(
1061 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPNUMGROUP
, aNumInfo
);
1062 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1063 if( pDlg
->Execute() == RET_OK
)
1064 pTabViewShell
->NumGroupDataPilot( pDlg
->GetGroupInfo() );
1067 pTabViewShell
->GroupDataPilot();
1071 else if( pReqArgs
!= NULL
)
1073 const SfxPoolItem
* pItem
;
1076 if( pReqArgs
->HasItem( SID_OUTLINE_MAKE
, &pItem
) )
1078 OUString aCol
= ((const SfxStringItem
*)pItem
)->GetValue();
1079 aCol
= aCol
.toAsciiUpperCase();
1083 case 'R': bColumns
=false; bOk
= true;break;
1084 case 'C': bColumns
=true; bOk
= true;break;
1088 else // Dialog, when not whole rows/columns are marked
1090 if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
1091 bColumns
= sal_True
;
1092 else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
1096 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1097 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1099 AbstractScGroupDlg
* pDlg
= pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), false);
1100 OSL_ENSURE(pDlg
, "Dialog create fail!");
1101 if ( pDlg
->Execute() == RET_OK
)
1102 bColumns
= pDlg
->GetColsChecked();
1110 pTabViewShell
->MakeOutline( bColumns
);
1112 if( ! rReq
.IsAPI() )
1114 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1115 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_MAKE
, aCol
) );
1122 case SID_OUTLINE_REMOVE
:
1124 sal_Bool bColumns
= false;
1125 sal_Bool bOk
= sal_True
;
1127 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1128 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1130 pTabViewShell
->UngroupDataPilot();
1133 else if( pReqArgs
!= NULL
)
1135 const SfxPoolItem
* pItem
;
1138 if( pReqArgs
->HasItem( SID_OUTLINE_REMOVE
, &pItem
) )
1140 OUString aCol
= ((const SfxStringItem
*)pItem
)->GetValue();
1141 aCol
= aCol
.toAsciiUpperCase();
1145 case 'R': bColumns
=false; bOk
= true;break;
1146 case 'C': bColumns
=true; bOk
= true;break;
1150 else // Dialog only when removal for rows and columns is possible
1152 sal_Bool bColPoss
, bRowPoss
;
1153 pTabViewShell
->TestRemoveOutline( bColPoss
, bRowPoss
);
1154 if ( bColPoss
&& bRowPoss
)
1156 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1157 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1159 AbstractScGroupDlg
* pDlg
= pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), true);
1160 OSL_ENSURE(pDlg
, "Dialog create fail!");
1161 if ( pDlg
->Execute() == RET_OK
)
1162 bColumns
= pDlg
->GetColsChecked();
1167 else if ( bColPoss
)
1168 bColumns
= sal_True
;
1169 else if ( bRowPoss
)
1176 pTabViewShell
->RemoveOutline( bColumns
);
1178 if( ! rReq
.IsAPI() )
1180 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1181 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE
, aCol
) );
1193 case SID_COPY
: // for graphs in DrawShell
1195 WaitObject
aWait( GetViewData()->GetDialogParent() );
1196 pTabViewShell
->CopyToClip( NULL
, false, false, true );
1198 GetViewData()->SetPasteMode( (ScPasteFlags
) (SC_PASTE_MODE
| SC_PASTE_BORDER
) );
1199 pTabViewShell
->ShowCursor();
1200 pTabViewShell
->UpdateCopySourceOverlay();
1204 case SID_CUT
: // for graphs in DrawShell
1206 WaitObject
aWait( GetViewData()->GetDialogParent() );
1207 pTabViewShell
->CutToClip( NULL
, true );
1209 GetViewData()->SetPasteMode( (ScPasteFlags
)(SC_PASTE_MODE
| SC_PASTE_BORDER
));
1210 pTabViewShell
->ShowCursor();
1211 pTabViewShell
->UpdateCopySourceOverlay();
1217 ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell
, true );
1222 case SID_CLIPBOARD_FORMAT_ITEMS
:
1224 WaitObject
aWait( GetViewData()->GetDialogParent() );
1226 sal_uLong nFormat
= 0;
1227 const SfxPoolItem
* pItem
;
1229 pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
&&
1230 pItem
->ISA(SfxUInt32Item
) )
1232 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
1237 Window
* pWin
= GetViewData()->GetActiveWin();
1238 sal_Bool bCells
= ( ScTransferObj::GetOwnClipboard( pWin
) != NULL
);
1239 sal_Bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1240 sal_Bool bOle
= ( nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
);
1242 if ( bCells
&& bOle
)
1243 pTabViewShell
->PasteFromSystem();
1244 else if ( bDraw
&& bOle
)
1245 pTabViewShell
->PasteDraw();
1247 pTabViewShell
->PasteFromSystem(nFormat
);
1250 //? pTabViewShell->PasteFromSystem();
1254 pTabViewShell
->CellContentChanged();
1257 case FID_INS_CELL_CONTENTS
:
1259 sal_uInt16 nFlags
= IDF_NONE
;
1260 sal_uInt16 nFunction
= PASTE_NOFUNC
;
1261 sal_Bool bSkipEmpty
= false;
1262 sal_Bool bTranspose
= false;
1263 sal_Bool bAsLink
= false;
1264 InsCellCmd eMoveMode
= INS_NONE
;
1266 Window
* pWin
= GetViewData()->GetActiveWin();
1267 ScDocument
* pDoc
= GetViewData()->GetDocument();
1268 sal_Bool bOtherDoc
= !pDoc
->IsClipboardSource();
1269 ScTransferObj
* pOwnClip
= ScTransferObj::GetOwnClipboard( pWin
);
1272 // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1273 uno::Reference
<datatransfer::XTransferable
> aOwnClipRef( pOwnClip
);
1274 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
1276 const SfxPoolItem
* pItem
;
1277 OUString
aFlags('A');
1279 if( pReqArgs
->HasItem( FID_INS_CELL_CONTENTS
, &pItem
) )
1280 aFlags
= ((const SfxStringItem
*)pItem
)->GetValue();
1282 aFlags
= aFlags
.toAsciiUpperCase();
1283 sal_Bool bCont
= sal_True
;
1285 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
1291 bCont
= false; // don't continue!
1293 case 'S': nFlags
|= IDF_STRING
; break;
1294 case 'V': nFlags
|= IDF_VALUE
; break;
1295 case 'D': nFlags
|= IDF_DATETIME
; break;
1296 case 'F': nFlags
|= IDF_FORMULA
; break;
1297 case 'N': nFlags
|= IDF_NOTE
; break;
1298 case 'T': nFlags
|= IDF_ATTRIB
; break;
1302 SFX_REQUEST_ARG( rReq
, pFuncItem
, SfxUInt16Item
, FN_PARAM_1
, false );
1303 SFX_REQUEST_ARG( rReq
, pSkipItem
, SfxBoolItem
, FN_PARAM_2
, false );
1304 SFX_REQUEST_ARG( rReq
, pTransposeItem
, SfxBoolItem
, FN_PARAM_3
, false );
1305 SFX_REQUEST_ARG( rReq
, pLinkItem
, SfxBoolItem
, FN_PARAM_4
, false );
1306 SFX_REQUEST_ARG( rReq
, pMoveItem
, SfxInt16Item
, FN_PARAM_5
, false );
1308 nFunction
= pFuncItem
->GetValue();
1310 bSkipEmpty
= pSkipItem
->GetValue();
1311 if ( pTransposeItem
)
1312 bTranspose
= pTransposeItem
->GetValue();
1314 bAsLink
= pLinkItem
->GetValue();
1316 eMoveMode
= (InsCellCmd
) pMoveItem
->GetValue();
1320 ScEditableTester
aTester( pTabViewShell
);
1321 if (aTester
.IsEditable())
1323 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1324 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1326 AbstractScInsertContentsDlg
* pDlg
= pFact
->CreateScInsertContentsDlg( pTabViewShell
->GetDialogParent(),
1328 OSL_ENSURE(pDlg
, "Dialog create fail!");
1329 pDlg
->SetOtherDoc( bOtherDoc
);
1330 // if ChangeTrack MoveMode disable
1331 pDlg
->SetChangeTrack( pDoc
->GetChangeTrack() != NULL
);
1332 // fdo#56098 disable shift if necessary
1333 if ( !bOtherDoc
&& pOwnClip
)
1335 ScViewData
* pData
= GetViewData();
1336 if ( pData
->GetMarkData().GetTableSelect( pData
->GetTabNo() ) )
1338 SCCOL nStartX
, nEndX
, nClipStartX
, nClipSizeX
, nRangeSizeX
;
1339 SCROW nStartY
, nEndY
, nClipStartY
, nClipSizeY
, nRangeSizeY
;
1340 SCTAB nStartTab
, nEndTab
;
1341 pOwnClip
->GetDocument()->GetClipStart( nClipStartX
, nClipStartY
);
1342 pOwnClip
->GetDocument()->GetClipArea( nClipSizeX
, nClipSizeY
, sal_True
);
1344 if ( !( pData
->GetSimpleArea( nStartX
, nStartY
, nStartTab
,
1345 nEndX
, nEndY
, nEndTab
) == SC_MARK_SIMPLE
&&
1346 nStartTab
== nEndTab
) )
1348 // the destination is not a simple range,
1349 // assume the destination as the current cell
1350 nStartX
= nEndX
= pData
->GetCurX();
1351 nStartY
= nEndY
= pData
->GetCurY();
1352 nStartTab
= pData
->GetTabNo();
1354 // we now have clip- and range dimensions
1355 // the size of the destination area is the larger of the two
1356 nRangeSizeX
= nClipSizeX
>= nEndX
- nStartX
? nClipSizeX
: nEndX
- nStartX
;
1357 nRangeSizeY
= nClipSizeY
>= nEndY
- nStartY
? nClipSizeY
: nEndY
- nStartY
;
1358 // When the source and destination areas intersect things may go wrong,
1359 // especially if the area contains references. This may produce data loss
1360 // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1361 ScRange
aSource( nClipStartX
, nClipStartY
, nStartTab
,
1362 nClipStartX
+ nClipSizeX
, nClipStartY
+ nClipSizeY
, nStartTab
);
1363 ScRange
aDest( nStartX
, nStartY
, nStartTab
,
1364 nStartX
+ nRangeSizeX
, nStartY
+ nRangeSizeY
, nStartTab
);
1365 if ( pOwnClip
->GetDocument()->IsCutMode() && aSource
.Intersects( aDest
) )
1366 pDlg
->SetCellShiftDisabled( SC_CELL_SHIFT_DISABLE_DOWN
| SC_CELL_SHIFT_DISABLE_RIGHT
);
1369 //no conflict with intersecting ranges,
1370 //check if paste plus shift will fit on sheet
1371 //and disable shift-option if no fit
1372 int nDisableShiftX
= 0;
1373 int nDisableShiftY
= 0;
1375 //check if horizontal shift will fit
1376 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1377 MAXCOL
- nRangeSizeX
, nStartY
,
1378 MAXCOL
, nStartY
+ nRangeSizeY
, false ) )
1379 nDisableShiftX
= SC_CELL_SHIFT_DISABLE_RIGHT
;
1381 //check if vertical shift will fit
1382 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1383 nStartX
, MAXROW
- nRangeSizeY
,
1384 nStartX
+ nRangeSizeX
, MAXROW
, false ) )
1385 nDisableShiftY
= SC_CELL_SHIFT_DISABLE_DOWN
;
1387 if ( nDisableShiftX
|| nDisableShiftY
)
1388 pDlg
->SetCellShiftDisabled( nDisableShiftX
| nDisableShiftY
);
1392 if (pDlg
->Execute() == RET_OK
)
1394 nFlags
= pDlg
->GetInsContentsCmdBits();
1395 nFunction
= pDlg
->GetFormulaCmdBits();
1396 bSkipEmpty
= pDlg
->IsSkipEmptyCells();
1397 bTranspose
= pDlg
->IsTranspose();
1398 bAsLink
= pDlg
->IsLink();
1399 eMoveMode
= pDlg
->GetMoveMode();
1404 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
1407 if( nFlags
!= IDF_NONE
)
1410 WaitObject
aWait( GetViewData()->GetDialogParent() );
1411 if ( bAsLink
&& bOtherDoc
)
1412 pTabViewShell
->PasteFromSystem(SOT_FORMATSTR_ID_LINK
); // DDE insert
1415 pTabViewShell
->PasteFromClip( nFlags
, pOwnClip
->GetDocument(),
1416 nFunction
, bSkipEmpty
, bTranspose
, bAsLink
,
1417 eMoveMode
, IDF_NONE
, sal_True
); // allow warning dialog
1425 if( nFlags
== IDF_ALL
)
1431 if( nFlags
& IDF_STRING
) aFlags
+= "S";
1432 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
1433 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
1434 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
1435 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
1436 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
1439 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1440 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bSkipEmpty
) );
1441 rReq
.AppendItem( SfxBoolItem( FN_PARAM_3
, bTranspose
) );
1442 rReq
.AppendItem( SfxBoolItem( FN_PARAM_4
, bAsLink
) );
1443 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, nFunction
) );
1444 rReq
.AppendItem( SfxInt16Item( FN_PARAM_5
, (sal_Int16
) eMoveMode
) );
1450 pTabViewShell
->CellContentChanged(); // => PasteFromXXX ???
1452 case SID_PASTE_ONLY_VALUE
:
1453 case SID_PASTE_ONLY_TEXT
:
1454 case SID_PASTE_ONLY_FORMULA
:
1456 Window
* pWin
= GetViewData()->GetActiveWin();
1457 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1459 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1461 if ( nSlot
== SID_PASTE_ONLY_VALUE
)
1463 else if ( nSlot
== SID_PASTE_ONLY_TEXT
)
1467 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1468 ExecuteSlot( rReq
, GetInterface() );
1469 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1470 pTabViewShell
->CellContentChanged();
1473 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1476 case SID_PASTE_SPECIAL
:
1477 // differentiate between own cell data and draw objects/external data
1478 // this makes FID_INS_CELL_CONTENTS superfluous
1480 Window
* pWin
= GetViewData()->GetActiveWin();
1482 // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1483 const SfxPoolItem
* pItem
=NULL
;
1485 pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
&&
1486 pItem
->ISA(SfxUInt32Item
) )
1488 sal_uLong nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
1489 sal_Bool bRet
=sal_True
;
1491 WaitObject
aWait( GetViewData()->GetDialogParent() );
1492 sal_Bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1493 if ( bDraw
&& nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1494 pTabViewShell
->PasteDraw();
1496 bRet
= pTabViewShell
->PasteFromSystem(nFormat
, sal_True
); // TRUE: no error messages
1501 rReq
.SetReturnValue(SfxInt16Item(nSlot
, bRet
)); // 1 = success, 0 = fail
1505 // if format is not available -> fallback to request without parameters
1511 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1513 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1514 ExecuteSlot( rReq
, GetInterface() );
1515 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1517 else // draw objects or external data
1519 sal_Bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1521 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
1522 GetPossibleClipboardFormats( aFormats
);
1524 sal_uInt16 nFormatCount
= aFormats
.Count();
1527 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1528 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( pTabViewShell
->GetDialogParent() );
1531 for (sal_uInt16 i
=0; i
<nFormatCount
; i
++)
1533 sal_uLong nFormatId
= aFormats
.GetClipbrdFormatId( i
);
1534 OUString aName
= aFormats
.GetClipbrdFormatName( i
);
1535 // special case for paste dialog: '*' is replaced by object type
1536 if ( nFormatId
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1538 pDlg
->Insert( nFormatId
, aName
);
1541 TransferableDataHelper
aDataHelper(
1542 TransferableDataHelper::CreateFromSystemClipboard( pWin
) );
1543 sal_uLong nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
1547 WaitObject
aWait( GetViewData()->GetDialogParent() );
1548 if ( bDraw
&& nFormat
== SOT_FORMATSTR_ID_EMBED_SOURCE
)
1549 pTabViewShell
->PasteDraw();
1551 pTabViewShell
->PasteFromSystem(nFormat
);
1553 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1554 rReq
.AppendItem( SfxUInt32Item( nSlot
, nFormat
) );
1559 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1567 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1571 pTabViewShell
->CellContentChanged(); // => PasteFromSystem() ???
1578 case FID_INS_ROWBRK
:
1579 pTabViewShell
->InsertPageBreak( false );
1583 case FID_INS_COLBRK
:
1584 pTabViewShell
->InsertPageBreak( sal_True
);
1588 case FID_DEL_ROWBRK
:
1589 pTabViewShell
->DeletePageBreak( false );
1593 case FID_DEL_COLBRK
:
1594 pTabViewShell
->DeletePageBreak( sal_True
);
1598 case SID_DETECTIVE_ADD_PRED
:
1599 pTabViewShell
->DetectiveAddPred();
1603 case SID_DETECTIVE_DEL_PRED
:
1604 pTabViewShell
->DetectiveDelPred();
1608 case SID_DETECTIVE_ADD_SUCC
:
1609 pTabViewShell
->DetectiveAddSucc();
1613 case SID_DETECTIVE_DEL_SUCC
:
1614 pTabViewShell
->DetectiveDelSucc();
1618 case SID_DETECTIVE_ADD_ERR
:
1619 pTabViewShell
->DetectiveAddError();
1623 case SID_DETECTIVE_INVALID
:
1624 pTabViewShell
->DetectiveMarkInvalid();
1628 case SID_DETECTIVE_REFRESH
:
1629 pTabViewShell
->DetectiveRefresh();
1633 case SID_DETECTIVE_MARK_PRED
:
1634 pTabViewShell
->DetectiveMarkPred();
1636 case SID_DETECTIVE_MARK_SUCC
:
1637 pTabViewShell
->DetectiveMarkSucc();
1639 case SID_INSERT_CURRENT_DATE
:
1640 pTabViewShell
->InsertCurrentTime(
1641 NUMBERFORMAT_DATE
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE
));
1643 case SID_INSERT_CURRENT_TIME
:
1644 pTabViewShell
->InsertCurrentTime(
1645 NUMBERFORMAT_TIME
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME
));
1648 case SID_SPELL_DIALOG
:
1650 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
1651 if( rReq
.GetArgs() )
1652 pViewFrame
->SetChildWindow( SID_SPELL_DIALOG
,
1653 static_cast< const SfxBoolItem
& >( rReq
.GetArgs()->
1654 Get( SID_SPELL_DIALOG
) ).GetValue() );
1656 pViewFrame
->ToggleChildWindow( SID_SPELL_DIALOG
);
1658 pViewFrame
->GetBindings().Invalidate( SID_SPELL_DIALOG
);
1663 case SID_HANGUL_HANJA_CONVERSION
:
1664 pTabViewShell
->DoHangulHanjaConversion();
1667 case SID_CHINESE_CONVERSION
:
1669 //open ChineseTranslationDialog
1670 Reference
< XComponentContext
> xContext(
1671 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1674 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1677 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1678 xMCF
->createInstanceWithContext(
1679 OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
1680 , xContext
), UNO_QUERY
);
1681 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1684 // initialize dialog
1685 Reference
< awt::XWindow
> xDialogParentWindow(0);
1686 Sequence
<Any
> aSeq(1);
1687 Any
* pArray
= aSeq
.getArray();
1688 PropertyValue aParam
;
1689 aParam
.Name
= "ParentWindow";
1690 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1691 pArray
[0] <<= makeAny(aParam
);
1692 xInit
->initialize( aSeq
);
1695 sal_Int16 nDialogRet
= xDialog
->execute();
1696 if( RET_OK
== nDialogRet
)
1698 //get some parameters from the dialog
1699 sal_Bool bToSimplified
= sal_True
;
1700 sal_Bool bUseVariants
= sal_True
;
1701 sal_Bool bCommonTerms
= sal_True
;
1702 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1707 xProp
->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified
;
1708 xProp
->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants
;
1709 xProp
->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms
;
1716 //execute translation
1717 LanguageType eSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1718 LanguageType eTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1719 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1721 nOptions
|= i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1723 Font aTargetFont
= GetViewData()->GetActiveWin()->GetDefaultFont(
1724 DEFAULTFONT_CJK_SPREADSHEET
,
1725 eTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
1726 ScConversionParam
aConvParam( SC_CONVERSION_CHINESE_TRANSL
,
1727 eSourceLang
, eTargetLang
, aTargetFont
, nOptions
, false );
1728 pTabViewShell
->DoSheetConversion( aConvParam
);
1731 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1732 if( xComponent
.is() )
1733 xComponent
->dispose();
1740 pTabViewShell
->DoThesaurus();
1743 case SID_TOGGLE_REL
:
1744 pTabViewShell
->DoRefConversion();
1747 case SID_DEC_INDENT
:
1748 pTabViewShell
->ChangeIndent( false );
1750 case SID_INC_INDENT
:
1751 pTabViewShell
->ChangeIndent( sal_True
);
1756 sal_uInt16 nFlags
= pTabViewShell
->GetCreateNameFlags();
1758 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1759 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1761 AbstractScNameCreateDlg
* pDlg
= pFact
->CreateScNameCreateDlg(pTabViewShell
->GetDialogParent(), nFlags
);
1762 OSL_ENSURE(pDlg
, "Dialog create fail!");
1764 if( pDlg
->Execute() )
1766 nFlags
= pDlg
->GetFlags();
1767 pTabViewShell
->CreateNames(nFlags
);
1774 case SID_CONSOLIDATE
:
1776 const SfxPoolItem
* pItem
;
1777 if ( pReqArgs
&& SFX_ITEM_SET
==
1778 pReqArgs
->GetItemState( SCITEM_CONSOLIDATEDATA
, sal_True
, &pItem
) )
1780 const ScConsolidateParam
& rParam
=
1781 ((const ScConsolidateItem
*)pItem
)->GetData();
1783 pTabViewShell
->Consolidate( rParam
);
1784 GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam
);
1788 #ifndef DISABLE_SCRIPTING
1789 else if (rReq
.IsAPI())
1790 SbxBase::SetError(SbxERR_BAD_PARAMETER
);
1795 case SID_INS_FUNCTION
:
1797 const SfxBoolItem
* pOkItem
= (const SfxBoolItem
*)&pReqArgs
->Get( SID_DLG_RETOK
);
1799 if ( pOkItem
->GetValue() ) // OK
1802 const SfxStringItem
* pSItem
= (const SfxStringItem
*)&pReqArgs
->Get( SCITEM_STRING
);
1803 const SfxBoolItem
* pMatrixItem
= (const SfxBoolItem
*) &pReqArgs
->Get( SID_DLG_MATRIX
);
1805 aFormula
+= pSItem
->GetValue();
1806 pScMod
->ActivateInputWindow( &aFormula
, pMatrixItem
->GetValue() );
1810 pScMod
->ActivateInputWindow( NULL
);
1812 rReq
.Ignore(); // only SID_ENTER_STRING is recorded
1816 case FID_DEFINE_NAME
:
1819 const SfxPoolItem
* pItem
;
1820 OUString aName
, aSymbol
, aAttrib
;
1822 if( pReqArgs
->HasItem( FID_DEFINE_NAME
, &pItem
) )
1823 aName
= ((const SfxStringItem
*)pItem
)->GetValue();
1825 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
1826 aSymbol
= ((const SfxStringItem
*)pItem
)->GetValue();
1828 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
1829 aAttrib
= ((const SfxStringItem
*)pItem
)->GetValue();
1831 if ( !aName
.isEmpty() && !aSymbol
.isEmpty() )
1833 if (pTabViewShell
->InsertName( aName
, aSymbol
, aAttrib
))
1835 #ifndef DISABLE_SCRIPTING
1837 SbxBase::SetError( SbxERR_BAD_PARAMETER
); // Basic-error
1843 sal_uInt16 nId
= ScNameDlgWrapper::GetChildWindowId();
1844 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1845 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1847 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
1852 sal_uInt16 nId
= ScNameDefDlgWrapper::GetChildWindowId();
1853 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1854 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1856 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
1860 case SID_OPENDLG_CONDFRMT
:
1861 case SID_OPENDLG_COLORSCALE
:
1862 case SID_OPENDLG_DATABAR
:
1863 case SID_OPENDLG_ICONSET
:
1864 case SID_OPENDLG_CONDDATE
:
1867 ScRangeList aRangeList
;
1868 ScViewData
* pData
= GetViewData();
1869 pData
->GetMarkData().FillRangeListWithMarks(&aRangeList
, false);
1871 ScDocument
* pDoc
= GetViewData()->GetDocument();
1872 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
1874 //ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
1878 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
1879 if(aRangeList
.empty())
1881 ScRange
* pRange
= new ScRange(aPos
);
1882 aRangeList
.push_back(pRange
);
1886 const ScPatternAttr
* pPattern
= pDoc
->GetPattern(aPos
.Col(), aPos
.Row(), aPos
.Tab());
1887 const std::vector
<sal_uInt32
>& rCondFormats
= static_cast<const ScCondFormatItem
&>(pPattern
->GetItem(ATTR_CONDITIONAL
)).GetCondFormatData();
1888 bool bContainsCondFormat
= !rCondFormats
.empty();
1889 boost::scoped_ptr
<ScCondFormatDlg
> pCondFormatDlg
;
1890 if(bContainsCondFormat
)
1892 bool bContainsExistingCondFormat
= false;
1893 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList(aPos
.Tab());
1894 for (std::vector
<sal_uInt32
>::const_iterator itr
= rCondFormats
.begin(), itrEnd
= rCondFormats
.end();
1895 itr
!= itrEnd
; ++itr
)
1897 // check if at least one existing conditional format has the same range
1898 const ScConditionalFormat
* pCondFormat
= pList
->GetFormat(*itr
);
1902 bContainsExistingCondFormat
= true;
1903 const ScRangeList
& rCondFormatRange
= pCondFormat
->GetRange();
1904 if(rCondFormatRange
== aRangeList
)
1906 // found a matching range, edit this conditional format
1907 nKey
= pCondFormat
->GetKey();
1908 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, pCondFormat
, rCondFormatRange
, aPos
, condformat::dialog::NONE
) );
1913 // if not found a conditional format ask whether we should edit one of the existing
1914 // or should create a new overlapping conditional format
1916 if(!pCondFormatDlg
&& bContainsExistingCondFormat
)
1918 QueryBox
aBox( pTabViewShell
->GetDialogParent(), WinBits( WB_YES_NO
| WB_DEF_YES
),
1919 ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS
) );
1920 bool bEditExisting
= aBox
.Execute() == RET_YES
;
1923 // differentiate between ranges where one conditional format is defined
1924 // and several formats are defined
1925 // if we have only one => open the cond format dlg to edit it
1926 // otherwise open the manage cond format dlg
1927 if(rCondFormats
.size() == 1)
1929 const ScConditionalFormat
* pCondFormat
= pList
->GetFormat(rCondFormats
[0]);
1930 assert(pCondFormat
);
1931 const ScRangeList
& rCondFormatRange
= pCondFormat
->GetRange();
1932 nKey
= pCondFormat
->GetKey();
1933 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, pCondFormat
, rCondFormatRange
, aPos
, condformat::dialog::NONE
) );
1937 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1938 boost::scoped_ptr
<AbstractScCondFormatManagerDlg
> pDlg(pFact
->CreateScCondFormatMgrDlg( pTabViewShell
->GetDialogParent(), pDoc
, pList
, aPos
, RID_SCDLG_COND_FORMAT_MANAGER
));
1939 if(pDlg
->Execute() == RET_OK
&& pDlg
->CondFormatsChanged())
1941 ScConditionalFormatList
* pCondFormatList
= pDlg
->GetConditionalFormatList();
1942 pData
->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList
, aPos
.Tab());
1944 // we need step out here because we don't want to open the normal dialog
1950 // define an overlapping conditional format
1951 // does not need to be handled here
1959 condformat::dialog::ScCondFormatDialogType eType
= condformat::dialog::NONE
;
1962 case SID_OPENDLG_CONDFRMT
:
1963 eType
= condformat::dialog::CONDITION
;
1965 case SID_OPENDLG_COLORSCALE
:
1966 eType
= condformat::dialog::COLORSCALE
;
1968 case SID_OPENDLG_DATABAR
:
1969 eType
= condformat::dialog::DATABAR
;
1971 case SID_OPENDLG_ICONSET
:
1972 eType
= condformat::dialog::ICONSET
;
1974 case SID_OPENDLG_CONDDATE
:
1975 eType
= condformat::dialog::DATE
;
1981 pCondFormatDlg
.reset( new ScCondFormatDlg( pTabViewShell
->GetDialogParent(), pDoc
, NULL
, aRangeList
, aRangeList
.GetTopLeftCorner(), eType
) );
1985 pScMod
->SetRefDialog( nId
, true );
1987 if( pCondFormatDlg
->Execute() == RET_OK
)
1989 ScConditionalFormat
* pFormat
= pCondFormatDlg
->GetConditionalFormat();
1991 pData
->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey
, pFormat
, aPos
.Tab(), pFormat
->GetRange());
1993 pData
->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey
, NULL
, aPos
.Tab(), ScRangeList());
1996 pScMod
->SetRefDialog( nId
, false );
2002 case SID_DEFINE_COLROWNAMERANGES
:
2005 sal_uInt16 nId
= ScColRowNameRangesDlgWrapper::GetChildWindowId();
2006 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2007 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2009 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
2014 case SID_UPDATECHART
:
2016 sal_Bool bAll
= false;
2020 const SfxPoolItem
* pItem
;
2022 if( pReqArgs
->HasItem( SID_UPDATECHART
, &pItem
) )
2023 bAll
= ((const SfxBoolItem
*)pItem
)->GetValue();
2026 pTabViewShell
->UpdateCharts( bAll
);
2028 if( ! rReq
.IsAPI() )
2030 rReq
.AppendItem( SfxBoolItem( SID_UPDATECHART
, bAll
) );
2040 const ScTabOpItem
& rItem
=
2041 (const ScTabOpItem
&)
2042 pReqArgs
->Get( SID_TABOP
);
2044 pTabViewShell
->TabOp( rItem
.GetData() );
2046 rReq
.Done( *pReqArgs
);
2053 const ScSolveItem
& rItem
=
2054 (const ScSolveItem
&)
2055 pReqArgs
->Get( SCITEM_SOLVEDATA
);
2057 pTabViewShell
->Solve( rItem
.GetData() );
2059 rReq
.Done( *pReqArgs
);
2063 case FID_INSERT_NAME
:
2065 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2066 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2068 AbstractScNamePasteDlg
* pDlg
= pFact
->CreateScNamePasteDlg( pTabViewShell
->GetDialogParent(), GetViewData()->GetDocShell() );
2069 OSL_ENSURE(pDlg
, "Dialog create fail!");
2070 switch( pDlg
->Execute() )
2072 case BTN_PASTE_LIST
:
2073 pTabViewShell
->InsertNameList();
2075 case BTN_PASTE_NAME
:
2077 ScInputHandler
* pHdl
= pScMod
->GetInputHdl( pTabViewShell
);
2080 // "=" in KeyEvent, switches to input-mode
2081 pScMod
->InputKeyEvent( KeyEvent('=',KeyCode()) );
2083 std::vector
<OUString
> aNames
= pDlg
->GetSelectedNames();
2084 if (!aNames
.empty())
2086 OUStringBuffer aBuffer
;
2087 for (std::vector
<OUString
>::const_iterator itr
= aNames
.begin();
2088 itr
!= aNames
.end(); ++itr
)
2090 aBuffer
.append(*itr
).append(' ');
2092 pHdl
->InsertFunction( aBuffer
.makeStringAndClear(), false ); // without "()"
2102 case SID_RANGE_NOTETEXT
:
2105 const SfxStringItem
& rTextItem
= (const SfxStringItem
&)pReqArgs
->Get( SID_RANGE_NOTETEXT
);
2107 // always cursor position
2108 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2109 pTabViewShell
->SetNoteText( aPos
, rTextItem
.GetValue() );
2114 case SID_INSERT_POSTIT
:
2117 const SvxPostItAuthorItem
& rAuthorItem
= (const SvxPostItAuthorItem
&)pReqArgs
->Get( SID_ATTR_POSTIT_AUTHOR
);
2118 const SvxPostItDateItem
& rDateItem
= (const SvxPostItDateItem
&) pReqArgs
->Get( SID_ATTR_POSTIT_DATE
);
2119 const SvxPostItTextItem
& rTextItem
= (const SvxPostItTextItem
&) pReqArgs
->Get( SID_ATTR_POSTIT_TEXT
);
2121 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2122 pTabViewShell
->ReplaceNote( aPos
, rTextItem
.GetValue(), &rAuthorItem
.GetValue(), &rDateItem
.GetValue() );
2127 pTabViewShell
->EditNote(); // note object to edit
2131 case FID_NOTE_VISIBLE
:
2133 ScDocument
* pDoc
= GetViewData()->GetDocument();
2134 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2135 if( ScPostIt
* pNote
= pDoc
->GetNote(aPos
) )
2138 const SfxPoolItem
* pItem
;
2139 if ( pReqArgs
&& (pReqArgs
->GetItemState( FID_NOTE_VISIBLE
, sal_True
, &pItem
) == SFX_ITEM_SET
) )
2140 bShow
= ((const SfxBoolItem
*) pItem
)->GetValue();
2142 bShow
= !pNote
->IsCaptionShown();
2144 pTabViewShell
->ShowNote( bShow
);
2147 rReq
.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE
, bShow
) );
2150 rBindings
.Invalidate( FID_NOTE_VISIBLE
);
2160 bool bShowNote
= nSlot
== FID_SHOW_NOTE
;
2161 ScViewData
* pData
= GetViewData();
2162 ScDocument
* pDoc
= pData
->GetDocument();
2163 ScMarkData
& rMark
= pData
->GetMarkData();
2166 if (!rMark
.IsMarked() && !rMark
.IsMultiMarked())
2168 // Check current cell
2169 ScAddress
aPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2170 if( pDoc
->GetNote(aPos
) )
2172 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2178 // Check selection range
2179 ScRangeListRef aRangesRef
;
2180 pData
->GetMultiArea(aRangesRef
);
2181 ScRangeList aRanges
= *aRangesRef
;
2182 size_t nRangeSize
= aRanges
.size();
2184 OUString aUndo
= ScGlobal::GetRscString( bShowNote
? STR_UNDO_SHOWNOTE
: STR_UNDO_HIDENOTE
);
2185 pData
->GetDocShell()->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
2187 for ( size_t i
= 0; i
< nRangeSize
; ++i
)
2189 const ScRange
* pRange
= aRanges
[i
];
2190 const SCROW nRow0
= pRange
->aStart
.Row();
2191 const SCROW nRow1
= pRange
->aEnd
.Row();
2192 const SCCOL nCol0
= pRange
->aStart
.Col();
2193 const SCCOL nCol1
= pRange
->aEnd
.Col();
2194 const SCTAB nRangeTab
= pRange
->aStart
.Tab();
2195 // Check by each cell
2196 for ( SCROW nRow
= nRow0
; nRow
<= nRow1
; ++nRow
)
2198 for ( SCCOL nCol
= nCol0
; nCol
<= nCol1
; ++nCol
)
2200 if ( pDoc
->HasNote(nCol
, nRow
, nRangeTab
) && pDoc
->IsBlockEditable( nRangeTab
, nCol
,nRow
, nCol
,nRow
) )
2202 ScAddress
aPos( nCol
, nRow
, nRangeTab
);
2203 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2210 pData
->GetDocShell()->GetUndoManager()->LeaveListAction();
2215 rBindings
.Invalidate( nSlot
);
2223 case SID_DELETE_NOTE
:
2224 pTabViewShell
->DeleteContents( IDF_NOTE
); // delete all notes in selection
2229 if( pReqArgs
!= NULL
)
2231 OUString aChars
, aFontName
;
2232 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2233 const SfxPoolItem
* pItem
= 0;
2235 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), false, &pItem
);
2238 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, pItem
);
2240 aChars
= pStringItem
->GetValue();
2241 const SfxPoolItem
* pFtItem
= NULL
;
2242 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), false, &pFtItem
);
2243 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
2245 aFontName
= pFontItem
->GetValue();
2248 if ( !aChars
.isEmpty() )
2251 pTabViewShell
->GetSelectionPattern()->GetFont( aFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2252 pTabViewShell
->GetSelectionScriptType() );
2253 if ( !aFontName
.isEmpty() )
2254 aFont
= Font( aFontName
, Size(1,1) );
2255 pTabViewShell
->InsertSpecialChar( aChars
, aFont
);
2256 if( ! rReq
.IsAPI() )
2262 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
2264 // font color doesn't matter here
2266 pTabViewShell
->GetSelectionPattern()->GetFont( aCurFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2267 pTabViewShell
->GetSelectionScriptType() );
2269 SfxAllItemSet
aSet( GetPool() );
2270 aSet
.Put( SfxBoolItem( FN_PARAM_1
, false ) );
2271 aSet
.Put( SvxFontItem( aCurFont
.GetFamily(), aCurFont
.GetName(), aCurFont
.GetStyleName(), aCurFont
.GetPitch(), aCurFont
.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT
) ) );
2273 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( pTabViewShell
->GetDialogParent(), aSet
,
2274 pTabViewShell
->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP
);
2276 if ( pDlg
->Execute() == RET_OK
)
2278 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pItem
, SfxStringItem
, SID_CHARMAP
, false );
2279 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, false );
2281 if ( pItem
&& pFontItem
)
2283 Font
aNewFont( pFontItem
->GetFamilyName(), pFontItem
->GetStyleName(), Size(1,1) );
2284 aNewFont
.SetCharSet( pFontItem
->GetCharSet() );
2285 aNewFont
.SetPitch( pFontItem
->GetPitch() );
2286 pTabViewShell
->InsertSpecialChar( pItem
->GetValue(), aNewFont
);
2287 rReq
.AppendItem( *pFontItem
);
2288 rReq
.AppendItem( *pItem
);
2296 case SID_SELECT_SCENARIO
:
2302 const SfxStringItem
* pItem
=
2303 (const SfxStringItem
*)&pReqArgs
->Get( SID_SELECT_SCENARIO
);
2307 pTabViewShell
->UseScenario( pItem
->GetValue() );
2308 //! why should the return value be valid?!?!
2309 rReq
.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO
, pItem
->GetValue() ) );
2320 case SID_HYPERLINK_SETLINK
:
2323 const SfxPoolItem
* pItem
;
2324 if( pReqArgs
->HasItem( SID_HYPERLINK_SETLINK
, &pItem
) )
2326 const SvxHyperlinkItem
* pHyper
= (const SvxHyperlinkItem
*) pItem
;
2327 const OUString
& rName
= pHyper
->GetName();
2328 const OUString
& rURL
= pHyper
->GetURL();
2329 const OUString
& rTarget
= pHyper
->GetTargetFrame();
2330 sal_uInt16 nType
= (sal_uInt16
) pHyper
->GetInsertMode();
2332 pTabViewShell
->InsertURL( rName
, rURL
, rTarget
, nType
);
2340 case SID_OPENDLG_CONDFRMT_MANAGER
:
2342 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2343 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2345 ScViewData
* pData
= GetViewData();
2346 ScDocument
* pDoc
= pData
->GetDocument();
2348 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
2350 pTabViewShell
->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED
);
2354 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
2356 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList( aPos
.Tab() );
2357 boost::scoped_ptr
<AbstractScCondFormatManagerDlg
> pDlg(pFact
->CreateScCondFormatMgrDlg( pTabViewShell
->GetDialogParent(), pDoc
, pList
, aPos
, RID_SCDLG_COND_FORMAT_MANAGER
));
2358 if(pDlg
->Execute() == RET_OK
&& pDlg
->CondFormatsChanged())
2360 ScConditionalFormatList
* pCondFormatList
= pDlg
->GetConditionalFormatList();
2361 pData
->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList
, aPos
.Tab());
2366 case SID_EXTERNAL_SOURCE
:
2372 sal_uLong nRefresh
=0;
2374 SFX_REQUEST_ARG( rReq
, pFile
, SfxStringItem
, SID_FILE_NAME
, false );
2375 SFX_REQUEST_ARG( rReq
, pSource
, SfxStringItem
, FN_PARAM_1
, false );
2376 if ( pFile
&& pSource
)
2378 aFile
= pFile
->GetValue();
2379 aSource
= pSource
->GetValue();
2380 SFX_REQUEST_ARG( rReq
, pFilter
, SfxStringItem
, SID_FILTER_NAME
, false );
2382 aFilter
= pFilter
->GetValue();
2383 SFX_REQUEST_ARG( rReq
, pOptions
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, false );
2385 aOptions
= pOptions
->GetValue();
2386 SFX_REQUEST_ARG( rReq
, pRefresh
, SfxUInt32Item
, FN_PARAM_2
, false );
2388 nRefresh
= pRefresh
->GetValue();
2392 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2393 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2395 delete pImpl
->m_pLinkedDlg
;
2396 pImpl
->m_pLinkedDlg
=
2397 pFact
->CreateScLinkedAreaDlg(pTabViewShell
->GetDialogParent());
2398 OSL_ENSURE(pImpl
->m_pLinkedDlg
, "Dialog create fail!");
2399 delete pImpl
->m_pRequest
;
2400 pImpl
->m_pRequest
= new SfxRequest( rReq
);
2401 pImpl
->m_pLinkedDlg
->StartExecuteModal( LINK( this, ScCellShell
, DialogClosed
) );
2405 ExecuteExternalSource( aFile
, aFilter
, aOptions
, aSource
, nRefresh
, rReq
);
2414 OSL_FAIL("incorrect slot in ExecuteEdit");
2419 void ScCellShell::ExecuteTrans( SfxRequest
& rReq
)
2421 sal_Int32 nType
= ScViewUtil::GetTransliterationType( rReq
.GetSlot() );
2424 GetViewData()->GetView()->TransliterateText( nType
);
2429 void ScCellShell::ExecuteRotateTrans( SfxRequest
& rReq
)
2431 if( rReq
.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE
)
2432 GetViewData()->GetView()->TransliterateText( m_aRotateCase
.getNextMode() );
2435 void ScCellShell::ExecuteExternalSource(
2436 const OUString
& _rFile
, const OUString
& _rFilter
, const OUString
& _rOptions
,
2437 const OUString
& _rSource
, sal_uLong _nRefresh
, SfxRequest
& _rRequest
)
2439 if ( !_rFile
.isEmpty() && !_rSource
.isEmpty() ) // filter may be empty
2442 sal_Bool bMove
= false;
2444 ScViewData
* pData
= GetViewData();
2445 ScMarkData
& rMark
= pData
->GetMarkData();
2446 rMark
.MarkToSimple();
2447 if ( rMark
.IsMarked() )
2449 rMark
.GetMarkArea( aLinkRange
);
2450 bMove
= sal_True
; // insert/delete cells to fit range
2453 aLinkRange
= ScRange( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2455 pData
->GetDocFunc().InsertAreaLink( _rFile
, _rFilter
, _rOptions
, _rSource
,
2456 aLinkRange
, _nRefresh
, bMove
, false );
2465 bool isDPSourceValid(const ScDPObject
& rDPObj
)
2467 if (rDPObj
.IsImportData())
2469 // If the data type is database, check if the database is still valid.
2470 const ScImportSourceDesc
* pDesc
= rDPObj
.GetImportSourceDesc();
2474 const ScDPSaveData
* pSaveData
= rDPObj
.GetSaveData();
2475 const ScDPDimensionSaveData
* pDimData
= NULL
;
2477 pDimData
= pSaveData
->GetExistingDimensionData();
2479 const ScDPCache
* pCache
= pDesc
->CreateCache(pDimData
);
2481 // cashe creation failed, probably due to invalid connection.
2489 void ScCellShell::ExecuteDataPilotDialog()
2491 ScModule
* pScMod
= SC_MOD();
2492 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2493 ScViewData
* pData
= GetViewData();
2494 ScDocument
* pDoc
= pData
->GetDocument();
2496 ::boost::scoped_ptr
<ScDPObject
> pNewDPObject(NULL
);
2498 // ScPivot is no longer used...
2499 ScDPObject
* pDPObj
= pDoc
->GetDPAtCursor(
2500 pData
->GetCurX(), pData
->GetCurY(),
2501 pData
->GetTabNo() );
2502 if ( pDPObj
) // on an existing table?
2504 if (isDPSourceValid(*pDPObj
))
2505 pNewDPObject
.reset(new ScDPObject(*pDPObj
));
2507 else // create new table
2509 sal_uLong nSrcErrorId
= 0;
2511 // select database range or data
2512 pTabViewShell
->GetDBData( true, SC_DB_OLD
);
2513 ScMarkData
& rMark
= GetViewData()->GetMarkData();
2514 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
2515 pTabViewShell
->MarkDataArea( false );
2517 // output to cursor position for non-sheet data
2518 ScAddress
aDestPos( pData
->GetCurX(), pData
->GetCurY(),
2519 pData
->GetTabNo() );
2521 // first select type of source data
2523 bool bEnableExt
= ScDPObject::HasRegisteredSources();
2525 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2526 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2528 ::boost::scoped_ptr
<AbstractScDataPilotSourceTypeDlg
> pTypeDlg(
2529 pFact
->CreateScDataPilotSourceTypeDlg(
2530 pTabViewShell
->GetDialogParent(), bEnableExt
));
2532 // Populate named ranges (if any).
2533 ScRangeName
* pRangeName
= pDoc
->GetRangeName();
2536 ScRangeName::const_iterator itr
= pRangeName
->begin(), itrEnd
= pRangeName
->end();
2537 for (; itr
!= itrEnd
; ++itr
)
2538 pTypeDlg
->AppendNamedRange(itr
->second
->GetName());
2541 OSL_ENSURE(pTypeDlg
, "Dialog create fail!");
2542 if ( pTypeDlg
->Execute() == RET_OK
)
2544 if ( pTypeDlg
->IsExternal() )
2546 uno::Sequence
<OUString
> aSources
= ScDPObject::GetRegisteredSources();
2547 ::boost::scoped_ptr
<AbstractScDataPilotServiceDlg
> pServDlg(
2548 pFact
->CreateScDataPilotServiceDlg(
2549 pTabViewShell
->GetDialogParent(), aSources
, RID_SCDLG_DAPISERVICE
));
2551 OSL_ENSURE(pServDlg
, "Dialog create fail!");
2552 if ( pServDlg
->Execute() == RET_OK
)
2554 ScDPServiceDesc
aServDesc(
2555 pServDlg
->GetServiceName(),
2556 pServDlg
->GetParSource(),
2557 pServDlg
->GetParName(),
2558 pServDlg
->GetParUser(),
2559 pServDlg
->GetParPass() );
2560 pNewDPObject
.reset(new ScDPObject(pDoc
));
2561 pNewDPObject
->SetServiceData( aServDesc
);
2564 else if ( pTypeDlg
->IsDatabase() )
2566 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2568 ::boost::scoped_ptr
<AbstractScDataPilotDatabaseDlg
> pDataDlg(
2569 pFact
->CreateScDataPilotDatabaseDlg(
2570 pTabViewShell
->GetDialogParent(), RID_SCDLG_DAPIDATA
));
2572 OSL_ENSURE(pDataDlg
, "Dialog create fail!");
2573 if ( pDataDlg
->Execute() == RET_OK
)
2575 ScImportSourceDesc
aImpDesc(pDoc
);
2576 pDataDlg
->GetValues( aImpDesc
);
2577 pNewDPObject
.reset(new ScDPObject(pDoc
));
2578 pNewDPObject
->SetImportDesc( aImpDesc
);
2581 else if (pTypeDlg
->IsNamedRange())
2583 OUString aName
= pTypeDlg
->GetSelectedNamedRange();
2584 ScSheetSourceDesc
aShtDesc(pDoc
);
2585 aShtDesc
.SetRangeName(aName
);
2586 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2589 pNewDPObject
.reset(new ScDPObject(pDoc
));
2590 pNewDPObject
->SetSheetDesc(aShtDesc
);
2595 //! use database ranges (select before type dialog?)
2597 ScMarkType eType
= GetViewData()->GetSimpleArea(aRange
);
2598 if ( (eType
& SC_MARK_SIMPLE
) == SC_MARK_SIMPLE
)
2600 // Shrink the range to the data area.
2601 SCCOL nStartCol
= aRange
.aStart
.Col(), nEndCol
= aRange
.aEnd
.Col();
2602 SCROW nStartRow
= aRange
.aStart
.Row(), nEndRow
= aRange
.aEnd
.Row();
2603 if (pDoc
->ShrinkToDataArea(aRange
.aStart
.Tab(), nStartCol
, nStartRow
, nEndCol
, nEndRow
))
2605 aRange
.aStart
.SetCol(nStartCol
);
2606 aRange
.aStart
.SetRow(nStartRow
);
2607 aRange
.aEnd
.SetCol(nEndCol
);
2608 aRange
.aEnd
.SetRow(nEndRow
);
2609 rMark
.SetMarkArea(aRange
);
2610 pTabViewShell
->MarkRange(aRange
);
2614 if ( pDoc
->HasSubTotalCells( aRange
) )
2616 // confirm selection if it contains SubTotal cells
2618 QueryBox
aBox( pTabViewShell
->GetDialogParent(),
2619 WinBits(WB_YES_NO
| WB_DEF_YES
),
2620 ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL
) );
2621 if (aBox
.Execute() == RET_NO
)
2626 ScSheetSourceDesc
aShtDesc(pDoc
);
2627 aShtDesc
.SetSourceRange(aRange
);
2628 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2631 pNewDPObject
.reset(new ScDPObject(pDoc
));
2632 pNewDPObject
->SetSheetDesc( aShtDesc
);
2635 // output below source data
2636 if ( aRange
.aEnd
.Row()+2 <= MAXROW
- 4 )
2637 aDestPos
= ScAddress( aRange
.aStart
.Col(),
2638 aRange
.aEnd
.Row()+2,
2639 aRange
.aStart
.Tab() );
2647 // Error occurred during data creation. Launch an error and bail out.
2648 InfoBox
aBox(pTabViewShell
->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId
));
2654 pNewDPObject
->SetOutRange( aDestPos
);
2657 pTabViewShell
->SetDialogDPObject( pNewDPObject
.get() ); // is copied
2660 // start layout dialog
2662 sal_uInt16 nId
= ScPivotLayoutWrapper::GetChildWindowId();
2663 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2664 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2665 pScMod
->SetRefDialog( nId
, pWnd
? false : true );
2669 void ScCellShell::ExecuteXMLSourceDialog()
2671 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2675 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2679 ScModule
* pScMod
= SC_MOD();
2681 sal_uInt16 nId
= ScXMLSourceDlgWrapper::GetChildWindowId();
2682 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
2683 SfxChildWindow
* pWnd
= pViewFrame
->GetChildWindow(nId
);
2684 pScMod
->SetRefDialog(nId
, pWnd
? false : true);
2687 void ScCellShell::ExecuteSubtotals(SfxRequest
& rReq
)
2689 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2690 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2693 pTabViewShell
->DoSubTotals( ((const ScSubTotalItem
&) pArgs
->Get( SCITEM_SUBTDATA
)).
2694 GetSubTotalData() );
2699 SfxAbstractTabDialog
* pDlg
= NULL
;
2700 ScSubTotalParam aSubTotalParam
;
2701 SfxItemSet
aArgSet( GetPool(), SCITEM_SUBTDATA
, SCITEM_SUBTDATA
);
2703 // Only get existing named database range.
2704 ScDBData
* pDBData
= pTabViewShell
->GetDBData(true, SC_DB_OLD
);
2707 // No existing DB data at this position. Create an
2709 pDBData
= pTabViewShell
->GetAnonymousDBData();
2711 pDBData
->GetArea(aDataRange
);
2712 pTabViewShell
->MarkRange(aDataRange
, false);
2717 pDBData
->GetSubTotalParam( aSubTotalParam
);
2718 aSubTotalParam
.bRemoveOnly
= false;
2720 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
, GetViewData(), &aSubTotalParam
) );
2721 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2722 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2724 pDlg
= pFact
->CreateScSubTotalDlg( pTabViewShell
->GetDialogParent(), &aArgSet
, RID_SCDLG_SUBTOTALS
);
2725 OSL_ENSURE(pDlg
, "Dialog create fail!");
2726 pDlg
->SetCurPageId(1);
2728 short bResult
= pDlg
->Execute();
2730 if ( (bResult
== RET_OK
) || (bResult
== SCRET_REMOVE
) )
2732 const SfxItemSet
* pOutSet
= NULL
;
2734 if ( bResult
== RET_OK
)
2736 pOutSet
= pDlg
->GetOutputItemSet();
2738 ((const ScSubTotalItem
&)
2739 pOutSet
->Get( SCITEM_SUBTDATA
)).
2742 else // if (bResult == SCRET_REMOVE)
2745 aSubTotalParam
.bRemoveOnly
= sal_True
;
2746 aSubTotalParam
.bReplace
= sal_True
;
2747 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
,
2749 &aSubTotalParam
) );
2752 pTabViewShell
->DoSubTotals( aSubTotalParam
);
2753 rReq
.Done( *pOutSet
);
2756 GetViewData()->GetDocShell()->CancelAutoDBRange();
2761 IMPL_LINK_NOARG(ScCellShell
, DialogClosed
)
2763 OSL_ENSURE( pImpl
->m_pLinkedDlg
, "ScCellShell::DialogClosed(): invalid request" );
2764 OSL_ENSURE( pImpl
->m_pRequest
, "ScCellShell::DialogClosed(): invalid request" );
2765 OUString sFile
, sFilter
, sOptions
, sSource
;
2766 sal_uLong nRefresh
= 0;
2768 if ( pImpl
->m_pLinkedDlg
->GetResult() == RET_OK
)
2770 sFile
= pImpl
->m_pLinkedDlg
->GetURL();
2771 sFilter
= pImpl
->m_pLinkedDlg
->GetFilter();
2772 sOptions
= pImpl
->m_pLinkedDlg
->GetOptions();
2773 sSource
= pImpl
->m_pLinkedDlg
->GetSource();
2774 nRefresh
= pImpl
->m_pLinkedDlg
->GetRefresh();
2775 if ( !sFile
.isEmpty() )
2776 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_NAME
, sFile
) );
2777 if ( !sFilter
.isEmpty() )
2778 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILTER_NAME
, sFilter
) );
2779 if ( !sOptions
.isEmpty() )
2780 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS
, sOptions
) );
2781 if ( !sSource
.isEmpty() )
2782 pImpl
->m_pRequest
->AppendItem( SfxStringItem( FN_PARAM_1
, sSource
) );
2784 pImpl
->m_pRequest
->AppendItem( SfxUInt32Item( FN_PARAM_2
, nRefresh
) );
2787 ExecuteExternalSource( sFile
, sFilter
, sOptions
, sSource
, nRefresh
, *(pImpl
->m_pRequest
) );
2791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */