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