2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* $RCSfile: docglbl.cxx,v $
|
|
|
|
* $Revision: 1.25 $
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:17:40 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 19:53:04 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <hintids.hxx>
|
2000-11-06 08:44:32 +00:00
|
|
|
#include <unotools/tempfile.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <svtools/urihelper.hxx>
|
2001-08-23 15:02:12 +00:00
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#include <svtools/eitem.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/docfilt.hxx>
|
2001-10-25 16:22:03 +00:00
|
|
|
#include <sfx2/fcontnr.hxx>
|
2001-08-23 15:02:12 +00:00
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
#include <sfx2/request.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtinfmt.hxx>
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <pam.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#ifndef _DOCSH_HXX
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _GLOBDOC_HXX
|
|
|
|
#include <globdoc.hxx>
|
|
|
|
#endif
|
|
|
|
#include <shellio.hxx>
|
|
|
|
#include <swundo.hxx> // fuer die UndoIds
|
|
|
|
#include <section.hxx>
|
|
|
|
#include <doctxm.hxx>
|
|
|
|
#include <poolfmt.hxx>
|
|
|
|
|
2008-02-26 13:06:09 +00:00
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
|
|
|
#include <com/sun/star/document/XDocumentProperties.hpp>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
enum SwSplitDocType
|
|
|
|
{
|
|
|
|
SPLITDOC_TO_GLOBALDOC,
|
|
|
|
SPLITDOC_TO_HTML
|
|
|
|
};
|
|
|
|
|
|
|
|
BOOL SwDoc::GenerateGlobalDoc( const String& rPath,
|
|
|
|
const SwTxtFmtColl* pSplitColl )
|
|
|
|
{
|
|
|
|
return SplitDoc( SPLITDOC_TO_GLOBALDOC, rPath, pSplitColl );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL SwDoc::GenerateHTMLDoc( const String& rPath,
|
|
|
|
const SwTxtFmtColl* pSplitColl )
|
|
|
|
{
|
|
|
|
#ifdef JP_TEST
|
|
|
|
if( !pSplitColl )
|
|
|
|
{
|
|
|
|
BYTE nLvl = 1;
|
|
|
|
const SwTxtFmtColls& rFmtColls =*GetTxtFmtColls();
|
|
|
|
for( USHORT n = rFmtColls.Count(); n; )
|
|
|
|
if( nLvl == rFmtColls[ --n ]->GetOutlineLevel() )
|
|
|
|
{
|
|
|
|
pSplitColl = rFmtColls[ n ];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pSplitColl )
|
|
|
|
pSplitColl = GetTxtCollFromPool( RES_POOLCOLL_HEADLINE2 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return SplitDoc( SPLITDOC_TO_HTML, rPath, pSplitColl );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath,
|
|
|
|
const SwTxtFmtColl* pSplitColl )
|
|
|
|
{
|
|
|
|
// ueber alle Node der Vorlage Iterieren und dafuer einzelne
|
|
|
|
// Dokumente erzeugen und in diesem gegen
|
|
|
|
// - gelinkte Bereiche (GlobalDoc)
|
|
|
|
// - Links (HTML)
|
|
|
|
// austauschen.
|
|
|
|
// Am Ende wird dieses Doc als GlobalDoc/HTML-Doc gespreichert.
|
|
|
|
if( !pDocShell || !pDocShell->GetMedium() ||
|
2006-08-14 14:58:11 +00:00
|
|
|
( SPLITDOC_TO_GLOBALDOC == eDocType && get(IDocumentSettingAccess::GLOBAL_DOCUMENT) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
USHORT nOutl = 0;
|
|
|
|
SwOutlineNodes* pOutlNds = (SwOutlineNodes*)&GetNodes().GetOutLineNds();
|
|
|
|
SwNodePtr pSttNd;
|
|
|
|
|
|
|
|
if( pSplitColl )
|
|
|
|
{
|
|
|
|
// wenn keine OutlineNumerierung ist, dann benutze eigenes Array
|
|
|
|
// und sammel die Nodes zusammen.
|
|
|
|
if( NO_NUMBERING == pSplitColl->GetOutlineLevel() )
|
|
|
|
{
|
|
|
|
pOutlNds = new SwOutlineNodes( 8, 8 );
|
|
|
|
SwClientIter aIter( *(SwModify*)pSplitColl );
|
|
|
|
for( SwTxtNode* pTNd = (SwTxtNode*)aIter.First( TYPE( SwTxtNode ));
|
|
|
|
pTNd; pTNd = (SwTxtNode*)aIter.Next() )
|
|
|
|
if( pTNd->GetNodes().IsDocNodes() )
|
|
|
|
pOutlNds->Insert( pTNd );
|
|
|
|
|
|
|
|
if( !pOutlNds->Count() )
|
|
|
|
{
|
|
|
|
delete pOutlNds;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// dann suche die Gliederungs - Vorlage, der 1. Ebene
|
|
|
|
const SwTxtFmtColls& rFmtColls =*GetTxtFmtColls();
|
|
|
|
for( USHORT n = rFmtColls.Count(); n; )
|
|
|
|
if( !rFmtColls[ --n ]->GetOutlineLevel() )
|
|
|
|
{
|
|
|
|
pSplitColl = rFmtColls[ n ];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pSplitColl )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SfxFilter* pFilter;
|
|
|
|
switch( eDocType )
|
|
|
|
{
|
|
|
|
case SPLITDOC_TO_HTML:
|
|
|
|
pFilter = SwIoSystem::GetFilterOfFormat( String::CreateFromAscii(
|
2001-10-25 16:22:03 +00:00
|
|
|
RTL_CONSTASCII_STRINGPARAM( "HTML" )));
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// case SPLITDOC_TO_GLOBALDOC:
|
2001-10-25 13:30:57 +00:00
|
|
|
pFilter = SwIoSystem::GetFilterOfFormat(
|
2001-10-25 16:22:03 +00:00
|
|
|
String::CreateFromAscii( FILTER_XML ));
|
2000-09-18 23:08:29 +00:00
|
|
|
eDocType = SPLITDOC_TO_GLOBALDOC;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pFilter )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
// Undo/Redline aufjedenfall abschalten
|
|
|
|
DoUndo( FALSE );
|
2007-09-27 07:35:38 +00:00
|
|
|
SetRedlineMode_intern( (RedlineMode_t)(GetRedlineMode() & ~nsRedlineMode_t::REDLINE_ON));
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
String sExt( pFilter->GetSuffixes().GetToken(0, ',') );
|
|
|
|
if( !sExt.Len() )
|
2001-02-26 07:24:19 +00:00
|
|
|
sExt.AssignAscii( "sxw" );
|
2000-10-19 08:44:23 +00:00
|
|
|
if( '.' != sExt.GetChar( 0 ) )
|
|
|
|
sExt.Insert( '.', 0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
INetURLObject aEntry(rPath);
|
|
|
|
String sLeading(aEntry.GetBase());
|
|
|
|
aEntry.removeSegment();
|
2001-08-31 10:13:43 +00:00
|
|
|
String sPath = aEntry.GetMainURL( INetURLObject::NO_DECODE );
|
2000-11-06 08:44:32 +00:00
|
|
|
utl::TempFile aTemp(sLeading,&sExt,&sPath );
|
2000-09-18 23:08:29 +00:00
|
|
|
aTemp.EnableKillingFile();
|
|
|
|
|
|
|
|
DateTime aTmplDate;
|
|
|
|
{
|
|
|
|
Time a2Min( 0 ); a2Min.SetMin( 2 );
|
|
|
|
aTmplDate += a2Min;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// alle Ungueltigen ueberspringen
|
|
|
|
while( nOutl < pOutlNds->Count() &&
|
|
|
|
pOutlNds->GetObject( nOutl )->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
|
|
|
|
++nOutl;
|
|
|
|
|
|
|
|
do {
|
|
|
|
pSttNd = 0;
|
|
|
|
|
|
|
|
SwNodePtr pNd;
|
|
|
|
for( ; nOutl < pOutlNds->Count(); ++nOutl )
|
|
|
|
if( ( pNd = pOutlNds->GetObject( nOutl ))->GetTxtNode()->
|
|
|
|
GetTxtColl() == pSplitColl &&
|
|
|
|
!pNd->FindTableNode() )
|
|
|
|
{
|
|
|
|
pSttNd = pNd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pSttNd )
|
|
|
|
{
|
|
|
|
SwNodePtr pEndNd = 0;
|
|
|
|
for( ++nOutl; nOutl < pOutlNds->Count(); ++nOutl )
|
|
|
|
{
|
|
|
|
pNd = pOutlNds->GetObject( nOutl );
|
|
|
|
SwTxtFmtColl* pTColl = pNd->GetTxtNode()->GetTxtColl();
|
|
|
|
|
|
|
|
if( ( pTColl == pSplitColl ||
|
|
|
|
( NO_NUMBERING != pSplitColl->GetOutlineLevel() &&
|
|
|
|
pTColl->GetOutlineLevel() <
|
|
|
|
pSplitColl->GetOutlineLevel() )) &&
|
|
|
|
!pNd->FindTableNode() )
|
|
|
|
{
|
|
|
|
pEndNd = pNd;
|
2004-07-05 13:38:48 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SwNodeIndex aEndIdx( pEndNd ? *pEndNd
|
|
|
|
: GetNodes().GetEndOfContent() );
|
|
|
|
|
|
|
|
// die Nodes komplett rausschreiben
|
|
|
|
String sFileName;
|
|
|
|
if( pSttNd->GetIndex() + 1 < aEndIdx.GetIndex() )
|
|
|
|
{
|
|
|
|
SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL ));
|
|
|
|
if( xDocSh->DoInitNew( 0 ) )
|
|
|
|
{
|
|
|
|
SwDoc* pDoc = ((SwDocShell*)(&xDocSh))->GetDoc();
|
|
|
|
|
2008-02-26 13:06:09 +00:00
|
|
|
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
|
|
|
((SwDocShell*)(&xDocSh))->GetModel(),
|
|
|
|
uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<document::XDocumentProperties> xDocProps(
|
|
|
|
xDPS->getDocumentProperties());
|
|
|
|
DBG_ASSERT(xDocProps.is(), "Doc has no DocumentProperties");
|
|
|
|
// the GlobalDoc is the template
|
|
|
|
xDocProps->setTemplateName(aEmptyStr);
|
|
|
|
::util::DateTime uDT(aTmplDate.Get100Sec(),
|
|
|
|
aTmplDate.GetSec(), aTmplDate.GetMin(),
|
|
|
|
aTmplDate.GetHour(), aTmplDate.GetDay(),
|
|
|
|
aTmplDate.GetMonth(), aTmplDate.GetYear());
|
|
|
|
xDocProps->setTemplateDate(uDT);
|
|
|
|
xDocProps->setTemplateURL(rPath);
|
2000-09-18 23:08:29 +00:00
|
|
|
//JP 14.06.99: Set the text of the "split para" as title
|
|
|
|
// from the new doc. Is the current doc has
|
|
|
|
// a title, insert it at begin.
|
2008-02-26 13:06:09 +00:00
|
|
|
String sTitle( xDocProps->getTitle() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( sTitle.Len() )
|
|
|
|
sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ));
|
|
|
|
sTitle += ((SwTxtNode*)pSttNd)->GetExpandTxt();
|
2008-02-26 13:06:09 +00:00
|
|
|
xDocProps->setTitle( sTitle );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Vorlagen ersetzen
|
|
|
|
pDoc->ReplaceStyles( *this );
|
|
|
|
|
|
|
|
// KapitelNumerierung uebernehmen
|
|
|
|
if( pOutlineRule )
|
|
|
|
pDoc->SetOutlineNumRule( *pOutlineRule );
|
|
|
|
|
|
|
|
SwNodeRange aRg( *pSttNd, 0, aEndIdx.GetNode() );
|
|
|
|
SwNodeIndex aTmpIdx( pDoc->GetNodes().GetEndOfContent() );
|
|
|
|
GetNodes()._Copy( aRg, aTmpIdx, FALSE );
|
|
|
|
|
|
|
|
// den initialen TextNode loeschen
|
|
|
|
SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfExtras(), 2 );
|
|
|
|
if( aIdx.GetIndex() + 1 !=
|
|
|
|
pDoc->GetNodes().GetEndOfContent().GetIndex() )
|
|
|
|
pDoc->GetNodes().Delete( aIdx, 1 );
|
|
|
|
|
|
|
|
// alle Flys in dem Bereich
|
|
|
|
_CopyFlyInFly( aRg, aIdx );
|
|
|
|
|
|
|
|
|
|
|
|
// und noch alle Bookmarks
|
|
|
|
// ?????
|
|
|
|
|
2000-11-06 08:44:32 +00:00
|
|
|
utl::TempFile aTempFile2(sLeading,&sExt,&sPath );
|
2001-01-15 17:47:21 +00:00
|
|
|
sFileName = aTempFile2.GetURL();
|
2000-10-19 08:44:23 +00:00
|
|
|
SfxMedium* pTmpMed = new SfxMedium( sFileName,
|
2000-09-18 23:08:29 +00:00
|
|
|
STREAM_STD_READWRITE, TRUE );
|
2000-10-19 08:44:23 +00:00
|
|
|
pTmpMed->SetFilter( pFilter );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// fuer den HTML-Filter mussen wir aber ein Layout
|
|
|
|
// haben, damit Textrahmen/Controls/OLE-Objecte korrekt
|
|
|
|
// als Grafik exportiert werden koennen.
|
|
|
|
if( SPLITDOC_TO_HTML == eDocType &&
|
|
|
|
pDoc->GetSpzFrmFmts()->Count() )
|
|
|
|
{
|
|
|
|
/* SfxViewFrame* pFrame = */
|
2006-05-02 14:17:15 +00:00
|
|
|
SfxViewFrame::CreateViewFrame( *xDocSh, 0, TRUE );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2000-10-19 08:44:23 +00:00
|
|
|
xDocSh->DoSaveAs( *pTmpMed );
|
|
|
|
xDocSh->DoSaveCompleted( pTmpMed );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// beim Fehler wird keine FileLinkSection eingefuegt
|
|
|
|
if( xDocSh->GetError() )
|
|
|
|
sFileName.Erase();
|
|
|
|
}
|
|
|
|
xDocSh->DoClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
// dann koennen ja die Bereiche eingefuegt werden
|
|
|
|
if( sFileName.Len() )
|
|
|
|
{
|
|
|
|
switch( eDocType )
|
|
|
|
{
|
|
|
|
case SPLITDOC_TO_HTML:
|
|
|
|
{
|
|
|
|
// loesche alle Nodes im Bereich und setze im "Start-
|
|
|
|
// Node" den Link auf das gespeicherte Doc
|
|
|
|
ULONG nNodeDiff = aEndIdx.GetIndex() -
|
|
|
|
pSttNd->GetIndex() - 1;
|
|
|
|
if( nNodeDiff )
|
|
|
|
{
|
|
|
|
SwPaM aTmp( *pSttNd, aEndIdx.GetNode(), 1, -1 );
|
|
|
|
aTmp.GetPoint()->nContent.Assign( 0, 0 );
|
|
|
|
aTmp.GetMark()->nContent.Assign( 0, 0 );
|
|
|
|
SwNodeIndex aSIdx( aTmp.GetMark()->nNode );
|
|
|
|
SwNodeIndex aEIdx( aTmp.GetPoint()->nNode );
|
|
|
|
|
|
|
|
// versuche hinters Ende zu verschieben
|
|
|
|
if( !aTmp.Move( fnMoveForward, fnGoNode ) )
|
|
|
|
{
|
|
|
|
// na gut, dann an den Anfang
|
|
|
|
aTmp.Exchange();
|
|
|
|
if( !aTmp.Move( fnMoveBackward, fnGoNode ))
|
|
|
|
{
|
|
|
|
ASSERT( FALSE, "kein Node mehr vorhanden" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Bookmarks usw. verschieben
|
|
|
|
CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE);
|
|
|
|
|
|
|
|
// stehen noch FlyFrames rum, loesche auch diese
|
|
|
|
const SwPosition* pAPos;
|
|
|
|
for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n )
|
|
|
|
{
|
|
|
|
SwFrmFmt* pFly = (*GetSpzFrmFmts())[n];
|
|
|
|
const SwFmtAnchor* pAnchor = &pFly->GetAnchor();
|
|
|
|
if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() ||
|
|
|
|
FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) &&
|
|
|
|
0 != ( pAPos = pAnchor->GetCntntAnchor() ) &&
|
|
|
|
aSIdx <= pAPos->nNode &&
|
|
|
|
pAPos->nNode < aEIdx )
|
|
|
|
{
|
|
|
|
DelLayoutFmt( pFly );
|
|
|
|
--n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetNodes().Delete( aSIdx, nNodeDiff );
|
|
|
|
}
|
|
|
|
|
|
|
|
// dann setze im StartNode noch den Link:
|
2005-01-11 11:18:14 +00:00
|
|
|
SwFmtINetFmt aINet( sFileName , aEmptyStr );
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTxtNode* pTNd = (SwTxtNode*)pSttNd;
|
2006-12-01 14:38:32 +00:00
|
|
|
pTNd->InsertItem( aINet, 0, pTNd->GetTxt().Len() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// wenn der nicht mehr gefunden wird, kann das nur
|
|
|
|
// ein Bug sein!
|
|
|
|
if( !pOutlNds->Seek_Entry( pSttNd, &nOutl ))
|
|
|
|
pSttNd = 0;
|
|
|
|
++nOutl;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
String sNm( INetURLObject( sFileName ).GetName() );
|
|
|
|
SwSection aSect( FILE_LINK_SECTION,
|
|
|
|
GetUniqueSectionName( &sNm ));
|
|
|
|
SwSectionFmt* pFmt = MakeSectionFmt( 0 );
|
2005-01-11 11:18:14 +00:00
|
|
|
aSect.SetLinkFileName(sFileName );
|
2000-09-18 23:08:29 +00:00
|
|
|
aSect.SetProtect();
|
|
|
|
|
|
|
|
aEndIdx--; // im InsertSection ist Ende inclusive
|
|
|
|
while( aEndIdx.GetNode().IsStartNode() )
|
|
|
|
aEndIdx--;
|
|
|
|
|
|
|
|
// JP 06.07.99 - Bug 67361 - is any Section ends or
|
|
|
|
// starts in the new sectionrange, they must end or
|
|
|
|
// start before or behind the range!
|
|
|
|
SwSectionNode* pSectNd = pSttNd->FindSectionNode();
|
|
|
|
while( pSectNd && pSectNd->EndOfSectionIndex()
|
|
|
|
<= aEndIdx.GetIndex() )
|
|
|
|
{
|
|
|
|
const SwNode* pSectEnd = pSectNd->EndOfSectionNode();
|
|
|
|
if( pSectNd->GetIndex() + 1 ==
|
|
|
|
pSttNd->GetIndex() )
|
|
|
|
{
|
|
|
|
BOOL bMvIdx = aEndIdx == *pSectEnd;
|
|
|
|
DelSectionFmt( pSectNd->GetSection().GetFmt() );
|
|
|
|
if( bMvIdx )
|
|
|
|
aEndIdx--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwNodeRange aRg( *pSttNd, *pSectEnd );
|
|
|
|
SwNodeIndex aIdx( *pSectEnd, 1 );
|
|
|
|
GetNodes()._MoveNodes( aRg, GetNodes(), aIdx );
|
|
|
|
}
|
|
|
|
pSectNd = pSttNd->FindSectionNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
pSectNd = aEndIdx.GetNode().FindSectionNode();
|
|
|
|
while( pSectNd && pSectNd->GetIndex() >
|
|
|
|
pSttNd->GetIndex() )
|
|
|
|
{
|
2003-12-01 08:38:06 +00:00
|
|
|
// #i15712# don't attempt to split sections if
|
|
|
|
// they are fully enclosed in [pSectNd,aEndIdx].
|
|
|
|
if( aEndIdx < pSectNd->EndOfSectionIndex() )
|
|
|
|
{
|
|
|
|
SwNodeRange aRg( *pSectNd, 1, aEndIdx, 1 );
|
|
|
|
SwNodeIndex aIdx( *pSectNd );
|
|
|
|
GetNodes()._MoveNodes( aRg, GetNodes(), aIdx );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
pSectNd = pSttNd->FindSectionNode();
|
|
|
|
}
|
|
|
|
|
2004-07-05 13:38:48 +00:00
|
|
|
// -> #i26762#
|
|
|
|
// Ensure order of start and end of section is sane.
|
|
|
|
SwNodeIndex aStartIdx(*pSttNd);
|
|
|
|
|
|
|
|
if (aEndIdx >= aStartIdx)
|
|
|
|
pSectNd = GetNodes().InsertSection
|
|
|
|
(aStartIdx, *pFmt, aSect, &aEndIdx, FALSE );
|
|
|
|
else
|
|
|
|
pSectNd = GetNodes().InsertSection
|
|
|
|
(aEndIdx, *pFmt, aSect, &aStartIdx, FALSE );
|
|
|
|
// <- #i26762#
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
pSectNd->GetSection().CreateLink( CREATE_CONNECT );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while( pSttNd );
|
|
|
|
|
|
|
|
// if( pOutlNds != (SwOutlineNodes*)&GetNodes().GetOutLineNds();
|
|
|
|
if( pOutlNds != &GetNodes().GetOutLineNds() )
|
|
|
|
delete pOutlNds;
|
|
|
|
|
2001-10-25 16:22:03 +00:00
|
|
|
switch( eDocType )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-25 16:22:03 +00:00
|
|
|
case SPLITDOC_TO_HTML:
|
2006-08-14 14:58:11 +00:00
|
|
|
if( get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
|
2001-10-25 16:22:03 +00:00
|
|
|
{
|
|
|
|
// dann alles verbliebenen Bereiche aufheben
|
|
|
|
while( GetSections().Count() )
|
|
|
|
DelSectionFmt( GetSections()[ 0 ] );
|
|
|
|
|
2003-09-19 07:44:12 +00:00
|
|
|
SfxFilterContainer* pFCntnr = pDocShell->GetFactory().GetFilterContainer();
|
|
|
|
pFilter = pFCntnr->GetFilter4EA( pFilter->GetTypeName(), SFX_FILTER_EXPORT );
|
2001-10-25 16:22:03 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// case SPLITDOC_TO_GLOBALDOC:
|
|
|
|
default:
|
2000-09-18 23:08:29 +00:00
|
|
|
// dann das Globaldoc speichern
|
2006-08-14 14:58:11 +00:00
|
|
|
set(IDocumentSettingAccess::GLOBAL_DOCUMENT, true);
|
|
|
|
set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, false);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2001-10-25 16:22:03 +00:00
|
|
|
// Medium istn't locked after reopen the document. Bug 91462
|
2001-08-23 15:02:12 +00:00
|
|
|
SfxRequest aReq( SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON, GetAttrPool() );
|
|
|
|
aReq.AppendItem( SfxStringItem( SID_FILE_NAME, rPath ) );
|
|
|
|
aReq.AppendItem( SfxBoolItem( SID_SAVETO, sal_True ) );
|
2006-03-29 07:04:42 +00:00
|
|
|
if(pFilter)
|
|
|
|
aReq.AppendItem( SfxStringItem( SID_FILTER_NAME, pFilter->GetName() ) );
|
2001-10-25 16:22:03 +00:00
|
|
|
const SfxBoolItem *pRet = (const SfxBoolItem*)pDocShell->ExecuteSlot( aReq );
|
|
|
|
|
2001-08-23 15:02:12 +00:00
|
|
|
return pRet && pRet->GetValue();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|