1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10b3f79822SAndrew Rist *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19b3f79822SAndrew Rist *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // System - Includes -----------------------------------------------------
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir #ifndef PCH
32cdf0e10cSrcweir #include "scitems.hxx"
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <svx/pageitem.hxx>
35cdf0e10cSrcweir #include <vcl/virdev.hxx>
36cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir
39cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
40cdf0e10cSrcweir
41cdf0e10cSrcweir //#include <svxlink.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include "docsh.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include "stlsheet.hxx"
46cdf0e10cSrcweir #include "stlpool.hxx"
47cdf0e10cSrcweir #include "global.hxx"
48cdf0e10cSrcweir #include "viewdata.hxx"
49cdf0e10cSrcweir #include "tabvwsh.hxx"
50cdf0e10cSrcweir #include "tablink.hxx"
51cdf0e10cSrcweir #include "collect.hxx"
52cdf0e10cSrcweir
53cdf0e10cSrcweir struct ScStylePair
54cdf0e10cSrcweir {
55cdf0e10cSrcweir SfxStyleSheetBase *pSource;
56cdf0e10cSrcweir SfxStyleSheetBase *pDest;
57cdf0e10cSrcweir };
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
61cdf0e10cSrcweir
62cdf0e10cSrcweir //----------------------------------------------------------------------
63cdf0e10cSrcweir
64cdf0e10cSrcweir //
65cdf0e10cSrcweir // Ole
66cdf0e10cSrcweir //
67cdf0e10cSrcweir
SetVisArea(const Rectangle & rVisArea)68cdf0e10cSrcweir void __EXPORT ScDocShell::SetVisArea( const Rectangle & rVisArea )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir // with the SnapVisArea call in SetVisAreaOrSize, it's safe to always
71cdf0e10cSrcweir // use both the size and position of the VisArea
72cdf0e10cSrcweir SetVisAreaOrSize( rVisArea, sal_True );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
lcl_SetTopRight(Rectangle & rRect,const Point & rPos)75cdf0e10cSrcweir void lcl_SetTopRight( Rectangle& rRect, const Point& rPos )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir Size aSize = rRect.GetSize();
78cdf0e10cSrcweir rRect.Right() = rPos.X();
79cdf0e10cSrcweir rRect.Left() = rPos.X() - aSize.Width() + 1;
80cdf0e10cSrcweir rRect.Top() = rPos.Y();
81cdf0e10cSrcweir rRect.Bottom() = rPos.Y() + aSize.Height() - 1;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
SetVisAreaOrSize(const Rectangle & rVisArea,sal_Bool bModifyStart)84cdf0e10cSrcweir void ScDocShell::SetVisAreaOrSize( const Rectangle& rVisArea, sal_Bool bModifyStart )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir sal_Bool bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() );
87cdf0e10cSrcweir
88cdf0e10cSrcweir Rectangle aArea = rVisArea;
89cdf0e10cSrcweir if (bModifyStart)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir // when loading, don't check for negative values, because the sheet orientation
92cdf0e10cSrcweir // might be set later
93cdf0e10cSrcweir if ( !aDocument.IsImportingXML() )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir if ( ( bNegativePage ? (aArea.Right() > 0) : (aArea.Left() < 0) ) || aArea.Top() < 0 )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir // VisArea start position can't be negative.
98cdf0e10cSrcweir // Move the VisArea, otherwise only the upper left position would
99cdf0e10cSrcweir // be changed in SnapVisArea, and the size would be wrong.
100cdf0e10cSrcweir
101cdf0e10cSrcweir Point aNewPos( 0, Max( aArea.Top(), (long) 0 ) );
102cdf0e10cSrcweir if ( bNegativePage )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir aNewPos.X() = Min( aArea.Right(), (long) 0 );
105cdf0e10cSrcweir lcl_SetTopRight( aArea, aNewPos );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir else
108cdf0e10cSrcweir {
109cdf0e10cSrcweir aNewPos.X() = Max( aArea.Left(), (long) 0 );
110cdf0e10cSrcweir aArea.SetPos( aNewPos );
111cdf0e10cSrcweir }
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir else
116cdf0e10cSrcweir {
117cdf0e10cSrcweir Rectangle aOldVisArea = SfxObjectShell::GetVisArea();
118cdf0e10cSrcweir if ( bNegativePage )
119cdf0e10cSrcweir lcl_SetTopRight( aArea, aOldVisArea.TopRight() );
120cdf0e10cSrcweir else
121cdf0e10cSrcweir aArea.SetPos( aOldVisArea.TopLeft() );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir // hier Position anpassen!
125cdf0e10cSrcweir
126cdf0e10cSrcweir // #92248# when loading an ole object, the VisArea is set from the document's
127cdf0e10cSrcweir // view settings and must be used as-is (document content may not be complete yet).
128cdf0e10cSrcweir if ( !aDocument.IsImportingXML() )
129cdf0e10cSrcweir aDocument.SnapVisArea( aArea );
130cdf0e10cSrcweir
131cdf0e10cSrcweir //TODO/LATER: it's unclear which IPEnv is used here
132cdf0e10cSrcweir /*
133cdf0e10cSrcweir SvInPlaceEnvironment* pEnv = GetIPEnv();
134cdf0e10cSrcweir if (pEnv)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir Window* pWin = pEnv->GetEditWin();
137cdf0e10cSrcweir pEnv->MakeScale( aArea.GetSize(), MAP_100TH_MM,
138cdf0e10cSrcweir pWin->LogicToPixel( aArea.GetSize() ) );
139cdf0e10cSrcweir } */
140cdf0e10cSrcweir
141cdf0e10cSrcweir //TODO/LATER: formerly in SvInplaceObject
142cdf0e10cSrcweir SfxObjectShell::SetVisArea( aArea );
143cdf0e10cSrcweir
144cdf0e10cSrcweir if (bIsInplace) // Zoom in der InPlace View einstellen
145cdf0e10cSrcweir {
146cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
147cdf0e10cSrcweir if (pViewSh)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir if (pViewSh->GetViewData()->GetDocShell() == this)
150cdf0e10cSrcweir pViewSh->UpdateOleZoom();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir //else
153cdf0e10cSrcweir // DataChanged( SvDataType() ); // fuer Zuppeln wenn nicht IP-aktiv
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir if (aDocument.IsEmbedded())
157cdf0e10cSrcweir {
158cdf0e10cSrcweir ScRange aOld;
159cdf0e10cSrcweir aDocument.GetEmbedded( aOld);
160cdf0e10cSrcweir aDocument.SetEmbedded( aArea );
161cdf0e10cSrcweir ScRange aNew;
162cdf0e10cSrcweir aDocument.GetEmbedded( aNew);
163cdf0e10cSrcweir if (aOld != aNew)
164cdf0e10cSrcweir PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_GRID);
165cdf0e10cSrcweir
166cdf0e10cSrcweir //TODO/LATER: currently not implemented
167cdf0e10cSrcweir //ViewChanged( ASPECT_CONTENT ); // auch im Container anzeigen
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
IsOle()171cdf0e10cSrcweir sal_Bool ScDocShell::IsOle()
172cdf0e10cSrcweir {
173cdf0e10cSrcweir return (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
UpdateOle(const ScViewData * pViewData,sal_Bool bSnapSize)176cdf0e10cSrcweir void ScDocShell::UpdateOle( const ScViewData* pViewData, sal_Bool bSnapSize )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir // wenn's gar nicht Ole ist, kann man sich die Berechnungen sparen
179cdf0e10cSrcweir // (VisArea wird dann beim Save wieder zurueckgesetzt)
180cdf0e10cSrcweir
181cdf0e10cSrcweir if (GetCreateMode() == SFX_CREATE_MODE_STANDARD)
182cdf0e10cSrcweir return;
183cdf0e10cSrcweir
184cdf0e10cSrcweir DBG_ASSERT(pViewData,"pViewData==0 bei ScDocShell::UpdateOle");
185cdf0e10cSrcweir
186cdf0e10cSrcweir Rectangle aOldArea = SfxObjectShell::GetVisArea();
187cdf0e10cSrcweir Rectangle aNewArea = aOldArea;
188cdf0e10cSrcweir
189cdf0e10cSrcweir sal_Bool bChange = sal_False;
190cdf0e10cSrcweir sal_Bool bEmbedded = aDocument.IsEmbedded();
191cdf0e10cSrcweir if (bEmbedded)
192cdf0e10cSrcweir aNewArea = aDocument.GetEmbeddedRect();
193cdf0e10cSrcweir else
194cdf0e10cSrcweir {
195cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo();
196cdf0e10cSrcweir if ( nTab != aDocument.GetVisibleTab() )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir aDocument.SetVisibleTab( nTab );
199cdf0e10cSrcweir bChange = sal_True;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir sal_Bool bNegativePage = aDocument.IsNegativePage( nTab );
203cdf0e10cSrcweir SCCOL nX = pViewData->GetPosX(SC_SPLIT_LEFT);
204cdf0e10cSrcweir SCROW nY = pViewData->GetPosY(SC_SPLIT_BOTTOM);
205cdf0e10cSrcweir Rectangle aMMRect = aDocument.GetMMRect( nX,nY, nX,nY, nTab );
206cdf0e10cSrcweir if (bNegativePage)
207cdf0e10cSrcweir lcl_SetTopRight( aNewArea, aMMRect.TopRight() );
208cdf0e10cSrcweir else
209cdf0e10cSrcweir aNewArea.SetPos( aMMRect.TopLeft() );
210cdf0e10cSrcweir if (bSnapSize)
211cdf0e10cSrcweir aDocument.SnapVisArea(aNewArea); // uses the new VisibleTab
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir if (aNewArea != aOldArea)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir SetVisAreaOrSize( aNewArea, sal_True ); // hier muss auch der Start angepasst werden
217cdf0e10cSrcweir bChange = sal_True;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir // if (bChange)
221cdf0e10cSrcweir // DataChanged( SvDataType() ); //! passiert auch bei SetModified
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir //
225cdf0e10cSrcweir // Style-Krempel fuer Organizer etc.
226cdf0e10cSrcweir //
227cdf0e10cSrcweir
GetStyleSheetPool()228cdf0e10cSrcweir SfxStyleSheetBasePool* __EXPORT ScDocShell::GetStyleSheetPool()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir return (SfxStyleSheetBasePool*)aDocument.GetStyleSheetPool();
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
233cdf0e10cSrcweir
234cdf0e10cSrcweir // nach dem Laden von Vorlagen aus einem anderen Dokment (LoadStyles, Insert)
235cdf0e10cSrcweir // muessen die SetItems (ATTR_PAGE_HEADERSET, ATTR_PAGE_FOOTERSET) auf den richtigen
236cdf0e10cSrcweir // Pool umgesetzt werden, bevor der Quell-Pool geloescht wird.
237cdf0e10cSrcweir
lcl_AdjustPool(SfxStyleSheetBasePool * pStylePool)238cdf0e10cSrcweir void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, 0xffff);
241cdf0e10cSrcweir SfxStyleSheetBase *pStyle = pStylePool->First();
242cdf0e10cSrcweir while ( pStyle )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir SfxItemSet& rStyleSet = pStyle->GetItemSet();
245cdf0e10cSrcweir
246cdf0e10cSrcweir const SfxPoolItem* pItem;
247cdf0e10cSrcweir if (rStyleSet.GetItemState(ATTR_PAGE_HEADERSET,sal_False,&pItem) == SFX_ITEM_SET)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
250cdf0e10cSrcweir SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
251cdf0e10cSrcweir pDestSet->Put(rSrcSet);
252cdf0e10cSrcweir rStyleSet.Put(SvxSetItem(ATTR_PAGE_HEADERSET,pDestSet));
253cdf0e10cSrcweir }
254cdf0e10cSrcweir if (rStyleSet.GetItemState(ATTR_PAGE_FOOTERSET,sal_False,&pItem) == SFX_ITEM_SET)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
257cdf0e10cSrcweir SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
258cdf0e10cSrcweir pDestSet->Put(rSrcSet);
259cdf0e10cSrcweir rStyleSet.Put(SvxSetItem(ATTR_PAGE_FOOTERSET,pDestSet));
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir pStyle = pStylePool->Next();
263cdf0e10cSrcweir }
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
LoadStyles(SfxObjectShell & rSource)266cdf0e10cSrcweir void __EXPORT ScDocShell::LoadStyles( SfxObjectShell &rSource )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir aDocument.StylesToNames();
269cdf0e10cSrcweir
270cdf0e10cSrcweir SfxObjectShell::LoadStyles(rSource);
271cdf0e10cSrcweir lcl_AdjustPool( GetStyleSheetPool() ); // SetItems anpassen
272cdf0e10cSrcweir
273cdf0e10cSrcweir aDocument.UpdStlShtPtrsFrmNms();
274cdf0e10cSrcweir
275cdf0e10cSrcweir UpdateAllRowHeights();
276cdf0e10cSrcweir
277cdf0e10cSrcweir // Paint
278cdf0e10cSrcweir
279cdf0e10cSrcweir PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
LoadStylesArgs(ScDocShell & rSource,sal_Bool bReplace,sal_Bool bCellStyles,sal_Bool bPageStyles)282cdf0e10cSrcweir void ScDocShell::LoadStylesArgs( ScDocShell& rSource, sal_Bool bReplace, sal_Bool bCellStyles, sal_Bool bPageStyles )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir // similar to LoadStyles, but with selectable behavior for XStyleLoader::loadStylesFromURL call
285cdf0e10cSrcweir
286cdf0e10cSrcweir if ( !bCellStyles && !bPageStyles ) // nothing to do
287cdf0e10cSrcweir return;
288cdf0e10cSrcweir
289cdf0e10cSrcweir ScStyleSheetPool* pSourcePool = rSource.GetDocument()->GetStyleSheetPool();
290cdf0e10cSrcweir ScStyleSheetPool* pDestPool = aDocument.GetStyleSheetPool();
291cdf0e10cSrcweir
292cdf0e10cSrcweir SfxStyleFamily eFamily = bCellStyles ?
293cdf0e10cSrcweir ( bPageStyles ? SFX_STYLE_FAMILY_ALL : SFX_STYLE_FAMILY_PARA ) :
294cdf0e10cSrcweir SFX_STYLE_FAMILY_PAGE;
295cdf0e10cSrcweir SfxStyleSheetIterator aIter( pSourcePool, eFamily );
296cdf0e10cSrcweir sal_uInt16 nSourceCount = aIter.Count();
297cdf0e10cSrcweir if ( nSourceCount == 0 )
298cdf0e10cSrcweir return; // no source styles
299cdf0e10cSrcweir
300cdf0e10cSrcweir ScStylePair* pStyles = new ScStylePair[ nSourceCount ];
301cdf0e10cSrcweir sal_uInt16 nFound = 0;
302cdf0e10cSrcweir
303cdf0e10cSrcweir // first create all new styles
304cdf0e10cSrcweir
305cdf0e10cSrcweir SfxStyleSheetBase* pSourceStyle = aIter.First();
306cdf0e10cSrcweir while (pSourceStyle)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir String aName = pSourceStyle->GetName();
309cdf0e10cSrcweir SfxStyleSheetBase* pDestStyle = pDestPool->Find( pSourceStyle->GetName(), pSourceStyle->GetFamily() );
310cdf0e10cSrcweir if ( pDestStyle )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir // touch existing styles only if replace flag is set
313cdf0e10cSrcweir if ( bReplace )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir pStyles[nFound].pSource = pSourceStyle;
316cdf0e10cSrcweir pStyles[nFound].pDest = pDestStyle;
317cdf0e10cSrcweir ++nFound;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir else
321cdf0e10cSrcweir {
322cdf0e10cSrcweir pStyles[nFound].pSource = pSourceStyle;
323cdf0e10cSrcweir pStyles[nFound].pDest = &pDestPool->Make( aName, pSourceStyle->GetFamily(), pSourceStyle->GetMask() );
324cdf0e10cSrcweir ++nFound;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir pSourceStyle = aIter.Next();
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
330cdf0e10cSrcweir // then copy contents (after inserting all styles, for parent etc.)
331cdf0e10cSrcweir
332cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nFound; ++i )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir pStyles[i].pDest->GetItemSet().PutExtended(
335cdf0e10cSrcweir pStyles[i].pSource->GetItemSet(), SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT);
336cdf0e10cSrcweir if(pStyles[i].pSource->HasParentSupport())
337cdf0e10cSrcweir pStyles[i].pDest->SetParent(pStyles[i].pSource->GetParent());
338cdf0e10cSrcweir // follow is never used
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
341cdf0e10cSrcweir lcl_AdjustPool( GetStyleSheetPool() ); // adjust SetItems
342cdf0e10cSrcweir UpdateAllRowHeights();
343cdf0e10cSrcweir PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT ); // Paint
344cdf0e10cSrcweir
345cdf0e10cSrcweir delete[] pStyles;
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir
Insert(SfxObjectShell & rSource,sal_uInt16 nSourceIdx1,sal_uInt16 nSourceIdx2,sal_uInt16 nSourceIdx3,sal_uInt16 & nIdx1,sal_uInt16 & nIdx2,sal_uInt16 & nIdx3,sal_uInt16 & rIdxDeleted)349cdf0e10cSrcweir sal_Bool __EXPORT ScDocShell::Insert( SfxObjectShell &rSource,
350cdf0e10cSrcweir sal_uInt16 nSourceIdx1, sal_uInt16 nSourceIdx2, sal_uInt16 nSourceIdx3,
351cdf0e10cSrcweir sal_uInt16 &nIdx1, sal_uInt16 &nIdx2, sal_uInt16 &nIdx3, sal_uInt16 &rIdxDeleted )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::Insert( rSource, nSourceIdx1, nSourceIdx2, nSourceIdx3,
354cdf0e10cSrcweir nIdx1, nIdx2, nIdx3, rIdxDeleted );
355cdf0e10cSrcweir if (bRet)
356cdf0e10cSrcweir lcl_AdjustPool( GetStyleSheetPool() ); // SetItems anpassen
357cdf0e10cSrcweir
358cdf0e10cSrcweir return bRet;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
UpdateLinks()361cdf0e10cSrcweir void ScDocShell::UpdateLinks()
362cdf0e10cSrcweir {
363cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
364cdf0e10cSrcweir ScStrCollection aNames;
365cdf0e10cSrcweir
366cdf0e10cSrcweir // nicht mehr benutzte Links raus
367cdf0e10cSrcweir
368cdf0e10cSrcweir sal_uInt16 nCount = pLinkManager->GetLinks().Count();
369cdf0e10cSrcweir for (sal_uInt16 k=nCount; k>0; )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir --k;
372cdf0e10cSrcweir ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[k];
373cdf0e10cSrcweir if (pBase->ISA(ScTableLink))
374cdf0e10cSrcweir {
375cdf0e10cSrcweir ScTableLink* pTabLink = (ScTableLink*)pBase;
376cdf0e10cSrcweir if (pTabLink->IsUsed())
377cdf0e10cSrcweir {
378cdf0e10cSrcweir StrData* pData = new StrData(pTabLink->GetFileName());
379cdf0e10cSrcweir if (!aNames.Insert(pData))
380cdf0e10cSrcweir delete pData;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir else // nicht mehr benutzt -> loeschen
383cdf0e10cSrcweir {
384cdf0e10cSrcweir pTabLink->SetAddUndo(sal_True);
385cdf0e10cSrcweir pLinkManager->Remove(k);
386cdf0e10cSrcweir }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir
391cdf0e10cSrcweir // neue Links eintragen
392cdf0e10cSrcweir
393cdf0e10cSrcweir SCTAB nTabCount = aDocument.GetTableCount();
394cdf0e10cSrcweir for (SCTAB i=0; i<nTabCount; i++)
395cdf0e10cSrcweir if (aDocument.IsLinked(i))
396cdf0e10cSrcweir {
397cdf0e10cSrcweir String aDocName = aDocument.GetLinkDoc(i);
398cdf0e10cSrcweir String aFltName = aDocument.GetLinkFlt(i);
399cdf0e10cSrcweir String aOptions = aDocument.GetLinkOpt(i);
400cdf0e10cSrcweir sal_uLong nRefresh = aDocument.GetLinkRefreshDelay(i);
401cdf0e10cSrcweir sal_Bool bThere = sal_False;
402cdf0e10cSrcweir for (SCTAB j=0; j<i && !bThere; j++) // im Dokument mehrfach?
403cdf0e10cSrcweir if (aDocument.IsLinked(j)
404cdf0e10cSrcweir && aDocument.GetLinkDoc(j) == aDocName
405cdf0e10cSrcweir && aDocument.GetLinkFlt(j) == aFltName
406cdf0e10cSrcweir && aDocument.GetLinkOpt(j) == aOptions)
407cdf0e10cSrcweir // Ignore refresh delay in compare, it should be the
408cdf0e10cSrcweir // same for identical links and we don't want dupes
409cdf0e10cSrcweir // if it ain't.
410cdf0e10cSrcweir bThere = sal_True;
411cdf0e10cSrcweir
412cdf0e10cSrcweir if (!bThere) // schon als Filter eingetragen?
413cdf0e10cSrcweir {
414cdf0e10cSrcweir StrData* pData = new StrData(aDocName);
415cdf0e10cSrcweir if (!aNames.Insert(pData))
416cdf0e10cSrcweir {
417cdf0e10cSrcweir delete pData;
418cdf0e10cSrcweir bThere = sal_True;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir }
421cdf0e10cSrcweir if (!bThere)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir ScTableLink* pLink = new ScTableLink( this, aDocName, aFltName, aOptions, nRefresh );
424cdf0e10cSrcweir pLink->SetInCreate( sal_True );
425cdf0e10cSrcweir pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName );
426cdf0e10cSrcweir pLink->Update();
427cdf0e10cSrcweir pLink->SetInCreate( sal_False );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir }
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
ReloadTabLinks()432cdf0e10cSrcweir sal_Bool ScDocShell::ReloadTabLinks()
433cdf0e10cSrcweir {
434cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
435cdf0e10cSrcweir
436cdf0e10cSrcweir sal_Bool bAny = sal_False;
437cdf0e10cSrcweir sal_uInt16 nCount = pLinkManager->GetLinks().Count();
438cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++ )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
441cdf0e10cSrcweir if (pBase->ISA(ScTableLink))
442cdf0e10cSrcweir {
443cdf0e10cSrcweir ScTableLink* pTabLink = (ScTableLink*)pBase;
444cdf0e10cSrcweir // pTabLink->SetAddUndo(sal_False); //! Undo's zusammenfassen
445*06fcc994SAriel Constenla-Haile // Painting only after Update() makes no sense:
446*06fcc994SAriel Constenla-Haile // ScTableLink::Refresh() will post a Paint only is bDoPaint is true
447*06fcc994SAriel Constenla-Haile //pTabLink->SetPaint(sal_False); // Paint nur einmal am Ende
448cdf0e10cSrcweir pTabLink->Update();
449*06fcc994SAriel Constenla-Haile //pTabLink->SetPaint(sal_True);
450cdf0e10cSrcweir // pTabLink->SetAddUndo(sal_True);
451cdf0e10cSrcweir bAny = sal_True;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir if ( bAny )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir // Paint nur einmal
458cdf0e10cSrcweir PostPaint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB),
459cdf0e10cSrcweir PAINT_GRID | PAINT_TOP | PAINT_LEFT );
460cdf0e10cSrcweir
461cdf0e10cSrcweir SetDocumentModified();
462cdf0e10cSrcweir }
463cdf0e10cSrcweir
464cdf0e10cSrcweir return sal_True; //! Fehler erkennen
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir
468