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 <config_features.h>
22 #include <com/sun/star/i18n/TextConversionOption.hpp>
23 #include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
25 #include "scitems.hxx"
26 #include <sfx2/viewfrm.hxx>
28 #include <svl/stritem.hxx>
29 #include <svl/whiter.hxx>
30 #include <svl/zforlist.hxx>
31 #include <svl/zformat.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/request.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <svx/svxdlg.hxx>
36 #include <sot/formats.hxx>
37 #include <svx/postattr.hxx>
38 #include <editeng/fontitem.hxx>
39 #include <svx/clipfmtitem.hxx>
40 #include <sfx2/passwd.hxx>
41 #include <svx/hlnkitem.hxx>
42 #include <basic/sbxcore.hxx>
43 #include <unotools/useroptions.hxx>
44 #include <vcl/waitobj.hxx>
45 #include <vcl/builderfactory.hxx>
46 #include <unotools/localedatawrapper.hxx>
50 #include "document.hxx"
51 #include "patattr.hxx"
53 #include "scresid.hxx"
54 #include "tabvwsh.hxx"
56 #include "reffind.hxx"
57 #include "uiitems.hxx"
58 #include "reffact.hxx"
59 #include "inputhdl.hxx"
60 #include "transobj.hxx"
61 #include "drwtrans.hxx"
62 #include "docfunc.hxx"
63 #include "editable.hxx"
64 #include "dpobject.hxx"
66 #include "dpgroup.hxx"
67 #include "spellparam.hxx"
69 #include "clipparam.hxx"
71 #include "dpsdbtab.hxx"
72 #include "dpshttab.hxx"
75 #include "cliputil.hxx"
76 #include "markdata.hxx"
77 #include "docpool.hxx"
78 #include "condformatdlg.hxx"
81 #include "globstr.hrc"
82 #include "scui_def.hxx"
83 #include <svx/dialogs.hrc>
84 #include "scabstdlg.hxx"
85 #include <tokenstringcontext.hxx>
86 #include <cellvalue.hxx>
87 #include <tokenarray.hxx>
88 #include <formulacell.hxx>
89 #include <gridwin.hxx>
90 #include <searchresults.hxx>
92 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
93 #include <com/sun/star/lang/XInitialization.hpp>
94 #include <com/sun/star/beans/PropertyValue.hpp>
95 #include <com/sun/star/beans/XPropertySet.hpp>
96 #include <cppuhelper/bootstrap.hxx>
97 #include <com/sun/star/i18n/TransliterationModules.hpp>
98 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
100 #include <boost/scoped_ptr.hpp>
102 using namespace ::com::sun::star
;
103 using namespace ::com::sun::star::beans
;
104 using namespace ::com::sun::star::uno
;
106 void ScCellShell::ExecuteEdit( SfxRequest
& rReq
)
108 ScModule
* pScMod
= SC_MOD();
109 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
110 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
111 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
112 sal_uInt16 nSlot
= rReq
.GetSlot();
114 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
117 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
121 case FID_DEFINE_NAME
:
124 case FID_INSERT_NAME
:
125 case SID_SPELL_DIALOG
:
126 case SID_HANGUL_HANJA_CONVERSION
:
127 case SID_OPENDLG_CONDFRMT
:
128 case SID_OPENDLG_COLORSCALE
:
129 case SID_OPENDLG_DATABAR
:
131 pScMod
->InputEnterHandler();
132 pTabViewShell
->UpdateInputHandler();
143 // insert / delete cells / rows / columns
146 pTabViewShell
->InsertCells(INS_INSROWS
);
151 pTabViewShell
->InsertCells(INS_INSCOLS
);
155 case FID_INS_CELLSDOWN
:
156 pTabViewShell
->InsertCells(INS_CELLSDOWN
);
160 case FID_INS_CELLSRIGHT
:
161 pTabViewShell
->InsertCells(INS_CELLSRIGHT
);
166 pTabViewShell
->DeleteCells( DEL_DELROWS
);
171 pTabViewShell
->DeleteCells( DEL_DELCOLS
);
177 InsCellCmd eCmd
=INS_NONE
;
181 const SfxPoolItem
* pItem
;
184 if( pReqArgs
->HasItem( FID_INS_CELL
, &pItem
) )
185 aFlags
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
186 if( !aFlags
.isEmpty() )
190 case 'V': eCmd
= INS_CELLSDOWN
;break;
191 case '>': eCmd
= INS_CELLSRIGHT
;break;
192 case 'R': eCmd
= INS_INSROWS
;break;
193 case 'C': eCmd
= INS_INSCOLS
;break;
199 if ( GetViewData()->SimpleColMarked() )
201 else if ( GetViewData()->SimpleRowMarked() )
205 ScDocument
* pDoc
= GetViewData()->GetDocument();
206 bool bTheFlag
=(pDoc
->GetChangeTrack()!=NULL
);
208 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
209 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
211 boost::scoped_ptr
<AbstractScInsertCellDlg
> pDlg(pFact
->CreateScInsertCellDlg( pTabViewShell
->GetDialogParent(), RID_SCDLG_INSCELL
, bTheFlag
));
212 OSL_ENSURE(pDlg
, "Dialog create fail!");
213 if (pDlg
->Execute() == RET_OK
)
214 eCmd
= pDlg
->GetInsCellCmd();
220 pTabViewShell
->InsertCells( eCmd
);
228 case INS_CELLSDOWN
: aParam
= "V"; break;
229 case INS_CELLSRIGHT
: aParam
= ">"; break;
230 case INS_INSROWS
: aParam
= "R"; break;
231 case INS_INSCOLS
: aParam
= "C"; break;
234 // added to avoid warnings
237 rReq
.AppendItem( SfxStringItem( FID_INS_CELL
, aParam
) );
244 case FID_DELETE_CELL
:
246 DelCellCmd eCmd
= DEL_NONE
;
250 const SfxPoolItem
* pItem
;
253 if( pReqArgs
->HasItem( FID_DELETE_CELL
, &pItem
) )
254 aFlags
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
255 if( !aFlags
.isEmpty() )
259 case 'U': eCmd
= DEL_CELLSUP
;break;
260 case 'L': eCmd
= DEL_CELLSLEFT
;break;
261 case 'R': eCmd
= DEL_DELROWS
;break;
262 case 'C': eCmd
= DEL_DELCOLS
;break;
268 if ( GetViewData()->SimpleColMarked() )
270 else if ( GetViewData()->SimpleRowMarked() )
275 ScDocument
* pDoc
= GetViewData()->GetDocument();
276 bool bTheFlag
=GetViewData()->IsMultiMarked() ||
277 (GetViewData()->GetSimpleArea(aRange
) == SC_MARK_SIMPLE_FILTERED
) ||
278 (pDoc
->GetChangeTrack() != NULL
);
280 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
281 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
283 boost::scoped_ptr
<AbstractScDeleteCellDlg
> pDlg(pFact
->CreateScDeleteCellDlg( pTabViewShell
->GetDialogParent(), bTheFlag
));
284 OSL_ENSURE(pDlg
, "Dialog create fail!");
286 if (pDlg
->Execute() == RET_OK
)
287 eCmd
= pDlg
->GetDelCellCmd();
291 if (eCmd
!= DEL_NONE
)
293 pTabViewShell
->DeleteCells( eCmd
);
301 case DEL_CELLSUP
: aParam
= "U"; break;
302 case DEL_CELLSLEFT
: aParam
= "L"; break;
303 case DEL_DELROWS
: aParam
= "R"; break;
304 case DEL_DELCOLS
: aParam
= "C"; break;
307 // added to avoid warnings
310 rReq
.AppendItem( SfxStringItem( FID_DELETE_CELL
, aParam
) );
317 // delete contents from cells
319 case SID_DELETE_CONTENTS
:
320 pTabViewShell
->DeleteContents( IDF_CONTENTS
);
326 InsertDeleteFlags nFlags
= IDF_NONE
;
328 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
330 const SfxPoolItem
* pItem
;
331 OUString
aFlags('A');
333 if( pReqArgs
->HasItem( SID_DELETE
, &pItem
) )
334 aFlags
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
336 aFlags
= aFlags
.toAsciiUpperCase();
339 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
345 bCont
= false; // don't continue!
347 case 'S': nFlags
|= IDF_STRING
; break;
348 case 'V': nFlags
|= IDF_VALUE
; break;
349 case 'D': nFlags
|= IDF_DATETIME
; break;
350 case 'F': nFlags
|= IDF_FORMULA
; break;
351 case 'N': nFlags
|= IDF_NOTE
; break;
352 case 'T': nFlags
|= IDF_ATTRIB
; break;
353 case 'O': nFlags
|= IDF_OBJECTS
; break;
359 ScEditableTester
aTester( pTabViewShell
);
360 if (aTester
.IsEditable())
362 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
363 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
365 boost::scoped_ptr
<AbstractScDeleteContentsDlg
> pDlg(pFact
->CreateScDeleteContentsDlg(pTabViewShell
->GetDialogParent()));
366 OSL_ENSURE(pDlg
, "Dialog create fail!");
367 ScDocument
* pDoc
= GetViewData()->GetDocument();
368 SCTAB nTab
= GetViewData()->GetTabNo();
369 if ( pDoc
->IsTabProtected(nTab
) )
370 pDlg
->DisableObjects();
371 if (pDlg
->Execute() == RET_OK
)
373 nFlags
= pDlg
->GetDelContentsCmdBits();
377 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
380 if( nFlags
!= IDF_NONE
)
382 pTabViewShell
->DeleteContents( nFlags
);
388 if( nFlags
== IDF_ALL
)
394 if( nFlags
& IDF_STRING
) aFlags
+= "S";
395 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
396 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
397 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
398 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
399 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
400 if( nFlags
& IDF_OBJECTS
) aFlags
+= "O";
403 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 InsertDeleteFlags nFlags
= IDF_NONE
;
435 sal_uInt16 nFunction
= PASTE_NOFUNC
;
436 bool bSkipEmpty
= false;
437 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
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
447 aFlags
= aFlags
.toAsciiUpperCase();
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 boost::scoped_ptr
<AbstractScInsertContentsDlg
> pDlg(pFact
->CreateScInsertContentsDlg( pTabViewShell
->GetDialogParent(),
473 IDF_NONE
, /* 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
488 if( nFlags
!= IDF_NONE
)
490 pTabViewShell
->FillTab( nFlags
, nFunction
, bSkipEmpty
, bAsLink
);
496 if( nFlags
== IDF_ALL
)
502 if( nFlags
& IDF_STRING
) aFlags
+= "S";
503 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
504 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
505 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
506 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
507 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
510 rReq
.AppendItem( SfxStringItem( FID_FILL_TAB
, aFlags
) );
517 case FID_FILL_SERIES
:
525 sal_uInt16 nPossDir
= FDS_OPT_NONE
;
526 FillDir eFillDir
= FILL_TO_BOTTOM
;
527 FillCmd eFillCmd
= FILL_LINEAR
;
528 FillDateCmd eFillDateCmd
= FILL_DAY
;
529 double fStartVal
= MAXDOUBLE
;
531 double fMaxVal
= MAXDOUBLE
;
534 GetViewData()->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
535 nEndCol
, nEndRow
, nEndTab
);
537 if( nStartCol
!=nEndCol
)
539 nPossDir
|= FDS_OPT_HORZ
;
540 eFillDir
=FILL_TO_RIGHT
;
543 if( nStartRow
!=nEndRow
)
545 nPossDir
|= FDS_OPT_VERT
;
546 eFillDir
=FILL_TO_BOTTOM
;
549 ScDocument
* pDoc
= GetViewData()->GetDocument();
550 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
554 const SfxPoolItem
* pItem
;
555 OUString aFillDir
, aFillCmd
, aFillDateCmd
;
556 OUString aFillStep
, aFillStart
, aFillMax
;
562 if( pReqArgs
->HasItem( FID_FILL_SERIES
, &pItem
) )
563 aFillDir
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
564 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
565 aFillCmd
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
566 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
567 aFillDateCmd
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
568 if( pReqArgs
->HasItem( FN_PARAM_3
, &pItem
) )
569 aFillStep
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
570 if( pReqArgs
->HasItem( FN_PARAM_4
, &pItem
) )
571 aFillStart
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
572 if( pReqArgs
->HasItem( FN_PARAM_5
, &pItem
) )
573 aFillMax
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
575 if( !aFillDir
.isEmpty() )
576 switch( aFillDir
[0] )
578 case 'B': case 'b': eFillDir
=FILL_TO_BOTTOM
; break;
579 case 'R': case 'r': eFillDir
=FILL_TO_RIGHT
; break;
580 case 'T': case 't': eFillDir
=FILL_TO_TOP
; break;
581 case 'L': case 'l': eFillDir
=FILL_TO_LEFT
; break;
584 if( !aFillCmd
.isEmpty() )
585 switch( aFillCmd
[0] )
587 case 'S': case 's': eFillCmd
=FILL_SIMPLE
; break;
588 case 'L': case 'l': eFillCmd
=FILL_LINEAR
; break;
589 case 'G': case 'g': eFillCmd
=FILL_GROWTH
; break;
590 case 'D': case 'd': eFillCmd
=FILL_DATE
; break;
591 case 'A': case 'a': eFillCmd
=FILL_AUTO
; break;
594 if( !aFillDateCmd
.isEmpty() )
595 switch( aFillDateCmd
[0] )
597 case 'D': case 'd': eFillDateCmd
=FILL_DAY
; break;
598 case 'W': case 'w': eFillDateCmd
=FILL_WEEKDAY
; break;
599 case 'M': case 'm': eFillDateCmd
=FILL_MONTH
; break;
600 case 'Y': case 'y': eFillDateCmd
=FILL_YEAR
; break;
604 if( pFormatter
->IsNumberFormat( aFillStart
, nKey
, fTmpVal
))
608 if( pFormatter
->IsNumberFormat( aFillStep
, nKey
, fTmpVal
))
612 if( pFormatter
->IsNumberFormat( aFillMax
, nKey
, fTmpVal
))
618 else // (pReqArgs == NULL) => raise Dialog
620 sal_uInt32 nPrivFormat
;
622 pDoc
->GetNumberFormat( nStartCol
, nStartRow
, nStartTab
, nPrivFormat
);
623 pDoc
->GetCellType( nStartCol
, nStartRow
, nStartTab
,eCellType
);
624 const SvNumberformat
* pPrivEntry
= pFormatter
->GetEntry( nPrivFormat
);
627 OSL_FAIL("Numberformat not found !!!");
631 short nPrivType
= pPrivEntry
->GetType();
632 if ( ( nPrivType
& css::util::NumberFormat::DATE
)>0)
636 else if(eCellType
==CELLTYPE_STRING
)
644 // suggest default Startvalue only, when just 1 row or column
645 if ( nStartCol
== nEndCol
|| nStartRow
== nEndRow
)
647 double fInputEndVal
= 0.0;
650 pDoc
->GetInputString( nStartCol
, nStartRow
, nStartTab
, aStartStr
);
651 pDoc
->GetValue( nStartCol
, nStartRow
, nStartTab
, fStartVal
);
653 if(eFillDir
==FILL_TO_BOTTOM
&& nStartRow
< nEndRow
)
655 pDoc
->GetInputString( nStartCol
, nStartRow
+1, nStartTab
, aEndStr
);
656 if(!aEndStr
.isEmpty())
658 pDoc
->GetValue( nStartCol
, nStartRow
+1, nStartTab
, fInputEndVal
);
659 fIncVal
=fInputEndVal
-fStartVal
;
664 if(nStartCol
< nEndCol
)
666 pDoc
->GetInputString( nStartCol
+1, nStartRow
, nStartTab
, aEndStr
);
667 if(!aEndStr
.isEmpty())
669 pDoc
->GetValue( nStartCol
+1, nStartRow
, nStartTab
, fInputEndVal
);
670 fIncVal
=fInputEndVal
-fStartVal
;
674 if(eFillCmd
==FILL_DATE
)
676 Date aNullDate
= *pDoc
->GetFormatTable()->GetNullDate();
677 Date aStartDate
= aNullDate
;
678 aStartDate
+= (long)fStartVal
;
679 Date aEndDate
= aNullDate
;
680 aEndDate
+= (long)fInputEndVal
;
683 if(aStartDate
.GetYear()!=aEndDate
.GetYear())
685 eFillDateCmd
= FILL_YEAR
;
686 fTempDate
=aEndDate
.GetYear()-aStartDate
.GetYear();
688 if(aStartDate
.GetMonth()!=aEndDate
.GetMonth())
690 eFillDateCmd
= FILL_MONTH
;
691 fTempDate
=fTempDate
*12+aEndDate
.GetMonth()-aStartDate
.GetMonth();
693 if(aStartDate
.GetDay()==aEndDate
.GetDay())
699 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
700 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
702 boost::scoped_ptr
<AbstractScFillSeriesDlg
> pDlg(pFact
->CreateScFillSeriesDlg( pTabViewShell
->GetDialogParent(),
704 eFillDir
, eFillCmd
, eFillDateCmd
,
705 aStartStr
, fIncVal
, fMaxVal
,
707 OSL_ENSURE(pDlg
, "Dialog create fail!");
709 if ( nStartCol
!= nEndCol
&& nStartRow
!= nEndRow
)
711 pDlg
->SetEdStartValEnabled(false);
714 if ( pDlg
->Execute() == RET_OK
)
716 eFillDir
= pDlg
->GetFillDir();
717 eFillCmd
= pDlg
->GetFillCmd();
718 eFillDateCmd
= pDlg
->GetFillDateCmd();
720 if(eFillCmd
==FILL_AUTO
)
722 OUString aStr
= pDlg
->GetStartStr();
724 pTabViewShell
->EnterData( nStartCol
, nStartRow
, nStartTab
, aStr
);
726 fStartVal
= pDlg
->GetStart();
727 fIncVal
= pDlg
->GetStep();
728 fMaxVal
= pDlg
->GetMax();
735 //nScFillModeMouseModifier = 0; // no Ctrl/Copy
736 pTabViewShell
->FillSeries( eFillDir
, eFillCmd
, eFillDateCmd
, fStartVal
, fIncVal
, fMaxVal
);
745 case FILL_TO_BOTTOM
: aPara
= "B"; break;
746 case FILL_TO_RIGHT
: aPara
= "R"; break;
747 case FILL_TO_TOP
: aPara
= "T"; break;
748 case FILL_TO_LEFT
: aPara
= "L"; break;
751 rReq
.AppendItem( SfxStringItem( FID_FILL_SERIES
, aPara
) );
755 case FILL_SIMPLE
: aPara
= "S"; break;
756 case FILL_LINEAR
: aPara
= "L"; break;
757 case FILL_GROWTH
: aPara
= "G"; break;
758 case FILL_DATE
: aPara
= "D"; break;
759 case FILL_AUTO
: aPara
= "A"; break;
762 rReq
.AppendItem( SfxStringItem( FN_PARAM_1
, aPara
) );
764 switch( eFillDateCmd
)
766 case FILL_DAY
: aPara
= "D"; break;
767 case FILL_WEEKDAY
: aPara
= "W"; break;
768 case FILL_MONTH
: aPara
= "M"; break;
769 case FILL_YEAR
: aPara
= "Y"; break;
772 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, aPara
) );
774 sal_uLong nFormatKey
= pFormatter
->GetStandardFormat(css::util::NumberFormat::NUMBER
,
777 pFormatter
->GetOutputString( fIncVal
, nFormatKey
, aPara
, &pColor
);
778 rReq
.AppendItem( SfxStringItem( FN_PARAM_3
, aPara
) );
780 pFormatter
->GetOutputString( fStartVal
, nFormatKey
, aPara
, &pColor
);
781 rReq
.AppendItem( SfxStringItem( FN_PARAM_4
, aPara
) );
783 pFormatter
->GetOutputString( fMaxVal
, nFormatKey
, aPara
, &pColor
);
784 rReq
.AppendItem( SfxStringItem( FN_PARAM_5
, aPara
) );
798 SCTAB nStartTab
, nEndTab
;
800 GetViewData()->GetFillData( nStartCol
, nStartRow
, nEndCol
, nEndRow
);
801 SCCOL nFillCol
= GetViewData()->GetRefEndX();
802 SCROW nFillRow
= GetViewData()->GetRefEndY();
803 ScDocument
* pDoc
= GetViewData()->GetDocument();
805 if( pReqArgs
!= NULL
)
807 const SfxPoolItem
* pItem
;
809 if( pReqArgs
->HasItem( FID_FILL_AUTO
, &pItem
) )
811 ScAddress aScAddress
;
812 OUString aArg
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
814 if( aScAddress
.Parse( aArg
, pDoc
, pDoc
->GetAddressConvention() ) & SCA_VALID
)
816 nFillRow
= aScAddress
.Row();
817 nFillCol
= aScAddress
.Col();
821 GetViewData()->GetSimpleArea( nStartCol
,nStartRow
,nStartTab
,
822 nEndCol
,nEndRow
,nEndTab
);
824 else // call via mouse
826 // not in a merged cell
828 if ( nStartCol
== nEndCol
&& nStartRow
== nEndRow
)
830 SCCOL nMergeCol
= nStartCol
;
831 SCROW nMergeRow
= nStartRow
;
832 if ( GetViewData()->GetDocument()->ExtendMerge(
833 nStartCol
, nStartRow
, nMergeCol
, nMergeRow
,
834 GetViewData()->GetTabNo() ) )
836 if ( nFillCol
>= nStartCol
&& nFillCol
<= nMergeCol
&& nFillRow
== nStartRow
)
837 nFillCol
= nStartCol
;
838 if ( nFillRow
>= nStartRow
&& nFillRow
<= nMergeRow
&& nFillCol
== nStartCol
)
839 nFillRow
= nStartRow
;
844 if ( nFillCol
!= nEndCol
|| nFillRow
!= nEndRow
)
846 if ( nFillCol
==nEndCol
|| nFillRow
==nEndRow
)
848 FillDir eDir
= FILL_TO_BOTTOM
;
851 if ( nFillCol
==nEndCol
)
853 if ( nFillRow
> nEndRow
)
855 eDir
= FILL_TO_BOTTOM
;
856 nCount
= nFillRow
- nEndRow
;
858 else if ( nFillRow
< nStartRow
)
861 nCount
= nStartRow
- nFillRow
;
866 if ( nFillCol
> nEndCol
)
868 eDir
= FILL_TO_RIGHT
;
869 nCount
= nFillCol
- nEndCol
;
871 else if ( nFillCol
< nStartCol
)
874 nCount
= nStartCol
- nFillCol
;
880 pTabViewShell
->FillAuto( eDir
, nStartCol
, nStartRow
, nEndCol
, nEndRow
, nCount
);
884 ScAddress
aAdr( nFillCol
, nFillRow
, 0 );
885 OUString
aAdrStr(aAdr
.Format(SCR_ABS
, pDoc
, pDoc
->GetAddressConvention()));
887 rReq
.AppendItem( SfxStringItem( FID_FILL_AUTO
, aAdrStr
) );
895 OSL_FAIL( "Direction not unique for autofill" );
900 case FID_FILL_SINGLE_EDIT
:
901 ExecuteFillSingleEdit();
903 case SID_RANDOM_NUMBER_GENERATOR_DIALOG
:
905 sal_uInt16 nId
= ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
906 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
907 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
909 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
913 case SID_SAMPLING_DIALOG
:
915 sal_uInt16 nId
= ScSamplingDialogWrapper::GetChildWindowId();
916 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
917 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
919 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
922 case SID_DESCRIPTIVE_STATISTICS_DIALOG
:
924 sal_uInt16 nId
= ScDescriptiveStatisticsDialogWrapper::GetChildWindowId();
925 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
926 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
928 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
931 case SID_ANALYSIS_OF_VARIANCE_DIALOG
:
933 sal_uInt16 nId
= ScAnalysisOfVarianceDialogWrapper::GetChildWindowId();
934 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
935 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
937 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
940 case SID_CORRELATION_DIALOG
:
942 sal_uInt16 nId
= ScCorrelationDialogWrapper::GetChildWindowId();
943 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
944 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
946 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
949 case SID_COVARIANCE_DIALOG
:
951 sal_uInt16 nId
= ScCovarianceDialogWrapper::GetChildWindowId();
952 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
953 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
955 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
958 case SID_EXPONENTIAL_SMOOTHING_DIALOG
:
960 sal_uInt16 nId
= ScExponentialSmoothingDialogWrapper::GetChildWindowId();
961 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
962 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
964 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
967 case SID_MOVING_AVERAGE_DIALOG
:
969 sal_uInt16 nId
= ScMovingAverageDialogWrapper::GetChildWindowId();
970 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
971 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
973 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
976 case SID_TTEST_DIALOG
:
978 sal_uInt16 nId
= ScTTestDialogWrapper::GetChildWindowId();
979 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
980 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
982 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
986 case SID_FTEST_DIALOG
:
988 sal_uInt16 nId
= ScFTestDialogWrapper::GetChildWindowId();
989 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
990 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
992 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
996 case SID_ZTEST_DIALOG
:
998 sal_uInt16 nId
= ScZTestDialogWrapper::GetChildWindowId();
999 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1000 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1002 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1006 case SID_CHI_SQUARE_TEST_DIALOG
:
1008 sal_uInt16 nId
= ScChiSquareTestDialogWrapper::GetChildWindowId();
1009 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1010 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1012 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1017 case SID_SEARCH_RESULTS_DIALOG
:
1019 const SfxPoolItem
* pItem
= NULL
;
1020 if (pReqArgs
&& pReqArgs
->HasItem(SID_SEARCH_RESULTS_DIALOG
, &pItem
))
1022 bool bVisible
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1023 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1024 // The window ID should equal the slot ID, but not a biggie if it wasn't.
1025 sal_uInt16 nId
= sc::SearchResultsDlgWrapper::GetChildWindowId();
1026 pViewFrm
->SetChildWindow(nId
, bVisible
, false);
1032 // disposal (Outlines)
1033 // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
1035 case SID_OUTLINE_HIDE
:
1036 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1037 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1038 pTabViewShell
->SetDataPilotDetails( false );
1040 pTabViewShell
->HideMarkedOutlines();
1044 case SID_OUTLINE_SHOW
:
1046 ScDPObject
* pDPObj
= GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1047 GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
1050 Sequence
<sheet::DataPilotFieldFilter
> aFilters
;
1051 sal_uInt16 nOrientation
;
1052 if ( pTabViewShell
->HasSelectionForDrillDown( nOrientation
) )
1054 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1055 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1057 AbstractScDPShowDetailDlg
* pDlg
= pFact
->CreateScDPShowDetailDlg(
1058 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL
, *pDPObj
, nOrientation
);
1059 OSL_ENSURE(pDlg
, "Dialog create fail!");
1060 if ( pDlg
->Execute() == RET_OK
)
1062 OUString
aNewDimName( pDlg
->GetDimensionName() );
1063 pTabViewShell
->SetDataPilotDetails( true, &aNewDimName
);
1066 else if ( !pDPObj
->IsServiceData() &&
1067 pDPObj
->GetDataFieldPositionData(
1068 ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
1070 pTabViewShell
->ShowDataPilotSourceData( *pDPObj
, aFilters
);
1072 pTabViewShell
->SetDataPilotDetails(true);
1075 pTabViewShell
->ShowMarkedOutlines();
1080 case SID_OUTLINE_MAKE
:
1082 bool bColumns
= false;
1085 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1086 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1088 ScDPNumGroupInfo aNumInfo
;
1089 aNumInfo
.mbEnable
= true;
1090 aNumInfo
.mbAutoStart
= true;
1091 aNumInfo
.mbAutoEnd
= true;
1092 sal_Int32 nParts
= 0;
1093 if ( pTabViewShell
->HasSelectionForDateGroup( aNumInfo
, nParts
) )
1095 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1096 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1097 Date
aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
1098 AbstractScDPDateGroupDlg
* pDlg
= pFact
->CreateScDPDateGroupDlg(
1099 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPDATEGROUP
,
1100 aNumInfo
, nParts
, aNullDate
);
1101 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1102 if( pDlg
->Execute() == RET_OK
)
1104 aNumInfo
= pDlg
->GetGroupInfo();
1105 pTabViewShell
->DateGroupDataPilot( aNumInfo
, pDlg
->GetDatePart() );
1108 else if ( pTabViewShell
->HasSelectionForNumGroup( aNumInfo
) )
1110 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1111 OSL_ENSURE( pFact
, "ScAbstractFactory create fail!" );
1112 AbstractScDPNumGroupDlg
* pDlg
= pFact
->CreateScDPNumGroupDlg(
1113 pTabViewShell
->GetDialogParent(), RID_SCDLG_DPNUMGROUP
, aNumInfo
);
1114 OSL_ENSURE( pDlg
, "Dialog create fail!" );
1115 if( pDlg
->Execute() == RET_OK
)
1116 pTabViewShell
->NumGroupDataPilot( pDlg
->GetGroupInfo() );
1119 pTabViewShell
->GroupDataPilot();
1123 else if( pReqArgs
!= NULL
)
1125 const SfxPoolItem
* pItem
;
1128 if( pReqArgs
->HasItem( SID_OUTLINE_MAKE
, &pItem
) )
1130 OUString aCol
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1131 aCol
= aCol
.toAsciiUpperCase();
1135 case 'R': bColumns
=false; bOk
= true;break;
1136 case 'C': bColumns
=true; bOk
= true;break;
1140 else // Dialog, when not whole rows/columns are marked
1142 if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
1144 else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
1148 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1149 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1151 boost::scoped_ptr
<AbstractScGroupDlg
> pDlg(pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), false));
1152 OSL_ENSURE(pDlg
, "Dialog create fail!");
1153 if ( pDlg
->Execute() == RET_OK
)
1154 bColumns
= pDlg
->GetColsChecked();
1161 pTabViewShell
->MakeOutline( bColumns
);
1163 if( ! rReq
.IsAPI() )
1165 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1166 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_MAKE
, aCol
) );
1173 case SID_OUTLINE_REMOVE
:
1175 bool bColumns
= false;
1178 if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
1179 GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
1181 pTabViewShell
->UngroupDataPilot();
1184 else if( pReqArgs
!= NULL
)
1186 const SfxPoolItem
* pItem
;
1189 if( pReqArgs
->HasItem( SID_OUTLINE_REMOVE
, &pItem
) )
1191 OUString aCol
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1192 aCol
= aCol
.toAsciiUpperCase();
1196 case 'R': bColumns
=false; bOk
= true;break;
1197 case 'C': bColumns
=true; bOk
= true;break;
1201 else // Dialog only when removal for rows and columns is possible
1203 bool bColPoss
, bRowPoss
;
1204 pTabViewShell
->TestRemoveOutline( bColPoss
, bRowPoss
);
1205 if ( bColPoss
&& bRowPoss
)
1207 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1208 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1210 boost::scoped_ptr
<AbstractScGroupDlg
> pDlg(pFact
->CreateAbstractScGroupDlg(pTabViewShell
->GetDialogParent(), true));
1211 OSL_ENSURE(pDlg
, "Dialog create fail!");
1212 if ( pDlg
->Execute() == RET_OK
)
1213 bColumns
= pDlg
->GetColsChecked();
1217 else if ( bColPoss
)
1219 else if ( bRowPoss
)
1226 pTabViewShell
->RemoveOutline( bColumns
);
1228 if( ! rReq
.IsAPI() )
1230 OUString aCol
= bColumns
? OUString('C') : OUString('R');
1231 rReq
.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE
, aCol
) );
1240 case SID_COPY
: // for graphs in DrawShell
1242 WaitObject
aWait( GetViewData()->GetDialogParent() );
1243 pTabViewShell
->CopyToClip( NULL
, false, false, true );
1245 GetViewData()->SetPasteMode( (ScPasteFlags
) (SC_PASTE_MODE
| SC_PASTE_BORDER
) );
1246 pTabViewShell
->ShowCursor();
1247 pTabViewShell
->UpdateCopySourceOverlay();
1251 case SID_CUT
: // for graphs in DrawShell
1253 WaitObject
aWait( GetViewData()->GetDialogParent() );
1254 pTabViewShell
->CutToClip( NULL
, true );
1256 GetViewData()->SetPasteMode( (ScPasteFlags
)(SC_PASTE_MODE
| SC_PASTE_BORDER
));
1257 pTabViewShell
->ShowCursor();
1258 pTabViewShell
->UpdateCopySourceOverlay();
1264 ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell
, true );
1269 case SID_CLIPBOARD_FORMAT_ITEMS
:
1271 WaitObject
aWait( GetViewData()->GetDialogParent() );
1273 SotClipboardFormatId nFormat
= SotClipboardFormatId::NONE
;
1274 const SfxPoolItem
* pItem
;
1276 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
&&
1277 pItem
->ISA(SfxUInt32Item
) )
1279 nFormat
= static_cast<SotClipboardFormatId
>(static_cast<const SfxUInt32Item
*>(pItem
)->GetValue());
1282 if ( nFormat
!= SotClipboardFormatId::NONE
)
1284 vcl::Window
* pWin
= GetViewData()->GetActiveWin();
1285 bool bCells
= ( ScTransferObj::GetOwnClipboard( pWin
) != NULL
);
1286 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1287 bool bOle
= ( nFormat
== SotClipboardFormatId::EMBED_SOURCE
);
1289 if ( bCells
&& bOle
)
1290 pTabViewShell
->PasteFromSystem();
1291 else if ( bDraw
&& bOle
)
1292 pTabViewShell
->PasteDraw();
1294 pTabViewShell
->PasteFromSystem(nFormat
);
1297 //? pTabViewShell->PasteFromSystem();
1301 pTabViewShell
->CellContentChanged();
1304 case FID_INS_CELL_CONTENTS
:
1306 InsertDeleteFlags nFlags
= IDF_NONE
;
1307 sal_uInt16 nFunction
= PASTE_NOFUNC
;
1308 InsCellCmd eMoveMode
= INS_NONE
;
1310 vcl::Window
* pWin
= GetViewData()->GetActiveWin();
1311 ScDocument
* pDoc
= GetViewData()->GetDocument();
1312 bool bOtherDoc
= !pDoc
->IsClipboardSource();
1313 ScTransferObj
* pOwnClip
= ScTransferObj::GetOwnClipboard( pWin
);
1316 bool bSkipEmpty
= false;
1317 bool bTranspose
= false;
1318 bool bAsLink
= false;
1320 // keep a reference in case the clipboard is changed during dialog or PasteFromClip
1321 uno::Reference
<datatransfer::XTransferable
> aOwnClipRef( pOwnClip
);
1322 if ( pReqArgs
!=NULL
&& pTabViewShell
->SelectionEditable() )
1324 const SfxPoolItem
* pItem
;
1325 OUString
aFlags('A');
1327 if( pReqArgs
->HasItem( FID_INS_CELL_CONTENTS
, &pItem
) )
1328 aFlags
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1330 aFlags
= aFlags
.toAsciiUpperCase();
1333 for (sal_Int32 i
=0 ; bCont
&& i
<aFlags
.getLength(); ++i
)
1339 bCont
= false; // don't continue!
1341 case 'S': nFlags
|= IDF_STRING
; break;
1342 case 'V': nFlags
|= IDF_VALUE
; break;
1343 case 'D': nFlags
|= IDF_DATETIME
; break;
1344 case 'F': nFlags
|= IDF_FORMULA
; break;
1345 case 'N': nFlags
|= IDF_NOTE
; break;
1346 case 'T': nFlags
|= IDF_ATTRIB
; break;
1350 SFX_REQUEST_ARG( rReq
, pFuncItem
, SfxUInt16Item
, FN_PARAM_1
, false );
1351 SFX_REQUEST_ARG( rReq
, pSkipItem
, SfxBoolItem
, FN_PARAM_2
, false );
1352 SFX_REQUEST_ARG( rReq
, pTransposeItem
, SfxBoolItem
, FN_PARAM_3
, false );
1353 SFX_REQUEST_ARG( rReq
, pLinkItem
, SfxBoolItem
, FN_PARAM_4
, false );
1354 SFX_REQUEST_ARG( rReq
, pMoveItem
, SfxInt16Item
, FN_PARAM_5
, false );
1356 nFunction
= pFuncItem
->GetValue();
1358 bSkipEmpty
= pSkipItem
->GetValue();
1359 if ( pTransposeItem
)
1360 bTranspose
= pTransposeItem
->GetValue();
1362 bAsLink
= pLinkItem
->GetValue();
1364 eMoveMode
= (InsCellCmd
) pMoveItem
->GetValue();
1368 ScEditableTester
aTester( pTabViewShell
);
1369 if (aTester
.IsEditable())
1371 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1372 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1374 boost::scoped_ptr
<AbstractScInsertContentsDlg
> pDlg(pFact
->CreateScInsertContentsDlg(pTabViewShell
->GetDialogParent()));
1375 OSL_ENSURE(pDlg
, "Dialog create fail!");
1376 pDlg
->SetOtherDoc( bOtherDoc
);
1377 // if ChangeTrack MoveMode disable
1378 pDlg
->SetChangeTrack( pDoc
->GetChangeTrack() != NULL
);
1379 // fdo#56098 disable shift if necessary
1380 if ( !bOtherDoc
&& pOwnClip
)
1382 ScViewData
* pData
= GetViewData();
1383 if ( pData
->GetMarkData().GetTableSelect( pData
->GetTabNo() ) )
1385 SCCOL nStartX
, nEndX
, nClipStartX
, nClipSizeX
, nRangeSizeX
;
1386 SCROW nStartY
, nEndY
, nClipStartY
, nClipSizeY
, nRangeSizeY
;
1387 SCTAB nStartTab
, nEndTab
;
1388 pOwnClip
->GetDocument()->GetClipStart( nClipStartX
, nClipStartY
);
1389 pOwnClip
->GetDocument()->GetClipArea( nClipSizeX
, nClipSizeY
, true );
1391 if ( !( pData
->GetSimpleArea( nStartX
, nStartY
, nStartTab
,
1392 nEndX
, nEndY
, nEndTab
) == SC_MARK_SIMPLE
&&
1393 nStartTab
== nEndTab
) )
1395 // the destination is not a simple range,
1396 // assume the destination as the current cell
1397 nStartX
= nEndX
= pData
->GetCurX();
1398 nStartY
= nEndY
= pData
->GetCurY();
1399 nStartTab
= pData
->GetTabNo();
1401 // we now have clip- and range dimensions
1402 // the size of the destination area is the larger of the two
1403 nRangeSizeX
= nClipSizeX
>= nEndX
- nStartX
? nClipSizeX
: nEndX
- nStartX
;
1404 nRangeSizeY
= nClipSizeY
>= nEndY
- nStartY
? nClipSizeY
: nEndY
- nStartY
;
1405 // When the source and destination areas intersect things may go wrong,
1406 // especially if the area contains references. This may produce data loss
1407 // (e.g. formulas that get wrong references), this scenario _must_ be avoided.
1408 ScRange
aSource( nClipStartX
, nClipStartY
, nStartTab
,
1409 nClipStartX
+ nClipSizeX
, nClipStartY
+ nClipSizeY
, nStartTab
);
1410 ScRange
aDest( nStartX
, nStartY
, nStartTab
,
1411 nStartX
+ nRangeSizeX
, nStartY
+ nRangeSizeY
, nStartTab
);
1412 if ( pOwnClip
->GetDocument()->IsCutMode() && aSource
.Intersects( aDest
) )
1413 pDlg
->SetCellShiftDisabled( SC_CELL_SHIFT_DISABLE_DOWN
| SC_CELL_SHIFT_DISABLE_RIGHT
);
1416 //no conflict with intersecting ranges,
1417 //check if paste plus shift will fit on sheet
1418 //and disable shift-option if no fit
1419 int nDisableShiftX
= 0;
1420 int nDisableShiftY
= 0;
1422 //check if horizontal shift will fit
1423 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1424 MAXCOL
- nRangeSizeX
, nStartY
,
1425 MAXCOL
, nStartY
+ nRangeSizeY
, false ) )
1426 nDisableShiftX
= SC_CELL_SHIFT_DISABLE_RIGHT
;
1428 //check if vertical shift will fit
1429 if ( !pData
->GetDocument()->IsBlockEmpty( nStartTab
,
1430 nStartX
, MAXROW
- nRangeSizeY
,
1431 nStartX
+ nRangeSizeX
, MAXROW
, false ) )
1432 nDisableShiftY
= SC_CELL_SHIFT_DISABLE_DOWN
;
1434 if ( nDisableShiftX
|| nDisableShiftY
)
1435 pDlg
->SetCellShiftDisabled( nDisableShiftX
| nDisableShiftY
);
1439 if (pDlg
->Execute() == RET_OK
)
1441 nFlags
= pDlg
->GetInsContentsCmdBits();
1442 nFunction
= pDlg
->GetFormulaCmdBits();
1443 bSkipEmpty
= pDlg
->IsSkipEmptyCells();
1444 bTranspose
= pDlg
->IsTranspose();
1445 bAsLink
= pDlg
->IsLink();
1446 eMoveMode
= pDlg
->GetMoveMode();
1450 pTabViewShell
->ErrorMessage(aTester
.GetMessageId());
1453 if( nFlags
!= IDF_NONE
)
1456 WaitObject
aWait( GetViewData()->GetDialogParent() );
1457 if ( bAsLink
&& bOtherDoc
)
1458 pTabViewShell
->PasteFromSystem(SotClipboardFormatId::LINK
); // DDE insert
1461 pTabViewShell
->PasteFromClip( nFlags
, pOwnClip
->GetDocument(),
1462 nFunction
, bSkipEmpty
, bTranspose
, bAsLink
,
1463 eMoveMode
, IDF_NONE
, true ); // allow warning dialog
1471 if( nFlags
== IDF_ALL
)
1477 if( nFlags
& IDF_STRING
) aFlags
+= "S";
1478 if( nFlags
& IDF_VALUE
) aFlags
+= "V";
1479 if( nFlags
& IDF_DATETIME
) aFlags
+= "D";
1480 if( nFlags
& IDF_FORMULA
) aFlags
+= "F";
1481 if( nFlags
& IDF_NOTE
) aFlags
+= "N";
1482 if( nFlags
& IDF_ATTRIB
) aFlags
+= "T";
1485 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1486 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bSkipEmpty
) );
1487 rReq
.AppendItem( SfxBoolItem( FN_PARAM_3
, bTranspose
) );
1488 rReq
.AppendItem( SfxBoolItem( FN_PARAM_4
, bAsLink
) );
1489 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, nFunction
) );
1490 rReq
.AppendItem( SfxInt16Item( FN_PARAM_5
, (sal_Int16
) eMoveMode
) );
1496 pTabViewShell
->CellContentChanged(); // => PasteFromXXX ???
1498 case SID_PASTE_ONLY_VALUE
:
1499 case SID_PASTE_ONLY_TEXT
:
1500 case SID_PASTE_ONLY_FORMULA
:
1502 vcl::Window
* pWin
= GetViewData()->GetActiveWin();
1503 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1505 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1507 if ( nSlot
== SID_PASTE_ONLY_VALUE
)
1509 else if ( nSlot
== SID_PASTE_ONLY_TEXT
)
1513 rReq
.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS
, aFlags
) );
1514 ExecuteSlot( rReq
, GetInterface() );
1515 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1516 pTabViewShell
->CellContentChanged();
1519 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1522 case SID_PASTE_SPECIAL
:
1523 // differentiate between own cell data and draw objects/external data
1524 // this makes FID_INS_CELL_CONTENTS superfluous
1526 vcl::Window
* pWin
= GetViewData()->GetActiveWin();
1528 // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
1529 const SfxPoolItem
* pItem
=NULL
;
1531 pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
&&
1532 pItem
->ISA(SfxUInt32Item
) )
1534 SotClipboardFormatId nFormat
= static_cast<SotClipboardFormatId
>(static_cast<const SfxUInt32Item
*>(pItem
)->GetValue());
1537 WaitObject
aWait( GetViewData()->GetDialogParent() );
1538 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1539 if ( bDraw
&& nFormat
== SotClipboardFormatId::EMBED_SOURCE
)
1540 pTabViewShell
->PasteDraw();
1542 bRet
= pTabViewShell
->PasteFromSystem(nFormat
, true); // TRUE: no error messages
1547 rReq
.SetReturnValue(SfxInt16Item(nSlot
, bRet
? 1 : 0)); // 1 = success, 0 = fail
1551 // if format is not available -> fallback to request without parameters
1557 if ( ScTransferObj::GetOwnClipboard( pWin
) ) // own cell data
1559 rReq
.SetSlot( FID_INS_CELL_CONTENTS
);
1560 ExecuteSlot( rReq
, GetInterface() );
1561 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1563 else // draw objects or external data
1565 bool bDraw
= ( ScDrawTransferObj::GetOwnClipboard( pWin
) != NULL
);
1567 SvxClipboardFormatItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
1568 GetPossibleClipboardFormats( aFormats
);
1570 sal_uInt16 nFormatCount
= aFormats
.Count();
1573 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1574 boost::scoped_ptr
<SfxAbstractPasteDialog
> pDlg(pFact
->CreatePasteDialog( pTabViewShell
->GetDialogParent() ));
1577 for (sal_uInt16 i
=0; i
<nFormatCount
; i
++)
1579 SotClipboardFormatId nFormatId
= aFormats
.GetClipbrdFormatId( i
);
1580 OUString aName
= aFormats
.GetClipbrdFormatName( i
);
1581 // special case for paste dialog: '*' is replaced by object type
1582 if ( nFormatId
== SotClipboardFormatId::EMBED_SOURCE
)
1584 pDlg
->Insert( nFormatId
, aName
);
1587 TransferableDataHelper
aDataHelper(
1588 TransferableDataHelper::CreateFromSystemClipboard( pWin
) );
1589 SotClipboardFormatId nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
1590 if (nFormat
!= SotClipboardFormatId::NONE
)
1593 WaitObject
aWait( GetViewData()->GetDialogParent() );
1594 if ( bDraw
&& nFormat
== SotClipboardFormatId::EMBED_SOURCE
)
1595 pTabViewShell
->PasteDraw();
1597 pTabViewShell
->PasteFromSystem(nFormat
);
1599 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 1)); // 1 = success
1600 rReq
.AppendItem( SfxUInt32Item( nSlot
, static_cast<sal_uInt32
>(nFormat
) ) );
1605 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1611 rReq
.SetReturnValue(SfxInt16Item(nSlot
, 0)); // 0 = fail
1615 pTabViewShell
->CellContentChanged(); // => PasteFromSystem() ???
1620 case FID_INS_ROWBRK
:
1621 pTabViewShell
->InsertPageBreak( false );
1625 case FID_INS_COLBRK
:
1626 pTabViewShell
->InsertPageBreak( true );
1630 case FID_DEL_ROWBRK
:
1631 pTabViewShell
->DeletePageBreak( false );
1635 case FID_DEL_COLBRK
:
1636 pTabViewShell
->DeletePageBreak( true );
1640 case SID_DETECTIVE_ADD_PRED
:
1641 pTabViewShell
->DetectiveAddPred();
1645 case SID_DETECTIVE_DEL_PRED
:
1646 pTabViewShell
->DetectiveDelPred();
1650 case SID_DETECTIVE_ADD_SUCC
:
1651 pTabViewShell
->DetectiveAddSucc();
1655 case SID_DETECTIVE_DEL_SUCC
:
1656 pTabViewShell
->DetectiveDelSucc();
1660 case SID_DETECTIVE_ADD_ERR
:
1661 pTabViewShell
->DetectiveAddError();
1665 case SID_DETECTIVE_INVALID
:
1666 pTabViewShell
->DetectiveMarkInvalid();
1670 case SID_DETECTIVE_REFRESH
:
1671 pTabViewShell
->DetectiveRefresh();
1675 case SID_DETECTIVE_MARK_PRED
:
1676 pTabViewShell
->DetectiveMarkPred();
1678 case SID_DETECTIVE_MARK_SUCC
:
1679 pTabViewShell
->DetectiveMarkSucc();
1681 case SID_INSERT_CURRENT_DATE
:
1682 pTabViewShell
->InsertCurrentTime(
1683 css::util::NumberFormat::DATE
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE
));
1685 case SID_INSERT_CURRENT_TIME
:
1686 pTabViewShell
->InsertCurrentTime(
1687 css::util::NumberFormat::TIME
, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME
));
1690 case SID_SPELL_DIALOG
:
1692 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
1693 if( rReq
.GetArgs() )
1694 pViewFrame
->SetChildWindow( SID_SPELL_DIALOG
,
1695 static_cast< const SfxBoolItem
& >( rReq
.GetArgs()->
1696 Get( SID_SPELL_DIALOG
) ).GetValue() );
1698 pViewFrame
->ToggleChildWindow( SID_SPELL_DIALOG
);
1700 pViewFrame
->GetBindings().Invalidate( SID_SPELL_DIALOG
);
1705 case SID_HANGUL_HANJA_CONVERSION
:
1706 pTabViewShell
->DoHangulHanjaConversion();
1709 case SID_CHINESE_CONVERSION
:
1711 //open ChineseTranslationDialog
1712 Reference
< XComponentContext
> xContext(
1713 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1716 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1719 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1720 xMCF
->createInstanceWithContext(
1721 OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
1722 , xContext
), UNO_QUERY
);
1723 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1726 // initialize dialog
1727 Reference
< awt::XWindow
> xDialogParentWindow(0);
1728 Sequence
<Any
> aSeq(1);
1729 Any
* pArray
= aSeq
.getArray();
1730 PropertyValue aParam
;
1731 aParam
.Name
= "ParentWindow";
1732 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1733 pArray
[0] <<= makeAny(aParam
);
1734 xInit
->initialize( aSeq
);
1737 sal_Int16 nDialogRet
= xDialog
->execute();
1738 if( RET_OK
== nDialogRet
)
1740 //get some parameters from the dialog
1741 bool bToSimplified
= true;
1742 bool bUseVariants
= true;
1743 bool bCommonTerms
= true;
1744 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1749 xProp
->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified
;
1750 xProp
->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants
;
1751 xProp
->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms
;
1758 //execute translation
1759 LanguageType eSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1760 LanguageType eTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1761 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1763 nOptions
|= i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1765 vcl::Font aTargetFont
= OutputDevice::GetDefaultFont(
1766 DefaultFontType::CJK_SPREADSHEET
,
1767 eTargetLang
, GetDefaultFontFlags::OnlyOne
);
1768 ScConversionParam
aConvParam( SC_CONVERSION_CHINESE_TRANSL
,
1769 eSourceLang
, eTargetLang
, aTargetFont
, nOptions
, false );
1770 pTabViewShell
->DoSheetConversion( aConvParam
);
1773 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1774 if( xComponent
.is() )
1775 xComponent
->dispose();
1781 case SID_CONVERT_FORMULA_TO_VALUE
:
1783 pTabViewShell
->ConvertFormulaToValue();
1787 pTabViewShell
->DoThesaurus();
1790 case SID_TOGGLE_REL
:
1791 pTabViewShell
->DoRefConversion();
1794 case SID_DEC_INDENT
:
1795 pTabViewShell
->ChangeIndent( false );
1797 case SID_INC_INDENT
:
1798 pTabViewShell
->ChangeIndent( true );
1803 sal_uInt16 nFlags
= pTabViewShell
->GetCreateNameFlags();
1805 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1806 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
1808 boost::scoped_ptr
<AbstractScNameCreateDlg
> pDlg(pFact
->CreateScNameCreateDlg(pTabViewShell
->GetDialogParent(), nFlags
));
1809 OSL_ENSURE(pDlg
, "Dialog create fail!");
1811 if( pDlg
->Execute() )
1813 nFlags
= pDlg
->GetFlags();
1814 pTabViewShell
->CreateNames(nFlags
);
1820 case SID_CONSOLIDATE
:
1822 const SfxPoolItem
* pItem
;
1823 if ( pReqArgs
&& SfxItemState::SET
==
1824 pReqArgs
->GetItemState( SCITEM_CONSOLIDATEDATA
, true, &pItem
) )
1826 const ScConsolidateParam
& rParam
=
1827 static_cast<const ScConsolidateItem
*>(pItem
)->GetData();
1829 pTabViewShell
->Consolidate( rParam
);
1830 GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam
);
1834 #if HAVE_FEATURE_SCRIPTING
1835 else if (rReq
.IsAPI())
1836 SbxBase::SetError(SbxERR_BAD_PARAMETER
);
1841 case SID_INS_FUNCTION
:
1843 const SfxBoolItem
* pOkItem
= static_cast<const SfxBoolItem
*>(&pReqArgs
->Get( SID_DLG_RETOK
));
1845 if ( pOkItem
->GetValue() ) // OK
1848 const SfxStringItem
* pSItem
= static_cast<const SfxStringItem
*>(&pReqArgs
->Get( SCITEM_STRING
));
1849 const SfxBoolItem
* pMatrixItem
= static_cast<const SfxBoolItem
*>(&pReqArgs
->Get( SID_DLG_MATRIX
));
1851 aFormula
+= pSItem
->GetValue();
1852 pScMod
->ActivateInputWindow( &aFormula
, pMatrixItem
->GetValue() );
1856 pScMod
->ActivateInputWindow( NULL
);
1858 rReq
.Ignore(); // only SID_ENTER_STRING is recorded
1862 case FID_DEFINE_NAME
:
1865 const SfxPoolItem
* pItem
;
1866 OUString aName
, aSymbol
, aAttrib
;
1868 if( pReqArgs
->HasItem( FID_DEFINE_NAME
, &pItem
) )
1869 aName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1871 if( pReqArgs
->HasItem( FN_PARAM_1
, &pItem
) )
1872 aSymbol
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1874 if( pReqArgs
->HasItem( FN_PARAM_2
, &pItem
) )
1875 aAttrib
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1877 if ( !aName
.isEmpty() && !aSymbol
.isEmpty() )
1879 if (pTabViewShell
->InsertName( aName
, aSymbol
, aAttrib
))
1881 #if HAVE_FEATURE_SCRIPTING
1883 SbxBase::SetError( SbxERR_BAD_PARAMETER
); // Basic-error
1889 sal_uInt16 nId
= ScNameDlgWrapper::GetChildWindowId();
1890 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1891 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1893 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1898 sal_uInt16 nId
= ScNameDefDlgWrapper::GetChildWindowId();
1899 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1900 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1902 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1906 case SID_OPENDLG_CONDFRMT
:
1907 case SID_OPENDLG_COLORSCALE
:
1908 case SID_OPENDLG_DATABAR
:
1909 case SID_OPENDLG_ICONSET
:
1910 case SID_OPENDLG_CONDDATE
:
1912 sal_uInt32 nIndex
= sal_uInt32(-1);
1913 sal_uInt8 nType
= 0;
1914 bool bManaged
= false;
1916 // Get the pool item stored it by Conditional Format Manager Dialog.
1917 const SfxPoolItem
* pItem
= NULL
;
1918 sal_uInt32
nItems(pTabViewShell
->GetPool().GetItemCount2( SCITEM_STRING
));
1919 for( sal_uInt32 nIter
= 0; nIter
< nItems
; ++nIter
)
1921 if( NULL
!= (pItem
= pTabViewShell
->GetPool().GetItem2( SCITEM_STRING
, nIter
) ) )
1923 if ( ScCondFormatDlg::ParseXmlString(
1924 static_cast<const SfxStringItem
*>(pItem
)->GetValue(),
1925 nIndex
, nType
, bManaged
))
1930 // Check if the Conditional Manager Dialog is editing or adding
1931 // conditional format item.
1934 sal_uInt16 nId
= ScCondFormatDlgWrapper::GetChildWindowId();
1935 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
1936 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
1938 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1942 ScRangeList aRangeList
;
1943 ScViewData
* pData
= GetViewData();
1944 pData
->GetMarkData().FillRangeListWithMarks(&aRangeList
, false);
1946 ScDocument
* pDoc
= GetViewData()->GetDocument();
1947 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
1949 //ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
1953 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
1954 if(aRangeList
.empty())
1956 ScRange
* pRange
= new ScRange(aPos
);
1957 aRangeList
.push_back(pRange
);
1960 const ScConditionalFormat
* pCondFormat
= NULL
;
1961 const ScPatternAttr
* pPattern
= pDoc
->GetPattern(aPos
.Col(), aPos
.Row(), aPos
.Tab());
1962 const std::vector
<sal_uInt32
>& rCondFormats
= static_cast<const ScCondFormatItem
&>(pPattern
->GetItem(ATTR_CONDITIONAL
)).GetCondFormatData();
1963 bool bContainsCondFormat
= !rCondFormats
.empty();
1964 bool bCondFormatDlg
= false;
1965 if(bContainsCondFormat
)
1967 bool bContainsExistingCondFormat
= false;
1968 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList(aPos
.Tab());
1969 for (std::vector
<sal_uInt32
>::const_iterator itr
= rCondFormats
.begin(), itrEnd
= rCondFormats
.end();
1970 itr
!= itrEnd
; ++itr
)
1972 // check if at least one existing conditional format has the same range
1973 pCondFormat
= pList
->GetFormat(*itr
);
1977 bContainsExistingCondFormat
= true;
1978 const ScRangeList
& rCondFormatRange
= pCondFormat
->GetRange();
1979 if(rCondFormatRange
== aRangeList
)
1981 // found a matching range, edit this conditional format
1982 bCondFormatDlg
= true;
1987 // if not found a conditional format ask whether we should edit one of the existing
1988 // or should create a new overlapping conditional format
1989 if(!bCondFormatDlg
&& bContainsExistingCondFormat
)
1991 ScopedVclPtrInstance
<QueryBox
> aBox( pTabViewShell
->GetDialogParent(), WinBits( WB_YES_NO
| WB_DEF_YES
),
1992 ScGlobal::GetRscString(STR_EDIT_EXISTING_COND_FORMATS
) );
1993 bool bEditExisting
= aBox
->Execute() == RET_YES
;
1996 // differentiate between ranges where one conditional format is defined
1997 // and several formats are defined
1998 // if we have only one => open the cond format dlg to edit it
1999 // otherwise open the manage cond format dlg
2000 if(rCondFormats
.size() == 1)
2002 pCondFormat
= pList
->GetFormat(rCondFormats
[0]);
2003 assert(pCondFormat
);
2004 bCondFormatDlg
= true;
2008 // Queue message to open Conditional Format Manager Dialog.
2009 GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER
, SfxCallMode::ASYNCHRON
);
2015 // define an overlapping conditional format
2016 // does not need to be handled here
2021 condformat::dialog::ScCondFormatDialogType eType
= condformat::dialog::NONE
;
2024 case SID_OPENDLG_CONDFRMT
:
2025 eType
= condformat::dialog::CONDITION
;
2027 case SID_OPENDLG_COLORSCALE
:
2028 eType
= condformat::dialog::COLORSCALE
;
2030 case SID_OPENDLG_DATABAR
:
2031 eType
= condformat::dialog::DATABAR
;
2033 case SID_OPENDLG_ICONSET
:
2034 eType
= condformat::dialog::ICONSET
;
2036 case SID_OPENDLG_CONDDATE
:
2037 eType
= condformat::dialog::DATE
;
2045 if(bCondFormatDlg
|| !bContainsCondFormat
)
2047 // Put the xml string parameter to initialize the
2048 // Conditional Format Dialog.
2049 pTabViewShell
->GetPool().Put( SfxStringItem( SCITEM_STRING
,
2050 ScCondFormatDlg::GenerateXmlString(
2051 pCondFormat
? pCondFormat
->GetKey() : sal_uInt32(-1),
2056 sal_uInt16 nId
= ScCondFormatDlgWrapper::GetChildWindowId();
2057 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2058 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2060 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
2065 case SID_DEFINE_COLROWNAMERANGES
:
2068 sal_uInt16 nId
= ScColRowNameRangesDlgWrapper::GetChildWindowId();
2069 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2070 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2072 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
2077 case SID_UPDATECHART
:
2083 const SfxPoolItem
* pItem
;
2085 if( pReqArgs
->HasItem( SID_UPDATECHART
, &pItem
) )
2086 bAll
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
2089 pTabViewShell
->UpdateCharts( bAll
);
2091 if( ! rReq
.IsAPI() )
2093 rReq
.AppendItem( SfxBoolItem( SID_UPDATECHART
, bAll
) );
2102 const ScTabOpItem
& rItem
=
2103 static_cast<const ScTabOpItem
&>(
2104 pReqArgs
->Get( SID_TABOP
));
2106 pTabViewShell
->TabOp( rItem
.GetData() );
2108 rReq
.Done( *pReqArgs
);
2115 const ScSolveItem
& rItem
=
2116 static_cast<const ScSolveItem
&>(
2117 pReqArgs
->Get( SCITEM_SOLVEDATA
));
2119 pTabViewShell
->Solve( rItem
.GetData() );
2121 rReq
.Done( *pReqArgs
);
2125 case FID_INSERT_NAME
:
2127 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2128 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2130 boost::scoped_ptr
<AbstractScNamePasteDlg
> pDlg(pFact
->CreateScNamePasteDlg( pTabViewShell
->GetDialogParent(), GetViewData()->GetDocShell() ));
2131 OSL_ENSURE(pDlg
, "Dialog create fail!");
2132 switch( pDlg
->Execute() )
2134 case BTN_PASTE_LIST
:
2135 pTabViewShell
->InsertNameList();
2137 case BTN_PASTE_NAME
:
2139 ScInputHandler
* pHdl
= pScMod
->GetInputHdl( pTabViewShell
);
2142 // "=" in KeyEvent, switches to input-mode
2143 (void)pScMod
->InputKeyEvent( KeyEvent('=', vcl::KeyCode()) );
2145 std::vector
<OUString
> aNames
= pDlg
->GetSelectedNames();
2146 if (!aNames
.empty())
2148 OUStringBuffer aBuffer
;
2149 for (std::vector
<OUString
>::const_iterator itr
= aNames
.begin();
2150 itr
!= aNames
.end(); ++itr
)
2152 aBuffer
.append(*itr
).append(' ');
2154 pHdl
->InsertFunction( aBuffer
.makeStringAndClear(), false ); // without "()"
2163 case SID_RANGE_NOTETEXT
:
2166 const SfxStringItem
& rTextItem
= static_cast<const SfxStringItem
&>(pReqArgs
->Get( SID_RANGE_NOTETEXT
));
2168 // always cursor position
2169 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2170 pTabViewShell
->SetNoteText( aPos
, rTextItem
.GetValue() );
2175 case SID_INSERT_POSTIT
:
2176 case SID_EDIT_POSTIT
:
2179 const SvxPostItAuthorItem
& rAuthorItem
= static_cast<const SvxPostItAuthorItem
&>(pReqArgs
->Get( SID_ATTR_POSTIT_AUTHOR
));
2180 const SvxPostItDateItem
& rDateItem
= static_cast<const SvxPostItDateItem
&>(pReqArgs
->Get( SID_ATTR_POSTIT_DATE
));
2181 const SvxPostItTextItem
& rTextItem
= static_cast<const SvxPostItTextItem
&>(pReqArgs
->Get( SID_ATTR_POSTIT_TEXT
));
2183 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2184 pTabViewShell
->ReplaceNote( aPos
, rTextItem
.GetValue(), &rAuthorItem
.GetValue(), &rDateItem
.GetValue() );
2189 pTabViewShell
->EditNote(); // note object to edit
2193 case FID_NOTE_VISIBLE
:
2195 ScDocument
* pDoc
= GetViewData()->GetDocument();
2196 ScAddress
aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
2197 if( ScPostIt
* pNote
= pDoc
->GetNote(aPos
) )
2200 const SfxPoolItem
* pItem
;
2201 if ( pReqArgs
&& (pReqArgs
->GetItemState( FID_NOTE_VISIBLE
, true, &pItem
) == SfxItemState::SET
) )
2202 bShow
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
2204 bShow
= !pNote
->IsCaptionShown();
2206 pTabViewShell
->ShowNote( bShow
);
2209 rReq
.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE
, bShow
) );
2212 rBindings
.Invalidate( FID_NOTE_VISIBLE
);
2222 bool bShowNote
= nSlot
== FID_SHOW_NOTE
;
2223 ScViewData
* pData
= GetViewData();
2224 ScDocument
* pDoc
= pData
->GetDocument();
2225 ScMarkData
& rMark
= pData
->GetMarkData();
2228 if (!rMark
.IsMarked() && !rMark
.IsMultiMarked())
2230 // Check current cell
2231 ScAddress
aPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2232 if( pDoc
->GetNote(aPos
) )
2234 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2240 // Check selection range
2241 ScRangeListRef aRangesRef
;
2242 pData
->GetMultiArea(aRangesRef
);
2243 ScRangeList aRanges
= *aRangesRef
;
2244 size_t nRangeSize
= aRanges
.size();
2246 OUString aUndo
= ScGlobal::GetRscString( bShowNote
? STR_UNDO_SHOWNOTE
: STR_UNDO_HIDENOTE
);
2247 pData
->GetDocShell()->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
2249 for ( size_t i
= 0; i
< nRangeSize
; ++i
)
2251 const ScRange
* pRange
= aRanges
[i
];
2252 const SCROW nRow0
= pRange
->aStart
.Row();
2253 const SCROW nRow1
= pRange
->aEnd
.Row();
2254 const SCCOL nCol0
= pRange
->aStart
.Col();
2255 const SCCOL nCol1
= pRange
->aEnd
.Col();
2256 const SCTAB nRangeTab
= pRange
->aStart
.Tab();
2257 // Check by each cell
2258 for ( SCROW nRow
= nRow0
; nRow
<= nRow1
; ++nRow
)
2260 for ( SCCOL nCol
= nCol0
; nCol
<= nCol1
; ++nCol
)
2262 if ( pDoc
->HasNote(nCol
, nRow
, nRangeTab
) && pDoc
->IsBlockEditable( nRangeTab
, nCol
,nRow
, nCol
,nRow
) )
2264 ScAddress
aPos( nCol
, nRow
, nRangeTab
);
2265 pData
->GetDocShell()->GetDocFunc().ShowNote( aPos
, bShowNote
);
2272 pData
->GetDocShell()->GetUndoManager()->LeaveListAction();
2277 rBindings
.Invalidate( nSlot
);
2285 case SID_DELETE_NOTE
:
2286 pTabViewShell
->DeleteContents( IDF_NOTE
); // delete all notes in selection
2291 if( pReqArgs
!= NULL
)
2293 OUString aChars
, aFontName
;
2294 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2295 const SfxPoolItem
* pItem
= 0;
2297 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), false, &pItem
);
2300 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, pItem
);
2302 aChars
= pStringItem
->GetValue();
2303 const SfxPoolItem
* pFtItem
= NULL
;
2304 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), false, &pFtItem
);
2305 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
2307 aFontName
= pFontItem
->GetValue();
2310 if ( !aChars
.isEmpty() )
2313 pTabViewShell
->GetSelectionPattern()->GetFont( aFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2314 pTabViewShell
->GetSelectionScriptType() );
2315 if ( !aFontName
.isEmpty() )
2316 aFont
= vcl::Font( aFontName
, Size(1,1) );
2317 pTabViewShell
->InsertSpecialChar( aChars
, aFont
);
2318 if( ! rReq
.IsAPI() )
2324 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
2326 // font color doesn't matter here
2328 pTabViewShell
->GetSelectionPattern()->GetFont( aCurFont
, SC_AUTOCOL_BLACK
, NULL
, NULL
, NULL
,
2329 pTabViewShell
->GetSelectionScriptType() );
2331 SfxAllItemSet
aSet( GetPool() );
2332 aSet
.Put( SfxBoolItem( FN_PARAM_1
, false ) );
2333 aSet
.Put( SvxFontItem( aCurFont
.GetFamily(), aCurFont
.GetName(), aCurFont
.GetStyleName(), aCurFont
.GetPitch(), aCurFont
.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT
) ) );
2335 boost::scoped_ptr
<SfxAbstractDialog
> pDlg(pFact
->CreateSfxDialog( pTabViewShell
->GetDialogParent(), aSet
,
2336 pTabViewShell
->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP
));
2338 if ( pDlg
->Execute() == RET_OK
)
2340 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pItem
, SfxStringItem
, SID_CHARMAP
, false );
2341 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, false );
2343 if ( pItem
&& pFontItem
)
2345 vcl::Font
aNewFont( pFontItem
->GetFamilyName(), pFontItem
->GetStyleName(), Size(1,1) );
2346 aNewFont
.SetCharSet( pFontItem
->GetCharSet() );
2347 aNewFont
.SetPitch( pFontItem
->GetPitch() );
2348 pTabViewShell
->InsertSpecialChar( pItem
->GetValue(), aNewFont
);
2349 rReq
.AppendItem( *pFontItem
);
2350 rReq
.AppendItem( *pItem
);
2357 case SID_SELECT_SCENARIO
:
2363 const SfxStringItem
* pItem
=
2364 static_cast<const SfxStringItem
*>(&pReqArgs
->Get( SID_SELECT_SCENARIO
));
2368 pTabViewShell
->UseScenario( pItem
->GetValue() );
2369 //! why should the return value be valid?!?!
2370 rReq
.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO
, pItem
->GetValue() ) );
2381 case SID_HYPERLINK_SETLINK
:
2384 const SfxPoolItem
* pItem
;
2385 if( pReqArgs
->HasItem( SID_HYPERLINK_SETLINK
, &pItem
) )
2387 const SvxHyperlinkItem
* pHyper
= static_cast<const SvxHyperlinkItem
*>(pItem
);
2388 const OUString
& rName
= pHyper
->GetName();
2389 const OUString
& rURL
= pHyper
->GetURL();
2390 const OUString
& rTarget
= pHyper
->GetTargetFrame();
2391 sal_uInt16 nType
= (sal_uInt16
) pHyper
->GetInsertMode();
2393 pTabViewShell
->InsertURL( rName
, rURL
, rTarget
, nType
);
2401 case SID_OPENDLG_CONDFRMT_MANAGER
:
2403 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2404 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2406 ScViewData
* pData
= GetViewData();
2407 ScDocument
* pDoc
= pData
->GetDocument();
2409 if(pDoc
->IsTabProtected(pData
->GetTabNo()))
2411 pTabViewShell
->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED
);
2415 ScAddress
aPos(pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo());
2417 ScConditionalFormatList
* pList
= pDoc
->GetCondFormList( aPos
.Tab() );
2418 boost::scoped_ptr
<AbstractScCondFormatManagerDlg
> pDlg(pFact
->CreateScCondFormatMgrDlg(
2419 pTabViewShell
->GetDialogParent(), pDoc
, pList
, aPos
, RID_SCDLG_COND_FORMAT_MANAGER
));
2420 short nRet
= pDlg
->Execute();
2421 if(nRet
== RET_OK
&& pDlg
->CondFormatsChanged())
2423 ScConditionalFormatList
* pCondFormatList
= pDlg
->GetConditionalFormatList();
2424 pData
->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList
, aPos
.Tab());
2426 else if(nRet
== DLG_RET_ADD
)
2428 // Put the xml string parameter to initialize the
2429 // Conditional Format Dialog. ( add new )
2430 pTabViewShell
->GetPool().Put( SfxStringItem( SCITEM_STRING
,
2431 ScCondFormatDlg::GenerateXmlString(
2433 sal_uInt8(condformat::dialog::ScCondFormatDialogType::CONDITION
),
2437 // Queue message to open Conditional Format Dialog
2438 GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT
, SfxCallMode::ASYNCHRON
);
2440 else if (nRet
== DLG_RET_EDIT
)
2442 ScConditionalFormat
* pFormat
= pDlg
->GetCondFormatSelected();
2443 // Put the xml string parameter to initialize the
2444 // Conditional Format Dialog. ( edit selected conditional format )
2445 pTabViewShell
->GetPool().Put( SfxStringItem( SCITEM_STRING
,
2446 ScCondFormatDlg::GenerateXmlString(
2447 pFormat
? pFormat
->GetKey() : sal_uInt32(-1),
2448 sal_uInt8(condformat::dialog::ScCondFormatDialogType::CONDITION
),
2452 // Queue message to open Conditional Format Dialog
2453 GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT
, SfxCallMode::ASYNCHRON
);
2458 case SID_EXTERNAL_SOURCE
:
2464 sal_uLong nRefresh
=0;
2466 SFX_REQUEST_ARG( rReq
, pFile
, SfxStringItem
, SID_FILE_NAME
, false );
2467 SFX_REQUEST_ARG( rReq
, pSource
, SfxStringItem
, FN_PARAM_1
, false );
2468 if ( pFile
&& pSource
)
2470 aFile
= pFile
->GetValue();
2471 aSource
= pSource
->GetValue();
2472 SFX_REQUEST_ARG( rReq
, pFilter
, SfxStringItem
, SID_FILTER_NAME
, false );
2474 aFilter
= pFilter
->GetValue();
2475 SFX_REQUEST_ARG( rReq
, pOptions
, SfxStringItem
, SID_FILE_FILTEROPTIONS
, false );
2477 aOptions
= pOptions
->GetValue();
2478 SFX_REQUEST_ARG( rReq
, pRefresh
, SfxUInt32Item
, FN_PARAM_2
, false );
2480 nRefresh
= pRefresh
->GetValue();
2484 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2485 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2487 delete pImpl
->m_pLinkedDlg
;
2488 pImpl
->m_pLinkedDlg
=
2489 pFact
->CreateScLinkedAreaDlg(pTabViewShell
->GetDialogParent());
2490 OSL_ENSURE(pImpl
->m_pLinkedDlg
, "Dialog create fail!");
2491 delete pImpl
->m_pRequest
;
2492 pImpl
->m_pRequest
= new SfxRequest( rReq
);
2493 pImpl
->m_pLinkedDlg
->StartExecuteModal( LINK( this, ScCellShell
, DialogClosed
) );
2497 ExecuteExternalSource( aFile
, aFilter
, aOptions
, aSource
, nRefresh
, rReq
);
2502 OSL_FAIL("incorrect slot in ExecuteEdit");
2507 void ScCellShell::ExecuteTrans( SfxRequest
& rReq
)
2509 sal_Int32 nType
= ScViewUtil::GetTransliterationType( rReq
.GetSlot() );
2512 GetViewData()->GetView()->TransliterateText( nType
);
2517 void ScCellShell::ExecuteRotateTrans( SfxRequest
& rReq
)
2519 if( rReq
.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE
)
2520 GetViewData()->GetView()->TransliterateText( m_aRotateCase
.getNextMode() );
2523 void ScCellShell::ExecuteExternalSource(
2524 const OUString
& _rFile
, const OUString
& _rFilter
, const OUString
& _rOptions
,
2525 const OUString
& _rSource
, sal_uLong _nRefresh
, SfxRequest
& _rRequest
)
2527 if ( !_rFile
.isEmpty() && !_rSource
.isEmpty() ) // filter may be empty
2532 ScViewData
* pData
= GetViewData();
2533 ScMarkData
& rMark
= pData
->GetMarkData();
2534 rMark
.MarkToSimple();
2535 if ( rMark
.IsMarked() )
2537 rMark
.GetMarkArea( aLinkRange
);
2538 bMove
= true; // insert/delete cells to fit range
2541 aLinkRange
= ScRange( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
2543 pData
->GetDocFunc().InsertAreaLink( _rFile
, _rFilter
, _rOptions
, _rSource
,
2544 aLinkRange
, _nRefresh
, bMove
, false );
2553 bool isDPSourceValid(const ScDPObject
& rDPObj
)
2555 if (rDPObj
.IsImportData())
2557 // If the data type is database, check if the database is still valid.
2558 const ScImportSourceDesc
* pDesc
= rDPObj
.GetImportSourceDesc();
2562 const ScDPSaveData
* pSaveData
= rDPObj
.GetSaveData();
2563 const ScDPDimensionSaveData
* pDimData
= NULL
;
2565 pDimData
= pSaveData
->GetExistingDimensionData();
2567 const ScDPCache
* pCache
= pDesc
->CreateCache(pDimData
);
2569 // cashe creation failed, probably due to invalid connection.
2577 void ScCellShell::ExecuteDataPilotDialog()
2579 ScModule
* pScMod
= SC_MOD();
2580 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2581 ScViewData
* pData
= GetViewData();
2582 ScDocument
* pDoc
= pData
->GetDocument();
2584 ::boost::scoped_ptr
<ScDPObject
> pNewDPObject(NULL
);
2586 // ScPivot is no longer used...
2587 ScDPObject
* pDPObj
= pDoc
->GetDPAtCursor(
2588 pData
->GetCurX(), pData
->GetCurY(),
2589 pData
->GetTabNo() );
2590 if ( pDPObj
) // on an existing table?
2592 if (isDPSourceValid(*pDPObj
))
2593 pNewDPObject
.reset(new ScDPObject(*pDPObj
));
2595 else // create new table
2597 sal_uLong nSrcErrorId
= 0;
2599 // select database range or data
2600 pTabViewShell
->GetDBData( true, SC_DB_OLD
);
2601 ScMarkData
& rMark
= GetViewData()->GetMarkData();
2602 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
2603 pTabViewShell
->MarkDataArea( false );
2605 // output to cursor position for non-sheet data
2606 ScAddress
aDestPos( pData
->GetCurX(), pData
->GetCurY(),
2607 pData
->GetTabNo() );
2609 // first select type of source data
2611 bool bEnableExt
= ScDPObject::HasRegisteredSources();
2613 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2614 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2616 ::boost::scoped_ptr
<AbstractScDataPilotSourceTypeDlg
> pTypeDlg(
2617 pFact
->CreateScDataPilotSourceTypeDlg(
2618 pTabViewShell
->GetDialogParent(), bEnableExt
));
2620 // Populate named ranges (if any).
2621 ScRangeName
* pRangeName
= pDoc
->GetRangeName();
2624 ScRangeName::const_iterator itr
= pRangeName
->begin(), itrEnd
= pRangeName
->end();
2625 for (; itr
!= itrEnd
; ++itr
)
2626 pTypeDlg
->AppendNamedRange(itr
->second
->GetName());
2629 OSL_ENSURE(pTypeDlg
, "Dialog create fail!");
2630 if ( pTypeDlg
->Execute() == RET_OK
)
2632 if ( pTypeDlg
->IsExternal() )
2634 uno::Sequence
<OUString
> aSources
= ScDPObject::GetRegisteredSources();
2635 ::boost::scoped_ptr
<AbstractScDataPilotServiceDlg
> pServDlg(
2636 pFact
->CreateScDataPilotServiceDlg(
2637 pTabViewShell
->GetDialogParent(), aSources
, RID_SCDLG_DAPISERVICE
));
2639 OSL_ENSURE(pServDlg
, "Dialog create fail!");
2640 if ( pServDlg
->Execute() == RET_OK
)
2642 ScDPServiceDesc
aServDesc(
2643 pServDlg
->GetServiceName(),
2644 pServDlg
->GetParSource(),
2645 pServDlg
->GetParName(),
2646 pServDlg
->GetParUser(),
2647 pServDlg
->GetParPass() );
2648 pNewDPObject
.reset(new ScDPObject(pDoc
));
2649 pNewDPObject
->SetServiceData( aServDesc
);
2652 else if ( pTypeDlg
->IsDatabase() )
2654 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2656 ::boost::scoped_ptr
<AbstractScDataPilotDatabaseDlg
> pDataDlg(
2657 pFact
->CreateScDataPilotDatabaseDlg(
2658 pTabViewShell
->GetDialogParent()));
2660 OSL_ENSURE(pDataDlg
, "Dialog create fail!");
2661 if ( pDataDlg
->Execute() == RET_OK
)
2663 ScImportSourceDesc
aImpDesc(pDoc
);
2664 pDataDlg
->GetValues( aImpDesc
);
2665 pNewDPObject
.reset(new ScDPObject(pDoc
));
2666 pNewDPObject
->SetImportDesc( aImpDesc
);
2669 else if (pTypeDlg
->IsNamedRange())
2671 OUString aName
= pTypeDlg
->GetSelectedNamedRange();
2672 ScSheetSourceDesc
aShtDesc(pDoc
);
2673 aShtDesc
.SetRangeName(aName
);
2674 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2677 pNewDPObject
.reset(new ScDPObject(pDoc
));
2678 pNewDPObject
->SetSheetDesc(aShtDesc
);
2683 //! use database ranges (select before type dialog?)
2685 ScMarkType eType
= GetViewData()->GetSimpleArea(aRange
);
2686 if ( (eType
& SC_MARK_SIMPLE
) == SC_MARK_SIMPLE
)
2688 // Shrink the range to the data area.
2689 SCCOL nStartCol
= aRange
.aStart
.Col(), nEndCol
= aRange
.aEnd
.Col();
2690 SCROW nStartRow
= aRange
.aStart
.Row(), nEndRow
= aRange
.aEnd
.Row();
2691 if (pDoc
->ShrinkToDataArea(aRange
.aStart
.Tab(), nStartCol
, nStartRow
, nEndCol
, nEndRow
))
2693 aRange
.aStart
.SetCol(nStartCol
);
2694 aRange
.aStart
.SetRow(nStartRow
);
2695 aRange
.aEnd
.SetCol(nEndCol
);
2696 aRange
.aEnd
.SetRow(nEndRow
);
2697 rMark
.SetMarkArea(aRange
);
2698 pTabViewShell
->MarkRange(aRange
);
2702 if ( pDoc
->HasSubTotalCells( aRange
) )
2704 // confirm selection if it contains SubTotal cells
2706 ScopedVclPtrInstance
<QueryBox
> aBox( pTabViewShell
->GetDialogParent(),
2707 WinBits(WB_YES_NO
| WB_DEF_YES
),
2708 ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL
) );
2709 if (aBox
->Execute() == RET_NO
)
2714 ScSheetSourceDesc
aShtDesc(pDoc
);
2715 aShtDesc
.SetSourceRange(aRange
);
2716 nSrcErrorId
= aShtDesc
.CheckSourceRange();
2719 pNewDPObject
.reset(new ScDPObject(pDoc
));
2720 pNewDPObject
->SetSheetDesc( aShtDesc
);
2723 // output below source data
2724 if ( aRange
.aEnd
.Row()+2 <= MAXROW
- 4 )
2725 aDestPos
= ScAddress( aRange
.aStart
.Col(),
2726 aRange
.aEnd
.Row()+2,
2727 aRange
.aStart
.Tab() );
2735 // Error occurred during data creation. Launch an error and bail out.
2736 ScopedVclPtrInstance
< InfoBox
> aBox(pTabViewShell
->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId
));
2742 pNewDPObject
->SetOutRange( aDestPos
);
2745 pTabViewShell
->SetDialogDPObject( pNewDPObject
.get() ); // is copied
2748 // start layout dialog
2750 sal_uInt16 nId
= ScPivotLayoutWrapper::GetChildWindowId();
2751 SfxViewFrame
* pViewFrm
= pTabViewShell
->GetViewFrame();
2752 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
2753 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
2757 void ScCellShell::ExecuteXMLSourceDialog()
2759 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2763 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2767 ScModule
* pScMod
= SC_MOD();
2769 sal_uInt16 nId
= ScXMLSourceDlgWrapper::GetChildWindowId();
2770 SfxViewFrame
* pViewFrame
= pTabViewShell
->GetViewFrame();
2771 SfxChildWindow
* pWnd
= pViewFrame
->GetChildWindow(nId
);
2772 pScMod
->SetRefDialog(nId
, pWnd
== nullptr);
2775 void ScCellShell::ExecuteSubtotals(SfxRequest
& rReq
)
2777 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2778 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2781 pTabViewShell
->DoSubTotals( static_cast<const ScSubTotalItem
&>( pArgs
->Get( SCITEM_SUBTDATA
)).
2782 GetSubTotalData() );
2787 boost::scoped_ptr
<SfxAbstractTabDialog
> pDlg
;
2788 ScSubTotalParam aSubTotalParam
;
2789 SfxItemSet
aArgSet( GetPool(), SCITEM_SUBTDATA
, SCITEM_SUBTDATA
);
2791 // Only get existing named database range.
2792 ScDBData
* pDBData
= pTabViewShell
->GetDBData(true, SC_DB_OLD
);
2795 // No existing DB data at this position. Create an
2797 pDBData
= pTabViewShell
->GetAnonymousDBData();
2799 pDBData
->GetArea(aDataRange
);
2800 pTabViewShell
->MarkRange(aDataRange
, false);
2803 pDBData
->GetSubTotalParam( aSubTotalParam
);
2804 aSubTotalParam
.bRemoveOnly
= false;
2806 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
, GetViewData(), &aSubTotalParam
) );
2807 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2808 assert(pFact
); //"ScAbstractFactory create fail
2810 pDlg
.reset(pFact
->CreateScSubTotalDlg(pTabViewShell
->GetDialogParent(), &aArgSet
));
2811 assert(pDlg
); // "Dialog create fail
2812 pDlg
->SetCurPageId(1);
2814 short bResult
= pDlg
->Execute();
2816 if ( (bResult
== RET_OK
) || (bResult
== SCRET_REMOVE
) )
2818 const SfxItemSet
* pOutSet
= NULL
;
2820 if ( bResult
== RET_OK
)
2822 pOutSet
= pDlg
->GetOutputItemSet();
2824 static_cast<const ScSubTotalItem
&>(
2825 pOutSet
->Get( SCITEM_SUBTDATA
)).
2828 else // if (bResult == SCRET_REMOVE)
2831 aSubTotalParam
.bRemoveOnly
= true;
2832 aSubTotalParam
.bReplace
= true;
2833 aArgSet
.Put( ScSubTotalItem( SCITEM_SUBTDATA
,
2835 &aSubTotalParam
) );
2838 pTabViewShell
->DoSubTotals( aSubTotalParam
);
2839 rReq
.Done( *pOutSet
);
2842 GetViewData()->GetDocShell()->CancelAutoDBRange();
2845 void ScCellShell::ExecuteFillSingleEdit()
2847 ScAddress aCurPos
= GetViewData()->GetCurPos();
2851 if (aCurPos
.Row() > 0)
2853 // Get the initial text value from the above cell.
2855 ScDocument
* pDoc
= GetViewData()->GetDocument();
2856 ScRefCellValue aCell
;
2857 ScAddress aPrevPos
= aCurPos
;
2858 aPrevPos
.IncRow(-1);
2859 aCell
.assign(*pDoc
, aPrevPos
);
2861 if (aCell
.meType
== CELLTYPE_FORMULA
)
2864 const ScTokenArray
* pCode
= aCell
.mpFormula
->GetCode();
2865 sc::TokenStringContext
aCxt(pDoc
, pDoc
->GetGrammar());
2866 aInit
+= pCode
->CreateString(aCxt
, aCurPos
);
2869 aInit
= aCell
.getString(pDoc
);
2872 SC_MOD()->SetInputMode(SC_INPUT_TABLE
, &aInit
);
2875 IMPL_LINK_NOARG(ScCellShell
, DialogClosed
)
2877 assert(pImpl
->m_pLinkedDlg
&& "ScCellShell::DialogClosed(): invalid request");
2878 assert(pImpl
->m_pRequest
&& "ScCellShell::DialogClosed(): invalid request");
2879 OUString sFile
, sFilter
, sOptions
, sSource
;
2880 sal_uLong nRefresh
= 0;
2882 if ( pImpl
->m_pLinkedDlg
->GetResult() == RET_OK
)
2884 sFile
= pImpl
->m_pLinkedDlg
->GetURL();
2885 sFilter
= pImpl
->m_pLinkedDlg
->GetFilter();
2886 sOptions
= pImpl
->m_pLinkedDlg
->GetOptions();
2887 sSource
= pImpl
->m_pLinkedDlg
->GetSource();
2888 nRefresh
= pImpl
->m_pLinkedDlg
->GetRefresh();
2889 if ( !sFile
.isEmpty() )
2890 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_NAME
, sFile
) );
2891 if ( !sFilter
.isEmpty() )
2892 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILTER_NAME
, sFilter
) );
2893 if ( !sOptions
.isEmpty() )
2894 pImpl
->m_pRequest
->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS
, sOptions
) );
2895 if ( !sSource
.isEmpty() )
2896 pImpl
->m_pRequest
->AppendItem( SfxStringItem( FN_PARAM_1
, sSource
) );
2898 pImpl
->m_pRequest
->AppendItem( SfxUInt32Item( FN_PARAM_2
, nRefresh
) );
2901 ExecuteExternalSource( sFile
, sFilter
, sOptions
, sSource
, nRefresh
, *(pImpl
->m_pRequest
) );
2905 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */