1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docglbl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
36 #include <unotools/tempfile.hxx>
37 #include <svtools/urihelper.hxx>
38 #include <svtools/stritem.hxx>
39 #include <svtools/eitem.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <sfx2/docfilt.hxx>
43 #include <sfx2/fcontnr.hxx>
44 #include <sfx2/bindings.hxx>
45 #include <sfx2/request.hxx>
46 #include <fmtinfmt.hxx>
47 #include <fmtanchr.hxx>
56 #include <globdoc.hxx>
58 #include <shellio.hxx>
59 #include <swundo.hxx> // fuer die UndoIds
60 #include <section.hxx>
62 #include <poolfmt.hxx>
64 #include <com/sun/star/uno/Reference.h>
65 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
66 #include <com/sun/star/document/XDocumentProperties.hpp>
68 using namespace ::com::sun::star
;
72 SPLITDOC_TO_GLOBALDOC
,
76 BOOL
SwDoc::GenerateGlobalDoc( const String
& rPath
,
77 const SwTxtFmtColl
* pSplitColl
)
79 return SplitDoc( SPLITDOC_TO_GLOBALDOC
, rPath
, pSplitColl
);
82 //#outline level,add by zhaojianwei
83 BOOL
SwDoc::GenerateGlobalDoc( const String
& rPath
, int nOutlineLevel
)
85 return SplitDoc( SPLITDOC_TO_GLOBALDOC
, rPath
, nOutlineLevel
);
87 BOOL
SwDoc::GenerateHTMLDoc( const String
& rPath
, int nOutlineLevel
)
89 return SplitDoc( SPLITDOC_TO_HTML
, rPath
, nOutlineLevel
);
93 BOOL
SwDoc::GenerateHTMLDoc( const String
& rPath
,
94 const SwTxtFmtColl
* pSplitColl
)
100 const SwTxtFmtColls
& rFmtColls
=*GetTxtFmtColls();
101 for( USHORT n
= rFmtColls
.Count(); n
; )
102 //if( nLvl == rFmtColls[ --n ]->GetOutlineLevel() )//#outline level,zhaojianwei
103 if( nLvl
== rFmtColls
[ --n
]->GetAttrOutlineLevel() -1 )//<-end,zhaojianwei 0814
105 pSplitColl
= rFmtColls
[ n
];
110 pSplitColl
= GetTxtCollFromPool( RES_POOLCOLL_HEADLINE2
);
114 return SplitDoc( SPLITDOC_TO_HTML
, rPath
, pSplitColl
);
117 BOOL
SwDoc::SplitDoc( USHORT eDocType
, const String
& rPath
,
118 const SwTxtFmtColl
* pSplitColl
)
120 // ueber alle Node der Vorlage Iterieren und dafuer einzelne
121 // Dokumente erzeugen und in diesem gegen
122 // - gelinkte Bereiche (GlobalDoc)
125 // Am Ende wird dieses Doc als GlobalDoc/HTML-Doc gespreichert.
126 if( !pDocShell
|| !pDocShell
->GetMedium() ||
127 ( SPLITDOC_TO_GLOBALDOC
== eDocType
&& get(IDocumentSettingAccess::GLOBAL_DOCUMENT
) ) )
131 SwOutlineNodes
* pOutlNds
= (SwOutlineNodes
*)&GetNodes().GetOutLineNds();
136 // wenn keine OutlineNumerierung ist, dann benutze eigenes Array
137 // und sammel die Nodes zusammen.
138 //if( NO_NUMBERING == pSplitColl->GetOutlineLevel() )//#outline level,zhaojianwei
139 if( pSplitColl
->GetAttrOutlineLevel() == 0 )//<-end,zhaojianwei, 0814
141 pOutlNds
= new SwOutlineNodes( 8, 8 );
142 SwClientIter
aIter( *(SwModify
*)pSplitColl
);
143 for( SwTxtNode
* pTNd
= (SwTxtNode
*)aIter
.First( TYPE( SwTxtNode
));
144 pTNd
; pTNd
= (SwTxtNode
*)aIter
.Next() )
145 if( pTNd
->GetNodes().IsDocNodes() )
146 pOutlNds
->Insert( pTNd
);
148 if( !pOutlNds
->Count() )
157 // dann suche die Gliederungs - Vorlage, der 1. Ebene
158 const SwTxtFmtColls
& rFmtColls
=*GetTxtFmtColls();
159 for( USHORT n
= rFmtColls
.Count(); n
; )
160 //if( !rFmtColls[ --n ]->GetOutlineLevel() )//#outline level,zhaojianwei
161 if ( rFmtColls
[ --n
]->GetAttrOutlineLevel() == 1 )//<-end,zhaojianwei
163 pSplitColl
= rFmtColls
[ n
];
171 const SfxFilter
* pFilter
;
174 case SPLITDOC_TO_HTML
:
175 pFilter
= SwIoSystem::GetFilterOfFormat( String::CreateFromAscii(
176 RTL_CONSTASCII_STRINGPARAM( "HTML" )));
180 // case SPLITDOC_TO_GLOBALDOC:
181 pFilter
= SwIoSystem::GetFilterOfFormat(
182 String::CreateFromAscii( FILTER_XML
));
183 eDocType
= SPLITDOC_TO_GLOBALDOC
;
190 // Undo/Redline aufjedenfall abschalten
192 SetRedlineMode_intern( (RedlineMode_t
)(GetRedlineMode() & ~nsRedlineMode_t::REDLINE_ON
));
194 String
sExt( pFilter
->GetSuffixes().GetToken(0, ',') );
196 sExt
.AssignAscii( "sxw" );
197 if( '.' != sExt
.GetChar( 0 ) )
198 sExt
.Insert( '.', 0 );
200 INetURLObject
aEntry(rPath
);
201 String
sLeading(aEntry
.GetBase());
202 aEntry
.removeSegment();
203 String sPath
= aEntry
.GetMainURL( INetURLObject::NO_DECODE
);
204 utl::TempFile
aTemp(sLeading
,&sExt
,&sPath
);
205 aTemp
.EnableKillingFile();
209 Time
a2Min( 0 ); a2Min
.SetMin( 2 );
214 // alle Ungueltigen ueberspringen
215 while( nOutl
< pOutlNds
->Count() &&
216 pOutlNds
->GetObject( nOutl
)->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
223 for( ; nOutl
< pOutlNds
->Count(); ++nOutl
)
224 if( ( pNd
= pOutlNds
->GetObject( nOutl
))->GetTxtNode()->
225 GetTxtColl() == pSplitColl
&&
226 !pNd
->FindTableNode() )
234 SwNodePtr pEndNd
= 0;
235 for( ++nOutl
; nOutl
< pOutlNds
->Count(); ++nOutl
)
237 pNd
= pOutlNds
->GetObject( nOutl
);
238 SwTxtFmtColl
* pTColl
= pNd
->GetTxtNode()->GetTxtColl();
240 //if( ( pTColl == pSplitColl || //#outline level,zhaojianwei
241 // ( NO_NUMBERING != pSplitColl->GetOutlineLevel() &&
242 // pTColl->GetOutlineLevel() <
243 // pSplitColl->GetOutlineLevel() )) &&
244 // !pNd->FindTableNode() )
245 if( ( pTColl
== pSplitColl
||
246 ( pSplitColl
->GetAttrOutlineLevel() > 0 &&
247 pTColl
->GetAttrOutlineLevel() > 0 &&
248 pTColl
->GetAttrOutlineLevel() <
249 pSplitColl
->GetAttrOutlineLevel() )) &&
250 !pNd
->FindTableNode() ) //<-end,zhaojianwei
257 SwNodeIndex
aEndIdx( pEndNd
? *pEndNd
258 : GetNodes().GetEndOfContent() );
260 // die Nodes komplett rausschreiben
262 if( pSttNd
->GetIndex() + 1 < aEndIdx
.GetIndex() )
264 SfxObjectShellRef
xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL
));
265 if( xDocSh
->DoInitNew( 0 ) )
267 SwDoc
* pDoc
= ((SwDocShell
*)(&xDocSh
))->GetDoc();
269 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
270 ((SwDocShell
*)(&xDocSh
))->GetModel(),
271 uno::UNO_QUERY_THROW
);
272 uno::Reference
<document::XDocumentProperties
> xDocProps(
273 xDPS
->getDocumentProperties());
274 DBG_ASSERT(xDocProps
.is(), "Doc has no DocumentProperties");
275 // the GlobalDoc is the template
276 xDocProps
->setTemplateName(aEmptyStr
);
277 ::util::DateTime
uDT(aTmplDate
.Get100Sec(),
278 aTmplDate
.GetSec(), aTmplDate
.GetMin(),
279 aTmplDate
.GetHour(), aTmplDate
.GetDay(),
280 aTmplDate
.GetMonth(), aTmplDate
.GetYear());
281 xDocProps
->setTemplateDate(uDT
);
282 xDocProps
->setTemplateURL(rPath
);
283 //JP 14.06.99: Set the text of the "split para" as title
284 // from the new doc. Is the current doc has
285 // a title, insert it at begin.
286 String
sTitle( xDocProps
->getTitle() );
288 sTitle
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ));
289 sTitle
+= ((SwTxtNode
*)pSttNd
)->GetExpandTxt();
290 xDocProps
->setTitle( sTitle
);
293 pDoc
->ReplaceStyles( *this );
295 // KapitelNumerierung uebernehmen
297 pDoc
->SetOutlineNumRule( *pOutlineRule
);
299 SwNodeRange
aRg( *pSttNd
, 0, aEndIdx
.GetNode() );
300 SwNodeIndex
aTmpIdx( pDoc
->GetNodes().GetEndOfContent() );
301 GetNodes()._Copy( aRg
, aTmpIdx
, FALSE
);
303 // den initialen TextNode loeschen
304 SwNodeIndex
aIdx( pDoc
->GetNodes().GetEndOfExtras(), 2 );
305 if( aIdx
.GetIndex() + 1 !=
306 pDoc
->GetNodes().GetEndOfContent().GetIndex() )
307 pDoc
->GetNodes().Delete( aIdx
, 1 );
309 // alle Flys in dem Bereich
310 CopyFlyInFlyImpl( aRg
, 0, aIdx
);
313 // und noch alle Bookmarks
316 utl::TempFile
aTempFile2(sLeading
,&sExt
,&sPath
);
317 sFileName
= aTempFile2
.GetURL();
318 SfxMedium
* pTmpMed
= new SfxMedium( sFileName
,
319 STREAM_STD_READWRITE
, TRUE
);
320 pTmpMed
->SetFilter( pFilter
);
322 // fuer den HTML-Filter mussen wir aber ein Layout
323 // haben, damit Textrahmen/Controls/OLE-Objecte korrekt
324 // als Grafik exportiert werden koennen.
325 if( SPLITDOC_TO_HTML
== eDocType
&&
326 pDoc
->GetSpzFrmFmts()->Count() )
328 /* SfxViewFrame* pFrame = */
329 SfxViewFrame::CreateViewFrame( *xDocSh
, 0, TRUE
);
331 xDocSh
->DoSaveAs( *pTmpMed
);
332 xDocSh
->DoSaveCompleted( pTmpMed
);
334 // beim Fehler wird keine FileLinkSection eingefuegt
335 if( xDocSh
->GetError() )
341 // dann koennen ja die Bereiche eingefuegt werden
342 if( sFileName
.Len() )
346 case SPLITDOC_TO_HTML
:
348 // loesche alle Nodes im Bereich und setze im "Start-
349 // Node" den Link auf das gespeicherte Doc
350 ULONG nNodeDiff
= aEndIdx
.GetIndex() -
351 pSttNd
->GetIndex() - 1;
354 SwPaM
aTmp( *pSttNd
, aEndIdx
.GetNode(), 1, -1 );
355 aTmp
.GetPoint()->nContent
.Assign( 0, 0 );
356 aTmp
.GetMark()->nContent
.Assign( 0, 0 );
357 SwNodeIndex
aSIdx( aTmp
.GetMark()->nNode
);
358 SwNodeIndex
aEIdx( aTmp
.GetPoint()->nNode
);
360 // versuche hinters Ende zu verschieben
361 if( !aTmp
.Move( fnMoveForward
, fnGoNode
) )
363 // na gut, dann an den Anfang
365 if( !aTmp
.Move( fnMoveBackward
, fnGoNode
))
367 ASSERT( FALSE
, "kein Node mehr vorhanden" );
370 // Bookmarks usw. verschieben
371 CorrAbs( aSIdx
, aEIdx
, *aTmp
.GetPoint(), TRUE
);
373 // stehen noch FlyFrames rum, loesche auch diese
374 const SwPosition
* pAPos
;
375 for( USHORT n
= 0; n
< GetSpzFrmFmts()->Count(); ++n
)
377 SwFrmFmt
* pFly
= (*GetSpzFrmFmts())[n
];
378 const SwFmtAnchor
* pAnchor
= &pFly
->GetAnchor();
379 if( ( FLY_AT_CNTNT
== pAnchor
->GetAnchorId() ||
380 FLY_AUTO_CNTNT
== pAnchor
->GetAnchorId() ) &&
381 0 != ( pAPos
= pAnchor
->GetCntntAnchor() ) &&
382 aSIdx
<= pAPos
->nNode
&&
383 pAPos
->nNode
< aEIdx
)
385 DelLayoutFmt( pFly
);
390 GetNodes().Delete( aSIdx
, nNodeDiff
);
393 // dann setze im StartNode noch den Link:
394 SwFmtINetFmt
aINet( sFileName
, aEmptyStr
);
395 SwTxtNode
* pTNd
= (SwTxtNode
*)pSttNd
;
396 pTNd
->InsertItem( aINet
, 0, pTNd
->GetTxt().Len() );
398 // wenn der nicht mehr gefunden wird, kann das nur
400 if( !pOutlNds
->Seek_Entry( pSttNd
, &nOutl
))
408 String
sNm( INetURLObject( sFileName
).GetName() );
409 SwSection
aSect( FILE_LINK_SECTION
,
410 GetUniqueSectionName( &sNm
));
411 SwSectionFmt
* pFmt
= MakeSectionFmt( 0 );
412 aSect
.SetLinkFileName(sFileName
);
415 aEndIdx
--; // im InsertSection ist Ende inclusive
416 while( aEndIdx
.GetNode().IsStartNode() )
419 // JP 06.07.99 - Bug 67361 - is any Section ends or
420 // starts in the new sectionrange, they must end or
421 // start before or behind the range!
422 SwSectionNode
* pSectNd
= pSttNd
->FindSectionNode();
423 while( pSectNd
&& pSectNd
->EndOfSectionIndex()
424 <= aEndIdx
.GetIndex() )
426 const SwNode
* pSectEnd
= pSectNd
->EndOfSectionNode();
427 if( pSectNd
->GetIndex() + 1 ==
430 BOOL bMvIdx
= aEndIdx
== *pSectEnd
;
431 DelSectionFmt( pSectNd
->GetSection().GetFmt() );
437 SwNodeRange
aRg( *pSttNd
, *pSectEnd
);
438 SwNodeIndex
aIdx( *pSectEnd
, 1 );
439 GetNodes()._MoveNodes( aRg
, GetNodes(), aIdx
);
441 pSectNd
= pSttNd
->FindSectionNode();
444 pSectNd
= aEndIdx
.GetNode().FindSectionNode();
445 while( pSectNd
&& pSectNd
->GetIndex() >
448 // #i15712# don't attempt to split sections if
449 // they are fully enclosed in [pSectNd,aEndIdx].
450 if( aEndIdx
< pSectNd
->EndOfSectionIndex() )
452 SwNodeRange
aRg( *pSectNd
, 1, aEndIdx
, 1 );
453 SwNodeIndex
aIdx( *pSectNd
);
454 GetNodes()._MoveNodes( aRg
, GetNodes(), aIdx
);
457 pSectNd
= pSttNd
->FindSectionNode();
461 // Ensure order of start and end of section is sane.
462 SwNodeIndex
aStartIdx(*pSttNd
);
464 if (aEndIdx
>= aStartIdx
)
465 pSectNd
= GetNodes().InsertSection
466 (aStartIdx
, *pFmt
, aSect
, &aEndIdx
, FALSE
);
468 pSectNd
= GetNodes().InsertSection
469 (aEndIdx
, *pFmt
, aSect
, &aStartIdx
, FALSE
);
472 pSectNd
->GetSection().CreateLink( CREATE_CONNECT
);
480 // if( pOutlNds != (SwOutlineNodes*)&GetNodes().GetOutLineNds();
481 if( pOutlNds
!= &GetNodes().GetOutLineNds() )
486 case SPLITDOC_TO_HTML
:
487 if( get(IDocumentSettingAccess::GLOBAL_DOCUMENT
) )
489 // dann alles verbliebenen Bereiche aufheben
490 while( GetSections().Count() )
491 DelSectionFmt( GetSections()[ 0 ] );
493 SfxFilterContainer
* pFCntnr
= pDocShell
->GetFactory().GetFilterContainer();
494 pFilter
= pFCntnr
->GetFilter4EA( pFilter
->GetTypeName(), SFX_FILTER_EXPORT
);
498 // case SPLITDOC_TO_GLOBALDOC:
500 // dann das Globaldoc speichern
501 set(IDocumentSettingAccess::GLOBAL_DOCUMENT
, true);
502 set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS
, false);
505 // Medium istn't locked after reopen the document. Bug 91462
506 SfxRequest
aReq( SID_SAVEASDOC
, SFX_CALLMODE_SYNCHRON
, GetAttrPool() );
507 aReq
.AppendItem( SfxStringItem( SID_FILE_NAME
, rPath
) );
508 aReq
.AppendItem( SfxBoolItem( SID_SAVETO
, sal_True
) );
510 aReq
.AppendItem( SfxStringItem( SID_FILTER_NAME
, pFilter
->GetName() ) );
511 const SfxBoolItem
*pRet
= (const SfxBoolItem
*)pDocShell
->ExecuteSlot( aReq
);
513 return pRet
&& pRet
->GetValue();
516 //#outline level,add by zhaojianwei
517 BOOL
SwDoc::SplitDoc( USHORT eDocType
, const String
& rPath
, int nOutlineLevel
)
519 if( !pDocShell
|| !pDocShell
->GetMedium() ||
520 ( SPLITDOC_TO_GLOBALDOC
== eDocType
&& get(IDocumentSettingAccess::GLOBAL_DOCUMENT
) ) )
524 SwOutlineNodes
* pOutlNds
= (SwOutlineNodes
*)&GetNodes().GetOutLineNds();
527 const SfxFilter
* pFilter
;
530 case SPLITDOC_TO_HTML
:
531 pFilter
= SwIoSystem::GetFilterOfFormat( String::CreateFromAscii(
532 RTL_CONSTASCII_STRINGPARAM( "HTML" )));
536 // case SPLITDOC_TO_GLOBALDOC:
537 pFilter
= SwIoSystem::GetFilterOfFormat(
538 String::CreateFromAscii( FILTER_XML
));
539 eDocType
= SPLITDOC_TO_GLOBALDOC
;
546 // Undo/Redline aufjedenfall abschalten
548 SetRedlineMode_intern( (RedlineMode_t
)(GetRedlineMode() & ~nsRedlineMode_t::REDLINE_ON
));
550 String
sExt( pFilter
->GetSuffixes().GetToken(0, ',') );
552 sExt
.AssignAscii( "sxw" );
553 if( '.' != sExt
.GetChar( 0 ) )
554 sExt
.Insert( '.', 0 );
556 INetURLObject
aEntry(rPath
);
557 String
sLeading(aEntry
.GetBase());
558 aEntry
.removeSegment();
559 String sPath
= aEntry
.GetMainURL( INetURLObject::NO_DECODE
);
560 utl::TempFile
aTemp(sLeading
,&sExt
,&sPath
);
561 aTemp
.EnableKillingFile();
565 Time
a2Min( 0 ); a2Min
.SetMin( 2 );
570 // alle Ungueltigen ueberspringen
571 while( nOutl
< pOutlNds
->Count() &&
572 pOutlNds
->GetObject( nOutl
)->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
579 for( ; nOutl
< pOutlNds
->Count(); ++nOutl
)
580 if( ( pNd
= pOutlNds
->GetObject( nOutl
))->GetTxtNode()->GetAttrOutlineLevel() == nOutlineLevel
&&
581 !pNd
->FindTableNode() )
589 SwNodePtr pEndNd
= 0;
590 for( ++nOutl
; nOutl
< pOutlNds
->Count(); ++nOutl
)
592 pNd
= pOutlNds
->GetObject( nOutl
);
594 const int nLevel
= pNd
->GetTxtNode()->GetAttrOutlineLevel();
596 if( ( 0 < nLevel
&& nLevel
<= nOutlineLevel
) &&
597 !pNd
->FindTableNode() )
604 SwNodeIndex
aEndIdx( pEndNd
? *pEndNd
605 : GetNodes().GetEndOfContent() );
608 if( pSttNd
->GetIndex() + 1 < aEndIdx
.GetIndex() )
610 SfxObjectShellRef
xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL
));
611 if( xDocSh
->DoInitNew( 0 ) )
613 SwDoc
* pDoc
= ((SwDocShell
*)(&xDocSh
))->GetDoc();
615 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
616 ((SwDocShell
*)(&xDocSh
))->GetModel(),
617 uno::UNO_QUERY_THROW
);
618 uno::Reference
<document::XDocumentProperties
> xDocProps(
619 xDPS
->getDocumentProperties());
620 DBG_ASSERT(xDocProps
.is(), "Doc has no DocumentProperties");
621 // the GlobalDoc is the template
622 xDocProps
->setTemplateName(aEmptyStr
);
623 ::util::DateTime
uDT(aTmplDate
.Get100Sec(),
624 aTmplDate
.GetSec(), aTmplDate
.GetMin(),
625 aTmplDate
.GetHour(), aTmplDate
.GetDay(),
626 aTmplDate
.GetMonth(), aTmplDate
.GetYear());
627 xDocProps
->setTemplateDate(uDT
);
628 xDocProps
->setTemplateURL(rPath
);
629 //JP 14.06.99: Set the text of the "split para" as title
630 // from the new doc. Is the current doc has
631 // a title, insert it at begin.
632 String
sTitle( xDocProps
->getTitle() );
634 sTitle
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ));
635 sTitle
+= ((SwTxtNode
*)pSttNd
)->GetExpandTxt();
636 xDocProps
->setTitle( sTitle
);
639 pDoc
->ReplaceStyles( *this );
641 // KapitelNumerierung uebernehmen
643 pDoc
->SetOutlineNumRule( *pOutlineRule
);
645 SwNodeRange
aRg( *pSttNd
, 0, aEndIdx
.GetNode() );
646 SwNodeIndex
aTmpIdx( pDoc
->GetNodes().GetEndOfContent() );
647 GetNodes()._Copy( aRg
, aTmpIdx
, FALSE
);
649 // den initialen TextNode loeschen
650 SwNodeIndex
aIdx( pDoc
->GetNodes().GetEndOfExtras(), 2 );
651 if( aIdx
.GetIndex() + 1 !=
652 pDoc
->GetNodes().GetEndOfContent().GetIndex() )
653 pDoc
->GetNodes().Delete( aIdx
, 1 );
655 // alle Flys in dem Bereich
656 CopyFlyInFlyImpl( aRg
, 0, aIdx
);
659 // und noch alle Bookmarks
662 utl::TempFile
aTempFile2(sLeading
,&sExt
,&sPath
);
663 sFileName
= aTempFile2
.GetURL();
664 SfxMedium
* pTmpMed
= new SfxMedium( sFileName
,
665 STREAM_STD_READWRITE
, TRUE
);
666 pTmpMed
->SetFilter( pFilter
);
668 // fuer den HTML-Filter mussen wir aber ein Layout
669 // haben, damit Textrahmen/Controls/OLE-Objecte korrekt
670 // als Grafik exportiert werden koennen.
671 if( SPLITDOC_TO_HTML
== eDocType
&&
672 pDoc
->GetSpzFrmFmts()->Count() )
674 /* SfxViewFrame* pFrame = */
675 SfxViewFrame::CreateViewFrame( *xDocSh
, 0, TRUE
);
677 xDocSh
->DoSaveAs( *pTmpMed
);
678 xDocSh
->DoSaveCompleted( pTmpMed
);
680 // beim Fehler wird keine FileLinkSection eingefuegt
681 if( xDocSh
->GetError() )
687 // dann koennen ja die Bereiche eingefuegt werden
688 if( sFileName
.Len() )
692 case SPLITDOC_TO_HTML
:
694 // loesche alle Nodes im Bereich und setze im "Start-
695 // Node" den Link auf das gespeicherte Doc
696 ULONG nNodeDiff
= aEndIdx
.GetIndex() -
697 pSttNd
->GetIndex() - 1;
700 SwPaM
aTmp( *pSttNd
, aEndIdx
.GetNode(), 1, -1 );
701 aTmp
.GetPoint()->nContent
.Assign( 0, 0 );
702 aTmp
.GetMark()->nContent
.Assign( 0, 0 );
703 SwNodeIndex
aSIdx( aTmp
.GetMark()->nNode
);
704 SwNodeIndex
aEIdx( aTmp
.GetPoint()->nNode
);
706 // versuche hinters Ende zu verschieben
707 if( !aTmp
.Move( fnMoveForward
, fnGoNode
) )
709 // na gut, dann an den Anfang
711 if( !aTmp
.Move( fnMoveBackward
, fnGoNode
))
713 ASSERT( FALSE
, "kein Node mehr vorhanden" );
716 // Bookmarks usw. verschieben
717 CorrAbs( aSIdx
, aEIdx
, *aTmp
.GetPoint(), TRUE
);
719 // stehen noch FlyFrames rum, loesche auch diese
720 const SwPosition
* pAPos
;
721 for( USHORT n
= 0; n
< GetSpzFrmFmts()->Count(); ++n
)
723 SwFrmFmt
* pFly
= (*GetSpzFrmFmts())[n
];
724 const SwFmtAnchor
* pAnchor
= &pFly
->GetAnchor();
725 if( ( FLY_AT_CNTNT
== pAnchor
->GetAnchorId() ||
726 FLY_AUTO_CNTNT
== pAnchor
->GetAnchorId() ) &&
727 0 != ( pAPos
= pAnchor
->GetCntntAnchor() ) &&
728 aSIdx
<= pAPos
->nNode
&&
729 pAPos
->nNode
< aEIdx
)
731 DelLayoutFmt( pFly
);
736 GetNodes().Delete( aSIdx
, nNodeDiff
);
739 // dann setze im StartNode noch den Link:
740 SwFmtINetFmt
aINet( sFileName
, aEmptyStr
);
741 SwTxtNode
* pTNd
= (SwTxtNode
*)pSttNd
;
742 pTNd
->InsertItem( aINet
, 0, pTNd
->GetTxt().Len() );
744 // wenn der nicht mehr gefunden wird, kann das nur
746 if( !pOutlNds
->Seek_Entry( pSttNd
, &nOutl
))
754 String
sNm( INetURLObject( sFileName
).GetName() );
755 SwSection
aSect( FILE_LINK_SECTION
,
756 GetUniqueSectionName( &sNm
));
757 SwSectionFmt
* pFmt
= MakeSectionFmt( 0 );
758 aSect
.SetLinkFileName(sFileName
);
761 aEndIdx
--; // im InsertSection ist Ende inclusive
762 while( aEndIdx
.GetNode().IsStartNode() )
765 // JP 06.07.99 - Bug 67361 - is any Section ends or
766 // starts in the new sectionrange, they must end or
767 // start before or behind the range!
768 SwSectionNode
* pSectNd
= pSttNd
->FindSectionNode();
769 while( pSectNd
&& pSectNd
->EndOfSectionIndex()
770 <= aEndIdx
.GetIndex() )
772 const SwNode
* pSectEnd
= pSectNd
->EndOfSectionNode();
773 if( pSectNd
->GetIndex() + 1 ==
776 BOOL bMvIdx
= aEndIdx
== *pSectEnd
;
777 DelSectionFmt( pSectNd
->GetSection().GetFmt() );
783 SwNodeRange
aRg( *pSttNd
, *pSectEnd
);
784 SwNodeIndex
aIdx( *pSectEnd
, 1 );
785 GetNodes()._MoveNodes( aRg
, GetNodes(), aIdx
);
787 pSectNd
= pSttNd
->FindSectionNode();
790 pSectNd
= aEndIdx
.GetNode().FindSectionNode();
791 while( pSectNd
&& pSectNd
->GetIndex() >
794 if( aEndIdx
< pSectNd
->EndOfSectionIndex() )
796 SwNodeRange
aRg( *pSectNd
, 1, aEndIdx
, 1 );
797 SwNodeIndex
aIdx( *pSectNd
);
798 GetNodes()._MoveNodes( aRg
, GetNodes(), aIdx
);
801 pSectNd
= pSttNd
->FindSectionNode();
804 SwNodeIndex
aStartIdx(*pSttNd
);
806 if (aEndIdx
>= aStartIdx
)
807 pSectNd
= GetNodes().InsertSection
808 (aStartIdx
, *pFmt
, aSect
, &aEndIdx
, FALSE
);
810 pSectNd
= GetNodes().InsertSection
811 (aEndIdx
, *pFmt
, aSect
, &aStartIdx
, FALSE
);
813 pSectNd
->GetSection().CreateLink( CREATE_CONNECT
);
821 if( pOutlNds
!= &GetNodes().GetOutLineNds() )
826 case SPLITDOC_TO_HTML
:
827 if( get(IDocumentSettingAccess::GLOBAL_DOCUMENT
) )
829 while( GetSections().Count() )
830 DelSectionFmt( GetSections()[ 0 ] );
832 SfxFilterContainer
* pFCntnr
= pDocShell
->GetFactory().GetFilterContainer();
833 pFilter
= pFCntnr
->GetFilter4EA( pFilter
->GetTypeName(), SFX_FILTER_EXPORT
);
837 // case SPLITDOC_TO_GLOBALDOC:
839 set(IDocumentSettingAccess::GLOBAL_DOCUMENT
, true);
840 set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS
, false);
843 SfxRequest
aReq( SID_SAVEASDOC
, SFX_CALLMODE_SYNCHRON
, GetAttrPool() );
844 aReq
.AppendItem( SfxStringItem( SID_FILE_NAME
, rPath
) );
845 aReq
.AppendItem( SfxBoolItem( SID_SAVETO
, sal_True
) );
847 aReq
.AppendItem( SfxStringItem( SID_FILTER_NAME
, pFilter
->GetName() ) );
848 const SfxBoolItem
*pRet
= (const SfxBoolItem
*)pDocShell
->ExecuteSlot( aReq
);
850 return pRet
&& pRet
->GetValue();