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