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 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 #include <com/sun/star/embed/XEmbeddedObject.hpp> 29cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir using namespace ::com::sun::star; 33cdf0e10cSrcweir 34cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 35cdf0e10cSrcweir #if STLPORT_VERSION>=321 36cdf0e10cSrcweir #include <math.h> // prevent conflict between exception and std::exception 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "scitems.hxx" 40cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 41cdf0e10cSrcweir #include <editeng/eeitem.hxx> 42cdf0e10cSrcweir #include <sfx2/objface.hxx> 43cdf0e10cSrcweir #include <sfx2/app.hxx> 44cdf0e10cSrcweir #include <sfx2/bindings.hxx> 45cdf0e10cSrcweir #include <sfx2/docfile.hxx> 46cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 47cdf0e10cSrcweir #include <svtools/ehdl.hxx> 48cdf0e10cSrcweir #include <basic/sbxcore.hxx> 49cdf0e10cSrcweir #include <sfx2/printer.hxx> 50cdf0e10cSrcweir #include <sfx2/request.hxx> 51cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 52cdf0e10cSrcweir #include <svx/ofaitem.hxx> 53cdf0e10cSrcweir #include <sot/formats.hxx> 54cdf0e10cSrcweir #include <svl/whiter.hxx> 55cdf0e10cSrcweir #include <vcl/msgbox.hxx> 56cdf0e10cSrcweir #include <vcl/waitobj.hxx> 57cdf0e10cSrcweir #include <tools/multisel.hxx> 58cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx> 59cdf0e10cSrcweir #include <svx/drawitem.hxx> 60cdf0e10cSrcweir #include <svx/fmview.hxx> 61cdf0e10cSrcweir #include <svx/pageitem.hxx> 62cdf0e10cSrcweir #include <svx/svditer.hxx> 63cdf0e10cSrcweir #include <svx/svdpage.hxx> 64cdf0e10cSrcweir #include <svx/fmshell.hxx> 65cdf0e10cSrcweir #include <svtools/xwindowitem.hxx> 66cdf0e10cSrcweir #include <sfx2/passwd.hxx> 67cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 68cdf0e10cSrcweir #include <sfx2/docinsert.hxx> 69cdf0e10cSrcweir #include <svl/PasswordHelper.hxx> 70cdf0e10cSrcweir #include <svl/documentlockfile.hxx> 71cdf0e10cSrcweir #include <svl/sharecontrolfile.hxx> 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 74cdf0e10cSrcweir #include "docuno.hxx" 75cdf0e10cSrcweir 76cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 77cdf0e10cSrcweir #include "docsh.hxx" 78cdf0e10cSrcweir #include "docshimp.hxx" 79cdf0e10cSrcweir #include "docfunc.hxx" 80cdf0e10cSrcweir #include "sc.hrc" 81cdf0e10cSrcweir #include "stlsheet.hxx" 82cdf0e10cSrcweir #include "stlpool.hxx" 83cdf0e10cSrcweir #include "appoptio.hxx" 84cdf0e10cSrcweir #include "globstr.hrc" 85cdf0e10cSrcweir #include "global.hxx" 86cdf0e10cSrcweir //CHINA001 #include "styledlg.hxx" 87cdf0e10cSrcweir //CHINA001 #include "hfedtdlg.hxx" 88cdf0e10cSrcweir #include "dbdocfun.hxx" 89cdf0e10cSrcweir #include "printfun.hxx" // DrawToDev 90cdf0e10cSrcweir #include "viewdata.hxx" 91cdf0e10cSrcweir #include "tabvwsh.hxx" 92cdf0e10cSrcweir #include "impex.hxx" 93cdf0e10cSrcweir #include "attrib.hxx" 94cdf0e10cSrcweir //CHINA001 #include "corodlg.hxx" 95cdf0e10cSrcweir #include "undodat.hxx" 96cdf0e10cSrcweir #include "autostyl.hxx" 97cdf0e10cSrcweir #include "undocell.hxx" 98cdf0e10cSrcweir #include "undotab.hxx" 99cdf0e10cSrcweir #include "inputhdl.hxx" 100cdf0e10cSrcweir #include "dbcolect.hxx" 101cdf0e10cSrcweir #include "servobj.hxx" 102cdf0e10cSrcweir #include "rangenam.hxx" 103cdf0e10cSrcweir #include "scmod.hxx" 104cdf0e10cSrcweir //CHINA001 #include "scendlg.hxx" 105cdf0e10cSrcweir #include "chgviset.hxx" 106cdf0e10cSrcweir #include "reffact.hxx" 107cdf0e10cSrcweir #include "chartlis.hxx" 108cdf0e10cSrcweir #include "chartpos.hxx" 109cdf0e10cSrcweir #include "waitoff.hxx" 110cdf0e10cSrcweir #include "tablink.hxx" // ScDocumentLoader statics 111cdf0e10cSrcweir #include "drwlayer.hxx" 112cdf0e10cSrcweir #include "docoptio.hxx" 113cdf0e10cSrcweir #include "undostyl.hxx" 114cdf0e10cSrcweir #include "rangeseq.hxx" 115cdf0e10cSrcweir #include "chgtrack.hxx" 116cdf0e10cSrcweir #include "printopt.hxx" 117cdf0e10cSrcweir #include <com/sun/star/document/UpdateDocMode.hpp> 118cdf0e10cSrcweir #include "scresid.hxx" //add by CHINA001 119cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001 120cdf0e10cSrcweir #include "externalrefmgr.hxx" 121cdf0e10cSrcweir #include "sharedocdlg.hxx" 122cdf0e10cSrcweir #include "conditio.hxx" 123cdf0e10cSrcweir #include "sheetevents.hxx" 124cdf0e10cSrcweir 125cdf0e10cSrcweir //------------------------------------------------------------------ 126cdf0e10cSrcweir 127cdf0e10cSrcweir #define IS_SHARE_HEADER(set) \ 128cdf0e10cSrcweir ((SfxBoolItem&) \ 129cdf0e10cSrcweir ((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \ 130cdf0e10cSrcweir Get(ATTR_PAGE_SHARED)).GetValue() 131cdf0e10cSrcweir 132cdf0e10cSrcweir #define IS_SHARE_FOOTER(set) \ 133cdf0e10cSrcweir ((SfxBoolItem&) \ 134cdf0e10cSrcweir ((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \ 135cdf0e10cSrcweir Get(ATTR_PAGE_SHARED)).GetValue() 136cdf0e10cSrcweir 137cdf0e10cSrcweir #define IS_AVAILABLE(WhichId,ppItem) \ 138cdf0e10cSrcweir (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET) 139cdf0e10cSrcweir 140cdf0e10cSrcweir #define SC_PREVIEW_SIZE_X 10000 141cdf0e10cSrcweir #define SC_PREVIEW_SIZE_Y 12400 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir //------------------------------------------------------------------ 145cdf0e10cSrcweir 146cdf0e10cSrcweir void ScDocShell::Execute( SfxRequest& rReq ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir // SID_SC_RANGE (Range), 149cdf0e10cSrcweir // SID_SC_CELLTEXT (CellText), 150cdf0e10cSrcweir // SID_SC_CELLS (Cells) - removed (old Basic) 151cdf0e10cSrcweir 152cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 153cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 154cdf0e10cSrcweir sal_Bool bUndo (aDocument.IsUndoEnabled()); 155cdf0e10cSrcweir 156cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 157cdf0e10cSrcweir switch ( nSlot ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir case SID_SC_SETTEXT: 160cdf0e10cSrcweir { 161cdf0e10cSrcweir const SfxPoolItem* pColItem; 162cdf0e10cSrcweir const SfxPoolItem* pRowItem; 163cdf0e10cSrcweir const SfxPoolItem* pTabItem; 164cdf0e10cSrcweir const SfxPoolItem* pTextItem; 165cdf0e10cSrcweir if( pReqArgs && IS_AVAILABLE( FN_PARAM_1, &pColItem ) && 166cdf0e10cSrcweir IS_AVAILABLE( FN_PARAM_2, &pRowItem ) && 167cdf0e10cSrcweir IS_AVAILABLE( FN_PARAM_3, &pTabItem ) && 168cdf0e10cSrcweir IS_AVAILABLE( SID_SC_SETTEXT, &pTextItem ) ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir // Parameter sind 1-based !!! 171cdf0e10cSrcweir SCCOL nCol = ((SfxInt16Item*)pColItem)->GetValue() - 1; 172cdf0e10cSrcweir SCROW nRow = ((SfxInt32Item*)pRowItem)->GetValue() - 1; 173cdf0e10cSrcweir SCTAB nTab = ((SfxInt16Item*)pTabItem)->GetValue() - 1; 174cdf0e10cSrcweir 175cdf0e10cSrcweir SCTAB nTabCount = aDocument.GetTableCount(); 176cdf0e10cSrcweir if ( ValidCol(nCol) && ValidRow(nRow) && ValidTab(nTab,nTabCount) ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir if ( aDocument.IsBlockEditable( nTab, nCol,nRow, nCol, nRow ) ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir String aVal = ((const SfxStringItem*)pTextItem)->GetValue(); 181cdf0e10cSrcweir aDocument.SetString( nCol, nRow, nTab, aVal ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir PostPaintCell( nCol, nRow, nTab ); 184cdf0e10cSrcweir SetDocumentModified(); 185cdf0e10cSrcweir 186cdf0e10cSrcweir rReq.Done(); 187cdf0e10cSrcweir break; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir else // geschuetzte Zelle 190cdf0e10cSrcweir { 191cdf0e10cSrcweir SbxBase::SetError( SbxERR_BAD_PARAMETER ); //! welchen Fehler ? 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir } 195cdf0e10cSrcweir } 196cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_OBJECT ); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir break; 199cdf0e10cSrcweir 200cdf0e10cSrcweir case SID_SBA_IMPORT: 201cdf0e10cSrcweir { 202cdf0e10cSrcweir if (pReqArgs) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir const SfxPoolItem* pItem; 205cdf0e10cSrcweir svx::ODataAccessDescriptor aDesc; 206cdf0e10cSrcweir if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir uno::Any aAny = static_cast<const SfxUsrAnyItem*>(pItem)->GetValue(); 209cdf0e10cSrcweir uno::Sequence<beans::PropertyValue> aProperties; 210cdf0e10cSrcweir if ( aAny >>= aProperties ) 211cdf0e10cSrcweir aDesc.initializeFrom( aProperties ); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir String sTarget; 215cdf0e10cSrcweir if ( pReqArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET ) 216cdf0e10cSrcweir sTarget = ((const SfxStringItem*)pItem)->GetValue(); 217cdf0e10cSrcweir 218cdf0e10cSrcweir sal_Bool bIsNewArea = sal_True; // Default sal_True (keine Nachfrage) 219cdf0e10cSrcweir if ( pReqArgs->GetItemState( FN_PARAM_2, sal_True, &pItem ) == SFX_ITEM_SET ) 220cdf0e10cSrcweir bIsNewArea = ((const SfxBoolItem*)pItem)->GetValue(); 221cdf0e10cSrcweir 222cdf0e10cSrcweir // bei Bedarf neuen Datenbankbereich anlegen 223cdf0e10cSrcweir sal_Bool bMakeArea = sal_False; 224cdf0e10cSrcweir if (bIsNewArea) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir ScDBCollection* pDBColl = aDocument.GetDBCollection(); 227cdf0e10cSrcweir sal_uInt16 nDummy; 228cdf0e10cSrcweir if ( !pDBColl || !pDBColl->SearchName( sTarget, nDummy ) ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir ScAddress aPos; 231cdf0e10cSrcweir if ( aPos.Parse( sTarget, &aDocument, aDocument.GetAddressConvention() ) & SCA_VALID ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir bMakeArea = sal_True; 234cdf0e10cSrcweir if (bUndo) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir String aStrImport = ScGlobal::GetRscString( STR_UNDO_IMPORTDATA ); 237cdf0e10cSrcweir GetUndoManager()->EnterListAction( aStrImport, aStrImport ); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, SC_DBSEL_KEEP ); 241cdf0e10cSrcweir DBG_ASSERT(pDBData, "kann DB-Daten nicht anlegen"); 242cdf0e10cSrcweir sTarget = pDBData->GetName(); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir } 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir // nachfragen, bevor alter DB-Bereich ueberschrieben wird 248cdf0e10cSrcweir sal_Bool bDo = sal_True; 249cdf0e10cSrcweir if (!bIsNewArea) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir String aTemplate = ScGlobal::GetRscString( STR_IMPORT_REPLACE ); 252cdf0e10cSrcweir String aMessage = aTemplate.GetToken( 0, '#' ); 253cdf0e10cSrcweir aMessage += sTarget; 254cdf0e10cSrcweir aMessage += aTemplate.GetToken( 1, '#' ); 255cdf0e10cSrcweir 256cdf0e10cSrcweir QueryBox aBox( 0, WinBits(WB_YES_NO | WB_DEF_YES), aMessage ); 257cdf0e10cSrcweir bDo = ( aBox.Execute() == RET_YES ); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir if (bDo) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir ScDBDocFunc(*this).UpdateImport( sTarget, aDesc ); 263cdf0e10cSrcweir rReq.Done(); 264cdf0e10cSrcweir 265cdf0e10cSrcweir // UpdateImport aktualisiert auch die internen Operationen 266cdf0e10cSrcweir } 267cdf0e10cSrcweir else 268cdf0e10cSrcweir rReq.Ignore(); 269cdf0e10cSrcweir 270cdf0e10cSrcweir if ( bMakeArea && bUndo) 271cdf0e10cSrcweir GetUndoManager()->LeaveListAction(); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir else 274cdf0e10cSrcweir { 275cdf0e10cSrcweir DBG_ERROR( "arguments expected" ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir break; 279cdf0e10cSrcweir 280cdf0e10cSrcweir case SID_CHART_SOURCE: 281cdf0e10cSrcweir case SID_CHART_ADDSOURCE: 282cdf0e10cSrcweir if (pReqArgs) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir ScDocument* pDoc = GetDocument(); 285cdf0e10cSrcweir // sal_Bool bUndo (pDoc->IsUndoEnabled()); 286cdf0e10cSrcweir const SfxPoolItem* pItem; 287cdf0e10cSrcweir String aChartName, aRangeName; 288cdf0e10cSrcweir 289cdf0e10cSrcweir ScRange aSingleRange; 290cdf0e10cSrcweir ScRangeListRef aRangeListRef; 291cdf0e10cSrcweir sal_Bool bMultiRange = sal_False; 292cdf0e10cSrcweir 293cdf0e10cSrcweir sal_Bool bColHeaders = sal_True; 294cdf0e10cSrcweir sal_Bool bRowHeaders = sal_True; 295cdf0e10cSrcweir sal_Bool bColInit = sal_False; 296cdf0e10cSrcweir sal_Bool bRowInit = sal_False; 297cdf0e10cSrcweir sal_Bool bAddRange = (nSlot == SID_CHART_ADDSOURCE); 298cdf0e10cSrcweir 299cdf0e10cSrcweir if( IS_AVAILABLE( SID_CHART_NAME, &pItem ) ) 300cdf0e10cSrcweir aChartName = ((const SfxStringItem*)pItem)->GetValue(); 301cdf0e10cSrcweir 302cdf0e10cSrcweir if( IS_AVAILABLE( SID_CHART_SOURCE, &pItem ) ) 303cdf0e10cSrcweir aRangeName = ((const SfxStringItem*)pItem)->GetValue(); 304cdf0e10cSrcweir 305cdf0e10cSrcweir if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir bColHeaders = ((const SfxBoolItem*)pItem)->GetValue(); 308cdf0e10cSrcweir bColInit = sal_True; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir if( IS_AVAILABLE( FN_PARAM_2, &pItem ) ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir bRowHeaders = ((const SfxBoolItem*)pItem)->GetValue(); 313cdf0e10cSrcweir bRowInit = sal_True; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0); 317cdf0e10cSrcweir sal_Bool bValid = ( aSingleRange.ParseAny( aRangeName, pDoc, aDetails ) & SCA_VALID ) != 0; 318cdf0e10cSrcweir if (!bValid) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir aRangeListRef = new ScRangeList; 321cdf0e10cSrcweir aRangeListRef->Parse( aRangeName, pDoc ); 322cdf0e10cSrcweir if ( aRangeListRef->Count() ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir bMultiRange = sal_True; 325cdf0e10cSrcweir aSingleRange = *aRangeListRef->GetObject(0); // fuer Header 326cdf0e10cSrcweir bValid = sal_True; 327cdf0e10cSrcweir } 328cdf0e10cSrcweir else 329cdf0e10cSrcweir aRangeListRef.Clear(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 333cdf0e10cSrcweir if (pViewSh && bValid && aChartName.Len() != 0 ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir Window* pParent = pViewSh->GetDialogParent(); 336cdf0e10cSrcweir 337cdf0e10cSrcweir SCCOL nCol1 = aSingleRange.aStart.Col(); 338cdf0e10cSrcweir SCROW nRow1 = aSingleRange.aStart.Row(); 339cdf0e10cSrcweir SCCOL nCol2 = aSingleRange.aEnd.Col(); 340cdf0e10cSrcweir SCROW nRow2 = aSingleRange.aEnd.Row(); 341cdf0e10cSrcweir SCTAB nTab = aSingleRange.aStart.Tab(); 342cdf0e10cSrcweir 343cdf0e10cSrcweir //! immer oder gar nicht begrenzen ??? 344cdf0e10cSrcweir if (!bMultiRange) 345cdf0e10cSrcweir aDocument.LimitChartArea( nTab, nCol1,nRow1, nCol2,nRow2 ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir // Dialog fuer Spalten/Zeilenkoepfe 348cdf0e10cSrcweir sal_Bool bOk = sal_True; 349cdf0e10cSrcweir if ( !bAddRange && ( !bColInit || !bRowInit ) ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir ScChartPositioner aChartPositioner( &aDocument, nTab, nCol1,nRow1, nCol2,nRow2 ); 352cdf0e10cSrcweir if (!bColInit) 353cdf0e10cSrcweir bColHeaders = aChartPositioner.HasColHeaders(); 354cdf0e10cSrcweir if (!bRowInit) 355cdf0e10cSrcweir bRowHeaders = aChartPositioner.HasRowHeaders(); 356cdf0e10cSrcweir 357cdf0e10cSrcweir //CHINA001 ScColRowLabelDlg aDlg( pParent, bRowHeaders, bColHeaders ); 358cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 359cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 360cdf0e10cSrcweir 361cdf0e10cSrcweir AbstractScColRowLabelDlg* pDlg = pFact->CreateScColRowLabelDlg( pParent, RID_SCDLG_CHARTCOLROW, bRowHeaders, bColHeaders); 362cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 363cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) //CHINA001 if ( aDlg.Execute() == RET_OK ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir bColHeaders = pDlg->IsRow(); //CHINA001 bColHeaders = aDlg.IsRow(); // Spaltenkoepfe = 1. Zeile 366cdf0e10cSrcweir bRowHeaders = pDlg->IsCol(); //CHINA001 bRowHeaders = aDlg.IsCol(); 367cdf0e10cSrcweir 368cdf0e10cSrcweir rReq.AppendItem(SfxBoolItem(FN_PARAM_1, bColHeaders)); 369cdf0e10cSrcweir rReq.AppendItem(SfxBoolItem(FN_PARAM_2, bRowHeaders)); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir else 372cdf0e10cSrcweir bOk = sal_False; 373cdf0e10cSrcweir delete pDlg; //CHINA001 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir if (bOk) // ausfuehren 377cdf0e10cSrcweir { 378cdf0e10cSrcweir if (bMultiRange) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if (bUndo) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir GetUndoManager()->AddUndoAction( 383cdf0e10cSrcweir new ScUndoChartData( this, aChartName, aRangeListRef, 384cdf0e10cSrcweir bColHeaders, bRowHeaders, bAddRange ) ); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir aDocument.UpdateChartArea( aChartName, aRangeListRef, 387cdf0e10cSrcweir bColHeaders, bRowHeaders, bAddRange ); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir else 390cdf0e10cSrcweir { 391cdf0e10cSrcweir ScRange aNewRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab ); 392cdf0e10cSrcweir if (bUndo) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir GetUndoManager()->AddUndoAction( 395cdf0e10cSrcweir new ScUndoChartData( this, aChartName, aNewRange, 396cdf0e10cSrcweir bColHeaders, bRowHeaders, bAddRange ) ); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir aDocument.UpdateChartArea( aChartName, aNewRange, 399cdf0e10cSrcweir bColHeaders, bRowHeaders, bAddRange ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir } 402cdf0e10cSrcweir } 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir DBG_ERROR("UpdateChartArea: keine ViewShell oder falsche Daten"); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir rReq.Done(); 408cdf0e10cSrcweir } 409cdf0e10cSrcweir else 410cdf0e10cSrcweir { 411cdf0e10cSrcweir DBG_ERROR("SID_CHART_SOURCE ohne Argumente"); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir break; 414cdf0e10cSrcweir 415cdf0e10cSrcweir case FID_AUTO_CALC: 416cdf0e10cSrcweir { 417cdf0e10cSrcweir sal_Bool bNewVal; 418cdf0e10cSrcweir const SfxPoolItem* pItem; 419cdf0e10cSrcweir if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, sal_True, &pItem ) ) 420cdf0e10cSrcweir bNewVal = ((const SfxBoolItem*)pItem)->GetValue(); 421cdf0e10cSrcweir else 422cdf0e10cSrcweir bNewVal = !aDocument.GetAutoCalc(); // Toggle fuer Menue 423cdf0e10cSrcweir aDocument.SetAutoCalc( bNewVal ); 424cdf0e10cSrcweir SetDocumentModified(); 425cdf0e10cSrcweir if (pBindings) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir pBindings->Invalidate( FID_AUTO_CALC ); 428cdf0e10cSrcweir // pBindings->Invalidate( FID_RECALC ); // jetzt immer enabled 429cdf0e10cSrcweir } 430cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FID_AUTO_CALC, bNewVal ) ); 431cdf0e10cSrcweir rReq.Done(); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir break; 434cdf0e10cSrcweir case FID_RECALC: 435cdf0e10cSrcweir DoRecalc( rReq.IsAPI() ); 436cdf0e10cSrcweir rReq.Done(); 437cdf0e10cSrcweir break; 438cdf0e10cSrcweir case FID_HARD_RECALC: 439cdf0e10cSrcweir DoHardRecalc( rReq.IsAPI() ); 440cdf0e10cSrcweir rReq.Done(); 441cdf0e10cSrcweir break; 442cdf0e10cSrcweir case SID_UPDATETABLINKS: 443cdf0e10cSrcweir { 444cdf0e10cSrcweir ScDocument* pDoc = GetDocument(); 445cdf0e10cSrcweir 446cdf0e10cSrcweir ScLkUpdMode nSet=pDoc->GetLinkMode(); 447cdf0e10cSrcweir 448cdf0e10cSrcweir sal_uInt16 nDlgRet=RET_NO; 449cdf0e10cSrcweir if(nSet==LM_UNKNOWN) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir ScAppOptions aAppOptions=SC_MOD()->GetAppOptions(); 452cdf0e10cSrcweir nSet=aAppOptions.GetLinkMode(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir if (nCanUpdate == com::sun::star::document::UpdateDocMode::NO_UPDATE) 456cdf0e10cSrcweir nSet = LM_NEVER; 457cdf0e10cSrcweir else if (nCanUpdate == com::sun::star::document::UpdateDocMode::QUIET_UPDATE && 458cdf0e10cSrcweir nSet == LM_ON_DEMAND) 459cdf0e10cSrcweir nSet = LM_NEVER; 460cdf0e10cSrcweir else if (nCanUpdate == com::sun::star::document::UpdateDocMode::FULL_UPDATE) 461cdf0e10cSrcweir nSet = LM_ALWAYS; 462cdf0e10cSrcweir 463cdf0e10cSrcweir if(nSet==LM_ON_DEMAND) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir QueryBox aBox( GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), 466cdf0e10cSrcweir ScGlobal::GetRscString(STR_RELOAD_TABLES) ); 467cdf0e10cSrcweir 468cdf0e10cSrcweir nDlgRet=aBox.Execute(); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir if (nDlgRet == RET_YES || nSet==LM_ALWAYS) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir ReloadTabLinks(); 474cdf0e10cSrcweir aDocument.UpdateExternalRefLinks(); 475cdf0e10cSrcweir aDocument.UpdateDdeLinks(); 476cdf0e10cSrcweir aDocument.UpdateAreaLinks(); 477cdf0e10cSrcweir 478cdf0e10cSrcweir //! Test, ob Fehler 479cdf0e10cSrcweir rReq.Done(); 480cdf0e10cSrcweir } 481cdf0e10cSrcweir else 482cdf0e10cSrcweir rReq.Ignore(); 483cdf0e10cSrcweir } 484cdf0e10cSrcweir break; 485cdf0e10cSrcweir 486cdf0e10cSrcweir case SID_REIMPORT_AFTER_LOAD: 487cdf0e10cSrcweir { 488cdf0e10cSrcweir // wird nach dem Laden aufgerufen, wenn DB-Bereiche mit 489cdf0e10cSrcweir // weggelassenen Daten enthalten sind 490cdf0e10cSrcweir 491cdf0e10cSrcweir sal_Bool bDone = sal_False; 492cdf0e10cSrcweir ScDBCollection* pDBColl = aDocument.GetDBCollection(); 493cdf0e10cSrcweir 494cdf0e10cSrcweir if ((nCanUpdate != com::sun::star::document::UpdateDocMode::NO_UPDATE) && 495cdf0e10cSrcweir (nCanUpdate != com::sun::star::document::UpdateDocMode::QUIET_UPDATE)) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir ScRange aRange; 498cdf0e10cSrcweir ScTabViewShell* pViewSh = GetBestViewShell(); 499cdf0e10cSrcweir DBG_ASSERT(pViewSh,"SID_REIMPORT_AFTER_LOAD: keine View"); 500cdf0e10cSrcweir if (pViewSh && pDBColl) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir QueryBox aBox( GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES), 503cdf0e10cSrcweir ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD) ); 504cdf0e10cSrcweir if (aBox.Execute() == RET_YES) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir for (sal_uInt16 i=0; i<pDBColl->GetCount(); i++) 507cdf0e10cSrcweir { 508cdf0e10cSrcweir ScDBData* pDBData = (*pDBColl)[i]; 509cdf0e10cSrcweir if ( pDBData->IsStripData() && 510cdf0e10cSrcweir pDBData->HasImportParam() && !pDBData->HasImportSelection() ) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir pDBData->GetArea(aRange); 513cdf0e10cSrcweir pViewSh->MarkRange(aRange); 514cdf0e10cSrcweir 515cdf0e10cSrcweir // Import und interne Operationen wie SID_REFRESH_DBAREA 516cdf0e10cSrcweir // (Abfrage auf Import hier nicht noetig) 517cdf0e10cSrcweir 518cdf0e10cSrcweir ScImportParam aImportParam; 519cdf0e10cSrcweir pDBData->GetImportParam( aImportParam ); 520cdf0e10cSrcweir sal_Bool bContinue = pViewSh->ImportData( aImportParam ); 521cdf0e10cSrcweir pDBData->SetImportParam( aImportParam ); 522cdf0e10cSrcweir 523cdf0e10cSrcweir // markieren (Groesse kann sich geaendert haben) 524cdf0e10cSrcweir pDBData->GetArea(aRange); 525cdf0e10cSrcweir pViewSh->MarkRange(aRange); 526cdf0e10cSrcweir 527cdf0e10cSrcweir if ( bContinue ) // #41905# Fehler beim Import -> Abbruch 528cdf0e10cSrcweir { 529cdf0e10cSrcweir // interne Operationen, wenn welche gespeichert 530cdf0e10cSrcweir 531cdf0e10cSrcweir if ( pDBData->HasQueryParam() || pDBData->HasSortParam() || 532cdf0e10cSrcweir pDBData->HasSubTotalParam() ) 533cdf0e10cSrcweir pViewSh->RepeatDB(); 534cdf0e10cSrcweir 535cdf0e10cSrcweir // Pivottabellen die den Bereich als Quelldaten haben 536cdf0e10cSrcweir 537cdf0e10cSrcweir RefreshPivotTables(aRange); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir bDone = sal_True; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir } 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir if ( !bDone && pDBColl ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir // wenn nicht, dann aber die abhaengigen Formeln updaten 549cdf0e10cSrcweir //! auch fuer einzelne Bereiche, die nicht aktualisiert werden koennen 550cdf0e10cSrcweir 551cdf0e10cSrcweir aDocument.CalcAll(); //! nur die abhaengigen 552cdf0e10cSrcweir PostDataChanged(); 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir if (bDone) 556cdf0e10cSrcweir rReq.Done(); 557cdf0e10cSrcweir else 558cdf0e10cSrcweir rReq.Ignore(); 559cdf0e10cSrcweir } 560cdf0e10cSrcweir break; 561cdf0e10cSrcweir 562cdf0e10cSrcweir 563cdf0e10cSrcweir case SID_AUTO_STYLE: 564cdf0e10cSrcweir DBG_ERROR("use ScAutoStyleHint instead of SID_AUTO_STYLE"); 565cdf0e10cSrcweir break; 566cdf0e10cSrcweir 567cdf0e10cSrcweir case SID_GET_COLORTABLE: 568cdf0e10cSrcweir { 569cdf0e10cSrcweir // passende ColorTable ist per PutItem gesetzt worden 570cdf0e10cSrcweir SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE); 571cdf0e10cSrcweir XColorTable* pTable = pColItem->GetColorTable(); 572cdf0e10cSrcweir rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable)); 573cdf0e10cSrcweir } 574cdf0e10cSrcweir break; 575cdf0e10cSrcweir 576cdf0e10cSrcweir case FID_CHG_RECORD: 577cdf0e10cSrcweir { 578cdf0e10cSrcweir ScDocument* pDoc = GetDocument(); 579cdf0e10cSrcweir if(pDoc!=NULL) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir // get argument (recorded macro) 582cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FID_CHG_RECORD, sal_False ); 583cdf0e10cSrcweir sal_Bool bDo = sal_True; 584cdf0e10cSrcweir 585cdf0e10cSrcweir // xmlsec05/06: 586cdf0e10cSrcweir // getting real parent window when called from Security-Options TP 587cdf0e10cSrcweir Window* pParent = NULL; 588cdf0e10cSrcweir const SfxPoolItem* pParentItem; 589cdf0e10cSrcweir if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) ) 590cdf0e10cSrcweir pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); 591cdf0e10cSrcweir 592cdf0e10cSrcweir // desired state 593cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 594cdf0e10cSrcweir sal_Bool bActivateTracking = (pChangeTrack == 0); // toggle 595cdf0e10cSrcweir if ( pItem ) 596cdf0e10cSrcweir bActivateTracking = pItem->GetValue(); // from argument 597cdf0e10cSrcweir 598cdf0e10cSrcweir if ( !bActivateTracking ) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir if ( !pItem ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir // no dialog on playing the macro 603cdf0e10cSrcweir WarningBox aBox( pParent ? pParent : GetActiveDialogParent(), 604cdf0e10cSrcweir WinBits(WB_YES_NO | WB_DEF_NO), 605cdf0e10cSrcweir ScGlobal::GetRscString( STR_END_REDLINING ) ); 606cdf0e10cSrcweir bDo = ( aBox.Execute() == RET_YES ); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir 609cdf0e10cSrcweir if ( bDo ) 610cdf0e10cSrcweir { 611cdf0e10cSrcweir if ( pChangeTrack->IsProtected() ) 612cdf0e10cSrcweir bDo = ExecuteChangeProtectionDialog( NULL ); 613cdf0e10cSrcweir if ( bDo ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir pDoc->EndChangeTracking(); 616cdf0e10cSrcweir PostPaintGridAll(); 617cdf0e10cSrcweir } 618cdf0e10cSrcweir } 619cdf0e10cSrcweir } 620cdf0e10cSrcweir else 621cdf0e10cSrcweir { 622cdf0e10cSrcweir pDoc->StartChangeTracking(); 623cdf0e10cSrcweir ScChangeViewSettings aChangeViewSet; 624cdf0e10cSrcweir aChangeViewSet.SetShowChanges(sal_True); 625cdf0e10cSrcweir pDoc->SetChangeViewSettings(aChangeViewSet); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir if ( bDo ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir UpdateAcceptChangesDialog(); 631cdf0e10cSrcweir 632cdf0e10cSrcweir // Slots invalidieren 633cdf0e10cSrcweir if (pBindings) 634cdf0e10cSrcweir pBindings->InvalidateAll(sal_False); 635cdf0e10cSrcweir if ( !pItem ) 636cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FID_CHG_RECORD, bActivateTracking ) ); 637cdf0e10cSrcweir rReq.Done(); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir else 640cdf0e10cSrcweir rReq.Ignore(); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir } 643cdf0e10cSrcweir break; 644cdf0e10cSrcweir 645cdf0e10cSrcweir case SID_CHG_PROTECT : 646cdf0e10cSrcweir { 647cdf0e10cSrcweir Window* pParent = NULL; 648cdf0e10cSrcweir const SfxPoolItem* pParentItem; 649cdf0e10cSrcweir if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) ) 650cdf0e10cSrcweir pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); 651cdf0e10cSrcweir if ( ExecuteChangeProtectionDialog( pParent ) ) 652cdf0e10cSrcweir { 653cdf0e10cSrcweir rReq.Done(); 654cdf0e10cSrcweir SetDocumentModified(); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir else 657cdf0e10cSrcweir rReq.Ignore(); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir break; 660cdf0e10cSrcweir 661cdf0e10cSrcweir case SID_DOCUMENT_MERGE: 662cdf0e10cSrcweir case SID_DOCUMENT_COMPARE: 663cdf0e10cSrcweir { 664cdf0e10cSrcweir sal_Bool bDo = sal_True; 665cdf0e10cSrcweir ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); 666cdf0e10cSrcweir if ( pChangeTrack && !pImpl->bIgnoreLostRedliningWarning ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir if ( nSlot == SID_DOCUMENT_COMPARE ) 669cdf0e10cSrcweir { //! old changes trace will be lost 670cdf0e10cSrcweir WarningBox aBox( GetActiveDialogParent(), 671cdf0e10cSrcweir WinBits(WB_YES_NO | WB_DEF_NO), 672cdf0e10cSrcweir ScGlobal::GetRscString( STR_END_REDLINING ) ); 673cdf0e10cSrcweir if( aBox.Execute() == RET_YES ) 674cdf0e10cSrcweir bDo = ExecuteChangeProtectionDialog( NULL, sal_True ); 675cdf0e10cSrcweir else 676cdf0e10cSrcweir bDo = sal_False; 677cdf0e10cSrcweir } 678cdf0e10cSrcweir else // merge might reject some actions 679cdf0e10cSrcweir bDo = ExecuteChangeProtectionDialog( NULL, sal_True ); 680cdf0e10cSrcweir } 681cdf0e10cSrcweir if ( !bDo ) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir rReq.Ignore(); 684cdf0e10cSrcweir break; 685cdf0e10cSrcweir } 686cdf0e10cSrcweir SfxApplication* pApp = SFX_APP(); 687cdf0e10cSrcweir const SfxPoolItem* pItem; 688cdf0e10cSrcweir SfxMedium* pMed = NULL; 689cdf0e10cSrcweir if ( pReqArgs && 690cdf0e10cSrcweir pReqArgs->GetItemState( SID_FILE_NAME, sal_True, &pItem ) == SFX_ITEM_SET && 691cdf0e10cSrcweir pItem->ISA(SfxStringItem) ) 692cdf0e10cSrcweir { 693cdf0e10cSrcweir String aFileName = ((const SfxStringItem*)pItem)->GetValue(); 694cdf0e10cSrcweir 695cdf0e10cSrcweir String aFilterName; 696cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_FILTER_NAME, sal_True, &pItem ) == SFX_ITEM_SET && 697cdf0e10cSrcweir pItem->ISA(SfxStringItem) ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir aFilterName = ((const SfxStringItem*)pItem)->GetValue(); 700cdf0e10cSrcweir } 701cdf0e10cSrcweir String aOptions; 702cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_FILE_FILTEROPTIONS, sal_True, &pItem ) == SFX_ITEM_SET && 703cdf0e10cSrcweir pItem->ISA(SfxStringItem) ) 704cdf0e10cSrcweir { 705cdf0e10cSrcweir aOptions = ((const SfxStringItem*)pItem)->GetValue(); 706cdf0e10cSrcweir } 707cdf0e10cSrcweir short nVersion = 0; 708cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_VERSION, sal_True, &pItem ) == SFX_ITEM_SET && 709cdf0e10cSrcweir pItem->ISA(SfxInt16Item) ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir nVersion = ((const SfxInt16Item*)pItem)->GetValue(); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir 714cdf0e10cSrcweir // kein Filter angegeben -> Detection 715cdf0e10cSrcweir if ( !aFilterName.Len() ) 716cdf0e10cSrcweir ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, sal_True, sal_False ); 717cdf0e10cSrcweir 718cdf0e10cSrcweir // filter name from dialog contains application prefix, 719cdf0e10cSrcweir // GetFilter needs name without the prefix. 720cdf0e10cSrcweir ScDocumentLoader::RemoveAppPrefix( aFilterName ); 721cdf0e10cSrcweir 722cdf0e10cSrcweir const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName ); 723cdf0e10cSrcweir SfxItemSet* pSet = new SfxAllItemSet( pApp->GetPool() ); 724cdf0e10cSrcweir if ( aOptions.Len() ) 725cdf0e10cSrcweir pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) ); 726cdf0e10cSrcweir if ( nVersion != 0 ) 727cdf0e10cSrcweir pSet->Put( SfxInt16Item( SID_VERSION, nVersion ) ); 728cdf0e10cSrcweir pMed = new SfxMedium( aFileName, STREAM_STD_READ, sal_False, pFilter, pSet ); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir else 731cdf0e10cSrcweir { 732cdf0e10cSrcweir // start file dialog asynchronous 733cdf0e10cSrcweir pImpl->bIgnoreLostRedliningWarning = true; 734cdf0e10cSrcweir delete pImpl->pRequest; 735cdf0e10cSrcweir pImpl->pRequest = new SfxRequest( rReq ); 736cdf0e10cSrcweir delete pImpl->pDocInserter; 737cdf0e10cSrcweir pImpl->pDocInserter = new ::sfx2::DocumentInserter( 738cdf0e10cSrcweir 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ), 0 ); 739cdf0e10cSrcweir pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) ); 740cdf0e10cSrcweir return ; 741cdf0e10cSrcweir } 742cdf0e10cSrcweir 743cdf0e10cSrcweir if ( pMed ) // nun wirklich ausfuehren... 744cdf0e10cSrcweir { 745cdf0e10cSrcweir SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() ); 746cdf0e10cSrcweir 747cdf0e10cSrcweir // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here 748cdf0e10cSrcweir ScDocShell* pOtherDocSh = new ScDocShell; 749cdf0e10cSrcweir SfxObjectShellLock aDocShTablesRef = pOtherDocSh; 750cdf0e10cSrcweir pOtherDocSh->DoLoad( pMed ); 751cdf0e10cSrcweir sal_uLong nErr = pOtherDocSh->GetErrorCode(); 752cdf0e10cSrcweir if (nErr) 753cdf0e10cSrcweir ErrorHandler::HandleError( nErr ); // auch Warnings 754cdf0e10cSrcweir 755cdf0e10cSrcweir if ( !pOtherDocSh->GetError() ) // nur Errors 756cdf0e10cSrcweir { 757cdf0e10cSrcweir sal_Bool bHadTrack = ( aDocument.GetChangeTrack() != NULL ); 758cdf0e10cSrcweir sal_uLong nStart = 0; 759cdf0e10cSrcweir if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack ) 760cdf0e10cSrcweir { 761cdf0e10cSrcweir nStart = pChangeTrack->GetActionMax() + 1; 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir if ( nSlot == SID_DOCUMENT_COMPARE ) 765cdf0e10cSrcweir CompareDocument( *pOtherDocSh->GetDocument() ); 766cdf0e10cSrcweir else 767cdf0e10cSrcweir MergeDocument( *pOtherDocSh->GetDocument() ); 768cdf0e10cSrcweir 769cdf0e10cSrcweir // show "accept changes" dialog 770cdf0e10cSrcweir //! get view for this document! 771cdf0e10cSrcweir if ( !IsDocShared() ) 772cdf0e10cSrcweir { 773cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 774cdf0e10cSrcweir if ( pViewFrm ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId(), sal_True ); //@51669 777cdf0e10cSrcweir } 778cdf0e10cSrcweir if ( pBindings ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir pBindings->Invalidate( FID_CHG_ACCEPT ); 781cdf0e10cSrcweir } 782cdf0e10cSrcweir } 783cdf0e10cSrcweir 784cdf0e10cSrcweir rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) ); //! ??????? 785cdf0e10cSrcweir rReq.Done(); 786cdf0e10cSrcweir 787cdf0e10cSrcweir if (!bHadTrack) // neu eingeschaltet -> auch anzeigen 788cdf0e10cSrcweir { 789cdf0e10cSrcweir ScChangeViewSettings* pOldSet = aDocument.GetChangeViewSettings(); 790cdf0e10cSrcweir if ( !pOldSet || !pOldSet->ShowChanges() ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir ScChangeViewSettings aChangeViewSet; 793cdf0e10cSrcweir aChangeViewSet.SetShowChanges(sal_True); 794cdf0e10cSrcweir aDocument.SetChangeViewSettings(aChangeViewSet); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir } 797cdf0e10cSrcweir else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir sal_uLong nEnd = pChangeTrack->GetActionMax(); 800cdf0e10cSrcweir if ( nEnd >= nStart ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir // only show changes from merged document 803cdf0e10cSrcweir ScChangeViewSettings aChangeViewSet; 804cdf0e10cSrcweir aChangeViewSet.SetShowChanges( sal_True ); 805cdf0e10cSrcweir aChangeViewSet.SetShowAccepted( sal_True ); 806cdf0e10cSrcweir aChangeViewSet.SetHasActionRange( true ); 807cdf0e10cSrcweir aChangeViewSet.SetTheActionRange( nStart, nEnd ); 808cdf0e10cSrcweir aDocument.SetChangeViewSettings( aChangeViewSet ); 809cdf0e10cSrcweir 810cdf0e10cSrcweir // update view 811cdf0e10cSrcweir PostPaintExtras(); 812cdf0e10cSrcweir PostPaintGridAll(); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir } 815cdf0e10cSrcweir } 816cdf0e10cSrcweir pOtherDocSh->DoClose(); // delete passiert mit der Ref 817cdf0e10cSrcweir } 818cdf0e10cSrcweir } 819cdf0e10cSrcweir break; 820cdf0e10cSrcweir 821cdf0e10cSrcweir case SID_DELETE_SCENARIO: 822cdf0e10cSrcweir if (pReqArgs) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir const SfxPoolItem* pItem; 825cdf0e10cSrcweir if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir if ( pItem->ISA(SfxStringItem) ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir String aName = ((const SfxStringItem*)pItem)->GetValue(); 830cdf0e10cSrcweir SCTAB nTab; 831cdf0e10cSrcweir if (aDocument.GetTable( aName, nTab )) 832cdf0e10cSrcweir { 833cdf0e10cSrcweir // DeleteTable von viewfunc nach docfunc verschieben! 834cdf0e10cSrcweir 835cdf0e10cSrcweir ScTabViewShell* pSh = GetBestViewShell(); 836cdf0e10cSrcweir if ( pSh ) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir //! SetTabNo in DeleteTable weglassen? 839cdf0e10cSrcweir SCTAB nDispTab = pSh->GetViewData()->GetTabNo(); 840cdf0e10cSrcweir pSh->DeleteTable( nTab ); 841cdf0e10cSrcweir pSh->SetTabNo(nDispTab); 842cdf0e10cSrcweir rReq.Done(); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir } 845cdf0e10cSrcweir } 846cdf0e10cSrcweir } 847cdf0e10cSrcweir } 848cdf0e10cSrcweir break; 849cdf0e10cSrcweir 850cdf0e10cSrcweir case SID_EDIT_SCENARIO: 851cdf0e10cSrcweir { 852cdf0e10cSrcweir const SfxPoolItem* pItem; 853cdf0e10cSrcweir if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 854cdf0e10cSrcweir { 855cdf0e10cSrcweir if ( pItem->ISA(SfxStringItem) ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir String aName = ((const SfxStringItem*)pItem)->GetValue(); 858cdf0e10cSrcweir SCTAB nTab; 859cdf0e10cSrcweir if (aDocument.GetTable( aName, nTab )) 860cdf0e10cSrcweir { 861cdf0e10cSrcweir if (aDocument.IsScenario(nTab)) 862cdf0e10cSrcweir { 863cdf0e10cSrcweir String aComment; 864cdf0e10cSrcweir Color aColor; 865cdf0e10cSrcweir sal_uInt16 nFlags; 866cdf0e10cSrcweir aDocument.GetScenarioData( nTab, aComment, aColor, nFlags ); 867cdf0e10cSrcweir 868cdf0e10cSrcweir // Determine if the Sheet that the Scenario was created on 869cdf0e10cSrcweir // is protected. But first we need to find that Sheet. 870cdf0e10cSrcweir // Rewind back to the actual sheet. 871cdf0e10cSrcweir SCTAB nActualTab = nTab; 872cdf0e10cSrcweir do 873cdf0e10cSrcweir { 874cdf0e10cSrcweir nActualTab--; 875cdf0e10cSrcweir } 876cdf0e10cSrcweir while(aDocument.IsScenario(nActualTab)); 877cdf0e10cSrcweir sal_Bool bSheetProtected = aDocument.IsTabProtected(nActualTab); 878cdf0e10cSrcweir 879cdf0e10cSrcweir //! anderen Titel am Dialog setzen 880cdf0e10cSrcweir //CHINA001 ScNewScenarioDlg* pNewDlg = 881cdf0e10cSrcweir //CHINA001 new ScNewScenarioDlg( GetActiveDialogParent(), aName, sal_True, bSheetProtected); 882cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 883cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 884cdf0e10cSrcweir 885cdf0e10cSrcweir AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( GetActiveDialogParent(), aName, RID_SCDLG_NEWSCENARIO, sal_True,bSheetProtected); 886cdf0e10cSrcweir DBG_ASSERT(pNewDlg, "Dialog create fail!");//CHINA001 887cdf0e10cSrcweir pNewDlg->SetScenarioData( aName, aComment, aColor, nFlags ); 888cdf0e10cSrcweir if ( pNewDlg->Execute() == RET_OK ) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags ); 891cdf0e10cSrcweir ModifyScenario( nTab, aName, aComment, aColor, nFlags ); 892cdf0e10cSrcweir rReq.Done(); 893cdf0e10cSrcweir } 894cdf0e10cSrcweir delete pNewDlg; 895cdf0e10cSrcweir } 896cdf0e10cSrcweir } 897cdf0e10cSrcweir } 898cdf0e10cSrcweir } 899cdf0e10cSrcweir } 900cdf0e10cSrcweir break; 901cdf0e10cSrcweir 902cdf0e10cSrcweir case SID_ATTR_YEAR2000 : 903cdf0e10cSrcweir { 904cdf0e10cSrcweir const SfxPoolItem* pItem; 905cdf0e10cSrcweir if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 906cdf0e10cSrcweir { 907cdf0e10cSrcweir if ( pItem->ISA(SfxUInt16Item) ) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir sal_uInt16 nY2k = ((SfxUInt16Item*)pItem)->GetValue(); 910cdf0e10cSrcweir // immer an den DocOptions setzen, damit das auch fuer SO50 911cdf0e10cSrcweir // gespeichert wird (und alle Abfragen bisher auch darauf laufen). 912cdf0e10cSrcweir // SetDocOptions propagiert das an den NumberFormatter 913cdf0e10cSrcweir ScDocOptions aDocOpt( aDocument.GetDocOptions() ); 914cdf0e10cSrcweir aDocOpt.SetYear2000( nY2k ); 915cdf0e10cSrcweir aDocument.SetDocOptions( aDocOpt ); 916cdf0e10cSrcweir // die FormShell soll es mitbekommen 917cdf0e10cSrcweir ScTabViewShell* pSh = GetBestViewShell(); 918cdf0e10cSrcweir if ( pSh ) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir FmFormShell* pFSh = pSh->GetFormShell(); 921cdf0e10cSrcweir if ( pFSh ) 922cdf0e10cSrcweir pFSh->SetY2KState( nY2k ); 923cdf0e10cSrcweir } 924cdf0e10cSrcweir } 925cdf0e10cSrcweir } 926cdf0e10cSrcweir } 927cdf0e10cSrcweir break; 928cdf0e10cSrcweir 929cdf0e10cSrcweir case SID_SHARE_DOC: 930cdf0e10cSrcweir { 931cdf0e10cSrcweir ScViewData* pViewData = GetViewData(); 932cdf0e10cSrcweir if ( !pViewData ) 933cdf0e10cSrcweir { 934cdf0e10cSrcweir rReq.Ignore(); 935cdf0e10cSrcweir break; 936cdf0e10cSrcweir } 937cdf0e10cSrcweir 938cdf0e10cSrcweir ScShareDocumentDlg aDlg( GetActiveDialogParent(), pViewData ); 939cdf0e10cSrcweir if ( aDlg.Execute() == RET_OK ) 940cdf0e10cSrcweir { 941cdf0e10cSrcweir bool bSetShared = aDlg.IsShareDocumentChecked(); 942cdf0e10cSrcweir if ( bSetShared != static_cast< bool >( IsDocShared() ) ) 943cdf0e10cSrcweir { 944cdf0e10cSrcweir if ( bSetShared ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir bool bContinue = true; 947cdf0e10cSrcweir if ( HasName() ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir QueryBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ), 950cdf0e10cSrcweir ScGlobal::GetRscString( STR_DOC_WILLBESAVED ) ); 951cdf0e10cSrcweir if ( aBox.Execute() == RET_NO ) 952cdf0e10cSrcweir { 953cdf0e10cSrcweir bContinue = false; 954cdf0e10cSrcweir } 955cdf0e10cSrcweir } 956cdf0e10cSrcweir if ( bContinue ) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir EnableSharedSettings( true ); 959cdf0e10cSrcweir 960cdf0e10cSrcweir SC_MOD()->SetInSharedDocSaving( true ); 961cdf0e10cSrcweir if ( !SwitchToShared( sal_True, sal_True ) ) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir // TODO/LATER: what should be done in case the switch has failed? 964cdf0e10cSrcweir // for example in case the user has cancelled the saveAs operation 965cdf0e10cSrcweir } 966cdf0e10cSrcweir 967cdf0e10cSrcweir SC_MOD()->SetInSharedDocSaving( false ); 968cdf0e10cSrcweir 969cdf0e10cSrcweir InvalidateName(); 970cdf0e10cSrcweir GetUndoManager()->Clear(); 971cdf0e10cSrcweir 972cdf0e10cSrcweir ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() ); 973cdf0e10cSrcweir if ( pTabView ) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir pTabView->UpdateLayerLocks(); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir } 978cdf0e10cSrcweir } 979cdf0e10cSrcweir else 980cdf0e10cSrcweir { 981cdf0e10cSrcweir uno::Reference< frame::XModel > xModel; 982cdf0e10cSrcweir try 983cdf0e10cSrcweir { 984cdf0e10cSrcweir // load shared file 985cdf0e10cSrcweir xModel.set( LoadSharedDocument(), uno::UNO_QUERY_THROW ); 986cdf0e10cSrcweir uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW ); 987cdf0e10cSrcweir 988cdf0e10cSrcweir // check if shared flag is set in shared file 989cdf0e10cSrcweir bool bShared = false; 990cdf0e10cSrcweir ScModelObj* pDocObj = ScModelObj::getImplementation( xModel ); 991cdf0e10cSrcweir if ( pDocObj ) 992cdf0e10cSrcweir { 993cdf0e10cSrcweir ScDocShell* pDocShell = dynamic_cast< ScDocShell* >( pDocObj->GetEmbeddedObject() ); 994cdf0e10cSrcweir if ( pDocShell ) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir bShared = pDocShell->HasSharedXMLFlagSet(); 997cdf0e10cSrcweir } 998cdf0e10cSrcweir } 999cdf0e10cSrcweir 1000cdf0e10cSrcweir // #i87870# check if shared status was disabled and enabled again 1001cdf0e10cSrcweir bool bOwnEntry = false; 1002cdf0e10cSrcweir try 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir ::svt::ShareControlFile aControlFile( GetSharedFileURL() ); 1005cdf0e10cSrcweir bOwnEntry = aControlFile.HasOwnEntry(); 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir catch ( uno::Exception& ) 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir if ( bShared && bOwnEntry ) 1012cdf0e10cSrcweir { 1013cdf0e10cSrcweir uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW ); 1014cdf0e10cSrcweir if ( xStorable->isReadonly() ) 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir xCloseable->close( sal_True ); 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir String aUserName( ScGlobal::GetRscString( STR_UNKNOWN_USER ) ); 1019cdf0e10cSrcweir try 1020cdf0e10cSrcweir { 1021cdf0e10cSrcweir ::svt::DocumentLockFile aLockFile( GetSharedFileURL() ); 1022cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aData = aLockFile.GetLockData(); 1023cdf0e10cSrcweir if ( aData.getLength() > LOCKFILE_SYSUSERNAME_ID ) 1024cdf0e10cSrcweir { 1025cdf0e10cSrcweir if ( aData[LOCKFILE_OOOUSERNAME_ID].getLength() > 0 ) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir aUserName = aData[LOCKFILE_OOOUSERNAME_ID]; 1028cdf0e10cSrcweir } 1029cdf0e10cSrcweir else if ( aData[LOCKFILE_SYSUSERNAME_ID].getLength() > 0 ) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir aUserName = aData[LOCKFILE_SYSUSERNAME_ID]; 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir } 1035cdf0e10cSrcweir catch ( uno::Exception& ) 1036cdf0e10cSrcweir { 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir String aMessage( ScGlobal::GetRscString( STR_FILE_LOCKED_TRY_LATER ) ); 1039cdf0e10cSrcweir aMessage.SearchAndReplaceAscii( "%1", aUserName ); 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ), aMessage ); 1042cdf0e10cSrcweir aBox.Execute(); 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir else 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir WarningBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ), 1047cdf0e10cSrcweir ScGlobal::GetRscString( STR_DOC_DISABLESHARED ) ); 1048cdf0e10cSrcweir if ( aBox.Execute() == RET_YES ) 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir xCloseable->close( sal_True ); 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir if ( !SwitchToShared( sal_False, sal_True ) ) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir // TODO/LATER: what should be done in case the switch has failed? 1055cdf0e10cSrcweir // for example in case the user has cancelled the saveAs operation 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir EnableSharedSettings( false ); 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir if ( pBindings ) 1061cdf0e10cSrcweir { 1062cdf0e10cSrcweir pBindings->ExecuteSynchron( SID_SAVEDOC ); 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() ); 1066cdf0e10cSrcweir if ( pTabView ) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir pTabView->UpdateLayerLocks(); 1069cdf0e10cSrcweir } 1070cdf0e10cSrcweir } 1071cdf0e10cSrcweir else 1072cdf0e10cSrcweir { 1073cdf0e10cSrcweir xCloseable->close( sal_True ); 1074cdf0e10cSrcweir } 1075cdf0e10cSrcweir } 1076cdf0e10cSrcweir } 1077cdf0e10cSrcweir else 1078cdf0e10cSrcweir { 1079cdf0e10cSrcweir xCloseable->close( sal_True ); 1080cdf0e10cSrcweir WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ), 1081cdf0e10cSrcweir ScGlobal::GetRscString( STR_DOC_NOLONGERSHARED ) ); 1082cdf0e10cSrcweir aBox.Execute(); 1083cdf0e10cSrcweir } 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir catch ( uno::Exception& ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir DBG_ERROR( "SID_SHARE_DOC: caught exception\n" ); 1088cdf0e10cSrcweir SC_MOD()->SetInSharedDocSaving( false ); 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir try 1091cdf0e10cSrcweir { 1092cdf0e10cSrcweir uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW ); 1093cdf0e10cSrcweir xClose->close( sal_True ); 1094cdf0e10cSrcweir } 1095cdf0e10cSrcweir catch ( uno::Exception& ) 1096cdf0e10cSrcweir { 1097cdf0e10cSrcweir } 1098cdf0e10cSrcweir } 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir } 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir rReq.Done(); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir break; 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir default: 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir // kleiner (?) Hack -> forward der Slots an TabViewShell 1109cdf0e10cSrcweir ScTabViewShell* pSh = GetBestViewShell(); 1110cdf0e10cSrcweir if ( pSh ) 1111cdf0e10cSrcweir pSh->Execute( rReq ); 1112cdf0e10cSrcweir else 1113cdf0e10cSrcweir SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT ); 1114cdf0e10cSrcweir } 1115cdf0e10cSrcweir } 1116cdf0e10cSrcweir } 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir 1119cdf0e10cSrcweir //------------------------------------------------------------------ 1120cdf0e10cSrcweir 1121cdf0e10cSrcweir void UpdateAcceptChangesDialog() 1122cdf0e10cSrcweir { 1123cdf0e10cSrcweir // update "accept changes" dialog 1124cdf0e10cSrcweir //! notify all views 1125cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 1126cdf0e10cSrcweir if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) ) 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT ); 1129cdf0e10cSrcweir if ( pChild ) 1130cdf0e10cSrcweir ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg(); 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir } 1133cdf0e10cSrcweir 1134cdf0e10cSrcweir //------------------------------------------------------------------ 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir sal_Bool ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, sal_Bool bJustQueryIfProtected ) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir sal_Bool bDone = sal_False; 1139cdf0e10cSrcweir ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); 1140cdf0e10cSrcweir if ( pChangeTrack ) 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir sal_Bool bProtected = pChangeTrack->IsProtected(); 1143cdf0e10cSrcweir if ( bJustQueryIfProtected && !bProtected ) 1144cdf0e10cSrcweir return sal_True; 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir String aTitle( ScResId( bProtected ? SCSTR_CHG_UNPROTECT : SCSTR_CHG_PROTECT ) ); 1147cdf0e10cSrcweir String aText( ScResId( SCSTR_PASSWORD ) ); 1148cdf0e10cSrcweir String aPassword; 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir SfxPasswordDialog* pDlg = new SfxPasswordDialog( 1151cdf0e10cSrcweir _pParent ? _pParent : GetActiveDialogParent(), &aText ); 1152cdf0e10cSrcweir pDlg->SetText( aTitle ); 1153cdf0e10cSrcweir pDlg->SetMinLen( 1 ); 1154cdf0e10cSrcweir pDlg->SetHelpId( GetStaticInterface()->GetSlot(SID_CHG_PROTECT)->GetCommand() ); 1155cdf0e10cSrcweir pDlg->SetEditHelpId( HID_CHG_PROTECT ); 1156cdf0e10cSrcweir if ( !bProtected ) 1157cdf0e10cSrcweir pDlg->ShowExtras( SHOWEXTRAS_CONFIRM ); 1158cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 1159cdf0e10cSrcweir aPassword = pDlg->GetPassword(); 1160cdf0e10cSrcweir delete pDlg; 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir if ( aPassword.Len() ) 1163cdf0e10cSrcweir { 1164cdf0e10cSrcweir if ( bProtected ) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir if ( SvPasswordHelper::CompareHashPassword(pChangeTrack->GetProtection(), aPassword) ) 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir if ( bJustQueryIfProtected ) 1169cdf0e10cSrcweir bDone = sal_True; 1170cdf0e10cSrcweir else 1171cdf0e10cSrcweir pChangeTrack->SetProtection( 1172cdf0e10cSrcweir com::sun::star::uno::Sequence< sal_Int8 > (0) ); 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir else 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir InfoBox aBox( GetActiveDialogParent(), 1177cdf0e10cSrcweir String( ScResId( SCSTR_WRONGPASSWORD ) ) ); 1178cdf0e10cSrcweir aBox.Execute(); 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir else 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir com::sun::star::uno::Sequence< sal_Int8 > aPass; 1184cdf0e10cSrcweir SvPasswordHelper::GetHashPassword( aPass, aPassword ); 1185cdf0e10cSrcweir pChangeTrack->SetProtection( aPass ); 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir if ( bProtected != pChangeTrack->IsProtected() ) 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir UpdateAcceptChangesDialog(); 1190cdf0e10cSrcweir bDone = sal_True; 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir } 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir else if ( bJustQueryIfProtected ) 1195cdf0e10cSrcweir bDone = sal_True; 1196cdf0e10cSrcweir return bDone; 1197cdf0e10cSrcweir } 1198cdf0e10cSrcweir 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir //------------------------------------------------------------------ 1201cdf0e10cSrcweir 1202cdf0e10cSrcweir void ScDocShell::DoRecalc( sal_Bool bApi ) 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir sal_Bool bDone = sal_False; 1205cdf0e10cSrcweir ScTabViewShell* pSh = GetBestViewShell(); 1206cdf0e10cSrcweir if ( pSh ) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl(pSh); 1209cdf0e10cSrcweir if ( pHdl && pHdl->IsInputMode() && pHdl->IsFormulaMode() && !bApi ) 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir pHdl->FormulaPreview(); // Teilergebnis als QuickHelp 1212cdf0e10cSrcweir bDone = sal_True; 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir else 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir pSh->UpdateInputLine(); // InputEnterHandler 1217cdf0e10cSrcweir pSh->UpdateInputHandler(); 1218cdf0e10cSrcweir } 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir if (!bDone) // sonst Dokument neu berechnen 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir WaitObject aWaitObj( GetActiveDialogParent() ); 1223cdf0e10cSrcweir aDocument.CalcFormulaTree(); 1224cdf0e10cSrcweir if ( pSh ) 1225cdf0e10cSrcweir pSh->UpdateCharts(sal_True); 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 1228cdf0e10cSrcweir 1229cdf0e10cSrcweir // #47939# Wenn es Charts gibt, dann alles painten, damit nicht 1230cdf0e10cSrcweir // PostDataChanged und die Charts nacheinander kommen und Teile 1231cdf0e10cSrcweir // doppelt gepainted werden. 1232cdf0e10cSrcweir 1233cdf0e10cSrcweir ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection(); 1234cdf0e10cSrcweir if ( pCharts && pCharts->GetCount() ) 1235cdf0e10cSrcweir PostPaintGridAll(); 1236cdf0e10cSrcweir else 1237cdf0e10cSrcweir PostDataChanged(); 1238cdf0e10cSrcweir } 1239cdf0e10cSrcweir } 1240cdf0e10cSrcweir 1241cdf0e10cSrcweir void ScDocShell::DoHardRecalc( sal_Bool /* bApi */ ) 1242cdf0e10cSrcweir { 1243cdf0e10cSrcweir WaitObject aWaitObj( GetActiveDialogParent() ); 1244cdf0e10cSrcweir ScTabViewShell* pSh = GetBestViewShell(); 1245cdf0e10cSrcweir if ( pSh ) 1246cdf0e10cSrcweir { 1247cdf0e10cSrcweir pSh->UpdateInputLine(); // InputEnterHandler 1248cdf0e10cSrcweir pSh->UpdateInputHandler(); 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir aDocument.CalcAll(); 1251cdf0e10cSrcweir GetDocFunc().DetectiveRefresh(); // erzeugt eigenes Undo 1252cdf0e10cSrcweir if ( pSh ) 1253cdf0e10cSrcweir pSh->UpdateCharts(sal_True); 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir // set notification flags for "calculate" event (used in SFX_HINT_DATACHANGED broadcast) 1256cdf0e10cSrcweir // (might check for the presence of any formulas on each sheet) 1257cdf0e10cSrcweir SCTAB nTabCount = aDocument.GetTableCount(); 1258cdf0e10cSrcweir SCTAB nTab; 1259cdf0e10cSrcweir if (aDocument.HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true )) // search also for VBA hendler 1260cdf0e10cSrcweir for (nTab=0; nTab<nTabCount; nTab++) 1261cdf0e10cSrcweir aDocument.SetCalcNotification(nTab); 1262cdf0e10cSrcweir 1263cdf0e10cSrcweir // CalcAll doesn't broadcast value changes, so SC_HINT_CALCALL is broadcasted globally 1264cdf0e10cSrcweir // in addition to SFX_HINT_DATACHANGED. 1265cdf0e10cSrcweir aDocument.BroadcastUno( SfxSimpleHint( SC_HINT_CALCALL ) ); 1266cdf0e10cSrcweir aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir // use hard recalc also to disable stream-copying of all sheets 1269cdf0e10cSrcweir // (somewhat consistent with charts) 1270cdf0e10cSrcweir for (nTab=0; nTab<nTabCount; nTab++) 1271cdf0e10cSrcweir if (aDocument.IsStreamValid(nTab)) 1272cdf0e10cSrcweir aDocument.SetStreamValid(nTab, sal_False); 1273cdf0e10cSrcweir 1274cdf0e10cSrcweir PostPaintGridAll(); 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir //------------------------------------------------------------------ 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir void ScDocShell::DoAutoStyle( const ScRange& rRange, const String& rStyle ) 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1282cdf0e10cSrcweir ScStyleSheet* pStyleSheet = 1283cdf0e10cSrcweir pStylePool->FindCaseIns( rStyle, SFX_STYLE_FAMILY_PARA ); 1284cdf0e10cSrcweir if (!pStyleSheet) 1285cdf0e10cSrcweir pStyleSheet = (ScStyleSheet*) 1286cdf0e10cSrcweir pStylePool->Find( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ); 1287cdf0e10cSrcweir if (pStyleSheet) 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir DBG_ASSERT(rRange.aStart.Tab() == rRange.aEnd.Tab(), 1290cdf0e10cSrcweir "DoAutoStyle mit mehreren Tabellen"); 1291cdf0e10cSrcweir SCTAB nTab = rRange.aStart.Tab(); 1292cdf0e10cSrcweir SCCOL nStartCol = rRange.aStart.Col(); 1293cdf0e10cSrcweir SCROW nStartRow = rRange.aStart.Row(); 1294cdf0e10cSrcweir SCCOL nEndCol = rRange.aEnd.Col(); 1295cdf0e10cSrcweir SCROW nEndRow = rRange.aEnd.Row(); 1296cdf0e10cSrcweir aDocument.ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet ); 1297cdf0e10cSrcweir aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab ); 1298cdf0e10cSrcweir PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PAINT_GRID ); 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir //------------------------------------------------------------------ 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir sal_uInt16 nId = rHint.GetHint(); 1307cdf0e10cSrcweir const SfxStyleSheetBase* pStyle = rHint.GetStyleSheet(); 1308cdf0e10cSrcweir if (!pStyle) 1309cdf0e10cSrcweir return; 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir if ( pStyle->GetFamily() == SFX_STYLE_FAMILY_PAGE ) 1312cdf0e10cSrcweir { 1313cdf0e10cSrcweir if ( nId == SFX_STYLESHEET_MODIFIED ) 1314cdf0e10cSrcweir { 1315cdf0e10cSrcweir ScDocShellModificator aModificator( *this ); 1316cdf0e10cSrcweir 1317cdf0e10cSrcweir String aNewName = pStyle->GetName(); 1318cdf0e10cSrcweir String aOldName = aNewName; 1319cdf0e10cSrcweir sal_Bool bExtended = rHint.ISA(SfxStyleSheetHintExtended); // Name geaendert? 1320cdf0e10cSrcweir if (bExtended) 1321cdf0e10cSrcweir aOldName = ((SfxStyleSheetHintExtended&)rHint).GetOldName(); 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir if ( aNewName != aOldName ) 1324cdf0e10cSrcweir aDocument.RenamePageStyleInUse( aOldName, aNewName ); 1325cdf0e10cSrcweir 1326cdf0e10cSrcweir SCTAB nTabCount = aDocument.GetTableCount(); 1327cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount; nTab++) 1328cdf0e10cSrcweir if (aDocument.GetPageStyle(nTab) == aNewName) // schon auf neu angepasst 1329cdf0e10cSrcweir { 1330cdf0e10cSrcweir aDocument.PageStyleModified( nTab, aNewName ); 1331cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, GetPrinter(), nTab ); 1332cdf0e10cSrcweir aPrintFunc.UpdatePages(); 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir aModificator.SetDocumentModified(); 1336cdf0e10cSrcweir 1337cdf0e10cSrcweir if (bExtended) 1338cdf0e10cSrcweir { 1339cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 1340cdf0e10cSrcweir if (pBindings) 1341cdf0e10cSrcweir { 1342cdf0e10cSrcweir pBindings->Invalidate( SID_STATUS_PAGESTYLE ); 1343cdf0e10cSrcweir pBindings->Invalidate( SID_STYLE_FAMILY4 ); 1344cdf0e10cSrcweir pBindings->Invalidate( FID_RESET_PRINTZOOM ); 1345cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT ); 1346cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT ); 1347cdf0e10cSrcweir } 1348cdf0e10cSrcweir } 1349cdf0e10cSrcweir } 1350cdf0e10cSrcweir } 1351cdf0e10cSrcweir else if ( pStyle->GetFamily() == SFX_STYLE_FAMILY_PARA ) 1352cdf0e10cSrcweir { 1353cdf0e10cSrcweir if ( nId == SFX_STYLESHEET_MODIFIED) 1354cdf0e10cSrcweir { 1355cdf0e10cSrcweir String aNewName = pStyle->GetName(); 1356cdf0e10cSrcweir String aOldName = aNewName; 1357cdf0e10cSrcweir sal_Bool bExtended = rHint.ISA(SfxStyleSheetHintExtended); 1358cdf0e10cSrcweir if (bExtended) 1359cdf0e10cSrcweir aOldName = ((SfxStyleSheetHintExtended&)rHint).GetOldName(); 1360cdf0e10cSrcweir if ( aNewName != aOldName ) 1361cdf0e10cSrcweir { 1362cdf0e10cSrcweir ScConditionalFormatList* pList = aDocument.GetCondFormList(); 1363cdf0e10cSrcweir if (pList) 1364cdf0e10cSrcweir pList->RenameCellStyle( aOldName,aNewName ); 1365cdf0e10cSrcweir } 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir 1369cdf0e10cSrcweir // alles andere geht ueber Slots... 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir 1372cdf0e10cSrcweir // wie in printfun.cxx 1373cdf0e10cSrcweir #define ZOOM_MIN 10 1374cdf0e10cSrcweir 1375cdf0e10cSrcweir void ScDocShell::SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages ) 1376cdf0e10cSrcweir { 1377cdf0e10cSrcweir sal_Bool bUndo(aDocument.IsUndoEnabled()); 1378cdf0e10cSrcweir String aStyleName = aDocument.GetPageStyle( nTab ); 1379cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1380cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE ); 1381cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found" ); 1382cdf0e10cSrcweir if ( pStyleSheet ) 1383cdf0e10cSrcweir { 1384cdf0e10cSrcweir ScDocShellModificator aModificator( *this ); 1385cdf0e10cSrcweir 1386cdf0e10cSrcweir SfxItemSet& rSet = pStyleSheet->GetItemSet(); 1387cdf0e10cSrcweir if (bUndo) 1388cdf0e10cSrcweir { 1389cdf0e10cSrcweir sal_uInt16 nOldScale = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALE)).GetValue(); 1390cdf0e10cSrcweir sal_uInt16 nOldPages = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue(); 1391cdf0e10cSrcweir GetUndoManager()->AddUndoAction( new ScUndoPrintZoom( 1392cdf0e10cSrcweir this, nTab, nOldScale, nOldPages, nScale, nPages ) ); 1393cdf0e10cSrcweir } 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) ); 1396cdf0e10cSrcweir rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) ); 1397cdf0e10cSrcweir 1398cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, GetPrinter(), nTab ); 1399cdf0e10cSrcweir aPrintFunc.UpdatePages(); 1400cdf0e10cSrcweir aModificator.SetDocumentModified(); 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 1403cdf0e10cSrcweir if (pBindings) 1404cdf0e10cSrcweir pBindings->Invalidate( FID_RESET_PRINTZOOM ); 1405cdf0e10cSrcweir } 1406cdf0e10cSrcweir } 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir sal_Bool ScDocShell::AdjustPrintZoom( const ScRange& rRange ) 1409cdf0e10cSrcweir { 1410cdf0e10cSrcweir sal_Bool bChange = sal_False; 1411cdf0e10cSrcweir SCTAB nTab = rRange.aStart.Tab(); 1412cdf0e10cSrcweir 1413cdf0e10cSrcweir String aStyleName = aDocument.GetPageStyle( nTab ); 1414cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1415cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE ); 1416cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found" ); 1417cdf0e10cSrcweir if ( pStyleSheet ) 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir SfxItemSet& rSet = pStyleSheet->GetItemSet(); 1420cdf0e10cSrcweir sal_Bool bHeaders = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_HEADERS)).GetValue(); 1421cdf0e10cSrcweir sal_uInt16 nOldScale = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALE)).GetValue(); 1422cdf0e10cSrcweir sal_uInt16 nOldPages = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue(); 1423cdf0e10cSrcweir const ScRange* pRepeatCol = aDocument.GetRepeatColRange( nTab ); 1424cdf0e10cSrcweir const ScRange* pRepeatRow = aDocument.GetRepeatRowRange( nTab ); 1425cdf0e10cSrcweir 1426cdf0e10cSrcweir // benoetigte Skalierung fuer Selektion ausrechnen 1427cdf0e10cSrcweir 1428cdf0e10cSrcweir sal_uInt16 nNewScale = nOldScale; 1429cdf0e10cSrcweir 1430cdf0e10cSrcweir long nBlkTwipsX = 0; 1431cdf0e10cSrcweir if (bHeaders) 1432cdf0e10cSrcweir nBlkTwipsX += (long) PRINT_HEADER_WIDTH; 1433cdf0e10cSrcweir SCCOL nStartCol = rRange.aStart.Col(); 1434cdf0e10cSrcweir SCCOL nEndCol = rRange.aEnd.Col(); 1435cdf0e10cSrcweir if ( pRepeatCol && nStartCol >= pRepeatCol->aStart.Col() ) 1436cdf0e10cSrcweir { 1437cdf0e10cSrcweir for (SCCOL i=pRepeatCol->aStart.Col(); i<=pRepeatCol->aEnd.Col(); i++ ) 1438cdf0e10cSrcweir nBlkTwipsX += aDocument.GetColWidth( i, nTab ); 1439cdf0e10cSrcweir if ( nStartCol <= pRepeatCol->aEnd.Col() ) 1440cdf0e10cSrcweir nStartCol = pRepeatCol->aEnd.Col() + 1; 1441cdf0e10cSrcweir } 1442cdf0e10cSrcweir // legacy compilers' own scope for i 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir for ( SCCOL i=nStartCol; i<=nEndCol; i++ ) 1445cdf0e10cSrcweir nBlkTwipsX += aDocument.GetColWidth( i, nTab ); 1446cdf0e10cSrcweir } 1447cdf0e10cSrcweir 1448cdf0e10cSrcweir long nBlkTwipsY = 0; 1449cdf0e10cSrcweir if (bHeaders) 1450cdf0e10cSrcweir nBlkTwipsY += (long) PRINT_HEADER_HEIGHT; 1451cdf0e10cSrcweir SCROW nStartRow = rRange.aStart.Row(); 1452cdf0e10cSrcweir SCROW nEndRow = rRange.aEnd.Row(); 1453cdf0e10cSrcweir if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() ) 1454cdf0e10cSrcweir { 1455cdf0e10cSrcweir nBlkTwipsY += aDocument.GetRowHeight( pRepeatRow->aStart.Row(), 1456cdf0e10cSrcweir pRepeatRow->aEnd.Row(), nTab ); 1457cdf0e10cSrcweir if ( nStartRow <= pRepeatRow->aEnd.Row() ) 1458cdf0e10cSrcweir nStartRow = pRepeatRow->aEnd.Row() + 1; 1459cdf0e10cSrcweir } 1460cdf0e10cSrcweir nBlkTwipsY += aDocument.GetRowHeight( nStartRow, nEndRow, nTab ); 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir Size aPhysPage; 1463cdf0e10cSrcweir long nHdr, nFtr; 1464cdf0e10cSrcweir ScPrintFunc aOldPrFunc( this, GetPrinter(), nTab ); 1465cdf0e10cSrcweir aOldPrFunc.GetScaleData( aPhysPage, nHdr, nFtr ); 1466cdf0e10cSrcweir nBlkTwipsY += nHdr + nFtr; 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir if ( nBlkTwipsX == 0 ) // #100639# hidden columns/rows may lead to 0 1469cdf0e10cSrcweir nBlkTwipsX = 1; 1470cdf0e10cSrcweir if ( nBlkTwipsY == 0 ) 1471cdf0e10cSrcweir nBlkTwipsY = 1; 1472cdf0e10cSrcweir 1473cdf0e10cSrcweir long nNeeded = Min( aPhysPage.Width() * 100 / nBlkTwipsX, 1474cdf0e10cSrcweir aPhysPage.Height() * 100 / nBlkTwipsY ); 1475cdf0e10cSrcweir if ( nNeeded < ZOOM_MIN ) 1476cdf0e10cSrcweir nNeeded = ZOOM_MIN; // Begrenzung 1477cdf0e10cSrcweir if ( nNeeded < (long) nNewScale ) 1478cdf0e10cSrcweir nNewScale = (sal_uInt16) nNeeded; 1479cdf0e10cSrcweir 1480cdf0e10cSrcweir bChange = ( nNewScale != nOldScale || nOldPages != 0 ); 1481cdf0e10cSrcweir if ( bChange ) 1482cdf0e10cSrcweir SetPrintZoom( nTab, nNewScale, 0 ); 1483cdf0e10cSrcweir } 1484cdf0e10cSrcweir return bChange; 1485cdf0e10cSrcweir } 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir void ScDocShell::PageStyleModified( const String& rStyleName, sal_Bool bApi ) 1488cdf0e10cSrcweir { 1489cdf0e10cSrcweir ScDocShellModificator aModificator( *this ); 1490cdf0e10cSrcweir 1491cdf0e10cSrcweir sal_Bool bWarn = sal_False; 1492cdf0e10cSrcweir 1493cdf0e10cSrcweir SCTAB nTabCount = aDocument.GetTableCount(); 1494cdf0e10cSrcweir SCTAB nUseTab = MAXTAB+1; 1495cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount && nUseTab>MAXTAB; nTab++) 1496cdf0e10cSrcweir if ( aDocument.GetPageStyle(nTab) == rStyleName && 1497cdf0e10cSrcweir ( !bApi || aDocument.GetPageSize(nTab).Width() ) ) 1498cdf0e10cSrcweir nUseTab = nTab; 1499cdf0e10cSrcweir // bei bApi nur, wenn Umbrueche schon angezeigt 1500cdf0e10cSrcweir 1501cdf0e10cSrcweir if (ValidTab(nUseTab)) // nicht verwendet -> nichts zu tun 1502cdf0e10cSrcweir { 1503cdf0e10cSrcweir ScPrintFunc aPrintFunc( this, GetPrinter(), nUseTab ); //! ohne CountPages auskommen 1504cdf0e10cSrcweir if (!aPrintFunc.UpdatePages()) // setzt Umbrueche auf allen Tabs 1505cdf0e10cSrcweir bWarn = sal_True; 1506cdf0e10cSrcweir 1507cdf0e10cSrcweir if (bWarn && !bApi) 1508cdf0e10cSrcweir { 1509cdf0e10cSrcweir ScWaitCursorOff aWaitOff( GetActiveDialogParent() ); 1510cdf0e10cSrcweir InfoBox aInfoBox(GetActiveDialogParent(), 1511cdf0e10cSrcweir ScGlobal::GetRscString(STR_PRINT_INVALID_AREA)); 1512cdf0e10cSrcweir aInfoBox.Execute(); 1513cdf0e10cSrcweir } 1514cdf0e10cSrcweir } 1515cdf0e10cSrcweir 1516cdf0e10cSrcweir aModificator.SetDocumentModified(); 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 1519cdf0e10cSrcweir if (pBindings) 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir pBindings->Invalidate( FID_RESET_PRINTZOOM ); 1522cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT ); 1523cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT ); 1524cdf0e10cSrcweir } 1525cdf0e10cSrcweir } 1526cdf0e10cSrcweir 1527cdf0e10cSrcweir void ScDocShell::ExecutePageStyle( SfxViewShell& rCaller, 1528cdf0e10cSrcweir SfxRequest& rReq, 1529cdf0e10cSrcweir SCTAB nCurTab ) 1530cdf0e10cSrcweir { 1531cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 1532cdf0e10cSrcweir 1533cdf0e10cSrcweir switch ( rReq.GetSlot() ) 1534cdf0e10cSrcweir { 1535cdf0e10cSrcweir case SID_STATUS_PAGESTYLE: // Click auf StatusBar-Control 1536cdf0e10cSrcweir case SID_FORMATPAGE: 1537cdf0e10cSrcweir { 1538cdf0e10cSrcweir if ( pReqArgs != NULL ) 1539cdf0e10cSrcweir { 1540cdf0e10cSrcweir } 1541cdf0e10cSrcweir else if ( pReqArgs == NULL ) 1542cdf0e10cSrcweir { 1543cdf0e10cSrcweir sal_Bool bUndo(aDocument.IsUndoEnabled()); 1544cdf0e10cSrcweir String aOldName = aDocument.GetPageStyle( nCurTab ); 1545cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1546cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet 1547cdf0e10cSrcweir = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE ); 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir if ( pStyleSheet ) 1552cdf0e10cSrcweir { 1553cdf0e10cSrcweir ScStyleSaveData aOldData; 1554cdf0e10cSrcweir if (bUndo) 1555cdf0e10cSrcweir aOldData.InitFromStyle( pStyleSheet ); 1556cdf0e10cSrcweir 1557cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); 1558cdf0e10cSrcweir 1559cdf0e10cSrcweir //CHINA001 ScStyleDlg* pDlg = new ScStyleDlg( GetActiveDialogParent(), 1560cdf0e10cSrcweir //CHINA001 *pStyleSheet, 1561cdf0e10cSrcweir //CHINA001 RID_SCDLG_STYLES_PAGE ); 1562cdf0e10cSrcweir //CHINA001 1563cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1564cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateScStyleDlg( GetActiveDialogParent(), *pStyleSheet, RID_SCDLG_STYLES_PAGE, RID_SCDLG_STYLES_PAGE ); 1567cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1568cdf0e10cSrcweir 1569cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 1570cdf0e10cSrcweir { 1571cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 1572cdf0e10cSrcweir 1573cdf0e10cSrcweir WaitObject aWait( GetActiveDialogParent() ); 1574cdf0e10cSrcweir 1575cdf0e10cSrcweir String aNewName = pStyleSheet->GetName(); 1576cdf0e10cSrcweir if ( aNewName != aOldName && 1577cdf0e10cSrcweir aDocument.RenamePageStyleInUse( aOldName, aNewName ) ) 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 1580cdf0e10cSrcweir if (pBindings) 1581cdf0e10cSrcweir { 1582cdf0e10cSrcweir pBindings->Invalidate( SID_STATUS_PAGESTYLE ); 1583cdf0e10cSrcweir pBindings->Invalidate( FID_RESET_PRINTZOOM ); 1584cdf0e10cSrcweir } 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir if ( pOutSet ) 1588cdf0e10cSrcweir aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet ); 1589cdf0e10cSrcweir 1590cdf0e10cSrcweir // merken fuer GetState(): 1591cdf0e10cSrcweir GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, bHeaderOn, bFooterOn ); 1592cdf0e10cSrcweir rCaller.GetViewFrame()->GetBindings().Invalidate( SID_HFEDIT ); 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir ScStyleSaveData aNewData; 1595cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet ); 1596cdf0e10cSrcweir if (bUndo) 1597cdf0e10cSrcweir { 1598cdf0e10cSrcweir GetUndoManager()->AddUndoAction( 1599cdf0e10cSrcweir new ScUndoModifyStyle( this, SFX_STYLE_FAMILY_PAGE, 1600cdf0e10cSrcweir aOldData, aNewData ) ); 1601cdf0e10cSrcweir } 1602cdf0e10cSrcweir 1603cdf0e10cSrcweir PageStyleModified( aNewName, sal_False ); 1604cdf0e10cSrcweir rReq.Done(); 1605cdf0e10cSrcweir } 1606cdf0e10cSrcweir delete pDlg; 1607cdf0e10cSrcweir 1608cdf0e10cSrcweir rStyleSet.ClearItem( ATTR_PAGE_PAPERTRAY ); 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir } 1611cdf0e10cSrcweir } 1612cdf0e10cSrcweir break; 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir case SID_HFEDIT: 1615cdf0e10cSrcweir { 1616cdf0e10cSrcweir if ( pReqArgs != NULL ) 1617cdf0e10cSrcweir { 1618cdf0e10cSrcweir } 1619cdf0e10cSrcweir else if ( pReqArgs == NULL ) 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir String aStr( aDocument.GetPageStyle( nCurTab ) ); 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir ScStyleSheetPool* pStylePool 1624cdf0e10cSrcweir = aDocument.GetStyleSheetPool(); 1625cdf0e10cSrcweir 1626cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet 1627cdf0e10cSrcweir = pStylePool->Find( aStr, SFX_STYLE_FAMILY_PAGE ); 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); 1630cdf0e10cSrcweir 1631cdf0e10cSrcweir if ( pStyleSheet ) 1632cdf0e10cSrcweir { 1633cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir SvxPageUsage eUsage = 1636cdf0e10cSrcweir SvxPageUsage( ((const SvxPageItem&) 1637cdf0e10cSrcweir rStyleSet.Get( ATTR_PAGE )). 1638cdf0e10cSrcweir GetPageUsage() ); 1639cdf0e10cSrcweir sal_Bool bShareHeader = IS_SHARE_HEADER(rStyleSet); 1640cdf0e10cSrcweir sal_Bool bShareFooter = IS_SHARE_FOOTER(rStyleSet); 1641cdf0e10cSrcweir sal_uInt16 nResId = 0; 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir switch ( eUsage ) 1644cdf0e10cSrcweir { 1645cdf0e10cSrcweir case SVX_PAGE_LEFT: 1646cdf0e10cSrcweir case SVX_PAGE_RIGHT: 1647cdf0e10cSrcweir { 1648cdf0e10cSrcweir if ( bHeaderOn && bFooterOn ) 1649cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT; 1650cdf0e10cSrcweir else if ( SVX_PAGE_RIGHT == eUsage ) 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir if ( !bHeaderOn && bFooterOn ) 1653cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER; 1654cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1655cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTHEADER; 1656cdf0e10cSrcweir } 1657cdf0e10cSrcweir else 1658cdf0e10cSrcweir { 1659cdf0e10cSrcweir // #69193a# respect "shared" setting 1660cdf0e10cSrcweir if ( !bHeaderOn && bFooterOn ) 1661cdf0e10cSrcweir nResId = bShareFooter ? 1662cdf0e10cSrcweir RID_SCDLG_HFEDIT_RIGHTFOOTER : 1663cdf0e10cSrcweir RID_SCDLG_HFEDIT_LEFTFOOTER; 1664cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1665cdf0e10cSrcweir nResId = bShareHeader ? 1666cdf0e10cSrcweir RID_SCDLG_HFEDIT_RIGHTHEADER : 1667cdf0e10cSrcweir RID_SCDLG_HFEDIT_LEFTHEADER; 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir } 1670cdf0e10cSrcweir break; 1671cdf0e10cSrcweir 1672cdf0e10cSrcweir case SVX_PAGE_MIRROR: 1673cdf0e10cSrcweir case SVX_PAGE_ALL: 1674cdf0e10cSrcweir default: 1675cdf0e10cSrcweir { 1676cdf0e10cSrcweir if ( !bShareHeader && !bShareFooter ) 1677cdf0e10cSrcweir { 1678cdf0e10cSrcweir if ( bHeaderOn && bFooterOn ) 1679cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_ALL; 1680cdf0e10cSrcweir else if ( !bHeaderOn && bFooterOn ) 1681cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_FOOTER; 1682cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1683cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_HEADER; 1684cdf0e10cSrcweir } 1685cdf0e10cSrcweir else if ( bShareHeader && bShareFooter ) 1686cdf0e10cSrcweir { 1687cdf0e10cSrcweir if ( bHeaderOn && bFooterOn ) 1688cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT; 1689cdf0e10cSrcweir else 1690cdf0e10cSrcweir { 1691cdf0e10cSrcweir if ( !bHeaderOn && bFooterOn ) 1692cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER; 1693cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1694cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTHEADER; 1695cdf0e10cSrcweir } 1696cdf0e10cSrcweir } 1697cdf0e10cSrcweir else if ( !bShareHeader && bShareFooter ) 1698cdf0e10cSrcweir { 1699cdf0e10cSrcweir if ( bHeaderOn && bFooterOn ) 1700cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_SFTR; 1701cdf0e10cSrcweir else if ( !bHeaderOn && bFooterOn ) 1702cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER; 1703cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1704cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_HEADER; 1705cdf0e10cSrcweir } 1706cdf0e10cSrcweir else if ( bShareHeader && !bShareFooter ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir if ( bHeaderOn && bFooterOn ) 1709cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_SHDR; 1710cdf0e10cSrcweir else if ( !bHeaderOn && bFooterOn ) 1711cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_FOOTER; 1712cdf0e10cSrcweir else if ( bHeaderOn && !bFooterOn ) 1713cdf0e10cSrcweir nResId = RID_SCDLG_HFEDIT_RIGHTHEADER; 1714cdf0e10cSrcweir } 1715cdf0e10cSrcweir } 1716cdf0e10cSrcweir } 1717cdf0e10cSrcweir 1718cdf0e10cSrcweir //CHINA001 ScHFEditDlg* pDlg 1719cdf0e10cSrcweir //CHINA001 = new ScHFEditDlg( SFX_APP()->GetViewFrame(), 1720cdf0e10cSrcweir //CHINA001 GetActiveDialogParent(), 1721cdf0e10cSrcweir //CHINA001 rStyleSet, 1722cdf0e10cSrcweir //CHINA001 aStr, 1723cdf0e10cSrcweir //CHINA001 nResId ); 1724cdf0e10cSrcweir //CHINA001 1725cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 1726cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateScHFEditDlg( SfxViewFrame::Current(), 1729cdf0e10cSrcweir GetActiveDialogParent(), 1730cdf0e10cSrcweir rStyleSet, 1731cdf0e10cSrcweir aStr, 1732cdf0e10cSrcweir RID_SCDLG_HFEDIT, nResId); 1733cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 1734cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 1735cdf0e10cSrcweir { 1736cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir if ( pOutSet ) 1739cdf0e10cSrcweir aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet ); 1740cdf0e10cSrcweir 1741cdf0e10cSrcweir SetDocumentModified(); 1742cdf0e10cSrcweir rReq.Done(); 1743cdf0e10cSrcweir } 1744cdf0e10cSrcweir delete pDlg; 1745cdf0e10cSrcweir } 1746cdf0e10cSrcweir } 1747cdf0e10cSrcweir } 1748cdf0e10cSrcweir break; 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir default: 1751cdf0e10cSrcweir break; 1752cdf0e10cSrcweir } 1753cdf0e10cSrcweir } 1754cdf0e10cSrcweir 1755cdf0e10cSrcweir void ScDocShell::GetStatePageStyle( SfxViewShell& /* rCaller */, 1756cdf0e10cSrcweir SfxItemSet& rSet, 1757cdf0e10cSrcweir SCTAB nCurTab ) 1758cdf0e10cSrcweir { 1759cdf0e10cSrcweir SfxWhichIter aIter(rSet); 1760cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 1761cdf0e10cSrcweir while ( nWhich ) 1762cdf0e10cSrcweir { 1763cdf0e10cSrcweir switch (nWhich) 1764cdf0e10cSrcweir { 1765cdf0e10cSrcweir case SID_STATUS_PAGESTYLE: 1766cdf0e10cSrcweir rSet.Put( SfxStringItem( nWhich, aDocument.GetPageStyle( nCurTab ) ) ); 1767cdf0e10cSrcweir break; 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir case SID_HFEDIT: 1770cdf0e10cSrcweir { 1771cdf0e10cSrcweir String aStr = aDocument.GetPageStyle( nCurTab ); 1772cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1773cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStr, SFX_STYLE_FAMILY_PAGE ); 1774cdf0e10cSrcweir 1775cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); 1776cdf0e10cSrcweir 1777cdf0e10cSrcweir if ( pStyleSheet ) 1778cdf0e10cSrcweir { 1779cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyleSheet->GetItemSet(); 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, bHeaderOn, bFooterOn ); 1782cdf0e10cSrcweir 1783cdf0e10cSrcweir if ( !bHeaderOn && !bFooterOn ) 1784cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1785cdf0e10cSrcweir } 1786cdf0e10cSrcweir } 1787cdf0e10cSrcweir break; 1788cdf0e10cSrcweir } 1789cdf0e10cSrcweir 1790cdf0e10cSrcweir nWhich = aIter.NextWhich(); 1791cdf0e10cSrcweir } 1792cdf0e10cSrcweir } 1793cdf0e10cSrcweir 1794cdf0e10cSrcweir void ScDocShell::GetState( SfxItemSet &rSet ) 1795cdf0e10cSrcweir { 1796cdf0e10cSrcweir SfxWhichIter aIter(rSet); 1797cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 1798cdf0e10cSrcweir while ( nWhich ) 1799cdf0e10cSrcweir { 1800cdf0e10cSrcweir switch (nWhich) 1801cdf0e10cSrcweir { 1802cdf0e10cSrcweir case FID_AUTO_CALC: 1803cdf0e10cSrcweir if ( (sal_Bool) aDocument.GetHardRecalcState() ) 1804cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1805cdf0e10cSrcweir else 1806cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, aDocument.GetAutoCalc() ) ); 1807cdf0e10cSrcweir break; 1808cdf0e10cSrcweir 1809cdf0e10cSrcweir case FID_CHG_RECORD: 1810cdf0e10cSrcweir if ( IsDocShared() ) 1811cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1812cdf0e10cSrcweir else 1813cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, 1814cdf0e10cSrcweir aDocument.GetChangeTrack() != NULL ) ); 1815cdf0e10cSrcweir break; 1816cdf0e10cSrcweir 1817cdf0e10cSrcweir case SID_CHG_PROTECT: 1818cdf0e10cSrcweir { 1819cdf0e10cSrcweir ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack(); 1820cdf0e10cSrcweir if ( pChangeTrack && !IsDocShared() ) 1821cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, 1822cdf0e10cSrcweir pChangeTrack->IsProtected() ) ); 1823cdf0e10cSrcweir else 1824cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1825cdf0e10cSrcweir } 1826cdf0e10cSrcweir break; 1827cdf0e10cSrcweir 1828cdf0e10cSrcweir case SID_DOCUMENT_COMPARE: 1829cdf0e10cSrcweir { 1830cdf0e10cSrcweir if ( IsDocShared() ) 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1833cdf0e10cSrcweir } 1834cdf0e10cSrcweir } 1835cdf0e10cSrcweir break; 1836cdf0e10cSrcweir 1837cdf0e10cSrcweir // Wenn eine Formel editiert wird, muss FID_RECALC auf jeden Fall enabled sein. 1838cdf0e10cSrcweir // Recalc fuer das Doc war mal wegen #29898# disabled, wenn AutoCalc an war, 1839cdf0e10cSrcweir // ist jetzt wegen #41540# aber auch immer enabled. 1840cdf0e10cSrcweir // case FID_RECALC: 1841cdf0e10cSrcweir // if ( aDocument.GetAutoCalc() ) 1842cdf0e10cSrcweir // rSet.DisableItem( nWhich ); 1843cdf0e10cSrcweir // break; 1844cdf0e10cSrcweir 1845cdf0e10cSrcweir case SID_TABLES_COUNT: 1846cdf0e10cSrcweir rSet.Put( SfxInt16Item( nWhich, aDocument.GetTableCount() ) ); 1847cdf0e10cSrcweir break; 1848cdf0e10cSrcweir 1849cdf0e10cSrcweir case SID_ATTR_YEAR2000 : 1850cdf0e10cSrcweir rSet.Put( SfxUInt16Item( nWhich, 1851cdf0e10cSrcweir aDocument.GetDocOptions().GetYear2000() ) ); 1852cdf0e10cSrcweir break; 1853cdf0e10cSrcweir 1854cdf0e10cSrcweir case SID_SHARE_DOC: 1855cdf0e10cSrcweir { 1856cdf0e10cSrcweir if ( IsReadOnly() ) 1857cdf0e10cSrcweir { 1858cdf0e10cSrcweir rSet.DisableItem( nWhich ); 1859cdf0e10cSrcweir } 1860cdf0e10cSrcweir } 1861cdf0e10cSrcweir break; 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir default: 1864cdf0e10cSrcweir { 1865cdf0e10cSrcweir } 1866cdf0e10cSrcweir break; 1867cdf0e10cSrcweir } 1868cdf0e10cSrcweir 1869cdf0e10cSrcweir nWhich = aIter.NextWhich(); 1870cdf0e10cSrcweir } 1871cdf0e10cSrcweir } 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir void ScDocShell::GetSbxState( SfxItemSet &rSet ) 1874cdf0e10cSrcweir { 1875cdf0e10cSrcweir // SID_SC_SELECTION (Selection), 1876cdf0e10cSrcweir // SID_SC_ACTIVECELL (ActiveCell), 1877cdf0e10cSrcweir // SID_SC_ACTIVETAB (ActiveTable), 1878cdf0e10cSrcweir // SID_TABLES_GET (Tables), 1879cdf0e10cSrcweir // SID_PIVOT_GET (DataPilotTables) - removed (old Basic) 1880cdf0e10cSrcweir 1881cdf0e10cSrcweir // 1882cdf0e10cSrcweir // Wenn hier Slots von der View-Shell executed werden, muss auch der 1883cdf0e10cSrcweir // GetState weitergeleitet werden! 1884cdf0e10cSrcweir // 1885cdf0e10cSrcweir 1886cdf0e10cSrcweir ScTabViewShell* pVisibleSh = GetBestViewShell(); // sichtbare View 1887cdf0e10cSrcweir if ( pVisibleSh ) 1888cdf0e10cSrcweir pVisibleSh->GetState( rSet ); 1889cdf0e10cSrcweir } 1890cdf0e10cSrcweir 1891cdf0e10cSrcweir void __EXPORT ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uInt16 nAspect ) 1892cdf0e10cSrcweir { 1893cdf0e10cSrcweir // bIsOle = sal_True; // jetzt ueber den CreateMode 1894cdf0e10cSrcweir 1895cdf0e10cSrcweir SCTAB nVisTab = aDocument.GetVisibleTab(); 1896cdf0e10cSrcweir if (!aDocument.HasTable(nVisTab)) 1897cdf0e10cSrcweir return; 1898cdf0e10cSrcweir 1899cdf0e10cSrcweir sal_uLong nOldLayoutMode = pDev->GetLayoutMode(); 1900cdf0e10cSrcweir pDev->SetLayoutMode( TEXT_LAYOUT_DEFAULT ); // even if it's the same, to get the metafile action 1901cdf0e10cSrcweir 1902cdf0e10cSrcweir if ( nAspect == ASPECT_THUMBNAIL ) 1903cdf0e10cSrcweir { 1904cdf0e10cSrcweir Rectangle aBoundRect = GetVisArea( ASPECT_THUMBNAIL ); 1905cdf0e10cSrcweir ScViewData aTmpData( this, NULL ); 1906cdf0e10cSrcweir aTmpData.SetTabNo(nVisTab); 1907cdf0e10cSrcweir aDocument.SnapVisArea( aBoundRect ); 1908cdf0e10cSrcweir aTmpData.SetScreen( aBoundRect ); 1909cdf0e10cSrcweir ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, sal_True ); 1910cdf0e10cSrcweir } 1911cdf0e10cSrcweir else 1912cdf0e10cSrcweir { 1913cdf0e10cSrcweir Rectangle aBoundRect = SfxObjectShell::GetVisArea(); 1914cdf0e10cSrcweir ScViewData aTmpData( this, NULL ); 1915cdf0e10cSrcweir aTmpData.SetTabNo(nVisTab); 1916cdf0e10cSrcweir aDocument.SnapVisArea( aBoundRect ); 1917cdf0e10cSrcweir aTmpData.SetScreen( aBoundRect ); 1918cdf0e10cSrcweir ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, sal_True ); 1919cdf0e10cSrcweir } 1920cdf0e10cSrcweir 1921cdf0e10cSrcweir pDev->SetLayoutMode( nOldLayoutMode ); 1922cdf0e10cSrcweir } 1923cdf0e10cSrcweir 1924cdf0e10cSrcweir Rectangle __EXPORT ScDocShell::GetVisArea( sal_uInt16 nAspect ) const 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir SfxObjectCreateMode eShellMode = GetCreateMode(); 1927cdf0e10cSrcweir if ( eShellMode == SFX_CREATE_MODE_ORGANIZER ) 1928cdf0e10cSrcweir { 1929cdf0e10cSrcweir // ohne Inhalte wissen wir auch nicht, wie gross die Inhalte sind 1930cdf0e10cSrcweir // leeres Rechteck zurueckgeben, das wird dann nach dem Laden berechnet 1931cdf0e10cSrcweir return Rectangle(); 1932cdf0e10cSrcweir } 1933cdf0e10cSrcweir 1934cdf0e10cSrcweir if( nAspect == ASPECT_THUMBNAIL ) 1935cdf0e10cSrcweir { 1936cdf0e10cSrcweir // Rectangle aArea( 0,0, 3175,3175 ); // 120x120 Pixel in 1:1 1937cdf0e10cSrcweir Rectangle aArea( 0,0, SC_PREVIEW_SIZE_X,SC_PREVIEW_SIZE_Y ); 1938cdf0e10cSrcweir sal_Bool bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() ); 1939cdf0e10cSrcweir if ( bNegativePage ) 1940cdf0e10cSrcweir ScDrawLayer::MirrorRectRTL( aArea ); 1941cdf0e10cSrcweir aDocument.SnapVisArea( aArea ); 1942cdf0e10cSrcweir return aArea; 1943cdf0e10cSrcweir } 1944cdf0e10cSrcweir else if( nAspect == ASPECT_CONTENT && eShellMode != SFX_CREATE_MODE_EMBEDDED ) 1945cdf0e10cSrcweir { 1946cdf0e10cSrcweir // Visarea holen wie nach Load 1947cdf0e10cSrcweir 1948cdf0e10cSrcweir SCTAB nVisTab = aDocument.GetVisibleTab(); 1949cdf0e10cSrcweir if (!aDocument.HasTable(nVisTab)) 1950cdf0e10cSrcweir { 1951cdf0e10cSrcweir nVisTab = 0; 1952cdf0e10cSrcweir ((ScDocShell*)this)->aDocument.SetVisibleTab(nVisTab); 1953cdf0e10cSrcweir } 1954cdf0e10cSrcweir SCCOL nStartCol; 1955cdf0e10cSrcweir SCROW nStartRow; 1956cdf0e10cSrcweir aDocument.GetDataStart( nVisTab, nStartCol, nStartRow ); 1957cdf0e10cSrcweir SCCOL nEndCol; 1958cdf0e10cSrcweir SCROW nEndRow; 1959cdf0e10cSrcweir aDocument.GetPrintArea( nVisTab, nEndCol, nEndRow ); 1960cdf0e10cSrcweir if (nStartCol>nEndCol) 1961cdf0e10cSrcweir nStartCol = nEndCol; 1962cdf0e10cSrcweir if (nStartRow>nEndRow) 1963cdf0e10cSrcweir nStartRow = nEndRow; 1964cdf0e10cSrcweir Rectangle aNewArea = ((ScDocument&)aDocument) 1965cdf0e10cSrcweir .GetMMRect( nStartCol,nStartRow, nEndCol,nEndRow, nVisTab ); 1966cdf0e10cSrcweir //TODO/LATER: different methods for setting VisArea?! 1967cdf0e10cSrcweir ((ScDocShell*)this)->SfxObjectShell::SetVisArea( aNewArea ); 1968cdf0e10cSrcweir return aNewArea; 1969cdf0e10cSrcweir } 1970cdf0e10cSrcweir else 1971cdf0e10cSrcweir return SfxObjectShell::GetVisArea( nAspect ); 1972cdf0e10cSrcweir } 1973cdf0e10cSrcweir 1974cdf0e10cSrcweir void ScDocShell::GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet, 1975cdf0e10cSrcweir SCTAB nCurTab, 1976cdf0e10cSrcweir sal_Bool& rbHeader, 1977cdf0e10cSrcweir sal_Bool& rbFooter ) 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir if ( !pStyleSet ) 1980cdf0e10cSrcweir { 1981cdf0e10cSrcweir ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool(); 1982cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = pStylePool-> 1983cdf0e10cSrcweir Find( aDocument.GetPageStyle( nCurTab ), 1984cdf0e10cSrcweir SFX_STYLE_FAMILY_PAGE ); 1985cdf0e10cSrcweir 1986cdf0e10cSrcweir DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" ); 1987cdf0e10cSrcweir 1988cdf0e10cSrcweir if ( pStyleSheet ) 1989cdf0e10cSrcweir pStyleSet = &pStyleSheet->GetItemSet(); 1990cdf0e10cSrcweir else 1991cdf0e10cSrcweir rbHeader = rbFooter = sal_False; 1992cdf0e10cSrcweir } 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir DBG_ASSERT( pStyleSet, "PageStyle-Set not found! :-(" ); 1995cdf0e10cSrcweir 1996cdf0e10cSrcweir //-------------------------------------------------------------------- 1997cdf0e10cSrcweir 1998cdf0e10cSrcweir const SvxSetItem* pSetItem = NULL; 1999cdf0e10cSrcweir const SfxItemSet* pSet = NULL; 2000cdf0e10cSrcweir 2001cdf0e10cSrcweir pSetItem = (const SvxSetItem*) &pStyleSet->Get( ATTR_PAGE_HEADERSET ); 2002cdf0e10cSrcweir pSet = &pSetItem->GetItemSet(); 2003cdf0e10cSrcweir rbHeader = ((const SfxBoolItem&)pSet->Get(ATTR_PAGE_ON)).GetValue(); 2004cdf0e10cSrcweir 2005cdf0e10cSrcweir pSetItem = (const SvxSetItem*) &pStyleSet->Get( ATTR_PAGE_FOOTERSET ); 2006cdf0e10cSrcweir pSet = &pSetItem->GetItemSet(); 2007cdf0e10cSrcweir rbFooter = ((const SfxBoolItem&)pSet->Get(ATTR_PAGE_ON)).GetValue(); 2008cdf0e10cSrcweir } 2009cdf0e10cSrcweir 2010cdf0e10cSrcweir long __EXPORT ScDocShell::DdeGetData( const String& rItem, 2011cdf0e10cSrcweir const String& rMimeType, 2012cdf0e10cSrcweir ::com::sun::star::uno::Any & rValue ) 2013cdf0e10cSrcweir { 2014cdf0e10cSrcweir if( FORMAT_STRING == SotExchange::GetFormatIdFromMimeType( rMimeType ) ) 2015cdf0e10cSrcweir { 2016cdf0e10cSrcweir if( rItem.EqualsIgnoreCaseAscii( "Format" ) ) 2017cdf0e10cSrcweir { 2018cdf0e10cSrcweir ByteString aFmtByte( aDdeTextFmt, gsl_getSystemTextEncoding() ); 2019cdf0e10cSrcweir rValue <<= ::com::sun::star::uno::Sequence< sal_Int8 >( 2020cdf0e10cSrcweir (sal_Int8*)aFmtByte.GetBuffer(), 2021cdf0e10cSrcweir aFmtByte.Len() + 1 ); 2022cdf0e10cSrcweir return 1; 2023cdf0e10cSrcweir } 2024cdf0e10cSrcweir ScImportExport aObj( &aDocument, rItem ); 2025cdf0e10cSrcweir if ( !aObj.IsRef() ) 2026cdf0e10cSrcweir return 0; // ungueltiger Bereich 2027cdf0e10cSrcweir 2028cdf0e10cSrcweir if( aDdeTextFmt.GetChar(0) == 'F' ) 2029cdf0e10cSrcweir aObj.SetFormulas( sal_True ); 2030cdf0e10cSrcweir if( aDdeTextFmt.EqualsAscii( "SYLK" ) || 2031cdf0e10cSrcweir aDdeTextFmt.EqualsAscii( "FSYLK" ) ) 2032cdf0e10cSrcweir { 2033cdf0e10cSrcweir ByteString aData; 2034cdf0e10cSrcweir if( aObj.ExportByteString( aData, gsl_getSystemTextEncoding(), 2035cdf0e10cSrcweir SOT_FORMATSTR_ID_SYLK ) ) 2036cdf0e10cSrcweir { 2037cdf0e10cSrcweir rValue <<= ::com::sun::star::uno::Sequence< sal_Int8 >( 2038cdf0e10cSrcweir (sal_Int8*)aData.GetBuffer(), 2039cdf0e10cSrcweir aData.Len() + 1 ); 2040cdf0e10cSrcweir return 1; 2041cdf0e10cSrcweir } 2042cdf0e10cSrcweir else 2043cdf0e10cSrcweir return 0; 2044cdf0e10cSrcweir } 2045cdf0e10cSrcweir if( aDdeTextFmt.EqualsAscii( "CSV" ) || 2046cdf0e10cSrcweir aDdeTextFmt.EqualsAscii( "FCSV" ) ) 2047cdf0e10cSrcweir aObj.SetSeparator( ',' ); 2048cdf0e10cSrcweir aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) ); 2049cdf0e10cSrcweir return aObj.ExportData( rMimeType, rValue ) ? 1 : 0; 2050cdf0e10cSrcweir } 2051cdf0e10cSrcweir 2052cdf0e10cSrcweir ScImportExport aObj( &aDocument, rItem ); 2053cdf0e10cSrcweir aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) ); 2054cdf0e10cSrcweir if( aObj.IsRef() ) 2055cdf0e10cSrcweir return aObj.ExportData( rMimeType, rValue ) ? 1 : 0; 2056cdf0e10cSrcweir return 0; 2057cdf0e10cSrcweir } 2058cdf0e10cSrcweir 2059cdf0e10cSrcweir long __EXPORT ScDocShell::DdeSetData( const String& rItem, 2060cdf0e10cSrcweir const String& rMimeType, 2061cdf0e10cSrcweir const ::com::sun::star::uno::Any & rValue ) 2062cdf0e10cSrcweir { 2063cdf0e10cSrcweir if( FORMAT_STRING == SotExchange::GetFormatIdFromMimeType( rMimeType )) 2064cdf0e10cSrcweir { 2065cdf0e10cSrcweir if( rItem.EqualsIgnoreCaseAscii( "Format" ) ) 2066cdf0e10cSrcweir { 2067cdf0e10cSrcweir if ( ScByteSequenceToString::GetString( aDdeTextFmt, rValue, gsl_getSystemTextEncoding() ) ) 2068cdf0e10cSrcweir { 2069cdf0e10cSrcweir aDdeTextFmt.ToUpperAscii(); 2070cdf0e10cSrcweir return 1; 2071cdf0e10cSrcweir } 2072cdf0e10cSrcweir return 0; 2073cdf0e10cSrcweir } 2074cdf0e10cSrcweir ScImportExport aObj( &aDocument, rItem ); 2075cdf0e10cSrcweir if( aDdeTextFmt.GetChar(0) == 'F' ) 2076cdf0e10cSrcweir aObj.SetFormulas( sal_True ); 2077cdf0e10cSrcweir if( aDdeTextFmt.EqualsAscii( "SYLK" ) || 2078cdf0e10cSrcweir aDdeTextFmt.EqualsAscii( "FSYLK" ) ) 2079cdf0e10cSrcweir { 2080cdf0e10cSrcweir String aData; 2081cdf0e10cSrcweir if ( ScByteSequenceToString::GetString( aData, rValue, gsl_getSystemTextEncoding() ) ) 2082cdf0e10cSrcweir { 2083cdf0e10cSrcweir return aObj.ImportString( aData, SOT_FORMATSTR_ID_SYLK ) ? 1 : 0; 2084cdf0e10cSrcweir } 2085cdf0e10cSrcweir return 0; 2086cdf0e10cSrcweir } 2087cdf0e10cSrcweir if( aDdeTextFmt.EqualsAscii( "CSV" ) || 2088cdf0e10cSrcweir aDdeTextFmt.EqualsAscii( "FCSV" ) ) 2089cdf0e10cSrcweir aObj.SetSeparator( ',' ); 2090cdf0e10cSrcweir return aObj.ImportData( rMimeType, rValue ) ? 1 : 0; 2091cdf0e10cSrcweir } 2092cdf0e10cSrcweir ScImportExport aObj( &aDocument, rItem ); 2093cdf0e10cSrcweir if( aObj.IsRef() ) 2094cdf0e10cSrcweir return aObj.ImportData( rMimeType, rValue ) ? 1 : 0; 2095cdf0e10cSrcweir return 0; 2096cdf0e10cSrcweir } 2097cdf0e10cSrcweir 2098cdf0e10cSrcweir ::sfx2::SvLinkSource* __EXPORT ScDocShell::DdeCreateLinkSource( const String& rItem ) 2099cdf0e10cSrcweir { 2100cdf0e10cSrcweir // only check for valid item string - range is parsed again in ScServerObject ctor 2101cdf0e10cSrcweir 2102cdf0e10cSrcweir // named range? 2103cdf0e10cSrcweir String aPos = rItem; 2104cdf0e10cSrcweir ScRangeName* pRange = aDocument.GetRangeName(); 2105cdf0e10cSrcweir if( pRange ) 2106cdf0e10cSrcweir { 2107cdf0e10cSrcweir sal_uInt16 nPos; 2108cdf0e10cSrcweir if( pRange->SearchName( aPos, nPos ) ) 2109cdf0e10cSrcweir { 2110cdf0e10cSrcweir ScRangeData* pData = (*pRange)[ nPos ]; 2111cdf0e10cSrcweir if( pData->HasType( RT_REFAREA ) 2112cdf0e10cSrcweir || pData->HasType( RT_ABSAREA ) 2113cdf0e10cSrcweir || pData->HasType( RT_ABSPOS ) ) 2114cdf0e10cSrcweir pData->GetSymbol( aPos ); // continue with the name's contents 2115cdf0e10cSrcweir } 2116cdf0e10cSrcweir } 2117cdf0e10cSrcweir 2118cdf0e10cSrcweir // Address in DDE function must be always parsed as CONV_OOO so that it 2119cdf0e10cSrcweir // would always work regardless of current address convension. We do this 2120cdf0e10cSrcweir // because the address item in a DDE entry is *not* normalized when saved 2121cdf0e10cSrcweir // into ODF. 2122cdf0e10cSrcweir ScRange aRange; 2123cdf0e10cSrcweir bool bValid = ( (aRange.Parse(aPos, &aDocument, formula::FormulaGrammar::CONV_OOO ) & SCA_VALID) || 2124cdf0e10cSrcweir (aRange.aStart.Parse(aPos, &aDocument, formula::FormulaGrammar::CONV_OOO) & SCA_VALID) ); 2125cdf0e10cSrcweir 2126cdf0e10cSrcweir ScServerObject* pObj = NULL; // NULL = error 2127cdf0e10cSrcweir if ( bValid ) 2128cdf0e10cSrcweir pObj = new ScServerObject( this, rItem ); 2129cdf0e10cSrcweir 2130cdf0e10cSrcweir // GetLinkManager()->InsertServer() is in the ScServerObject ctor 2131cdf0e10cSrcweir 2132cdf0e10cSrcweir return pObj; 2133cdf0e10cSrcweir } 2134cdf0e10cSrcweir 2135cdf0e10cSrcweir //------------------------------------------------------------------ 2136cdf0e10cSrcweir 2137cdf0e10cSrcweir ScViewData* ScDocShell::GetViewData() 2138cdf0e10cSrcweir { 2139cdf0e10cSrcweir SfxViewShell* pCur = SfxViewShell::Current(); 2140cdf0e10cSrcweir ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pCur); 2141cdf0e10cSrcweir return pViewSh ? pViewSh->GetViewData() : NULL; 2142cdf0e10cSrcweir } 2143cdf0e10cSrcweir 2144cdf0e10cSrcweir //------------------------------------------------------------------ 2145cdf0e10cSrcweir 2146cdf0e10cSrcweir SCTAB ScDocShell::GetCurTab() 2147cdf0e10cSrcweir { 2148cdf0e10cSrcweir //! this must be made non-static and use a ViewShell from this document! 2149cdf0e10cSrcweir 2150cdf0e10cSrcweir ScViewData* pViewData = GetViewData(); 2151cdf0e10cSrcweir 2152cdf0e10cSrcweir return pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0); 2153cdf0e10cSrcweir } 2154cdf0e10cSrcweir 2155cdf0e10cSrcweir ScTabViewShell* ScDocShell::GetBestViewShell( sal_Bool bOnlyVisible ) 2156cdf0e10cSrcweir { 2157cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 2158cdf0e10cSrcweir // falsches Doc? 2159cdf0e10cSrcweir if( pViewSh && pViewSh->GetViewData()->GetDocShell() != this ) 2160cdf0e10cSrcweir pViewSh = NULL; 2161cdf0e10cSrcweir if( !pViewSh ) 2162cdf0e10cSrcweir { 2163cdf0e10cSrcweir // 1. ViewShell suchen 2164cdf0e10cSrcweir SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, bOnlyVisible ); 2165cdf0e10cSrcweir if( pFrame ) 2166cdf0e10cSrcweir { 2167cdf0e10cSrcweir SfxViewShell* p = pFrame->GetViewShell(); 2168cdf0e10cSrcweir pViewSh = PTR_CAST(ScTabViewShell,p); 2169cdf0e10cSrcweir } 2170cdf0e10cSrcweir } 2171cdf0e10cSrcweir return pViewSh; 2172cdf0e10cSrcweir } 2173cdf0e10cSrcweir 2174cdf0e10cSrcweir SfxBindings* ScDocShell::GetViewBindings() 2175cdf0e10cSrcweir { 2176cdf0e10cSrcweir // used to invalidate slots after changes to this document 2177cdf0e10cSrcweir 2178cdf0e10cSrcweir SfxViewShell* pViewSh = GetBestViewShell(); 2179cdf0e10cSrcweir if (pViewSh) 2180cdf0e10cSrcweir return &pViewSh->GetViewFrame()->GetBindings(); 2181cdf0e10cSrcweir else 2182cdf0e10cSrcweir return NULL; 2183cdf0e10cSrcweir } 2184cdf0e10cSrcweir 2185cdf0e10cSrcweir //------------------------------------------------------------------ 2186cdf0e10cSrcweir 2187cdf0e10cSrcweir ScDocShell* ScDocShell::GetShellByNum( sal_uInt16 nDocNo ) // static 2188cdf0e10cSrcweir { 2189cdf0e10cSrcweir ScDocShell* pFound = NULL; 2190cdf0e10cSrcweir SfxObjectShell* pShell = SfxObjectShell::GetFirst(); 2191cdf0e10cSrcweir sal_uInt16 nShellCnt = 0; 2192cdf0e10cSrcweir 2193cdf0e10cSrcweir while ( pShell && !pFound ) 2194cdf0e10cSrcweir { 2195cdf0e10cSrcweir if ( pShell->Type() == TYPE(ScDocShell) ) 2196cdf0e10cSrcweir { 2197cdf0e10cSrcweir if ( nShellCnt == nDocNo ) 2198cdf0e10cSrcweir pFound = (ScDocShell*) pShell; 2199cdf0e10cSrcweir else 2200cdf0e10cSrcweir ++nShellCnt; 2201cdf0e10cSrcweir } 2202cdf0e10cSrcweir pShell = SfxObjectShell::GetNext( *pShell ); 2203cdf0e10cSrcweir } 2204cdf0e10cSrcweir 2205cdf0e10cSrcweir return pFound; 2206cdf0e10cSrcweir } 2207cdf0e10cSrcweir 2208cdf0e10cSrcweir //------------------------------------------------------------------ 2209cdf0e10cSrcweir 2210cdf0e10cSrcweir IMPL_LINK( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) 2211cdf0e10cSrcweir { 2212cdf0e10cSrcweir DBG_ASSERT( _pFileDlg, "ScDocShell::DialogClosedHdl(): no file dialog" ); 2213cdf0e10cSrcweir DBG_ASSERT( pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" ); 2214cdf0e10cSrcweir 2215cdf0e10cSrcweir if ( ERRCODE_NONE == _pFileDlg->GetError() ) 2216cdf0e10cSrcweir { 2217cdf0e10cSrcweir sal_uInt16 nSlot = pImpl->pRequest->GetSlot(); 2218cdf0e10cSrcweir SfxMedium* pMed = pImpl->pDocInserter->CreateMedium(); 2219cdf0e10cSrcweir // #i87094# If a .odt was selected pMed is NULL. 2220cdf0e10cSrcweir if (pMed) 2221cdf0e10cSrcweir { 2222cdf0e10cSrcweir pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); 2223cdf0e10cSrcweir if ( SID_DOCUMENT_COMPARE == nSlot ) 2224cdf0e10cSrcweir { 2225cdf0e10cSrcweir if ( pMed->GetFilter() ) 2226cdf0e10cSrcweir pImpl->pRequest->AppendItem( 2227cdf0e10cSrcweir SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) ); 2228cdf0e10cSrcweir String sOptions = ScDocumentLoader::GetOptions( *pMed ); 2229cdf0e10cSrcweir if ( sOptions.Len() > 0 ) 2230cdf0e10cSrcweir pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) ); 2231cdf0e10cSrcweir } 2232cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 2233cdf0e10cSrcweir SfxItemSet* pSet = pMed->GetItemSet(); 2234cdf0e10cSrcweir if ( pSet && 2235cdf0e10cSrcweir pSet->GetItemState( SID_VERSION, sal_True, &pItem ) == SFX_ITEM_SET && 2236cdf0e10cSrcweir pItem->ISA( SfxInt16Item ) ) 2237cdf0e10cSrcweir { 2238cdf0e10cSrcweir pImpl->pRequest->AppendItem( *pItem ); 2239cdf0e10cSrcweir } 2240cdf0e10cSrcweir 2241cdf0e10cSrcweir Execute( *(pImpl->pRequest) ); 2242cdf0e10cSrcweir } 2243cdf0e10cSrcweir } 2244cdf0e10cSrcweir 2245cdf0e10cSrcweir pImpl->bIgnoreLostRedliningWarning = false; 2246cdf0e10cSrcweir return 0; 2247cdf0e10cSrcweir } 2248cdf0e10cSrcweir 2249cdf0e10cSrcweir //------------------------------------------------------------------ 2250cdf0e10cSrcweir 2251cdf0e10cSrcweir void ScDocShell::EnableSharedSettings( bool bEnable ) 2252cdf0e10cSrcweir { 2253cdf0e10cSrcweir SetDocumentModified(); 2254cdf0e10cSrcweir 2255cdf0e10cSrcweir if ( bEnable ) 2256cdf0e10cSrcweir { 2257cdf0e10cSrcweir aDocument.EndChangeTracking(); 2258cdf0e10cSrcweir aDocument.StartChangeTracking(); 2259cdf0e10cSrcweir 2260cdf0e10cSrcweir // hide accept or reject changes dialog 2261cdf0e10cSrcweir sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId(); 2262cdf0e10cSrcweir SfxViewFrame* pViewFrame = SfxViewFrame::Current(); 2263cdf0e10cSrcweir if ( pViewFrame && pViewFrame->HasChildWindow( nId ) ) 2264cdf0e10cSrcweir { 2265cdf0e10cSrcweir pViewFrame->ToggleChildWindow( nId ); 2266cdf0e10cSrcweir SfxBindings* pBindings = GetViewBindings(); 2267cdf0e10cSrcweir if ( pBindings ) 2268cdf0e10cSrcweir { 2269cdf0e10cSrcweir pBindings->Invalidate( FID_CHG_ACCEPT ); 2270cdf0e10cSrcweir } 2271cdf0e10cSrcweir } 2272cdf0e10cSrcweir } 2273cdf0e10cSrcweir else 2274cdf0e10cSrcweir { 2275cdf0e10cSrcweir aDocument.EndChangeTracking(); 2276cdf0e10cSrcweir } 2277cdf0e10cSrcweir 2278cdf0e10cSrcweir ScChangeViewSettings aChangeViewSet; 2279cdf0e10cSrcweir aChangeViewSet.SetShowChanges( sal_False ); 2280cdf0e10cSrcweir aDocument.SetChangeViewSettings( aChangeViewSet ); 2281cdf0e10cSrcweir } 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument() 2284cdf0e10cSrcweir { 2285cdf0e10cSrcweir uno::Reference< frame::XModel > xModel; 2286cdf0e10cSrcweir try 2287cdf0e10cSrcweir { 2288cdf0e10cSrcweir SC_MOD()->SetInSharedDocLoading( true ); 2289cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory( 2290cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 2291cdf0e10cSrcweir uno::Reference< frame::XComponentLoader > xLoader( 2292cdf0e10cSrcweir xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), 2293cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 2294cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aArgs( 1 ); 2295cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString::createFromAscii( "Hidden" ); 2296cdf0e10cSrcweir aArgs[0].Value <<= sal_True; 2297cdf0e10cSrcweir 2298cdf0e10cSrcweir if ( GetMedium() ) 2299cdf0e10cSrcweir { 2300cdf0e10cSrcweir SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False); 2301cdf0e10cSrcweir if ( pPasswordItem && pPasswordItem->GetValue().Len() ) 2302cdf0e10cSrcweir { 2303cdf0e10cSrcweir aArgs.realloc( 2 ); 2304cdf0e10cSrcweir aArgs[1].Name = ::rtl::OUString::createFromAscii( "Password" ); 2305cdf0e10cSrcweir aArgs[1].Value <<= ::rtl::OUString( pPasswordItem->GetValue() ); 2306cdf0e10cSrcweir } 2307cdf0e10cSrcweir } 2308cdf0e10cSrcweir 2309cdf0e10cSrcweir xModel.set( 2310cdf0e10cSrcweir xLoader->loadComponentFromURL( GetSharedFileURL(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0, aArgs ), 2311cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 2312cdf0e10cSrcweir SC_MOD()->SetInSharedDocLoading( false ); 2313cdf0e10cSrcweir } 2314cdf0e10cSrcweir catch ( uno::Exception& ) 2315cdf0e10cSrcweir { 2316cdf0e10cSrcweir DBG_ERROR( "ScDocShell::LoadSharedDocument(): caught exception\n" ); 2317cdf0e10cSrcweir SC_MOD()->SetInSharedDocLoading( false ); 2318cdf0e10cSrcweir try 2319cdf0e10cSrcweir { 2320cdf0e10cSrcweir uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW ); 2321cdf0e10cSrcweir xClose->close( sal_True ); 2322cdf0e10cSrcweir return uno::Reference< frame::XModel >(); 2323cdf0e10cSrcweir } 2324cdf0e10cSrcweir catch ( uno::Exception& ) 2325cdf0e10cSrcweir { 2326cdf0e10cSrcweir return uno::Reference< frame::XModel >(); 2327cdf0e10cSrcweir } 2328cdf0e10cSrcweir } 2329cdf0e10cSrcweir return xModel; 2330cdf0e10cSrcweir } 2331