1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //------------------------------------------------------------------ 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "scitems.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <svl/slstitm.hxx> 36*cdf0e10cSrcweir #include <svl/stritem.hxx> 37*cdf0e10cSrcweir #include <svl/whiter.hxx> 38*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx> 39*cdf0e10cSrcweir #include <svtools/cliplistener.hxx> 40*cdf0e10cSrcweir #include <svtools/insdlg.hxx> 41*cdf0e10cSrcweir #include <sot/formats.hxx> 42*cdf0e10cSrcweir #include <svx/hlnkitem.hxx> 43*cdf0e10cSrcweir #include <sfx2/app.hxx> 44*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 45*cdf0e10cSrcweir #include <sfx2/childwin.hxx> 46*cdf0e10cSrcweir #include <sfx2/objface.hxx> 47*cdf0e10cSrcweir #include <sfx2/request.hxx> 48*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 49*cdf0e10cSrcweir #include <svx/clipfmtitem.hxx> 50*cdf0e10cSrcweir #include <editeng/langitem.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include "cellsh.hxx" 53*cdf0e10cSrcweir #include "sc.hrc" 54*cdf0e10cSrcweir #include "docsh.hxx" 55*cdf0e10cSrcweir #include "attrib.hxx" 56*cdf0e10cSrcweir #include "scresid.hxx" 57*cdf0e10cSrcweir #include "tabvwsh.hxx" 58*cdf0e10cSrcweir #include "impex.hxx" 59*cdf0e10cSrcweir #include "cell.hxx" 60*cdf0e10cSrcweir #include "scmod.hxx" 61*cdf0e10cSrcweir #include "globstr.hrc" 62*cdf0e10cSrcweir #include "transobj.hxx" 63*cdf0e10cSrcweir #include "drwtrans.hxx" 64*cdf0e10cSrcweir #include "scabstdlg.hxx" 65*cdf0e10cSrcweir #include "dociter.hxx" 66*cdf0e10cSrcweir #include "postit.hxx" 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //------------------------------------------------------------------ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #define ScCellShell 71*cdf0e10cSrcweir #define CellMovement 72*cdf0e10cSrcweir #include "scslots.hxx" 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir TYPEINIT1( ScCellShell, ScFormatShell ); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SFX_IMPL_INTERFACE(ScCellShell, ScFormatShell , ScResId(SCSTR_CELLSHELL) ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | 79*cdf0e10cSrcweir SFX_VISIBILITY_SERVER, 80*cdf0e10cSrcweir ScResId(RID_OBJECTBAR_FORMAT)); 81*cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_CELLS)); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir ScCellShell::ScCellShell(ScViewData* pData) : 86*cdf0e10cSrcweir ScFormatShell(pData), 87*cdf0e10cSrcweir pImpl( new CellShell_Impl() ), 88*cdf0e10cSrcweir bPastePossible(sal_False) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SetHelpId(HID_SCSHELL_CELLSH); 91*cdf0e10cSrcweir SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Cell"))); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir ScCellShell::~ScCellShell() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir if ( pImpl->m_pClipEvtLstnr ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr->AddRemoveListener( GetViewData()->GetActiveWin(), sal_False ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir // #103849# The listener may just now be waiting for the SolarMutex and call the link 101*cdf0e10cSrcweir // afterwards, in spite of RemoveListener. So the link has to be reset, too. 102*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr->ClearCallbackLink(); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr->release(); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir delete pImpl->m_pLinkedDlg; 108*cdf0e10cSrcweir delete pImpl->m_pRequest; 109*cdf0e10cSrcweir delete pImpl; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir //------------------------------------------------------------------ 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir void ScCellShell::GetBlockState( SfxItemSet& rSet ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 117*cdf0e10cSrcweir ScRange aMarkRange; 118*cdf0e10cSrcweir ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange ); 119*cdf0e10cSrcweir sal_Bool bSimpleArea = (eMarkType == SC_MARK_SIMPLE); 120*cdf0e10cSrcweir sal_Bool bOnlyNotBecauseOfMatrix; 121*cdf0e10cSrcweir sal_Bool bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix ); 122*cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument(); 123*cdf0e10cSrcweir ScDocShell* pDocShell = GetViewData()->GetDocShell(); 124*cdf0e10cSrcweir ScMarkData& rMark = GetViewData()->GetMarkData(); 125*cdf0e10cSrcweir SCCOL nCol1, nCol2; 126*cdf0e10cSrcweir SCROW nRow1, nRow2; 127*cdf0e10cSrcweir nCol1 = aMarkRange.aStart.Col(); 128*cdf0e10cSrcweir nRow1 = aMarkRange.aStart.Row(); 129*cdf0e10cSrcweir nCol2 = aMarkRange.aEnd.Col(); 130*cdf0e10cSrcweir nRow2 = aMarkRange.aEnd.Row(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir SfxWhichIter aIter(rSet); 133*cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 134*cdf0e10cSrcweir while ( nWhich ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir sal_Bool bDisable = sal_False; 137*cdf0e10cSrcweir sal_Bool bNeedEdit = sal_True; // muss Selektion editierbar sein? 138*cdf0e10cSrcweir switch ( nWhich ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir case FID_FILL_TO_BOTTOM: // Fuellen oben/unten 141*cdf0e10cSrcweir case FID_FILL_TO_TOP: // mind. 2 Zeilen markiert? 142*cdf0e10cSrcweir bDisable = (!bSimpleArea) || (nRow1 == nRow2); 143*cdf0e10cSrcweir if ( !bDisable && bEditable ) 144*cdf0e10cSrcweir { // Matrix nicht zerreissen 145*cdf0e10cSrcweir if ( nWhich == FID_FILL_TO_BOTTOM ) 146*cdf0e10cSrcweir bDisable = pDoc->HasSelectedBlockMatrixFragment( 147*cdf0e10cSrcweir nCol1, nRow1, nCol2, nRow1, rMark ); // erste Zeile 148*cdf0e10cSrcweir else 149*cdf0e10cSrcweir bDisable = pDoc->HasSelectedBlockMatrixFragment( 150*cdf0e10cSrcweir nCol1, nRow2, nCol2, nRow2, rMark ); // letzte Zeile 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir break; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir case FID_FILL_TO_RIGHT: // Fuellen links/rechts 155*cdf0e10cSrcweir case FID_FILL_TO_LEFT: // mind. 2 Spalten markiert? 156*cdf0e10cSrcweir bDisable = (!bSimpleArea) || (nCol1 == nCol2); 157*cdf0e10cSrcweir if ( !bDisable && bEditable ) 158*cdf0e10cSrcweir { // Matrix nicht zerreissen 159*cdf0e10cSrcweir if ( nWhich == FID_FILL_TO_RIGHT ) 160*cdf0e10cSrcweir bDisable = pDoc->HasSelectedBlockMatrixFragment( 161*cdf0e10cSrcweir nCol1, nRow1, nCol1, nRow2, rMark ); // erste Spalte 162*cdf0e10cSrcweir else 163*cdf0e10cSrcweir bDisable = pDoc->HasSelectedBlockMatrixFragment( 164*cdf0e10cSrcweir nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir break; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir case FID_FILL_SERIES: // Block fuellen 169*cdf0e10cSrcweir case SID_OPENDLG_TABOP: // Mehrfachoperationen, mind. 2 Zellen markiert? 170*cdf0e10cSrcweir if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP) 171*cdf0e10cSrcweir bDisable = sal_True; 172*cdf0e10cSrcweir else 173*cdf0e10cSrcweir bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES ) 176*cdf0e10cSrcweir { // Matrix nicht zerreissen 177*cdf0e10cSrcweir bDisable = pDoc->HasSelectedBlockMatrixFragment( 178*cdf0e10cSrcweir nCol1, nRow1, nCol2, nRow1, rMark ) // erste Zeile 179*cdf0e10cSrcweir || pDoc->HasSelectedBlockMatrixFragment( 180*cdf0e10cSrcweir nCol1, nRow2, nCol2, nRow2, rMark ) // letzte Zeile 181*cdf0e10cSrcweir || pDoc->HasSelectedBlockMatrixFragment( 182*cdf0e10cSrcweir nCol1, nRow1, nCol1, nRow2, rMark ) // erste Spalte 183*cdf0e10cSrcweir || pDoc->HasSelectedBlockMatrixFragment( 184*cdf0e10cSrcweir nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir break; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir case SID_CUT: // Ausschneiden, 189*cdf0e10cSrcweir case FID_INS_CELL: // Zellen einfuegen, nur einf. Selektion 190*cdf0e10cSrcweir bDisable = (!bSimpleArea); 191*cdf0e10cSrcweir break; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir case FID_INS_ROW: // insert rows 194*cdf0e10cSrcweir case FID_INS_CELLSDOWN: 195*cdf0e10cSrcweir bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked(); 196*cdf0e10cSrcweir break; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir case FID_INS_COLUMN: // insert columns 199*cdf0e10cSrcweir case FID_INS_CELLSRIGHT: 200*cdf0e10cSrcweir bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked(); 201*cdf0e10cSrcweir break; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir case SID_COPY: // Kopieren 204*cdf0e10cSrcweir // nur wegen Matrix nicht editierbar? Matrix nicht zerreissen 205*cdf0e10cSrcweir //! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit 206*cdf0e10cSrcweir //! muss man leben.. wird in Copy-Routine abgefangen, sonst 207*cdf0e10cSrcweir //! muesste hier nochmal Aufwand getrieben werden 208*cdf0e10cSrcweir if ( !(!bEditable && bOnlyNotBecauseOfMatrix) ) 209*cdf0e10cSrcweir bNeedEdit = sal_False; // erlaubt, wenn geschuetzt/ReadOnly 210*cdf0e10cSrcweir break; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir case SID_AUTOFORMAT: // Autoformat, mind. 3x3 selektiert 213*cdf0e10cSrcweir bDisable = (!bSimpleArea) 214*cdf0e10cSrcweir || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2); 215*cdf0e10cSrcweir break; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir case SID_OPENDLG_CONDFRMT : 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir if ( !bEditable && bOnlyNotBecauseOfMatrix ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir bNeedEdit = sal_False; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir if ( pDocShell && pDocShell->IsDocShared() ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir bDisable = sal_True; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir break; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir case FID_CONDITIONAL_FORMAT : 231*cdf0e10cSrcweir case SID_CELL_FORMAT_RESET : 232*cdf0e10cSrcweir case FID_CELL_FORMAT : 233*cdf0e10cSrcweir case SID_ENABLE_HYPHENATION : 234*cdf0e10cSrcweir // nur wegen Matrix nicht editierbar? Attribute trotzdem ok 235*cdf0e10cSrcweir if ( !bEditable && bOnlyNotBecauseOfMatrix ) 236*cdf0e10cSrcweir bNeedEdit = sal_False; 237*cdf0e10cSrcweir break; 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir case FID_VALIDATION: 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir if ( pDocShell && pDocShell->IsDocShared() ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir bDisable = sal_True; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir break; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir case SID_TRANSLITERATE_HALFWIDTH: 249*cdf0e10cSrcweir case SID_TRANSLITERATE_FULLWIDTH: 250*cdf0e10cSrcweir case SID_TRANSLITERATE_HIRAGANA: 251*cdf0e10cSrcweir case SID_TRANSLITERATE_KATAGANA: 252*cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, GetViewData()->GetBindings(), nWhich ); 253*cdf0e10cSrcweir break; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir if (!bDisable && bNeedEdit && !bEditable) 256*cdf0e10cSrcweir bDisable = sal_True; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir if (bDisable) 259*cdf0e10cSrcweir rSet.DisableItem(nWhich); 260*cdf0e10cSrcweir else if (nWhich == SID_ENABLE_HYPHENATION) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir // toggle slots need a bool item 263*cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, sal_False ) ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir nWhich = aIter.NextWhich(); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir // Funktionen, die je nach Cursorposition disabled sind 270*cdf0e10cSrcweir // Default: 271*cdf0e10cSrcweir // SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir void ScCellShell::GetCellState( SfxItemSet& rSet ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir ScDocShell* pDocShell = GetViewData()->GetDocShell(); 276*cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); 277*cdf0e10cSrcweir ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 278*cdf0e10cSrcweir GetViewData()->GetTabNo() ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir SfxWhichIter aIter(rSet); 281*cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 282*cdf0e10cSrcweir while ( nWhich ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir sal_Bool bDisable = sal_False; 285*cdf0e10cSrcweir sal_Bool bNeedEdit = sal_True; // muss Cursorposition editierbar sein? 286*cdf0e10cSrcweir switch ( nWhich ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir case SID_THESAURUS: 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir CellType eType = pDoc->GetCellType( aCursor ); 291*cdf0e10cSrcweir bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT); 292*cdf0e10cSrcweir if (!bDisable) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir // test for available languages 295*cdf0e10cSrcweir sal_uInt16 nLang = ScViewUtil::GetEffLanguage( pDoc, aCursor ); 296*cdf0e10cSrcweir bDisable = !ScModule::HasThesaurusLanguage( nLang ); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir break; 300*cdf0e10cSrcweir case SID_OPENDLG_FUNCTION: 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ScMarkData aMarkData=GetViewData()->GetMarkData(); 303*cdf0e10cSrcweir aMarkData.MarkToSimple(); 304*cdf0e10cSrcweir ScRange aRange; 305*cdf0e10cSrcweir aMarkData.GetMarkArea(aRange); 306*cdf0e10cSrcweir if(aMarkData.IsMarked()) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if (!pDoc->IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(), 309*cdf0e10cSrcweir aRange.aEnd.Col(),aRange.aEnd.Row() )) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir bDisable = sal_True; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir bNeedEdit=sal_False; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir break; 318*cdf0e10cSrcweir case SID_INSERT_POSTIT: 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir if ( pDocShell && pDocShell->IsDocShared() ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir bDisable = sal_True; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir break; 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir if (!bDisable && bNeedEdit) 328*cdf0e10cSrcweir if (!pDoc->IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(), 329*cdf0e10cSrcweir aCursor.Col(),aCursor.Row() )) 330*cdf0e10cSrcweir bDisable = sal_True; 331*cdf0e10cSrcweir if (bDisable) 332*cdf0e10cSrcweir rSet.DisableItem(nWhich); 333*cdf0e10cSrcweir nWhich = aIter.NextWhich(); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir sal_Bool lcl_TestFormat( SvxClipboardFmtItem& rFormats, const TransferableDataHelper& rDataHelper, 338*cdf0e10cSrcweir SotFormatStringId nFormatId ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir if ( rDataHelper.HasFormat( nFormatId ) ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir // #90675# translated format name strings are no longer inserted here, 343*cdf0e10cSrcweir // handled by "paste special" dialog / toolbox controller instead. 344*cdf0e10cSrcweir // Only the object type name has to be set here: 345*cdf0e10cSrcweir String aStrVal; 346*cdf0e10cSrcweir if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir TransferableObjectDescriptor aDesc; 349*cdf0e10cSrcweir if ( ((TransferableDataHelper&)rDataHelper).GetTransferableObjectDescriptor( 350*cdf0e10cSrcweir SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc ) ) 351*cdf0e10cSrcweir aStrVal = aDesc.maTypeName; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir else if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE 354*cdf0e10cSrcweir || nFormatId == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir String aSource; 357*cdf0e10cSrcweir SvPasteObjectHelper::GetEmbeddedName( rDataHelper, aStrVal, aSource, nFormatId ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir if ( aStrVal.Len() ) 361*cdf0e10cSrcweir rFormats.AddClipbrdFormat( nFormatId, aStrVal ); 362*cdf0e10cSrcweir else 363*cdf0e10cSrcweir rFormats.AddClipbrdFormat( nFormatId ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir return sal_True; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir return sal_False; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir Window* pWin = GetViewData()->GetActiveWin(); 374*cdf0e10cSrcweir sal_Bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL ); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DRAWING ); 379*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_SVXB ); 380*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_GDIMETAFILE ); 381*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_BITMAP ); 382*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE ); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir if ( !bDraw ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_LINK ); 387*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_STRING ); 388*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DIF ); 389*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_RTF ); 390*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML ); 391*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML_SIMPLE ); 392*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_8 ); 393*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_5 ); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir if ( !lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ) 397*cdf0e10cSrcweir lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir // Einfuegen, Inhalte einfuegen 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir sal_Bool lcl_IsCellPastePossible( const TransferableDataHelper& rData ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir sal_Bool bPossible = sal_False; 405*cdf0e10cSrcweir if ( ScTransferObj::GetOwnClipboard( NULL ) || ScDrawTransferObj::GetOwnClipboard( NULL ) ) 406*cdf0e10cSrcweir bPossible = sal_True; 407*cdf0e10cSrcweir else 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir if ( rData.HasFormat( SOT_FORMAT_BITMAP ) || 410*cdf0e10cSrcweir rData.HasFormat( SOT_FORMAT_GDIMETAFILE ) || 411*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_SVXB ) || 412*cdf0e10cSrcweir rData.HasFormat( FORMAT_PRIVATE ) || 413*cdf0e10cSrcweir rData.HasFormat( SOT_FORMAT_RTF ) || 414*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) || 415*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) || 416*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) || 417*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) || 418*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) || 419*cdf0e10cSrcweir rData.HasFormat( SOT_FORMAT_STRING ) || 420*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) || 421*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_LINK ) || 422*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_HTML ) || 423*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) || 424*cdf0e10cSrcweir rData.HasFormat( SOT_FORMATSTR_ID_DIF ) ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir bPossible = sal_True; 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir return bPossible; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir if ( pDataHelper ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir bPastePossible = lcl_IsCellPastePossible( *pDataHelper ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir SfxBindings& rBindings = GetViewData()->GetBindings(); 439*cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE ); 440*cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE_SPECIAL ); 441*cdf0e10cSrcweir rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir return 0; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void __EXPORT ScCellShell::GetClipState( SfxItemSet& rSet ) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir // SID_PASTE 450*cdf0e10cSrcweir // SID_PASTE_SPECIAL 451*cdf0e10cSrcweir // SID_CLIPBOARD_FORMAT_ITEMS 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir if ( !pImpl->m_pClipEvtLstnr ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir // create listener 456*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) ); 457*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr->acquire(); 458*cdf0e10cSrcweir Window* pWin = GetViewData()->GetActiveWin(); 459*cdf0e10cSrcweir pImpl->m_pClipEvtLstnr->AddRemoveListener( pWin, sal_True ); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir // get initial state 462*cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) ); 463*cdf0e10cSrcweir bPastePossible = lcl_IsCellPastePossible( aDataHelper ); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir sal_Bool bDisable = !bPastePossible; 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir // Zellschutz / Multiselektion 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir if (!bDisable) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir SCCOL nCol = GetViewData()->GetCurX(); 473*cdf0e10cSrcweir SCROW nRow = GetViewData()->GetCurY(); 474*cdf0e10cSrcweir SCTAB nTab = GetViewData()->GetTabNo(); 475*cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument(); 476*cdf0e10cSrcweir if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow )) 477*cdf0e10cSrcweir bDisable = sal_True; 478*cdf0e10cSrcweir ScRange aDummy; 479*cdf0e10cSrcweir ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy); 480*cdf0e10cSrcweir if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED) 481*cdf0e10cSrcweir bDisable = sal_True; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if (bDisable) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir rSet.DisableItem( SID_PASTE ); 487*cdf0e10cSrcweir rSet.DisableItem( SID_PASTE_SPECIAL ); 488*cdf0e10cSrcweir rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS ); 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SFX_ITEM_UNKNOWN ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 493*cdf0e10cSrcweir GetPossibleClipboardFormats( aFormats ); 494*cdf0e10cSrcweir rSet.Put( aFormats ); 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir // only SID_HYPERLINK_GETLINK: 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir void ScCellShell::GetHLinkState( SfxItemSet& rSet ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir // always return an item (or inserting will be disabled) 503*cdf0e10cSrcweir // if the cell at the cursor contains only a link, return that link 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir SvxHyperlinkItem aHLinkItem; 506*cdf0e10cSrcweir if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir //! put selected text into item? 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir rSet.Put(aHLinkItem); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir void ScCellShell::GetState(SfxItemSet &rSet) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir // removed: SID_BORDER_OBJECT (old Basic) 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 519*cdf0e10cSrcweir // sal_Bool bOle = pTabViewShell->GetViewFrame()->GetFrame().IsInPlace(); 520*cdf0e10cSrcweir // sal_Bool bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo()); 521*cdf0e10cSrcweir ScDocShell* pDocSh = GetViewData()->GetDocShell(); 522*cdf0e10cSrcweir ScViewData* pData = GetViewData(); 523*cdf0e10cSrcweir ScDocument* pDoc = pData->GetDocument(); 524*cdf0e10cSrcweir ScMarkData& rMark = pData->GetMarkData(); 525*cdf0e10cSrcweir SCCOL nPosX = pData->GetCurX(); 526*cdf0e10cSrcweir SCROW nPosY = pData->GetCurY(); 527*cdf0e10cSrcweir SCTAB nTab = pData->GetTabNo(); 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 530*cdf0e10cSrcweir SCTAB nTabSelCount = rMark.GetSelectCount(); 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir SfxWhichIter aIter(rSet); 535*cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 536*cdf0e10cSrcweir while ( nWhich ) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir switch ( nWhich ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir case SID_DETECTIVE_REFRESH: 541*cdf0e10cSrcweir if (!pDoc->HasDetectiveOperations()) 542*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 543*cdf0e10cSrcweir break; 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir case SID_RANGE_ADDRESS: 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir ScRange aRange; 548*cdf0e10cSrcweir if ( pData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir String aStr; 551*cdf0e10cSrcweir sal_uInt16 nFlags = SCA_VALID | SCA_TAB_3D; 552*cdf0e10cSrcweir aRange.Format(aStr,nFlags,pDoc); 553*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aStr ) ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir break; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir case SID_RANGE_NOTETEXT: 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir // #43343# always take cursor position, do not use top-left cell of selection 561*cdf0e10cSrcweir ScAddress aPos( nPosX, nPosY, nTab ); 562*cdf0e10cSrcweir String aNoteText; 563*cdf0e10cSrcweir if ( const ScPostIt* pNote = pDoc->GetNote( aPos ) ) 564*cdf0e10cSrcweir aNoteText = pNote->GetText(); 565*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aNoteText ) ); 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir break; 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir case SID_RANGE_ROW: 570*cdf0e10cSrcweir rSet.Put( SfxInt32Item( nWhich, nPosY+1 ) ); 571*cdf0e10cSrcweir break; 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir case SID_RANGE_COL: 574*cdf0e10cSrcweir rSet.Put( SfxInt16Item( nWhich, nPosX+1 ) ); 575*cdf0e10cSrcweir break; 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir case SID_RANGE_TABLE: 578*cdf0e10cSrcweir rSet.Put( SfxInt16Item( nWhich, nTab+1 ) ); 579*cdf0e10cSrcweir break; 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir case SID_RANGE_VALUE: 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir double nValue; 584*cdf0e10cSrcweir pDoc->GetValue( nPosX, nPosY, nTab, nValue ); 585*cdf0e10cSrcweir rSet.Put( ScDoubleItem( nWhich, nValue ) ); 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir break; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir case SID_RANGE_FORMULA: 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir String aString; 592*cdf0e10cSrcweir pDoc->GetFormula( nPosX, nPosY, nTab, aString ); 593*cdf0e10cSrcweir if( aString.Len() == 0 ) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir pDoc->GetInputString( nPosX, nPosY, nTab, aString ); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aString ) ); 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir break; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir case SID_RANGE_TEXTVALUE: 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir String aString; 604*cdf0e10cSrcweir pDoc->GetString( nPosX, nPosY, nTab, aString ); 605*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aString ) ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir break; 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir case SID_STATUS_SELMODE: 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir /* 0: STD Click hebt Sel auf 612*cdf0e10cSrcweir * 1: ER Click erweitert Selektion 613*cdf0e10cSrcweir * 2: ERG Click definiert weitere Selektion 614*cdf0e10cSrcweir */ 615*cdf0e10cSrcweir sal_uInt16 nMode = pTabViewShell->GetLockedModifiers(); 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir switch ( nMode ) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir case KEY_SHIFT: nMode = 1; break; 620*cdf0e10cSrcweir case KEY_MOD1: nMode = 2; break; // Control-Taste 621*cdf0e10cSrcweir case 0: 622*cdf0e10cSrcweir default: 623*cdf0e10cSrcweir nMode = 0; 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir rSet.Put( SfxUInt16Item( nWhich, nMode ) ); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir break; 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir case SID_STATUS_DOCPOS: 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir String aStr( ScGlobal::GetRscString( STR_TABLE ) ); 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir aStr += ' '; 635*cdf0e10cSrcweir aStr += String::CreateFromInt32( nTab + 1 ); 636*cdf0e10cSrcweir aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " )); 637*cdf0e10cSrcweir aStr += String::CreateFromInt32( nTabCount ); 638*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aStr ) ); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir break; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir // Summe etc. mit Datum/Zeit/Fehler/Pos&Groesse zusammengefasst 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir // #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be 645*cdf0e10cSrcweir // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl. 646*cdf0e10cSrcweir case SID_TABLE_CELL: 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir // Testen, ob Fehler unter Cursor 649*cdf0e10cSrcweir // (nicht pDoc->GetErrCode, um keine zirkulaeren Referenzen auszuloesen) 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir // In interpreter may happen via rescheduled Basic 652*cdf0e10cSrcweir if ( pDoc->IsInInterpreter() ) 653*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, 654*cdf0e10cSrcweir String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")) ) ); 655*cdf0e10cSrcweir else 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir sal_uInt16 nErrCode = 0; 658*cdf0e10cSrcweir ScBaseCell* pCell; 659*cdf0e10cSrcweir pDoc->GetCell( nPosX, nPosY, nTab, pCell ); 660*cdf0e10cSrcweir if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir ScFormulaCell* pFCell = (ScFormulaCell*) pCell; 663*cdf0e10cSrcweir if (!pFCell->IsRunning()) 664*cdf0e10cSrcweir nErrCode = pFCell->GetErrCode(); 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir String aFuncStr; 668*cdf0e10cSrcweir if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) ) 669*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aFuncStr ) ); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir break; 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir case SID_DATA_SELECT: 675*cdf0e10cSrcweir // HasSelectionData includes column content and validity, 676*cdf0e10cSrcweir // page fields have to be checked separately. 677*cdf0e10cSrcweir if ( !pDoc->HasSelectionData( nPosX, nPosY, nTab ) && 678*cdf0e10cSrcweir !pTabViewShell->HasPageFieldDataAtCursor() ) 679*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 680*cdf0e10cSrcweir break; 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir case SID_STATUS_SUM: 683*cdf0e10cSrcweir { 684*cdf0e10cSrcweir String aFuncStr; 685*cdf0e10cSrcweir if ( pTabViewShell->GetFunction( aFuncStr ) ) 686*cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aFuncStr ) ); 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir break; 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir case FID_MERGE_ON: 691*cdf0e10cSrcweir if ( pDoc->GetChangeTrack() || !pTabViewShell->TestMergeCells() ) 692*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 693*cdf0e10cSrcweir break; 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir case FID_MERGE_OFF: 696*cdf0e10cSrcweir if ( pDoc->GetChangeTrack() || !pTabViewShell->TestRemoveMerge() ) 697*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 698*cdf0e10cSrcweir break; 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir case FID_MERGE_TOGGLE: 701*cdf0e10cSrcweir if ( pDoc->GetChangeTrack() ) 702*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 703*cdf0e10cSrcweir else 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir bool bCanMerge = pTabViewShell->TestMergeCells(); 706*cdf0e10cSrcweir bool bCanSplit = pTabViewShell->TestRemoveMerge(); 707*cdf0e10cSrcweir if( !bCanMerge && !bCanSplit ) 708*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 709*cdf0e10cSrcweir else 710*cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bCanSplit ) ); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir break; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir case FID_INS_ROWBRK: 715*cdf0e10cSrcweir if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) ) 716*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 717*cdf0e10cSrcweir break; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir case FID_INS_COLBRK: 720*cdf0e10cSrcweir if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) ) 721*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 722*cdf0e10cSrcweir break; 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir case FID_DEL_ROWBRK: 725*cdf0e10cSrcweir if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 ) 726*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 727*cdf0e10cSrcweir break; 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir case FID_DEL_COLBRK: 730*cdf0e10cSrcweir if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 ) 731*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 732*cdf0e10cSrcweir break; 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir case FID_FILL_TAB: 735*cdf0e10cSrcweir if ( nTabSelCount < 2 ) 736*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 737*cdf0e10cSrcweir break; 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir case SID_SELECT_SCENARIO: 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir // ScDocument* pDoc = GetViewData()->GetDocument(); 742*cdf0e10cSrcweir // SCTAB nTab = GetViewData()->GetTabNo(); 743*cdf0e10cSrcweir List aList; 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir Color aDummyCol; 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir if ( !pDoc->IsScenario(nTab) ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir String aStr; 750*cdf0e10cSrcweir sal_uInt16 nFlags; 751*cdf0e10cSrcweir SCTAB nScTab = nTab + 1; 752*cdf0e10cSrcweir String aProtect; 753*cdf0e10cSrcweir bool bSheetProtected = pDoc->IsTabProtected(nTab); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir while ( pDoc->IsScenario(nScTab) ) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir pDoc->GetName( nScTab, aStr ); 758*cdf0e10cSrcweir aList.Insert( new String( aStr ), LIST_APPEND ); 759*cdf0e10cSrcweir pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nFlags ); 760*cdf0e10cSrcweir aList.Insert( new String( aStr ), LIST_APPEND ); 761*cdf0e10cSrcweir // Protection is sal_True if both Sheet and Scenario are protected 762*cdf0e10cSrcweir aProtect = (bSheetProtected && (nFlags & SC_SCENARIO_PROTECT)) ? '1' : '0'; 763*cdf0e10cSrcweir aList.Insert( new String( aProtect), LIST_APPEND ); 764*cdf0e10cSrcweir ++nScTab; 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir else 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir String aComment; 770*cdf0e10cSrcweir sal_uInt16 nDummyFlags; 771*cdf0e10cSrcweir pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags ); 772*cdf0e10cSrcweir DBG_ASSERT( aList.Count() == 0, "List not empty!" ); 773*cdf0e10cSrcweir aList.Insert( new String( aComment ) ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir rSet.Put( SfxStringListItem( nWhich, &aList ) ); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir sal_uLong nCount = aList.Count(); 779*cdf0e10cSrcweir for ( sal_uLong i=0; i<nCount; i++ ) 780*cdf0e10cSrcweir delete (String*) aList.GetObject(i); 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir break; 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir case FID_ROW_HIDE: 785*cdf0e10cSrcweir case FID_ROW_SHOW: 786*cdf0e10cSrcweir case FID_COL_HIDE: 787*cdf0e10cSrcweir case FID_COL_SHOW: 788*cdf0e10cSrcweir case FID_COL_OPT_WIDTH: 789*cdf0e10cSrcweir case FID_ROW_OPT_HEIGHT: 790*cdf0e10cSrcweir case FID_DELETE_CELL: 791*cdf0e10cSrcweir if ( pDoc->IsTabProtected(nTab) || pDocSh->IsReadOnly()) 792*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 793*cdf0e10cSrcweir break; 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir /* Zellschutz bei selektierten Zellen wird bei anderen Funktionen auch nicht abgefragt... 796*cdf0e10cSrcweir case SID_DELETE: 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir if ( pDoc->IsTabProtected(nTab) ) 799*cdf0e10cSrcweir { 800*cdf0e10cSrcweir const SfxItemSet& rAttrSet = GetSelectionPattern()->GetItemSet(); 801*cdf0e10cSrcweir const ScProtectionAttr& rProtAttr = (const ScProtectionAttr&)rAttrSet.Get( ATTR_PROTECTION, sal_True ); 802*cdf0e10cSrcweir if ( rProtAttr.GetProtection() ) 803*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir break; 807*cdf0e10cSrcweir */ 808*cdf0e10cSrcweir case SID_OUTLINE_MAKE: 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 811*cdf0e10cSrcweir GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir //! test for data pilot operation 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir else if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked()) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir break; 821*cdf0e10cSrcweir case SID_OUTLINE_SHOW: 822*cdf0e10cSrcweir if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 823*cdf0e10cSrcweir GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 824*cdf0e10cSrcweir { 825*cdf0e10cSrcweir //! test for data pilot operation 826*cdf0e10cSrcweir } 827*cdf0e10cSrcweir else if (!pTabViewShell->OutlinePossible(sal_False)) 828*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 829*cdf0e10cSrcweir break; 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir case SID_OUTLINE_HIDE: 832*cdf0e10cSrcweir if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 833*cdf0e10cSrcweir GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir //! test for data pilot operation 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir else if (!pTabViewShell->OutlinePossible(sal_True)) 838*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 839*cdf0e10cSrcweir break; 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir case SID_OUTLINE_REMOVE: 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(), 844*cdf0e10cSrcweir GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir //! test for data pilot operation 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir else 849*cdf0e10cSrcweir { 850*cdf0e10cSrcweir sal_Bool bCol, bRow; 851*cdf0e10cSrcweir pTabViewShell->TestRemoveOutline( bCol, bRow ); 852*cdf0e10cSrcweir if ( !bCol && !bRow ) 853*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir break; 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir case FID_COL_WIDTH: 859*cdf0e10cSrcweir { 860*cdf0e10cSrcweir //GetViewData()->GetCurX(); 861*cdf0e10cSrcweir SfxUInt16Item aWidthItem( FID_COL_WIDTH, pDoc->GetColWidth( nPosX , nTab) ); 862*cdf0e10cSrcweir rSet.Put( aWidthItem ); 863*cdf0e10cSrcweir if ( pDocSh->IsReadOnly()) 864*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir //XXX Disablen wenn nicht eindeutig 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir break; 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir case FID_ROW_HEIGHT: 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir //GetViewData()->GetCurY(); 873*cdf0e10cSrcweir SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, pDoc->GetRowHeight( nPosY , nTab) ); 874*cdf0e10cSrcweir rSet.Put( aHeightItem ); 875*cdf0e10cSrcweir //XXX Disablen wenn nicht eindeutig 876*cdf0e10cSrcweir if ( pDocSh->IsReadOnly()) 877*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir break; 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir case SID_DETECTIVE_FILLMODE: 882*cdf0e10cSrcweir rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() )); 883*cdf0e10cSrcweir break; 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir case FID_INPUTLINE_STATUS: 886*cdf0e10cSrcweir DBG_ERROR( "Old update method. Use ScTabViewShell::UpdateInputHandler()." ); 887*cdf0e10cSrcweir break; 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir case SID_SCENARIOS: // Szenarios: 890*cdf0e10cSrcweir if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // nur, wenn etwas selektiert 891*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 892*cdf0e10cSrcweir break; 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir case FID_NOTE_VISIBLE: 895*cdf0e10cSrcweir { 896*cdf0e10cSrcweir const ScPostIt* pNote = pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) ); 897*cdf0e10cSrcweir if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) ) 898*cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) ); 899*cdf0e10cSrcweir else 900*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir break; 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir case SID_DELETE_NOTE: 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir sal_Bool bEnable = sal_False; 907*cdf0e10cSrcweir if ( rMark.IsMarked() || rMark.IsMultiMarked() ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir if ( pDoc->IsSelectionEditable( rMark ) ) 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir // look for at least one note in selection 912*cdf0e10cSrcweir ScRangeList aRanges; 913*cdf0e10cSrcweir rMark.FillRangeListWithMarks( &aRanges, sal_False ); 914*cdf0e10cSrcweir sal_uLong nCount = aRanges.Count(); 915*cdf0e10cSrcweir for (sal_uLong nPos=0; nPos<nCount && !bEnable; nPos++) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir ScCellIterator aCellIter( pDoc, *aRanges.GetObject(nPos) ); 918*cdf0e10cSrcweir for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() ) 919*cdf0e10cSrcweir if ( pCell->HasNote() ) 920*cdf0e10cSrcweir bEnable = sal_True; // note found 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir else 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) && 927*cdf0e10cSrcweir pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) ); 928*cdf0e10cSrcweir } 929*cdf0e10cSrcweir if ( !bEnable ) 930*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir break; 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir case SID_OPENDLG_CONSOLIDATE: 935*cdf0e10cSrcweir case SCITEM_CONSOLIDATEDATA: 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir if(pDoc->GetChangeTrack()!=NULL) 938*cdf0e10cSrcweir rSet.DisableItem( nWhich); 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir break; 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir case SID_CHINESE_CONVERSION: 943*cdf0e10cSrcweir case SID_HANGUL_HANJA_CONVERSION: 944*cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pData->GetBindings(), nWhich ); 945*cdf0e10cSrcweir break; 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir case FID_USE_NAME: 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir if ( pDocSh && pDocSh->IsDocShared() ) 950*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 951*cdf0e10cSrcweir else 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir ScRange aRange; 954*cdf0e10cSrcweir if ( pData->GetSimpleArea( aRange ) != SC_MARK_SIMPLE ) 955*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir break; 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir case FID_DEFINE_NAME: 961*cdf0e10cSrcweir case FID_INSERT_NAME: 962*cdf0e10cSrcweir case SID_DEFINE_COLROWNAMERANGES: 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir if ( pDocSh && pDocSh->IsDocShared() ) 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir } 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir case SID_SPELL_DIALOG: 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) ) 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir bool bVisible = false; 976*cdf0e10cSrcweir SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL ); 977*cdf0e10cSrcweir if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) ) 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich ); 980*cdf0e10cSrcweir Window* pWin = ( pChild ? pChild->GetWindow() : NULL ); 981*cdf0e10cSrcweir if ( pWin && pWin->IsVisible() ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir bVisible = true; 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir if ( !bVisible ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir rSet.DisableItem( nWhich ); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir break; 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir } // switch ( nWitch ) 995*cdf0e10cSrcweir nWhich = aIter.NextWhich(); 996*cdf0e10cSrcweir } // while ( nWitch ) 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir //------------------------------------------------------------------ 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir 1003