1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "fuinsfil.hxx"
21 #include <vcl/wrkwin.hxx>
22 #include <sfx2/progress.hxx>
23 #include <editeng/outliner.hxx>
24 #include <editeng/outlobj.hxx>
25 #include <editeng/editeng.hxx>
26 #include <svl/stritem.hxx>
27 #include <sfx2/request.hxx>
28 #include <sfx2/app.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <sfx2/printer.hxx>
31 #include <svx/svdorect.hxx>
32 #include <svx/svdundo.hxx>
33 #include <svx/svdoutl.hxx>
34 #include <sfx2/filedlghelper.hxx>
35 #include <sot/formats.hxx>
36 #include <svl/urihelper.hxx>
37 #include <editeng/forbiddencharacterstable.hxx>
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/docfilt.hxx>
40 #include <sfx2/fcontnr.hxx>
41 #include <svx/svdpagv.hxx>
42 #include <svx/dialogs.hrc>
43 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
45 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
46 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
48 #include "sdresid.hxx"
49 #include "drawdoc.hxx"
52 #include "strings.hrc"
53 #include "stlpool.hxx"
57 #include "DrawViewShell.hxx"
58 #include "OutlineViewShell.hxx"
59 #include "DrawDocShell.hxx"
60 #include "GraphicDocShell.hxx"
62 #include "unmovss.hxx"
63 #include "Outliner.hxx"
64 #include "sdabstdlg.hxx"
65 #include <boost/scoped_ptr.hpp>
67 using namespace ::com::sun::star::lang
;
68 using namespace ::com::sun::star::uno
;
69 using namespace ::com::sun::star::ui::dialogs
;
70 using namespace ::com::sun::star
;
72 typedef ::std::pair
< OUString
, OUString
> FilterDesc
;
77 OUString
lcl_GetExtensionsList ( ::std::vector
< FilterDesc
> const& rFilterDescList
)
80 ::std::vector
< FilterDesc
>::const_iterator
aIter( rFilterDescList
.begin() );
82 while (aIter
!= rFilterDescList
.end())
84 OUString sWildcard
= (*aIter
).second
;
86 if ( aExtensions
.indexOf( sWildcard
) == -1 )
88 if ( !aExtensions
.isEmpty() )
90 aExtensions
+= sWildcard
;
99 void lcl_AddFilter ( ::std::vector
< FilterDesc
>& rFilterDescList
,
100 const SfxFilter
*pFilter
)
103 rFilterDescList
.push_back( ::std::make_pair( pFilter
->GetUIName(), pFilter
->GetDefaultExtension() ) );
110 TYPEINIT1( FuInsertFile
, FuPoor
);
112 FuInsertFile::FuInsertFile (
116 SdDrawDocument
* pDoc
,
118 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
122 rtl::Reference
<FuPoor
> FuInsertFile::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
124 rtl::Reference
<FuPoor
> xFunc( new FuInsertFile( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
125 xFunc
->DoExecute(rReq
);
129 void FuInsertFile::DoExecute( SfxRequest
& rReq
)
131 SfxFilterMatcher
& rMatcher
= SfxGetpApp()->GetFilterMatcher();
132 ::std::vector
< FilterDesc
> aFilterVector
;
133 ::std::vector
< OUString
> aOtherFilterVector
;
134 const SfxItemSet
* pArgs
= rReq
.GetArgs ();
136 FuInsertFile::GetSupportedFilterVector( aOtherFilterVector
);
140 sfx2::FileDialogHelper
aFileDialog(
141 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
,
143 Reference
< XFilePicker
> xFilePicker( aFileDialog
.GetFilePicker(), UNO_QUERY
);
144 Reference
< XFilterManager
> xFilterManager( xFilePicker
, UNO_QUERY
);
148 aFileDialog
.SetTitle( SD_RESSTR(STR_DLG_INSERT_PAGES_FROM_FILE
) );
150 if( mpDoc
->GetDocumentType() == DOCUMENT_TYPE_IMPRESS
)
152 aOwnCont
= "simpress";
153 aOtherCont
= "sdraw";
157 aOtherCont
= "simpress";
161 SfxFilterMatcher
aMatch( aOwnCont
);
163 if( xFilterManager
.is() )
165 // Get filter for current format
169 const SfxFilter
* pFilter
= SfxFilter::GetDefaultFilterFromFactory( aOwnCont
);
170 lcl_AddFilter( aFilterVector
, pFilter
);
172 // get template filter
173 if( mpDoc
->GetDocumentType() == DOCUMENT_TYPE_IMPRESS
)
174 pFilter
= DrawDocShell::Factory().GetTemplateFilter();
176 pFilter
= GraphicDocShell::Factory().GetTemplateFilter();
177 lcl_AddFilter( aFilterVector
, pFilter
);
180 pFilter
= SfxFilter::GetDefaultFilterFromFactory( aOtherCont
);
181 lcl_AddFilter( aFilterVector
, pFilter
);
183 // get Powerpoint filter
184 OUString aExt
= ".ppt";
185 pFilter
= aMatch
.GetFilter4Extension( aExt
);
186 lcl_AddFilter( aFilterVector
, pFilter
);
188 // Get other draw/impress filters
189 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60
, SfxFilterFlags::IMPORT
, SfxFilterFlags::TEMPLATEPATH
);
190 lcl_AddFilter( aFilterVector
, pFilter
);
192 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60
, SfxFilterFlags::TEMPLATEPATH
);
193 lcl_AddFilter( aFilterVector
, pFilter
);
195 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60
, SfxFilterFlags::IMPORT
, SfxFilterFlags::TEMPLATEPATH
);
196 lcl_AddFilter( aFilterVector
, pFilter
);
198 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60
, SfxFilterFlags::TEMPLATEPATH
);
199 lcl_AddFilter( aFilterVector
, pFilter
);
201 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW
, SfxFilterFlags::IMPORT
, SfxFilterFlags::TEMPLATEPATH
);
202 lcl_AddFilter( aFilterVector
, pFilter
);
204 pFilter
= aMatch
.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW
, SfxFilterFlags::TEMPLATEPATH
);
205 lcl_AddFilter( aFilterVector
, pFilter
);
207 // add additional supported filters
208 ::std::vector
< OUString
>::const_iterator
aOtherIter( aOtherFilterVector
.begin() );
210 while( aOtherIter
!= aOtherFilterVector
.end() )
212 if( ( pFilter
= rMatcher
.GetFilter4Mime( *aOtherIter
) ) != NULL
)
213 lcl_AddFilter( aFilterVector
, pFilter
);
218 // set default-filter (<All>)
219 OUString
aAllSpec( SD_RESSTR( STR_ALL_FILES
) );
220 OUString aExtensions
= lcl_GetExtensionsList( aFilterVector
);
221 OUString aGUIName
= aAllSpec
+ " (" + aExtensions
+ ")";
223 xFilterManager
->appendFilter( aGUIName
, aExtensions
);
224 xFilterManager
->setCurrentFilter( aAllSpec
);
226 // add filters to filter manager finally
227 ::std::vector
< ::std::pair
< OUString
, OUString
> >::const_iterator
aIter( aFilterVector
.begin() );
229 while( aIter
!= aFilterVector
.end() )
231 xFilterManager
->appendFilter( (*aIter
).first
, (*aIter
).second
);
236 catch (const IllegalArgumentException
&)
241 if( aFileDialog
.Execute() != ERRCODE_NONE
)
245 aFilterName
= aFileDialog
.GetCurrentFilter();
246 aFile
= aFileDialog
.GetPath();
251 SFX_REQUEST_ARG (rReq
, pFileName
, SfxStringItem
, ID_VAL_DUMMY0
, false);
252 SFX_REQUEST_ARG (rReq
, pFilterName
, SfxStringItem
, ID_VAL_DUMMY1
, false);
254 aFile
= pFileName
->GetValue ();
257 aFilterName
= pFilterName
->GetValue ();
260 mpDocSh
->SetWaitCursor( true );
262 SfxMedium
* pMedium
= new SfxMedium( aFile
, StreamMode::READ
| StreamMode::NOCREATE
);
263 const SfxFilter
* pFilter
= NULL
;
265 SfxGetpApp()->GetFilterMatcher().GuessFilter( *pMedium
, &pFilter
, SfxFilterFlags::IMPORT
, SFX_FILTER_NOTINSTALLED
| SfxFilterFlags::EXECUTABLE
);
267 bool bDrawMode
= mpViewShell
&& mpViewShell
->ISA(DrawViewShell
);
268 bool bInserted
= false;
272 pMedium
->SetFilter( pFilter
);
273 aFilterName
= pFilter
->GetFilterName();
275 if( pMedium
->IsStorage() || ( pMedium
->GetInStream() && SotStorage::IsStorageFile( pMedium
->GetInStream() ) ) )
277 if ( pFilter
->GetServiceName() == "com.sun.star.presentation.PresentationDocument" ||
278 pFilter
->GetServiceName() == "com.sun.star.drawing.DrawingDocument" )
280 // Draw, Impress or PowerPoint document
281 // the ownership of the Medium is transferred
283 InsSDDinDrMode( pMedium
);
285 InsSDDinOlMode( pMedium
);
287 // don't delete Medium here, ownership of pMedium has changed in this case
293 bool bFound
= ( ::std::find( aOtherFilterVector
.begin(), aOtherFilterVector
.end(), pFilter
->GetMimeType() ) != aOtherFilterVector
.end() );
295 ( aFilterName
.indexOf( "Text" ) != -1 ||
296 aFilterName
.indexOf( "Rich" ) != -1 ||
297 aFilterName
.indexOf( "RTF" ) != -1 ||
298 aFilterName
.indexOf( "HTML" ) != -1 ) )
306 InsTextOrRTFinDrMode(pMedium
);
308 InsTextOrRTFinOlMode(pMedium
);
316 mpDocSh
->SetWaitCursor( false );
320 ScopedVclPtrInstance
< MessageDialog
> aErrorBox(mpWindow
, SD_RESSTR( STR_READ_DATA_ERROR
));
321 aErrorBox
->Execute();
326 bool FuInsertFile::InsSDDinDrMode(SfxMedium
* pMedium
)
330 mpDocSh
->SetWaitCursor( false );
331 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
332 boost::scoped_ptr
<AbstractSdInsertPagesObjsDlg
> pDlg(pFact
? pFact
->CreateSdInsertPagesObjsDlg( NULL
, mpDoc
, pMedium
, aFile
) : 0);
337 /* Maybe a QueryBox is opened ("update links?"), therefore the dialog
338 becomes the current DefModalDialogParent */
339 vcl::Window
* pDefParent
= Application::GetDefDialogParent();
340 Application::SetDefDialogParent(pDlg
->GetWindow());
342 sal_uInt16 nRet
= pDlg
->Execute();
344 Application::SetDefDialogParent(pDefParent
);
346 mpDocSh
->SetWaitCursor( true );
350 /* list with page names (if NULL, then all pages)
351 First, insert pages */
352 std::vector
<OUString
> aBookmarkList
= pDlg
->GetList( 1 ); // pages
353 bool bLink
= pDlg
->IsLink();
354 bool bReplace
= false;
355 SdPage
* pPage
= NULL
;
356 ::sd::View
* pView
= mpViewShell
? mpViewShell
->GetView() : NULL
;
360 if (pView
->ISA(OutlineView
))
362 pPage
= static_cast<OutlineView
*>(pView
)->GetActualPage();
366 pPage
= static_cast<SdPage
*>(pView
->GetSdrPageView()->GetPage());
370 sal_uInt16 nPos
= 0xFFFF;
372 if (pPage
&& !pPage
->IsMasterPage())
374 if (pPage
->GetPageKind() == PK_STANDARD
)
376 nPos
= pPage
->GetPageNum() + 2;
378 else if (pPage
->GetPageKind() == PK_NOTES
)
380 nPos
= pPage
->GetPageNum() + 1;
385 std::vector
<OUString
> aExchangeList
;
386 std::vector
<OUString
> aObjectBookmarkList
= pDlg
->GetList( 2 ); // objects
388 /* if pBookmarkList is NULL, we insert selected pages, and/or selected
389 objects or everything. */
390 if( !aBookmarkList
.empty() || aObjectBookmarkList
.empty() )
392 /* To ensure that all page names are unique, we check the ones we
393 want to insert and insert them into a substitution list if
395 bNameOK is sal_False if the user has canceled. */
396 bNameOK
= mpView
->GetExchangeList( aExchangeList
, aBookmarkList
, 0 );
399 bOK
= mpDoc
->InsertBookmarkAsPage( aBookmarkList
, &aExchangeList
,
400 bLink
, bReplace
, nPos
,
401 false, NULL
, true, true, false );
403 aBookmarkList
.clear();
404 aExchangeList
.clear();
407 // to ensure ... (see above)
408 bNameOK
= mpView
->GetExchangeList( aExchangeList
, aObjectBookmarkList
, 1 );
411 bOK
= mpDoc
->InsertBookmarkAsObject( aObjectBookmarkList
, aExchangeList
,
414 if( pDlg
->IsRemoveUnnessesaryMasterPages() )
415 mpDoc
->RemoveUnnecessaryMasterPages();
421 void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium
* pMedium
)
423 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
424 boost::scoped_ptr
<AbstractSdInsertPagesObjsDlg
> pDlg(pFact
? pFact
->CreateSdInsertPagesObjsDlg(NULL
, mpDoc
, NULL
, aFile
) : 0);
428 mpDocSh
->SetWaitCursor( false );
430 sal_uInt16 nRet
= pDlg
->Execute();
431 mpDocSh
->SetWaitCursor( true );
435 // selected file format: text, RTF or HTML (default is text)
436 sal_uInt16 nFormat
= EE_FORMAT_TEXT
;
438 if( aFilterName
.indexOf( "Rich") != -1 )
439 nFormat
= EE_FORMAT_RTF
;
440 else if( aFilterName
.indexOf( "HTML" ) != -1 )
441 nFormat
= EE_FORMAT_HTML
;
443 /* create our own outline since:
444 - it is possible that the document outliner is actually used in the
446 - the draw outliner of the drawing engine has to draw something in
448 - the global outliner could be used in SdPage::CreatePresObj */
449 boost::scoped_ptr
<SdrOutliner
> pOutliner(new ::sd::Outliner( mpDoc
, OUTLINERMODE_TEXTOBJECT
));
451 // set reference device
452 pOutliner
->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh
) );
454 SdPage
* pPage
= static_cast<DrawViewShell
*>(mpViewShell
)->GetActualPage();
455 aLayoutName
= pPage
->GetLayoutName();
456 sal_Int32 nIndex
= aLayoutName
.indexOf(SD_LT_SEPARATOR
);
458 aLayoutName
= aLayoutName
.copy(0, nIndex
);
460 pOutliner
->SetPaperSize(pPage
->GetSize());
462 SvStream
* pStream
= pMedium
->GetInStream();
463 assert(pStream
&& "No InStream!");
466 sal_uLong nErr
= pOutliner
->Read( *pStream
, pMedium
->GetBaseURL(), nFormat
, mpDocSh
->GetHeaderAttributes() );
468 if (nErr
|| pOutliner
->GetEditEngine().GetText().isEmpty())
470 ScopedVclPtrInstance
< MessageDialog
> aErrorBox(mpWindow
, SD_RESSTR(STR_READ_DATA_ERROR
));
471 aErrorBox
->Execute();
475 // is it a master page?
476 if (static_cast<DrawViewShell
*>(mpViewShell
)->GetEditMode() == EM_MASTERPAGE
&&
477 !pPage
->IsMasterPage())
479 pPage
= static_cast<SdPage
*>(&(pPage
->TRG_GetMasterPage()));
482 assert(pPage
&& "page not found");
484 // if editing is going on right now, let it flow into this text object
485 OutlinerView
* pOutlinerView
= mpView
->GetTextEditOutlinerView();
488 SdrObject
* pObj
= mpView
->GetTextEditObject();
490 pObj
->GetObjInventor() == SdrInventor
&&
491 pObj
->GetObjIdentifier() == OBJ_TITLETEXT
&&
492 pOutliner
->GetParagraphCount() > 1 )
494 // in title objects, only one paragraph is allowed
495 while ( pOutliner
->GetParagraphCount() > 1 )
497 Paragraph
* pPara
= pOutliner
->GetParagraph( 0 );
498 sal_uLong nLen
= pOutliner
->GetText( pPara
, 1 ).getLength();
499 pOutliner
->QuickDelete( ESelection( 0, nLen
, 1, 0 ) );
500 pOutliner
->QuickInsertLineBreak( ESelection( 0, nLen
, 0, nLen
) );
505 OutlinerParaObject
* pOPO
= pOutliner
->CreateParaObject();
509 pOutlinerView
->InsertText(*pOPO
);
514 SdrRectObj
* pTO
= new SdrRectObj(OBJ_TEXT
);
515 pTO
->SetOutlinerParaObject(pOPO
);
517 const bool bUndo
= mpView
->IsUndoEnabled();
519 mpView
->BegUndo(SD_RESSTR(STR_UNDO_INSERT_TEXTFRAME
));
520 pPage
->InsertObject(pTO
);
522 /* can be bigger as the maximal allowed size:
523 limit object size if necessary */
524 Size
aSize(pOutliner
->CalcTextSize());
525 Size aMaxSize
= mpDoc
->GetMaxObjSize();
526 aSize
.Height() = std::min(aSize
.Height(), aMaxSize
.Height());
527 aSize
.Width() = std::min(aSize
.Width(), aMaxSize
.Width());
528 aSize
= mpWindow
->LogicToPixel(aSize
);
530 // put it at the center of the window
531 Size
aTemp(mpWindow
->GetOutputSizePixel());
532 Point
aPos(aTemp
.Width() / 2, aTemp
.Height() / 2);
533 aPos
.X() -= aSize
.Width() / 2;
534 aPos
.Y() -= aSize
.Height() / 2;
535 aSize
= mpWindow
->PixelToLogic(aSize
);
536 aPos
= mpWindow
->PixelToLogic(aPos
);
537 pTO
->SetLogicRect(Rectangle(aPos
, aSize
));
541 pTO
->SetTextLink(aFile
, aFilterName
, osl_getThreadTextEncoding() );
546 mpView
->AddUndo(mpDoc
->GetSdrUndoFactory().CreateUndoInsertObject(*pTO
));
554 void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium
* pMedium
)
556 // selected file format: text, RTF or HTML (default is text)
557 sal_uInt16 nFormat
= EE_FORMAT_TEXT
;
559 if( aFilterName
.indexOf( "Rich") != -1 )
560 nFormat
= EE_FORMAT_RTF
;
561 else if( aFilterName
.indexOf( "HTML" ) != -1 )
562 nFormat
= EE_FORMAT_HTML
;
564 ::Outliner
& rDocliner
= static_cast<OutlineView
*>(mpView
)->GetOutliner();
566 std::vector
<Paragraph
*> aSelList
;
567 rDocliner
.GetView(0)->CreateSelectionList(aSelList
);
569 Paragraph
* pPara
= aSelList
.empty() ? NULL
: *(aSelList
.begin());
571 // what should we insert?
572 while (pPara
&& !Outliner::HasParaFlag(pPara
, ParaFlag::ISPAGE
))
573 pPara
= rDocliner
.GetParent(pPara
);
575 sal_Int32 nTargetPos
= rDocliner
.GetAbsPos(pPara
) + 1;
577 // apply layout of predecessor page
578 sal_uInt16 nPage
= 0;
579 pPara
= rDocliner
.GetParagraph( rDocliner
.GetAbsPos( pPara
) - 1 );
582 sal_Int32 nPos
= rDocliner
.GetAbsPos( pPara
);
583 if ( Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
585 pPara
= rDocliner
.GetParagraph( nPos
- 1 );
587 SdPage
* pPage
= mpDoc
->GetSdPage(nPage
, PK_STANDARD
);
588 aLayoutName
= pPage
->GetLayoutName();
589 sal_Int32 nIndex
= aLayoutName
.indexOf(SD_LT_SEPARATOR
);
591 aLayoutName
= aLayoutName
.copy(0, nIndex
);
593 /* create our own outline since:
594 - it is possible that the document outliner is actually used in the
596 - the draw outliner of the drawing engine has to draw something in
598 - the global outliner could be used in SdPage::CreatePresObj */
599 boost::scoped_ptr
< ::Outliner
> pOutliner(new ::Outliner( &mpDoc
->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT
));
600 pOutliner
->SetStyleSheetPool(static_cast<SfxStyleSheetPool
*>(mpDoc
->GetStyleSheetPool()));
602 // set reference device
603 pOutliner
->SetRefDevice(SD_MOD()->GetRefDevice( *mpDocSh
));
604 pOutliner
->SetPaperSize(Size(0x7fffffff, 0x7fffffff));
606 SvStream
* pStream
= pMedium
->GetInStream();
607 DBG_ASSERT( pStream
, "No InStream!" );
610 sal_uLong nErr
= pOutliner
->Read(*pStream
, pMedium
->GetBaseURL(), nFormat
, mpDocSh
->GetHeaderAttributes());
612 if (nErr
|| pOutliner
->GetEditEngine().GetText().isEmpty())
614 ScopedVclPtrInstance
< MessageDialog
> aErrorBox(mpWindow
, SD_RESSTR(STR_READ_DATA_ERROR
));
615 aErrorBox
->Execute();
619 sal_Int32 nParaCount
= pOutliner
->GetParagraphCount();
621 // for progress bar: number of level-0-paragraphs
622 sal_uInt16 nNewPages
= 0;
623 pPara
= pOutliner
->GetParagraph( 0 );
626 sal_Int32 nPos
= pOutliner
->GetAbsPos( pPara
);
627 if( Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
629 pPara
= pOutliner
->GetParagraph( ++nPos
);
632 mpDocSh
->SetWaitCursor( false );
634 boost::scoped_ptr
<SfxProgress
> pProgress(new SfxProgress( mpDocSh
, SD_RESSTR(STR_CREATE_PAGES
), nNewPages
));
636 pProgress
->SetState( 0, 100 );
640 rDocliner
.GetUndoManager().EnterListAction(
641 SD_RESSTR(STR_UNDO_INSERT_FILE
), OUString() );
643 sal_Int32 nSourcePos
= 0;
644 SfxStyleSheet
* pStyleSheet
= pPage
->GetStyleSheetForPresObj( PRESOBJ_OUTLINE
);
645 Paragraph
* pSourcePara
= pOutliner
->GetParagraph( 0 );
648 sal_Int32 nPos
= pOutliner
->GetAbsPos( pSourcePara
);
649 sal_Int16 nDepth
= pOutliner
->GetDepth( nPos
);
651 // only take the last paragraph if it is filled
652 if (nSourcePos
< nParaCount
- 1 ||
653 !pOutliner
->GetText(pSourcePara
).isEmpty())
655 rDocliner
.Insert( pOutliner
->GetText(pSourcePara
), nTargetPos
, nDepth
);
656 OUString
aStyleSheetName( pStyleSheet
->GetName() );
657 aStyleSheetName
= aStyleSheetName
.copy( 0, aStyleSheetName
.getLength()-1 );
658 aStyleSheetName
+= OUString::number( nDepth
<= 0 ? 1 : nDepth
+1 );
659 SfxStyleSheetBasePool
* pStylePool
= mpDoc
->GetStyleSheetPool();
660 SfxStyleSheet
* pOutlStyle
= static_cast<SfxStyleSheet
*>( pStylePool
->Find( aStyleSheetName
, pStyleSheet
->GetFamily() ) );
661 rDocliner
.SetStyleSheet( nTargetPos
, pOutlStyle
);
664 if( Outliner::HasParaFlag( pSourcePara
, ParaFlag::ISPAGE
) )
668 pProgress
->SetState( nNewPages
);
671 pSourcePara
= pOutliner
->GetParagraph( ++nPos
);
676 rDocliner
.GetUndoManager().LeaveListAction();
680 mpDocSh
->SetWaitCursor( true );
684 bool FuInsertFile::InsSDDinOlMode(SfxMedium
* pMedium
)
686 OutlineView
* pOlView
= static_cast<OutlineView
*>(mpView
);
688 // transfer Outliner content to SdDrawDocument
689 pOlView
->PrepareClose();
691 // einlesen wie im Zeichenmodus
692 if (InsSDDinDrMode(pMedium
))
694 ::Outliner
* pOutliner
= pOlView
->GetViewByWindow(mpWindow
)->GetOutliner();
696 // cut notification links temporarily
697 Link
<> aOldParagraphInsertedHdl
= pOutliner
->GetParaInsertedHdl();
698 pOutliner
->SetParaInsertedHdl( Link
<>(NULL
, NULL
));
699 Link
<> aOldParagraphRemovingHdl
= pOutliner
->GetParaRemovingHdl();
700 pOutliner
->SetParaRemovingHdl( Link
<>(NULL
, NULL
));
701 Link
<> aOldDepthChangedHdl
= pOutliner
->GetDepthChangedHdl();
702 pOutliner
->SetDepthChangedHdl( Link
<>(NULL
, NULL
));
703 Link
<> aOldBeginMovingHdl
= pOutliner
->GetBeginMovingHdl();
704 pOutliner
->SetBeginMovingHdl( Link
<>(NULL
, NULL
));
705 Link
<> aOldEndMovingHdl
= pOutliner
->GetEndMovingHdl();
706 pOutliner
->SetEndMovingHdl( Link
<>(NULL
, NULL
));
708 Link
<> aOldStatusEventHdl
= pOutliner
->GetStatusEventHdl();
709 pOutliner
->SetStatusEventHdl(Link
<>(NULL
, NULL
));
712 pOlView
->FillOutliner();
715 pOutliner
->SetParaInsertedHdl(aOldParagraphInsertedHdl
);
716 pOutliner
->SetParaRemovingHdl(aOldParagraphRemovingHdl
);
717 pOutliner
->SetDepthChangedHdl(aOldDepthChangedHdl
);
718 pOutliner
->SetBeginMovingHdl(aOldBeginMovingHdl
);
719 pOutliner
->SetEndMovingHdl(aOldEndMovingHdl
);
720 pOutliner
->SetStatusEventHdl(aOldStatusEventHdl
);
728 void FuInsertFile::GetSupportedFilterVector( ::std::vector
< OUString
>& rFilterVector
)
730 SfxFilterMatcher
& rMatcher
= SfxGetpApp()->GetFilterMatcher();
731 const SfxFilter
* pSearchFilter
= NULL
;
733 rFilterVector
.clear();
735 if( ( pSearchFilter
= rMatcher
.GetFilter4Mime( "text/plain" )) != NULL
)
736 rFilterVector
.push_back( pSearchFilter
->GetMimeType() );
738 if( ( pSearchFilter
= rMatcher
.GetFilter4Mime( "application/rtf" ) ) != NULL
)
739 rFilterVector
.push_back( pSearchFilter
->GetMimeType() );
741 if( ( pSearchFilter
= rMatcher
.GetFilter4Mime( "text/html" ) ) != NULL
)
742 rFilterVector
.push_back( pSearchFilter
->GetMimeType() );
745 } // end of namespace sd
747 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */