xref: /aoo41x/main/sfx2/source/view/orgmgr.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_sfx2.hxx"
30*cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
35*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #include <tools/urlobj.hxx>
38*cdf0e10cSrcweir #ifndef GCC
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
42*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #include <unotools/intlwrapper.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <sfx2/app.hxx>
49*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
50*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
51*cdf0e10cSrcweir #include <sfx2/docfac.hxx>
52*cdf0e10cSrcweir #include <sfx2/doctempl.hxx>
53*cdf0e10cSrcweir #include "docvor.hxx"
54*cdf0e10cSrcweir #include "orgmgr.hxx"
55*cdf0e10cSrcweir #include "sfxtypes.hxx"
56*cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
57*cdf0e10cSrcweir #include "view.hrc"
58*cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
59*cdf0e10cSrcweir #include "fltfnc.hxx"
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir using namespace ::com::sun::star;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir //=========================================================================
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir /*  [Beschreibung]
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 	Implementierungsklasse; einzelner Eintrag in der Dateiansicht
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir */
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir struct _FileListEntry
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	String aFileName;			// Dateiname mit komplettem Pfad
74*cdf0e10cSrcweir 	String aBaseName;			// Dateiname
75*cdf0e10cSrcweir 	const CollatorWrapper* pCollator;
76*cdf0e10cSrcweir 	SfxObjectShellLock aDocShell; // ObjectShell als Ref-Klasse
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir //REMOVE		SvStorageRef aStor;			// Referenz auf Storage, wenn wir diesen geoeffnet haben
79*cdf0e10cSrcweir     //uno::Reference< embed::XStorage > xStorage;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	sal_Bool bFile;					// als Datei auf Platte
82*cdf0e10cSrcweir 								// (!= unbenannt1, nicht als Dok. geladen;
83*cdf0e10cSrcweir 								// diese werden nicht gespeichert!)
84*cdf0e10cSrcweir 	sal_Bool bOwner;				// selbst erzeugt
85*cdf0e10cSrcweir 	sal_Bool bNoName;
86*cdf0e10cSrcweir     sal_Bool bOwnFormat;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	_FileListEntry( const String& rFileName,
89*cdf0e10cSrcweir 					const CollatorWrapper* pColl, const String* pTitle = NULL );
90*cdf0e10cSrcweir 	~_FileListEntry();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	int operator==( const _FileListEntry &rCmp) const;
93*cdf0e10cSrcweir 	int operator< ( const _FileListEntry &rCmp) const;
94*cdf0e10cSrcweir 	sal_Bool DeleteObjectShell();
95*cdf0e10cSrcweir };
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir //-------------------------------------------------------------------------
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir inline int _FileListEntry::operator==(const _FileListEntry &rCmp) const
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	DBG_ASSERT( pCollator, "invalid CollatorWrapper" );
102*cdf0e10cSrcweir 	return COMPARE_EQUAL == pCollator->compareString(aBaseName, rCmp.aBaseName);
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir //-------------------------------------------------------------------------
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir inline int _FileListEntry::operator< (const _FileListEntry &rCmp) const
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir 	DBG_ASSERT( pCollator, "invalid CollatorWrapper" );
110*cdf0e10cSrcweir 	return COMPARE_LESS == pCollator->compareString(aBaseName, rCmp.aBaseName);
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir //-------------------------------------------------------------------------
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir _FileListEntry::_FileListEntry( const String& rFileName,
116*cdf0e10cSrcweir 								const CollatorWrapper* pColl, const String* pTitle ) :
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     aFileName   ( rFileName ),
119*cdf0e10cSrcweir     pCollator   ( pColl ),
120*cdf0e10cSrcweir     bFile       ( sal_False ),
121*cdf0e10cSrcweir     bOwner      ( sal_False ),
122*cdf0e10cSrcweir     bNoName     ( sal_True ),
123*cdf0e10cSrcweir     bOwnFormat  ( sal_True )
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	if ( pTitle )
126*cdf0e10cSrcweir 		aBaseName = *pTitle;
127*cdf0e10cSrcweir 	else
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		INetURLObject aObj( rFileName, INET_PROT_FILE );
130*cdf0e10cSrcweir 		aBaseName = aObj.getName( INetURLObject::LAST_SEGMENT, true,
131*cdf0e10cSrcweir 								  INetURLObject::DECODE_WITH_CHARSET );
132*cdf0e10cSrcweir 	}
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir //-------------------------------------------------------------------------
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir _FileListEntry::~_FileListEntry()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	DeleteObjectShell();
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir //-------------------------------------------------------------------------
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT(_SfxObjectList, _FileListEntry*)
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir //=========================================================================
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir sal_Bool _FileListEntry::DeleteObjectShell()
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir /*  [Beschreibung]
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	Freigabe der DokumentShell
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	[Returnwert]			sal_True: alles Ok
155*cdf0e10cSrcweir 							sal_False: es ist ein Fehler aufgetreten (das
156*cdf0e10cSrcweir 							Dokument konnte nicht gesichert werden)
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir */
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
162*cdf0e10cSrcweir 	//Falls wir die Shell angelegt haben und sie veraendert wurde
163*cdf0e10cSrcweir 	if(bOwner && aDocShell.Is() && aDocShell->IsModified())
164*cdf0e10cSrcweir 	{
165*cdf0e10cSrcweir 		//Mussten wir konvertieren?
166*cdf0e10cSrcweir         if( bOwnFormat )
167*cdf0e10cSrcweir 		{
168*cdf0e10cSrcweir 			if(!aDocShell->Save() )
169*cdf0e10cSrcweir 				bRet = sal_False;
170*cdf0e10cSrcweir 			else
171*cdf0e10cSrcweir 			{
172*cdf0e10cSrcweir 				try {
173*cdf0e10cSrcweir                     uno::Reference< embed::XTransactedObject > xTransact( aDocShell->GetStorage(), uno::UNO_QUERY );
174*cdf0e10cSrcweir 					OSL_ENSURE( xTransact.is(), "Storage must implement XTransactedObject!\n" );
175*cdf0e10cSrcweir 					if ( !xTransact.is() )
176*cdf0e10cSrcweir 						throw uno::RuntimeException();
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 					xTransact->commit();
179*cdf0e10cSrcweir 				}
180*cdf0e10cSrcweir 				catch( uno::Exception& )
181*cdf0e10cSrcweir 				{
182*cdf0e10cSrcweir 				}
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir //				aDocShell->SfxObjectShell::DoSaveCompleted();
185*cdf0e10cSrcweir 			}
186*cdf0e10cSrcweir 		}
187*cdf0e10cSrcweir 		else
188*cdf0e10cSrcweir 		{
189*cdf0e10cSrcweir 			// Falls konvertiert im eigenen Format speichern
190*cdf0e10cSrcweir 			INetURLObject aObj( aFileName );
191*cdf0e10cSrcweir 			String aTitle = aObj.getName( INetURLObject::LAST_SEGMENT, true,
192*cdf0e10cSrcweir 										  INetURLObject::DECODE_WITH_CHARSET );
193*cdf0e10cSrcweir 			bRet = aDocShell->PreDoSaveAs_Impl(
194*cdf0e10cSrcweir                         aTitle, aDocShell->GetFactory().GetFilterContainer()->GetAnyFilter( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT )->GetFilterName(), 0 );
195*cdf0e10cSrcweir 		}
196*cdf0e10cSrcweir 	}
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	if( bOwner)
199*cdf0e10cSrcweir 	{
200*cdf0e10cSrcweir 		aDocShell.Clear();
201*cdf0e10cSrcweir 	}
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 	return bRet;
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir //-------------------------------------------------------------------------
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir SfxObjectList::SfxObjectList()
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir //-------------------------------------------------------------------------
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir SfxObjectList::~SfxObjectList()
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	DeleteAndDestroy(0, Count());
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir //-------------------------------------------------------------------------
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir const String &SfxObjectList::GetBaseName(sal_uInt16 i) const
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	return (*this)[i]->aBaseName;
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir //-------------------------------------------------------------------------
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir const String& SfxObjectList::GetFileName( sal_uInt16 i ) const
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir 	return (*this)[i]->aFileName;
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir //-------------------------------------------------------------------------
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir SfxOrganizeMgr::SfxOrganizeMgr( SfxOrganizeListBox_Impl *pLeft,
236*cdf0e10cSrcweir 								SfxOrganizeListBox_Impl *pRight,
237*cdf0e10cSrcweir 								SfxDocumentTemplates *pTempl) :
238*cdf0e10cSrcweir 	pImpl(new SfxOrganizeMgr_Impl),
239*cdf0e10cSrcweir 	pTemplates(pTempl? pTempl: new SfxDocumentTemplates),
240*cdf0e10cSrcweir 	pLeftBox(pLeft),
241*cdf0e10cSrcweir 	pRightBox(pRight),
242*cdf0e10cSrcweir 	bDeleteTemplates(pTempl == 0),
243*cdf0e10cSrcweir 	bModified(0)
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir /*  [Beschreibung]
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 	Konstruktor
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	Das aktuelle Dokument wird in die Liste der Dokumente
250*cdf0e10cSrcweir 	aufgenommen.
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir */
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir 	pImpl->pDocList = new SfxObjectList;
255*cdf0e10cSrcweir 	pImpl->pIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
256*cdf0e10cSrcweir 	const CollatorWrapper* pCollator = pImpl->pIntlWrapper->getCaseCollator();
257*cdf0e10cSrcweir 	for ( SfxObjectShell* pTmp = SfxObjectShell::GetFirst(); pTmp; pTmp = SfxObjectShell::GetNext(*pTmp) )
258*cdf0e10cSrcweir 	{
259*cdf0e10cSrcweir 		if ( pTmp->GetCreateMode() != SFX_CREATE_MODE_STANDARD ||
260*cdf0e10cSrcweir 			 !( pTmp->GetFlags() & SFXOBJECTSHELL_HASOPENDOC ) || !pTmp->GetStyleSheetPool() )
261*cdf0e10cSrcweir 			continue;
262*cdf0e10cSrcweir 		_FileListEntry* pNewEntry = NULL;
263*cdf0e10cSrcweir 		String aTitle = pTmp->GetTitle( SFX_TITLE_TITLE );
264*cdf0e10cSrcweir         pNewEntry = new _FileListEntry( pTmp->GetMedium()->GetName(), pCollator, &aTitle );
265*cdf0e10cSrcweir 		pNewEntry->aDocShell = pTmp;
266*cdf0e10cSrcweir 		pImpl->pDocList->C40_PTR_INSERT( _FileListEntry, pNewEntry );
267*cdf0e10cSrcweir 	}
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir //-------------------------------------------------------------------------
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir SfxOrganizeMgr::~SfxOrganizeMgr()
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir 	if ( bDeleteTemplates )
275*cdf0e10cSrcweir 		delete pTemplates;
276*cdf0e10cSrcweir 	delete pImpl->pDocList;
277*cdf0e10cSrcweir 	delete pImpl->pIntlWrapper;
278*cdf0e10cSrcweir 	delete pImpl;
279*cdf0e10cSrcweir 	pLeftBox = pRightBox = NULL;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir //-------------------------------------------------------------------------
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir SfxObjectShellRef SfxOrganizeMgr::CreateObjectShell( sal_uInt16 nIdx )
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir /*  [Beschreibung]
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 	Zugriff auf die DokumentShell an der Position nIdx
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	[Returnwert]			Referenz auf die DokumentShell
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir */
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir 	_FileListEntry* pEntry = (*pImpl->pDocList)[nIdx];
296*cdf0e10cSrcweir 	// andernfalls Doc-Shell anlegen
297*cdf0e10cSrcweir 	if ( !pEntry->aDocShell.Is() )
298*cdf0e10cSrcweir 	{
299*cdf0e10cSrcweir //(mba)/task        SfxWaitCursor aWaitCursor;
300*cdf0e10cSrcweir 		INetURLObject aFileObj( pEntry->aFileName );
301*cdf0e10cSrcweir 		sal_Bool bDum = sal_False;
302*cdf0e10cSrcweir 		SfxApplication* pSfxApp = SFX_APP();
303*cdf0e10cSrcweir         String aFilePath = aFileObj.GetMainURL( INetURLObject::NO_DECODE );
304*cdf0e10cSrcweir 		pEntry->aDocShell = pSfxApp->DocAlreadyLoaded( aFilePath, sal_False, bDum );
305*cdf0e10cSrcweir 		if ( !pEntry->aDocShell.Is() )
306*cdf0e10cSrcweir 		{
307*cdf0e10cSrcweir 			pEntry->bOwner = sal_True;
308*cdf0e10cSrcweir 			SfxMedium* pMed = new SfxMedium(
309*cdf0e10cSrcweir 				aFilePath, ( STREAM_READ | STREAM_SHARE_DENYWRITE ), sal_False, 0 );
310*cdf0e10cSrcweir 			const SfxFilter* pFilter = NULL;
311*cdf0e10cSrcweir             pMed->UseInteractionHandler(sal_True);
312*cdf0e10cSrcweir 			if (
313*cdf0e10cSrcweir                 pSfxApp->GetFilterMatcher().GuessFilter(*pMed, &pFilter, SFX_FILTER_TEMPLATE, 0) ||
314*cdf0e10cSrcweir 				(pFilter && !pFilter->IsOwnFormat()) ||
315*cdf0e10cSrcweir 				(pFilter && !pFilter->UsesStorage())
316*cdf0e10cSrcweir                )
317*cdf0e10cSrcweir 			{
318*cdf0e10cSrcweir 				pSfxApp->LoadTemplate( pEntry->aDocShell, aFilePath );
319*cdf0e10cSrcweir                 pEntry->bOwnFormat = sal_False;
320*cdf0e10cSrcweir 				delete pMed;
321*cdf0e10cSrcweir 				if ( pEntry->aDocShell.Is() )
322*cdf0e10cSrcweir 					return (SfxObjectShellRef)(SfxObjectShell*)(pEntry->aDocShell);
323*cdf0e10cSrcweir 			}
324*cdf0e10cSrcweir 			else
325*cdf0e10cSrcweir 			{
326*cdf0e10cSrcweir 				if ( pFilter )
327*cdf0e10cSrcweir 				{
328*cdf0e10cSrcweir                     pEntry->bOwnFormat = sal_True;
329*cdf0e10cSrcweir 					pEntry->aDocShell = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_ORGANIZER );
330*cdf0e10cSrcweir 					if ( pEntry->aDocShell.Is() )
331*cdf0e10cSrcweir 					{
332*cdf0e10cSrcweir 						pEntry->aDocShell->DoInitNew(0);
333*cdf0e10cSrcweir                         pEntry->aDocShell->LoadFrom( *pMed );
334*cdf0e10cSrcweir                         // Medium is now owned by DocShell
335*cdf0e10cSrcweir                         pEntry->aDocShell->DoSaveCompleted( pMed );
336*cdf0e10cSrcweir 					}
337*cdf0e10cSrcweir 				}
338*cdf0e10cSrcweir 			}
339*cdf0e10cSrcweir 		}
340*cdf0e10cSrcweir 	}
341*cdf0e10cSrcweir 	return ( SfxObjectShellRef )(SfxObjectShell*)(pEntry->aDocShell);
342*cdf0e10cSrcweir }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir //-------------------------------------------------------------------------
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::DeleteObjectShell(sal_uInt16 nIdx)
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir /*  [Beschreibung]
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	Freigabe der DokumentShell an der Position nIdx
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	[Returnwert]			sal_True: alles Ok
353*cdf0e10cSrcweir 							sal_False: es ist ein Fehler aufgetreten (das
354*cdf0e10cSrcweir 							Dokument konnte nicht gesichert werden)
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir */
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir 	return (*pImpl->pDocList)[nIdx]->DeleteObjectShell();
359*cdf0e10cSrcweir }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir //-------------------------------------------------------------------------
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir SfxObjectShellRef SfxOrganizeMgr::CreateObjectShell(sal_uInt16 nRegion,
364*cdf0e10cSrcweir 														sal_uInt16 nIdx)
365*cdf0e10cSrcweir /*  [Beschreibung]
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	Zugriff auf die DokumentShell an der Position nIdx im Bereich
368*cdf0e10cSrcweir 	nRegion (Dokumentvorlage)
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir 	[Returnwert]			Referenz auf die DokumentShell
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir */
373*cdf0e10cSrcweir {
374*cdf0e10cSrcweir //(mba)/task    SfxWaitCursor aWaitCursor;
375*cdf0e10cSrcweir 	return pTemplates->CreateObjectShell(nRegion, nIdx);
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir //-------------------------------------------------------------------------
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::DeleteObjectShell(sal_uInt16 nRegion, sal_uInt16 nIdx)
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir /*  [Beschreibung]
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 	Freigabe der DokumentShell an der Position nIdx im Bereich
385*cdf0e10cSrcweir 	nRegion (Dokumentvorlage)
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	[Returnwert]			sal_True: alles Ok
388*cdf0e10cSrcweir 							sal_False: es ist ein Fehler aufgetreten (das
389*cdf0e10cSrcweir 							Dokument konnte nicht gesichert werden)
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir */
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	return pTemplates->DeleteObjectShell(nRegion, nIdx);
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir //-------------------------------------------------------------------------
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir sal_Bool	SfxOrganizeMgr::Copy(sal_uInt16 nTargetRegion,
400*cdf0e10cSrcweir 							sal_uInt16 nTargetIdx,
401*cdf0e10cSrcweir 							sal_uInt16 nSourceRegion,
402*cdf0e10cSrcweir 							sal_uInt16 nSourceIdx)
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir /*  [Beschreibung]
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	Kopieren einer Dokumentvorlage
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 	[Parameter]
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir 	sal_uInt16 nTargetRegion			Index des Zielbereiches
411*cdf0e10cSrcweir 	sal_uInt16 nTargetIdx				Index Zielposition
412*cdf0e10cSrcweir 	sal_uInt16 nSourceRegion			Index des Quellbereiches
413*cdf0e10cSrcweir 	sal_uInt16 nSourceIdx				Index der zu kopierenden / z uverschiebenden
414*cdf0e10cSrcweir 									Dokumentvorlage
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	[Querverweise]
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir 	<SfxDocumentTemplates::Copy(sal_uInt16 nTargetRegion,
422*cdf0e10cSrcweir 								sal_uInt16 nTargetIdx,
423*cdf0e10cSrcweir 								sal_uInt16 nSourceRegion,
424*cdf0e10cSrcweir 								sal_uInt16 nSourceIdx)>
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir */
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir 	if(nSourceIdx == USHRT_MAX)	// keine Verzeichnisse kopieren
430*cdf0e10cSrcweir 		return sal_False ;
431*cdf0e10cSrcweir 	const sal_Bool bOk = pTemplates->Copy(nTargetRegion, nTargetIdx,
432*cdf0e10cSrcweir 										nSourceRegion, nSourceIdx);
433*cdf0e10cSrcweir 	if(bOk)
434*cdf0e10cSrcweir 		bModified = 1;
435*cdf0e10cSrcweir 	return bOk;
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir //-------------------------------------------------------------------------
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir sal_Bool	SfxOrganizeMgr::Move(sal_uInt16 nTargetRegion,
441*cdf0e10cSrcweir 							sal_uInt16 nTargetIdx,
442*cdf0e10cSrcweir 							sal_uInt16 nSourceRegion,
443*cdf0e10cSrcweir 							sal_uInt16 nSourceIdx)
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir /*  [Beschreibung]
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	Verschieben einer Dokumentvorlage
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 	[Parameter]
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir 	sal_uInt16 nTargetRegion			Index des Zielbereiches
452*cdf0e10cSrcweir 	sal_uInt16 nTargetIdx				Index Zielposition
453*cdf0e10cSrcweir 	sal_uInt16 nSourceRegion			Index des Quellbereiches
454*cdf0e10cSrcweir 	sal_uInt16 nSourceIdx				Index der zu kopierenden / z uverschiebenden
455*cdf0e10cSrcweir 									Dokumentvorlage
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 	[Querverweise]
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir 	<SfxDocumentTemplates::Move(sal_uInt16 nTargetRegion,
463*cdf0e10cSrcweir 								sal_uInt16 nTargetIdx,
464*cdf0e10cSrcweir 								sal_uInt16 nSourceRegion,
465*cdf0e10cSrcweir 								sal_uInt16 nSourceIdx)>
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir */
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir 	if(nSourceIdx == USHRT_MAX)	// keine Verzeichnisse verschieben
471*cdf0e10cSrcweir 		return sal_False ;
472*cdf0e10cSrcweir 	const sal_Bool bOk = pTemplates->Move(nTargetRegion, nTargetIdx,
473*cdf0e10cSrcweir 										nSourceRegion, nSourceIdx);
474*cdf0e10cSrcweir 	if(bOk)
475*cdf0e10cSrcweir 		bModified = 1;
476*cdf0e10cSrcweir 	return bOk;
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir //-------------------------------------------------------------------------
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir sal_Bool	SfxOrganizeMgr::Delete(SfxOrganizeListBox_Impl *pCaller,
482*cdf0e10cSrcweir 								sal_uInt16 nRegion, sal_uInt16 nIdx)
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir /*  [Beschreibung]
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	"oschen einer Dokumentvorlage
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 	[Parameter]
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	SfxOrganizeListBox *pCaller		rufende ListBox; da dieses
491*cdf0e10cSrcweir 									Event durch das Men"u oder
492*cdf0e10cSrcweir 									durch das Keyboard angetriggert wird,
493*cdf0e10cSrcweir 									mu"s das Model der ListBox anschlie"send
494*cdf0e10cSrcweir 									aktualisiert werden.
495*cdf0e10cSrcweir 	sal_uInt16 nRegion					Index des Bereiches
496*cdf0e10cSrcweir 	sal_uInt16 nIdx						Index der Dokumentvorlage
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 	[Querverweise]
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	<SfxDocumentTemplates::Delete(sal_uInt16 nRegion, sal_uInt16 nIdx)>
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir */
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir 	sal_Bool bOk = sal_False;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 	if ( USHRT_MAX == nIdx )
511*cdf0e10cSrcweir 	{
512*cdf0e10cSrcweir 		// deleting of a group
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 		SvLBoxEntry *pGroupToDelete = pCaller->SvLBox::GetEntry(nRegion);
515*cdf0e10cSrcweir 		if ( pGroupToDelete )
516*cdf0e10cSrcweir 		{
517*cdf0e10cSrcweir 			sal_uInt16 nItemNum = (sal_uInt16)( pCaller->GetModel()->GetChildCount( pGroupToDelete ) );
518*cdf0e10cSrcweir 			sal_uInt16 nToDeleteNum = 0;
519*cdf0e10cSrcweir 			SvLBoxEntry **pEntriesToDelete = new SvLBoxEntry*[nItemNum];
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 			sal_uInt16 nInd = 0;
522*cdf0e10cSrcweir 			for ( nInd = 0; nInd < nItemNum; nInd++ )
523*cdf0e10cSrcweir 				pEntriesToDelete[nInd] = NULL;
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 			for ( nInd = 0; nInd < nItemNum; nInd++ )
526*cdf0e10cSrcweir 			{
527*cdf0e10cSrcweir 				// TODO/LATER: check that nInd is the same index that is used in pTemplates
528*cdf0e10cSrcweir 				if ( pTemplates->Delete( nRegion, nInd ) )
529*cdf0e10cSrcweir 				{
530*cdf0e10cSrcweir 					bModified = 1;
531*cdf0e10cSrcweir 					pEntriesToDelete[nToDeleteNum++] = pCaller->SvLBox::GetEntry( pGroupToDelete, nInd );
532*cdf0e10cSrcweir 				}
533*cdf0e10cSrcweir 			}
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 			for ( nInd = 0; nInd < nToDeleteNum; nInd++ )
536*cdf0e10cSrcweir 				if ( pEntriesToDelete[nInd] )
537*cdf0e10cSrcweir 					pCaller->GetModel()->Remove( pEntriesToDelete[nInd] );
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 			if ( !pCaller->GetModel()->GetChildCount( pGroupToDelete ) )
540*cdf0e10cSrcweir             {
541*cdf0e10cSrcweir                 bOk = pTemplates->Delete( nRegion, nIdx );
542*cdf0e10cSrcweir                 if ( bOk )
543*cdf0e10cSrcweir                     pCaller->GetModel()->Remove( pGroupToDelete );
544*cdf0e10cSrcweir             }
545*cdf0e10cSrcweir 		}
546*cdf0e10cSrcweir 	}
547*cdf0e10cSrcweir 	else
548*cdf0e10cSrcweir 	{
549*cdf0e10cSrcweir 		// deleting of a template
550*cdf0e10cSrcweir 		bOk = pTemplates->Delete(nRegion, nIdx);
551*cdf0e10cSrcweir 		if(bOk)
552*cdf0e10cSrcweir 		{
553*cdf0e10cSrcweir 			bModified = 1;
554*cdf0e10cSrcweir 				// zu loeschender Eintrag
555*cdf0e10cSrcweir 			SvLBoxEntry *pEntryToDelete = pCaller->SvLBox::GetEntry(pCaller->SvLBox::GetEntry(nRegion), nIdx);
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 			pCaller->GetModel()->Remove(pEntryToDelete);
558*cdf0e10cSrcweir 		}
559*cdf0e10cSrcweir 	}
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 	return bOk;
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir //-------------------------------------------------------------------------
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir sal_Bool	SfxOrganizeMgr::InsertDir
567*cdf0e10cSrcweir (
568*cdf0e10cSrcweir 	SfxOrganizeListBox_Impl*	pCaller,/*	rufende ListBox; da dieses Event
569*cdf0e10cSrcweir 											durch das Men"u oder durch das
570*cdf0e10cSrcweir 											Keyboard angetriggert wird,
571*cdf0e10cSrcweir 											mu\s das Model der ListBox
572*cdf0e10cSrcweir 											anschlie\send aktualisiert werden */
573*cdf0e10cSrcweir 	const String&				rText,	//	logischer Name des Bereiches
574*cdf0e10cSrcweir 	sal_uInt16						nRegion //	Index des Bereiches
575*cdf0e10cSrcweir )
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir /*	[Beschreibung]
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 	Einf"ugen eines Bereiches
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	[R"uckgabewert]
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	Erfolg (sal_True) oder Mi\serfolg (sal_False)
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 	[Querverweise]
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 	<SfxDocumentTemplates::InsertDir(const String &, sal_uInt16 nRegion)>
590*cdf0e10cSrcweir */
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir {
593*cdf0e10cSrcweir 	const sal_Bool bOk = pTemplates->InsertDir(rText, nRegion);
594*cdf0e10cSrcweir 	if(bOk)
595*cdf0e10cSrcweir 	{
596*cdf0e10cSrcweir 		bModified = 1;
597*cdf0e10cSrcweir 		SvLBoxEntry *pEntry = pCaller->InsertEntry(rText,
598*cdf0e10cSrcweir 												   pCaller->GetOpenedBmp(0),
599*cdf0e10cSrcweir 												   pCaller->GetClosedBmp(0),
600*cdf0e10cSrcweir 												   0, sal_True, nRegion);
601*cdf0e10cSrcweir 		pCaller->Update();
602*cdf0e10cSrcweir 		pCaller->EditEntry(pEntry);
603*cdf0e10cSrcweir 	}
604*cdf0e10cSrcweir 	return bOk;
605*cdf0e10cSrcweir }
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir //-------------------------------------------------------------------------
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::SetName(const String &rName,
610*cdf0e10cSrcweir 							 sal_uInt16 nRegion, sal_uInt16 nIdx)
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir /*  [Beschreibung]
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 	"Andern eines (logischen) Namens
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	[Parameter]
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 	const String &rName				der neue Name
619*cdf0e10cSrcweir 	sal_uInt16 nRegion					Index des Bereiches
620*cdf0e10cSrcweir 	sal_uInt16 nIdx						Index der Dokumentvorlage
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 	[Querverweise]
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir 	<SfxDocumentTemplates::SetName(const String &, sal_uInt16 nRegion, sal_uInt16 nIdx)>
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir */
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir 	const sal_Bool bOk = pTemplates->SetName(rName, nRegion, nIdx);
633*cdf0e10cSrcweir 	if(bOk)
634*cdf0e10cSrcweir 		bModified = 1;
635*cdf0e10cSrcweir 	return bOk;
636*cdf0e10cSrcweir }
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir //-------------------------------------------------------------------------
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, const String &rName) const
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir /*  [Beschreibung]
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 	Export einer Vorlage
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 	[Parameter]
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 	sal_uInt16 nRegion					Index des Bereiches
649*cdf0e10cSrcweir 	sal_uInt16 nIdx						Index der Dokumentvorlage
650*cdf0e10cSrcweir 	const String &rName				Dateiname
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	[Querverweise]
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 	<SfxDocumentTemplates::CopyTo( sal_uInt16 nRegion, sal_uInt16 nIdx, const String &)>
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir */
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir 	return pTemplates->CopyTo(nRegion, nIdx, rName);
663*cdf0e10cSrcweir }
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir //-------------------------------------------------------------------------
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::CopyFrom(SfxOrganizeListBox_Impl *pCaller,
668*cdf0e10cSrcweir 							  sal_uInt16 nRegion, sal_uInt16 nIdx, String &rName)
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir /*  [Beschreibung]
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 	Import einer Vorlage
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	[Parameter]
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir 	SfxOrganizeListBox *pCaller		rufende ListBox; da dieses
677*cdf0e10cSrcweir 									Event durch das Men"u angetriggert wird,
678*cdf0e10cSrcweir 									mu"s das Model der ListBox anschlie"send
679*cdf0e10cSrcweir 									aktualisiert werden.
680*cdf0e10cSrcweir 	sal_uInt16 nRegion					Index des Bereiches
681*cdf0e10cSrcweir 	sal_uInt16 nIdx						Index der Dokumentvorlage
682*cdf0e10cSrcweir 	String &rName					Dateiname
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir 	[Querverweise]
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	<SfxDocumentTemplates::CopyFrom( sal_uInt16 nRegion, sal_uInt16 nIdx, const String &)>
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir */
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir {
694*cdf0e10cSrcweir     SvLBoxEntry *pParent = pCaller->FirstSelected();
695*cdf0e10cSrcweir     if( nIdx!=USHRT_MAX )
696*cdf0e10cSrcweir         pParent = pCaller->GetParent(pParent);
697*cdf0e10cSrcweir     if( pTemplates->CopyFrom( nRegion, nIdx, rName ) )
698*cdf0e10cSrcweir     {
699*cdf0e10cSrcweir         // pCaller aktualisieren
700*cdf0e10cSrcweir         if( nIdx == USHRT_MAX )
701*cdf0e10cSrcweir             nIdx = 0;
702*cdf0e10cSrcweir         else nIdx++;
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir         pCaller->InsertEntry( rName,
705*cdf0e10cSrcweir                               pCaller->GetOpenedBmp(1),
706*cdf0e10cSrcweir                               pCaller->GetClosedBmp(1),
707*cdf0e10cSrcweir                               pParent,
708*cdf0e10cSrcweir                               sal_True,
709*cdf0e10cSrcweir                               nIdx);
710*cdf0e10cSrcweir         pCaller->Update();
711*cdf0e10cSrcweir         // pCaller->EditEntry( pEntry );
712*cdf0e10cSrcweir         pCaller->Expand( pParent );
713*cdf0e10cSrcweir         bModified = sal_True;
714*cdf0e10cSrcweir         return sal_True;
715*cdf0e10cSrcweir     }
716*cdf0e10cSrcweir     return sal_False;
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir //-------------------------------------------------------------------------
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::InsertFile( SfxOrganizeListBox_Impl* pCaller, const String& rFileName )
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir /*  [Beschreibung]
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 	Eine Datei in der Dateiansicht hinzuf"ugen
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 	[Parameter]
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir 	SfxOrganizeListBox *pCaller		rufende ListBox; da dieses
730*cdf0e10cSrcweir 									Event durch das Men"u angetriggert wird,
731*cdf0e10cSrcweir 									mu"s das Model der ListBox anschlie"send
732*cdf0e10cSrcweir 									aktualisiert werden.
733*cdf0e10cSrcweir 	const String &rFileName			Name der hinzuf"ugenden Datei
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 	[R"uckgabewert]					Erfolg (TRUE) oder Mi"serfolg (FALSE)
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir */
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir {
740*cdf0e10cSrcweir 	const CollatorWrapper* pCollator = pImpl->pIntlWrapper->getCaseCollator();
741*cdf0e10cSrcweir 	_FileListEntry* pEntry = new _FileListEntry( rFileName, pCollator );
742*cdf0e10cSrcweir 	if ( pImpl->pDocList->C40_PTR_INSERT( _FileListEntry, pEntry ) )
743*cdf0e10cSrcweir 	{
744*cdf0e10cSrcweir 		sal_uInt16 nPos = 0;
745*cdf0e10cSrcweir 		pImpl->pDocList->Seek_Entry( pEntry, &nPos );
746*cdf0e10cSrcweir 		pCaller->InsertEntry( pEntry->aBaseName, pCaller->GetOpenedBmp(1),
747*cdf0e10cSrcweir 							  pCaller->GetClosedBmp(1), 0, sal_True, nPos );
748*cdf0e10cSrcweir 		return sal_True;
749*cdf0e10cSrcweir 	}
750*cdf0e10cSrcweir 	return sal_False;
751*cdf0e10cSrcweir }
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir //-------------------------------------------------------------------------
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir sal_Bool SfxOrganizeMgr::Rescan()
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir /*  [Beschreibung]
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 	Aktualisieren der Datenbasis
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	[R"uckgabewert]
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 	sal_True					es bestanden Unterschiede
764*cdf0e10cSrcweir 	FALSE					keine "Anderung
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 	[Querverweise]
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 	<SfxDocumentTemplates::Rescan()>
769*cdf0e10cSrcweir */
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir {
772*cdf0e10cSrcweir 	if(pTemplates->Rescan())
773*cdf0e10cSrcweir 	{
774*cdf0e10cSrcweir 		bModified = sal_True;
775*cdf0e10cSrcweir 		return sal_True;
776*cdf0e10cSrcweir 	}
777*cdf0e10cSrcweir 	return sal_False;
778*cdf0e10cSrcweir }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir //-------------------------------------------------------------------------
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir void SfxOrganizeMgr::SaveAll(Window *pParent)
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir /*  [Beschreibung]
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 	Schreiben aller ge"anderten Dokumente
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 	[Parameter]
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 	Window *pParent			Parent der Boxen f"ur Fehlermeldungen
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir */
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir {
795*cdf0e10cSrcweir 	sal_uInt16 nRangeCount = pTemplates->GetRegionCount();
796*cdf0e10cSrcweir 	sal_uInt16 i;
797*cdf0e10cSrcweir 	for(i = 0; i < nRangeCount; ++i)
798*cdf0e10cSrcweir 	{
799*cdf0e10cSrcweir 		if( pTemplates->IsRegionLoaded( i ))
800*cdf0e10cSrcweir 		{
801*cdf0e10cSrcweir 			const sal_uInt16 nCount = pTemplates->GetCount(i);
802*cdf0e10cSrcweir 			for(sal_uInt16 j = 0; j < nCount; ++j)
803*cdf0e10cSrcweir 			{
804*cdf0e10cSrcweir 				if(!pTemplates->DeleteObjectShell(i, j))
805*cdf0e10cSrcweir 				{
806*cdf0e10cSrcweir 					String aText = String(SfxResId(STR_ERROR_SAVE_TEMPLATE));
807*cdf0e10cSrcweir 					aText += pTemplates->GetName(i, j);
808*cdf0e10cSrcweir 					ErrorBox aBox(pParent,
809*cdf0e10cSrcweir 								  WinBits(WB_OK_CANCEL | WB_DEF_CANCEL),
810*cdf0e10cSrcweir 								  aText);
811*cdf0e10cSrcweir 					if(RET_CANCEL == aBox.Execute())
812*cdf0e10cSrcweir 						break;
813*cdf0e10cSrcweir 				}
814*cdf0e10cSrcweir 			}
815*cdf0e10cSrcweir 		}
816*cdf0e10cSrcweir 	}
817*cdf0e10cSrcweir 	nRangeCount = pImpl->pDocList->Count();
818*cdf0e10cSrcweir 	for(i = 0; i < nRangeCount; ++i)
819*cdf0e10cSrcweir 	{
820*cdf0e10cSrcweir 		_FileListEntry *pEntry = (*pImpl->pDocList)[i];
821*cdf0e10cSrcweir 		if(!pEntry->DeleteObjectShell())
822*cdf0e10cSrcweir 		{
823*cdf0e10cSrcweir 			String aText(SfxResId(STR_ERROR_SAVE_TEMPLATE));
824*cdf0e10cSrcweir 			aText += pEntry->aBaseName;
825*cdf0e10cSrcweir 			ErrorBox aBox(pParent, WinBits(WB_OK_CANCEL | WB_DEF_CANCEL), aText);
826*cdf0e10cSrcweir 			if(RET_CANCEL == aBox.Execute())
827*cdf0e10cSrcweir 				break;
828*cdf0e10cSrcweir 		}
829*cdf0e10cSrcweir 	}
830*cdf0e10cSrcweir }
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir 
833