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