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