summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/auditsh.cxx157
-rw-r--r--sc/source/ui/view/cellmergeoption.cxx90
-rw-r--r--sc/source/ui/view/cellsh.cxx985
-rw-r--r--sc/source/ui/view/cellsh1.cxx2485
-rw-r--r--sc/source/ui/view/cellsh2.cxx1192
-rw-r--r--sc/source/ui/view/cellsh3.cxx923
-rw-r--r--sc/source/ui/view/cellsh4.cxx456
-rw-r--r--sc/source/ui/view/colrowba.cxx416
-rw-r--r--sc/source/ui/view/dbfunc.cxx538
-rw-r--r--sc/source/ui/view/dbfunc2.cxx79
-rw-r--r--sc/source/ui/view/dbfunc3.cxx2334
-rw-r--r--sc/source/ui/view/dbfunc4.cxx103
-rw-r--r--sc/source/ui/view/drawattr.cxx84
-rw-r--r--sc/source/ui/view/drawutil.cxx118
-rw-r--r--sc/source/ui/view/drawvie2.cxx64
-rw-r--r--sc/source/ui/view/drawvie3.cxx214
-rw-r--r--sc/source/ui/view/drawvie4.cxx357
-rw-r--r--sc/source/ui/view/drawview.cxx753
-rw-r--r--sc/source/ui/view/editsh.cxx1203
-rw-r--r--sc/source/ui/view/formatsh.cxx2242
-rw-r--r--sc/source/ui/view/galwrap.cxx81
-rw-r--r--sc/source/ui/view/gridmerg.cxx176
-rw-r--r--sc/source/ui/view/gridwin.cxx5742
-rw-r--r--sc/source/ui/view/gridwin2.cxx1066
-rw-r--r--sc/source/ui/view/gridwin3.cxx400
-rw-r--r--sc/source/ui/view/gridwin4.cxx1749
-rw-r--r--sc/source/ui/view/gridwin5.cxx440
-rw-r--r--sc/source/ui/view/hdrcont.cxx1027
-rw-r--r--sc/source/ui/view/hintwin.cxx111
-rw-r--r--sc/source/ui/view/imapwrap.cxx78
-rw-r--r--sc/source/ui/view/invmerge.cxx194
-rw-r--r--sc/source/ui/view/notemark.cxx202
-rw-r--r--sc/source/ui/view/olinewin.cxx1045
-rw-r--r--sc/source/ui/view/olkact.cxx217
-rw-r--r--sc/source/ui/view/output.cxx2373
-rw-r--r--sc/source/ui/view/output2.cxx4766
-rw-r--r--sc/source/ui/view/output3.cxx274
-rw-r--r--sc/source/ui/view/overlayobject.cxx104
-rw-r--r--sc/source/ui/view/pfuncache.cxx200
-rw-r--r--sc/source/ui/view/pgbrksh.cxx87
-rw-r--r--sc/source/ui/view/pivotsh.cxx202
-rw-r--r--sc/source/ui/view/preview.cxx1612
-rw-r--r--sc/source/ui/view/prevloc.cxx751
-rw-r--r--sc/source/ui/view/prevwsh.cxx1136
-rw-r--r--sc/source/ui/view/prevwsh2.cxx222
-rw-r--r--sc/source/ui/view/printfun.cxx3176
-rw-r--r--sc/source/ui/view/reffact.cxx402
-rw-r--r--sc/source/ui/view/scextopt.cxx227
-rw-r--r--sc/source/ui/view/select.cxx965
-rw-r--r--sc/source/ui/view/selectionstate.cxx91
-rw-r--r--sc/source/ui/view/spelldialog.cxx281
-rw-r--r--sc/source/ui/view/spelleng.cxx460
-rw-r--r--sc/source/ui/view/tabcont.cxx647
-rw-r--r--sc/source/ui/view/tabpopsh.cxx75
-rw-r--r--sc/source/ui/view/tabsplit.cxx107
-rw-r--r--sc/source/ui/view/tabview.cxx2447
-rw-r--r--sc/source/ui/view/tabview2.cxx1470
-rw-r--r--sc/source/ui/view/tabview3.cxx2540
-rw-r--r--sc/source/ui/view/tabview4.cxx565
-rw-r--r--sc/source/ui/view/tabview5.cxx676
-rw-r--r--sc/source/ui/view/tabvwsh.cxx112
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx482
-rw-r--r--sc/source/ui/view/tabvwsh3.cxx1160
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx1891
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx428
-rw-r--r--sc/source/ui/view/tabvwsh8.cxx105
-rw-r--r--sc/source/ui/view/tabvwsh9.cxx282
-rw-r--r--sc/source/ui/view/tabvwsha.cxx805
-rw-r--r--sc/source/ui/view/tabvwshb.cxx577
-rw-r--r--sc/source/ui/view/tabvwshc.cxx344
-rw-r--r--sc/source/ui/view/tabvwshd.cxx102
-rw-r--r--sc/source/ui/view/tabvwshe.cxx345
-rw-r--r--sc/source/ui/view/tabvwshf.cxx978
-rw-r--r--sc/source/ui/view/tabvwshg.cxx137
-rw-r--r--sc/source/ui/view/tabvwshh.cxx295
-rw-r--r--sc/source/ui/view/viewdata.cxx3096
-rw-r--r--sc/source/ui/view/viewfun2.cxx3093
-rw-r--r--sc/source/ui/view/viewfun3.cxx1955
-rw-r--r--sc/source/ui/view/viewfun4.cxx827
-rw-r--r--sc/source/ui/view/viewfun5.cxx737
-rw-r--r--sc/source/ui/view/viewfun6.cxx375
-rw-r--r--sc/source/ui/view/viewfun7.cxx491
-rw-r--r--sc/source/ui/view/viewfunc.cxx3046
-rw-r--r--sc/source/ui/view/viewutil.cxx473
-rw-r--r--sc/source/ui/view/waitoff.cxx72
85 files changed, 75385 insertions, 0 deletions
diff --git a/sc/source/ui/view/auditsh.cxx b/sc/source/ui/view/auditsh.cxx
new file mode 100644
index 000000000000..b35be06c4e5a
--- /dev/null
+++ b/sc/source/ui/view/auditsh.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+
+#include "auditsh.hxx"
+#include "tabvwsh.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "document.hxx"
+
+//------------------------------------------------------------------------
+
+#define ScAuditingShell
+#include "scslots.hxx"
+
+//------------------------------------------------------------------------
+
+TYPEINIT1( ScAuditingShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) );
+}
+
+
+//------------------------------------------------------------------------
+
+ScAuditingShell::ScAuditingShell(ScViewData* pData) :
+ SfxShell(pData->GetViewShell()),
+ pViewData( pData ),
+ nFunction( SID_FILL_ADD_PRED )
+{
+ SetPool( &pViewData->GetViewShell()->GetPool() );
+ ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId( HID_SCSHELL_AUDIT );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing")));
+}
+
+//------------------------------------------------------------------------
+
+ScAuditingShell::~ScAuditingShell()
+{
+}
+
+//------------------------------------------------------------------------
+
+void ScAuditingShell::Execute( SfxRequest& rReq )
+{
+ SfxBindings& rBindings = pViewData->GetBindings();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_FILL_ADD_PRED:
+ case SID_FILL_DEL_PRED:
+ case SID_FILL_ADD_SUCC:
+ case SID_FILL_DEL_SUCC:
+ nFunction = nSlot;
+ rBindings.Invalidate( SID_FILL_ADD_PRED );
+ rBindings.Invalidate( SID_FILL_DEL_PRED );
+ rBindings.Invalidate( SID_FILL_ADD_SUCC );
+ rBindings.Invalidate( SID_FILL_DEL_SUCC );
+ break;
+ case SID_CANCEL: // Escape
+ case SID_FILL_NONE:
+ pViewData->GetViewShell()->SetAuditShell( false );
+ break;
+
+ case SID_FILL_SELECT:
+ {
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pXItem;
+ const SfxPoolItem* pYItem;
+ if ( pReqArgs->GetItemState( SID_RANGE_COL, sal_True, &pXItem ) == SFX_ITEM_SET
+ && pReqArgs->GetItemState( SID_RANGE_ROW, sal_True, &pYItem ) == SFX_ITEM_SET )
+ {
+ DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt32Item),
+ "falsche Items" );
+ SCsCOL nCol = static_cast<SCsCOL>(((const SfxInt16Item*) pXItem)->GetValue());
+ SCsROW nRow = static_cast<SCsROW>(((const SfxInt32Item*) pYItem)->GetValue());
+ ScViewFunc* pView = pViewData->GetView();
+ pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, false, false );
+ switch ( nFunction )
+ {
+ case SID_FILL_ADD_PRED:
+ pView->DetectiveAddPred();
+ break;
+ case SID_FILL_DEL_PRED:
+ pView->DetectiveDelPred();
+ break;
+ case SID_FILL_ADD_SUCC:
+ pView->DetectiveAddSucc();
+ break;
+ case SID_FILL_DEL_SUCC:
+ pView->DetectiveDelSucc();
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAuditingShell::GetState( SfxItemSet& rSet )
+{
+ rSet.Put( SfxBoolItem( nFunction, sal_True ) ); // aktive Funktion markieren
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellmergeoption.cxx b/sc/source/ui/view/cellmergeoption.cxx
new file mode 100644
index 000000000000..52dfc5d4aea1
--- /dev/null
+++ b/sc/source/ui/view/cellmergeoption.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * [ Kohei Yoshida <kyoshida@novell.com> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "cellmergeoption.hxx"
+#include "address.hxx"
+
+ScCellMergeOption::ScCellMergeOption() :
+ mnStartCol(0),
+ mnStartRow(0),
+ mnEndCol(0),
+ mnEndRow(0),
+ mbCenter(false)
+{
+}
+
+ScCellMergeOption::ScCellMergeOption(const ScRange& rRange) :
+ mnStartCol(rRange.aStart.Col()),
+ mnStartRow(rRange.aStart.Row()),
+ mnEndCol(rRange.aEnd.Col()),
+ mnEndRow(rRange.aEnd.Row()),
+ mbCenter(false)
+{
+ SCTAB nTab1 = rRange.aStart.Tab();
+ SCTAB nTab2 = rRange.aEnd.Tab();
+ for (SCTAB i = nTab1; i <= nTab2; ++i)
+ maTabs.insert(i);
+}
+
+ScCellMergeOption::ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bCenter) :
+ mnStartCol(nStartCol),
+ mnStartRow(nStartRow),
+ mnEndCol(nEndCol),
+ mnEndRow(nEndRow),
+ mbCenter(bCenter)
+{
+}
+
+ScCellMergeOption::ScCellMergeOption(const ScCellMergeOption& r) :
+ maTabs(r.maTabs),
+ mnStartCol(r.mnStartCol),
+ mnStartRow(r.mnStartRow),
+ mnEndCol(r.mnEndCol),
+ mnEndRow(r.mnEndRow),
+ mbCenter(r.mbCenter)
+{
+}
+
+ScRange ScCellMergeOption::getSingleRange(SCTAB nTab) const
+{
+ return ScRange(mnStartCol, mnStartRow, nTab, mnEndCol, mnEndRow, nTab);
+}
+
+ScRange ScCellMergeOption::getFirstSingleRange() const
+{
+ SCTAB nTab = 0;
+ if (!maTabs.empty())
+ nTab = *maTabs.begin();
+
+ return getSingleRange(nTab);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
new file mode 100644
index 000000000000..209fff0eae38
--- /dev/null
+++ b/sc/source/ui/view/cellsh.cxx
@@ -0,0 +1,985 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svtools/insdlg.hxx>
+#include <sot/formats.hxx>
+#include <svx/hlnkitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <editeng/langitem.hxx>
+
+#include "cellsh.hxx"
+#include "sc.hrc"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "globstr.hrc"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "scabstdlg.hxx"
+#include "dociter.hxx"
+#include "postit.hxx"
+
+//------------------------------------------------------------------
+
+#define ScCellShell
+#define CellMovement
+#include "scslots.hxx"
+
+TYPEINIT1( ScCellShell, ScFormatShell );
+
+SFX_IMPL_INTERFACE(ScCellShell, ScFormatShell , ScResId(SCSTR_CELLSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_FORMAT));
+ SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_CELLS));
+}
+
+
+ScCellShell::ScCellShell(ScViewData* pData) :
+ ScFormatShell(pData),
+ pImpl( new CellShell_Impl() ),
+ bPastePossible(false)
+{
+ SetHelpId(HID_SCSHELL_CELLSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Cell")));
+}
+
+ScCellShell::~ScCellShell()
+{
+ if ( pImpl->m_pClipEvtLstnr )
+ {
+ pImpl->m_pClipEvtLstnr->AddRemoveListener( GetViewData()->GetActiveWin(), false );
+
+ // The listener may just now be waiting for the SolarMutex and call the link
+ // afterwards, in spite of RemoveListener. So the link has to be reset, too.
+ pImpl->m_pClipEvtLstnr->ClearCallbackLink();
+
+ pImpl->m_pClipEvtLstnr->release();
+ }
+
+ delete pImpl->m_pLinkedDlg;
+ delete pImpl->m_pRequest;
+ delete pImpl;
+}
+
+//------------------------------------------------------------------
+
+void ScCellShell::GetBlockState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScRange aMarkRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange );
+ sal_Bool bSimpleArea = (eMarkType == SC_MARK_SIMPLE);
+ sal_Bool bOnlyNotBecauseOfMatrix;
+ sal_Bool bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix );
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ nCol1 = aMarkRange.aStart.Col();
+ nRow1 = aMarkRange.aStart.Row();
+ nCol2 = aMarkRange.aEnd.Col();
+ nRow2 = aMarkRange.aEnd.Row();
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ sal_Bool bDisable = false;
+ sal_Bool bNeedEdit = sal_True; // muss Selektion editierbar sein?
+ switch ( nWhich )
+ {
+ case FID_FILL_TO_BOTTOM: // Fuellen oben/unten
+ case FID_FILL_TO_TOP: // mind. 2 Zeilen markiert?
+ bDisable = (!bSimpleArea) || (nRow1 == nRow2);
+ if ( !bDisable && bEditable )
+ { // Matrix nicht zerreissen
+ if ( nWhich == FID_FILL_TO_BOTTOM )
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol2, nRow1, rMark ); // erste Zeile
+ else
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow2, nCol2, nRow2, rMark ); // letzte Zeile
+ }
+ break;
+
+ case FID_FILL_TO_RIGHT: // Fuellen links/rechts
+ case FID_FILL_TO_LEFT: // mind. 2 Spalten markiert?
+ bDisable = (!bSimpleArea) || (nCol1 == nCol2);
+ if ( !bDisable && bEditable )
+ { // Matrix nicht zerreissen
+ if ( nWhich == FID_FILL_TO_RIGHT )
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol1, nRow2, rMark ); // erste Spalte
+ else
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte
+ }
+ break;
+
+ case FID_FILL_SERIES: // Block fuellen
+ case SID_OPENDLG_TABOP: // Mehrfachoperationen, mind. 2 Zellen markiert?
+ if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP)
+ bDisable = sal_True;
+ else
+ bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2);
+
+ if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES )
+ { // Matrix nicht zerreissen
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol2, nRow1, rMark ) // erste Zeile
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow2, nCol2, nRow2, rMark ) // letzte Zeile
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol1, nRow2, rMark ) // erste Spalte
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte
+ }
+ break;
+
+ case SID_CUT: // Ausschneiden,
+ case FID_INS_CELL: // Zellen einfuegen, nur einf. Selektion
+ bDisable = (!bSimpleArea);
+ break;
+
+ case FID_INS_ROW: // insert rows
+ case FID_INS_CELLSDOWN:
+ bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked();
+ break;
+
+ case FID_INS_COLUMN: // insert columns
+ case FID_INS_CELLSRIGHT:
+ bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked();
+ break;
+
+ case SID_COPY: // Kopieren
+ // nur wegen Matrix nicht editierbar? Matrix nicht zerreissen
+ //! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit
+ //! muss man leben.. wird in Copy-Routine abgefangen, sonst
+ //! muesste hier nochmal Aufwand getrieben werden
+ if ( !(!bEditable && bOnlyNotBecauseOfMatrix) )
+ bNeedEdit = false; // erlaubt, wenn geschuetzt/ReadOnly
+ break;
+
+ case SID_AUTOFORMAT: // Autoformat, mind. 3x3 selektiert
+ bDisable = (!bSimpleArea)
+ || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2);
+ break;
+
+ case SID_OPENDLG_CONDFRMT :
+ {
+ if ( !bEditable && bOnlyNotBecauseOfMatrix )
+ {
+ bNeedEdit = false;
+ }
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = sal_True;
+ }
+ }
+ break;
+
+ case FID_CONDITIONAL_FORMAT :
+ case SID_CELL_FORMAT_RESET :
+ case FID_CELL_FORMAT :
+ case SID_ENABLE_HYPHENATION :
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ if ( !bEditable && bOnlyNotBecauseOfMatrix )
+ bNeedEdit = false;
+ break;
+
+ case FID_VALIDATION:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = sal_True;
+ }
+ }
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ ScViewUtil::HideDisabledSlot( rSet, GetViewData()->GetBindings(), nWhich );
+ break;
+ }
+ if (!bDisable && bNeedEdit && !bEditable)
+ bDisable = sal_True;
+
+ if (bDisable)
+ rSet.DisableItem(nWhich);
+ else if (nWhich == SID_ENABLE_HYPHENATION)
+ {
+ // toggle slots need a bool item
+ rSet.Put( SfxBoolItem( nWhich, false ) );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Funktionen, die je nach Cursorposition disabled sind
+// Default:
+// SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION
+
+void ScCellShell::GetCellState( SfxItemSet& rSet )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
+ ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ sal_Bool bDisable = false;
+ sal_Bool bNeedEdit = sal_True; // muss Cursorposition editierbar sein?
+ switch ( nWhich )
+ {
+ case SID_THESAURUS:
+ {
+ CellType eType = pDoc->GetCellType( aCursor );
+ bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT);
+ if (!bDisable)
+ {
+ // test for available languages
+ sal_uInt16 nLang = ScViewUtil::GetEffLanguage( pDoc, aCursor );
+ bDisable = !ScModule::HasThesaurusLanguage( nLang );
+ }
+ }
+ break;
+ case SID_OPENDLG_FUNCTION:
+ {
+ ScMarkData aMarkData=GetViewData()->GetMarkData();
+ aMarkData.MarkToSimple();
+ ScRange aRange;
+ aMarkData.GetMarkArea(aRange);
+ if(aMarkData.IsMarked())
+ {
+ if (!pDoc->IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(),
+ aRange.aEnd.Col(),aRange.aEnd.Row() ))
+ {
+ bDisable = sal_True;
+ }
+ bNeedEdit=false;
+ }
+
+ }
+ break;
+ case SID_INSERT_POSTIT:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = sal_True;
+ }
+ }
+ break;
+ }
+ if (!bDisable && bNeedEdit)
+ if (!pDoc->IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(),
+ aCursor.Col(),aCursor.Row() ))
+ bDisable = sal_True;
+ if (bDisable)
+ rSet.DisableItem(nWhich);
+ nWhich = aIter.NextWhich();
+ }
+}
+
+sal_Bool lcl_TestFormat( SvxClipboardFmtItem& rFormats, const TransferableDataHelper& rDataHelper,
+ SotFormatStringId nFormatId )
+{
+ if ( rDataHelper.HasFormat( nFormatId ) )
+ {
+ // translated format name strings are no longer inserted here,
+ // handled by "paste special" dialog / toolbox controller instead.
+ // Only the object type name has to be set here:
+ String aStrVal;
+ if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ {
+ TransferableObjectDescriptor aDesc;
+ if ( ((TransferableDataHelper&)rDataHelper).GetTransferableObjectDescriptor(
+ SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc ) )
+ aStrVal = aDesc.maTypeName;
+ }
+ else if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
+ || nFormatId == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
+ {
+ String aSource;
+ SvPasteObjectHelper::GetEmbeddedName( rDataHelper, aStrVal, aSource, nFormatId );
+ }
+
+ if ( aStrVal.Len() )
+ rFormats.AddClipbrdFormat( nFormatId, aStrVal );
+ else
+ rFormats.AddClipbrdFormat( nFormatId );
+
+ return sal_True;
+ }
+
+ return false;
+}
+
+void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats )
+{
+ Window* pWin = GetViewData()->GetActiveWin();
+ sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DRAWING );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_SVXB );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_GDIMETAFILE );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_BITMAP );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ if ( !bDraw )
+ {
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_LINK );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_STRING );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DIF );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_RTF );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML_SIMPLE );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_8 );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_5 );
+ }
+
+ if ( !lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) )
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
+}
+
+// Einfuegen, Inhalte einfuegen
+
+sal_Bool lcl_IsCellPastePossible( const TransferableDataHelper& rData )
+{
+ sal_Bool bPossible = false;
+ if ( ScTransferObj::GetOwnClipboard( NULL ) || ScDrawTransferObj::GetOwnClipboard( NULL ) )
+ bPossible = sal_True;
+ else
+ {
+ if ( rData.HasFormat( SOT_FORMAT_BITMAP ) ||
+ rData.HasFormat( SOT_FORMAT_GDIMETAFILE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
+ rData.HasFormat( FORMAT_PRIVATE ) ||
+ rData.HasFormat( SOT_FORMAT_RTF ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
+ rData.HasFormat( SOT_FORMAT_STRING ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_HTML ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_DIF ) )
+ {
+ bPossible = sal_True;
+ }
+ }
+ return bPossible;
+}
+
+IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+
+void ScCellShell::GetClipState( SfxItemSet& rSet )
+{
+// SID_PASTE
+// SID_PASTE_SPECIAL
+// SID_CLIPBOARD_FORMAT_ITEMS
+
+ if ( !pImpl->m_pClipEvtLstnr )
+ {
+ // create listener
+ pImpl->m_pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) );
+ pImpl->m_pClipEvtLstnr->acquire();
+ Window* pWin = GetViewData()->GetActiveWin();
+ pImpl->m_pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+ bPastePossible = lcl_IsCellPastePossible( aDataHelper );
+ }
+
+ sal_Bool bDisable = !bPastePossible;
+
+ // Zellschutz / Multiselektion
+
+ if (!bDisable)
+ {
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
+ if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
+ bDisable = sal_True;
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ bDisable = sal_True;
+ }
+
+ if (bDisable)
+ {
+ rSet.DisableItem( SID_PASTE );
+ rSet.DisableItem( SID_PASTE_SPECIAL );
+ rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SFX_ITEM_UNKNOWN )
+ {
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ GetPossibleClipboardFormats( aFormats );
+ rSet.Put( aFormats );
+ }
+}
+
+// only SID_HYPERLINK_GETLINK:
+
+void ScCellShell::GetHLinkState( SfxItemSet& rSet )
+{
+ // always return an item (or inserting will be disabled)
+ // if the cell at the cursor contains only a link, return that link
+
+ SvxHyperlinkItem aHLinkItem;
+ if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
+ {
+ //! put selected text into item?
+ }
+
+ rSet.Put(aHLinkItem);
+}
+
+void ScCellShell::GetState(SfxItemSet &rSet)
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScViewData* pData = GetViewData();
+ ScDocument* pDoc = pData->GetDocument();
+ ScMarkData& rMark = pData->GetMarkData();
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCTAB nTab = pData->GetTabNo();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_DETECTIVE_REFRESH:
+ if (!pDoc->HasDetectiveOperations())
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_RANGE_ADDRESS:
+ {
+ ScRange aRange;
+ if ( pData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ String aStr;
+ sal_uInt16 nFlags = SCA_VALID | SCA_TAB_3D;
+ aRange.Format(aStr,nFlags,pDoc);
+ rSet.Put( SfxStringItem( nWhich, aStr ) );
+ }
+ }
+ break;
+
+ case SID_RANGE_NOTETEXT:
+ {
+ // always take cursor position, do not use top-left cell of selection
+ ScAddress aPos( nPosX, nPosY, nTab );
+ String aNoteText;
+ if ( const ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ aNoteText = pNote->GetText();
+ rSet.Put( SfxStringItem( nWhich, aNoteText ) );
+ }
+ break;
+
+ case SID_RANGE_ROW:
+ rSet.Put( SfxInt32Item( nWhich, nPosY+1 ) );
+ break;
+
+ case SID_RANGE_COL:
+ rSet.Put( SfxInt16Item( nWhich, nPosX+1 ) );
+ break;
+
+ case SID_RANGE_TABLE:
+ rSet.Put( SfxInt16Item( nWhich, nTab+1 ) );
+ break;
+
+ case SID_RANGE_VALUE:
+ {
+ double nValue;
+ pDoc->GetValue( nPosX, nPosY, nTab, nValue );
+ rSet.Put( ScDoubleItem( nWhich, nValue ) );
+ }
+ break;
+
+ case SID_RANGE_FORMULA:
+ {
+ String aString;
+ pDoc->GetFormula( nPosX, nPosY, nTab, aString );
+ if( aString.Len() == 0 )
+ {
+ pDoc->GetInputString( nPosX, nPosY, nTab, aString );
+ }
+ rSet.Put( SfxStringItem( nWhich, aString ) );
+ }
+ break;
+
+ case SID_RANGE_TEXTVALUE:
+ {
+ String aString;
+ pDoc->GetString( nPosX, nPosY, nTab, aString );
+ rSet.Put( SfxStringItem( nWhich, aString ) );
+ }
+ break;
+
+ case SID_STATUS_SELMODE:
+ {
+ /* 0: STD Click hebt Sel auf
+ * 1: ER Click erweitert Selektion
+ * 2: ERG Click definiert weitere Selektion
+ */
+ sal_uInt16 nMode = pTabViewShell->GetLockedModifiers();
+
+ switch ( nMode )
+ {
+ case KEY_SHIFT: nMode = 1; break;
+ case KEY_MOD1: nMode = 2; break; // Control-Taste
+ case 0:
+ default:
+ nMode = 0;
+ }
+
+ rSet.Put( SfxUInt16Item( nWhich, nMode ) );
+ }
+ break;
+
+ case SID_STATUS_DOCPOS:
+ {
+ String aStr( ScGlobal::GetRscString( STR_TABLE ) );
+
+ aStr += ' ';
+ aStr += String::CreateFromInt32( nTab + 1 );
+ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aStr += String::CreateFromInt32( nTabCount );
+ rSet.Put( SfxStringItem( nWhich, aStr ) );
+ }
+ break;
+
+ // Summe etc. mit Datum/Zeit/Fehler/Pos&Groesse zusammengefasst
+
+ // #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be
+ // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
+ case SID_TABLE_CELL:
+ {
+ // Testen, ob Fehler unter Cursor
+ // (nicht pDoc->GetErrCode, um keine zirkulaeren Referenzen auszuloesen)
+
+ // In interpreter may happen via rescheduled Basic
+ if ( pDoc->IsInInterpreter() )
+ rSet.Put( SfxStringItem( nWhich,
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")) ) );
+ else
+ {
+ sal_uInt16 nErrCode = 0;
+ ScBaseCell* pCell;
+ pDoc->GetCell( nPosX, nPosY, nTab, pCell );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
+ if (!pFCell->IsRunning())
+ nErrCode = pFCell->GetErrCode();
+ }
+
+ String aFuncStr;
+ if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
+ rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
+ }
+ }
+ break;
+
+ case SID_DATA_SELECT:
+ // HasSelectionData includes column content and validity,
+ // page fields have to be checked separately.
+ if ( !pDoc->HasSelectionData( nPosX, nPosY, nTab ) &&
+ !pTabViewShell->HasPageFieldDataAtCursor() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_STATUS_SUM:
+ {
+ String aFuncStr;
+ if ( pTabViewShell->GetFunction( aFuncStr ) )
+ rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
+ }
+ break;
+
+ case FID_MERGE_ON:
+ if ( pDoc->GetChangeTrack() || !pTabViewShell->TestMergeCells() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_MERGE_OFF:
+ if ( pDoc->GetChangeTrack() || !pTabViewShell->TestRemoveMerge() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_MERGE_TOGGLE:
+ if ( pDoc->GetChangeTrack() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ bool bCanMerge = pTabViewShell->TestMergeCells();
+ bool bCanSplit = pTabViewShell->TestRemoveMerge();
+ if( !bCanMerge && !bCanSplit )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich, bCanSplit ) );
+ }
+ break;
+
+ case FID_INS_ROWBRK:
+ if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_INS_COLBRK:
+ if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_DEL_ROWBRK:
+ if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_DEL_COLBRK:
+ if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_FILL_TAB:
+ if ( nTabSelCount < 2 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_SELECT_SCENARIO:
+ {
+ List aList;
+
+ Color aDummyCol;
+
+ if ( !pDoc->IsScenario(nTab) )
+ {
+ String aStr;
+ sal_uInt16 nFlags;
+ SCTAB nScTab = nTab + 1;
+ String aProtect;
+ bool bSheetProtected = pDoc->IsTabProtected(nTab);
+
+ while ( pDoc->IsScenario(nScTab) )
+ {
+ pDoc->GetName( nScTab, aStr );
+ aList.Insert( new String( aStr ), LIST_APPEND );
+ pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nFlags );
+ aList.Insert( new String( aStr ), LIST_APPEND );
+ // Protection is sal_True if both Sheet and Scenario are protected
+ aProtect = (bSheetProtected && (nFlags & SC_SCENARIO_PROTECT)) ? '1' : '0';
+ aList.Insert( new String( aProtect), LIST_APPEND );
+ ++nScTab;
+ }
+ }
+ else
+ {
+ String aComment;
+ sal_uInt16 nDummyFlags;
+ pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags );
+ DBG_ASSERT( aList.Count() == 0, "List not empty!" );
+ aList.Insert( new String( aComment ) );
+ }
+
+ rSet.Put( SfxStringListItem( nWhich, &aList ) );
+
+ sal_uLong nCount = aList.Count();
+ for ( sal_uLong i=0; i<nCount; i++ )
+ delete (String*) aList.GetObject(i);
+ }
+ break;
+
+ case FID_ROW_HIDE:
+ case FID_ROW_SHOW:
+ case FID_COL_HIDE:
+ case FID_COL_SHOW:
+ case FID_COL_OPT_WIDTH:
+ case FID_ROW_OPT_HEIGHT:
+ case FID_DELETE_CELL:
+ if ( pDoc->IsTabProtected(nTab) || pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OUTLINE_MAKE:
+ {
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ case SID_OUTLINE_SHOW:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (!pTabViewShell->OutlinePossible(false))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OUTLINE_HIDE:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (!pTabViewShell->OutlinePossible(sal_True))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OUTLINE_REMOVE:
+ {
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else
+ {
+ sal_Bool bCol, bRow;
+ pTabViewShell->TestRemoveOutline( bCol, bRow );
+ if ( !bCol && !bRow )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_COL_WIDTH:
+ {
+ //GetViewData()->GetCurX();
+ SfxUInt16Item aWidthItem( FID_COL_WIDTH, pDoc->GetColWidth( nPosX , nTab) );
+ rSet.Put( aWidthItem );
+ if ( pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+
+ //XXX Disablen wenn nicht eindeutig
+ }
+ break;
+
+ case FID_ROW_HEIGHT:
+ {
+ //GetViewData()->GetCurY();
+ SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, pDoc->GetRowHeight( nPosY , nTab) );
+ rSet.Put( aHeightItem );
+ //XXX Disablen wenn nicht eindeutig
+ if ( pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DETECTIVE_FILLMODE:
+ rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() ));
+ break;
+
+ case FID_INPUTLINE_STATUS:
+ OSL_FAIL( "Old update method. Use ScTabViewShell::UpdateInputHandler()." );
+ break;
+
+ case SID_SCENARIOS: // Szenarios:
+ if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // nur, wenn etwas selektiert
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_NOTE_VISIBLE:
+ {
+ const ScPostIt* pNote = pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
+ rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DELETE_NOTE:
+ {
+ sal_Bool bEnable = false;
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ if ( pDoc->IsSelectionEditable( rMark ) )
+ {
+ // look for at least one note in selection
+ ScRangeList aRanges;
+ rMark.FillRangeListWithMarks( &aRanges, false );
+ size_t nCount = aRanges.size();
+ for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos)
+ {
+ ScCellIterator aCellIter(pDoc, *aRanges[nPos]);
+ for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() )
+ if ( pCell->HasNote() )
+ bEnable = sal_True; // note found
+ }
+ }
+ }
+ else
+ {
+ bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
+ pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ }
+ if ( !bEnable )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_OPENDLG_CONSOLIDATE:
+ case SCITEM_CONSOLIDATEDATA:
+ {
+ if(pDoc->GetChangeTrack()!=NULL)
+ rSet.DisableItem( nWhich);
+ }
+ break;
+
+ case SID_CHINESE_CONVERSION:
+ case SID_HANGUL_HANJA_CONVERSION:
+ ScViewUtil::HideDisabledSlot( rSet, pData->GetBindings(), nWhich );
+ break;
+
+ case FID_USE_NAME:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ ScRange aRange;
+ if ( pData->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_DEFINE_NAME:
+ case FID_INSERT_NAME:
+ case SID_DEFINE_COLROWNAMERANGES:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_SPELL_DIALOG:
+ {
+ if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) )
+ {
+ bool bVisible = false;
+ SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL );
+ if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
+ {
+ SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
+ Window* pWin = ( pChild ? pChild->GetWindow() : NULL );
+ if ( pWin && pWin->IsVisible() )
+ {
+ bVisible = true;
+ }
+ }
+ if ( !bVisible )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ }
+ break;
+
+ } // switch ( nWitch )
+ nWhich = aIter.NextWhich();
+ } // while ( nWitch )
+}
+
+//------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
new file mode 100644
index 000000000000..2e05df32fb0f
--- /dev/null
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -0,0 +1,2485 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+//------------------------------------------------------------------
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SI_NOSBXCONTROLS
+#define _VCONT_HXX
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+
+//------------------------------------------------------------------
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svxdlg.hxx>
+#include <sot/formats.hxx>
+#include <svx/postattr.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <sfx2/passwd.hxx>
+#include <svx/hlnkitem.hxx>
+#include <basic/sbxcore.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/waitobj.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "cellsh.hxx"
+#include "sc.hrc"
+#include "document.hxx"
+#include "patattr.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "reffind.hxx"
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "inputhdl.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "docfunc.hxx"
+#include "editable.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpgroup.hxx" // for ScDPNumGroupInfo
+#include "spellparam.hxx"
+#include "postit.hxx"
+#include "clipparam.hxx"
+#include "pivot.hxx"
+#include "dpobject.hxx"
+#include "dpsdbtab.hxx" // ScImportSourceDesc
+#include "dpshttab.hxx" // ScSheetSourceDesc
+#include "dbcolect.hxx"
+#include "docsh.hxx"
+
+#include "globstr.hrc"
+#include "scui_def.hxx"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "scabstdlg.hxx"
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
+
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+//------------------------------------------------------------------
+void ScCellShell::ExecuteEdit( SfxRequest& rReq )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ // Eingabe beenden
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ switch ( nSlot )
+ {
+ case FID_DEFINE_NAME:
+ case FID_USE_NAME:
+ case FID_INSERT_NAME:
+ case SID_SPELL_DIALOG:
+ case SID_HANGUL_HANJA_CONVERSION:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch ( nSlot )
+ {
+ //
+ // Einfuegen / Loeschen von Zellen / Zeilen / Spalten
+ //
+
+ case FID_INS_ROW:
+ pTabViewShell->InsertCells(INS_INSROWS);
+ rReq.Done();
+ break;
+
+ case FID_INS_COLUMN:
+ pTabViewShell->InsertCells(INS_INSCOLS);
+ rReq.Done();
+ break;
+
+ case FID_INS_CELLSDOWN:
+ pTabViewShell->InsertCells(INS_CELLSDOWN);
+ rReq.Done();
+ break;
+
+ case FID_INS_CELLSRIGHT:
+ pTabViewShell->InsertCells(INS_CELLSRIGHT);
+ rReq.Done();
+ break;
+
+ case SID_DEL_ROWS:
+ pTabViewShell->DeleteCells( DEL_DELROWS );
+ rReq.Done();
+ break;
+
+ case SID_DEL_COLS:
+ pTabViewShell->DeleteCells( DEL_DELCOLS );
+ rReq.Done();
+ break;
+
+ case FID_INS_CELL:
+ {
+ InsCellCmd eCmd=INS_NONE;
+
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags;
+
+ if( IS_AVAILABLE( FID_INS_CELL, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+ if( aFlags.Len() )
+ {
+ switch( aFlags.GetChar(0) )
+ {
+ case 'V': eCmd = INS_CELLSDOWN ;break;
+ case '>': eCmd = INS_CELLSRIGHT ;break;
+ case 'R': eCmd = INS_INSROWS ;break;
+ case 'C': eCmd = INS_INSCOLS ;break;
+ }
+ }
+ }
+ else
+ {
+ if ( GetViewData()->SimpleColMarked() )
+ eCmd = INS_INSCOLS;
+ else if ( GetViewData()->SimpleRowMarked() )
+ eCmd = INS_INSROWS;
+ else
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ sal_Bool bTheFlag=(pDoc->GetChangeTrack()!=NULL);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertCellDlg* pDlg = pFact->CreateScInsertCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_INSCELL, bTheFlag);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if (pDlg->Execute() == RET_OK)
+ eCmd = pDlg->GetInsCellCmd();
+ delete pDlg;
+ }
+ }
+
+ if (eCmd!=INS_NONE)
+ {
+ pTabViewShell->InsertCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aParam;
+
+ switch( eCmd )
+ {
+ case INS_CELLSDOWN: aParam='V'; break;
+ case INS_CELLSRIGHT: aParam='>'; break;
+ case INS_INSROWS: aParam='R'; break;
+ case INS_INSCOLS: aParam='C'; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_DELETE_CELL:
+ {
+ DelCellCmd eCmd = DEL_NONE;
+
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags;
+
+ if( IS_AVAILABLE( FID_DELETE_CELL, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+ if( aFlags.Len() )
+ {
+ switch( aFlags.GetChar(0) )
+ {
+ case 'U': eCmd = DEL_CELLSUP ;break;
+ case 'L': eCmd = DEL_CELLSLEFT ;break;
+ case 'R': eCmd = DEL_DELROWS ;break;
+ case 'C': eCmd = DEL_DELCOLS ;break;
+ }
+ }
+ }
+ else
+ {
+ if ( GetViewData()->SimpleColMarked() )
+ eCmd = DEL_DELCOLS;
+ else if ( GetViewData()->SimpleRowMarked() )
+ eCmd = DEL_DELROWS;
+ else
+ {
+ ScRange aRange;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ sal_Bool bTheFlag=GetViewData()->IsMultiMarked() ||
+ (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) ||
+ (pDoc->GetChangeTrack() != NULL);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDeleteCellDlg* pDlg = pFact->CreateScDeleteCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCELL, bTheFlag );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if (pDlg->Execute() == RET_OK)
+ eCmd = pDlg->GetDelCellCmd();
+ delete pDlg;
+ }
+ }
+
+ if (eCmd != DEL_NONE )
+ {
+ pTabViewShell->DeleteCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aParam;
+
+ switch( eCmd )
+ {
+ case DEL_CELLSUP: aParam='U'; break;
+ case DEL_CELLSLEFT: aParam='L'; break;
+ case DEL_DELROWS: aParam='R'; break;
+ case DEL_DELCOLS: aParam='C'; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Inhalte von Zellen loeschen
+ //
+
+ case SID_DELETE_CONTENTS:
+ pTabViewShell->DeleteContents( IDF_CONTENTS );
+ rReq.Done();
+ break;
+
+ case SID_DELETE:
+ {
+ sal_uInt16 nFlags = IDF_NONE;
+
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( SID_DELETE, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ sal_Bool bCont = sal_True;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = false; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ case 'O': nFlags |= IDF_OBJECTS; break;
+ }
+ }
+ }
+ else
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if (aTester.IsEditable())
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDeleteContentsDlg* pDlg = pFact->CreateScDeleteContentsDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCONT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if ( pDoc->IsTabProtected(nTab) )
+ pDlg->DisableObjects();
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetDelContentsCmdBits();
+ }
+ delete pDlg;
+ }
+ else
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ pTabViewShell->DeleteContents( nFlags );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ if( nFlags & IDF_OBJECTS ) aFlags += 'O';
+ }
+
+ rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Ausfuellen...
+ //
+
+ case FID_FILL_TO_BOTTOM:
+ pTabViewShell->FillSimple( FILL_TO_BOTTOM );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_RIGHT:
+ pTabViewShell->FillSimple( FILL_TO_RIGHT );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_TOP:
+ pTabViewShell->FillSimple( FILL_TO_TOP );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_LEFT:
+ pTabViewShell->FillSimple( FILL_TO_LEFT );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TAB:
+ {
+ sal_uInt16 nFlags = IDF_NONE;
+ sal_uInt16 nFunction = PASTE_NOFUNC;
+ sal_Bool bSkipEmpty = false;
+ sal_Bool bAsLink = false;
+
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( FID_FILL_TAB, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ sal_Bool bCont = sal_True;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = false; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ }
+ }
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_INSCONT, 0, /* nCheckDefaults */
+ &ScGlobal::GetRscString(STR_FILL_TAB));
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetFillMode(true);
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetInsContentsCmdBits();
+ nFunction = pDlg->GetFormulaCmdBits();
+ bSkipEmpty = pDlg->IsSkipEmptyCells();
+ bAsLink = pDlg->IsLink();
+ // MoveMode gibt's bei Tabelle fuellen nicht
+ }
+ delete pDlg;
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ }
+
+ rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_FILL_SERIES:
+ {
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ sal_uInt16 nPossDir = FDS_OPT_NONE;
+ FillDir eFillDir = FILL_TO_BOTTOM;
+ FillCmd eFillCmd = FILL_LINEAR;
+ FillDateCmd eFillDateCmd = FILL_DAY;
+ double fStartVal = MAXDOUBLE;
+ double fIncVal = 1;
+ double fMaxVal = MAXDOUBLE;
+ sal_Bool bDoIt = false;
+
+ GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ if( nStartCol!=nEndCol )
+ {
+ nPossDir |= FDS_OPT_HORZ;
+ eFillDir=FILL_TO_RIGHT;
+ }
+
+ if( nStartRow!=nEndRow )
+ {
+ nPossDir |= FDS_OPT_VERT;
+ eFillDir=FILL_TO_BOTTOM;
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFillDir, aFillCmd, aFillDateCmd;
+ String aFillStep, aFillStart, aFillMax;
+ sal_uInt32 nKey;
+ double fTmpVal;
+
+ bDoIt=false;
+
+ if( IS_AVAILABLE( FID_FILL_SERIES, &pItem ) )
+ aFillDir = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ aFillCmd = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_3, &pItem ) )
+ aFillStep = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_4, &pItem ) )
+ aFillStart = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_5, &pItem ) )
+ aFillMax = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( aFillDir.Len() )
+ switch( aFillDir.GetChar(0) )
+ {
+ case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break;
+ case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break;
+ case 'T': case 't': eFillDir=FILL_TO_TOP; break;
+ case 'L': case 'l': eFillDir=FILL_TO_LEFT; break;
+ }
+
+ if( aFillCmd.Len() )
+ switch( aFillCmd.GetChar(0) )
+ {
+ case 'S': case 's': eFillCmd=FILL_SIMPLE; break;
+ case 'L': case 'l': eFillCmd=FILL_LINEAR; break;
+ case 'G': case 'g': eFillCmd=FILL_GROWTH; break;
+ case 'D': case 'd': eFillCmd=FILL_DATE; break;
+ case 'A': case 'a': eFillCmd=FILL_AUTO; break;
+ }
+
+ if( aFillDateCmd.Len() )
+ switch( aFillDateCmd.GetChar(0) )
+ {
+ case 'D': case 'd': eFillDateCmd=FILL_DAY; break;
+ case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break;
+ case 'M': case 'm': eFillDateCmd=FILL_MONTH; break;
+ case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break;
+ }
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal ))
+ fStartVal = fTmpVal;
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal ))
+ fIncVal = fTmpVal;
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal ))
+ fMaxVal = fTmpVal;
+
+ bDoIt = sal_True;
+
+ }
+ else // (pReqArgs == NULL) => Dialog hochziehen
+ {
+ //
+ sal_uInt32 nPrivFormat;
+ CellType eCellType;
+ pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
+ pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType );
+ const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat );
+ if (!pPrivEntry)
+ {
+ OSL_FAIL("Zahlformat nicht gefunden !!!");
+ }
+ else
+ {
+ short nPrivType = pPrivEntry->GetType();
+ if ( ( nPrivType & NUMBERFORMAT_DATE)>0)
+ {
+ eFillCmd=FILL_DATE;
+ }
+ else if(eCellType==CELLTYPE_STRING)
+ {
+ eFillCmd=FILL_AUTO;
+ }
+ }
+
+ //
+ String aStartStr;
+
+ // Startwert nur vorbelegen, wenn nur 1 Zeile oder Spalte:
+ if ( nStartCol == nEndCol || nStartRow == nEndRow )
+ {
+ double fInputEndVal = 0.0;
+ String aEndStr;
+
+ pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
+ pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
+
+
+ if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
+ {
+ pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
+ if(aEndStr.Len()>0)
+ {
+ pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
+ fIncVal=fInputEndVal-fStartVal;
+ }
+ }
+ else
+ {
+ if(nStartCol < nEndCol)
+ {
+ pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
+ if(aEndStr.Len()>0)
+ {
+ pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
+ fIncVal=fInputEndVal-fStartVal;
+ }
+ }
+ }
+ if(eFillCmd==FILL_DATE)
+ {
+ Date aNullDate = *pDoc->GetFormatTable()->GetNullDate();
+ Date aStartDate = aNullDate;
+ aStartDate+= (long)fStartVal;
+ Date aEndDate = aNullDate;
+ aEndDate+= (long)fInputEndVal;
+ double fTempDate=0;
+
+ if(aStartDate.GetYear()!=aEndDate.GetYear())
+ {
+ eFillDateCmd = FILL_YEAR;
+ fTempDate=aEndDate.GetYear()-aStartDate.GetYear();
+ }
+ if(aStartDate.GetMonth()!=aEndDate.GetMonth())
+ {
+ eFillDateCmd = FILL_MONTH;
+ fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth();
+ }
+ if(aStartDate.GetDay()==aEndDate.GetDay())
+ {
+ fIncVal=fTempDate;
+ }
+ }
+ }
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScFillSeriesDlg* pDlg = pFact->CreateScFillSeriesDlg( pTabViewShell->GetDialogParent(),
+ *pDoc,
+ eFillDir, eFillCmd, eFillDateCmd,
+ aStartStr, fIncVal, fMaxVal,
+ nPossDir,
+ RID_SCDLG_FILLSERIES);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( nStartCol != nEndCol && nStartRow != nEndRow )
+ {
+ pDlg->SetEdStartValEnabled(false);
+ }
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ eFillDir = pDlg->GetFillDir();
+ eFillCmd = pDlg->GetFillCmd();
+ eFillDateCmd = pDlg->GetFillDateCmd();
+
+ if(eFillCmd==FILL_AUTO)
+ {
+ String aStr=pDlg->GetStartStr();
+ if(aStr.Len()>0)
+ pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr );
+ }
+ fStartVal = pDlg->GetStart();
+ fIncVal = pDlg->GetStep();
+ fMaxVal = pDlg->GetMax();
+ bDoIt = sal_True;
+ }
+ delete pDlg;
+ }
+
+ if( bDoIt )
+ {
+ //nScFillModeMouseModifier = 0; // kein Ctrl/Copy
+ pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aPara;
+ Color* pColor=0;
+
+ switch( eFillDir )
+ {
+ case FILL_TO_BOTTOM: aPara = 'B'; break;
+ case FILL_TO_RIGHT: aPara = 'R'; break;
+ case FILL_TO_TOP: aPara = 'T'; break;
+ case FILL_TO_LEFT: aPara = 'L'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) );
+
+ switch( eFillCmd )
+ {
+ case FILL_SIMPLE: aPara = 'S'; break;
+ case FILL_LINEAR: aPara = 'L'; break;
+ case FILL_GROWTH: aPara = 'G'; break;
+ case FILL_DATE: aPara = 'D'; break;
+ case FILL_AUTO: aPara = 'A'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) );
+
+ switch( eFillDateCmd )
+ {
+ case FILL_DAY: aPara = 'D'; break;
+ case FILL_WEEKDAY: aPara = 'W'; break;
+ case FILL_MONTH: aPara = 'M'; break;
+ case FILL_YEAR: aPara = 'Y'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) );
+
+ sal_uLong nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER,
+ ScGlobal::eLnge );
+
+ pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) );
+
+ pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) );
+
+ pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) );
+
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_FILL_AUTO:
+ {
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nStartTab, nEndTab;
+
+ GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
+ SCCOL nFillCol = GetViewData()->GetRefEndX();
+ SCROW nFillRow = GetViewData()->GetRefEndY();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+
+ if( IS_AVAILABLE( FID_FILL_AUTO, &pItem ) )
+ {
+ ScAddress aScAddress;
+ String aArg = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID )
+ {
+ nFillRow = aScAddress.Row();
+ nFillCol = aScAddress.Col();
+ }
+ }
+
+ GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
+ nEndCol,nEndRow,nEndTab );
+ }
+ else // Aufruf per Maus
+ {
+ // nicht innerhalb einer zusammengefassten Zelle
+
+ if ( nStartCol == nEndCol && nStartRow == nEndRow )
+ {
+ SCCOL nMergeCol = nStartCol;
+ SCROW nMergeRow = nStartRow;
+ if ( GetViewData()->GetDocument()->ExtendMerge(
+ nStartCol, nStartRow, nMergeCol, nMergeRow,
+ GetViewData()->GetTabNo() ) )
+ {
+ if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow )
+ nFillCol = nStartCol;
+ if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol )
+ nFillRow = nStartRow;
+ }
+ }
+ }
+
+ if ( nFillCol != nEndCol || nFillRow != nEndRow )
+ {
+ if ( nFillCol==nEndCol || nFillRow==nEndRow )
+ {
+ FillDir eDir = FILL_TO_BOTTOM;
+ SCCOLROW nCount = 0;
+
+ if ( nFillCol==nEndCol )
+ {
+ if ( nFillRow > nEndRow )
+ {
+ eDir = FILL_TO_BOTTOM;
+ nCount = nFillRow - nEndRow;
+ }
+ else if ( nFillRow < nStartRow )
+ {
+ eDir = FILL_TO_TOP;
+ nCount = nStartRow - nFillRow;
+ }
+ }
+ else
+ {
+ if ( nFillCol > nEndCol )
+ {
+ eDir = FILL_TO_RIGHT;
+ nCount = nFillCol - nEndCol;
+ }
+ else if ( nFillCol < nStartCol )
+ {
+ eDir = FILL_TO_LEFT;
+ nCount = nStartCol - nFillCol;
+ }
+ }
+
+ if ( nCount != 0)
+ {
+ pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aAdrStr;
+ ScAddress aAdr( nFillCol, nFillRow, 0 );
+ aAdr.Format( aAdrStr, SCR_ABS, pDoc, pDoc->GetAddressConvention() );
+
+ rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) );
+ rReq.Done();
+ }
+ }
+
+ }
+ else
+ {
+ OSL_FAIL( "Richtung nicht eindeutig fuer AutoFill" );
+ }
+ }
+ }
+ break;
+
+ //
+ // Gliederung (Outlines)
+ // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
+ //
+
+ case SID_OUTLINE_HIDE:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ pTabViewShell->SetDataPilotDetails( false );
+ else
+ pTabViewShell->HideMarkedOutlines();
+ rReq.Done();
+ break;
+
+ case SID_OUTLINE_SHOW:
+ {
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ Sequence<sheet::DataPilotFieldFilter> aFilters;
+ sal_uInt16 nOrientation;
+ if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDPShowDetailDlg* pDlg = pFact->CreateScDPShowDetailDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL, *pDPObj, nOrientation );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ String aNewDimName( pDlg->GetDimensionName() );
+ pTabViewShell->SetDataPilotDetails( sal_True, &aNewDimName );
+ }
+ }
+ else if ( !pDPObj->IsServiceData() &&
+ pDPObj->GetDataFieldPositionData(
+ ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
+ aFilters ) )
+ pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
+ else
+ pTabViewShell->SetDataPilotDetails( sal_True );
+ }
+ else
+ pTabViewShell->ShowMarkedOutlines();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_MAKE:
+ {
+ sal_Bool bColumns = false;
+ sal_Bool bOk = sal_True;
+
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ ScDPNumGroupInfo aNumInfo;
+ aNumInfo.Enable = sal_True;
+ aNumInfo.AutoStart = sal_True;
+ aNumInfo.AutoEnd = sal_True;
+ sal_Int32 nParts = 0;
+ if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
+ Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
+ AbstractScDPDateGroupDlg* pDlg = pFact->CreateScDPDateGroupDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPDATEGROUP,
+ aNumInfo, nParts, aNullDate );
+ DBG_ASSERT( pDlg, "Dialog create fail!" );
+ if( pDlg->Execute() == RET_OK )
+ {
+ aNumInfo = pDlg->GetGroupInfo();
+ pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() );
+ }
+ }
+ else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
+ AbstractScDPNumGroupDlg* pDlg = pFact->CreateScDPNumGroupDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPNUMGROUP, aNumInfo );
+ DBG_ASSERT( pDlg, "Dialog create fail!" );
+ if( pDlg->Execute() == RET_OK )
+ pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() );
+ }
+ else
+ pTabViewShell->GroupDataPilot();
+
+ bOk = false;
+ }
+ else if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ bOk = false;
+
+ if( IS_AVAILABLE( SID_OUTLINE_MAKE, &pItem ) )
+ {
+ String aCol = ((const SfxStringItem*)pItem)->GetValue();
+ aCol.ToUpperAscii();
+
+ switch( aCol.GetChar(0) )
+ {
+ case 'R': bColumns=false; bOk = sal_True;break;
+ case 'C': bColumns=sal_True; bOk = sal_True;break;
+ }
+ }
+ }
+ else // Dialog, wenn nicht ganze Zeilen/Spalten markiert
+ {
+ if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
+ bColumns = sal_True;
+ else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
+ bColumns = false;
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_MAKE, RID_SCDLG_GRP_MAKE,false);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ bColumns = pDlg->GetColsChecked();
+ else
+ bOk = false;
+ delete pDlg;
+ }
+ }
+ if (bOk)
+ {
+ pTabViewShell->MakeOutline( bColumns );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aCol = bColumns ? 'C' : 'R';
+ rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case SID_OUTLINE_REMOVE:
+ {
+ sal_Bool bColumns = false;
+ sal_Bool bOk = sal_True;
+
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ pTabViewShell->UngroupDataPilot();
+ bOk = false;
+ }
+ else if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ bOk = false;
+
+ if( IS_AVAILABLE( SID_OUTLINE_REMOVE, &pItem ) )
+ {
+ String aCol = ((const SfxStringItem*)pItem)->GetValue();
+ aCol.ToUpperAscii();
+
+ switch( aCol.GetChar(0) )
+ {
+ case 'R': bColumns=false; bOk = sal_True;break;
+ case 'C': bColumns=sal_True; bOk = sal_True;break;
+ }
+ }
+ }
+ else // Dialog nur, wenn Aufheben fuer Zeilen und Spalten moeglich
+ {
+ sal_Bool bColPoss, bRowPoss;
+ pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
+ if ( bColPoss && bRowPoss )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_KILL, RID_SCDLG_GRP_KILL,true);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ bColumns = pDlg->GetColsChecked();
+ else
+ bOk = false;
+ delete pDlg;
+ }
+ else if ( bColPoss )
+ bColumns = sal_True;
+ else if ( bRowPoss )
+ bColumns = false;
+ else
+ bOk = false;
+ }
+ if (bOk)
+ {
+ pTabViewShell->RemoveOutline( bColumns );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aCol = bColumns ? 'C' : 'R';
+ rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Clipboard
+ //
+
+
+ case SID_COPY: // fuer Grafiken in DrawShell
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ pTabViewShell->CopyToClip( NULL, false, false, sal_True );
+ rReq.Done();
+ GetViewData()->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) );
+ pTabViewShell->ShowCursor();
+ pTabViewShell->UpdateCopySourceOverlay();
+ }
+ break;
+
+ case SID_CUT: // fuer Grafiken in DrawShell
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ pTabViewShell->CutToClip( NULL, sal_True );
+ rReq.Done();
+ GetViewData()->SetPasteMode( SC_PASTE_MODE );
+ pTabViewShell->UpdateCopySourceOverlay();
+ }
+ break;
+
+ case SID_PASTE:
+ {
+ PasteFromClipboard ( GetViewData(), pTabViewShell, true );
+ rReq.Done();
+ }
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+
+ sal_uLong nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ Window* pWin = GetViewData()->GetActiveWin();
+ sal_Bool bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != NULL );
+ sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+ sal_Bool bOle = ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ if ( bCells && bOle )
+ pTabViewShell->PasteFromSystem();
+ else if ( bDraw && bOle )
+ pTabViewShell->PasteDraw();
+ else
+ pTabViewShell->PasteFromSystem(nFormat);
+ }
+ //?else
+ //? pTabViewShell->PasteFromSystem();
+
+ rReq.Done();
+ }
+ pTabViewShell->CellContentChanged();
+ break;
+
+ case FID_INS_CELL_CONTENTS:
+ {
+ sal_uInt16 nFlags = IDF_NONE;
+ sal_uInt16 nFunction = PASTE_NOFUNC;
+ sal_Bool bSkipEmpty = false;
+ sal_Bool bTranspose = false;
+ sal_Bool bAsLink = false;
+ InsCellCmd eMoveMode = INS_NONE;
+
+ Window* pWin = GetViewData()->GetActiveWin();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ sal_Bool bOtherDoc = !pDoc->IsClipboardSource();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ if ( pOwnClip )
+ {
+ // keep a reference in case the clipboard is changed during dialog or PasteFromClip
+ uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( FID_INS_CELL_CONTENTS, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ sal_Bool bCont = sal_True;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = false; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ }
+ }
+
+ SFX_REQUEST_ARG( rReq, pFuncItem, SfxUInt16Item, FN_PARAM_1, false );
+ SFX_REQUEST_ARG( rReq, pSkipItem, SfxBoolItem, FN_PARAM_2, false );
+ SFX_REQUEST_ARG( rReq, pTransposeItem, SfxBoolItem, FN_PARAM_3, false );
+ SFX_REQUEST_ARG( rReq, pLinkItem, SfxBoolItem, FN_PARAM_4, false );
+ SFX_REQUEST_ARG( rReq, pMoveItem, SfxInt16Item, FN_PARAM_5, false );
+ if ( pFuncItem )
+ nFunction = pFuncItem->GetValue();
+ if ( pSkipItem )
+ bSkipEmpty = pSkipItem->GetValue();
+ if ( pTransposeItem )
+ bTranspose = pTransposeItem->GetValue();
+ if ( pLinkItem )
+ bAsLink = pLinkItem->GetValue();
+ if ( pMoveItem )
+ eMoveMode = (InsCellCmd) pMoveItem->GetValue();
+ }
+ else
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if (aTester.IsEditable())
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_INSCONT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetOtherDoc( bOtherDoc );
+ // bei ChangeTrack MoveMode disablen
+ pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL );
+ // cut/move references may disable shift
+ // directions if source and destination ranges intersect
+ if ( !bOtherDoc )
+ {
+ if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() )
+ {
+ ScViewData* pData = GetViewData();
+ if ( pData->GetMarkData().GetTableSelect(
+ pData->GetTabNo() ) )
+ {
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCCOL nClipStartX, nClipSizeX;
+ SCROW nClipStartY, nClipSizeY;
+ pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
+ // for CutMode, filtered rows can always be included
+ pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, sal_True );
+ int nDisableShift = 0;
+ if ( nClipStartX <= nPosX + nClipSizeX &&
+ nPosX <= nClipStartX + nClipSizeX )
+ nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
+ if ( nClipStartY <= nPosY + nClipSizeY &&
+ nPosY <= nClipStartY + nClipSizeY )
+ nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
+ if ( nDisableShift )
+ pDlg->SetCellShiftDisabled( nDisableShift );
+ }
+ }
+ }
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetInsContentsCmdBits();
+ nFunction = pDlg->GetFormulaCmdBits();
+ bSkipEmpty = pDlg->IsSkipEmptyCells();
+ bTranspose = pDlg->IsTranspose();
+ bAsLink = pDlg->IsLink();
+ eMoveMode = pDlg->GetMoveMode();
+ }
+ delete pDlg;
+ }
+ else
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ if ( bAsLink && bOtherDoc )
+ pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK); // DDE einfuegen
+ else
+ pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
+ nFunction, bSkipEmpty, bTranspose, bAsLink,
+ eMoveMode, IDF_NONE, sal_True ); // allow warning dialog
+ }
+
+ if( !pReqArgs )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ }
+
+ rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) );
+ rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) );
+ rReq.Done();
+ }
+ }
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
+ break;
+
+ case SID_PASTE_SPECIAL:
+ // Unterscheidung, ob eigene oder fremde Daten,
+ // dadurch FID_INS_CELL_CONTENTS ueberfluessig
+ {
+ Window* pWin = GetViewData()->GetActiveWin();
+
+ // Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)"
+ const SfxPoolItem* pItem=NULL;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ sal_uLong nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ sal_Bool bRet=sal_True;
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+ if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ pTabViewShell->PasteDraw();
+ else
+ bRet = pTabViewShell->PasteFromSystem(nFormat, sal_True); // TRUE: keine Fehlermeldungen
+ }
+
+ if ( bRet )
+ {
+ rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler
+ rReq.Done();
+ }
+ else
+ // if format is not available -> fallback to request without parameters
+ pItem = NULL;
+ }
+
+ if ( !pItem )
+ {
+ if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data
+ {
+ rReq.SetSlot( FID_INS_CELL_CONTENTS );
+ ExecuteSlot( rReq, GetInterface() );
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
+ }
+ else // Zeichenobjekte oder fremde Daten
+ {
+ sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ GetPossibleClipboardFormats( aFormats );
+
+ sal_uInt16 nFormatCount = aFormats.Count();
+ if ( nFormatCount )
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() );
+ if ( pDlg )
+ {
+ for (sal_uInt16 i=0; i<nFormatCount; i++)
+ {
+ sal_uLong nFormatId = aFormats.GetClipbrdFormatId( i );
+ String aName = aFormats.GetClipbrdFormatName( i );
+ // special case for paste dialog: '*' is replaced by object type
+ if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ aName.Assign((sal_Unicode)'*');
+ pDlg->Insert( nFormatId, aName );
+ }
+
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+ sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+ if (nFormat > 0)
+ {
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ pTabViewShell->PasteDraw();
+ else
+ pTabViewShell->PasteFromSystem(nFormat);
+ }
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
+ rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) );
+ rReq.Done();
+ }
+ else
+ {
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
+ rReq.Ignore();
+ }
+
+ delete pDlg;
+ }
+ }
+ else
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
+ }
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
+ break;
+
+ //
+ // sonstiges
+ //
+
+ case FID_INS_ROWBRK:
+ pTabViewShell->InsertPageBreak( false );
+ rReq.Done();
+ break;
+
+ case FID_INS_COLBRK:
+ pTabViewShell->InsertPageBreak( sal_True );
+ rReq.Done();
+ break;
+
+ case FID_DEL_ROWBRK:
+ pTabViewShell->DeletePageBreak( false );
+ rReq.Done();
+ break;
+
+ case FID_DEL_COLBRK:
+ pTabViewShell->DeletePageBreak( sal_True );
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_PRED:
+ pTabViewShell->DetectiveAddPred();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_DEL_PRED:
+ pTabViewShell->DetectiveDelPred();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_SUCC:
+ pTabViewShell->DetectiveAddSucc();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_DEL_SUCC:
+ pTabViewShell->DetectiveDelSucc();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_ERR:
+ pTabViewShell->DetectiveAddError();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_INVALID:
+ pTabViewShell->DetectiveMarkInvalid();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_REFRESH:
+ pTabViewShell->DetectiveRefresh();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_MARK_PRED:
+ pTabViewShell->DetectiveMarkPred();
+ break;
+ case SID_DETECTIVE_MARK_SUCC:
+ pTabViewShell->DetectiveMarkSucc();
+ break;
+ case SID_INSERT_CURRENT_DATE:
+ pTabViewShell->InsertCurrentTime(
+ NUMBERFORMAT_DATE, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE));
+ break;
+ case SID_INSERT_CURRENT_TIME:
+ pTabViewShell->InsertCurrentTime(
+ NUMBERFORMAT_TIME, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME));
+ break;
+
+ case SID_SPELL_DIALOG:
+ {
+ SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
+ if( rReq.GetArgs() )
+ pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
+ static_cast< const SfxBoolItem& >( rReq.GetArgs()->
+ Get( SID_SPELL_DIALOG ) ).GetValue() );
+ else
+ pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
+
+ pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_HANGUL_HANJA_CONVERSION:
+ pTabViewShell->DoHangulHanjaConversion();
+ break;
+
+ case SID_CHINESE_CONVERSION:
+ {
+ //open ChineseTranslationDialog
+ Reference< XComponentContext > xContext(
+ ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
+ if(xContext.is())
+ {
+ Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
+ if(xMCF.is())
+ {
+ Reference< ui::dialogs::XExecutableDialog > xDialog(
+ xMCF->createInstanceWithContext(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ChineseTranslationDialog"))
+ , xContext), UNO_QUERY);
+ Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
+ if( xInit.is() )
+ {
+ // initialize dialog
+ Reference< awt::XWindow > xDialogParentWindow(0);
+ Sequence<Any> aSeq(1);
+ Any* pArray = aSeq.getArray();
+ PropertyValue aParam;
+ aParam.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow"));
+ aParam.Value <<= makeAny(xDialogParentWindow);
+ pArray[0] <<= makeAny(aParam);
+ xInit->initialize( aSeq );
+
+ //execute dialog
+ sal_Int16 nDialogRet = xDialog->execute();
+ if( RET_OK == nDialogRet )
+ {
+ //get some parameters from the dialog
+ sal_Bool bToSimplified = sal_True;
+ sal_Bool bUseVariants = sal_True;
+ sal_Bool bCommonTerms = sal_True;
+ Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ xProp->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsDirectionToSimplified")) ) >>= bToSimplified;
+ xProp->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUseCharacterVariants")) ) >>= bUseVariants;
+ xProp->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsTranslateCommonTerms")) ) >>= bCommonTerms;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ //execute translation
+ LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont(
+ DEFAULTFONT_CJK_SPREADSHEET,
+ eTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+ ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
+ eSourceLang, eTargetLang, aTargetFont, nOptions, false );
+ pTabViewShell->DoSheetConversion( aConvParam );
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ }
+ break;
+
+ case SID_THESAURUS:
+ pTabViewShell->DoThesaurus();
+ break;
+
+ case SID_TOGGLE_REL:
+ pTabViewShell->DoRefConversion();
+ break;
+
+ case SID_DEC_INDENT:
+ pTabViewShell->ChangeIndent( false );
+ break;
+ case SID_INC_INDENT:
+ pTabViewShell->ChangeIndent( sal_True );
+ break;
+
+ case FID_USE_NAME:
+ {
+ sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if( pDlg->Execute() )
+ {
+ nFlags = pDlg->GetFlags();
+ pTabViewShell->CreateNames(nFlags);
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_CONSOLIDATE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, sal_True, &pItem ) )
+ {
+ const ScConsolidateParam& rParam =
+ ((const ScConsolidateItem*)pItem)->GetData();
+
+ pTabViewShell->Consolidate( rParam );
+ GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
+
+ rReq.Done();
+ }
+ else if (rReq.IsAPI())
+ SbxBase::SetError(SbxERR_BAD_PARAMETER);
+ }
+ break;
+
+ case SID_INS_FUNCTION:
+ {
+ const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK );
+
+ if ( pOkItem->GetValue() ) // OK
+ {
+ String aFormula;
+ const SfxStringItem* pSItem = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING );
+ const SfxBoolItem* pMatrixItem = (const SfxBoolItem*) &pReqArgs->Get( SID_DLG_MATRIX );
+
+ aFormula += pSItem->GetValue();
+ pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
+ }
+ else // CANCEL
+ {
+ pScMod->ActivateInputWindow( NULL );
+ }
+ rReq.Ignore(); // only SID_ENTER_STRING is recorded
+ }
+ break;
+
+ case FID_DEFINE_NAME:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aName, aSymbol, aAttrib;
+
+ if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) )
+ aName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ aSymbol = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ aAttrib = ((const SfxStringItem*)pItem)->GetValue();
+
+ if ( aName.Len() && aSymbol.Len() )
+ {
+ if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
+ rReq.Done();
+ else
+ SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
+ }
+ }
+ else
+ {
+ sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ case SID_DEFINE_COLROWNAMERANGES:
+ {
+
+ sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+
+ }
+ break;
+
+ case SID_UPDATECHART:
+ {
+ sal_Bool bAll = false;
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+
+ if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) )
+ bAll = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+
+ pTabViewShell->UpdateCharts( bAll );
+
+ if( ! rReq.IsAPI() )
+ {
+ rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
+ rReq.Done();
+ }
+ }
+ break;
+
+
+ case SID_TABOP:
+ if (pReqArgs)
+ {
+ const ScTabOpItem& rItem =
+ (const ScTabOpItem&)
+ pReqArgs->Get( SID_TABOP );
+
+ pTabViewShell->TabOp( rItem.GetData() );
+
+ rReq.Done( *pReqArgs );
+ }
+ break;
+
+ case SID_SOLVE:
+ if (pReqArgs)
+ {
+ const ScSolveItem& rItem =
+ (const ScSolveItem&)
+ pReqArgs->Get( SCITEM_SOLVEDATA );
+
+ pTabViewShell->Solve( rItem.GetData() );
+
+ rReq.Done( *pReqArgs );
+ }
+ break;
+
+ case FID_INSERT_NAME:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ switch( pDlg->Execute() )
+ {
+ case BTN_PASTE_LIST:
+ pTabViewShell->InsertNameList();
+ break;
+ case BTN_PASTE_NAME:
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
+ if (pHdl)
+ {
+ // das "=" per Key-Event, schaltet in den Eingabe-Modus
+ pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
+
+ String aName = pDlg->GetSelectedName();
+ pHdl->InsertFunction( aName, false ); // ohne "()"
+ }
+ }
+ break;
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_RANGE_NOTETEXT:
+ if (pReqArgs)
+ {
+ const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT );
+
+ // immer Cursorposition
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
+ rReq.Done();
+ }
+ break;
+
+ case SID_INSERT_POSTIT:
+ if ( pReqArgs )
+ {
+ const SvxPostItAuthorItem& rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR );
+ const SvxPostItDateItem& rDateItem = (const SvxPostItDateItem&) pReqArgs->Get( SID_ATTR_POSTIT_DATE );
+ const SvxPostItTextItem& rTextItem = (const SvxPostItTextItem&) pReqArgs->Get( SID_ATTR_POSTIT_TEXT );
+
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() );
+ rReq.Done();
+ }
+ else
+ {
+ pTabViewShell->EditNote(); // Zeichenobjekt zum Editieren
+ }
+ break;
+
+ case FID_NOTE_VISIBLE:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if( ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ {
+ bool bShow;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, sal_True, &pItem ) == SFX_ITEM_SET) )
+ bShow = ((const SfxBoolItem*) pItem)->GetValue();
+ else
+ bShow = !pNote->IsCaptionShown();
+
+ pTabViewShell->ShowNote( bShow );
+
+ if (!pReqArgs)
+ rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
+
+ rReq.Done();
+ rBindings.Invalidate( FID_NOTE_VISIBLE );
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_DELETE_NOTE:
+ pTabViewShell->DeleteContents( IDF_NOTE ); // delete all notes in selection
+ rReq.Done();
+ break;
+
+ case SID_CHARMAP:
+ if( pReqArgs != NULL )
+ {
+ String aChars, aFontName;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if ( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+ if ( pItem )
+ {
+ const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem );
+ if ( pStringItem )
+ aChars = pStringItem->GetValue();
+ const SfxPoolItem* pFtItem = NULL;
+ pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
+ const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
+ if ( pFontItem )
+ aFontName = pFontItem->GetValue();
+ }
+
+ if ( aChars.Len() )
+ {
+ Font aFont;
+ pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
+ pTabViewShell->GetSelectionScriptType() );
+ if ( aFontName.Len() )
+ aFont = Font( aFontName, Size(1,1) );
+ pTabViewShell->InsertSpecialChar( aChars, aFont );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ }
+ else
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+
+ // font color doesn't matter here
+ Font aCurFont;
+ pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
+ pTabViewShell->GetSelectionScriptType() );
+
+ SfxAllItemSet aSet( GetPool() );
+ aSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
+ aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
+
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
+ pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, false );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, false );
+
+ if ( pItem && pFontItem )
+ {
+ Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) );
+ aNewFont.SetCharSet( pFontItem->GetCharSet() );
+ aNewFont.SetPitch( pFontItem->GetPitch() );
+ pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont );
+ rReq.AppendItem( *pFontItem );
+ rReq.AppendItem( *pItem );
+ rReq.Done();
+ }
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_SELECT_SCENARIO:
+ {
+ // Testing
+
+ if ( pReqArgs )
+ {
+ const SfxStringItem* pItem =
+ (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO );
+
+ if( pItem )
+ {
+ pTabViewShell->UseScenario( pItem->GetValue() );
+ //! wofuer soll der Return-Wert gut sein?!?!
+ rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
+ rReq.Done();
+ }
+ else
+ {
+ OSL_FAIL("NULL");
+ }
+ }
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ sal_uInt16 nType = (sal_uInt16) pHyper->GetInsertMode();
+
+ pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case FID_CONDITIONAL_FORMAT:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) )
+ {
+ // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
+ // hat wieder zurueckschalten:
+ if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() )
+ {
+ pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() );
+ pTabViewShell->PaintExtras();
+ }
+
+ const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem;
+ pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_EXTERNAL_SOURCE:
+ {
+ String aFile;
+ String aFilter;
+ String aOptions;
+ String aSource;
+ sal_uLong nRefresh=0;
+
+ SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, false );
+ SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, false );
+ if ( pFile && pSource )
+ {
+ aFile = pFile->GetValue();
+ aSource = pSource->GetValue();
+ SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, false );
+ if ( pFilter )
+ aFilter = pFilter->GetValue();
+ SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, false );
+ if ( pOptions )
+ aOptions = pOptions->GetValue();
+ SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, false );
+ if ( pRefresh )
+ nRefresh = pRefresh->GetValue();
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ delete pImpl->m_pLinkedDlg;
+ pImpl->m_pLinkedDlg =
+ pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_LINKAREA);
+ DBG_ASSERT(pImpl->m_pLinkedDlg, "Dialog create fail!");
+ delete pImpl->m_pRequest;
+ pImpl->m_pRequest = new SfxRequest( rReq );
+ pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
+ return;
+ }
+
+ ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
+ }
+ break;
+
+ //
+ //
+ //
+
+ default:
+ OSL_FAIL("falscher Slot bei ExecuteEdit");
+ break;
+ }
+}
+
+void ScCellShell::ExecuteTrans( SfxRequest& rReq )
+{
+ sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
+ if ( nType )
+ {
+ GetViewData()->GetView()->TransliterateText( nType );
+ rReq.Done();
+ }
+}
+
+void ScCellShell::ExecuteRotateTrans( SfxRequest& rReq )
+{
+ if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
+ GetViewData()->GetView()->TransliterateText( m_aRotateCase.getNextMode() );
+}
+
+void ScCellShell::ExecuteExternalSource(
+ const String& _rFile, const String& _rFilter, const String& _rOptions,
+ const String& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest )
+{
+ if ( _rFile.Len() && _rSource.Len() ) // filter may be empty
+ {
+ ScRange aLinkRange;
+ sal_Bool bMove = false;
+
+ ScViewData* pData = GetViewData();
+ ScMarkData& rMark = pData->GetMarkData();
+ rMark.MarkToSimple();
+ if ( rMark.IsMarked() )
+ {
+ rMark.GetMarkArea( aLinkRange );
+ bMove = sal_True; // insert/delete cells to fit range
+ }
+ else
+ aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+
+ ScDocFunc aFunc(*pData->GetDocShell());
+ aFunc.InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
+ aLinkRange, _nRefresh, bMove, false );
+ _rRequest.Done();
+ }
+ else
+ _rRequest.Ignore();
+}
+
+namespace {
+
+bool isDPSourceValid(const ScDPObject& rDPObj)
+{
+ if (rDPObj.IsImportData())
+ {
+ // If the data type is database, check if the database is still valid.
+ const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
+ if (!pDesc)
+ return false;
+
+ const ScDPCache* pCache = pDesc->CreateCache();
+ if (!pCache)
+ // cashe creation failed, probably due to invalid connection.
+ return false;
+ }
+ return true;
+}
+
+}
+
+void ScCellShell::ExecuteDataPilotDialog()
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScViewData* pData = GetViewData();
+ ScDocument* pDoc = pData->GetDocument();
+
+ ::boost::scoped_ptr<ScDPObject> pNewDPObject(NULL);
+
+ // ScPivot is no longer used...
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(
+ pData->GetCurX(), pData->GetCurY(),
+ pData->GetTabNo() );
+ if ( pDPObj ) // on an existing table?
+ {
+ if (isDPSourceValid(*pDPObj))
+ pNewDPObject.reset(new ScDPObject(*pDPObj));
+ }
+ else // create new table
+ {
+ sal_uLong nSrcErrorId = 0;
+
+ // select database range or data
+ pTabViewShell->GetDBData( true, SC_DB_OLD );
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ pTabViewShell->MarkDataArea( false );
+
+ // output to cursor position for non-sheet data
+ ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
+ pData->GetTabNo() );
+
+ // first select type of source data
+
+ bool bEnableExt = ScDPObject::HasRegisteredSources();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ ::boost::scoped_ptr<AbstractScDataPilotSourceTypeDlg> pTypeDlg(
+ pFact->CreateScDataPilotSourceTypeDlg(
+ pTabViewShell->GetDialogParent(), bEnableExt, RID_SCDLG_DAPITYPE));
+
+ // Populate named ranges (if any).
+ ScRangeName* pRangeName = pDoc->GetRangeName();
+ if (pRangeName)
+ {
+ ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
+ for (; itr != itrEnd; ++itr)
+ pTypeDlg->AppendNamedRange(itr->GetName());
+ }
+
+ DBG_ASSERT(pTypeDlg, "Dialog create fail!");
+ if ( pTypeDlg->Execute() == RET_OK )
+ {
+ if ( pTypeDlg->IsExternal() )
+ {
+ uno::Sequence<rtl::OUString> aSources = ScDPObject::GetRegisteredSources();
+ ::boost::scoped_ptr<AbstractScDataPilotServiceDlg> pServDlg(
+ pFact->CreateScDataPilotServiceDlg(
+ pTabViewShell->GetDialogParent(), aSources, RID_SCDLG_DAPISERVICE));
+
+ DBG_ASSERT(pServDlg, "Dialog create fail!");
+ if ( pServDlg->Execute() == RET_OK )
+ {
+ ScDPServiceDesc aServDesc(
+ pServDlg->GetServiceName(),
+ pServDlg->GetParSource(),
+ pServDlg->GetParName(),
+ pServDlg->GetParUser(),
+ pServDlg->GetParPass() );
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetServiceData( aServDesc );
+ }
+ }
+ else if ( pTypeDlg->IsDatabase() )
+ {
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ ::boost::scoped_ptr<AbstractScDataPilotDatabaseDlg> pDataDlg(
+ pFact->CreateScDataPilotDatabaseDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DAPIDATA));
+
+ DBG_ASSERT(pDataDlg, "Dialog create fail!");
+ if ( pDataDlg->Execute() == RET_OK )
+ {
+ ScImportSourceDesc aImpDesc(pDoc);
+ pDataDlg->GetValues( aImpDesc );
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetImportDesc( aImpDesc );
+ }
+ }
+ else if (pTypeDlg->IsNamedRange())
+ {
+ OUString aName = pTypeDlg->GetSelectedNamedRange();
+ ScSheetSourceDesc aShtDesc(pDoc);
+ aShtDesc.SetRangeName(aName);
+ nSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!nSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetSheetDesc(aShtDesc);
+ }
+ }
+ else // selection
+ {
+ //! use database ranges (select before type dialog?)
+ ScRange aRange;
+ ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
+ if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
+ {
+ // Shrink the range to the data area.
+ SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
+ SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
+ {
+ aRange.aStart.SetCol(nStartCol);
+ aRange.aStart.SetRow(nStartRow);
+ aRange.aEnd.SetCol(nEndCol);
+ aRange.aEnd.SetRow(nEndRow);
+ rMark.SetMarkArea(aRange);
+ pTabViewShell->MarkRange(aRange);
+ }
+
+ bool bOK = true;
+ if ( pDoc->HasSubTotalCells( aRange ) )
+ {
+ // confirm selection if it contains SubTotal cells
+
+ QueryBox aBox( pTabViewShell->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) );
+ if (aBox.Execute() == RET_NO)
+ bOK = false;
+ }
+ if (bOK)
+ {
+ ScSheetSourceDesc aShtDesc(pDoc);
+ aShtDesc.SetSourceRange(aRange);
+ nSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!nSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetSheetDesc( aShtDesc );
+ }
+
+ // output below source data
+ if ( aRange.aEnd.Row()+2 <= MAXROW - 4 )
+ aDestPos = ScAddress( aRange.aStart.Col(),
+ aRange.aEnd.Row()+2,
+ aRange.aStart.Tab() );
+ }
+ }
+ }
+ }
+
+ if (nSrcErrorId)
+ {
+ // Error occurred during data creation. Launch an error and bail out.
+ InfoBox aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId));
+ aBox.Execute();
+ return;
+ }
+
+ if ( pNewDPObject )
+ pNewDPObject->SetOutRange( aDestPos );
+ }
+
+ pTabViewShell->SetDialogDPObject( pNewDPObject.get() ); // is copied
+ if ( pNewDPObject )
+ {
+ // start layout dialog
+
+ sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+ pScMod->SetRefDialog( nId, pWnd ? false : true );
+ }
+}
+
+void ScCellShell::ExecuteSubtotals(SfxRequest& rReq)
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
+ GetSubTotalData() );
+ rReq.Done();
+ return;
+ }
+
+ SfxAbstractTabDialog * pDlg = NULL;
+ ScSubTotalParam aSubTotalParam;
+ SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
+
+ // Only get existing named database range.
+ ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD);
+ if (!pDBData)
+ {
+ // No existing DB data at this position. Create an
+ // anonymous DB.
+ pDBData = pTabViewShell->GetAnonymousDBData();
+ ScRange aDataRange;
+ pDBData->GetArea(aDataRange);
+ pTabViewShell->MarkRange(aDataRange, false);
+ }
+ if (!pDBData)
+ return;
+
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ aSubTotalParam.bRemoveOnly = false;
+
+ aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetCurPageId(1);
+
+ short bResult = pDlg->Execute();
+
+ if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
+ {
+ const SfxItemSet* pOutSet = NULL;
+
+ if ( bResult == RET_OK )
+ {
+ pOutSet = pDlg->GetOutputItemSet();
+ aSubTotalParam =
+ ((const ScSubTotalItem&)
+ pOutSet->Get( SCITEM_SUBTDATA )).
+ GetSubTotalData();
+ }
+ else // if (bResult == SCRET_REMOVE)
+ {
+ pOutSet = &aArgSet;
+ aSubTotalParam.bRemoveOnly = sal_True;
+ aSubTotalParam.bReplace = sal_True;
+ aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
+ GetViewData(),
+ &aSubTotalParam ) );
+ }
+
+ pTabViewShell->DoSubTotals( aSubTotalParam );
+ rReq.Done( *pOutSet );
+ }
+ else
+ GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+ delete pDlg;
+}
+
+IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
+{
+ DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
+ DBG_ASSERT( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" );
+ String sFile, sFilter, sOptions, sSource;
+ sal_uLong nRefresh = 0;
+
+ if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
+ {
+ sFile = pImpl->m_pLinkedDlg->GetURL();
+ sFilter = pImpl->m_pLinkedDlg->GetFilter();
+ sOptions = pImpl->m_pLinkedDlg->GetOptions();
+ sSource = pImpl->m_pLinkedDlg->GetSource();
+ nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
+ if ( sFile.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
+ if ( sFilter.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
+ if ( sOptions.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
+ if ( sSource.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
+ if ( nRefresh )
+ pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
+ }
+
+ ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
+ return 0;
+}
+
+void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
+{
+ Window* pWin = pViewData->GetActiveWin();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
+ pViewData->GetCurY(), pViewData->GetTabNo() );
+ if ( pOwnClip && pDPObj )
+ {
+ // paste from Calc into DataPilot table: sort (similar to drag & drop)
+
+ ScDocument* pClipDoc = pOwnClip->GetDocument();
+ SCTAB nSourceTab = pOwnClip->GetVisibleTab();
+
+ SCCOL nClipStartX;
+ SCROW nClipStartY;
+ SCCOL nClipEndX;
+ SCROW nClipEndY;
+ pClipDoc->GetClipStart( nClipStartX, nClipStartY );
+ pClipDoc->GetClipArea( nClipEndX, nClipEndY, sal_True );
+ nClipEndX = nClipEndX + nClipStartX;
+ nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference
+
+ ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
+ sal_Bool bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
+ if ( !bDone )
+ pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
+ }
+ else
+ {
+ // normal paste
+ WaitObject aWait( pViewData->GetDialogParent() );
+ if (!pOwnClip)
+ pTabViewShell->PasteFromSystem();
+ else
+ {
+ ScDocument* pClipDoc = pOwnClip->GetDocument();
+ sal_uInt16 nFlags = IDF_ALL;
+ if (pClipDoc->GetClipParam().isMultiRange())
+ // For multi-range paste, we paste values by default.
+ nFlags &= ~IDF_FORMULA;
+
+ pTabViewShell->PasteFromClip( nFlags, pClipDoc,
+ PASTE_NOFUNC, false, false, false, INS_NONE, IDF_NONE,
+ bShowDialog ); // allow warning dialog
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
new file mode 100644
index 000000000000..e3931d52ced3
--- /dev/null
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -0,0 +1,1192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <svl/aeitem.hxx>
+#include <basic/sbxcore.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/visitem.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+#include "cellsh.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "globalnames.hxx"
+#include "scmod.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "dbfunc.hxx"
+#include "dbdocfun.hxx"
+#include "filtdlg.hxx"
+#include "dbnamdlg.hxx"
+#include "reffact.hxx"
+#include "pvlaydlg.hxx"
+#include "validat.hxx"
+#include "scresid.hxx"
+
+#include "validate.hrc" // ScValidationDlg
+#include "scui_def.hxx"
+#include "scabstdlg.hxx"
+#include "impex.hxx"
+#include "asciiopt.hxx"
+using namespace com::sun::star;
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
+
+//------------------------------------------------------------------
+
+bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange )
+{
+ DBG_ASSERT( pData, "lcl_GetTextToColumnsRange: pData is null!" );
+
+ bool bRet = false;
+ const ScMarkData& rMark = pData->GetMarkData();
+
+ if ( rMark.IsMarked() )
+ {
+ if ( !rMark.IsMultiMarked() )
+ {
+ rMark.GetMarkArea( rRange );
+ if ( rRange.aStart.Col() == rRange.aEnd.Col() )
+ {
+ bRet = true;
+ }
+ }
+ }
+ else
+ {
+ const SCCOL nCol = pData->GetCurX();
+ const SCROW nRow = pData->GetCurY();
+ const SCTAB nTab = pData->GetTabNo();
+ rRange = ScRange( nCol, nRow, nTab, nCol, nRow, nTab );
+ bRet = true;
+ }
+
+ const ScDocument* pDoc = pData->GetDocument();
+ DBG_ASSERT( pDoc, "lcl_GetTextToColumnsRange: pDoc is null!" );
+
+ if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
+ rRange.aStart.Row(), rRange.aEnd.Col(),
+ rRange.aEnd.Row() ) )
+ {
+ bRet = false;
+ }
+
+ return bRet;
+}
+
+sal_Bool lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
+{
+ ScTabViewShell* pTabViewShell = pData->GetViewShell();
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScDocument* pDoc = pData->GetDocument();
+ SCTAB nTab = pData->GetTabNo();
+ ScDirection eFillDir = DIR_TOP;
+ sal_Bool bSort = sal_True;
+ ScRange aExternalRange;
+
+ if( rSortParam.nCol1 != rSortParam.nCol2 )
+ eFillDir = DIR_LEFT;
+ if( rSortParam.nRow1 != rSortParam.nRow2 )
+ eFillDir = DIR_TOP;
+
+ SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir );
+
+ if( rSortParam.nRow2 == MAXROW )
+ aExternalRange = ScRange( rSortParam.nCol1,sal::static_int_cast<SCROW>( nCount ), nTab );
+ else
+ aExternalRange = ScRange( pData->GetCurX(), pData->GetCurY(), nTab );
+
+ SCROW nStartRow = aExternalRange.aStart.Row();
+ SCCOL nStartCol = aExternalRange.aStart.Col();
+ SCROW nEndRow = aExternalRange.aEnd.Row();
+ SCCOL nEndCol = aExternalRange.aEnd.Col();
+ pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, false, false );
+ aExternalRange.aStart.SetRow( nStartRow );
+ aExternalRange.aStart.SetCol( nStartCol );
+ aExternalRange.aEnd.SetRow( nEndRow );
+ aExternalRange.aEnd.SetCol( nEndCol );
+
+ if(( rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col() ) ||
+ ( rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row() ) )
+ {
+ sal_uInt16 nFmt = SCA_VALID;
+ String aExtendStr,aCurrentStr;
+
+ pTabViewShell->AddHighlightRange( aExternalRange,Color( COL_LIGHTBLUE ) );
+ ScRange rExtendRange( aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), nTab, aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row(), nTab );
+ rExtendRange.Format( aExtendStr, nFmt, pDoc );
+
+ ScRange rCurrentRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab );
+ rCurrentRange.Format( aCurrentStr, nFmt, pDoc );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ VclAbstractDialog* pWarningDlg = pFact->CreateScSortWarningDlg( pTabViewShell->GetDialogParent(),aExtendStr,aCurrentStr,RID_SCDLG_SORT_WARNING );
+ DBG_ASSERT(pWarningDlg, "Dialog create fail!");
+ short bResult = pWarningDlg->Execute();
+ if( bResult == BTN_EXTEND_RANGE || bResult == BTN_CURRENT_SELECTION )
+ {
+ if( bResult == BTN_EXTEND_RANGE )
+ {
+ pTabViewShell->MarkRange( aExternalRange, false );
+ pDBData->SetArea( nTab, aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row() );
+ }
+ }
+ else
+ {
+ bSort = false;
+ pData->GetDocShell()->CancelAutoDBRange();
+ }
+
+ delete pWarningDlg;
+ pTabViewShell->ClearHighlightRanges();
+ }
+ return bSort;
+}
+
+//after end execute from !IsModalInputMode, it is safer to delay deleting
+namespace
+{
+ long DelayDeleteAbstractDialog( void *pAbstractDialog, void * /*pArg*/ )
+ {
+ delete reinterpret_cast<VclAbstractDialog*>( pAbstractDialog );
+ return 0;
+ }
+}
+
+void ScCellShell::ExecuteDB( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ ScModule* pScMod = SC_MOD();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ switch ( nSlotId )
+ {
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ // check if database beamer is open
+
+ SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
+ sal_Bool bWasOpen = false;
+ {
+ uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
+ uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_beamer")),
+ frame::FrameSearchFlag::CHILDREN);
+ if ( xBeamerFrame.is() )
+ bWasOpen = sal_True;
+ }
+
+ if ( bWasOpen )
+ {
+ // close database beamer: just forward to SfxViewFrame
+
+ pViewFrame->ExecuteSlot( rReq );
+ }
+ else
+ {
+ // show database beamer: SfxViewFrame call must be synchronous
+
+ pViewFrame->ExecuteSlot( rReq, (sal_Bool) false ); // sal_False = synchronous
+
+ // select current database in database beamer
+
+ ScImportParam aImportParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD); // don't create if none found
+ if (pDBData)
+ pDBData->GetImportParam( aImportParam );
+
+ ScDBDocFunc::ShowInBeamer( aImportParam, pTabViewShell->GetViewFrame() );
+ }
+ rReq.Done(); // needed because it's a toggle slot
+ }
+ break;
+
+ case SID_REIMPORT_DATA:
+ {
+ sal_Bool bOk = false;
+ ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
+ if (pDBData)
+ {
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pDBData->HasImportSelection())
+ {
+ pTabViewShell->ImportData( aImportParam );
+ pDBData->SetImportParam( aImportParam ); //! Undo ??
+ bOk = sal_True;
+ }
+ }
+
+ if (!bOk && ! rReq.IsAPI() )
+ pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY);
+
+ if( bOk )
+ rReq.Done();
+ }
+ break;
+
+ case SID_REFRESH_DBAREA:
+ {
+ ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
+ if (pDBData)
+ {
+ // Import wiederholen wie SID_REIMPORT_DATA
+
+ sal_Bool bContinue = sal_True;
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pDBData->HasImportSelection())
+ {
+ bContinue = pTabViewShell->ImportData( aImportParam );
+ pDBData->SetImportParam( aImportParam ); //! Undo ??
+
+ // markieren (Groesse kann sich geaendert haben)
+ ScRange aNewRange;
+ pDBData->GetArea(aNewRange);
+ pTabViewShell->MarkRange(aNewRange);
+ }
+
+ if ( bContinue ) // Fehler beim Import -> Abbruch
+ {
+ // interne Operationen, wenn welche gespeichert
+
+ if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
+ pDBData->HasSubTotalParam() )
+ pTabViewShell->RepeatDB();
+
+ // Pivottabellen die den Bereich als Quelldaten haben
+
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ GetViewData()->GetDocShell()->RefreshPivotTables(aRange);
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_SBA_BRW_INSERT:
+ {
+ OSL_FAIL( "Deprecated Slot" );
+ }
+ break;
+
+ case SID_DATA_FORM:
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ pDlg->Execute();
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_SUBTOTALS:
+ ExecuteSubtotals(rReq);
+ break;
+
+ case SID_SORT_DESCENDING:
+ case SID_SORT_ASCENDING:
+ {
+ //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
+ //the patch comes from maoyg
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCCOL nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ pDBData->GetSortParam( aSortParam );
+ sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab );
+
+ if( nCol < aSortParam.nCol1 )
+ nCol = aSortParam.nCol1;
+ else if( nCol > aSortParam.nCol2 )
+ nCol = aSortParam.nCol2;
+
+ aSortParam.bHasHeader = bHasHeader;
+ aSortParam.bByRow = true;
+ aSortParam.bCaseSens = false;
+ aSortParam.bNaturalSort = false;
+ aSortParam.bIncludePattern = true;
+ aSortParam.bInplace = true;
+ aSortParam.bDoSort[0] = true;
+ aSortParam.nField[0] = nCol;
+ aSortParam.bAscending[0] = (nSlotId == SID_SORT_ASCENDING);
+
+ for ( sal_uInt16 i=1; i<MAXSORT; i++ )
+ aSortParam.bDoSort[i] = false;
+
+ aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
+
+ pTabViewShell->UISort( aSortParam ); // Teilergebnisse bei Bedarf neu
+
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_SORT:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
+ //the patch comes from maoyg
+
+ if ( pArgs ) // Basic
+ {
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ pDBData->GetSortParam( aSortParam );
+ sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
+ if( bHasHeader )
+ aSortParam.bHasHeader = bHasHeader;
+
+ aSortParam.bInplace = sal_True; // von Basic immer
+
+ const SfxPoolItem* pItem;
+ if ( pArgs->GetItemState( SID_SORT_BYROW, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bByRow = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_HASHEADER, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_CASESENS, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_NATURALSORT, true, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bNaturalSort = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_ATTRIBS, true, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_USERDEF, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ sal_uInt16 nUserIndex = ((const SfxUInt16Item*)pItem)->GetValue();
+ aSortParam.bUserDef = ( nUserIndex != 0 );
+ if ( nUserIndex )
+ aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-basiert
+ }
+
+ SCCOLROW nField0 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET )
+ nField0 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[0] = ( nField0 != 0 );
+ aSortParam.nField[0] = nField0 > 0 ? (nField0-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_2, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[0] = ((const SfxBoolItem*)pItem)->GetValue();
+ SCCOLROW nField1 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_3, sal_True, &pItem ) == SFX_ITEM_SET )
+ nField1 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[1] = ( nField1 != 0 );
+ aSortParam.nField[1] = nField1 > 0 ? (nField1-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_4, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[1] = ((const SfxBoolItem*)pItem)->GetValue();
+ SCCOLROW nField2 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_5, sal_True, &pItem ) == SFX_ITEM_SET )
+ nField2 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[2] = ( nField2 != 0 );
+ aSortParam.nField[2] = nField2 > 0 ? (nField2-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_6, sal_True, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[2] = ((const SfxBoolItem*)pItem)->GetValue();
+
+ // Teilergebnisse bei Bedarf neu
+ pTabViewShell->UISort( aSortParam );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ SfxAbstractTabDialog* pDlg = NULL;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
+
+ pDBData->GetSortParam( aSortParam );
+ sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
+ if( bHasHeader )
+ aSortParam.bHasHeader = bHasHeader;
+
+ aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetCurPageId(1); // 1=sort field tab 2=sort options tab
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ const ScSortParam& rOutParam = ((const ScSortItem&)
+ pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
+
+ // Teilergebnisse bei Bedarf neu
+ pTabViewShell->UISort( rOutParam );
+
+ if ( rOutParam.bInplace )
+ {
+ rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW,
+ rOutParam.bByRow ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
+ rOutParam.bHasHeader ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
+ rOutParam.bCaseSens ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
+ rOutParam.bNaturalSort ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
+ rOutParam.bIncludePattern ) );
+ sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
+ rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
+ if ( rOutParam.bDoSort[0] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_1,
+ rOutParam.nField[0] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2,
+ rOutParam.bAscending[0] ) );
+ }
+ if ( rOutParam.bDoSort[1] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_3,
+ rOutParam.nField[1] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_4,
+ rOutParam.bAscending[1] ) );
+ }
+ if ( rOutParam.bDoSort[2] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_5,
+ rOutParam.nField[2] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_6,
+ rOutParam.bAscending[2] ) );
+ }
+ }
+
+ rReq.Done();
+ }
+ else
+ GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+ delete pDlg;
+ }
+ }
+ }
+ break;
+
+ case SID_FILTER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ OSL_FAIL("SID_FILTER with arguments?");
+ pTabViewShell->Query( ((const ScQueryItem&)
+ pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
+ rReq.Done();
+ }
+ else
+ {
+ sal_uInt16 nId = ScFilterDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ }
+ break;
+
+ case SID_SPECIAL_FILTER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ OSL_FAIL("SID_SPECIAL_FILTER with arguments?");
+ pTabViewShell->Query( ((const ScQueryItem&)
+ pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
+ rReq.Done();
+ }
+ else
+ {
+ sal_uInt16 nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ }
+ break;
+
+ case FID_FILTER_OK:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_QUERYDATA, sal_True, &pItem ) )
+ {
+ const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(*pItem);
+
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ SCTAB nRefTab = GetViewData()->GetRefTabNo();
+
+ // If RefInput switched to a different sheet from the data sheet,
+ // switch back:
+
+ if ( nCurTab != nRefTab )
+ {
+ pTabViewShell->SetTabNo( nRefTab );
+ pTabViewShell->PaintExtras();
+ }
+
+ ScRange aAdvSource;
+ if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
+ pTabViewShell->Query( rQueryItem.GetQueryData(), &aAdvSource, sal_True );
+ else
+ pTabViewShell->Query( rQueryItem.GetQueryData(), NULL, sal_True );
+ rReq.Done( *pReqArgs );
+ }
+ }
+ break;
+
+ case SID_UNFILTER:
+ {
+ ScQueryParam aParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+
+ pDBData->GetQueryParam( aParam );
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aParam.GetEntry(i).bDoQuery = false;
+ aParam.bDuplicate = sal_True;
+ pTabViewShell->Query( aParam, NULL, sal_True );
+ rReq.Done();
+ }
+ break;
+
+ case SID_AUTO_FILTER:
+ pTabViewShell->ToggleAutoFilter();
+ rReq.Done();
+ break;
+
+ case SID_AUTOFILTER_HIDE:
+ pTabViewShell->HideAutoFilter();
+ rReq.Done();
+ break;
+
+ case SID_PIVOT_TABLE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_PIVOTDATA, sal_True, &pItem ) )
+ {
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ SCTAB nRefTab = GetViewData()->GetRefTabNo();
+
+ // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
+ // hat wieder zurueckschalten:
+
+ if ( nCurTab != nRefTab )
+ {
+ pTabViewShell->SetTabNo( nRefTab );
+ pTabViewShell->PaintExtras();
+ }
+
+ const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
+ if ( pDPObject )
+ {
+ const ScPivotItem* pPItem = (const ScPivotItem*)pItem;
+ bool bSuccess = pTabViewShell->MakePivotTable(
+ pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
+ SfxBoolItem aRet(0, bSuccess);
+ rReq.SetReturnValue(aRet);
+ }
+ rReq.Done();
+ }
+ else if (rReq.IsAPI())
+ SbxBase::SetError(SbxERR_BAD_PARAMETER);
+ }
+ break;
+
+ case SID_OPENDLG_PIVOTTABLE:
+ ExecuteDataPilotDialog();
+ break;
+ case SID_DEFINE_DBNAME:
+ {
+
+ sal_uInt16 nId = ScDbNameDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+
+ }
+ break;
+
+ case SID_SELECT_DB:
+ {
+ if ( pReqArgs )
+ {
+ const SfxStringItem* pItem =
+ (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_DB );
+
+ if( pItem )
+ {
+ pTabViewShell->GotoDBArea( pItem->GetValue() );
+ rReq.Done();
+ }
+ else
+ {
+ OSL_FAIL("NULL");
+ }
+ }
+ else
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBCollection* pDBCol = pDoc->GetDBCollection();
+
+ if ( pDBCol )
+ {
+ const String aStrNoName( RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME) );
+ List aList;
+ sal_uInt16 nDBCount = pDBCol->GetCount();
+ ScDBData* pDbData = NULL;
+ String* pDBName = NULL;
+
+ for ( sal_uInt16 i=0; i < nDBCount; i++ )
+ {
+ pDbData = (ScDBData*)(pDBCol->At( i ));
+ if ( pDbData )
+ {
+ pDBName = new String;
+ pDbData->GetName( *pDBName );
+
+ if ( *pDBName != aStrNoName )
+ aList.Insert( pDBName );
+ else
+ DELETEZ(pDBName);
+ }
+ }
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScSelEntryDlg* pDlg = pFact->CreateScSelEntryDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_SELECTDB,
+ String(ScResId(SCSTR_SELECTDB)),
+ String(ScResId(SCSTR_AREAS)),
+ aList,
+ RID_SCDLG_SELECTDB);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ String aName = pDlg->GetSelectEntry();
+ pTabViewShell->GotoDBArea( aName );
+ rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
+ rReq.Done();
+ }
+
+ delete pDlg;
+
+ void* pEntry = aList.First();
+ while ( pEntry )
+ {
+ delete (String*) aList.Remove( pEntry );
+ pEntry = aList.Next();
+ }
+ }
+ }
+ }
+ break;
+
+ case FID_VALIDATION:
+ {
+ const SfxPoolItem* pItem;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ OSL_FAIL("spaeter...");
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(TP_VALIDATION_VALUES);
+ DBG_ASSERT(ScTPValidationValueGetRanges, "TabPage create fail!");
+ SfxItemSet aArgSet( GetPool(), (*ScTPValidationValueGetRanges)() );
+ ScValidationMode eMode = SC_VALID_ANY;
+ ScConditionMode eOper = SC_COND_EQUAL;
+ String aExpr1, aExpr2;
+ sal_Bool bBlank = sal_True;
+ sal_Int16 nListType = ValidListType::UNSORTED;
+ sal_Bool bShowHelp = false;
+ String aHelpTitle, aHelpText;
+ sal_Bool bShowError = false;
+ ScValidErrorStyle eErrStyle = SC_VALERR_STOP;
+ String aErrTitle, aErrText;
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aCursorPos( nCurX, nCurY, nTab );
+ sal_uLong nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
+ nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue();
+ if ( nIndex )
+ {
+ const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex );
+ if ( pOldData )
+ {
+ eMode = pOldData->GetDataMode();
+ eOper = pOldData->GetOperation();
+ sal_uLong nNumFmt = 0;
+ if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
+ {
+ short nType = ( eMode == SC_VALID_DATE ) ? NUMBERFORMAT_DATE
+ : NUMBERFORMAT_TIME;
+ nNumFmt = pDoc->GetFormatTable()->GetStandardFormat(
+ nType, ScGlobal::eLnge );
+ }
+ aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
+ aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
+ bBlank = pOldData->IsIgnoreBlank();
+ nListType = pOldData->GetListType();
+
+ bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
+ bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
+
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
+ aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
+ }
+ }
+
+ // cell range picker
+ SfxAbstractTabDialog* pDlg = pFact->CreateScValidationDlg( NULL, &aArgSet, TAB_DLG_VALIDATION, pTabViewShell );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ short nResult = pDlg->Execute();
+ //When picking Cell Range, other Tab may be switched. Need restore the correct tab
+ pTabViewShell->SetTabNo( nTab );
+ if ( nResult == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ if ( pOutSet->GetItemState( FID_VALID_MODE, sal_True, &pItem ) == SFX_ITEM_SET )
+ eMode = (ScValidationMode) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_CONDMODE, sal_True, &pItem ) == SFX_ITEM_SET )
+ eOper = (ScConditionMode) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_VALUE1, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ String aTemp1 = ((const SfxStringItem*)pItem)->GetValue();
+ if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
+ {
+ sal_uInt32 nNumIndex = 0;
+ double nVal;
+ if (pDoc->GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
+ aExpr1 =String( ::rtl::math::doubleToUString( nVal,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), sal_True));
+ else
+ aExpr1 = aTemp1;
+ }
+ else
+ aExpr1 = aTemp1;
+ }
+ if ( pOutSet->GetItemState( FID_VALID_VALUE2, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ String aTemp2 = ((const SfxStringItem*)pItem)->GetValue();
+ if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
+ {
+ sal_uInt32 nNumIndex = 0;
+ double nVal;
+ if (pDoc->GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
+ aExpr2 =String( ::rtl::math::doubleToUString( nVal,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), sal_True));
+ else
+ aExpr2 = aTemp2;
+ }
+ else
+ aExpr2 = aTemp2;
+ }
+
+ if ( pOutSet->GetItemState( FID_VALID_BLANK, sal_True, &pItem ) == SFX_ITEM_SET )
+ bBlank = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, sal_True, &pItem ) == SFX_ITEM_SET )
+ nListType = ((const SfxInt16Item*)pItem)->GetValue();
+
+ if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, sal_True, &pItem ) == SFX_ITEM_SET )
+ bShowHelp = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
+ aHelpTitle = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
+ aHelpText = ((const SfxStringItem*)pItem)->GetValue();
+
+ if ( pOutSet->GetItemState( FID_VALID_SHOWERR, sal_True, &pItem ) == SFX_ITEM_SET )
+ bShowError = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, sal_True, &pItem ) == SFX_ITEM_SET )
+ eErrStyle = (ScValidErrorStyle) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
+ aErrTitle = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
+ aErrText = ((const SfxStringItem*)pItem)->GetValue();
+
+ ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos );
+ aData.SetIgnoreBlank( bBlank );
+ aData.SetListType( nListType );
+
+ aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
+ if (!bShowHelp)
+ aData.ResetInput(); // reset only bShowInput
+
+ aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
+ if (!bShowError)
+ aData.ResetError(); // reset only bShowError
+
+ pTabViewShell->SetValidation( aData );
+ rReq.Done( *pOutSet );
+ }
+ //after end execute from !IsModalInputMode, it is safer to delay deleting
+ //delete pDlg;
+ Application::PostUserEvent( Link( pDlg, &DelayDeleteAbstractDialog ) );
+ }
+ }
+ break;
+
+ case SID_TEXT_TO_COLUMNS:
+ {
+ ScViewData* pData = GetViewData();
+ DBG_ASSERT( pData, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pData is null!" );
+ ScRange aRange;
+
+ if ( lcl_GetTextToColumnsRange( pData, aRange ) )
+ {
+ ScDocument* pDoc = pData->GetDocument();
+ DBG_ASSERT( pDoc, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDoc is null!" );
+
+ ScImportExport aExport( pDoc, aRange );
+ aExport.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::None, 0, false ) );
+
+ // #i87703# text to columns fails with tab separator
+ aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
+
+ SvMemoryStream aStream;
+ aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
+ ScImportExport::SetNoEndianSwap( aStream );
+ aExport.ExportStream( aStream, String(), FORMAT_STRING );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pFact is null!" );
+ AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg(
+ NULL, String(), &aStream, RID_SCDLG_ASCII );
+ DBG_ASSERT( pDlg, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDlg is null!" );
+ pDlg->SetTextToColumnsMode();
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScDocShell* pDocSh = pData->GetDocShell();
+ DBG_ASSERT( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
+
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_TEXTTOCOLUMNS );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ ScImportExport aImport( pDoc, aRange.aStart );
+ ScAsciiOptions aOptions;
+ pDlg->GetOptions( aOptions );
+ aImport.SetExtOptions( aOptions );
+ aImport.SetApi( false );
+ aStream.Seek( 0 );
+ aImport.ImportStream( aStream, String(), FORMAT_STRING );
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ delete pDlg;
+ }
+ }
+ break;
+ }
+}
+
+void ScCellShell::GetDBState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScViewData* pData = GetViewData();
+ ScDocShell* pDocSh = pData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCTAB nTab = pData->GetTabNo();
+
+ sal_Bool bAutoFilter = false;
+ sal_Bool bAutoFilterTested = false;
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_REFRESH_DBAREA:
+ {
+ // importierte Daten ohne Selektion
+ // oder Filter,Sortierung,Teilergebis (auch ohne Import)
+ sal_Bool bOk = false;
+ ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
+ if (pDBData && pDoc->GetChangeTrack() == NULL)
+ {
+ if ( pDBData->HasImportParam() )
+ bOk = !pDBData->HasImportSelection();
+ else
+ {
+ bOk = pDBData->HasQueryParam() ||
+ pDBData->HasSortParam() ||
+ pDBData->HasSubTotalParam();
+ }
+ }
+ if (!bOk)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_FILTER:
+ case SID_SPECIAL_FILTER:
+ {
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+
+ //Bei Redlining und Multiselektion Disablen
+ case SID_SORT_ASCENDING:
+ case SID_SORT_DESCENDING:
+ case SCITEM_SORTDATA:
+ case SCITEM_SUBTDATA:
+ case SID_OPENDLG_PIVOTTABLE:
+ {
+ //! move ReadOnly check to idl flags
+
+ if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL ||
+ GetViewData()->IsMultiMarked() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_REIMPORT_DATA:
+ {
+ // nur importierte Daten ohne Selektion
+ ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
+ if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
+ pDoc->GetChangeTrack()!=NULL)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
+ rSet.Put(SfxVisibilityItem(nWhich, false));
+ else
+ // get state (BoolItem) from SfxViewFrame
+ pTabViewShell->GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
+ }
+ break;
+ case SID_SBA_BRW_INSERT:
+ {
+ // SBA will ein sal_Bool-Item, damit ueberhaupt enabled
+
+ sal_Bool bEnable = sal_True;
+ rSet.Put(SfxBoolItem(nWhich, bEnable));
+ }
+ break;
+
+ case SID_AUTO_FILTER:
+ case SID_AUTOFILTER_HIDE:
+ {
+ if (!bAutoFilterTested)
+ {
+ bAutoFilter = pDoc->HasAutoFilter( nPosX, nPosY, nTab );
+ bAutoFilterTested = sal_True;
+ }
+ if ( nWhich == SID_AUTO_FILTER )
+ {
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else if (pDoc->GetDPAtBlock(aDummy))
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
+ }
+ else
+ if (!bAutoFilter)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_UNFILTER:
+ {
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nStartTab, nEndTab;
+ sal_Bool bAnyQuery = false;
+
+ sal_Bool bSelected = (GetViewData()->GetSimpleArea(
+ nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
+ == SC_MARK_SIMPLE);
+
+ if ( bSelected )
+ {
+ if (nStartCol==nEndCol && nStartRow==nEndRow)
+ bSelected = false;
+ }
+ else
+ {
+ nStartCol = GetViewData()->GetCurX();
+ nStartRow = GetViewData()->GetCurY();
+ nStartTab = GetViewData()->GetTabNo();
+ }
+
+ ScDBData* pDBData = bSelected
+ ? pDoc->GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
+ : pDoc->GetDBAtCursor( nStartCol, nStartRow, nStartTab );
+
+ if ( pDBData )
+ {
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam );
+ if ( aParam.GetEntry(0).bDoQuery )
+ bAnyQuery = sal_True;
+ }
+
+ if ( !bAnyQuery )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DEFINE_DBNAME:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_TEXT_TO_COLUMNS:
+ {
+ ScRange aRange;
+ if ( !lcl_GetTextToColumnsRange( pData, aRange ) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
new file mode 100644
index 000000000000..06c960a8ac0a
--- /dev/null
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -0,0 +1,923 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "docsh.hxx"
+#include "reffact.hxx"
+#include "uiitems.hxx"
+#include "autoform.hxx"
+#include "autofmt.hxx"
+#include "cellsh.hxx"
+#include "attrdlg.hrc" // TP_ALIGNMENT
+#include "inputhdl.hxx"
+#include "editable.hxx"
+
+#include "scabstdlg.hxx"
+
+#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
+
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
+
+//------------------------------------------------------------------
+
+void ScCellShell::Execute( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ ScModule* pScMod = SC_MOD();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( IS_EDITMODE() )
+ {
+ switch ( nSlot )
+ {
+ // beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden
+ // (beim Schliessen des Dialogs wird StopEditShell gerufen)
+ case SID_OPENDLG_FUNCTION:
+ // inplace macht die EditShell Aerger...
+ //! kann nicht immer umgeschaltet werden ????
+ if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace())
+ pTabViewShell->SetDontSwitch(sal_True); // EditShell nicht abschalten
+ // kein break
+
+ case FID_CELL_FORMAT:
+ case SID_ENABLE_HYPHENATION:
+ case SID_DATA_SELECT:
+ case SID_OPENDLG_CONSOLIDATE:
+ case SID_OPENDLG_SOLVE:
+ case SID_OPENDLG_OPTSOLVER:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+
+ pTabViewShell->SetDontSwitch(false);
+
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch ( nSlot )
+ {
+
+
+
+ case SID_ATTR_SIZE://XXX ???
+ break;
+
+ case SID_STATUS_SELMODE:
+ if ( pReqArgs )
+ {
+ /* 0: STD Click hebt Sel auf
+ * 1: ER Click erweitert Selektion
+ * 2: ERG Click definiert weitere Selektion
+ */
+ sal_uInt16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue();
+
+ switch ( nMode )
+ {
+ case 1: nMode = KEY_SHIFT; break;
+ case 2: nMode = KEY_MOD1; break; // Control-Taste
+ case 0:
+ default:
+ nMode = 0;
+ }
+
+ pTabViewShell->LockModifiers( nMode );
+ }
+ else
+ {
+ // no arguments (also executed by double click on the status bar controller):
+ // advance to next selection mode
+
+ sal_uInt16 nModifiers = pTabViewShell->GetLockedModifiers();
+ switch ( nModifiers )
+ {
+ case KEY_SHIFT: nModifiers = KEY_MOD1; break; // EXT -> ADD
+ case KEY_MOD1: nModifiers = 0; break; // ADD -> STD
+ default: nModifiers = KEY_SHIFT; break; // STD -> EXT
+ }
+ pTabViewShell->LockModifiers( nModifiers );
+ }
+
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ rReq.Done();
+ break;
+
+ // SID_STATUS_SELMODE_NORM wird nicht benutzt ???
+
+ case SID_STATUS_SELMODE_NORM:
+ pTabViewShell->LockModifiers( 0 );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles:
+
+ case SID_STATUS_SELMODE_ERG:
+ if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 )
+ pTabViewShell->LockModifiers( 0 );
+ else
+ pTabViewShell->LockModifiers( KEY_MOD1 );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ case SID_STATUS_SELMODE_ERW:
+ if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT )
+ pTabViewShell->LockModifiers( 0 );
+ else
+ pTabViewShell->LockModifiers( KEY_SHIFT );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ case SID_ENTER_STRING:
+ {
+ if ( pReqArgs )
+ {
+ String aStr( ((const SfxStringItem&)pReqArgs->
+ Get( SID_ENTER_STRING )).GetValue() );
+
+ pTabViewShell->EnterData( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo(),
+ aStr );
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
+ if ( !pHdl || !pHdl->IsInEnterHandler() )
+ {
+ // UpdateInputHandler is needed after the cell content
+ // has changed, but if called from EnterHandler, UpdateInputHandler
+ // will be called later when moving the cursor.
+
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ rReq.Done();
+
+ // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
+ // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
+ // (GrabFocus passiert in KillEditView)
+ }
+ }
+ break;
+
+ case SID_INSERT_MATRIX:
+ {
+ if ( pReqArgs )
+ {
+ String aStr = ((const SfxStringItem&)pReqArgs->
+ Get( SID_INSERT_MATRIX )).GetValue();
+ pTabViewShell->EnterMatrix( aStr );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case FID_INPUTLINE_ENTER:
+ case FID_INPUTLINE_BLOCK:
+ case FID_INPUTLINE_MATRIX:
+ {
+ if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden
+ break;
+
+ const ScInputStatusItem* pStatusItem
+ = (const ScInputStatusItem*)&pReqArgs->
+ Get( FID_INPUTLINE_STATUS );
+
+ ScAddress aCursorPos = pStatusItem->GetPos();
+ String aString = pStatusItem->GetString();
+ const EditTextObject* pData = pStatusItem->GetEditData();
+ if (pData)
+ {
+ if (nSlot == FID_INPUTLINE_BLOCK)
+ {
+ pTabViewShell->EnterBlock( aString, pData );
+ }
+ else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, sal_True, pData );
+ }
+ else
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData );
+ }
+ }
+ else
+ {
+ if (nSlot == FID_INPUTLINE_ENTER)
+ {
+ if (
+ aCursorPos.Col() == GetViewData()->GetCurX() &&
+ aCursorPos.Row() == GetViewData()->GetCurY() &&
+ aCursorPos.Tab() == GetViewData()->GetTabNo()
+ )
+ {
+ SfxStringItem aItem( SID_ENTER_STRING, aString );
+
+ // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ const SfxPoolItem* aArgs[2];
+ aArgs[0] = &aItem;
+ aArgs[1] = NULL;
+ rBindings.Execute( SID_ENTER_STRING, aArgs );
+ }
+ else
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(),
+ aCursorPos.Row(),
+ aCursorPos.Tab(),
+ aString );
+ rReq.Done();
+ }
+ }
+ else if (nSlot == FID_INPUTLINE_BLOCK)
+ {
+ pTabViewShell->EnterBlock( aString, NULL );
+ rReq.Done();
+ }
+ else
+ {
+ pTabViewShell->EnterMatrix( aString );
+ rReq.Done();
+ }
+
+ }
+
+ // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
+ // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
+ // (GrabFocus passiert in KillEditView)
+ }
+ break;
+
+ case SID_OPENDLG_FUNCTION:
+ {
+ sal_uInt16 nId = SID_OPENDLG_FUNCTION;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_OPENDLG_CONSOLIDATE:
+ {
+ sal_uInt16 nId = ScConsolidateDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ case FID_CELL_FORMAT:
+ {
+ if ( pReqArgs != NULL )
+ {
+ //----------------------------------
+ // Zellattribute ohne Dialog setzen:
+ //----------------------------------
+ SfxItemSet* pEmptySet =
+ new SfxItemSet( *pReqArgs->GetPool(),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+
+ SfxItemSet* pNewSet =
+ new SfxItemSet( *pReqArgs->GetPool(),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+
+ const SfxPoolItem* pAttr = NULL;
+ sal_uInt16 nWhich = 0;
+
+ for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
+ if ( pReqArgs->GetItemState( nWhich, sal_True, &pAttr ) == SFX_ITEM_SET )
+ pNewSet->Put( *pAttr );
+
+ pTabViewShell->ApplyAttributes( pNewSet, pEmptySet );
+
+ delete pNewSet;
+ delete pEmptySet;
+
+ rReq.Done();
+ }
+ else if ( pReqArgs == NULL )
+ {
+ pTabViewShell->ExecuteCellFormatDlg( rReq );
+ }
+ }
+ break;
+
+ case SID_ENABLE_HYPHENATION:
+ pTabViewShell->ExecuteCellFormatDlg( rReq, TP_ALIGNMENT );
+ break;
+
+ case SID_OPENDLG_SOLVE:
+ {
+ sal_uInt16 nId = ScSolverDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ case SID_OPENDLG_OPTSOLVER:
+ {
+ sal_uInt16 nId = ScOptSolverDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ case SID_OPENDLG_TABOP:
+ {
+ sal_uInt16 nId = ScTabOpDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ case SID_SCENARIOS:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ if ( pDoc->IsScenario(nTab) )
+ {
+ rMark.MarkToMulti();
+ if ( rMark.IsMultiMarked() )
+ {
+ if ( rReq.IsAPI()
+ || RET_YES ==
+ QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ).
+ Execute() )
+ {
+ pTabViewShell->ExtendScenario();
+ rReq.Done();
+ }
+ }
+ else if( ! rReq.IsAPI() )
+ {
+ ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_NOAREASELECTED) );
+ aErrorBox.Execute();
+ }
+ }
+ else
+ {
+ rMark.MarkToMulti();
+ if ( rMark.IsMultiMarked() )
+ {
+ SCTAB i=1;
+ String aBaseName;
+ String aName;
+ String aComment;
+ Color aColor;
+ sal_uInt16 nFlags;
+
+ pDoc->GetName( nTab, aBaseName );
+ aBaseName += '_';
+ aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
+ aBaseName += '_';
+
+ // vorneweg testen, ob der Prefix als gueltig erkannt wird
+ // wenn nicht, nur doppelte vermeiden
+ sal_Bool bPrefix = pDoc->ValidTabName( aBaseName );
+ DBG_ASSERT(bPrefix, "ungueltiger Tabellenname");
+
+ while ( pDoc->IsScenario(nTab+i) )
+ i++;
+
+ sal_Bool bValid;
+ SCTAB nDummy;
+ do
+ {
+ aName = aBaseName;
+ aName += String::CreateFromInt32( i );
+ if (bPrefix)
+ bValid = pDoc->ValidNewTabName( aName );
+ else
+ bValid = !pDoc->GetTable( aName, nDummy );
+ ++i;
+ }
+ while ( !bValid && i <= 2*MAXTAB );
+
+ if ( pReqArgs != NULL )
+ {
+ String aArgName;
+ String aArgComment;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_SCENARIOS, sal_True, &pItem ) == SFX_ITEM_SET )
+ aArgName = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, sal_True, &pItem ) == SFX_ITEM_SET )
+ aArgComment = ((const SfxStringItem*)pItem)->GetValue();
+
+ aColor = Color( COL_LIGHTGRAY ); // Default
+ nFlags = 0; // nicht-TwoWay
+
+ pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ sal_Bool bSheetProtected = pDoc->IsTabProtected(nTab);
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, false,bSheetProtected);
+ DBG_ASSERT(pNewDlg, "Dialog create fail!");
+ if ( pNewDlg->Execute() == RET_OK )
+ {
+ pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
+ pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
+
+ rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
+ rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
+ rReq.Done();
+ }
+ delete pNewDlg;
+ }
+ }
+ else if( ! rReq.IsAPI() )
+ {
+ pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
+ }
+ }
+ }
+ break;
+
+
+ case SID_SELECTALL:
+ {
+ pTabViewShell->SelectAll();
+ rReq.Done();
+ }
+ break;
+
+ //----------------------------------------------------------------
+
+ case FID_ROW_HEIGHT:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT,
+ sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ ScViewData* pData = GetViewData();
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+ sal_uInt16 nCurHeight = pData->GetDocument()->
+ GetRowHeight( pData->GetCurY(),
+ pData->GetTabNo() );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
+ nCurHeight,
+ ScGlobal::nStdRowHeight,
+ RID_SCDLG_ROW_MAN,
+ eMetric,
+ 2,
+ MAX_COL_HEIGHT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, (sal_uInt16)nVal );
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_ROW_OPT_HEIGHT:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL,
+ sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
+ ScGlobal::nLastRowHeightExtra,
+ 0,
+ RID_SCDLG_ROW_OPT,
+ eMetric,
+ 1,
+ MAX_EXTRA_HEIGHT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
+ ScGlobal::nLastRowHeightExtra = nVal;
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_WIDTH:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT,
+ sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+ ScViewData* pData = GetViewData();
+ sal_uInt16 nCurHeight = pData->GetDocument()->
+ GetColWidth( pData->GetCurX(),
+ pData->GetTabNo() );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
+ nCurHeight,
+ STD_COL_WIDTH,
+ RID_SCDLG_COL_MAN,
+ eMetric,
+ 2,
+ MAX_COL_WIDTH);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, (sal_uInt16)nVal );
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal)) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_OPT_WIDTH:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL,
+ sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
+ ScGlobal::nLastColWidthExtra,
+ STD_EXTRA_WIDTH,
+ RID_SCDLG_COL_OPT,
+ eMetric,
+ 1,
+ MAX_EXTRA_WIDTH);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, (sal_uInt16)nVal );
+ ScGlobal::nLastColWidthExtra = nVal;
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (sal_uInt16)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_OPT_DIRECT:
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
+ rReq.Done();
+ break;
+
+ case FID_ROW_HIDE:
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, 0 );
+ rReq.Done();
+ break;
+ case FID_ROW_SHOW:
+ pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_SHOW, 0 );
+ rReq.Done();
+ break;
+ case FID_COL_HIDE:
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_DIRECT, 0 );
+ rReq.Done();
+ break;
+ case FID_COL_SHOW:
+ pTabViewShell->SetMarkedWidthOrHeight( sal_True, SC_SIZE_SHOW, 0 );
+ rReq.Done();
+ break;
+
+ //----------------------------------------------------------------
+
+
+ case SID_CELL_FORMAT_RESET:
+ {
+ pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
+ rReq.Done();
+ }
+ break;
+
+ case FID_MERGE_ON:
+ case FID_MERGE_OFF:
+ case FID_MERGE_TOGGLE:
+ {
+ if ( !GetViewData()->GetDocument()->GetChangeTrack() )
+ {
+ // test whether to merge or to split
+ bool bMerge = false;
+ sal_Bool bCenter = false;
+ switch( nSlot )
+ {
+ case FID_MERGE_ON:
+ bMerge = true;
+ break;
+ case FID_MERGE_OFF:
+ bMerge = false;
+ break;
+ case FID_MERGE_TOGGLE:
+ {
+ bCenter = true;
+ SfxPoolItem* pItem = 0;
+ if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT )
+ bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
+ }
+ break;
+ }
+
+ if( bMerge )
+ {
+ // merge - check if to move contents of covered cells
+ sal_Bool bMoveContents = false;
+ sal_Bool bApi = rReq.IsAPI();
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
+ {
+ DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
+ bMoveContents = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+
+ if (pTabViewShell->MergeCells( bApi, bMoveContents, true, bCenter ))
+ {
+ if (!bApi && bMoveContents) // "ja" im Dialog geklickt
+ rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ // split cells
+ if (pTabViewShell->RemoveMerge())
+ {
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case SID_AUTOFORMAT:
+ {
+ Window* pDlgParent = pTabViewShell->GetDialogParent();
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ pTabViewShell->MarkDataArea( sal_True );
+
+ GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
+ nEndCol,nEndRow,nEndTab );
+
+ if ( ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
+ && ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
+ {
+ if ( pReqArgs )
+ {
+ const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT );
+ ScAutoFormat* pFormat = ScGlobal::GetAutoFormat();
+ sal_uInt16 nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() );
+
+ pTabViewShell->AutoFormat( nIndex );
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ ScGlobal::ClearAutoFormat();
+ ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if ( !aTester.IsEditable() )
+ {
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+ else
+ {
+ pTabViewShell->AutoFormat( pDlg->GetIndex() );
+
+ rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
+ rReq.Done();
+ }
+ }
+ delete pDlg;
+ delete pNewEntry;
+ }
+ }
+ else
+ ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute();
+ }
+ break;
+
+ case SID_CANCEL:
+ {
+ if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
+ pScMod->InputCancelHandler();
+ else if (pTabViewShell->HasPaintBrush())
+ pTabViewShell->ResetBrushDocument(); // abort format paint brush
+ else if (pTabViewShell->HasHintWindow())
+ pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten
+ else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
+ ScViewUtil::SetFullScreen( *pTabViewShell, false );
+ else
+ {
+ // TODO/LATER: when is this code executed?
+ pTabViewShell->Escape();
+ }
+ }
+ break;
+
+ case SID_DATA_SELECT:
+ pTabViewShell->StartDataSelect();
+ break;
+
+ case SID_DETECTIVE_FILLMODE:
+ {
+ sal_Bool bOldMode = pTabViewShell->IsAuditShell();
+ pTabViewShell->SetAuditShell( !bOldMode );
+ pTabViewShell->Invalidate( nSlot );
+ }
+ break;
+
+ case SID_OPENDLG_CONDFRMT:
+ {
+ sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+
+ // ----------------------------------------------------------------
+
+ case FID_INPUTLINE_STATUS:
+ OSL_FAIL("Execute von InputLine-Status");
+ break;
+
+ case SID_STATUS_DOCPOS:
+ // Launch navigator.
+ GetViewData()->GetDispatcher().Execute(
+ SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ break;
+
+ case SID_MARKAREA:
+ // called from Basic at the hidden view to select a range in the visible view
+ OSL_FAIL("old slot SID_MARKAREA");
+ break;
+
+ default:
+ OSL_FAIL("Unbekannter Slot bei ScCellShell::Execute");
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh4.cxx b/sc/source/ui/view/cellsh4.cxx
new file mode 100644
index 000000000000..d5062793940d
--- /dev/null
+++ b/sc/source/ui/view/cellsh4.cxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/request.hxx>
+
+#include "cellsh.hxx"
+#include "tabvwsh.hxx"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+
+#include "vcl/svapp.hxx"
+
+//------------------------------------------------------------------
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
+
+
+void ScCellShell::ExecuteCursor( SfxRequest& rReq )
+{
+ ScViewData* pData = GetViewData();
+ ScTabViewShell* pTabViewShell = pData->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ SCsCOLROW nRepeat = 1;
+ sal_Bool bSel = false;
+ sal_Bool bKeep = false;
+
+ if ( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ nRepeat = static_cast<SCsCOLROW>(((const SfxInt16Item*)pItem)->GetValue());
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ bSel = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+ else
+ {
+ // evaluate locked selection mode
+
+ sal_uInt16 nLocked = pTabViewShell->GetLockedModifiers();
+ if ( nLocked & KEY_SHIFT )
+ bSel = sal_True; // EXT
+ else if ( nLocked & KEY_MOD1 )
+ {
+ // ADD mode: keep the selection, start a new block when marking with shift again
+ bKeep = true;
+ }
+ }
+
+ if (bSel)
+ {
+ switch (nSlotId)
+ {
+ case SID_CURSORDOWN:
+ rReq.SetSlot(SID_CURSORDOWN_SEL);
+ break;
+ case SID_CURSORUP:
+ rReq.SetSlot(SID_CURSORUP_SEL);
+ break;
+ case SID_CURSORRIGHT:
+ rReq.SetSlot(SID_CURSORRIGHT_SEL);
+ break;
+ case SID_CURSORLEFT:
+ rReq.SetSlot(SID_CURSORLEFT_SEL);
+ break;
+ case SID_CURSORPAGEDOWN:
+ rReq.SetSlot(SID_CURSORPAGEDOWN_SEL);
+ break;
+ case SID_CURSORPAGEUP:
+ rReq.SetSlot(SID_CURSORPAGEUP_SEL);
+ break;
+ case SID_CURSORPAGERIGHT:
+ rReq.SetSlot(SID_CURSORPAGERIGHT_SEL);
+ break;
+ case SID_CURSORPAGELEFT:
+ rReq.SetSlot(SID_CURSORPAGELEFT_SEL);
+ break;
+ case SID_CURSORBLKDOWN:
+ rReq.SetSlot(SID_CURSORBLKDOWN_SEL);
+ break;
+ case SID_CURSORBLKUP:
+ rReq.SetSlot(SID_CURSORBLKUP_SEL);
+ break;
+ case SID_CURSORBLKRIGHT:
+ rReq.SetSlot(SID_CURSORBLKRIGHT_SEL);
+ break;
+ case SID_CURSORBLKLEFT:
+ rReq.SetSlot(SID_CURSORBLKLEFT_SEL);
+ break;
+ default:
+ ;
+ }
+ ExecuteCursorSel(rReq);
+ return;
+ }
+
+ SCsCOLROW nRTLSign = 1;
+ if ( pData->GetDocument()->IsLayoutRTL( pData->GetTabNo() ) )
+ {
+ //! evaluate cursor movement option?
+ nRTLSign = -1;
+ }
+
+ // einmal extra, damit der Cursor bei ExecuteInputDirect nicht zuoft gemalt wird:
+ pTabViewShell->HideAllCursors();
+
+ //OS: einmal fuer alle wird doch reichen!
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_CURSORDOWN:
+ pTabViewShell->MoveCursorRel( 0, nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKDOWN:
+ pTabViewShell->MoveCursorArea( 0, nRepeat, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORUP:
+ pTabViewShell->MoveCursorRel( 0, -nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKUP:
+ pTabViewShell->MoveCursorArea( 0, -nRepeat, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORLEFT:
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKLEFT:
+ pTabViewShell->MoveCursorArea( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORRIGHT:
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKRIGHT:
+ pTabViewShell->MoveCursorArea( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGEDOWN:
+ pTabViewShell->MoveCursorPage( 0, nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGEUP:
+ pTabViewShell->MoveCursorPage( 0, -nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGERIGHT_: //XXX !!!
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGELEFT_: //XXX !!!
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(-nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ default:
+ OSL_FAIL("Unbekannte Message bei ViewShell (Cursor)");
+ return;
+ }
+
+ pTabViewShell->ShowAllCursors();
+
+ rReq.AppendItem( SfxInt16Item(FN_PARAM_1, static_cast<sal_Int16>(nRepeat)) );
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) );
+ rReq.Done();
+}
+
+void ScCellShell::GetStateCursor( SfxItemSet& /* rSet */ )
+{
+}
+
+void ScCellShell::ExecuteCursorSel( SfxRequest& rReq )
+{
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
+ ScInputHandler* pInputHdl = pViewShell->GetInputHandler();
+ pViewShell->HideAllCursors();
+ if (pInputHdl && pInputHdl->IsInputMode())
+ {
+ // the current cell is in edit mode. Commit the text before moving on.
+ pViewShell->ExecuteInputDirect();
+ }
+
+ // Horizontal direction depends on whether or not the UI language is RTL.
+ SCsCOL nMovX = 1;
+ if (GetViewData()->GetDocument()->IsLayoutRTL(GetViewData()->GetTabNo()))
+ // mirror horizontal movement for right-to-left mode.
+ nMovX = -1;
+
+ switch (nSlotId)
+ {
+ case SID_CURSORDOWN_SEL:
+ pViewShell->ExpandBlock(0, 1, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORUP_SEL:
+ pViewShell->ExpandBlock(0, -1, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORRIGHT_SEL:
+ pViewShell->ExpandBlock(nMovX, 0, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORLEFT_SEL:
+ pViewShell->ExpandBlock(-nMovX, 0, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORPAGEUP_SEL:
+ pViewShell->ExpandBlockPage(0, -1);
+ break;
+ case SID_CURSORPAGEDOWN_SEL:
+ pViewShell->ExpandBlockPage(0, 1);
+ break;
+ case SID_CURSORPAGERIGHT_SEL:
+ pViewShell->ExpandBlockPage(nMovX, 0);
+ break;
+ case SID_CURSORPAGELEFT_SEL:
+ pViewShell->ExpandBlockPage(-nMovX, 0);
+ break;
+ case SID_CURSORBLKDOWN_SEL:
+ pViewShell->ExpandBlockArea(0, 1);
+ break;
+ case SID_CURSORBLKUP_SEL:
+ pViewShell->ExpandBlockArea(0, -1);
+ break;
+ case SID_CURSORBLKRIGHT_SEL:
+ pViewShell->ExpandBlockArea(nMovX, 0);
+ break;
+ case SID_CURSORBLKLEFT_SEL:
+ pViewShell->ExpandBlockArea(-nMovX, 0);
+ break;
+ default:
+ ;
+ }
+ pViewShell->ShowAllCursors();
+}
+
+void ScCellShell::ExecuteMove( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+
+ if(nSlotId != SID_CURSORTOPOFSCREEN && nSlotId != SID_CURSORENDOFSCREEN)
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_NEXT_TABLE:
+ case SID_NEXT_TABLE_SEL:
+ pTabViewShell->SelectNextTab( 1, (nSlotId == SID_NEXT_TABLE_SEL) );
+ break;
+
+ case SID_PREV_TABLE:
+ case SID_PREV_TABLE_SEL:
+ pTabViewShell->SelectNextTab( -1, (nSlotId == SID_PREV_TABLE_SEL) );
+ break;
+
+ // Cursorbewegungen in Bloecken gehen nicht von Basic aus,
+ // weil das ScSbxRange-Objekt bei Eingaben die Markierung veraendert
+
+ case SID_NEXT_UNPROTECT:
+ pTabViewShell->FindNextUnprot( false, !rReq.IsAPI() );
+ break;
+
+ case SID_PREV_UNPROTECT:
+ pTabViewShell->FindNextUnprot( sal_True, !rReq.IsAPI() );
+ break;
+
+ case SID_CURSORENTERUP:
+ if (rReq.IsAPI())
+ pTabViewShell->MoveCursorRel( 0, -1, SC_FOLLOW_LINE, false );
+ else
+ pTabViewShell->MoveCursorEnter( sal_True );
+ break;
+
+ case SID_CURSORENTERDOWN:
+ if (rReq.IsAPI())
+ pTabViewShell->MoveCursorRel( 0, 1, SC_FOLLOW_LINE, false );
+ else
+ pTabViewShell->MoveCursorEnter( false );
+ break;
+
+ case SID_SELECT_COL:
+ pTabViewShell->MarkColumns();
+ break;
+
+ case SID_SELECT_ROW:
+ pTabViewShell->MarkRows();
+ break;
+
+ case SID_SELECT_NONE:
+ pTabViewShell->Unmark();
+ break;
+
+ case SID_ALIGNCURSOR:
+ pTabViewShell->AlignToCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), SC_FOLLOW_JUMP );
+ break;
+
+ case SID_MARKDATAAREA:
+ pTabViewShell->MarkDataArea();
+ break;
+
+ case SID_MARKARRAYFORMULA:
+ pTabViewShell->MarkMatrixFormula();
+ break;
+
+ case SID_SETINPUTMODE:
+ SC_MOD()->SetInputMode( SC_INPUT_TABLE );
+ break;
+
+ case SID_FOCUS_INPUTLINE:
+ {
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
+ if (pHdl)
+ {
+ ScInputWindow* pWin = pHdl->GetInputWindow();
+ if (pWin)
+ pWin->SwitchToTextWin();
+ }
+ }
+ break;
+
+ case SID_CURSORTOPOFSCREEN:
+ pTabViewShell->MoveCursorScreen( 0, -1, SC_FOLLOW_LINE, false );
+ break;
+
+ case SID_CURSORENDOFSCREEN:
+ pTabViewShell->MoveCursorScreen( 0, 1, SC_FOLLOW_LINE, false );
+ break;
+
+ default:
+ OSL_FAIL("Unbekannte Message bei ViewShell (Cursor)");
+ return;
+ }
+
+ rReq.Done();
+}
+
+void ScCellShell::ExecutePageSel( SfxRequest& rReq )
+{
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ switch ( nSlotId )
+ {
+ case SID_CURSORHOME_SEL: rReq.SetSlot( SID_CURSORHOME ); break;
+ case SID_CURSOREND_SEL: rReq.SetSlot( SID_CURSOREND ); break;
+ case SID_CURSORTOPOFFILE_SEL: rReq.SetSlot( SID_CURSORTOPOFFILE ); break;
+ case SID_CURSORENDOFFILE_SEL: rReq.SetSlot( SID_CURSORENDOFFILE ); break;
+ default:
+ OSL_FAIL("Unbekannte Message bei ViewShell (ExecutePageSel)");
+ return;
+ }
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, sal_True) );
+ ExecuteSlot( rReq, GetInterface() );
+}
+
+void ScCellShell::ExecutePage( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ sal_Bool bSel = false;
+ sal_Bool bKeep = false;
+
+ if ( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ bSel = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+ else
+ {
+ // evaluate locked selection mode
+
+ sal_uInt16 nLocked = pTabViewShell->GetLockedModifiers();
+ if ( nLocked & KEY_SHIFT )
+ bSel = sal_True; // EXT
+ else if ( nLocked & KEY_MOD1 )
+ {
+ // ADD mode: keep the selection, start a new block when marking with shift again
+ bKeep = true;
+ }
+ }
+
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_CURSORHOME:
+ pTabViewShell->MoveCursorEnd( -1, 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSOREND:
+ pTabViewShell->MoveCursorEnd( 1, 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORTOPOFFILE:
+ pTabViewShell->MoveCursorEnd( -1, -1, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORENDOFFILE:
+ pTabViewShell->MoveCursorEnd( 1, 1, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ default:
+ OSL_FAIL("Unbekannte Message bei ViewShell (ExecutePage)");
+ return;
+ }
+
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) );
+ rReq.Done();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx
new file mode 100644
index 000000000000..0f24a98e2bf4
--- /dev/null
+++ b/sc/source/ui/view/colrowba.cxx
@@ -0,0 +1,416 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdtrans.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "colrowba.hxx"
+#include "document.hxx"
+#include "scmod.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "appoptio.hxx"
+#include "globstr.hrc"
+
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+String lcl_MetricString( long nTwips, const String& rText )
+{
+ if ( nTwips <= 0 )
+ return ScGlobal::GetRscString(STR_TIP_HIDE);
+ else
+ {
+ FieldUnit eUserMet = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ sal_Int64 nUserVal = MetricField::ConvertValue( nTwips*100, 1, 2, FUNIT_TWIP, eUserMet );
+
+ String aStr = rText;
+ aStr += ' ';
+ aStr += ScGlobal::pLocaleData->getNum( nUserVal, 2 );
+ aStr += ' ';
+ aStr += SdrFormatter::GetUnitStr(eUserMet);
+
+ return aStr;
+ }
+}
+
+//==================================================================
+
+ScColBar::ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) :
+ ScHeaderControl( pParent, pEng, MAXCOL+1, HDR_HORIZONTAL ),
+ pViewData( pData ),
+ eWhich( eWhichPos ),
+ pFuncSet( pFunc ),
+ pSelEngine( pEng )
+{
+ Show();
+}
+
+ScColBar::~ScColBar()
+{
+}
+
+inline sal_Bool ScColBar::UseNumericHeader() const
+{
+ return pViewData->GetDocument()->GetAddressConvention() == formula::FormulaGrammar::CONV_XL_R1C1;
+}
+
+SCCOLROW ScColBar::GetPos()
+{
+ return pViewData->GetPosX(eWhich);
+}
+
+sal_uInt16 ScColBar::GetEntrySize( SCCOLROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab))
+ return 0;
+ else
+ return (sal_uInt16) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), pViewData->GetPPTX() );
+}
+
+String ScColBar::GetEntryText( SCCOLROW nEntryNo )
+{
+ return UseNumericHeader()
+ ? String::CreateFromInt32( nEntryNo + 1 )
+ : ScColToAlpha( static_cast<SCCOL>(nEntryNo) );
+}
+
+void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
+{
+ sal_uInt16 nSizeTwips;
+ ScSizeMode eMode = SC_SIZE_DIRECT;
+ if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel)
+
+ if ( nNewSize == HDR_SIZE_OPTIMUM )
+ {
+ nSizeTwips = STD_EXTRA_WIDTH;
+ eMode = SC_SIZE_OPTIMAL;
+ }
+ else
+ nSizeTwips = (sal_uInt16) ( nNewSize / pViewData->GetPPTX() );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ SCCOLROW* pRanges = new SCCOLROW[MAXCOL+1];
+ SCCOL nRangeCnt = 0;
+ if ( rMark.IsColumnMarked( static_cast<SCCOL>(nPos) ) )
+ {
+ SCCOL nStart = 0;
+ while (nStart<=MAXCOL)
+ {
+ while (nStart<MAXCOL && !rMark.IsColumnMarked(nStart))
+ ++nStart;
+ if (rMark.IsColumnMarked(nStart))
+ {
+ SCCOL nEnd = nStart;
+ while (nEnd<MAXCOL && rMark.IsColumnMarked(nEnd))
+ ++nEnd;
+ if (!rMark.IsColumnMarked(nEnd))
+ --nEnd;
+ pRanges[static_cast<size_t>(2*nRangeCnt) ] = nStart;
+ pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
+ ++nRangeCnt;
+ nStart = nEnd+1;
+ }
+ else
+ nStart = MAXCOL+1;
+ }
+ }
+ else
+ {
+ pRanges[0] = nPos;
+ pRanges[1] = nPos;
+ nRangeCnt = 1;
+ }
+
+ pViewData->GetView()->SetWidthOrHeight( sal_True, nRangeCnt, pRanges, eMode, nSizeTwips );
+ delete[] pRanges;
+}
+
+void ScColBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
+{
+ SCCOLROW nRange[2];
+ nRange[0] = nStart;
+ nRange[1] = nEnd;
+ pViewData->GetView()->SetWidthOrHeight( sal_True, 1, nRange, SC_SIZE_DIRECT, 0 );
+}
+
+void ScColBar::SetMarking( sal_Bool bSet )
+{
+ pViewData->GetMarkData().SetMarking( bSet );
+ if (!bSet)
+ {
+ pViewData->GetView()->UpdateAutoFillMark();
+ }
+}
+
+void ScColBar::SelectWindow()
+{
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ pViewSh->SetActive(); // Appear und SetViewFrame
+ pViewSh->DrawDeselectAll();
+
+ ScSplitPos eActive = pViewData->GetActivePart();
+ if (eWhich==SC_SPLIT_LEFT)
+ {
+ if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_TOPLEFT;
+ if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_BOTTOMLEFT;
+ }
+ else
+ {
+ if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_TOPRIGHT;
+ if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_BOTTOMRIGHT;
+ }
+ pViewSh->ActivatePart( eActive );
+
+ pFuncSet->SetColumn( sal_True );
+ pFuncSet->SetWhich( eActive );
+
+ pViewSh->ActiveGrabFocus();
+}
+
+sal_Bool ScColBar::IsDisabled()
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->IsFormulaMode() || pScMod->IsModalMode();
+}
+
+sal_Bool ScColBar::ResizeAllowed()
+{
+ return !pViewData->HasEditView( pViewData->GetActivePart() );
+}
+
+void ScColBar::DrawInvert( long nDragPosP )
+{
+ Rectangle aRect( nDragPosP,0, nDragPosP+HDR_SLIDERSIZE-1,GetOutputSizePixel().Width()-1 );
+ Update();
+ Invert(aRect);
+
+ pViewData->GetView()->InvertVertical(eWhich,nDragPosP);
+}
+
+String ScColBar::GetDragHelp( long nVal )
+{
+ long nTwips = (long) ( nVal / pViewData->GetPPTX() );
+ return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_WIDTH) );
+}
+
+sal_Bool ScColBar::IsLayoutRTL() // overloaded only for columns
+{
+ return pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+}
+
+//==================================================================
+
+ScRowBar::ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) :
+ ScHeaderControl( pParent, pEng, MAXROW+1, HDR_VERTICAL ),
+ pViewData( pData ),
+ eWhich( eWhichPos ),
+ pFuncSet( pFunc ),
+ pSelEngine( pEng )
+{
+ Show();
+}
+
+ScRowBar::~ScRowBar()
+{
+}
+
+SCCOLROW ScRowBar::GetPos()
+{
+ return pViewData->GetPosY(eWhich);
+}
+
+sal_uInt16 ScRowBar::GetEntrySize( SCCOLROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCROW nLastRow = -1;
+ if (pDoc->RowHidden(nEntryNo, nTab, NULL, &nLastRow))
+ return 0;
+ else
+ return (sal_uInt16) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo,
+ nTab ), pViewData->GetPPTY() );
+}
+
+String ScRowBar::GetEntryText( SCCOLROW nEntryNo )
+{
+ return String::CreateFromInt32( nEntryNo + 1 );
+}
+
+void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize )
+{
+ sal_uInt16 nSizeTwips;
+ ScSizeMode eMode = SC_SIZE_DIRECT;
+ if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel)
+
+ if ( nNewSize == HDR_SIZE_OPTIMUM )
+ {
+ nSizeTwips = 0;
+ eMode = SC_SIZE_OPTIMAL;
+ }
+ else
+ nSizeTwips = (sal_uInt16) ( nNewSize / pViewData->GetPPTY() );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ SCCOLROW* pRanges = new SCCOLROW[MAXROW+1];
+ SCROW nRangeCnt = 0;
+ if ( rMark.IsRowMarked( nPos ) )
+ {
+ SCROW nStart = 0;
+ while (nStart<=MAXROW)
+ {
+ while (nStart<MAXROW && !rMark.IsRowMarked(nStart))
+ ++nStart;
+ if (rMark.IsRowMarked(nStart))
+ {
+ SCROW nEnd = nStart;
+ while (nEnd<MAXROW && rMark.IsRowMarked(nEnd))
+ ++nEnd;
+ if (!rMark.IsRowMarked(nEnd))
+ --nEnd;
+ pRanges[static_cast<size_t>(2*nRangeCnt) ] = nStart;
+ pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
+ ++nRangeCnt;
+ nStart = nEnd+1;
+ }
+ else
+ nStart = MAXROW+1;
+ }
+ }
+ else
+ {
+ pRanges[0] = nPos;
+ pRanges[1] = nPos;
+ nRangeCnt = 1;
+ }
+
+ pViewData->GetView()->SetWidthOrHeight( false, nRangeCnt, pRanges, eMode, nSizeTwips );
+ delete[] pRanges;
+}
+
+void ScRowBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
+{
+ SCCOLROW nRange[2];
+ nRange[0] = nStart;
+ nRange[1] = nEnd;
+ pViewData->GetView()->SetWidthOrHeight( false, 1, nRange, SC_SIZE_DIRECT, 0 );
+}
+
+void ScRowBar::SetMarking( sal_Bool bSet )
+{
+ pViewData->GetMarkData().SetMarking( bSet );
+ if (!bSet)
+ {
+ pViewData->GetView()->UpdateAutoFillMark();
+ }
+}
+
+void ScRowBar::SelectWindow()
+{
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ pViewSh->SetActive(); // Appear und SetViewFrame
+ pViewSh->DrawDeselectAll();
+
+ ScSplitPos eActive = pViewData->GetActivePart();
+ if (eWhich==SC_SPLIT_TOP)
+ {
+ if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_TOPLEFT;
+ if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_TOPRIGHT;
+ }
+ else
+ {
+ if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_BOTTOMLEFT;
+ if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_BOTTOMRIGHT;
+ }
+ pViewSh->ActivatePart( eActive );
+
+ pFuncSet->SetColumn( false );
+ pFuncSet->SetWhich( eActive );
+
+ pViewSh->ActiveGrabFocus();
+}
+
+sal_Bool ScRowBar::IsDisabled()
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->IsFormulaMode() || pScMod->IsModalMode();
+}
+
+sal_Bool ScRowBar::ResizeAllowed()
+{
+ return !pViewData->HasEditView( pViewData->GetActivePart() );
+}
+
+void ScRowBar::DrawInvert( long nDragPosP )
+{
+ Rectangle aRect( 0,nDragPosP, GetOutputSizePixel().Width()-1,nDragPosP+HDR_SLIDERSIZE-1 );
+ Update();
+ Invert(aRect);
+
+ pViewData->GetView()->InvertHorizontal(eWhich,nDragPosP);
+}
+
+String ScRowBar::GetDragHelp( long nVal )
+{
+ long nTwips = (long) ( nVal / pViewData->GetPPTY() );
+ return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_HEIGHT) );
+}
+
+// GetHiddenCount ist nur fuer Zeilen ueberladen
+
+SCROW ScRowBar::GetHiddenCount( SCROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ return pDoc->GetHiddenRowCount( nEntryNo, nTab );
+}
+
+sal_Bool ScRowBar::IsMirrored() // overloaded only for rows
+{
+ return pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
new file mode 100644
index 000000000000..453bc59f1304
--- /dev/null
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -0,0 +1,538 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+#include "dbfunc.hxx"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "sc.hrc"
+#include "undodat.hxx"
+#include "dbcolect.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "dbdocfun.hxx"
+#include "editable.hxx"
+
+//==================================================================
+
+ScDBFunc::ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
+ ScViewFunc( pParent, rDocSh, pViewShell )
+{
+}
+
+ScDBFunc::~ScDBFunc()
+{
+}
+
+//
+// Hilfsfunktionen
+//
+
+void ScDBFunc::GotoDBArea( const String& rDBName )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBCollection* pDBCol = pDoc->GetDBCollection();
+
+ sal_uInt16 nFoundAt = 0;
+ if ( pDBCol->SearchName( rDBName, nFoundAt ) )
+ {
+ ScDBData* pData = (*pDBCol)[nFoundAt];
+ DBG_ASSERT( pData, "GotoDBArea: Datenbankbereich nicht gefunden!" );
+
+ if ( pData )
+ {
+ SCTAB nTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ SetTabNo( nTab );
+
+ MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ),
+ false, false ); // bShift,bControl
+ DoneBlockMode();
+ InitBlockMode( nStartCol, nStartRow, nTab );
+ MarkCursor( nEndCol, nEndRow, nTab );
+ SelectionChanged();
+ }
+ }
+}
+
+// aktuellen Datenbereich fuer Sortieren / Filtern suchen
+
+ScDBData* ScDBFunc::GetDBData( bool bMark, ScGetDBMode eMode, ScGetDBSelection eSel )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDBData* pData = NULL;
+ ScRange aRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea(aRange);
+ if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
+ {
+ bool bShrinkColumnsOnly = false;
+ if (eSel == SC_DBSEL_ROW_DOWN)
+ {
+ // Don't alter row range, additional rows may have been selected on
+ // purpose to append data, or to have a fake header row.
+ bShrinkColumnsOnly = true;
+ // Select further rows only if only one row or a portion thereof is
+ // selected.
+ if (aRange.aStart.Row() != aRange.aEnd.Row())
+ {
+ // If an area is selected shrink that to the actual used
+ // columns, don't draw filter buttons for empty columns.
+ eSel = SC_DBSEL_SHRINK_TO_USED_DATA;
+ }
+ else if (aRange.aStart.Col() == aRange.aEnd.Col())
+ {
+ // One cell only, if it is not marked obtain entire used data
+ // area.
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if (!(rMarkData.IsMarked() || rMarkData.IsMultiMarked()))
+ eSel = SC_DBSEL_KEEP;
+ }
+ }
+ switch (eSel)
+ {
+ case SC_DBSEL_SHRINK_TO_SHEET_DATA:
+ {
+ // Shrink the selection to sheet data area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ case SC_DBSEL_SHRINK_TO_USED_DATA:
+ case SC_DBSEL_ROW_DOWN:
+ {
+ // Shrink the selection to actual used area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ bool bShrunk;
+ pDoc->ShrinkToUsedDataArea( bShrunk, aRange.aStart.Tab(),
+ nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly);
+ if (bShrunk)
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ default:
+ ; // nothing
+ }
+ pData = pDocSh->GetDBData( aRange, eMode, eSel );
+ }
+ else if ( eMode != SC_DB_OLD )
+ pData = pDocSh->GetDBData(
+ ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() ),
+ eMode, SC_DBSEL_KEEP );
+
+ if (!pData)
+ return NULL;
+
+ if (bMark)
+ {
+ ScRange aFound;
+ pData->GetArea(aFound);
+ MarkRange( aFound, false );
+ }
+ return pData;
+}
+
+ScDBData* ScDBFunc::GetAnonymousDBData()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScRange aRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea(aRange);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ return NULL;
+
+ // Expand to used data area if not explicitly marked.
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if (!rMarkData.IsMarked() && !rMarkData.IsMultiMarked())
+ {
+ SCCOL nCol1 = aRange.aStart.Col();
+ SCCOL nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row();
+ SCROW nRow2 = aRange.aEnd.Row();
+ pDocSh->GetDocument()->GetDataArea(aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2, false, false);
+ aRange.aStart.SetCol(nCol1);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aEnd.SetRow(nRow2);
+ }
+
+ return pDocSh->GetAnonymousDBData(aRange);
+}
+
+// Datenbankbereiche aendern (Dialog)
+
+void ScDBFunc::NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList )
+{
+
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocShell );
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDBCollection* pOldColl = pDoc->GetDBCollection();
+ ScDBCollection* pUndoColl = NULL;
+ ScDBCollection* pRedoColl = NULL;
+ const sal_Bool bRecord (pDoc->IsUndoEnabled());
+
+ long nDelCount = rDelAreaList.Count();
+ for (long nDelPos=0; nDelPos<nDelCount; nDelPos++)
+ {
+ ScRange* pEntry = (ScRange*) rDelAreaList.GetObject(nDelPos);
+
+ if ( pEntry )
+ {
+ ScAddress& rStart = pEntry->aStart;
+ ScAddress& rEnd = pEntry->aEnd;
+ pDocShell->DBAreaDeleted( rStart.Tab(),
+ rStart.Col(), rStart.Row(),
+ rEnd.Col(), rEnd.Row() );
+
+ // Targets am SBA abmelden nicht mehr noetig
+ }
+ }
+
+ if (bRecord)
+ pUndoColl = new ScDBCollection( *pOldColl );
+
+ // neue Targets am SBA anmelden nicht mehr noetig
+
+ pDoc->CompileDBFormula( sal_True ); // CreateFormulaString
+ pDoc->SetDBCollection( new ScDBCollection( rNewColl ) );
+ pDoc->CompileDBFormula( false ); // CompileFormulaString
+ pOldColl = NULL;
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+
+ if (bRecord)
+ {
+ pRedoColl = new ScDBCollection( rNewColl );
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( pDocShell, pUndoColl, pRedoColl ) );
+ }
+}
+
+//
+// wirkliche Funktionen
+//
+
+// Sortieren
+
+void ScDBFunc::UISort( const ScSortParam& rSortParam, sal_Bool bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rSortParam.nCol1, rSortParam.nRow1,
+ rSortParam.nCol2, rSortParam.nRow2 );
+ if (!pDBData)
+ {
+ OSL_FAIL( "Sort: keine DBData" );
+ return;
+ }
+
+ ScSubTotalParam aSubTotalParam;
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ if (aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly)
+ {
+ // Subtotals wiederholen, mit neuer Sortierung
+
+ DoSubTotals( aSubTotalParam, bRecord, &rSortParam );
+ }
+ else
+ {
+ Sort( rSortParam, bRecord ); // nur sortieren
+ }
+}
+
+void ScDBFunc::Sort( const ScSortParam& rSortParam, sal_Bool bRecord, sal_Bool bPaint )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBDocFunc aDBDocFunc( *pDocSh );
+ sal_Bool bSuccess = aDBDocFunc.Sort( nTab, rSortParam, bRecord, bPaint, false );
+ if ( bSuccess && !rSortParam.bInplace )
+ {
+ // Ziel markieren
+ ScRange aDestRange( rSortParam.nDestCol, rSortParam.nDestRow, rSortParam.nDestTab,
+ rSortParam.nDestCol + rSortParam.nCol2 - rSortParam.nCol1,
+ rSortParam.nDestRow + rSortParam.nRow2 - rSortParam.nRow1,
+ rSortParam.nDestTab );
+ MarkRange( aDestRange );
+ }
+}
+
+// Filtern
+
+void ScDBFunc::Query( const ScQueryParam& rQueryParam, const ScRange* pAdvSource, sal_Bool bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBDocFunc aDBDocFunc( *pDocSh );
+ sal_Bool bSuccess = aDBDocFunc.Query( nTab, rQueryParam, pAdvSource, bRecord, false );
+
+ if (bSuccess)
+ {
+ sal_Bool bCopy = !rQueryParam.bInplace;
+ if (bCopy)
+ {
+ // Zielbereich markieren (DB-Bereich wurde ggf. angelegt)
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDBData* pDestData = pDoc->GetDBAtCursor(
+ rQueryParam.nDestCol, rQueryParam.nDestRow,
+ rQueryParam.nDestTab, sal_True );
+ if (pDestData)
+ {
+ ScRange aDestRange;
+ pDestData->GetArea(aDestRange);
+ MarkRange( aDestRange );
+ }
+ }
+
+ if (!bCopy)
+ {
+ UpdateScrollBars();
+ SelectionChanged(); // for attribute states (filtered rows are ignored)
+ }
+
+ GetViewData()->GetBindings().Invalidate( SID_UNFILTER );
+ }
+}
+
+// Autofilter-Knoepfe ein-/ausblenden
+
+void ScDBFunc::ToggleAutoFilter()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScQueryParam aParam;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
+
+ pDBData->SetByRow( sal_True ); //! Undo, vorher abfragen ??
+ pDBData->GetQueryParam( aParam );
+
+
+ SCCOL nCol;
+ SCROW nRow = aParam.nRow1;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ sal_Int16 nFlag;
+ sal_Bool bHasAuto = sal_True;
+ sal_Bool bHeader = pDBData->HasHeader();
+ sal_Bool bPaint = false;
+
+ //! stattdessen aus DB-Bereich abfragen?
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+
+ if ( (nFlag & SC_MF_AUTO) == 0 )
+ bHasAuto = false;
+ }
+
+ if (bHasAuto) // aufheben
+ {
+ // Filterknoepfe ausblenden
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
+
+ // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation
+
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), false ) );
+
+ pDBData->SetAutoFilter(false);
+
+ // Filter aufheben (incl. Paint / Undo)
+
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aParam.GetEntry(i).bDoQuery = false;
+ aParam.bDuplicate = sal_True;
+ Query( aParam, NULL, sal_True );
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ bPaint = sal_True;
+ }
+ else // Filterknoepfe einblenden
+ {
+ if ( !pDoc->IsBlockEmpty( nTab,
+ aParam.nCol1, aParam.nRow1,
+ aParam.nCol2, aParam.nRow2 ) )
+ {
+ if (!bHeader)
+ {
+ if ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc"
+ ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile?
+ ).Execute() == RET_YES )
+ {
+ pDBData->SetHeader( sal_True ); //! Undo ??
+ bHeader = sal_True;
+ }
+ }
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), sal_True ) );
+
+ pDBData->SetAutoFilter(sal_True);
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) );
+ }
+ pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab,
+ PAINT_GRID );
+ bPaint = sal_True;
+ }
+ else
+ {
+ ErrorBox aErrorBox( GetViewData()->GetDialogParent(), WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) );
+ aErrorBox.Execute();
+ }
+ }
+
+ if ( bPaint )
+ {
+ aModificator.SetDocumentModified();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+ }
+}
+
+// nur ausblenden, keine Daten veraendern
+
+void ScDBFunc::HideAutoFilter()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ ScQueryParam aParam;
+ ScDBData* pDBData = GetDBData( false );
+
+ SCTAB nTab;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
+
+ for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
+ {
+ sal_Int16 nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), false ) );
+
+ pDBData->SetAutoFilter(false);
+
+ pDocSh->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+}
+
+// Re-Import
+
+sal_Bool ScDBFunc::ImportData( const ScImportParam& rParam, sal_Bool bRecord )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScEditableTester aTester( pDoc, GetViewData()->GetTabNo(), rParam.nCol1,rParam.nRow1,
+ rParam.nCol2,rParam.nRow2 );
+ if ( !aTester.IsEditable() )
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return false;
+ }
+
+ ScDBDocFunc aDBDocFunc( *GetViewData()->GetDocShell() );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet;
+ return aDBDocFunc.DoImport( GetViewData()->GetTabNo(), rParam, xResultSet, NULL, bRecord );
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc2.cxx b/sc/source/ui/view/dbfunc2.cxx
new file mode 100644
index 000000000000..5753eb1367c2
--- /dev/null
+++ b/sc/source/ui/view/dbfunc2.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include "dbfunc.hxx"
+#include "docsh.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+
+
+// STATIC DATA -----------------------------------------------------------
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+//==================================================================
+
+class ScDrawLayer;
+class ScChartCollection;
+
+void ScDBFunc::UpdateCharts( sal_Bool bAllCharts )
+{
+ sal_uInt16 nFound = 0;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ if ( pDoc->GetDrawLayer() )
+ nFound = DoUpdateCharts( ScAddress( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo()),
+ pDoc,
+ bAllCharts );
+
+ if ( !nFound && !bAllCharts )
+ ErrorMessage(STR_NOCHARTATCURSOR);
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
new file mode 100644
index 000000000000..ac4408238818
--- /dev/null
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -0,0 +1,2334 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "dbfunc.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/waitobj.hxx>
+#include <svl/zforlist.hxx>
+#include <sfx2/app.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/MemberResultFlags.hpp>
+#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
+#include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
+
+#include "global.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+#include "undotab.hxx"
+#include "undodat.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "docsh.hxx"
+#include "olinetab.hxx"
+#include "consoli.hxx"
+#include "olinefun.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpdimsave.hxx"
+#include "dbdocfun.hxx"
+#include "dpoutput.hxx"
+#include "dptabsrc.hxx"
+#include "dpshttab.hxx"
+#include "dpsdbtab.hxx"
+#include "editable.hxx"
+#include "docpool.hxx"
+#include "patattr.hxx"
+#include "unonames.hxx"
+#include "cell.hxx"
+#include "userlist.hxx"
+
+#include <boost/unordered_set.hpp>
+#include <boost/unordered_map.hpp>
+#include <memory>
+#include <list>
+#include <vector>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::sheet::XDimensionsSupplier;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::rtl::OUStringBuffer;
+using ::std::auto_ptr;
+using ::std::list;
+using ::std::vector;
+
+// STATIC DATA -----------------------------------------------------------
+
+
+//==================================================================
+
+//
+// Outliner
+//
+
+// Outline-Gruppierung erzeugen
+
+void ScDBFunc::MakeOutline( sal_Bool bColumns, sal_Bool bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.MakeOutline( aRange, bColumns, bRecord, false );
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// Outline-Gruppierung loeschen
+
+void ScDBFunc::RemoveOutline( sal_Bool bColumns, sal_Bool bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.RemoveOutline( aRange, bColumns, bRecord, false );
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// Menue-Status: Outlines loeschen
+
+void ScDBFunc::TestRemoveOutline( sal_Bool& rCol, sal_Bool& rRow )
+{
+ sal_Bool bColFound = false;
+ sal_Bool bRowFound = false;
+
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nStartTab, nEndTab;
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ SCTAB nTab = nStartTab;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ ScOutlineArray* pArray;
+ ScOutlineEntry* pEntry;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ sal_Bool bColMarked = ( nStartRow == 0 && nEndRow == MAXROW );
+ sal_Bool bRowMarked = ( nStartCol == 0 && nEndCol == MAXCOL );
+
+ // Spalten
+
+ if ( !bRowMarked || bColMarked ) // nicht wenn ganze Zeilen markiert
+ {
+ pArray = pTable->GetColArray();
+ ScSubOutlineIterator aColIter( pArray );
+ while ((pEntry=aColIter.GetNext()) != NULL && !bColFound)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStartCol<=static_cast<SCCOL>(nEnd) && nEndCol>=static_cast<SCCOL>(nStart) )
+ bColFound = sal_True;
+ }
+ }
+
+ // Zeilen
+
+ if ( !bColMarked || bRowMarked ) // nicht wenn ganze Spalten markiert
+ {
+ pArray = pTable->GetRowArray();
+ ScSubOutlineIterator aRowIter( pArray );
+ while ((pEntry=aRowIter.GetNext()) != NULL && !bRowFound)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStartRow<=nEnd && nEndRow>=nStart )
+ bRowFound = sal_True;
+ }
+ }
+ }
+ }
+
+ rCol = bColFound;
+ rRow = bRowFound;
+}
+
+void ScDBFunc::RemoveAllOutlines( sal_Bool bRecord )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ sal_Bool bOk = aFunc.RemoveAllOutlines( nTab, bRecord, false );
+ ShowCursor();
+
+ if (bOk)
+ UpdateScrollBars();
+}
+
+// Auto-Outlines
+
+void ScDBFunc::AutoOutline( sal_Bool bRecord )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab ); // ganze Tabelle, wenn nichts markiert
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ rMark.MarkToMulti();
+ rMark.GetMultiMarkArea( aRange );
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.AutoOutline( aRange, bRecord, false );
+}
+
+// Outline-Ebene auswaehlen
+
+void ScDBFunc::SelectLevel( sal_Bool bColumns, sal_uInt16 nLevel, sal_Bool bRecord, sal_Bool bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ sal_Bool bOk = aFunc.SelectLevel( nTab, bColumns, nLevel, bRecord, bPaint, false );
+ ShowCursor();
+
+ if (bOk)
+ UpdateScrollBars();
+}
+
+// einzelne Outline-Gruppe einblenden
+
+void ScDBFunc::ShowOutline( sal_Bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bRecord, sal_Bool bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ sal_Bool bOk = aFunc.ShowOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, false );
+ ShowCursor();
+
+ if ( bOk && bPaint )
+ UpdateScrollBars();
+}
+
+// einzelne Outline-Gruppe ausblenden
+
+void ScDBFunc::HideOutline( sal_Bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bRecord, sal_Bool bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ sal_Bool bOk = aFunc.HideOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, false );
+ ShowCursor();
+
+ if ( bOk && bPaint )
+ UpdateScrollBars();
+}
+
+// Menue-Status: markierten Bereich ein-/ausblenden
+
+sal_Bool ScDBFunc::OutlinePossible(sal_Bool bHide)
+{
+ sal_Bool bEnable = false;
+
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ ScOutlineArray* pArray;
+ ScOutlineEntry* pEntry;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+
+ // Spalten
+
+ pArray = pTable->GetColArray();
+ ScSubOutlineIterator aColIter( pArray );
+ while ((pEntry=aColIter.GetNext()) != NULL && !bEnable)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( bHide )
+ {
+ if ( nStartCol<=static_cast<SCCOL>(nEnd) && nEndCol>=static_cast<SCCOL>(nStart) )
+ if (!pEntry->IsHidden())
+ bEnable = sal_True;
+ }
+ else
+ {
+ if ( nStart>=nStartCol && nEnd<=nEndCol )
+ if (pEntry->IsHidden())
+ bEnable = sal_True;
+ }
+ }
+
+ // Zeilen
+
+ pArray = pTable->GetRowArray();
+ ScSubOutlineIterator aRowIter( pArray );
+ while ((pEntry=aRowIter.GetNext()) != NULL)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( bHide )
+ {
+ if ( nStartRow<=nEnd && nEndRow>=nStart )
+ if (!pEntry->IsHidden())
+ bEnable = sal_True;
+ }
+ else
+ {
+ if ( nStart>=nStartRow && nEnd<=nEndRow )
+ if (pEntry->IsHidden())
+ bEnable = sal_True;
+ }
+ }
+ }
+ }
+
+ return bEnable;
+}
+
+// markierten Bereich einblenden
+
+void ScDBFunc::ShowMarkedOutlines( sal_Bool bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ HideCursor();
+ sal_Bool bDone = aFunc.ShowMarkedOutlines( aRange, bRecord, false );
+ ShowCursor();
+ if (bDone)
+ UpdateScrollBars();
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// markierten Bereich ausblenden
+
+void ScDBFunc::HideMarkedOutlines( sal_Bool bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ HideCursor();
+ sal_Bool bDone = aFunc.HideMarkedOutlines( aRange, bRecord, false );
+ ShowCursor();
+ if (bDone)
+ UpdateScrollBars();
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// --------------------------------------------------------------------------
+
+//
+// Teilergebnisse
+//
+
+void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, sal_Bool bRecord,
+ const ScSortParam* pForceNewSort )
+{
+ sal_Bool bDo = !rParam.bRemoveOnly; // sal_False = nur loeschen
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = false;
+
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
+ rParam.nCol2, rParam.nRow2 );
+ if (!pDBData)
+ {
+ OSL_FAIL( "SubTotals: keine DBData" );
+ return;
+ }
+
+ ScEditableTester aTester( pDoc, nTab, 0,rParam.nRow1+1, MAXCOL,MAXROW );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ if (pDoc->HasAttrib( rParam.nCol1, rParam.nRow1+1, nTab,
+ rParam.nCol2, rParam.nRow2, nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ ErrorMessage(STR_MSSG_INSERTCELLS_0); // nicht in zusammengefasste einfuegen
+ return;
+ }
+
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ sal_Bool bOk = true;
+ if (rParam.bReplace)
+ if (pDoc->TestRemoveSubTotals( nTab, rParam ))
+ {
+ bOk = ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ // "StarCalc" "Daten loeschen?"
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) ).Execute()
+ == RET_YES );
+ }
+
+ if (bOk)
+ {
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScSubTotalParam aNewParam( rParam ); // Bereichsende wird veraendert
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+
+ if (bRecord) // alte Daten sichern
+ {
+ sal_Bool bOldFilter = bDo && rParam.bDoSort;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ SCCOLROW nOutStartCol; // Zeilen/Spaltenstatus
+ SCCOLROW nOutStartRow;
+ SCCOLROW nOutEndCol;
+ SCCOLROW nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab, IDF_NONE, false, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, false, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, false, bOldFilter );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,rParam.nRow1+1,nTab, MAXCOL,rParam.nRow2,nTab,
+ IDF_ALL, false, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
+ IDF_FORMULA, false, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (!pDocRange->empty())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+ ScOutlineTable* pOut = pDoc->GetOutlineTable( nTab );
+ if (pOut)
+ {
+ // Remove all existing outlines in the specified range.
+ ScOutlineArray* pRowArray = pOut->GetRowArray();
+ sal_uInt16 nDepth = pRowArray->GetDepth();
+ for (sal_uInt16 i = 0; i < nDepth; ++i)
+ {
+ sal_Bool bSize;
+ pRowArray->Remove(aNewParam.nRow1, aNewParam.nRow2, bSize);
+ }
+ }
+
+ if (rParam.bReplace)
+ pDoc->RemoveSubTotals( nTab, aNewParam );
+ sal_Bool bSuccess = sal_True;
+ if (bDo)
+ {
+ // Sortieren
+ if ( rParam.bDoSort || pForceNewSort )
+ {
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+
+ // Teilergebnis-Felder vor die Sortierung setzen
+ // (doppelte werden weggelassen, kann darum auch wieder aufgerufen werden)
+
+ ScSortParam aOldSort;
+ pDBData->GetSortParam( aOldSort );
+ ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort );
+ Sort( aSortParam, false, false );
+ }
+
+ bSuccess = pDoc->DoSubTotals( nTab, aNewParam );
+ }
+ ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab,
+ aNewParam.nCol2, aNewParam.nRow2, nTab );
+ pDoc->SetDirty( aDirtyRange );
+
+ if (bRecord)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoSubTotals( pDocSh, nTab,
+ rParam, aNewParam.nRow2,
+ pUndoDoc, pUndoTab, // pUndoDBData,
+ pUndoRange, pUndoDB ) );
+ }
+
+ if (!bSuccess)
+ {
+ // "Kann keine Zeilen einfuegen"
+ ErrorMessage(STR_MSSG_DOSUBTOTALS_2);
+ }
+
+ // merken
+ pDBData->SetSubTotalParam( aNewParam );
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+ pDoc->CompileDBFormula();
+
+ DoneBlockMode();
+ InitOwnBlockMode();
+ rMark.SetMarkArea( ScRange( aNewParam.nCol1,aNewParam.nRow1,nTab,
+ aNewParam.nCol2,aNewParam.nRow2,nTab ) );
+ MarkDataChanged();
+
+ pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+
+ aModificator.SetDocumentModified();
+
+ SelectionChanged();
+ }
+}
+
+//
+// Consolidate
+//
+
+void ScDBFunc::Consolidate( const ScConsolidateParam& rParam, sal_Bool bRecord )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ pDocShell->DoConsolidate( rParam, bRecord );
+ SetTabNo( rParam.nTab, sal_True );
+}
+
+//
+// Pivot
+//
+
+String lcl_MakePivotTabName( const String& rPrefix, SCTAB nNumber )
+{
+ String aName = rPrefix;
+ aName += String::CreateFromInt32( nNumber );
+ return aName;
+}
+
+bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, sal_Bool bNewTable,
+ const ScDPObject& rSource, sal_Bool bApi )
+{
+ // error message if no fields are set
+ // this must be removed when drag&drop of fields from a toolbox is available
+
+ if ( rData.IsEmpty() && !bApi )
+ {
+ ErrorMessage(STR_PIVOT_NODATA);
+ return false;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ sal_Bool bUndo(pDoc->IsUndoEnabled());
+
+ ScRange aDestRange = rDest;
+ if ( bNewTable )
+ {
+ SCTAB nSrcTab = GetViewData()->GetTabNo();
+
+ String aName( ScGlobal::GetRscString(STR_PIVOT_TABLE) );
+ String aStr;
+
+ pDoc->GetName( nSrcTab, aStr );
+ aName += '_';
+ aName += aStr;
+ aName += '_';
+
+ SCTAB nNewTab = nSrcTab+1;
+
+ SCTAB i=1;
+ while ( !pDoc->InsertTab( nNewTab, lcl_MakePivotTabName( aName, i ) ) && i <= MAXTAB )
+ i++;
+
+ sal_Bool bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( pDocSh, nNewTab, bAppend, lcl_MakePivotTabName( aName, i ) ));
+ }
+
+ GetViewData()->InsertTab( nNewTab );
+ SetTabNo( nNewTab, sal_True );
+
+ aDestRange = ScRange( 0, 0, nNewTab );
+ }
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(
+ aDestRange.aStart.Col(), aDestRange.aStart.Row(), aDestRange.aStart.Tab() );
+
+ ScDPObject aObj( rSource );
+ aObj.SetOutRange( aDestRange );
+ if ( pDPObj && !rData.GetExistingDimensionData() )
+ {
+ // copy dimension data from old object - lost in the dialog
+ //! change the dialog to keep the dimension data
+
+ ScDPSaveData aNewData( rData );
+ const ScDPSaveData* pOldData = pDPObj->GetSaveData();
+ if ( pOldData )
+ {
+ const ScDPDimensionSaveData* pDimSave = pOldData->GetExistingDimensionData();
+ aNewData.SetDimensionData( pDimSave );
+ }
+ aObj.SetSaveData( aNewData );
+ }
+ else
+ aObj.SetSaveData( rData );
+
+ bool bAllowMove = (pDPObj != NULL); // allow re-positioning when editing existing table
+
+ ScDBDocFunc aFunc( *pDocSh );
+ bool bSuccess = aFunc.DataPilotUpdate( pDPObj, &aObj, sal_True, false, bAllowMove );
+
+ CursorPosChanged(); // shells may be switched
+
+ if ( bNewTable )
+ {
+ pDocSh->PostPaintExtras();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ }
+
+ return bSuccess;
+}
+
+void ScDBFunc::DeletePivotTable()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScDBDocFunc aFunc( *pDocSh );
+ aFunc.DataPilotUpdate( pDPObj, NULL, sal_True, false );
+ CursorPosChanged(); // shells may be switched
+ }
+ else
+ ErrorMessage(STR_PIVOT_NOTFOUND);
+}
+
+void ScDBFunc::RecalcPivotTable()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ ScDPCollection* pDPs = pDoc->GetDPCollection();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+ if (pDPs && pDPObj)
+ {
+ // Remove existing data cache for the data that this datapilot uses,
+ // to force re-build data cache.
+ if (!pDPs->ClearCache(pDPObj))
+ {
+ ErrorMessage(STR_PIVOT_NOTFOUND);
+ return;
+ }
+
+ ScDBDocFunc aFunc( *pDocSh );
+ aFunc.DataPilotUpdate( pDPObj, pDPObj, true, false );
+ CursorPosChanged(); // shells may be switched
+ }
+ else
+ ErrorMessage(STR_PIVOT_NOTFOUND);
+}
+
+void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( !pDPObj )
+ return;
+
+ long nStartDimension = -1;
+ long nStartHierarchy = -1;
+ long nStartLevel = -1;
+
+ ScRangeListRef xRanges;
+ GetViewData()->GetMultiArea( xRanges ); // incl. cursor if nothing is selected
+ size_t nRangeCount = xRanges->size();
+ sal_Bool bContinue = true;
+
+ for (size_t nRangePos=0; nRangePos < nRangeCount && bContinue; nRangePos++)
+ {
+ ScRange aRange = *(*xRanges)[nRangePos];
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ for (SCROW nRow=nStartRow; nRow<=nEndRow && bContinue; nRow++)
+ for (SCCOL nCol=nStartCol; nCol<=nEndCol && bContinue; nCol++)
+ {
+ sheet::DataPilotTableHeaderData aData;
+ pDPObj->GetHeaderPositionData(ScAddress(nCol, nRow, nTab), aData);
+ if ( aData.Dimension < 0 )
+ bContinue = false; // not part of any dimension
+ else
+ {
+ if ( nStartDimension < 0 ) // first member?
+ {
+ nStartDimension = aData.Dimension;
+ nStartHierarchy = aData.Hierarchy;
+ nStartLevel = aData.Level;
+ }
+ if ( aData.Dimension != nStartDimension ||
+ aData.Hierarchy != nStartHierarchy ||
+ aData.Level != nStartLevel )
+ {
+ bContinue = false; // cannot mix dimensions
+ }
+ }
+ if ( bContinue )
+ {
+ // accept any part of a member description, also subtotals,
+ // but don't stop if empty parts are contained
+ if ( aData.Flags & sheet::MemberResultFlags::HASMEMBER )
+ {
+ StrData* pNew = new StrData( aData.MemberName );
+ if ( !rEntries.Insert( pNew ) )
+ delete pNew;
+ }
+ }
+ }
+ }
+
+ rDimension = nStartDimension; // dimension from which the found members came
+ if (!bContinue)
+ rEntries.FreeAll(); // remove all if not valid
+}
+
+sal_Bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts )
+{
+ // determine if the date group dialog has to be shown for the current selection
+
+ sal_Bool bFound = false;
+
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ String aBaseDimName( aDimName );
+
+ sal_Bool bInGroupDim = false;
+ sal_Bool bFoundParts = false;
+
+ ScDPDimensionSaveData* pDimData =
+ const_cast<ScDPDimensionSaveData*>( pDPObj->GetSaveData()->GetExistingDimensionData() );
+ if ( pDimData )
+ {
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ const ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDim( aDimName );
+ if ( pNumGroupDim )
+ {
+ // existing num group dimension
+
+ if ( pNumGroupDim->GetDatePart() != 0 )
+ {
+ // dimension has date info -> edit settings of this dimension
+ // (parts are collected below)
+
+ rOldInfo = pNumGroupDim->GetDateInfo();
+ bFound = sal_True;
+ }
+ else if ( pNumGroupDim->GetInfo().DateValues )
+ {
+ // Numerical grouping with DateValues flag is used for grouping
+ // of days with a "Number of days" value.
+
+ rOldInfo = pNumGroupDim->GetInfo();
+ rParts = com::sun::star::sheet::DataPilotFieldGroupBy::DAYS; // not found in CollectDateParts
+ bFoundParts = sal_True;
+ bFound = sal_True;
+ }
+ bInGroupDim = sal_True;
+ }
+ else if ( pGroupDim )
+ {
+ // existing additional group dimension
+
+ if ( pGroupDim->GetDatePart() != 0 )
+ {
+ // dimension has date info -> edit settings of this dimension
+ // (parts are collected below)
+
+ rOldInfo = pGroupDim->GetDateInfo();
+ aBaseDimName = pGroupDim->GetSourceDimName();
+ bFound = sal_True;
+ }
+ bInGroupDim = sal_True;
+ }
+ }
+ if ( bFound && !bFoundParts )
+ {
+ // collect date parts from all group dimensions
+ rParts = pDimData->CollectDateParts( aBaseDimName );
+ }
+ if ( !bFound && !bInGroupDim )
+ {
+ // create new date group dimensions if the selection is a single cell
+ // in a normal dimension with date content
+
+ ScRange aSelRange;
+ if ( (GetViewData()->GetSimpleArea( aSelRange ) == SC_MARK_SIMPLE) &&
+ aSelRange.aStart == aSelRange.aEnd )
+ {
+ SCCOL nSelCol = aSelRange.aStart.Col();
+ SCROW nSelRow = aSelRange.aStart.Row();
+ SCTAB nSelTab = aSelRange.aStart.Tab();
+ if ( pDoc->HasValueData( nSelCol, nSelRow, nSelTab ) )
+ {
+ sal_uLong nIndex = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(
+ nSelCol, nSelRow, nSelTab, ATTR_VALUE_FORMAT))->GetValue();
+ short nType = pDoc->GetFormatTable()->GetType(nIndex);
+ if ( nType == NUMBERFORMAT_DATE || nType == NUMBERFORMAT_TIME || nType == NUMBERFORMAT_DATETIME )
+ {
+ bFound = sal_True;
+ // use currently selected value for automatic limits
+ if( rOldInfo.AutoStart )
+ rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.AutoEnd )
+ rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+sal_Bool ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
+{
+ // determine if the numeric group dialog has to be shown for the current selection
+
+ sal_Bool bFound = false;
+
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ sal_Bool bInGroupDim = false;
+
+ ScDPDimensionSaveData* pDimData =
+ const_cast<ScDPDimensionSaveData*>( pDPObj->GetSaveData()->GetExistingDimensionData() );
+ if ( pDimData )
+ {
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ if ( pNumGroupDim )
+ {
+ // existing num group dimension
+ // -> edit settings of this dimension
+
+ rOldInfo = pNumGroupDim->GetInfo();
+ bFound = sal_True;
+ }
+ else if ( pDimData->GetNamedGroupDim( aDimName ) )
+ bInGroupDim = sal_True; // in a group dimension
+ }
+ if ( !bFound && !bInGroupDim )
+ {
+ // create a new num group dimension if the selection is a single cell
+ // in a normal dimension with numeric content
+
+ ScRange aSelRange;
+ if ( (GetViewData()->GetSimpleArea( aSelRange ) == SC_MARK_SIMPLE) &&
+ aSelRange.aStart == aSelRange.aEnd )
+ {
+ if ( pDoc->HasValueData( aSelRange.aStart.Col(), aSelRange.aStart.Row(),
+ aSelRange.aStart.Tab() ) )
+ {
+ bFound = sal_True;
+ // use currently selected value for automatic limits
+ if( rOldInfo.AutoStart )
+ rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.AutoEnd )
+ rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ }
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+void ScDBFunc::DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ // find original base
+ String aBaseDimName = aDimName;
+ if( const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName ) )
+ aBaseDimName = pBaseGroupDim->GetSourceDimName();
+
+ // remove all existing parts (the grouping is built completely new)
+
+ /* Remove numeric group dimension (exists once at most). No need
+ to delete anything in save data (grouping was done inplace in
+ an existing base dimension). */
+ pDimData->RemoveNumGroupDimension( aBaseDimName );
+
+ /* Remove named group dimension(s). Collect deleted dimension
+ names which may be reused while recreating the groups.
+ Dimensions have to be removed from dimension save data and from
+ save data too. */
+ std::vector< String > aDeletedNames;
+ const ScDPSaveGroupDimension* pExistingGroup = pDimData->GetGroupDimForBase( aBaseDimName );
+ while ( pExistingGroup )
+ {
+ String aGroupDimName = pExistingGroup->GetGroupDimName();
+ pDimData->RemoveGroupDimension( aGroupDimName ); // pExistingGroup is deleted
+
+ // also remove SaveData settings for the dimension that no longer exists
+ aData.RemoveDimensionByName( aGroupDimName );
+
+ /* The name can be used for the new group dimensions, although
+ it is still in use with the DataPilotSource. */
+ aDeletedNames.push_back( aGroupDimName );
+
+ // see if there are more group dimensions
+ pExistingGroup = pDimData->GetGroupDimForBase( aBaseDimName );
+
+ if ( pExistingGroup && pExistingGroup->GetGroupDimName() == aGroupDimName )
+ {
+ // still get the same group dimension?
+ OSL_FAIL("couldn't remove group dimension");
+ pExistingGroup = NULL; // avoid endless loop
+ }
+ }
+
+ if ( nParts )
+ {
+ // create date group dimensions
+
+ ScDPNumGroupInfo aEmpty;
+ bool bFirst = true;
+ sal_Int32 nMask = 1;
+ for (sal_uInt16 nBit=0; nBit<32; nBit++)
+ {
+ if ( nParts & nMask )
+ {
+ if ( bFirst )
+ {
+ // innermost part: create NumGroupDimension (replacing original values)
+ // Dimension name is left unchanged
+
+ if ( (nParts == sheet::DataPilotFieldGroupBy::DAYS) && (rInfo.Step >= 1.0) )
+ {
+ // only days, and a step value specified: use numerical grouping
+ // with DateValues flag, not date grouping
+
+ ScDPNumGroupInfo aNumInfo( rInfo );
+ aNumInfo.DateValues = sal_True;
+
+ ScDPSaveNumGroupDimension aNumGroupDim( aBaseDimName, aNumInfo );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+ else
+ {
+ ScDPSaveNumGroupDimension aNumGroupDim( aBaseDimName, rInfo, nMask );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+
+ bFirst = false;
+ }
+ else
+ {
+ // additional parts: create GroupDimension (shown as additional dimensions)
+ String aGroupDimName = pDimData->CreateDateGroupDimName( nMask, *pDPObj, true, &aDeletedNames );
+ ScDPSaveGroupDimension aGroupDim( aBaseDimName, aGroupDimName );
+ aGroupDim.SetDateInfo( rInfo, nMask );
+ pDimData->AddGroupDimension( aGroupDim );
+
+ // set orientation
+ ScDPSaveDimension* pSaveDimension = aData.GetDimensionByName( aGroupDimName );
+ if ( pSaveDimension->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension* pOldDimension = aData.GetDimensionByName( aBaseDimName );
+ pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
+ long nPosition = 0; //! before (immediate) base
+ aData.SetPosition( pSaveDimension, nPosition );
+ }
+ }
+ }
+ nMask *= 2;
+ }
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::NumGroupDataPilot( const ScDPNumGroupInfo& rInfo )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ ScDPSaveNumGroupDimension* pExisting = pDimData->GetNumGroupDimAcc( aDimName );
+ if ( pExisting )
+ {
+ // modify existing group dimension
+ pExisting->SetGroupInfo( rInfo );
+ }
+ else
+ {
+ // create new group dimension
+ ScDPSaveNumGroupDimension aNumGroupDim( aDimName, rInfo );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::GroupDataPilot()
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ // find original base
+ String aBaseDimName( aDimName );
+ const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName );
+ if ( pBaseGroupDim )
+ {
+ // any entry's SourceDimName is the original base
+ aBaseDimName = pBaseGroupDim->GetSourceDimName();
+ }
+
+ // find existing group dimension
+ // (using the selected dim, can be intermediate group dim)
+ ScDPSaveGroupDimension* pGroupDimension = pDimData->GetGroupDimAccForBase( aDimName );
+
+ // remove the selected items from their groups
+ // (empty groups are removed, too)
+ sal_uInt16 nEntryCount = aEntries.GetCount();
+ sal_uInt16 nEntry;
+ if ( pGroupDimension )
+ {
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, remove all its items
+ // (same logic as for adding, below)
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ pBaseGroup->RemoveElementsFromGroups( *pGroupDimension ); // remove all elements
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ }
+
+ ScDPSaveGroupDimension* pNewGroupDim = NULL;
+ if ( !pGroupDimension )
+ {
+ // create a new group dimension
+ String aGroupDimName = pDimData->CreateGroupDimName( aBaseDimName, *pDPObj, false, NULL );
+ pNewGroupDim = new ScDPSaveGroupDimension( aBaseDimName, aGroupDimName );
+
+ pGroupDimension = pNewGroupDim; // make changes to the new dim if none existed
+
+ if ( pBaseGroupDim )
+ {
+ // If it's a higher-order group dimension, pre-allocate groups for all
+ // non-selected original groups, so the individual base members aren't
+ // used for automatic groups (this would make the original groups hard
+ // to find).
+ //! Also do this when removing groups?
+ //! Handle this case dynamically with automatic groups?
+
+ long nGroupCount = pBaseGroupDim->GetGroupCount();
+ for ( long nGroup = 0; nGroup < nGroupCount; nGroup++ )
+ {
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetGroupByIndex( nGroup );
+
+ StrData aStrData( pBaseGroup->GetGroupName() );
+ sal_uInt16 nCollIndex;
+ if ( !aEntries.Search( &aStrData, nCollIndex ) ) //! ignore case?
+ {
+ // add an additional group for each item that is not in the selection
+ ScDPSaveGroupItem aGroup( pBaseGroup->GetGroupName() );
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ pGroupDimension->AddGroupItem( aGroup );
+ }
+ }
+ }
+ }
+ String aGroupDimName = pGroupDimension->GetGroupDimName();
+
+ //! localized prefix string
+ String aGroupName = pGroupDimension->CreateGroupName( String::CreateFromAscii("Group") );
+ ScDPSaveGroupItem aGroup( aGroupName );
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, add all its items
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ else
+ aGroup.AddElement( aEntryName ); // no group found -> automatic group, add the item itself
+ }
+ else
+ aGroup.AddElement( aEntryName ); // no group dimension, add all items directly
+ }
+
+ pGroupDimension->AddGroupItem( aGroup );
+
+ if ( pNewGroupDim )
+ {
+ pDimData->AddGroupDimension( *pNewGroupDim );
+ delete pNewGroupDim; // AddGroupDimension copies the object
+ // don't access pGroupDimension after here
+ }
+ pGroupDimension = pNewGroupDim = NULL;
+
+ // set orientation
+ ScDPSaveDimension* pSaveDimension = aData.GetDimensionByName( aGroupDimName );
+ if ( pSaveDimension->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension* pOldDimension = aData.GetDimensionByName( aDimName );
+ pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
+ long nPosition = 0; //! before (immediate) base
+ aData.SetPosition( pSaveDimension, nPosition );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::UngroupDataPilot()
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+ //! test first if DimensionData exists?
+
+ sal_Bool bApply = false;
+
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ if ( ( pGroupDim && pGroupDim->GetDatePart() != 0 ) ||
+ ( pNumGroupDim && pNumGroupDim->GetDatePart() != 0 ) )
+ {
+ // Date grouping: need to remove all affected group dimensions.
+ // This is done using DateGroupDataPilot with nParts=0.
+
+ DateGroupDataPilot( ScDPNumGroupInfo(), 0 );
+ // bApply remains FALSE
+ // dimension pointers become invalid
+ }
+ else if ( pGroupDim )
+ {
+ sal_uInt16 nEntryCount = aEntries.GetCount();
+ for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ pGroupDim->RemoveGroup( aEntryName );
+ }
+ // remove group dimension if empty
+ bool bEmptyDim = pGroupDim->IsEmpty();
+ if ( !bEmptyDim )
+ {
+ // If all remaining groups in the dimension aren't shown, remove
+ // the dimension too, as if it was completely empty.
+ ScStrCollection aVisibleEntries;
+ pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
+ bEmptyDim = pGroupDim->HasOnlyHidden( aVisibleEntries );
+ }
+ if ( bEmptyDim )
+ {
+ pDimData->RemoveGroupDimension( aDimName ); // pGroupDim is deleted
+
+ // also remove SaveData settings for the dimension that no longer exists
+ aData.RemoveDimensionByName( aDimName );
+ }
+ bApply = sal_True;
+ }
+ else if ( pNumGroupDim )
+ {
+ // remove the numerical grouping
+ pDimData->RemoveNumGroupDimension( aDimName );
+ // SaveData settings can remain unchanged - the same dimension still exists
+ bApply = sal_True;
+ }
+
+ if ( bApply )
+ {
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+ }
+}
+
+static OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUString& rMemberName)
+{
+ sal_Int32 n = rSubtotal.getLength();
+ const sal_Unicode* p = rSubtotal.getStr();
+ OUStringBuffer aBuf, aWordBuf;
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ sal_Unicode c = p[i];
+ if (c == sal_Unicode(' '))
+ {
+ OUString aWord = aWordBuf.makeStringAndClear();
+ if (aWord.equals(rMemberName))
+ aBuf.append(sal_Unicode('?'));
+ else
+ aBuf.append(aWord);
+ aBuf.append(c);
+ }
+ else if (c == sal_Unicode('\\'))
+ {
+ // Escape a backslash character.
+ aWordBuf.append(c);
+ aWordBuf.append(c);
+ }
+ else if (c == sal_Unicode('?'))
+ {
+ // A literal '?' must be escaped with a backslash ('\');
+ aWordBuf.append(sal_Unicode('\\'));
+ aWordBuf.append(c);
+ }
+ else
+ aWordBuf.append(c);
+ }
+
+ if (aWordBuf.getLength() > 0)
+ {
+ OUString aWord = aWordBuf.makeStringAndClear();
+ if (aWord.equals(rMemberName))
+ aBuf.append(sal_Unicode('?'));
+ else
+ aBuf.append(aWord);
+ }
+
+ return aBuf.makeStringAndClear();
+}
+
+void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+{
+ using namespace ::com::sun::star::sheet;
+
+ String aNewName( rString );
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( rPos.Col(), rPos.Row(), rPos.Tab() );
+ if (!pDPObj)
+ return;
+
+ String aOldText;
+ pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
+
+ if ( aOldText == rString )
+ {
+ // nothing to do: silently exit
+ return;
+ }
+
+ sal_uInt16 nErrorId = 0;
+
+ pDPObj->BuildAllDimensionMembers();
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ sal_Bool bChange = false;
+
+ sal_uInt16 nOrient = DataPilotFieldOrientation_HIDDEN;
+ long nField = pDPObj->GetHeaderDim( rPos, nOrient );
+ if ( nField >= 0 )
+ {
+ // changing a field title
+ if ( aData.GetExistingDimensionData() )
+ {
+ // only group dimensions can be renamed
+
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aOldText );
+ if ( pGroupDim )
+ {
+ // valid name: not empty, no existing dimension (group or other)
+ if ( rString.Len() && !pDPObj->IsDimNameInUse(rString) )
+ {
+ pGroupDim->Rename( aNewName );
+
+ // also rename in SaveData to preserve the field settings
+ ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
+ pSaveDim->SetName( aNewName );
+
+ bChange = sal_True;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else if (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW)
+ {
+ sal_Bool bDataLayout = false;
+ String aDimName = pDPObj->GetDimName(nField, bDataLayout);
+ ScDPSaveDimension* pDim = bDataLayout ? aData.GetDataLayoutDimension() : aData.GetDimensionByName(aDimName);
+ if (pDim)
+ {
+ if (rString.Len())
+ {
+ if (rString.EqualsIgnoreCaseAscii(aDimName))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ }
+ else if (pDPObj->IsDataDescriptionCell(rPos))
+ {
+ // There is only one data dimension.
+ ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
+ if (pDim)
+ {
+ if (rString.Len())
+ {
+ if (pDim->GetName().equalsIgnoreAsciiCase(rString))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else
+ {
+ // This is not a field header.
+ sheet::DataPilotTableHeaderData aPosData;
+ pDPObj->GetHeaderPositionData(rPos, aPosData);
+
+ if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
+ {
+ if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
+
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+ if ( pGroupDim )
+ {
+ // valid name: not empty, no existing group in this dimension
+ //! ignore case?
+ if ( aNewName.Len() && !pGroupDim->GetNamedGroup( aNewName ) )
+ {
+ ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
+ if ( pGroup )
+ pGroup->Rename( aNewName ); // rename the existing group
+ else
+ {
+ // create a new group to replace the automatic group
+ ScDPSaveGroupItem aGroup( aNewName );
+ aGroup.AddElement( aOldText );
+ pGroupDim->AddGroupItem( aGroup );
+ }
+
+ // in both cases also adjust savedata, to preserve member settings (show details)
+ ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aDimName );
+ ScDPSaveMember* pSaveMember = pSaveDim->GetExistingMemberByName( aOldText );
+ if ( pSaveMember )
+ pSaveMember->SetName( aNewName );
+
+ bChange = sal_True;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else if ((aPosData.Flags & MemberResultFlags::GRANDTOTAL))
+ {
+ aData.SetGrandTotalName(rString);
+ bChange = true;
+ }
+ else if (aPosData.Dimension >= 0 && aPosData.MemberName.getLength() > 0)
+ {
+ sal_Bool bDataLayout = false;
+ String aDimName = pDPObj->GetDimName(static_cast<long>(aPosData.Dimension), bDataLayout);
+ if (bDataLayout)
+ {
+ // data dimension
+ do
+ {
+ if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ break;
+
+ ScDPSaveDimension* pDim = aData.GetDimensionByName(aPosData.MemberName);
+ if (!pDim)
+ break;
+
+ if (!rString.Len())
+ {
+ nErrorId = STR_INVALIDNAME;
+ break;
+ }
+
+ if (aPosData.MemberName.equalsIgnoreAsciiCase(rString))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ while (false);
+ }
+ else
+ {
+ // field member
+ do
+ {
+ ScDPSaveDimension* pDim = aData.GetDimensionByName(aDimName);
+ if (!pDim)
+ break;
+
+ ScDPSaveMember* pMem = pDim->GetExistingMemberByName(aPosData.MemberName);
+ if (!pMem)
+ break;
+
+ if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ {
+ // Change subtotal only when the table has one data dimension.
+ if (aData.GetDataDimensionCount() > 1)
+ break;
+
+ // display name for subtotal is allowed only if the subtotal type is 'Automatic'.
+ if (pDim->GetSubTotalsCount() != 1)
+ break;
+
+ if (pDim->GetSubTotalFunc(0) != sheet::GeneralFunction_AUTO)
+ break;
+
+ const OUString* pLayoutName = pMem->GetLayoutName();
+ String aMemberName;
+ if (pLayoutName)
+ aMemberName = *pLayoutName;
+ else
+ aMemberName = aPosData.MemberName;
+
+ String aNew = lcl_replaceMemberNameInSubtotal(rString, aMemberName);
+ pDim->SetSubtotalName(aNew);
+ bChange = true;
+ }
+ else
+ {
+ // Check to make sure the member name isn't
+ // already used.
+ if (rString.Len())
+ {
+ if (::rtl::OUString(rString).equalsIgnoreAsciiCase(pMem->GetName()))
+ {
+ pMem->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDim->IsMemberNameInUse(rString))
+ {
+ pMem->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ while (false);
+ }
+ }
+ }
+ }
+
+ if ( bChange )
+ {
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+ }
+ else
+ {
+ if ( !nErrorId )
+ nErrorId = STR_ERR_DATAPILOT_INPUT;
+ ErrorMessage( nErrorId );
+ }
+}
+
+void lcl_MoveToEnd( ScDPSaveDimension& rDim, const String& rItemName )
+{
+ ScDPSaveMember* pNewMember = NULL;
+ const ScDPSaveMember* pOldMember = rDim.GetExistingMemberByName( rItemName );
+ if ( pOldMember )
+ pNewMember = new ScDPSaveMember( *pOldMember );
+ else
+ pNewMember = new ScDPSaveMember( rItemName );
+ rDim.AddMember( pNewMember );
+ // AddMember takes ownership of the new pointer,
+ // puts it to the end of the list even if it was in the list before.
+}
+
+struct ScOUStringCollate
+{
+ CollatorWrapper* mpCollator;
+
+ ScOUStringCollate(CollatorWrapper* pColl) : mpCollator(pColl) {}
+
+ bool operator()(const rtl::OUString& rStr1, const rtl::OUString& rStr2) const
+ {
+ return ( mpCollator->compareString(rStr1, rStr2) < 0 );
+ }
+};
+
+bool ScDBFunc::DataPilotSort( const ScAddress& rPos, bool bAscending, sal_uInt16* pUserListId )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(rPos.Col(), rPos.Row(), rPos.Tab());
+ if (!pDPObj)
+ return false;
+
+ // We need to run this to get all members later.
+ if ( pUserListId )
+ pDPObj->BuildAllDimensionMembers();
+
+ sal_uInt16 nOrientation;
+ long nDimIndex = pDPObj->GetHeaderDim(rPos, nOrientation);
+ if (nDimIndex < 0)
+ // Invalid dimension index. Bail out.
+ return false;
+
+ sal_Bool bDataLayout;
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ if (!pSaveData)
+ return false;
+
+ ScDPSaveData aNewSaveData(*pSaveData);
+ String aDimName = pDPObj->GetDimName(nDimIndex, bDataLayout);
+ ScDPSaveDimension* pSaveDim = aNewSaveData.GetDimensionByName(aDimName);
+ if (!pSaveDim)
+ return false;
+
+ // manual evaluation of sort order is only needed if a user list id is given
+ if ( pUserListId )
+ {
+ typedef ScDPSaveDimension::MemberList MemList;
+ const MemList& rDimMembers = pSaveDim->GetMembers();
+ list<OUString> aMembers;
+ boost::unordered_set<OUString, ::rtl::OUStringHash> aMemberSet;
+ size_t nMemberCount = 0;
+ for (MemList::const_iterator itr = rDimMembers.begin(), itrEnd = rDimMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMem = *itr;
+ aMembers.push_back(pMem->GetName());
+ aMemberSet.insert(pMem->GetName());
+ ++nMemberCount;
+ }
+
+ // Sort the member list in ascending order.
+ ScOUStringCollate aCollate( ScGlobal::GetCollator() );
+ aMembers.sort(aCollate);
+
+ // Collect and rank those custom sort strings that also exist in the member name list.
+
+ typedef boost::unordered_map<OUString, sal_uInt16, OUStringHash> UserSortMap;
+ UserSortMap aSubStrs;
+ sal_uInt16 nSubCount = 0;
+ if (pUserListId)
+ {
+ ScUserList* pUserList = ScGlobal::GetUserList();
+ if (!pUserList)
+ return false;
+
+ {
+ sal_uInt16 n = pUserList->GetCount();
+ if (!n || *pUserListId >= n)
+ return false;
+ }
+
+ ScUserListData* pData = static_cast<ScUserListData*>((*pUserList)[*pUserListId]);
+ if (pData)
+ {
+ sal_uInt16 n = pData->GetSubCount();
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ OUString aSub = pData->GetSubStr(i);
+ if (!aMemberSet.count(aSub))
+ // This string doesn't exist in the member name set. Don't add this.
+ continue;
+
+ aSubStrs.insert(UserSortMap::value_type(aSub, nSubCount++));
+ }
+ }
+ }
+
+ // Rank all members.
+
+ vector<OUString> aRankedNames(nMemberCount);
+ sal_uInt16 nCurStrId = 0;
+ for (list<OUString>::const_iterator itr = aMembers.begin(), itrEnd = aMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ OUString aName = *itr;
+ sal_uInt16 nRank = 0;
+ UserSortMap::const_iterator itrSub = aSubStrs.find(aName);
+ if (itrSub == aSubStrs.end())
+ nRank = nSubCount + nCurStrId++;
+ else
+ nRank = itrSub->second;
+
+ if (!bAscending)
+ nRank = static_cast< sal_uInt16 >( nMemberCount - nRank - 1 );
+
+ aRankedNames[nRank] = aName;
+ }
+
+ // Re-order ScDPSaveMember instances with the new ranks.
+
+ for (vector<OUString>::const_iterator itr = aRankedNames.begin(), itrEnd = aRankedNames.end();
+ itr != itrEnd; ++itr)
+ {
+ const ScDPSaveMember* pOldMem = pSaveDim->GetExistingMemberByName(*itr);
+ if (!pOldMem)
+ // All members are supposed to be present.
+ continue;
+
+ ScDPSaveMember* pNewMem = new ScDPSaveMember(*pOldMem);
+ pSaveDim->AddMember(pNewMem);
+ }
+
+ // Set the sorting mode to manual for now. We may introduce a new sorting
+ // mode later on.
+
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ pSaveDim->SetSortInfo(&aSortInfo);
+ }
+ else
+ {
+ // without user list id, just apply sorting mode
+
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::NAME;
+ aSortInfo.IsAscending = bAscending;
+ pSaveDim->SetSortInfo(&aSortInfo);
+ }
+
+ // Update the datapilot with the newly sorted field members.
+
+ auto_ptr<ScDPObject> pNewObj(new ScDPObject(*pDPObj));
+ pNewObj->SetSaveData(aNewSaveData);
+ ScDBDocFunc aFunc(*GetViewData()->GetDocShell());
+
+ return aFunc.DataPilotUpdate(pDPObj, pNewObj.get(), true, false);
+}
+
+sal_Bool ScDBFunc::DataPilotMove( const ScRange& rSource, const ScAddress& rDest )
+{
+ sal_Bool bRet = false;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( rSource.aStart.Col(), rSource.aStart.Row(), rSource.aStart.Tab() );
+ if ( pDPObj && pDPObj == pDoc->GetDPAtCursor( rDest.Col(), rDest.Row(), rDest.Tab() ) )
+ {
+ sheet::DataPilotTableHeaderData aDestData;
+ pDPObj->GetHeaderPositionData( rDest, aDestData );
+ bool bValid = ( aDestData.Dimension >= 0 ); // dropping onto a field
+
+ // look through the source range
+ boost::unordered_set< rtl::OUString, rtl::OUStringHash, std::equal_to<rtl::OUString> > aMembersSet; // for lookup
+ std::vector< rtl::OUString > aMembersVector; // members in original order, for inserting
+ aMembersVector.reserve( std::max( static_cast<SCSIZE>( rSource.aEnd.Col() - rSource.aStart.Col() + 1 ),
+ static_cast<SCSIZE>( rSource.aEnd.Row() - rSource.aStart.Row() + 1 ) ) );
+ for (SCROW nRow = rSource.aStart.Row(); bValid && nRow <= rSource.aEnd.Row(); ++nRow )
+ for (SCCOL nCol = rSource.aStart.Col(); bValid && nCol <= rSource.aEnd.Col(); ++nCol )
+ {
+ sheet::DataPilotTableHeaderData aSourceData;
+ pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, rSource.aStart.Tab() ), aSourceData );
+ if ( aSourceData.Dimension == aDestData.Dimension && aSourceData.MemberName.getLength() )
+ {
+ if ( aMembersSet.find( aSourceData.MemberName ) == aMembersSet.end() )
+ {
+ aMembersSet.insert( aSourceData.MemberName );
+ aMembersVector.push_back( aSourceData.MemberName );
+ }
+ // duplicates are ignored
+ }
+ else
+ bValid = false; // empty (subtotal) or different field
+ }
+
+ if ( bValid )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( aDestData.Dimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName );
+
+ // get all member names in source order
+ uno::Sequence<rtl::OUString> aMemberNames;
+ pDPObj->GetMemberNames( aDestData.Dimension, aMemberNames );
+
+ bool bInserted = false;
+
+ sal_Int32 nMemberCount = aMemberNames.getLength();
+ for (sal_Int32 nMemberPos=0; nMemberPos<nMemberCount; ++nMemberPos)
+ {
+ String aMemberStr( aMemberNames[nMemberPos] );
+
+ if ( !bInserted && aMemberNames[nMemberPos] == aDestData.MemberName )
+ {
+ // insert dragged items before this item
+ for ( std::vector<rtl::OUString>::const_iterator aIter = aMembersVector.begin();
+ aIter != aMembersVector.end(); ++aIter )
+ lcl_MoveToEnd( *pDim, *aIter );
+ bInserted = true;
+ }
+
+ if ( aMembersSet.find( aMemberStr ) == aMembersSet.end() ) // skip dragged items
+ lcl_MoveToEnd( *pDim, aMemberStr );
+ }
+ // insert dragged item at end if dest wasn't found (for example, empty)
+ if ( !bInserted )
+ for ( std::vector<rtl::OUString>::const_iterator aIter = aMembersVector.begin();
+ aIter != aMembersVector.end(); ++aIter )
+ lcl_MoveToEnd( *pDim, *aIter );
+
+ // Items that were in SaveData, but not in the source, end up at the start of the list.
+
+ // set flag for manual sorting
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ pDim->SetSortInfo( &aSortInfo );
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false ); //! bApi for drag&drop?
+ delete pNewObj;
+
+ Unmark(); // entry was moved - no use in leaving the old cell selected
+
+ bRet = sal_True;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+sal_Bool ScDBFunc::HasSelectionForDrillDown( sal_uInt16& rOrientation )
+{
+ sal_Bool bRet = false;
+
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName( aDimName );
+ if ( pDim )
+ {
+ sal_uInt16 nDimOrient = pDim->GetOrientation();
+ ScDPSaveDimension* pInner = pSaveData->GetInnermostDimension( nDimOrient );
+ if ( pDim == pInner )
+ {
+ rOrientation = nDimOrient;
+ bRet = sal_True;
+ }
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void ScDBFunc::SetDataPilotDetails( sal_Bool bShow, const String* pNewDimensionName )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ sal_Bool bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName );
+
+ if ( bShow && pNewDimensionName )
+ {
+ // add the new dimension with the same orientation, at the end
+
+ ScDPSaveDimension* pNewDim = aData.GetDimensionByName( *pNewDimensionName );
+ ScDPSaveDimension* pDuplicated = NULL;
+ if ( pNewDim->GetOrientation() == sheet::DataPilotFieldOrientation_DATA )
+ {
+ // Need to duplicate the dimension, create column/row in addition to data:
+ // The duplicated dimension inherits the existing settings, pNewDim is modified below.
+ pDuplicated = aData.DuplicateDimension( *pNewDimensionName );
+ }
+
+ sal_uInt16 nOrientation = pDim->GetOrientation();
+ pNewDim->SetOrientation( nOrientation );
+
+ long nPosition = LONG_MAX;
+ aData.SetPosition( pNewDim, nPosition );
+
+ ScDPSaveDimension* pDataLayout = aData.GetDataLayoutDimension();
+ if ( pDataLayout->GetOrientation() == nOrientation &&
+ aData.GetDataDimensionCount() <= 1 )
+ {
+ // If there is only one data dimension, the data layout dimension
+ // must still be the last one in its orientation.
+ aData.SetPosition( pDataLayout, nPosition );
+ }
+
+ if ( pDuplicated )
+ {
+ // The duplicated (data) dimension needs to be behind the original dimension
+ aData.SetPosition( pDuplicated, nPosition );
+ }
+
+ // Hide details for all visible members (selected are changed below).
+ //! Use all members from source level instead (including non-visible)?
+
+ ScStrCollection aVisibleEntries;
+ pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
+
+ sal_uInt16 nVisCount = aVisibleEntries.GetCount();
+ for (sal_uInt16 nVisPos=0; nVisPos<nVisCount; nVisPos++)
+ {
+ String aVisName = aVisibleEntries[nVisPos]->GetString();
+ ScDPSaveMember* pMember = pDim->GetMemberByName( aVisName );
+ pMember->SetShowDetails( false );
+ }
+ }
+
+ sal_uInt16 nEntryCount = aEntries.GetCount();
+ for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ ScDPSaveMember* pMember = pDim->GetMemberByName( aEntryName );
+ pMember->SetShowDetails( bShow );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, sal_True, false );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+ }
+}
+
+void ScDBFunc::ShowDataPilotSourceData( ScDPObject& rDPObj, const Sequence<sheet::DataPilotFieldFilter>& rFilters )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if (pDoc->GetDocumentShell()->IsReadOnly())
+ {
+ ErrorMessage(STR_READONLYERR);
+ return;
+ }
+
+ Reference<sheet::XDimensionsSupplier> xDimSupplier = rDPObj.GetSource();
+ Reference<container::XNameAccess> xDims = xDimSupplier->getDimensions();
+ Reference<sheet::XDrillDownDataSupplier> xDDSupplier(xDimSupplier, UNO_QUERY);
+ if (!xDDSupplier.is())
+ return;
+
+ Sequence< Sequence<Any> > aTabData = xDDSupplier->getDrillDownData(rFilters);
+ sal_Int32 nRowSize = aTabData.getLength();
+ if (nRowSize <= 1)
+ // There is no data to show. Bail out.
+ return;
+
+ sal_Int32 nColSize = aTabData[0].getLength();
+
+ SCTAB nNewTab = GetViewData()->GetTabNo();
+
+ auto_ptr<ScDocument> pInsDoc(new ScDocument(SCDOCMODE_CLIP));
+ pInsDoc->ResetClip( pDoc, nNewTab );
+ for (SCROW nRow = 0; nRow < nRowSize; ++nRow)
+ {
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ const Any& rAny = aTabData[nRow][nCol];
+ rtl::OUString aStr;
+ double fVal;
+ if (rAny >>= aStr)
+ pInsDoc->PutCell( ScAddress(nCol, nRow, nNewTab), new ScStringCell(String(aStr)) );
+ else if (rAny >>= fVal)
+ pInsDoc->SetValue(nCol, nRow, nNewTab, fVal);
+ }
+ }
+
+ // set number format (important for dates)
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ rtl::OUString aStr;
+ if (!(aTabData[0][nCol] >>= aStr))
+ continue;
+
+ Reference<XPropertySet> xPropSet(xDims->getByName(aStr), UNO_QUERY);
+ if (!xPropSet.is())
+ continue;
+
+ Any any = xPropSet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_NUMBERFO)) );
+ sal_Int32 nNumFmt = 0;
+ if (!(any >>= nNumFmt))
+ continue;
+
+ ScPatternAttr aPattern( pInsDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item(ATTR_VALUE_FORMAT, static_cast<sal_uInt32>(nNumFmt)) );
+ pInsDoc->ApplyPatternAreaTab(nCol, 1, nCol, nRowSize-1, nNewTab, aPattern);
+ }
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pInsDoc->GetCellArea( nNewTab, nEndCol, nEndRow );
+ pInsDoc->SetClipArea( ScRange( 0, 0, nNewTab, nEndCol, nEndRow, nNewTab ) );
+
+ ::svl::IUndoManager* pMgr = GetViewData()->GetDocShell()->GetUndoManager();
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_DOOUTLINE );
+ pMgr->EnterListAction( aUndo, aUndo );
+
+ String aNewTabName;
+ pDoc->CreateValidTabName(aNewTabName);
+ if ( InsertTable(aNewTabName, nNewTab) )
+ PasteFromClip( IDF_ALL, pInsDoc.get() );
+
+ pMgr->LeaveListAction();
+}
+
+//
+// DB-Operationen (Sortieren, Filtern, Teilergebnisse) wiederholen
+//
+
+void ScDBFunc::RepeatDB( sal_Bool bRecord )
+{
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBData* pDBData = GetDBData();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = false;
+
+ ScQueryParam aQueryParam;
+ pDBData->GetQueryParam( aQueryParam );
+ sal_Bool bQuery = aQueryParam.GetEntry(0).bDoQuery;
+
+ ScSortParam aSortParam;
+ pDBData->GetSortParam( aSortParam );
+ sal_Bool bSort = aSortParam.bDoSort[0];
+
+ ScSubTotalParam aSubTotalParam;
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ sal_Bool bSubTotal = aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly;
+
+ if ( bQuery || bSort || bSubTotal )
+ {
+ sal_Bool bQuerySize = false;
+ ScRange aOldQuery;
+ ScRange aNewQuery;
+ if (bQuery && !aQueryParam.bInplace)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, sal_True );
+ if (pDest && pDest->IsDoSize())
+ {
+ pDest->GetArea( aOldQuery );
+ bQuerySize = sal_True;
+ }
+ }
+
+ SCTAB nDummy;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDBData->GetArea( nDummy, nStartCol, nStartRow, nEndCol, nEndRow );
+
+ //! Undo nur benoetigte Daten ?
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+
+ if (bRecord)
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ SCCOLROW nOutStartCol; // Zeilen/Spaltenstatus
+ SCCOLROW nOutStartRow;
+ SCCOLROW nOutEndCol;
+ SCCOLROW nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab, IDF_NONE, false, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, false, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, false, sal_True );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab, IDF_ALL, false, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, IDF_FORMULA, false, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (!pDocRange->empty())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+ if (bSort && bSubTotal)
+ {
+ // Sortieren ohne SubTotals
+
+ aSubTotalParam.bRemoveOnly = sal_True; // wird unten wieder zurueckgesetzt
+ DoSubTotals( aSubTotalParam, false );
+ }
+
+ if (bSort)
+ {
+ pDBData->GetSortParam( aSortParam ); // Bereich kann sich geaendert haben
+ Sort( aSortParam, false, false);
+ }
+ if (bQuery)
+ {
+ pDBData->GetQueryParam( aQueryParam ); // Bereich kann sich geaendert haben
+ ScRange aAdvSource;
+ if (pDBData->GetAdvancedQuerySource(aAdvSource))
+ {
+ pDoc->CreateQueryParam(
+ aAdvSource.aStart.Col(), aAdvSource.aStart.Row(),
+ aAdvSource.aEnd.Col(), aAdvSource.aEnd.Row(),
+ aAdvSource.aStart.Tab(), aQueryParam );
+ Query( aQueryParam, &aAdvSource, false );
+ }
+ else
+ Query( aQueryParam, NULL, false );
+
+ // bei nicht-inplace kann die Tabelle umgestellt worden sein
+ if ( !aQueryParam.bInplace && aQueryParam.nDestTab != nTab )
+ SetTabNo( nTab );
+ }
+ if (bSubTotal)
+ {
+ pDBData->GetSubTotalParam( aSubTotalParam ); // Bereich kann sich geaendert haben
+ aSubTotalParam.bRemoveOnly = false;
+ DoSubTotals( aSubTotalParam, false );
+ }
+
+ if (bRecord)
+ {
+ SCTAB nDummyTab;
+ SCCOL nDummyCol;
+ SCROW nDummyRow, nNewEndRow;
+ pDBData->GetArea( nDummyTab, nDummyCol,nDummyRow, nDummyCol,nNewEndRow );
+
+ const ScRange* pOld = NULL;
+ const ScRange* pNew = NULL;
+ if (bQuerySize)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, sal_True );
+ if (pDest)
+ {
+ pDest->GetArea( aNewQuery );
+ pOld = &aOldQuery;
+ pNew = &aNewQuery;
+ }
+ }
+
+ GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
+ new ScUndoRepeatDB( GetViewData()->GetDocShell(), nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow,
+ nNewEndRow,
+ nCurX, nCurY,
+ pUndoDoc, pUndoTab,
+ pUndoRange, pUndoDB,
+ pOld, pNew ) );
+ }
+
+ GetViewData()->GetDocShell()->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ }
+ else // "Keine Operationen auszufuehren"
+ ErrorMessage(STR_MSSG_REPEATDB_0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc4.cxx b/sc/source/ui/view/dbfunc4.cxx
new file mode 100644
index 000000000000..f395cb741221
--- /dev/null
+++ b/sc/source/ui/view/dbfunc4.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svditer.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+
+#include "dbfunc.hxx"
+#include "drwlayer.hxx"
+#include "document.hxx"
+
+// -----------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+using namespace com::sun::star;
+
+//==================================================================
+
+sal_uInt16 ScDBFunc::DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, sal_Bool bAllCharts )
+{
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return 0;
+
+ sal_uInt16 nFound = 0;
+
+ sal_uInt16 nPageCount = pModel->GetPageCount();
+ for (sal_uInt16 nPageNo=0; nPageNo<nPageCount; nPageNo++)
+ {
+ SdrPage* pPage = pModel->GetPage(nPageNo);
+ DBG_ASSERT(pPage,"Page ?");
+
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart( pObject ) )
+ {
+ String aName = ((SdrOle2Obj*)pObject)->GetPersistName();
+ sal_Bool bHit = sal_True;
+ if ( !bAllCharts )
+ {
+ ScRangeList aRanges;
+ sal_Bool bColHeaders = false;
+ sal_Bool bRowHeaders = false;
+ pDoc->GetOldChartParameters( aName, aRanges, bColHeaders, bRowHeaders );
+ bHit = aRanges.In( rPos );
+ }
+ if ( bHit )
+ {
+ pDoc->UpdateChart( aName );
+ ++nFound;
+ }
+ }
+ pObject = aIter.Next();
+ }
+ }
+ return nFound;
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawattr.cxx b/sc/source/ui/view/drawattr.cxx
new file mode 100644
index 000000000000..7067b0d711eb
--- /dev/null
+++ b/sc/source/ui/view/drawattr.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "drawattr.hxx"
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+String SvxDrawToolItem::GetValueText() const
+{
+ return GetValueText(GetValue());
+}
+
+//------------------------------------------------------------------------
+
+String SvxDrawToolItem::GetValueText( sal_uInt16 nVal ) const
+{
+ const sal_Char* p;
+
+ switch (nVal)
+ {
+ case 0 : p = "SVX_SNAP_DRAW_SELECT" ; break;
+ //
+ case 1 : p = "SVX_SNAP_DRAW_LINE" ; break;
+ case 2 : p = "SVX_SNAP_DRAW_RECT" ; break;
+ case 3 : p = "SVX_SNAP_DRAW_ELLIPSE" ; break;
+ case 4 : p = "SVX_SNAP_DRAW_POLYGON" ; break;
+ case 5 : p = "SVX_SNAP_DRAW_ARC" ; break;
+ case 6 : p = "SVX_SNAP_DRAW_PIE" ; break;
+ case 7 : p = "SVX_SNAP_DRAW_CIRCLECUT" ; break;
+ case 8 : p = "SVX_SNAP_DRAW_TEXT" ; break;
+ default : return EMPTY_STRING;
+ }
+ return String::CreateFromAscii( p );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxDrawToolItem::Clone( SfxItemPool * ) const
+{
+ return new SvxDrawToolItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxDrawToolItem::Create( SvStream& rStream, sal_uInt16 nVer ) const
+{
+ sal_uInt16 nVal;
+ rStream >> nVal;
+ return new SvxDrawToolItem(nVal);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx
new file mode 100644
index 000000000000..54b4ef95dd83
--- /dev/null
+++ b/sc/source/ui/view/drawutil.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/outdev.hxx>
+
+#include "drawutil.hxx"
+#include "document.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+
+inline Fraction MakeFraction( long nA, long nB )
+{
+ return ( nA && nB ) ? Fraction(nA,nB) : Fraction(1,1);
+}
+
+void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ OutputDevice* pDev,
+ const Fraction& rZoomX, const Fraction& rZoomY,
+ double nPPTX, double nPPTY,
+ Fraction& rScaleX, Fraction& rScaleY )
+{
+ long nPixelX = 0;
+ long nTwipsX = 0;
+ long nPixelY = 0;
+ long nTwipsY = 0;
+ for (SCCOL i=nStartCol; i<nEndCol; i++)
+ {
+ sal_uInt16 nWidth = pDoc->GetColWidth(i,nTab);
+ nTwipsX += (long) nWidth;
+ nPixelX += ScViewData::ToPixel( nWidth, nPPTX );
+ }
+
+ for (SCROW nRow = nStartRow; nRow <= nEndRow-1; ++nRow)
+ {
+ SCROW nLastRow = nRow;
+ if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
+ {
+ nRow = nLastRow;
+ continue;
+ }
+
+ sal_uInt16 nHeight = pDoc->GetRowHeight(nRow, nTab);
+ nTwipsY += static_cast<long>(nHeight);
+ nPixelY += ScViewData::ToPixel(nHeight, nPPTY);
+ }
+
+ MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY );
+ Point aPixelLog = pDev->PixelToLogic( Point( nPixelX,nPixelY ), aHMMMode );
+
+ // Fraction(double) ctor can be used here (and avoid overflows of PixelLog * Zoom)
+ // because ReduceInaccurate is called later anyway.
+
+ if ( aPixelLog.X() && nTwipsX )
+ rScaleX = Fraction( ((double)aPixelLog.X()) *
+ ((double)rZoomX.GetNumerator()) /
+ ((double)nTwipsX) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomX.GetDenominator()) );
+ else
+ rScaleX = Fraction( 1, 1 );
+
+ if ( aPixelLog.Y() && nTwipsY )
+ rScaleY = Fraction( ((double)aPixelLog.Y()) *
+ ((double)rZoomY.GetNumerator()) /
+ ((double)nTwipsY) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomY.GetDenominator()) );
+ else
+ rScaleY = Fraction( 1, 1 );
+
+ // 25 bits of accuracy are needed to always hit the right part of
+ // cells in the last rows (was 17 before 1M rows).
+ rScaleX.ReduceInaccurate( 25 );
+ rScaleY.ReduceInaccurate( 25 );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie2.cxx b/sc/source/ui/view/drawvie2.cxx
new file mode 100644
index 000000000000..c047fcdbd6fe
--- /dev/null
+++ b/sc/source/ui/view/drawvie2.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "drawview.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+
+// UpdateBrowser in MarkListHasChanged gerufen
+
+void ScDrawView::UpdateBrowser()
+{
+ // VC's und den Browser dazu gibts nicht mehr...
+}
+
+void ScDrawView::VCAddWin( Window* /* pWin */ )
+{
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+void ScDrawView::VCRemoveWin( Window* /* pWin */ )
+{
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx
new file mode 100644
index 000000000000..400384a38712
--- /dev/null
+++ b/sc/source/ui/view/drawvie3.cxx
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "drawview.hxx"
+#include "drwlayer.hxx"
+#include "viewdata.hxx"
+#include "dbfunc.hxx"
+#include "document.hxx"
+#include "userdat.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+
+void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
+ const TargetList* pTargetList, void* pEditingObj ); // imapwrap
+sal_uInt16 ScIMapChildWindowId();
+
+// STATIC DATA -----------------------------------------------------------
+
+ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) :
+ FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ),
+ pViewData( pData ),
+ pDev( pOut ),
+ pDoc( pData->GetDocument() ),
+ nTab( pData->GetTabNo() ),
+ pDropMarker( NULL ),
+ pDropMarkObj( NULL ),
+ bInConstruct( true )
+{
+ // #i73602# Use default from the configuration
+ SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
+
+ // #i74769#, #i75172# Use default from the configuration
+ SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
+
+ Construct();
+}
+
+// Verankerung setzen
+
+void ScDrawView::SetPageAnchored()
+{
+ SdrObject* pObj = NULL;
+ if( AreObjectsMarked() )
+ {
+ const SdrMarkList* pMark = &GetMarkedObjectList();
+ sal_uLong nCount = pMark->GetMarkCount();
+ for( sal_uLong i=0; i<nCount; i++ )
+ {
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
+ ScDrawLayer::SetPageAnchored( *pObj );
+ }
+
+ if ( pViewData )
+ pViewData->GetDocShell()->SetDrawModified();
+ }
+}
+
+void ScDrawView::SetCellAnchored()
+{
+ if (!pDoc)
+ return;
+
+ SdrObject* pObj = NULL;
+ if( AreObjectsMarked() )
+ {
+ const SdrMarkList* pMark = &GetMarkedObjectList();
+ sal_uLong nCount = pMark->GetMarkCount();
+ for( sal_uLong i=0; i<nCount; i++ )
+ {
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
+ }
+
+ if ( pViewData )
+ pViewData->GetDocShell()->SetDrawModified();
+ }
+}
+
+ScAnchorType ScDrawView::GetAnchorType() const
+{
+ sal_Bool bPage = false;
+ sal_Bool bCell = false;
+ const SdrObject* pObj = NULL;
+ if( AreObjectsMarked() )
+ {
+ const SdrMarkList* pMark = &GetMarkedObjectList();
+ sal_uLong nCount = pMark->GetMarkCount();
+ Point p0;
+ for( sal_uLong i=0; i<nCount; i++ )
+ {
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
+ if( ScDrawLayer::GetAnchorType( *pObj ) == SCA_CELL )
+ bCell =true;
+ else
+ bPage = sal_True;
+ }
+ }
+ if( bPage && !bCell )
+ return SCA_PAGE;
+ if( !bPage && bCell )
+ return SCA_CELL;
+ return SCA_DONTKNOW;
+}
+
+void ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA(ScTabDeletedHint)) // Tabelle geloescht
+ {
+ SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
+ if (ValidTab(nDelTab))
+ {
+ // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
+ if ( nDelTab == nTab )
+ HideSdrPage();
+ }
+ }
+ else if (rHint.ISA(ScTabSizeChangedHint)) // Groesse geaendert
+ {
+ if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
+ UpdateWorkArea();
+ }
+ else if ( rHint.ISA( SdrHint ) )
+ {
+ if (const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ))
+ {
+ //Update the anchors of any non note object that is cell anchored which has
+ //been moved since the last anchors for its position was calculated
+ if (pSdrHint->GetKind() == HINT_OBJCHG || pSdrHint->GetKind() == HINT_OBJINSERTED)
+ if (SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject()))
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pObj))
+ if (!pAnchor->mbNote && pAnchor->maLastRect != pObj->GetLogicRect())
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, nTab);
+ }
+ FmFormView::Notify( rBC,rHint );
+ }
+ else
+ FmFormView::Notify( rBC,rHint );
+}
+
+void ScDrawView::UpdateIMap( SdrObject* pObj )
+{
+ if ( pViewData &&
+ pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
+ pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) )
+ {
+ Graphic aGraphic;
+ TargetList aTargetList;
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj );
+ const ImageMap* pImageMap = NULL;
+ if ( pIMapInfo )
+ pImageMap = &pIMapInfo->GetImageMap();
+
+ // Target-Liste besorgen
+ pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList );
+
+ // Grafik vom Objekt besorgen
+ if ( pObj->ISA( SdrGrafObj ) )
+ aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
+ else
+ {
+ Graphic* pGraphic = ((const SdrOle2Obj*) pObj )->GetGraphic();
+ if ( pGraphic )
+ aGraphic = *pGraphic;
+ }
+
+ ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // aus imapwrap
+
+ // TargetListe kann von uns wieder geloescht werden
+ for ( size_t i = 0, n = aTargetList.size(); i < n; ++i )
+ delete aTargetList[ i ];
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
new file mode 100644
index 000000000000..1e6f330a3fd3
--- /dev/null
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -0,0 +1,357 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/docfile.hxx>
+#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include "drawview.hxx"
+#include "global.hxx"
+#include "drwlayer.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "drwtrans.hxx"
+#include "transobj.hxx" // SetDrawClipDoc
+#include "drawutil.hxx"
+#include "scmod.hxx"
+#include "globstr.hrc"
+#include "chartarr.hxx"
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+Point aDragStartDiff;
+
+// -----------------------------------------------------------------------
+
+//! welche Funktionen aus drawview/drawvie4 muessen wirklich ohne Optimierung sein?
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+// -----------------------------------------------------------------------
+
+void lcl_CheckOle( const SdrMarkList& rMarkList, sal_Bool& rAnyOle, sal_Bool& rOneOle )
+{
+ rAnyOle = rOneOle = false;
+ sal_uLong nCount = rMarkList.GetMarkCount();
+ for (sal_uLong i=0; i<nCount; i++)
+ {
+ SdrMark* pMark = rMarkList.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
+ if (nSdrObjKind == OBJ_OLE2)
+ {
+ rAnyOle = sal_True;
+ rOneOle = (nCount == 1);
+ break;
+ }
+ else if ( pObj->ISA(SdrObjGroup) )
+ {
+ SdrObjListIter aIter( *pObj, IM_DEEPNOGROUPS );
+ SdrObject* pSubObj = aIter.Next();
+ while (pSubObj)
+ {
+ if ( pSubObj->GetObjIdentifier() == OBJ_OLE2 )
+ {
+ rAnyOle = sal_True;
+ // rOneOle remains sal_False - a group isn't treated like a single OLE object
+ return;
+ }
+ pSubObj = aIter.Next();
+ }
+ }
+ }
+}
+
+sal_Bool ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos )
+{
+ sal_Bool bReturn = false;
+
+ if ( AreObjectsMarked() )
+ {
+ BrkAction();
+
+ Rectangle aMarkedRect = GetAllMarkedRect();
+ Region aRegion( aMarkedRect );
+
+ aDragStartDiff = rStartPos - aMarkedRect.TopLeft();
+
+ sal_Bool bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ ScDocShellRef aDragShellRef;
+ if (bAnyOle)
+ {
+ aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
+ aDragShellRef->DoInitNew(NULL);
+ }
+ ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ pTransferObj->SetDrawPersist( &aDragShellRef ); // keep persist for ole objects alive
+ pTransferObj->SetDragSource( this ); // copies selection
+
+ SC_MOD()->SetDragObject( NULL, pTransferObj ); // for internal D&D
+ pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+ }
+
+ return bReturn;
+}
+
+void ScDrawView::DoCopy()
+{
+ sal_Bool bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ // update ScGlobal::pDrawClipDocShellRef
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) ); // keep persist for ole objects alive
+ }
+
+ pTransferObj->CopyToClipboard( pViewData->GetActiveWin() ); // system clipboard
+ SC_MOD()->SetClipObject( NULL, pTransferObj ); // internal clipboard
+}
+
+uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
+{
+ sal_Bool bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ // update ScGlobal::pDrawClipDocShellRef
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) ); // keep persist for ole objects alive
+ }
+
+ return xTransferable;
+}
+
+// Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen
+
+void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const
+{
+ double nPPTX = ScGlobal::nScreenPPTX;
+ double nPPTY = ScGlobal::nScreenPPTY;
+
+ if (pViewData)
+ nPPTX /= pViewData->GetDocShell()->GetOutputFactor();
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pDoc->GetTableArea( nTab, nEndCol, nEndRow );
+ if (nEndCol<20)
+ nEndCol = 20;
+ if (nEndRow<20)
+ nEndRow = 1000;
+
+ Fraction aZoom(1,1);
+ ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom,
+ nPPTX, nPPTY, rFractX,rFractY );
+}
+
+void ScDrawView::SetMarkedOriginalSize()
+{
+ SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*GetModel());
+
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ long nDone = 0;
+ sal_uLong nCount = rMarkList.GetMarkCount();
+ for (sal_uLong i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ sal_uInt16 nIdent = pObj->GetObjIdentifier();
+ sal_Bool bDo = false;
+ Size aOriginalSize;
+ if (nIdent == OBJ_OLE2)
+ {
+ // TODO/LEAN: working with visual area can switch object to running state
+ uno::Reference < embed::XEmbeddedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
+ if ( xObj.is() ) // NULL for an invalid object that couldn't be loaded
+ {
+ sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
+
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aOriginalSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMapMode );
+ bDo = sal_True;
+ }
+ else
+ {
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( ((SdrOle2Obj*)pObj)->GetAspect() ) );
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( ((SdrOle2Obj*)pObj)->GetAspect() );
+ aOriginalSize = OutputDevice::LogicToLogic(
+ Size( aSz.Width, aSz.Height ),
+ aUnit, MAP_100TH_MM );
+ bDo = sal_True;
+ } catch( embed::NoVisualAreaSizeException& )
+ {
+ OSL_ENSURE( false, "Can't get the original size of the object!" );
+ }
+ }
+ }
+ }
+ else if (nIdent == OBJ_GRAF)
+ {
+ const Graphic& rGraphic = ((SdrGrafObj*)pObj)->GetGraphic();
+
+ MapMode aSourceMap = rGraphic.GetPrefMapMode();
+ MapMode aDestMap( MAP_100TH_MM );
+ if (aSourceMap.GetMapUnit() == MAP_PIXEL)
+ {
+ // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
+
+ Fraction aNormScaleX, aNormScaleY;
+ CalcNormScale( aNormScaleX, aNormScaleY );
+ aDestMap.SetScaleX(aNormScaleX);
+ aDestMap.SetScaleY(aNormScaleY);
+ }
+ if (pViewData)
+ {
+ Window* pActWin = pViewData->GetActiveWin();
+ if (pActWin)
+ {
+ aOriginalSize = pActWin->LogicToLogic(
+ rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
+ bDo = sal_True;
+ }
+ }
+ }
+
+ if ( bDo )
+ {
+ Rectangle aDrawRect = pObj->GetLogicRect();
+
+ pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) );
+ pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ),
+ Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) );
+ ++nDone;
+ }
+ }
+
+ if (nDone)
+ {
+ pUndoGroup->SetComment(ScGlobal::GetRscString( STR_UNDO_ORIGINALSIZE ));
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ pDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
+ pDocSh->SetDrawModified();
+ }
+ else
+ delete pUndoGroup;
+}
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
new file mode 100644
index 000000000000..9c2bb98e1321
--- /dev/null
+++ b/sc/source/ui/view/drawview.cxx
@@ -0,0 +1,753 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/embed/EmbedStates.hpp>
+
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdocapt.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "drawview.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "drawutil.hxx"
+#include "futext.hxx"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "client.hxx"
+#include "scmod.hxx"
+#include "drwlayer.hxx"
+#include "docsh.hxx"
+#include "viewuno.hxx"
+#include "userdat.hxx"
+#include "postit.hxx"
+#include "undocell.hxx"
+
+#include "sc.hrc"
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+#define SC_HANDLESIZE_BIG 9
+#define SC_HANDLESIZE_SMALL 7
+
+// -----------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+
+void ScDrawView::Construct()
+{
+ EnableExtendedKeyInputDispatcher(false);
+ EnableExtendedMouseEventDispatcher(false);
+ EnableExtendedCommandEventDispatcher(false);
+
+ SetFrameDragSingles(true);
+
+ SetMinMoveDistancePixel( 2 );
+ SetHitTolerancePixel( 2 );
+
+ if (pViewData)
+ {
+ SCTAB nViewTab = pViewData->GetTabNo();
+ ShowSdrPage(GetModel()->GetPage(nViewTab));
+
+ sal_Bool bEx = pViewData->GetViewShell()->IsDrawSelMode();
+ sal_Bool bProt = pDoc->IsTabProtected( nViewTab ) ||
+ pViewData->GetSfxDocShell()->IsReadOnly();
+
+ SdrLayer* pLayer;
+ SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin();
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), bProt || !bEx );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), sal_True );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
+ if (pLayer)
+ {
+ SetLayerLocked( pLayer->GetName(), bProt );
+ SetActiveLayer( pLayer->GetName() ); // set active layer to FRONT
+ }
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), bProt );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
+ if (pLayer)
+ {
+ SetLayerLocked( pLayer->GetName(), bProt );
+ SetLayerVisible( pLayer->GetName(), false);
+ }
+
+ SetSwapAsynchron(sal_True);
+ }
+ else
+ {
+ ShowSdrPage(GetModel()->GetPage(nTab));
+ }
+
+ UpdateUserViewOptions();
+ RecalcScale();
+ UpdateWorkArea();
+
+ bInConstruct = false;
+}
+
+void ScDrawView::ImplClearCalcDropMarker()
+{
+ if(pDropMarker)
+ {
+ delete pDropMarker;
+ pDropMarker = 0L;
+ }
+}
+
+ScDrawView::~ScDrawView()
+{
+ ImplClearCalcDropMarker();
+}
+
+void ScDrawView::AddCustomHdl()
+{
+ const SdrMarkList &rMrkList = GetMarkedObjectList();
+ sal_uInt32 nCount = rMrkList.GetMarkCount();
+ for(sal_uInt32 nPos=0; nPos<nCount; nPos++ )
+ {
+ SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
+ if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
+ {
+ if (ScTabView* pView = pViewData->GetView())
+ pView->CreateAnchorHandles(aHdl, pAnchor->maStart);
+ }
+ }
+}
+
+void ScDrawView::InvalidateAttribs()
+{
+ if (!pViewData) return;
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ // true status values:
+ rBindings.InvalidateAll( true );
+}
+
+void ScDrawView::InvalidateDrawTextAttrs()
+{
+ if (!pViewData) return;
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ // cjk/ctl font items have no configured slots,
+ // need no invalidate
+
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+ rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
+ rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
+ rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
+ rBindings.Invalidate( SID_SET_SUB_SCRIPT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+}
+
+void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
+{
+ if (AreObjectsMarked())
+ {
+ // #i11702# use SdrUndoObjectLayerChange for undo
+ // STR_UNDO_SELATTR is "Attributes" - should use a different text later
+ BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
+
+ const SdrMarkList& rMark = GetMarkedObjectList();
+ sal_uLong nCount = rMark.GetMarkCount();
+ for (sal_uLong i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
+ if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
+ {
+ AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
+ pObj->SetLayer( nLayerNo );
+ }
+ }
+
+ EndUndo();
+
+ // repaint is done in SetLayer
+
+ pViewData->GetDocShell()->SetDrawModified();
+
+ // check mark list now instead of later in a timer
+ CheckMarked();
+ MarkListHasChanged();
+ }
+}
+
+bool ScDrawView::HasMarkedControl() const
+{
+ SdrObjListIter aIter( GetMarkedObjectList() );
+ for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
+ if( pObj->ISA( SdrUnoObj ) )
+ return true;
+ return false;
+}
+
+bool ScDrawView::HasMarkedInternal() const
+{
+ // internal objects should not be inside a group, but who knows...
+ SdrObjListIter aIter( GetMarkedObjectList() );
+ for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
+ if( pObj->GetLayer() == SC_LAYER_INTERN )
+ return true;
+ return false;
+}
+
+void ScDrawView::UpdateWorkArea()
+{
+ SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
+ if (pPage)
+ {
+ Point aPos;
+ Size aPageSize( pPage->GetSize() );
+ Rectangle aNewArea( aPos, aPageSize );
+ if ( aPageSize.Width() < 0 )
+ {
+ // RTL: from max.negative (left) to zero (right)
+ aNewArea.Right() = 0;
+ aNewArea.Left() = aPageSize.Width() + 1;
+ }
+ SetWorkArea( aNewArea );
+ }
+ else
+ {
+ OSL_FAIL("Page nicht gefunden");
+ }
+}
+
+void ScDrawView::DoCut()
+{
+ DoCopy();
+ BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
+ DeleteMarked(); // auf dieser View - von der 505f Umstellung nicht betroffen
+ EndUndo();
+}
+
+void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
+{
+ rFractX = aScaleX;
+ rFractY = aScaleY;
+}
+
+void ScDrawView::RecalcScale()
+{
+ double nPPTX;
+ double nPPTY;
+ Fraction aZoomX(1,1);
+ Fraction aZoomY(1,1);
+
+ if (pViewData)
+ {
+ nTab = pViewData->GetTabNo();
+ nPPTX = pViewData->GetPPTX();
+ nPPTY = pViewData->GetPPTY();
+ aZoomX = pViewData->GetZoomX();
+ aZoomY = pViewData->GetZoomY();
+ }
+ else
+ {
+ Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
+ nPPTX = aLogic.X() / 1000.0;
+ nPPTY = aLogic.Y() / 1000.0;
+ //! Zoom uebergeben ???
+ }
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pDoc->GetTableArea( nTab, nEndCol, nEndRow );
+ if (nEndCol<20)
+ nEndCol = 20;
+ if (nEndRow<20)
+ nEndRow = 1000;
+
+ ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
+ aScaleX,aScaleY );
+}
+
+void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
+{
+ if ( pViewData )
+ pViewData->GetViewShell()->ConnectObject( pOleObj );
+}
+
+void ScDrawView::MarkListHasChanged()
+{
+ FmFormView::MarkListHasChanged();
+
+ UpdateBrowser();
+
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ // #i110829# remove the cell selection only if drawing objects are selected
+ if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() )
+ {
+ pViewSh->Unmark(); // remove cell selection
+
+ // end cell edit mode if drawing objects are selected
+ SC_MOD()->InputEnterHandler();
+ }
+
+ // IP deaktivieren
+
+ ScModule* pScMod = SC_MOD();
+ bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
+
+ ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
+ {
+ // beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
+ pClient->DeactivateObject();
+ // Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
+ }
+
+ // Ole-Objekt selektiert?
+
+ SdrOle2Obj* pOle2Obj = NULL;
+ SdrGrafObj* pGrafObj = NULL;
+
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ sal_uLong nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
+ {
+ // relock layers that may have been unlocked before
+ LockBackgroundLayer();
+ LockInternalLayer();
+ }
+
+ sal_Bool bSubShellSet = false;
+ if (nMarkCount == 1)
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if (pObj->GetObjIdentifier() == OBJ_OLE2)
+ {
+ pOle2Obj = (SdrOle2Obj*) pObj;
+ if (!pDoc->IsChart(pObj) )
+ pViewSh->SetOleObjectShell(sal_True);
+ else
+ pViewSh->SetChartShell(sal_True);
+ bSubShellSet = sal_True;
+ }
+ else if (pObj->GetObjIdentifier() == OBJ_GRAF)
+ {
+ pGrafObj = (SdrGrafObj*) pObj;
+ pViewSh->SetGraphicShell(sal_True);
+ bSubShellSet = sal_True;
+ }
+ else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
+ {
+ pViewSh->SetMediaShell(true);
+ bSubShellSet = true;
+ }
+ else if (pObj->GetObjIdentifier() != OBJ_TEXT // Verhindern, das beim Anlegen
+ || !pViewSh->IsDrawTextShell()) // eines TextObjekts auf die
+ { // DrawShell umgeschaltet wird.
+ pViewSh->SetDrawShell(sal_True); //@#70206#
+ }
+ }
+
+ if ( nMarkCount && !bSubShellSet )
+ {
+ sal_Bool bOnlyControls = sal_True;
+ sal_Bool bOnlyGraf = sal_True;
+ for (sal_uLong i=0; i<nMarkCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if ( pObj->ISA( SdrObjGroup ) )
+ {
+ const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
+ sal_uLong nListCount = pLst->GetObjCount();
+ if ( nListCount == 0 )
+ {
+ // An empty group (may occur during Undo) is no control or graphics object.
+ // Creating the form shell during undo would lead to problems with the undo manager.
+ bOnlyControls = false;
+ bOnlyGraf = false;
+ }
+ for ( sal_uInt16 j = 0; j < nListCount; ++j )
+ {
+ SdrObject *pSubObj = pLst->GetObj( j );
+
+ if (!pSubObj->ISA(SdrUnoObj))
+ bOnlyControls = false;
+ if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
+ bOnlyGraf = false;
+
+ if ( !bOnlyControls && !bOnlyGraf ) break;
+ }
+ }
+ else
+ {
+ if (!pObj->ISA(SdrUnoObj))
+ bOnlyControls = false;
+ if (pObj->GetObjIdentifier() != OBJ_GRAF)
+ bOnlyGraf = false;
+ }
+
+ if ( !bOnlyControls && !bOnlyGraf ) break;
+ }
+
+ if(bOnlyControls)
+ {
+ pViewSh->SetDrawFormShell(sal_True); // jetzt UNO-Controls
+ }
+ else if(bOnlyGraf)
+ {
+ pViewSh->SetGraphicShell(sal_True);
+ }
+ else if(nMarkCount>1)
+ {
+ pViewSh->SetDrawShell(sal_True);
+ }
+ }
+
+
+
+ // Verben anpassen
+
+ SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
+ sal_Bool bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
+ uno::Sequence< embed::VerbDescriptor > aVerbs;
+ if ( pOle2Obj && !bOle )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
+ DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" );
+ if (xObj.is())
+ aVerbs = xObj->getSupportedVerbs();
+ }
+ pViewSh->SetVerbs( aVerbs );
+
+ // Image-Map Editor
+
+ if ( pOle2Obj )
+ UpdateIMap( pOle2Obj );
+ else if ( pGrafObj )
+ UpdateIMap( pGrafObj );
+
+ InvalidateAttribs(); // nach dem IMap-Editor Update
+ InvalidateDrawTextAttrs();
+
+ for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
+ {
+ ((Window&)rOutDev).Update();
+ }
+ }
+
+ // uno object for view returns drawing objects as selection,
+ // so it must notify its SelectionChangeListeners
+
+ if (pViewFrame)
+ {
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ uno::Reference<frame::XController> xController = rFrame.GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SelectionChanged();
+ }
+ }
+
+ // update selection transfer object
+
+ pViewSh->CheckSelectionTransfer();
+
+}
+
+void ScDrawView::ModelHasChanged()
+{
+ SdrObject* pEditObj = GetTextEditObject();
+ if ( pEditObj && !pEditObj->IsInserted() && pViewData )
+ {
+ // SdrObjEditView::ModelHasChanged will end text edit in this case,
+ // so make sure the EditEngine's undo manager is no longer used.
+ pViewData->GetViewShell()->SetDrawTextUndo(NULL);
+ SetCreateMode(); // don't leave FuText in a funny state
+ }
+
+ FmFormView::ModelHasChanged();
+}
+
+void ScDrawView::UpdateUserViewOptions()
+{
+ if (pViewData)
+ {
+ const ScViewOptions& rOpt = pViewData->GetOptions();
+ const ScGridOptions& rGrid = rOpt.GetGridOptions();
+
+ sal_Bool bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
+
+ SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
+ SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
+ SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
+
+ SetGridVisible( rGrid.GetGridVisible() );
+ SetSnapEnabled( rGrid.GetUseGridSnap() );
+ SetGridSnap( rGrid.GetUseGridSnap() );
+
+ Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
+ Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
+ SetSnapGridWidth( aFractX, aFractY );
+
+ SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
+ SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
+ rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
+ }
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+sal_Bool ScDrawView::SelectObject( const String& rName )
+{
+ UnmarkAll();
+
+ SCTAB nObjectTab = 0;
+ SdrObject* pFound = NULL;
+
+ SfxObjectShell* pShell = pDoc->GetDocumentShell();
+ if (pShell)
+ {
+ SdrModel* pDrawLayer = GetModel();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount && !pFound; i++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !pFound)
+ {
+ if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
+ {
+ pFound = pObject;
+ nObjectTab = i;
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+
+ if ( pFound )
+ {
+ ScTabView* pView = pViewData->GetView();
+ if ( nObjectTab != nTab ) // Tabelle umschalten
+ pView->SetTabNo( nObjectTab );
+
+ DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
+
+ pView->ScrollToObject( pFound );
+
+ /* To select an object on the background layer, the layer has to
+ be unlocked even if exclusive drawing selection mode is not active
+ (this is reversed in MarkListHasChanged when nothing is selected) */
+ if ( pFound->GetLayer() == SC_LAYER_BACK &&
+ !pViewData->GetViewShell()->IsDrawSelMode() &&
+ !pDoc->IsTabProtected( nTab ) &&
+ !pViewData->GetSfxDocShell()->IsReadOnly() )
+ {
+ UnlockBackgroundLayer();
+ }
+
+ SdrPageView* pPV = GetSdrPageView();
+ MarkObj( pFound, pPV );
+ }
+
+ return ( pFound != NULL );
+}
+
+
+bool ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, sal_uLong nOptions)
+{
+ // Markierung nicht aendern, wenn Ole-Objekt aktiv
+ // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
+
+ if (pViewData)
+ {
+ SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ return InsertObjectAtView( pObj, rPV, nOptions );
+}
+
+SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
+{
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ if( pViewData && (rMarkList.GetMarkCount() == 1) )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
+ {
+ if( ppCaptData ) *ppCaptData = pCaptData;
+ return pObj;
+ }
+ }
+ return 0;
+}
+
+void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
+{
+ SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
+ if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
+ SetLayerLocked( pLockLayer->GetName(), bLock );
+}
+
+void ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
+{
+ //! rWin richtig auswerten
+ //! ggf Zoom aendern
+
+ if ( pViewData && pViewData->GetActiveWin() == &rWin )
+ pViewData->GetView()->MakeVisible( rRect );
+}
+
+void ScDrawView::DeleteMarked()
+{
+ // try to delete a note caption object with its cell note in the Calc document
+ ScDrawObjData* pCaptData = 0;
+ if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
+ {
+ (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
+ ::svl::IUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
+ bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
+
+ // remove the cell note from document, we are its owner now
+ ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
+ DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
+ if( pNote )
+ {
+ // rescue note data for undo (with pointer to caption object)
+ ScNoteData aNoteData = pNote->GetNoteData();
+ DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
+ // collect the drawing undo action created while deleting the note
+ if( bUndo )
+ pDrawLayer->BeginCalcUndo();
+ // delete the note (already removed from document above)
+ delete pNote;
+ // add the undo action for the note
+ if( bUndo )
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
+ // repaint the cell to get rid of the note marker
+ if( pDocShell )
+ pDocShell->PostPaintCell( pCaptData->maStart );
+ // done, return now to skip call of FmFormView::DeleteMarked()
+ return;
+ }
+ }
+
+ FmFormView::DeleteMarked();
+}
+
+SdrEndTextEditKind ScDrawView::ScEndTextEdit()
+{
+ sal_Bool bIsTextEdit = IsTextEdit();
+ SdrEndTextEditKind eKind = SdrEndTextEdit();
+
+ if ( bIsTextEdit && pViewData )
+ pViewData->GetViewShell()->SetDrawTextUndo(NULL); // "normaler" Undo-Manager
+
+ return eKind;
+}
+
+void ScDrawView::MarkDropObj( SdrObject* pObj )
+{
+ if ( pDropMarkObj != pObj )
+ {
+ pDropMarkObj = pObj;
+ ImplClearCalcDropMarker();
+
+ if(pDropMarkObj)
+ {
+ pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
new file mode 100644
index 000000000000..5464a0f13f52
--- /dev/null
+++ b/sc/source/ui/view/editsh.cxx
@@ -0,0 +1,1203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <svx/clipfmtitem.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sot/exchange.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <sot/formats.hxx>
+#include <svtools/transfer.hxx>
+#include <svl/stritem.hxx>
+
+#define _EDITSH_CXX
+#include "editsh.hxx"
+
+#include "scresid.hxx"
+#include "global.hxx"
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "viewutil.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "reffind.hxx"
+#include "tabvwsh.hxx"
+#include "editutil.hxx"
+#include "globstr.hrc"
+
+#define ScEditShell
+#include "scslots.hxx"
+
+#include "scui_def.hxx"
+#include "scabstdlg.hxx"
+
+
+using namespace ::com::sun::star;
+
+
+TYPEINIT1( ScEditShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_EDIT) );
+}
+
+
+ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
+ pEditView (pView),
+ pViewData (pData),
+ pClipEvtLstnr (NULL),
+ bPastePossible (false),
+ bIsInsertMode (sal_True)
+{
+ SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("EditCell")));
+}
+
+ScEditShell::~ScEditShell()
+{
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
+
+ // The listener may just now be waiting for the SolarMutex and call the link
+ // afterwards, in spite of RemoveListener. So the link has to be reset, too.
+ pClipEvtLstnr->ClearCallbackLink();
+
+ pClipEvtLstnr->release();
+ }
+}
+
+ScInputHandler* ScEditShell::GetMyInputHdl()
+{
+ return SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
+}
+
+void ScEditShell::SetEditView(EditView* pView)
+{
+ pEditView = pView;
+ pEditView->SetInsertMode( bIsInsertMode );
+ SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+}
+
+void lcl_RemoveAttribs( EditView& rEditView )
+{
+ ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine());
+
+ sal_Bool bOld = pEngine->GetUpdateMode();
+ pEngine->SetUpdateMode(false);
+
+ String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
+ pEngine->GetUndoManager().EnterListAction( aName, aName );
+
+ rEditView.RemoveAttribs(true);
+ pEngine->RepeatDefaults(); // paragraph attributes from cell formats must be preserved
+
+ pEngine->GetUndoManager().LeaveListAction();
+
+ pEngine->SetUpdateMode(bOld);
+}
+
+void lclInsertCharacter( EditView* pTableView, EditView* pTopView, sal_Unicode cChar )
+{
+ String aString( cChar );
+ if( pTableView )
+ pTableView->InsertText( aString );
+ if( pTopView )
+ pTopView->InsertText( aString );
+}
+
+void ScEditShell::Execute( SfxRequest& rReq )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"kein ScInputHandler");
+
+ EditView* pTopView = pHdl->GetTopView(); // hat Eingabezeile den Focus?
+ EditView* pTableView = pHdl->GetTableView();
+
+ DBG_ASSERT(pTableView,"no EditView :-(");
+ /* #i91683# No EditView if spell-check dialog is active and positioned on
+ * an error and user immediately (without double click or F2) selected a
+ * text portion of that cell with the mouse and wanted to modify it. */
+ /* FIXME: Bailing out only cures the symptom and prevents a crash, no edit
+ * action is possible. A real fix somehow would need to create a valid
+ * EditView from the spell-check view. */
+ if (!pTableView)
+ return;
+
+ EditEngine* pEngine = pTableView->GetEditEngine();
+
+ pHdl->DataChanging();
+ sal_Bool bSetSelIsRef = false;
+
+ switch ( nSlot )
+ {
+ case FID_INS_CELL_CONTENTS: // Insert-Taste, weil als Acc definiert
+ bIsInsertMode = !pTableView->IsInsertMode();
+ pTableView->SetInsertMode( bIsInsertMode );
+ if (pTopView)
+ pTopView->SetInsertMode( bIsInsertMode );
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ break;
+
+ case SID_ATTR_INSERT:
+ if ( pReqArgs )
+ {
+ bIsInsertMode = ((const SfxBoolItem&)pReqArgs->Get(nSlot)).GetValue();
+ pTableView->SetInsertMode( bIsInsertMode );
+ if (pTopView)
+ pTopView->SetInsertMode( bIsInsertMode );
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ }
+ break;
+
+ case SID_THES:
+ {
+ String aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , false );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (aReplaceText.Len() > 0)
+ ReplaceTextWithSynonym( *pEditView, aReplaceText );
+ }
+ break;
+
+ case SID_COPY:
+ pTableView->Copy();
+ break;
+
+ case SID_CUT:
+ pTableView->Cut();
+ if (pTopView)
+ pTopView->DeleteSelected();
+ break;
+
+ case SID_PASTE:
+ pTableView->PasteSpecial();
+ if (pTopView)
+ pTopView->Paste();
+ break;
+
+ case SID_DELETE:
+ pTableView->DeleteSelected();
+ if (pTopView)
+ pTopView->DeleteSelected();
+ break;
+
+ case SID_CELL_FORMAT_RESET: // "Standard"
+ lcl_RemoveAttribs( *pTableView );
+ if ( pTopView )
+ lcl_RemoveAttribs( *pTopView );
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ sal_uLong nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ if (SOT_FORMAT_STRING == nFormat)
+ pTableView->Paste();
+ else
+ pTableView->PasteSpecial();
+
+ if (pTopView)
+ pTopView->Paste();
+ }
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
+ sal_uLong nFormat = 0;
+ if ( pDlg )
+ {
+ pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING );
+ pDlg->Insert( SOT_FORMAT_RTF, EMPTY_STRING );
+
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+ DELETEZ(pDlg);
+ }
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ return;
+ }
+
+ if (nFormat > 0)
+ {
+ if (SOT_FORMAT_STRING == nFormat)
+ pTableView->Paste();
+ else
+ pTableView->PasteSpecial();
+
+ if (pTopView)
+ pTopView->Paste();
+ }
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case SID_SELECTALL:
+ {
+ sal_uInt16 nPar = pEngine->GetParagraphCount();
+ if (nPar)
+ {
+ xub_StrLen nLen = pEngine->GetTextLen(nPar-1);
+ pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
+ if (pTopView)
+ pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
+ }
+ }
+ break;
+
+ case SID_CHARMAP:
+ {
+ sal_uInt16 nScript = pTableView->GetSelectedScriptType();
+ sal_uInt16 nFontWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_FONTINFO_CJK :
+ ( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_FONTINFO_CTL :
+ EE_CHAR_FONTINFO );
+ const SvxFontItem& rItem = (const SvxFontItem&)
+ pTableView->GetAttribs().Get(nFontWhich);
+
+ String aString;
+ SvxFontItem aNewItem( EE_CHAR_FONTINFO );
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
+
+ if ( pItem )
+ {
+ aString = ((const SfxStringItem*)pItem)->GetValue();
+ const SfxPoolItem* pFtItem = NULL;
+ pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
+ const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
+ if ( pFontItem )
+ {
+ String aFontName(pFontItem->GetValue());
+ Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
+ aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
+ aFont.GetStyleName(), aFont.GetPitch(),
+ aFont.GetCharSet(), ATTR_FONT );
+ }
+ else
+ aNewItem = rItem;
+ }
+ else
+ {
+ ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ return;
+ }
+ }
+
+ if ( aString.Len() )
+ {
+ // if string contains WEAK characters, set all fonts
+ sal_uInt8 nSetScript;
+ ScDocument* pDoc = pViewData->GetDocument();
+ if ( pDoc->HasStringWeakCharacters( aString ) )
+ nSetScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ else
+ nSetScript = pDoc->GetStringScriptType( aString );
+
+ SfxItemSet aSet( pTableView->GetEmptyItemSet() );
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() );
+ aSetItem.PutItemForScriptType( nSetScript, aNewItem );
+ aSet.Put( aSetItem.GetItemSet(), false );
+
+ // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
+ pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() );
+ pTableView->InsertText(aString);
+ if (pTopView)
+ pTopView->InsertText(aString);
+
+ SfxStringItem aStringItem( SID_CHARMAP, aString );
+ SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem.GetFamilyName() );
+ rReq.AppendItem( aFontItem );
+ rReq.AppendItem( aStringItem );
+ rReq.Done();
+
+
+ }
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case FID_INSERT_NAME:
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, false );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nRet = pDlg->Execute();
+ // pDlg is needed below
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ delete pDlg;
+ return;
+ }
+
+ if ( nRet == BTN_PASTE_NAME )
+ {
+ String aName = pDlg->GetSelectedName();
+ pTableView->InsertText(aName);
+ if (pTopView)
+ pTopView->InsertText(aName);
+ }
+ delete pDlg;
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case SID_CHAR_DLG:
+ {
+ SfxItemSet aAttrs( pTableView->GetAttribs() );
+
+ SfxObjectShell* pObjSh = pViewData->GetSfxDocShell();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &aAttrs,
+ pObjSh, RID_SCDLG_CHAR );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nRet = pDlg->Execute();
+ // pDlg is needed below
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ delete pDlg;
+ return;
+ }
+
+ if ( nRet == RET_OK )
+ {
+ const SfxItemSet* pOut = pDlg->GetOutputItemSet();
+ pTableView->SetAttribs( *pOut );
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_TOGGLE_REL:
+ {
+ bool bOk = false;
+ if (pEngine->GetParagraphCount() == 1)
+ {
+ String aText = pEngine->GetText();
+ ESelection aSel = pEditView->GetSelection(); // aktuelle View
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScRefFinder aFinder(aText, pViewData->GetCurPos(), pDoc, pDoc->GetAddressConvention());
+ aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos );
+ if (aFinder.GetFound())
+ {
+ String aNew = aFinder.GetText();
+ ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() );
+ pEngine->SetText( aNew );
+ pTableView->SetSelection( aNewSel );
+ if ( pTopView )
+ {
+ pTopView->GetEditEngine()->SetText( aNew );
+ pTopView->SetSelection( aNewSel );
+ }
+ bOk = true;
+
+ // Referenz wird selektiert -> beim Tippen nicht ueberschreiben
+ bSetSelIsRef = sal_True;
+ }
+ }
+ if (!bOk)
+ Sound::Beep(); // keine Referenzen oder mehrere Absaetze
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ SvxLinkInsertMode eMode = pHyper->GetInsertMode();
+
+ sal_Bool bDone = false;
+ if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD )
+ {
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ {
+ // altes Feld selektieren
+
+ ESelection aSel = pTableView->GetSelection();
+ aSel.Adjust();
+ aSel.nEndPara = aSel.nStartPara;
+ aSel.nEndPos = aSel.nStartPos + 1;
+ pTableView->SetSelection( aSel );
+
+ // neues Feld einfuegen
+
+ SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
+ aURLField.SetTargetFrame( rTarget );
+ SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
+ pTableView->InsertField( aURLItem );
+ pTableView->SetSelection( aSel ); // select inserted field
+
+ // jetzt doch auch Felder in der Top-View
+
+ if ( pTopView )
+ {
+ aSel = pTopView->GetSelection();
+ aSel.nEndPara = aSel.nStartPara;
+ aSel.nEndPos = aSel.nStartPos + 1;
+ pTopView->SetSelection( aSel );
+ pTopView->InsertField( aURLItem );
+ pTopView->SetSelection( aSel ); // select inserted field
+ }
+
+ bDone = sal_True;
+ }
+ }
+
+ if (!bDone)
+ {
+ pViewData->GetViewShell()->
+ InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode );
+
+ // InsertURL an der ViewShell schaltet bei "Button"
+ // die EditShell ab, darum sofort return
+
+ return;
+ }
+ }
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
+ return;
+ }
+ //break;
+
+ case FN_INSERT_SOFT_HYPHEN:
+ lclInsertCharacter( pTableView, pTopView, CHAR_SHY );
+ break;
+ case FN_INSERT_HARDHYPHEN:
+ lclInsertCharacter( pTableView, pTopView, CHAR_NBHY );
+ break;
+ case FN_INSERT_HARD_SPACE:
+ lclInsertCharacter( pTableView, pTopView, CHAR_NBSP );
+ break;
+ case SID_INSERT_RLM:
+ lclInsertCharacter( pTableView, pTopView, CHAR_RLM );
+ break;
+ case SID_INSERT_LRM:
+ lclInsertCharacter( pTableView, pTopView, CHAR_LRM );
+ break;
+ case SID_INSERT_ZWSP:
+ lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP );
+ break;
+ case SID_INSERT_ZWNBSP:
+ lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
+ break;
+ }
+
+ pHdl->DataChanged();
+ if (bSetSelIsRef)
+ pHdl->SetSelIsRef(sal_True);
+}
+
+void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScEditShell::GetState( SfxItemSet& rSet )
+{
+ // When deactivating the view, edit mode is stopped, but the EditShell is left active
+ // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted
+ // into the EditEngine, so it can have an invalid selection and must not be used.
+ if ( !pViewData->HasEditView( pViewData->GetActivePart() ) )
+ {
+ lcl_DisableAll( rSet );
+ return;
+ }
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_ATTR_INSERT: // Statuszeile
+ {
+ if ( pActiveView )
+ rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, 42 ) );
+ }
+ break;
+
+ case SID_HYPERLINK_GETLINK:
+ {
+ SvxHyperlinkItem aHLinkItem;
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ {
+ aHLinkItem.SetName( pURLField->GetRepresentation() );
+ aHLinkItem.SetURL( pURLField->GetURL() );
+ aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
+ }
+ else if ( pActiveView )
+ {
+ // use selected text as name for urls
+ String sReturn = pActiveView->GetSelected();
+ sReturn.Erase(255);
+ sReturn.EraseTrailingChars();
+ aHLinkItem.SetName(sReturn);
+ }
+ rSet.Put(aHLinkItem);
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ if ( !GetURLField() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ case SID_INSERT_RLM:
+ case SID_INSERT_LRM:
+ case SID_INSERT_ZWNBSP:
+ case SID_INSERT_ZWSP:
+ ScViewUtil::HideDisabledSlot( rSet, pViewData->GetBindings(), nWhich );
+ break;
+
+ case SID_THES:
+ {
+ String aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, *pActiveView );
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable thesaurus context menu entry if there is nothing to look up
+ sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
+ if (!bIsLookUpWord || !bCanDoThesaurus)
+ rSet.DisableItem( SID_THES );
+ }
+ break;
+
+
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+const SvxURLField* ScEditShell::GetURLField()
+{
+ ScInputHandler* pHdl = GetMyInputHdl();
+ EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
+ if ( pActiveView )
+ {
+ const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ return (const SvxURLField*)pField;
+ }
+ }
+
+ return NULL;
+}
+
+IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+void ScEditShell::GetClipState( SfxItemSet& rSet )
+{
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ Window* pWin = pViewData->GetActiveWin();
+ pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+ bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_PASTE:
+ case SID_PASTE_SPECIAL:
+ if( !bPastePossible )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ if( bPastePossible )
+ {
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
+ if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
+
+ rSet.Put( aFormats );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void lcl_InvalidateUnder( SfxBindings& rBindings )
+{
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+}
+
+void ScEditShell::ExecuteAttr(SfxRequest& rReq)
+{
+ SfxItemSet aSet( pEditView->GetEmptyItemSet() );
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_FONT:
+ {
+ if (pArgs)
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ {
+ nScript = pEditView->GetSelectedScriptType();
+ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
+ }
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+ aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
+
+ aSet.Put( aSetItem.GetItemSet(), false );
+ }
+ }
+ break;
+
+ case SID_ATTR_CHAR_COLOR:
+ {
+ if (pArgs)
+ {
+ aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) );
+ rBindings.Invalidate( nSlot );
+ }
+ }
+ break;
+
+ // Toggles
+
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+
+ sal_Bool bOld = false;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() > WEIGHT_NORMAL )
+ bOld = sal_True;
+
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ aSetItem.PutItemForScriptType( nScript,
+ SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) );
+ aSet.Put( aSetItem.GetItemSet(), false );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+
+ sal_Bool bOld = false;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxPostureItem*)pCore)->GetValue() != ITALIC_NONE )
+ bOld = sal_True;
+
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ aSetItem.PutItemForScriptType( nScript,
+ SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) );
+ aSet.Put( aSetItem.GetItemSet(), false );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ULINE_VAL_NONE:
+ aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
+ lcl_InvalidateUnder( rBindings );
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE: // Toggles
+ case SID_ULINE_VAL_SINGLE:
+ case SID_ULINE_VAL_DOUBLE:
+ case SID_ULINE_VAL_DOTTED:
+ {
+ FontUnderline eOld = ((const SvxUnderlineItem&) pEditView->
+ GetAttribs().Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ FontUnderline eNew = eOld;
+ switch (nSlot)
+ {
+ case SID_ATTR_CHAR_UNDERLINE:
+ eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_SINGLE:
+ eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_DOUBLE:
+ eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
+ break;
+ case SID_ULINE_VAL_DOTTED:
+ eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
+ break;
+ }
+ aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
+ lcl_InvalidateUnder( rBindings );
+ }
+ break;
+
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ FontUnderline eOld = ((const SvxOverlineItem&) pEditView->
+ GetAttribs().Get(EE_CHAR_OVERLINE)).GetLineStyle();
+ FontUnderline eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_STRIKEOUT:
+ {
+ sal_Bool bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE;
+ aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_SHADOWED:
+ {
+ sal_Bool bOld = ((const SvxShadowedItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_SHADOW)).GetValue();
+ aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_CONTOUR:
+ {
+ sal_Bool bOld = ((const SvxContourItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_OUTLINE)).GetValue();
+ aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_SET_SUPER_SCRIPT:
+ {
+ SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
+ pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
+ SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ?
+ SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT;
+ aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+ case SID_SET_SUB_SCRIPT:
+ {
+ SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
+ pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
+ SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ?
+ SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT;
+ aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+ }
+
+ //
+ // anwenden
+ //
+
+ EditEngine* pEngine = pEditView->GetEditEngine();
+ sal_Bool bOld = pEngine->GetUpdateMode();
+ pEngine->SetUpdateMode(false);
+
+ pEditView->SetAttribs( aSet );
+
+ pEngine->SetUpdateMode(bOld);
+ pEditView->Invalidate();
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ pHdl->SetModified();
+
+ rReq.Done();
+}
+
+void ScEditShell::GetAttrState(SfxItemSet &rSet)
+{
+ if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326#
+ {
+ lcl_DisableAll( rSet );
+ return;
+ }
+
+ SfxItemSet aAttribs = pEditView->GetAttribs();
+ rSet.Put( aAttribs );
+
+ // choose font info according to selection script type
+
+ sal_uInt16 nScript = pEditView->GetSelectedScriptType();
+ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
+
+ // #i55929# input-language-dependent script type (depends on input language if nothing selected)
+ sal_uInt16 nInputScript = nScript;
+ if ( !pEditView->GetSelection().HasRange() )
+ {
+ LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
+ if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+
+ // #i55929# according to spec, nInputScript is used for font and font height only
+ if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript );
+ if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript );
+ if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript );
+ if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript );
+
+ // Unterstreichung
+
+ SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, sal_True );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rSet.InvalidateItem( SID_ULINE_VAL_NONE );
+ rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
+ }
+ else
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ aAttribs.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ sal_uInt16 nId = SID_ULINE_VAL_NONE;
+ switch (eUnderline)
+ {
+ case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
+ case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
+ case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
+ default:
+ break;
+ }
+ rSet.Put( SfxBoolItem( nId, sal_True ) );
+ }
+
+ //! Testen, ob Klammer-Hervorhebung aktiv ist !!!!
+ ScInputHandler* pHdl = GetMyInputHdl();
+ if ( pHdl && pHdl->IsFormulaMode() )
+ rSet.ClearItem( EE_CHAR_WEIGHT ); // hervorgehobene Klammern hier nicht
+}
+
+String ScEditShell::GetSelectionText( sal_Bool bWholeWord )
+{
+ String aStrSelection;
+
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326#
+ {
+ if ( bWholeWord )
+ {
+ EditEngine* pEngine = pEditView->GetEditEngine();
+ ESelection aSel = pEditView->GetSelection();
+ String aStrCurrentDelimiters = pEngine->GetWordDelimiters();
+
+ pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) );
+ aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
+ pEngine->SetWordDelimiters( aStrCurrentDelimiters );
+ }
+ else
+ {
+ aStrSelection = pEditView->GetSelected();
+ }
+ }
+
+ return aStrSelection;
+}
+
+void ScEditShell::ExecuteUndo(SfxRequest& rReq)
+{
+ // Undo must be handled here because it's called for both EditViews
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"no ScInputHandler");
+ EditView* pTopView = pHdl->GetTopView();
+ EditView* pTableView = pHdl->GetTableView();
+ DBG_ASSERT(pTableView,"no EditView");
+
+ pHdl->DataChanging();
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ sal_Bool bIsUndo = ( nSlot == SID_UNDO );
+
+ sal_uInt16 nCount = 1;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
+ nCount = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ if ( bIsUndo )
+ {
+ pTableView->Undo();
+ if (pTopView)
+ pTopView->Undo();
+ }
+ else
+ {
+ pTableView->Redo();
+ if (pTopView)
+ pTopView->Redo();
+ }
+ }
+ }
+ break;
+ }
+ pViewData->GetBindings().InvalidateAll(false);
+
+ pHdl->DataChanged();
+}
+
+void ScEditShell::GetUndoState(SfxItemSet &rSet)
+{
+ // Undo state is taken from normal ViewFrame state function
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if ( pViewFrm && GetUndoManager() )
+ {
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ pViewFrm->GetSlotState( nWhich, NULL, &rSet );
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+ // disable if no action in input line EditView
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"no ScInputHandler");
+ EditView* pTopView = pHdl->GetTopView();
+ if (pTopView)
+ {
+ ::svl::IUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
+ if ( rTopMgr.GetUndoActionCount() == 0 )
+ rSet.DisableItem( SID_UNDO );
+ if ( rTopMgr.GetRedoActionCount() == 0 )
+ rSet.DisableItem( SID_REDO );
+ }
+}
+
+void ScEditShell::ExecuteTrans( SfxRequest& rReq )
+{
+ sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
+ if ( nType )
+ {
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT( pHdl, "no ScInputHandler" );
+
+ EditView* pTopView = pHdl->GetTopView();
+ EditView* pTableView = pHdl->GetTableView();
+ DBG_ASSERT( pTableView, "no EditView" );
+
+ pHdl->DataChanging();
+
+ pTableView->TransliterateText( nType );
+ if (pTopView)
+ pTopView->TransliterateText( nType );
+
+ pHdl->DataChanged();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
new file mode 100644
index 000000000000..eb839d58ce5d
--- /dev/null
+++ b/sc/source/ui/view/formatsh.cxx
@@ -0,0 +1,2242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+//------------------------------------------------------------------
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SI_NOSBXCONTROLS
+#define _VCONT_HXX
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/stritem.hxx>
+#include <svl/zformat.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/numinf.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <editeng/svxenum.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/bolnitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/justifyitem.hxx>
+
+#include "formatsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "docsh.hxx"
+#include "patattr.hxx"
+#include "scmod.hxx"
+#include "attrdlg.hrc"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
+#include "printfun.hxx"
+#include "docpool.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "undostyl.hxx"
+
+
+#define ScFormatShell
+#define TableFont
+#define FormatForSelection
+#include "scslots.hxx"
+
+#include "scabstdlg.hxx"
+
+namespace {
+
+SvxCellHorJustify lclConvertSlotToHAlign( sal_uInt16 nSlot )
+{
+ SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD;
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_HDEFAULT: eHJustify = SVX_HOR_JUSTIFY_STANDARD; break;
+ case SID_ALIGN_ANY_LEFT: eHJustify = SVX_HOR_JUSTIFY_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER: eHJustify = SVX_HOR_JUSTIFY_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT: eHJustify = SVX_HOR_JUSTIFY_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: eHJustify = SVX_HOR_JUSTIFY_BLOCK; break;
+ default: DBG_ERRORFILE( "lclConvertSlotToHAlign - invalid slot" );
+ }
+ return eHJustify;
+}
+
+SvxCellVerJustify lclConvertSlotToVAlign( sal_uInt16 nSlot )
+{
+ SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD;
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_VDEFAULT: eVJustify = SVX_VER_JUSTIFY_STANDARD; break;
+ case SID_ALIGN_ANY_TOP: eVJustify = SVX_VER_JUSTIFY_TOP; break;
+ case SID_ALIGN_ANY_VCENTER: eVJustify = SVX_VER_JUSTIFY_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM: eVJustify = SVX_VER_JUSTIFY_BOTTOM; break;
+ default: DBG_ERRORFILE( "lclConvertSlotToVAlign - invalid slot" );
+ }
+ return eVJustify;
+}
+
+} // namespace
+
+TYPEINIT1( ScFormatShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_FORMAT));
+
+}
+
+
+ScFormatShell::ScFormatShell(ScViewData* pData) :
+ SfxShell(pData->GetViewShell()),
+ pViewData(pData)
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+
+ SetPool( &pTabViewShell->GetPool() );
+ ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId(HID_SCSHELL_FORMATSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format")));
+}
+
+ScFormatShell::~ScFormatShell()
+{
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetStyleState( SfxItemSet& rSet )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
+
+ sal_Bool bProtected = false;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (pDoc->IsTabProtected(i)) // ueberhaupt eine Tabelle geschuetzt?
+ bProtected = sal_True;
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_uInt16 nSlotId = 0;
+
+ while ( nWhich )
+ {
+ nSlotId = SfxItemPool::IsWhich( nWhich )
+ ? GetPool().GetSlotId( nWhich )
+ : nWhich;
+
+ switch ( nSlotId )
+ {
+ case SID_STYLE_APPLY:
+ if ( !pStylePool )
+ rSet.DisableItem( nSlotId );
+ break;
+
+ case SID_STYLE_FAMILY2: // Zellvorlagen
+ {
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)
+ pTabViewShell->GetStyleSheetFromMarked();
+
+ if ( pStyleSheet )
+ rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
+ else
+ rSet.Put( SfxTemplateItem( nSlotId, String() ) );
+ }
+ break;
+
+ case SID_STYLE_FAMILY4: // Seitenvorlagen
+ {
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ String aPageStyle = pDoc->GetPageStyle( nCurTab );
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStylePool->
+ Find( aPageStyle, SFX_STYLE_FAMILY_PAGE );
+
+ if ( pStyleSheet )
+ rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) );
+ else
+ rSet.Put( SfxTemplateItem( nSlotId, String() ) );
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) );
+ }
+ break;
+
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ ISfxTemplateCommon* pDesigner = SFX_APP()->
+ GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
+ sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+
+ if ( bProtected || bPage )
+ rSet.DisableItem( nSlotId );
+ }
+ break;
+
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ {
+ ISfxTemplateCommon* pDesigner = SFX_APP()->
+ GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
+ sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+
+ if ( bProtected && !bPage )
+ rSet.DisableItem( nSlotId );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
+{
+ // Wenn ToolBar vertikal :
+ if ( !rReq.GetArgs() )
+ {
+ pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ return;
+ }
+
+ //--------------------------------------------------------------------
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const sal_uInt16 nSlotId = rReq.GetSlot();
+ const SCTAB nCurTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScModule* pScMod = SC_MOD();
+ String aRefName;
+ sal_Bool bUndo = pDoc->IsUndoEnabled();
+
+ if ( (nSlotId == SID_STYLE_NEW)
+ || (nSlotId == SID_STYLE_EDIT)
+ || (nSlotId == SID_STYLE_DELETE)
+ || (nSlotId == SID_STYLE_APPLY)
+ || (nSlotId == SID_STYLE_WATERCAN)
+ || (nSlotId == SID_STYLE_FAMILY)
+ || (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
+ || (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) )
+ {
+ SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = NULL;
+
+ sal_Bool bStyleToMarked = false;
+ sal_Bool bListAction = false;
+ sal_Bool bAddUndo = false; // add ScUndoModifyStyle (style modified)
+ ScStyleSaveData aOldData; // for undo/redo
+ ScStyleSaveData aNewData;
+
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA;
+ const SfxPoolItem* pFamItem;
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, sal_True, &pFamItem ) )
+ eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue();
+ else
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, sal_True, &pFamItem ) )
+ {
+ String sFamily = ((const SfxStringItem*)pFamItem)->GetValue();
+ if (sFamily.CompareToAscii("CellStyles") == COMPARE_EQUAL)
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ else
+ if (sFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL)
+ eFamily = SFX_STYLE_FAMILY_PAGE;
+ }
+
+ String aStyleName;
+ sal_uInt16 nRetMask = 0xffff;
+
+ pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL );
+
+ switch ( nSlotId )
+ {
+ case SID_STYLE_NEW:
+ {
+ const SfxPoolItem* pNameItem;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem ))
+ aStyleName = ((const SfxStringItem*)pNameItem)->GetValue();
+
+ const SfxPoolItem* pRefItem=NULL;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, sal_True, &pRefItem ))
+ {
+ if(pRefItem!=NULL)
+ aRefName = ((const SfxStringItem*)pRefItem)->GetValue();
+ }
+
+ pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF ) );
+
+ if ( pStyleSheet && pStyleSheet->HasParentSupport() )
+ pStyleSheet->SetParent(aRefName);
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, false );
+ SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, false );
+ if ( pFamilyItem && pNameItem )
+ {
+ com::sun::star::uno::Reference< com::sun::star::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), com::sun::star::uno::UNO_QUERY);
+ try
+ {
+ com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xStyles;
+ com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xCont = xModel->getStyleFamilies();
+ xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xInfo;
+ xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
+ ::rtl::OUString aUIName;
+ xInfo->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")) ) >>= aUIName;
+ if ( aUIName.getLength() )
+ rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
+ }
+ catch( com::sun::star::uno::Exception& )
+ {
+ }
+ }
+ }
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ const SfxPoolItem* pNameItem;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem ))
+ aStyleName = ((const SfxStringItem*)pNameItem)->GetValue();
+ pStyleSheet = pStylePool->Find( aStyleName, eFamily );
+
+ aOldData.InitFromStyle( pStyleSheet );
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ sal_Bool bWaterCan = pScMod->GetIsWaterCan();
+
+ if( !bWaterCan )
+ {
+ const SfxPoolItem* pItem;
+
+ if ( SFX_ITEM_SET ==
+ pArgs->GetItemState( nSlotId, sal_True, &pItem ) )
+ {
+ const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem);
+ if ( pStrItem )
+ {
+ aStyleName = pStrItem->GetValue();
+ pStyleSheet = pStylePool->Find( aStyleName, eFamily );
+
+ if ( pStyleSheet )
+ {
+ ((ScStyleSheetPool*)pStylePool)->
+ SetActualStyleSheet( pStyleSheet );
+ rReq.Done();
+ }
+ }
+ }
+ }
+
+ if ( !bWaterCan && pStyleSheet )
+ {
+ pScMod->SetWaterCan( sal_True );
+ pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) );
+ rReq.Done();
+ }
+ else
+ {
+ pScMod->SetWaterCan( false );
+ pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) );
+ rReq.Done();
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ // Neuen Style fuer WaterCan-Mode setzen
+ if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
+ ((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet );
+
+ switch ( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ switch ( nSlotId )
+ {
+ case SID_STYLE_DELETE:
+ {
+ if ( pStyleSheet )
+ {
+ pTabViewShell->RemoveStyleSheetInUse( pStyleSheet );
+ pStylePool->Remove( pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ nRetMask = sal_True;
+ bAddUndo = sal_True;
+ rReq.Done();
+ }
+ else
+ nRetMask = false;
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ if ( pStyleSheet && !pScMod->GetIsWaterCan() )
+ {
+ // Anwenden der Vorlage auf das Dokument
+ pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ // Vorlage erzeugen/ersetzen durch Attribute
+ // an der Cursor-Position:
+
+ const ScPatternAttr* pAttrItem = NULL;
+
+ // Die Abfrage, ob markiert ist, war hier immer falsch,
+ // darum jetzt gar nicht mehr, und einfach vom Cursor.
+ // Wenn Attribute aus der Selektion genommen werden sollen,
+ // muss noch darauf geachtet werden, Items aus Vorlagen nicht
+ // zu uebernehmen (GetSelectionPattern sammelt auch Items aus
+ // Vorlagen zusammen) (#44748#)
+ // pAttrItem = GetSelectionPattern();
+
+ // ScViewData* pViewData = GetViewData();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab );
+
+ SfxItemSet aAttrSet = pAttrItem->GetItemSet();
+ aAttrSet.ClearItem( ATTR_MERGE );
+ aAttrSet.ClearItem( ATTR_MERGE_FLAG );
+ // bedingte Formatierung und Gueltigkeit nicht uebernehmen,
+ // weil sie in der Vorlage nicht editiert werden koennen
+ aAttrSet.ClearItem( ATTR_VALIDDATA );
+ aAttrSet.ClearItem( ATTR_CONDITIONAL );
+
+ if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId )
+ {
+ if ( bUndo )
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ bListAction = sal_True;
+ }
+
+ sal_Bool bConvertBack = false;
+ SfxStyleSheet* pSheetInUse = (SfxStyleSheet*)
+ pTabViewShell->GetStyleSheetFromMarked();
+
+ // wenn neuer Style vorhanden und in der Selektion
+ // verwendet wird, so darf der Parent nicht uebernommen
+ // werden:
+
+ if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
+ pSheetInUse = NULL;
+
+ // wenn bereits vorhanden, erstmal entfernen...
+ if ( pStyleSheet )
+ {
+ // Style-Pointer zu Namen vor Erase,
+ // weil Zellen sonst ungueltige Pointer
+ // enthalten.
+ //!!! bei Gelenheit mal eine Methode, die
+ // das fuer einen bestimmten Style macht
+ pDoc->StylesToNames();
+ bConvertBack = sal_True;
+ pStylePool->Remove(pStyleSheet);
+ }
+
+ // ...und neu anlegen
+ pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF );
+
+ // wenn ein Style vorhanden ist, so wird dieser
+ // Parent der neuen Vorlage:
+ if ( pSheetInUse && pStyleSheet->HasParentSupport() )
+ pStyleSheet->SetParent( pSheetInUse->GetName() );
+
+ if ( bConvertBack )
+ // Namen zu Style-Pointer
+ pDoc->UpdStlShtPtrsFrmNms();
+ else
+ pDoc->GetPool()->CellStyleCreated( aStyleName );
+
+ // Attribute uebernehmen und Style anwenden
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
+
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
+ // (pStyleSheet pointer is used!)
+ bStyleToMarked = sal_True;
+ }
+ else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
+ {
+ pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked();
+
+ if ( pStyleSheet )
+ {
+ aOldData.InitFromStyle( pStyleSheet );
+
+ if ( bUndo )
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ bListAction = sal_True;
+ }
+
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
+
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
+ // (pStyleSheet pointer is used!)
+ bStyleToMarked = sal_True;
+ }
+ }
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = sal_True;
+ rReq.Done();
+ }
+ break;
+
+ default:
+ break;
+ }
+ } // case SFX_STYLE_FAMILY_PARA:
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ switch ( nSlotId )
+ {
+ case SID_STYLE_DELETE:
+ {
+ nRetMask = ( NULL != pStyleSheet );
+ if ( pStyleSheet )
+ {
+ if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) )
+ {
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nCurTab ).UpdatePages();
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+ pStylePool->Remove( pStyleSheet );
+ rBindings.Invalidate( SID_STYLE_FAMILY4 );
+ pDocSh->SetDocumentModified();
+ bAddUndo = sal_True;
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ nRetMask = ( NULL != pStyleSheet );
+ if ( pStyleSheet && !pScMod->GetIsWaterCan() )
+ {
+ ScUndoApplyPageStyle* pUndoAction = 0;
+ for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ {
+ if( rMark.GetTableSelect( nTab ) )
+ {
+ String aOldName = pDoc->GetPageStyle( nTab );
+ if ( aOldName != aStyleName )
+ {
+ pDoc->SetPageStyle( nTab, aStyleName );
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nTab ).UpdatePages();
+ if( !pUndoAction )
+ pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName );
+ pUndoAction->AddSheetAction( nTab, aOldName );
+ }
+ }
+ }
+ if( pUndoAction )
+ {
+ pDocSh->GetUndoManager()->AddUndoAction( pUndoAction );
+ pDocSh->SetDocumentModified();
+ rBindings.Invalidate( SID_STYLE_FAMILY4 );
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab );
+
+ if ( rStrCurStyle != aStyleName )
+ {
+ SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily );
+ SfxItemSet aAttrSet = pCurStyle->GetItemSet();
+ SCTAB nInTab;
+ sal_Bool bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab );
+
+ // wenn bereits vorhanden, erstmal entfernen...
+ if ( pStyleSheet )
+ pStylePool->Remove( pStyleSheet );
+
+ // ...und neu anlegen
+ pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF );
+
+ // Attribute uebernehmen
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pDocSh->SetDocumentModified();
+
+ // wenn in Verwendung -> Update
+ if ( bUsed )
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nInTab ).UpdatePages();
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = sal_True;
+ rReq.Done();
+ nRetMask = sal_True;
+ }
+ }
+ break;
+
+ default:
+ break;
+ } // switch ( nSlotId )
+ } // case SFX_STYLE_FAMILY_PAGE:
+ break;
+
+ default:
+ break;
+ } // switch ( eFamily )
+
+ // Neu anlegen oder bearbeiten ueber Dialog:
+ if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT )
+ {
+ if ( pStyleSheet )
+ {
+ SvxNumberInfoItem* pNumberInfoItem = NULL;
+
+ SfxStyleFamily eFam = pStyleSheet->GetFamily();
+ SfxAbstractTabDialog* pDlg = NULL;
+ sal_uInt16 nRsc = 0;
+
+ // alte Items aus der Vorlage merken
+ SfxItemSet aOldSet = pStyleSheet->GetItemSet();
+ String aOldName = pStyleSheet->GetName();
+
+ switch ( eFam )
+ {
+ case SFX_STYLE_FAMILY_PAGE:
+ nRsc = RID_SCDLG_STYLES_PAGE;
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ default:
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+
+ const SfxPoolItem* pItem;
+ if ( rSet.GetItemState( ATTR_VALUE_FORMAT,
+ false, &pItem ) == SFX_ITEM_SET )
+ {
+ // NumberFormat Value aus Value und Language
+ // erzeugen und eintueten
+ sal_uLong nFormat =
+ ((SfxUInt32Item*)pItem)->GetValue();
+ LanguageType eLang =
+ ((SvxLanguageItem*)&rSet.Get(
+ ATTR_LANGUAGE_FORMAT ))->GetLanguage();
+ sal_uLong nLangFormat = pDoc->GetFormatTable()->
+ GetFormatForLanguageIfBuiltIn( nFormat, eLang );
+ if ( nLangFormat != nFormat )
+ {
+ SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
+ rSet.Put( aNewItem );
+ aOldSet.Put( aNewItem );
+ // auch in aOldSet fuer Vergleich nach dem Dialog,
+ // sonst geht evtl. eine Aenderung der Sprache verloren
+ }
+ }
+
+ pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
+ pDocSh->PutItem( *pNumberInfoItem );
+ nRsc = RID_SCDLG_STYLES_PAR;
+
+ // auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set:
+ // (wenn gar kein Item da ist, loescht der Dialog auch das
+ // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set)
+
+ if ( rSet.GetItemState( ATTR_BORDER_INNER, false ) != SFX_ITEM_SET )
+ {
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+ aBoxInfoItem.SetTable(false); // keine inneren Linien
+ aBoxInfoItem.SetDist(sal_True);
+ aBoxInfoItem.SetMinDist(false);
+ rSet.Put( aBoxInfoItem );
+ }
+ }
+ break;
+ }
+
+ // If GetDefDialogParent is a dialog, it must be used
+ // (style catalog)
+
+ Window* pParent = Application::GetDefDialogParent();
+ if ( !pParent || !pParent->IsDialog() )
+ {
+ // GetDefDialogParent currently doesn't return the window
+ // that was set with SetDefDialogParent (but dynamically finds the
+ // topmost parent of the focus window), so IsDialog above is FALSE
+ // even if called from the style catalog.
+ // -> Use NULL if a modal dialog is open, to enable the Dialog's
+ // default parent handling.
+ if ( Application::IsInModalMode() )
+ pParent = NULL;
+ else
+ pParent = pTabViewShell->GetDialogParent();
+ }
+
+ pTabViewShell->SetInFormatDialog(sal_True);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nResult = pDlg->Execute();
+ pTabViewShell->SetInFormatDialog(false);
+
+ if ( nResult == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ if ( pOutSet )
+ {
+ nRetMask = pStyleSheet->GetMask();
+
+ // Attribut-Vergleiche (frueher in ModifyStyleSheet)
+ // jetzt hier mit den alten Werten (Style ist schon veraendert)
+
+ if ( SFX_STYLE_FAMILY_PARA == eFam )
+ {
+ SfxItemSet& rNewSet = pStyleSheet->GetItemSet();
+ sal_Bool bNumFormatChanged;
+ if ( ScGlobal::CheckWidthInvalidate(
+ bNumFormatChanged, aOldSet, rNewSet ) )
+ pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, false);
+
+ sal_uLong nOldFormat = ((const SfxUInt32Item&)aOldSet.
+ Get( ATTR_VALUE_FORMAT )).GetValue();
+ sal_uLong nNewFormat = ((const SfxUInt32Item&)rNewSet.
+ Get( ATTR_VALUE_FORMAT )).GetValue();
+ if ( nNewFormat != nOldFormat )
+ {
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
+ const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
+ if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
+ rNewSet.Put( SvxLanguageItem(
+ pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
+ }
+
+ pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() );
+ }
+ else
+ {
+ //! auch fuer Seitenvorlagen die Abfragen hier
+
+ String aNewName = pStyleSheet->GetName();
+ if ( aNewName != aOldName &&
+ pDoc->RenamePageStyleInUse( aOldName, aNewName ) )
+ {
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+
+ pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+
+ pDocSh->SetDocumentModified();
+
+ if ( SFX_STYLE_FAMILY_PARA == eFam )
+ {
+ pTabViewShell->UpdateNumberFormatter( pDoc,
+ (const SvxNumberInfoItem&)
+ *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) );
+
+ pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ }
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = sal_True;
+ }
+ }
+ else
+ {
+ if ( nSlotId == SID_STYLE_NEW )
+ pStylePool->Remove( pStyleSheet );
+ else
+ {
+ // falls zwischendurch etwas mit dem temporaer geaenderten
+ // ItemSet gepainted wurde:
+ pDocSh->PostPaintGridAll();
+ }
+ }
+ delete pDlg;
+ }
+ }
+
+ rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) );
+
+ if ( bAddUndo && bUndo)
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) );
+
+ if ( bStyleToMarked )
+ {
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
+ // so redo will find the modified style
+ pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ }
+
+ if ( bListAction )
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ else
+ {
+ OSL_FAIL( "Unknown slot (ScViewShell::ExecuteStyle)" );
+ }
+}
+
+void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ // Eingabe beenden
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ switch ( nSlot )
+ {
+ case SID_NUMBER_TWODEC:
+ case SID_NUMBER_SCIENTIFIC:
+ case SID_NUMBER_DATE:
+ case SID_NUMBER_CURRENCY:
+ case SID_NUMBER_PERCENT:
+ case SID_NUMBER_STANDARD:
+ case SID_NUMBER_FORMAT:
+ case SID_NUMBER_INCDEC:
+ case SID_NUMBER_DECDEC:
+ case FID_DEFINE_NAME:
+ case FID_USE_NAME:
+ case FID_INSERT_NAME:
+ case SID_SPELL_DIALOG:
+ case SID_HANGUL_HANJA_CONVERSION:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ short nType = GetCurrentNumberFormatType();
+ SfxItemSet aSet( GetPool(), nSlot, nSlot );
+ switch ( nSlot )
+ {
+ case SID_NUMBER_TWODEC:
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 ); // Standard+4 = #.##0,00
+ rReq.Done();
+ break;
+ case SID_NUMBER_SCIENTIFIC:
+ if ((nType & NUMBERFORMAT_SCIENTIFIC))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_SCIENTIFIC)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_DATE:
+ if ((nType & NUMBERFORMAT_DATE))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_DATE)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_TIME:
+ if ((nType & NUMBERFORMAT_TIME))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_TIME)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_CURRENCY:
+ if ((nType & NUMBERFORMAT_CURRENCY))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_CURRENCY)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_PERCENT:
+ if ((nType & NUMBERFORMAT_PERCENT))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_PERCENT)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_STANDARD:
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ rReq.Done();
+ break;
+ case SID_NUMBER_INCDEC:
+ pTabViewShell->ChangeNumFmtDecimals( sal_True );
+ rReq.Done();
+ break;
+ case SID_NUMBER_DECDEC:
+ pTabViewShell->ChangeNumFmtDecimals( false );
+ rReq.Done();
+ break;
+
+ case SID_NUMBER_FORMAT:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET)
+ {
+ String aCode = ((const SfxStringItem*)pItem)->GetValue();
+ pTabViewShell->SetNumFmtByStr( aCode );
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ // We have to accomplish this using ApplyAttributes()
+ // because we also need the language information to be
+ // considered.
+ const SfxItemSet& rOldSet =
+ pTabViewShell->GetSelectionPattern()->GetItemSet();
+ SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
+ SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
+ aNewSet.Put( *pItem );
+ pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True );
+ }
+ }
+ break;
+
+ default:
+ OSL_FAIL("falscher Slot bei ExecuteEdit");
+ break;
+ }
+}
+
+
+//------------------------------------------------------------------
+
+#define APPLY_HOR_JUSTIFY(j) \
+ { \
+ if ( !pHorJustify || (eHorJustify != (j) ) ) \
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \
+ else \
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \
+ }
+
+#define APPLY_VER_JUSTIFY(j) \
+ { \
+ if ( !pVerJustify || (eVerJustify != (j) ) ) \
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \
+ else \
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \
+ }
+
+void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pSet = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ switch( nSlot )
+ {
+ // pseudo slots for Format menu
+ case SID_ALIGN_ANY_HDEFAULT:
+ case SID_ALIGN_ANY_LEFT:
+ case SID_ALIGN_ANY_HCENTER:
+ case SID_ALIGN_ANY_RIGHT:
+ case SID_ALIGN_ANY_JUSTIFIED:
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
+ break;
+ case SID_ALIGN_ANY_VDEFAULT:
+ case SID_ALIGN_ANY_TOP:
+ case SID_ALIGN_ANY_VCENTER:
+ case SID_ALIGN_ANY_BOTTOM:
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
+ break;
+
+ default:
+ if( pSet )
+ {
+ const SfxPoolItem* pItem = NULL;
+ if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_ALIGN_HOR_JUSTIFY:
+ case SID_ATTR_ALIGN_VER_JUSTIFY:
+ case SID_ATTR_ALIGN_INDENT:
+ case SID_ATTR_ALIGN_HYPHENATION:
+ case SID_ATTR_ALIGN_DEGREES:
+ case SID_ATTR_ALIGN_LOCKPOS:
+ case SID_ATTR_ALIGN_MARGIN:
+ case SID_ATTR_ALIGN_STACKED:
+ pTabViewShell->ApplyAttr( *pItem );
+ break;
+
+ case SID_H_ALIGNCELL:
+ {
+ SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
+ // #i78476# update alignment of text in cell edit mode
+ pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
+ }
+ break;
+ case SID_V_ALIGNCELL:
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
+ break;
+ default:
+ OSL_FAIL( "ExecuteAlignment: invalid slot" );
+ return;
+ }
+ }
+ }
+ }
+
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ALIGNTOP );
+ rBindings.Invalidate( SID_ALIGNBOTTOM );
+ rBindings.Invalidate( SID_ALIGNCENTERVER );
+ rBindings.Invalidate( SID_V_ALIGNCELL );
+ rBindings.Invalidate( SID_H_ALIGNCELL );
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+ rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_TOP );
+ rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
+ rBindings.Update();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+}
+
+void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
+ const SfxItemSet* pSet = rReq.GetArgs();
+ sal_uInt16 nSlot = rReq.GetSlot();
+ SfxAllItemSet* pNewSet = 0;
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( (nSlot == SID_ATTR_CHAR_WEIGHT)
+ ||(nSlot == SID_ATTR_CHAR_POSTURE)
+ ||(nSlot == SID_ATTR_CHAR_UNDERLINE)
+ ||(nSlot == SID_ULINE_VAL_NONE)
+ ||(nSlot == SID_ULINE_VAL_SINGLE)
+ ||(nSlot == SID_ULINE_VAL_DOUBLE)
+ ||(nSlot == SID_ULINE_VAL_DOTTED) )
+ {
+ pNewSet = new SfxAllItemSet( GetPool() );
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ if ( pSet )
+ aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
+ else
+ {
+ // toggle manually
+
+ FontWeight eWeight = WEIGHT_BOLD;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), false );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
+ eWeight = WEIGHT_NORMAL;
+
+ aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
+ }
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+ pNewSet->Put( aSetItem.GetItemSet(), false );
+ }
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ if ( pSet )
+ aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
+ else
+ {
+ // toggle manually
+
+ FontItalic eItalic = ITALIC_NORMAL;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), false );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
+ eItalic = ITALIC_NONE;
+
+ aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
+ }
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+ pNewSet->Put( aSetItem.GetItemSet(), false );
+ }
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE:
+ {
+ FontUnderline eUnderline;
+
+ if( pSet )
+ {
+ const SvxUnderlineItem& rUnderline = (const SvxUnderlineItem&)pSet->Get( ATTR_FONT_UNDERLINE );
+
+ if( rUnderline.ISA(SvxUnderlineItem) )
+ {
+ pTabViewShell->ApplyAttr( rUnderline );
+ pNewSet->Put( rUnderline,rUnderline.Which() );
+ }
+ }
+ else
+ {
+ SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
+ pAttrs->GetItem(
+ ATTR_FONT_UNDERLINE ) );
+ eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
+ ? UNDERLINE_NONE
+ : UNDERLINE_SINGLE;
+ aUnderline.SetLineStyle( eUnderline );
+ pTabViewShell->ApplyAttr( aUnderline );
+ pNewSet->Put( aUnderline,aUnderline.Which() );
+ }
+ }
+ break;
+
+ case SID_ULINE_VAL_NONE:
+ pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
+ break;
+ case SID_ULINE_VAL_SINGLE: // Toggles
+ case SID_ULINE_VAL_DOUBLE:
+ case SID_ULINE_VAL_DOTTED:
+ {
+ FontUnderline eOld = ((const SvxUnderlineItem&)
+ pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
+ FontUnderline eNew = eOld;
+ switch (nSlot)
+ {
+ case SID_ULINE_VAL_SINGLE:
+ eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_DOUBLE:
+ eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
+ break;
+ case SID_ULINE_VAL_DOTTED:
+ eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
+ break;
+ }
+ pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
+ }
+ break;
+
+ default:
+ break;
+ }
+ rBindings.Invalidate( nSlot );
+ }
+ else
+ {
+ /*
+ * "Selbstgemachte" RadioButton-Funktionalitaet
+ * Beim Toggle gibt es den Standard-State, d.h. kein
+ * Button ist gedrueckt
+ */
+
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ const SfxPoolItem* pItem = NULL;
+ const SvxHorJustifyItem* pHorJustify = NULL;
+ const SvxVerJustifyItem* pVerJustify = NULL;
+ SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
+ SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
+
+ if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
+ {
+ pHorJustify = (const SvxHorJustifyItem*)pItem;
+ eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
+ }
+ if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
+ {
+ pVerJustify = (const SvxVerJustifyItem*)pItem;
+ eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
+ }
+
+ switch ( nSlot )
+ {
+ case SID_ALIGNLEFT:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
+ SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNRIGHT:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
+ SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNCENTERHOR:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
+ SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNBLOCK:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
+ SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNTOP:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
+ SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNBOTTOM:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
+ SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ case SID_ALIGNCENTERVER:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
+ SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+ //break;
+
+ default:
+ break;
+ }
+
+ }
+
+ rBindings.Update();
+
+ if( pNewSet )
+ {
+ rReq.Done( *pNewSet );
+ delete pNewSet;
+ }
+ else
+ {
+ rReq.Done();
+ }
+
+}
+
+#undef APPLY_HOR_JUSTIFY
+#undef APPLY_VER_JUSTIFY
+
+//------------------------------------------------------------------
+
+void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pNewAttrs = rReq.GetArgs();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( !pNewAttrs )
+ {
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal
+ break;
+
+ case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle
+ {
+ const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
+ sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
+ SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
+ pTabViewShell->ApplyAttr( aBreakItem );
+
+ SfxAllItemSet aNewSet( GetPool() );
+ aNewSet.Put( aBreakItem,aBreakItem.Which() );
+ rReq.Done( aNewSet );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_BACKGROUND_COLOR:
+ {
+ // SID_BACKGROUND_COLOR without arguments -> set transparent background
+
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+
+ aBrushItem.SetColor( COL_TRANSPARENT );
+
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+ }
+ }
+ else
+ {
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_OVERLINE:
+ case SID_ATTR_CHAR_STRIKEOUT:
+ case SID_ATTR_ALIGN_LINEBREAK:
+ case SID_ATTR_CHAR_COLOR:
+ case SID_ATTR_CHAR_CONTOUR:
+ case SID_ATTR_CHAR_SHADOWED:
+ case SID_ATTR_CHAR_RELIEF:
+ case SID_SCATTR_PROTECTION :
+ pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
+ rBindings.Invalidate( nSlot );
+ rBindings.Update( nSlot );
+ break;
+
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ nScript = pTabViewShell->GetSelectionScriptType();
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+ aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
+
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+
+ rBindings.Invalidate( nSlot );
+ rBindings.Update( nSlot );
+ }
+ break;
+
+ case SID_FRAME_LINESTYLE:
+ {
+ // Default-Linie aktualisieren
+ const ::editeng::SvxBorderLine* pLine =
+ ((const SvxLineItem&)
+ pNewAttrs->Get( SID_FRAME_LINESTYLE )).
+ GetLine();
+
+ if ( pLine )
+ {
+ ::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+
+ if ( pDefLine )
+ {
+ pDefLine->SetStyle( pLine->GetStyle( ) );
+ pDefLine->SetWidth( pLine->GetWidth( ) );
+ pTabViewShell->SetSelectionFrameLines( pDefLine, false );
+ }
+ else
+ {
+ pTabViewShell->SetDefaultFrameLine( pLine );
+ pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
+ pTabViewShell->SetSelectionFrameLines( pLine, false );
+ }
+ }
+ else
+ {
+ Color aColorBlack( COL_BLACK );
+ ::editeng::SvxBorderLine aDefLine( &aColorBlack, 20, ::editeng::SOLID );
+ pTabViewShell->SetDefaultFrameLine( &aDefLine );
+ pTabViewShell->SetSelectionFrameLines( NULL, false );
+ }
+ }
+ break;
+
+ case SID_FRAME_LINECOLOR:
+ {
+ ::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+ const Color& rColor = ((const SvxColorItem&)
+ pNewAttrs->Get( SID_FRAME_LINECOLOR )).
+ GetValue();
+
+ // Default-Linie aktualisieren
+ if ( pDefLine )
+ {
+ pDefLine->SetColor( rColor );
+ pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
+ }
+ else
+ {
+ ::editeng::SvxBorderLine aDefLine( &rColor, 20, ::editeng::SOLID );
+ pTabViewShell->SetDefaultFrameLine( &aDefLine );
+ pTabViewShell->SetSelectionFrameLines( &aDefLine, false );
+ }
+ }
+ break;
+
+ case SID_ATTR_BORDER_OUTER:
+ case SID_ATTR_BORDER:
+ {
+ ::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+ const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SfxItemSet* pOldSet =
+ new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+ SfxItemSet* pNewSet =
+ new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+ const SfxPoolItem& rBorderAttr =
+ pOldAttrs->GetItemSet().
+ Get( ATTR_BORDER );
+
+ // Border-Items vom Controller auswerten:
+ const SfxPoolItem* pItem = 0;
+
+ if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
+ == SFX_ITEM_SET )
+ {
+ // The SvxFrameToolBoxControl toolbox controller uses a default
+ // SvxBorderLine (all widths 0) to mark the lines that should be set.
+ // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
+ // or NULL pointers for no lines.
+ // -> Substitute existing lines with pDefLine only if widths are 0.
+ SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
+ if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
+ if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
+ if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
+ if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
+ pNewSet->Put( aBoxItem );
+ rReq.AppendItem( aBoxItem );
+ }
+
+ if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
+ == SFX_ITEM_SET )
+ {
+ SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
+ if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
+ aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
+ if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
+ aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
+ pNewSet->Put( aBoxInfoItem );
+ rReq.AppendItem( aBoxInfoItem );
+ }
+ else
+ {
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+ aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
+ aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
+ pNewSet->Put( aBoxInfoItem );
+ }
+
+ pOldSet->Put( rBorderAttr );
+ pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
+
+ delete pOldSet;
+ delete pNewSet;
+ }
+ break;
+
+ // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
+ // gesetzt werden:
+ case SID_BACKGROUND_COLOR:
+ {
+ const SvxColorItem rNewColorItem = (const SvxColorItem&)
+ pNewAttrs->Get( SID_BACKGROUND_COLOR );
+
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+
+ aBrushItem.SetColor( rNewColorItem.GetValue() );
+
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+
+ case SID_ATTR_BRUSH:
+ {
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+ const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
+ pNewAttrs->Get( GetPool().GetWhich(nSlot) );
+ aBrushItem.SetColor(rNewBrushItem.GetColor());
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+
+ case SID_ATTR_BORDER_SHADOW:
+ {
+ const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
+ pNewAttrs->Get( ATTR_SHADOW );
+ pTabViewShell->ApplyAttr( rNewShadowItem );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( ! rReq.IsAPI() )
+ if( ! rReq.IsDone() )
+ rReq.Done();
+ }
+}
+
+void ScFormatShell::GetAttrState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ const ::editeng::SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine();
+ const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ rSet.Put( rAttrSet, false );
+
+ // choose font info according to selection script type
+ sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0
+ if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
+ }
+ if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
+ }
+
+ while ( nWhich )
+ {
+ switch(nWhich)
+ {
+ case SID_BACKGROUND_COLOR:
+ {
+ rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
+ }
+ break;
+ case SID_FRAME_LINECOLOR:
+ {
+ rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ {
+ rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ rSet.Put( rAttrSet, false ); // ItemStates mitkopieren
+
+ // choose font info according to selection script type
+ sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0
+ if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
+ }
+ if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
+ }
+
+ SfxItemState eState;
+// const SfxPoolItem* pItem;
+
+ //--------------------------------------------------------------------
+ // eigene Kontrolle ueber RadioButton-Funktionalitaet:
+ //--------------------------------------------------------------------
+ // Unterstreichung
+ //------------------------
+
+ eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rSet.InvalidateItem( SID_ULINE_VAL_NONE );
+ rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
+ }
+ else
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
+ sal_uInt16 nId = SID_ULINE_VAL_NONE;
+ switch (eUnderline)
+ {
+ case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
+ case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
+ case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
+ default:
+ break;
+ }
+ rSet.Put( SfxBoolItem( nId, sal_True ) );
+ }
+
+ //------------------------
+ // horizontale Ausrichtung
+ //------------------------
+
+ const SvxHorJustifyItem* pHorJustify = NULL;
+ const SvxVerJustifyItem* pVerJustify = NULL;
+ SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
+ sal_uInt16 nWhich = 0;
+ sal_Bool bJustifyStd = false;
+ SfxBoolItem aBoolItem ( 0, sal_True );
+
+ eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
+ (const SfxPoolItem**)&pHorJustify );
+ switch ( eState )
+ {
+ case SFX_ITEM_SET:
+ {
+ switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ break;
+
+ case SVX_HOR_JUSTIFY_LEFT:
+ nWhich = SID_ALIGNLEFT;
+ break;
+
+ case SVX_HOR_JUSTIFY_RIGHT:
+ nWhich = SID_ALIGNRIGHT;
+ break;
+
+ case SVX_HOR_JUSTIFY_CENTER:
+ nWhich = SID_ALIGNCENTERHOR;
+ break;
+
+ case SVX_HOR_JUSTIFY_BLOCK:
+ nWhich = SID_ALIGNBLOCK;
+ break;
+
+ case SVX_HOR_JUSTIFY_REPEAT:
+ default:
+ bJustifyStd = sal_True;
+ break;
+ }
+ }
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ rSet.InvalidateItem( SID_ALIGNLEFT );
+ rSet.InvalidateItem( SID_ALIGNRIGHT );
+ rSet.InvalidateItem( SID_ALIGNCENTERHOR );
+ rSet.InvalidateItem( SID_ALIGNBLOCK );
+ break;
+
+ default:
+ bJustifyStd = sal_True;
+ break;
+ }
+
+ if ( nWhich )
+ {
+ aBoolItem.SetWhich( nWhich );
+ rSet.Put( aBoolItem );
+ }
+ else if ( bJustifyStd )
+ {
+ aBoolItem.SetValue( false );
+ aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem );
+ bJustifyStd = false;
+ }
+
+ //------------------------
+ // vertikale Ausrichtung
+ //------------------------
+
+ nWhich = 0;
+ aBoolItem.SetValue( sal_True );
+
+ eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
+ (const SfxPoolItem**)&pVerJustify );
+
+ switch ( eState )
+ {
+ case SFX_ITEM_SET:
+ {
+ eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
+
+ switch ( eVerJustify )
+ {
+ case SVX_VER_JUSTIFY_TOP:
+ nWhich = SID_ALIGNTOP;
+ break;
+
+ case SVX_VER_JUSTIFY_BOTTOM:
+ nWhich = SID_ALIGNBOTTOM;
+ break;
+
+ case SVX_VER_JUSTIFY_CENTER:
+ nWhich = SID_ALIGNCENTERVER;
+ break;
+
+ case SVX_VER_JUSTIFY_STANDARD:
+ default:
+ bJustifyStd = sal_True;
+ break;
+ }
+ }
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ rSet.InvalidateItem( SID_ALIGNTOP );
+ rSet.InvalidateItem( SID_ALIGNBOTTOM );
+ rSet.InvalidateItem( SID_ALIGNCENTERVER );
+ break;
+
+ default:
+ bJustifyStd = sal_True;
+ break;
+ }
+
+ if ( nWhich )
+ {
+ aBoolItem.SetWhich( nWhich );
+ rSet.Put( aBoolItem );
+ }
+ else if ( bJustifyStd )
+ {
+ aBoolItem.SetValue( false );
+ aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
+ }
+}
+
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetBorderState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SvxBoxItem aBoxItem( ATTR_BORDER );
+ SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER );
+
+ pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
+
+ if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
+ rSet.Put( aBoxItem );
+ if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
+ rSet.Put( aInfoItem );
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetAlignState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
+ bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
+ if( bHasHAlign )
+ eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
+
+ SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
+ bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
+ if( bHasVAlign )
+ eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_H_ALIGNCELL:
+ if ( bHasHAlign )
+ rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
+ break;
+ case SID_V_ALIGNCELL:
+ if ( bHasVAlign )
+ rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
+ break;
+
+ // pseudo slots for Format menu
+ case SID_ALIGN_ANY_HDEFAULT:
+ case SID_ALIGN_ANY_LEFT:
+ case SID_ALIGN_ANY_HCENTER:
+ case SID_ALIGN_ANY_RIGHT:
+ case SID_ALIGN_ANY_JUSTIFIED:
+ rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
+ break;
+ case SID_ALIGN_ANY_VDEFAULT:
+ case SID_ALIGN_ANY_TOP:
+ case SID_ALIGN_ANY_VCENTER:
+ case SID_ALIGN_ANY_BOTTOM:
+ rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScDocument* pDoc = pViewData->GetDocument();
+ short nType = GetCurrentNumberFormatType();
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_NUMBER_FORMAT:
+ {
+ String aFormatCode; // bleibt leer, wenn dont-care
+
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
+ {
+ sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
+ ATTR_VALUE_FORMAT )).GetValue();
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
+ if ( pFormatEntry )
+ aFormatCode = pFormatEntry->GetFormatstring();
+ }
+
+ rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
+ }
+ break;
+ case SID_NUMBER_SCIENTIFIC:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_SCIENTIFIC)) );
+ break;
+ case SID_NUMBER_DATE:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_DATE)) );
+ break;
+ case SID_NUMBER_CURRENCY:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_CURRENCY)) );
+ break;
+ case SID_NUMBER_PERCENT:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_PERCENT)) );
+ break;
+ case SID_NUMBER_TIME:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_TIME)) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ SC_MOD()->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch( nSlot )
+ {
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ {
+ sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
+ ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
+ SfxItemSet& rItemSet = aAttr.GetItemSet();
+ rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
+ rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
+ pTabViewShell->ApplySelectionPattern( aAttr );
+ pTabViewShell->AdjustBlockHeight();
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
+ FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
+ pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
+ }
+ break;
+ }
+}
+
+void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+
+ sal_Bool bVertDontCare =
+ (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
+ (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
+ sal_Bool bLeftRight = !bVertDontCare &&
+ !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
+ sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
+ ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
+
+ sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
+ EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
+ if ( !bBidiDontCare )
+ {
+ SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
+ rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
+ if ( eCellDir == FRMDIR_ENVIRONMENT )
+ eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
+ GetEditTextDirection( GetViewData()->GetTabNo() );
+ else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
+ eBidiDir = EE_HTEXTDIR_R2L;
+ else
+ eBidiDir = EE_HTEXTDIR_L2R;
+ }
+
+ SvtLanguageOptions aLangOpt;
+ sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
+ sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
+
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ if ( bDisableVerticalText )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if( bVertDontCare )
+ rSet.InvalidateItem( nWhich );
+ else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
+ rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ if ( bDisableCTLFont )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if ( bTopBottom )
+ rSet.DisableItem( nWhich );
+ else if ( bBidiDontCare )
+ rSet.InvalidateItem( nWhich );
+ else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
+ rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
+{
+ ScViewFunc* pView = pViewData->GetView();
+ if ( pView->HasPaintBrush() )
+ {
+ // cancel paintbrush mode
+ pView->ResetBrushDocument();
+ }
+ else
+ {
+ sal_Bool bLock = false;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
+
+ // in case of multi selection, deselect all and use the cursor position
+ ScRange aDummy;
+ if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
+ pView->Unmark();
+
+ ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
+ pView->CopyToClip( pBrushDoc, false, sal_True );
+ pView->SetBrushDocument( pBrushDoc, bLock );
+ }
+}
+
+void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
+{
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+ else
+ rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
+}
+
+short ScFormatShell::GetCurrentNumberFormatType()
+{
+ short nType = NUMBERFORMAT_ALL;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData aMark(GetViewData()->GetMarkData());
+ const SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ if (!pFormatter)
+ return nType;
+
+ // TODO: Find out how to get a selected table range in case multiple tables
+ // are selected. Currently we only check for the current active table.
+
+ if ( aMark.IsMarked() || aMark.IsMultiMarked() )
+ {
+ aMark.MarkToMulti();
+ ScRange aRange;
+ aMark.GetMultiMarkArea(aRange);
+
+ const ScMarkArray* pArray = aMark.GetArray();
+ if (!pArray)
+ return nType;
+
+ short nComboType = NUMBERFORMAT_ALL;
+ bool bFirstItem = true;
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ {
+ const ScMarkArray& rColArray = pArray[nCol];
+ if (!rColArray.HasMarks())
+ continue;
+
+ SCROW nRow1, nRow2;
+ ScMarkArrayIter aMarkIter(&rColArray);
+ while (aMarkIter.Next(nRow1, nRow2))
+ {
+ ScRange aColRange(nCol, nRow1, aRange.aStart.Tab());
+ aColRange.aEnd.SetRow(nRow2);
+ sal_uInt32 nNumFmt = pDoc->GetNumberFormat(aColRange);
+ const SvNumberformat* pEntry = pFormatter->GetEntry(nNumFmt);
+ if (!pEntry)
+ return 0;
+
+ short nThisType = pEntry->GetType();
+ if (bFirstItem)
+ {
+ bFirstItem = false;
+ nComboType = nThisType;
+ }
+ else if (nComboType != nThisType)
+ // mixed number format type.
+ return NUMBERFORMAT_ALL;
+ }
+ }
+ nType = nComboType;
+ }
+ else
+ {
+ sal_uInt32 nNumFmt;
+ pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(),
+ pViewData->GetTabNo(), nNumFmt );
+ const SvNumberformat* pEntry = pFormatter->GetEntry( nNumFmt );
+ nType = pEntry ? pEntry->GetType() : 0;
+ }
+ return nType;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/galwrap.cxx b/sc/source/ui/view/galwrap.cxx
new file mode 100644
index 000000000000..c781841b52dd
--- /dev/null
+++ b/sc/source/ui/view/galwrap.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/graph.hxx>
+#include <svx/gallery.hxx>
+#include <sfx2/app.hxx>
+
+// -----------------------------------------------------------------------
+
+Graphic GalleryGetGraphic()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->GetGraphic();
+}
+
+sal_uInt16 GallerySGA_FORMAT_GRAPHIC()
+{
+ return SGA_FORMAT_GRAPHIC;
+}
+
+sal_Bool GalleryIsLinkage()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->IsLinkage();
+}
+
+String GalleryGetFullPath()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+
+ return pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE);
+ // URL as stored in GraphicLink must be encoded
+}
+
+String GalleryGetFilterName()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->GetFilterName();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridmerg.cxx b/sc/source/ui/view/gridmerg.cxx
new file mode 100644
index 000000000000..97821e406c96
--- /dev/null
+++ b/sc/source/ui/view/gridmerg.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <vcl/outdev.hxx>
+
+#include "gridmerg.hxx"
+
+//------------------------------------------------------------------
+
+ScGridMerger::ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY ) :
+ pDev( pOutDev ),
+ nOneX( nOnePixelX ),
+ nOneY( nOnePixelY ),
+ nCount( 0 ),
+ bVertical( false )
+{
+ // optimize (DrawGrid) only for pixel MapMode,
+ // to avoid rounding errors
+
+ bOptimize = ( pDev->GetMapMode().GetMapUnit() == MAP_PIXEL );
+}
+
+ScGridMerger::~ScGridMerger()
+{
+ Flush();
+}
+
+void ScGridMerger::AddLine( long nStart, long nEnd, long nPos )
+{
+ if ( nCount )
+ {
+ // not first line - test fix position
+ // more than one previous line - test distance
+
+ if ( nStart != nFixStart || nEnd != nFixEnd )
+ {
+ if ( nCount == 1 && nPos == nVarStart &&
+ ( nStart == nFixEnd ||
+ nStart == nFixEnd + ( bVertical ? nOneY : nOneX ) ) )
+ {
+ // additional optimization: extend connected lines
+ // keep nCount at 1
+ nFixEnd = nEnd;
+ }
+ else
+ Flush();
+ }
+ else if ( nCount == 1 )
+ {
+ nVarDiff = nPos - nVarStart;
+ ++nCount;
+ }
+ else if ( nPos != nVarStart + nCount * nVarDiff ) //! keep VarEnd?
+ Flush();
+ else
+ ++nCount;
+ }
+
+ if ( !nCount )
+ {
+ // first line (or flushed above) - just store
+
+ nFixStart = nStart;
+ nFixEnd = nEnd;
+ nVarStart = nPos;
+ nVarDiff = 0;
+ nCount = 1;
+ }
+}
+
+void ScGridMerger::AddHorLine( long nX1, long nX2, long nY )
+{
+ if ( bOptimize )
+ {
+ if ( bVertical )
+ {
+ Flush();
+ bVertical = false;
+ }
+ AddLine( nX1, nX2, nY );
+ }
+ else
+ pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+}
+
+void ScGridMerger::AddVerLine( long nX, long nY1, long nY2 )
+{
+ if ( bOptimize )
+ {
+ if ( !bVertical )
+ {
+ Flush();
+ bVertical = sal_True;
+ }
+ AddLine( nY1, nY2, nX );
+ }
+ else
+ pDev->DrawLine( Point( nX, nY1 ), Point( nX, nY2 ) );
+}
+
+void ScGridMerger::Flush()
+{
+ if (nCount)
+ {
+ if (bVertical)
+ {
+ if ( nCount == 1 )
+ pDev->DrawLine( Point( nVarStart, nFixStart ), Point( nVarStart, nFixEnd ) );
+ else
+ {
+ long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff;
+ if ( nVarDiff < 0 )
+ {
+ // nVarDiff is negative in RTL layout mode
+ // Change the positions so DrawGrid is called with a positive distance
+ // (nVarStart / nVarDiff can be modified, aren't used after Flush)
+
+ nVarDiff = -nVarDiff;
+ long nTemp = nVarStart;
+ nVarStart = nVarEnd;
+ nVarEnd = nTemp;
+ }
+ pDev->DrawGrid( Rectangle( nVarStart, nFixStart, nVarEnd, nFixEnd ),
+ Size( nVarDiff, nFixEnd - nFixStart ),
+ GRID_VERTLINES );
+ }
+ }
+ else
+ {
+ if ( nCount == 1 )
+ pDev->DrawLine( Point( nFixStart, nVarStart ), Point( nFixEnd, nVarStart ) );
+ else
+ {
+ long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff;
+ pDev->DrawGrid( Rectangle( nFixStart, nVarStart, nFixEnd, nVarEnd ),
+ Size( nFixEnd - nFixStart, nVarDiff ),
+ GRID_HORZLINES );
+ }
+ }
+ nCount = 0;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
new file mode 100644
index 000000000000..985240bd248d
--- /dev/null
+++ b/sc/source/ui/view/gridwin.cxx
@@ -0,0 +1,5742 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+
+#include <memory> //auto_ptr
+#include <editeng/adjitem.hxx>
+#include <svx/algitem.hxx>
+#include <svx/dbexch.hrc>
+#include <editeng/editview.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editobj.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/svlbox.hxx>
+#include <svtools/svtabbx.hxx>
+#include <svl/urlbmk.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/cursor.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/hatch.hxx>
+#include <sot/formats.hxx>
+#include <sot/clsids.hxx>
+#include <sal/macros.h>
+
+#include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
+#include <editeng/outliner.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
+#include <svx/svditer.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpagv.hxx>
+
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
+#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
+#include <com/sun/star/sheet/MemberResultFlags.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/awt/MouseButton.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+
+#include "gridwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "tabview.hxx"
+#include "select.hxx"
+#include "scmod.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "dbcolect.hxx"
+#include "stlpool.hxx"
+#include "printfun.hxx"
+#include "cbutton.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "editutil.hxx"
+#include "scresid.hxx"
+#include "inputhdl.hxx"
+#include "uiitems.hxx" // Filter-Dialog - auslagern !!!
+#include "filtdlg.hxx"
+#include "impex.hxx" // Sylk-ID fuer CB
+#include "cell.hxx" // fuer Edit-Felder
+#include "patattr.hxx"
+#include "notemark.hxx"
+#include "rfindlst.hxx"
+#include "docpool.hxx"
+#include "output.hxx"
+#include "docfunc.hxx"
+#include "dbdocfun.hxx"
+#include "dpobject.hxx"
+#include "dpoutput.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "seltrans.hxx"
+#include "sizedev.hxx"
+#include "AccessibilityHints.hxx"
+#include "dpsave.hxx"
+#include "viewuno.hxx"
+#include "compiler.hxx"
+#include "editable.hxx"
+#include "fillinfo.hxx"
+#include "scitems.hxx"
+#include "userdat.hxx"
+#include "drwlayer.hxx"
+#include "attrib.hxx"
+#include "validat.hxx"
+#include "tabprotection.hxx"
+#include "postit.hxx"
+#include "dpcontrol.hxx"
+#include "clipparam.hxx"
+#include "cellsh.hxx"
+#include "overlayobject.hxx"
+#include "cellsuno.hxx"
+
+#include "drawview.hxx"
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/overlay/overlayselection.hxx>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+const sal_uInt8 SC_NESTEDBUTTON_NONE = 0;
+const sal_uInt8 SC_NESTEDBUTTON_DOWN = 1;
+const sal_uInt8 SC_NESTEDBUTTON_UP = 2;
+
+#define SC_AUTOFILTER_ALL 0
+#define SC_AUTOFILTER_TOP10 1
+#define SC_AUTOFILTER_CUSTOM 2
+#define SC_AUTOFILTER_EMPTY 3
+#define SC_AUTOFILTER_NOTEMPTY 4
+
+// Modi fuer die FilterListBox
+enum ScFilterBoxMode
+{
+ SC_FILTERBOX_FILTER,
+ SC_FILTERBOX_DATASELECT,
+ SC_FILTERBOX_SCENARIO,
+ SC_FILTERBOX_PAGEFIELD
+};
+
+extern SfxViewShell* pScActiveViewShell; // global.cxx
+extern sal_uInt16 nScClickMouseModifier; // global.cxx
+extern sal_uInt16 nScFillModeMouseModifier; // global.cxx
+
+#define SC_FILTERLISTBOX_LINES 12
+
+// ============================================================================
+
+ScGridWindow::VisibleRange::VisibleRange() :
+ mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW)
+{
+}
+
+bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const
+{
+ return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
+}
+
+// ============================================================================
+
+class ScFilterListBox : public ListBox
+{
+private:
+ ScGridWindow* pGridWin;
+ SCCOL nCol;
+ SCROW nRow;
+ sal_Bool bButtonDown;
+ sal_Bool bInit;
+ sal_Bool bCancelled;
+ sal_Bool bInSelect;
+ bool mbListHasDates;
+ sal_uLong nSel;
+ ScFilterBoxMode eMode;
+
+protected:
+ virtual void LoseFocus();
+ void SelectHdl();
+
+public:
+ ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
+ SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode );
+ ~ScFilterListBox();
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Select();
+
+ SCCOL GetCol() const { return nCol; }
+ SCROW GetRow() const { return nRow; }
+ ScFilterBoxMode GetMode() const { return eMode; }
+ sal_Bool IsDataSelect() const { return (eMode == SC_FILTERBOX_DATASELECT); }
+ void EndInit();
+ sal_Bool IsInInit() const { return bInit; }
+ void SetCancelled() { bCancelled = sal_True; }
+ sal_Bool IsInSelect() const { return bInSelect; }
+ void SetListHasDates(bool b) { mbListHasDates = b; }
+ bool HasDates() const { return mbListHasDates; }
+};
+
+//-------------------------------------------------------------------
+
+// ListBox in einem FloatingWindow (pParent)
+ScFilterListBox::ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
+ SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ) :
+ ListBox( pParent, WB_AUTOHSCROLL ),
+ pGridWin( pGrid ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ bButtonDown( false ),
+ bInit( sal_True ),
+ bCancelled( false ),
+ bInSelect( false ),
+ mbListHasDates(false),
+ nSel( 0 ),
+ eMode( eNewMode )
+{
+}
+
+ScFilterListBox::~ScFilterListBox()
+{
+ if (IsMouseCaptured())
+ ReleaseMouse();
+}
+
+void ScFilterListBox::EndInit()
+{
+ sal_uInt16 nPos = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nSel = 0;
+ else
+ nSel = nPos;
+
+ bInit = false;
+}
+
+void ScFilterListBox::LoseFocus()
+{
+#ifndef UNX
+ Hide();
+#endif
+}
+
+// -----------------------------------------------------------------------
+
+long ScFilterListBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
+ KeyCode aCode = aKeyEvt.GetKeyCode();
+ if ( !aCode.GetModifier() ) // ohne alle Modifiers
+ {
+ sal_uInt16 nKey = aCode.GetCode();
+ if ( nKey == KEY_RETURN )
+ {
+ SelectHdl(); // auswaehlen
+ nDone = 1;
+ }
+ else if ( nKey == KEY_ESCAPE )
+ {
+ pGridWin->ClickExtern(); // loescht die List-Box !!!
+ nDone = 1;
+ }
+ }
+ }
+
<