LibreOffice Module sd (master) 1
fuinsfil.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <fuinsfil.hxx>
21#include <vcl/svapp.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/weld.hxx>
30#include <svx/svdorect.hxx>
31#include <svx/svdundo.hxx>
32#include <svx/svdoutl.hxx>
34#include <sot/formats.hxx>
35#include <sfx2/docfile.hxx>
36#include <sfx2/docfilt.hxx>
37#include <sfx2/fcontnr.hxx>
38#include <svx/svdpagv.hxx>
39#include <svx/svxids.hrc>
40#include <tools/debug.hxx>
41#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
42#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
43#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
44#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
45
46#include <sdresid.hxx>
47#include <drawdoc.hxx>
48#include <Window.hxx>
49#include <View.hxx>
50#include <strings.hrc>
51#include <sdmod.hxx>
52#include <sdpage.hxx>
53#include <ViewShellBase.hxx>
54#include <DrawViewShell.hxx>
55#include <OutlineView.hxx>
56#include <DrawDocShell.hxx>
57#include <GraphicDocShell.hxx>
58#include <app.hrc>
59#include <Outliner.hxx>
60#include <sdabstdlg.hxx>
61#include <memory>
62
63using namespace ::com::sun::star::lang;
64using namespace ::com::sun::star::uno;
65using namespace ::com::sun::star::ui::dialogs;
66using namespace ::com::sun::star;
67
68typedef ::std::pair< OUString, OUString > FilterDesc;
69
70namespace
71{
72
73OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescList )
74{
75 OUStringBuffer aExtensions;
76
77 for (const auto& rFilterDesc : rFilterDescList)
78 {
79 OUString sWildcard = rFilterDesc.second;
80
81 if ( aExtensions.indexOf( sWildcard ) == -1 )
82 {
83 if ( !aExtensions.isEmpty() )
84 aExtensions.append(";");
85 aExtensions.append(sWildcard);
86 }
87
88 }
89
90 return aExtensions.makeStringAndClear();
91}
92
93void lcl_AddFilter ( ::std::vector< FilterDesc >& rFilterDescList,
94 const std::shared_ptr<const SfxFilter>& pFilter )
95{
96 if (pFilter)
97 rFilterDescList.emplace_back( pFilter->GetUIName(), pFilter->GetDefaultExtension() );
98}
99
100}
101
102namespace sd {
103
104
106 ViewShell* pViewSh,
107 ::sd::Window* pWin,
108 ::sd::View* pView,
109 SdDrawDocument* pDoc,
110 SfxRequest& rReq)
111 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
112{
113}
114
116{
117 rtl::Reference<FuPoor> xFunc( new FuInsertFile( pViewSh, pWin, pView, pDoc, rReq ) );
118 xFunc->DoExecute(rReq);
119 return xFunc;
120}
121
123{
125 ::std::vector< FilterDesc > aFilterVector;
126 ::std::vector< OUString > aOtherFilterVector;
127 const SfxItemSet* pArgs = rReq.GetArgs ();
128
129 FuInsertFile::GetSupportedFilterVector( aOtherFilterVector );
130
131 if (!pArgs)
132 {
133 sfx2::FileDialogHelper aFileDialog(
134 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
135 FileDialogFlags::Insert, mpWindow ? mpWindow->GetFrameWeld() : nullptr);
137 Reference< XFilePicker > xFilePicker( aFileDialog.GetFilePicker() );
138 Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
139 OUString aOwnCont;
140 OUString aOtherCont;
141
142 aFileDialog.SetTitle( SdResId(STR_DLG_INSERT_PAGES_FROM_FILE) );
143
145 {
146 aOwnCont = "simpress";
147 aOtherCont = "sdraw";
148 }
149 else
150 {
151 aOtherCont = "simpress";
152 aOwnCont = "sdraw" ;
153 }
154
155 SfxFilterMatcher aMatch( aOwnCont );
156
157 if( xFilterManager.is() )
158 {
159 // Get filter for current format
160 try
161 {
162 // Get main filter
163 std::shared_ptr<const SfxFilter> pFilter = SfxFilter::GetDefaultFilterFromFactory( aOwnCont );
164 lcl_AddFilter( aFilterVector, pFilter );
165
166 // get template filter
168 pFilter = DrawDocShell::Factory().GetTemplateFilter();
169 else
170 pFilter = GraphicDocShell::Factory().GetTemplateFilter();
171 lcl_AddFilter( aFilterVector, pFilter );
172
173 // get cross filter
174 pFilter = SfxFilter::GetDefaultFilterFromFactory( aOtherCont );
175 lcl_AddFilter( aFilterVector, pFilter );
176
177 // get Powerpoint filter
178 pFilter = aMatch.GetFilter4Extension( ".ppt" );
179 lcl_AddFilter( aFilterVector, pFilter );
180
181 // Get other draw/impress filters
182 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
183 lcl_AddFilter( aFilterVector, pFilter );
184
185 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARIMPRESS_60, SfxFilterFlags::TEMPLATEPATH );
186 lcl_AddFilter( aFilterVector, pFilter );
187
188 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
189 lcl_AddFilter( aFilterVector, pFilter );
190
191 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW_60, SfxFilterFlags::TEMPLATEPATH );
192 lcl_AddFilter( aFilterVector, pFilter );
193
194 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW, SfxFilterFlags::IMPORT, SfxFilterFlags::TEMPLATEPATH );
195 lcl_AddFilter( aFilterVector, pFilter );
196
197 pFilter = aMatch.GetFilter4ClipBoardId( SotClipboardFormatId::STARDRAW, SfxFilterFlags::TEMPLATEPATH );
198 lcl_AddFilter( aFilterVector, pFilter );
199
200 // add additional supported filters
201 for( const auto& rOtherFilter : aOtherFilterVector )
202 {
203 if( ( pFilter = rMatcher.GetFilter4Mime( rOtherFilter ) ) != nullptr )
204 lcl_AddFilter( aFilterVector, pFilter );
205 }
206
207 // set "All supported formats" as the default filter
208 OUString aAllSpec( SdResId( STR_ALL_SUPPORTED_FORMATS ) );
209 OUString aExtensions = lcl_GetExtensionsList( aFilterVector );
210 OUString aGUIName = aAllSpec + " (" + aExtensions + ")";
211
212 xFilterManager->appendFilter( aGUIName, aExtensions );
213 xFilterManager->setCurrentFilter( aAllSpec );
214
215 // append individual filters
216 for( const auto& rFilter : aFilterVector )
217 {
218 xFilterManager->appendFilter( rFilter.first, rFilter.second );
219 }
220
221 // end with "All files" as fallback
222 xFilterManager->appendFilter( SdResId( STR_ALL_FILES ), "*.*" );
223 }
224 catch (const IllegalArgumentException&)
225 {
226 }
227 }
228
229 if( aFileDialog.Execute() != ERRCODE_NONE )
230 return;
231 else
232 {
233 aFilterName = aFileDialog.GetCurrentFilter();
234 aFile = aFileDialog.GetPath();
235 }
236 }
237 else
238 {
239 const SfxStringItem* pFileName = rReq.GetArg<SfxStringItem>(ID_VAL_DUMMY0);
240 assert(pFileName && "must be present");
241 aFile = pFileName->GetValue();
242 if (const SfxStringItem* pFilterName = rReq.GetArg<SfxStringItem>(ID_VAL_DUMMY1))
243 aFilterName = pFilterName->GetValue();
244 }
245
246 mpDocSh->SetWaitCursor( true );
247
248 std::unique_ptr<SfxMedium> xMedium(new SfxMedium(aFile, StreamMode::READ | StreamMode::NOCREATE));
249 std::shared_ptr<const SfxFilter> pFilter;
250
251 SfxGetpApp()->GetFilterMatcher().GuessFilter(*xMedium, pFilter);
252
253 bool bDrawMode = dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr;
254 bool bInserted = false;
255
256 if( pFilter )
257 {
258 xMedium->SetFilter( pFilter );
259 aFilterName = pFilter->GetFilterName();
260
261 if( xMedium->IsStorage() || ( xMedium->GetInStream() && SotStorage::IsStorageFile( xMedium->GetInStream() ) ) )
262 {
263 if ( pFilter->GetServiceName() == "com.sun.star.presentation.PresentationDocument" ||
264 pFilter->GetServiceName() == "com.sun.star.drawing.DrawingDocument" )
265 {
266 // Draw, Impress or PowerPoint document
267 // the ownership of the Medium is transferred
268 if( bDrawMode )
269 InsSDDinDrMode(xMedium.release());
270 else
271 InsSDDinOlMode(xMedium.release());
272
273 // ownership of pMedium has changed in this case
274 bInserted = true;
275 }
276 }
277 else
278 {
279 bool bFound = ( ::std::find( aOtherFilterVector.begin(), aOtherFilterVector.end(), pFilter->GetMimeType() ) != aOtherFilterVector.end() );
280 if( !bFound &&
281 ( aFilterName.indexOf( "Text" ) != -1 ||
282 aFilterName.indexOf( "Rich" ) != -1 ||
283 aFilterName.indexOf( "RTF" ) != -1 ||
284 aFilterName.indexOf( "HTML" ) != -1 ) )
285 {
286 bFound = true;
287 }
288
289 if( bFound )
290 {
291 if( bDrawMode )
292 InsTextOrRTFinDrMode(xMedium.get());
293 else
294 InsTextOrRTFinOlMode(xMedium.get());
295
296 bInserted = true;
297 xMedium.reset();
298 }
299 }
300 }
301
302 mpDocSh->SetWaitCursor( false );
303
304 if( !bInserted )
305 {
306 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(),
307 VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR)));
308 xErrorBox->run();
309 }
310}
311
313{
314 bool bOK = false;
315
316 mpDocSh->SetWaitCursor( false );
318 weld::Window* pParent = mpViewShell ? mpViewShell->GetFrameWeld() : nullptr;
320
321 sal_uInt16 nRet = pDlg->Execute();
322
323 mpDocSh->SetWaitCursor( true );
324
325 if( nRet == RET_OK )
326 {
327 /* list with page names (if NULL, then all pages)
328 First, insert pages */
329 std::vector<OUString> aBookmarkList = pDlg->GetList( 1 ); // pages
330 bool bLink = pDlg->IsLink();
331 SdPage* pPage = nullptr;
332 ::sd::View* pView = mpViewShell ? mpViewShell->GetView() : nullptr;
333
334 if (pView)
335 {
336 if( auto pOutlineView = dynamic_cast<OutlineView *>( pView ))
337 {
338 pPage = pOutlineView->GetActualPage();
339 }
340 else
341 {
342 pPage = static_cast<SdPage*>(pView->GetSdrPageView()->GetPage());
343 }
344 }
345
346 sal_uInt16 nPos = 0xFFFF;
347
348 if (pPage && !pPage->IsMasterPage())
349 {
350 if (pPage->GetPageKind() == PageKind::Standard)
351 {
352 nPos = pPage->GetPageNum() + 2;
353 }
354 else if (pPage->GetPageKind() == PageKind::Notes)
355 {
356 nPos = pPage->GetPageNum() + 1;
357 }
358 }
359
360 bool bNameOK;
361 std::vector<OUString> aExchangeList;
362 std::vector<OUString> aObjectBookmarkList = pDlg->GetList( 2 ); // objects
363
364 /* if pBookmarkList is NULL, we insert selected pages, and/or selected
365 objects or everything. */
366 if( !aBookmarkList.empty() || aObjectBookmarkList.empty() )
367 {
368 /* To ensure that all page names are unique, we check the ones we
369 want to insert and insert them into a substitution list if
370 necessary.
371 bNameOK is sal_False if the user has canceled. */
372 bNameOK = mpView->GetExchangeList( aExchangeList, aBookmarkList, 0 );
373
374 if( bNameOK )
375 bOK = mpDoc->InsertBookmarkAsPage( aBookmarkList, &aExchangeList,
376 bLink, false/*bReplace*/, nPos,
377 false, nullptr, true, true, false );
378
379 aBookmarkList.clear();
380 aExchangeList.clear();
381 }
382
383 // to ensure ... (see above)
384 bNameOK = mpView->GetExchangeList( aExchangeList, aObjectBookmarkList, 1 );
385
386 if( bNameOK )
387 bOK = mpDoc->InsertBookmarkAsObject( aObjectBookmarkList, aExchangeList,
388 nullptr, nullptr, false );
389
390 if( pDlg->IsRemoveUnnecessaryMasterPages() )
392 }
393
394 return bOK;
395}
396
398{
401
402 mpDocSh->SetWaitCursor( false );
403
404 sal_uInt16 nRet = pDlg->Execute();
405 mpDocSh->SetWaitCursor( true );
406
407 if( nRet != RET_OK )
408 return;
409
410 // selected file format: text, RTF or HTML (default is text)
411 EETextFormat nFormat = EETextFormat::Text;
412
413 if( aFilterName.indexOf( "Rich") != -1 )
414 nFormat = EETextFormat::Rtf;
415 else if( aFilterName.indexOf( "HTML" ) != -1 )
416 nFormat = EETextFormat::Html;
417
418 /* create our own outline since:
419 - it is possible that the document outliner is actually used in the
420 structuring mode
421 - the draw outliner of the drawing engine has to draw something in
422 between
423 - the global outliner could be used in SdPage::CreatePresObj */
424 SdOutliner aOutliner( mpDoc, OutlinerMode::TextObject );
425
426 // set reference device
427 aOutliner.SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
428
429 SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage();
430 aLayoutName = pPage->GetLayoutName();
431 sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR);
432 if( nIndex != -1 )
433 aLayoutName = aLayoutName.copy(0, nIndex);
434
435 aOutliner.SetPaperSize(pPage->GetSize());
436
437 SvStream* pStream = pMedium->GetInStream();
438 assert(pStream && "No InStream!");
439 pStream->Seek( 0 );
440
441 ErrCode nErr = aOutliner.Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() );
442
443 if (nErr || aOutliner.GetEditEngine().GetText().isEmpty())
444 {
445 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(),
446 VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR)));
447 xErrorBox->run();
448 }
449 else
450 {
451 // is it a master page?
452 if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == EditMode::MasterPage &&
453 !pPage->IsMasterPage())
454 {
455 pPage = static_cast<SdPage*>(&(pPage->TRG_GetMasterPage()));
456 }
457
458 assert(pPage && "page not found");
459
460 // if editing is going on right now, let it flow into this text object
461 OutlinerView* pOutlinerView = mpView->GetTextEditOutlinerView();
462 if( pOutlinerView )
463 {
465 if( pObj &&
466 pObj->GetObjInventor() == SdrInventor::Default &&
467 pObj->GetObjIdentifier() == SdrObjKind::TitleText &&
468 aOutliner.GetParagraphCount() > 1 )
469 {
470 // in title objects, only one paragraph is allowed
471 while ( aOutliner.GetParagraphCount() > 1 )
472 {
473 Paragraph* pPara = aOutliner.GetParagraph( 0 );
474 sal_uLong nLen = aOutliner.GetText( pPara ).getLength();
475 aOutliner.QuickDelete( ESelection( 0, nLen, 1, 0 ) );
476 aOutliner.QuickInsertLineBreak( ESelection( 0, nLen, 0, nLen ) );
477 }
478 }
479 }
480
481 std::optional<OutlinerParaObject> pOPO = aOutliner.CreateParaObject();
482
483 if (pOutlinerView)
484 {
485 pOutlinerView->InsertText(*pOPO);
486 }
487 else
488 {
491 SdrObjKind::Text);
492 pTO->SetOutlinerParaObject(std::move(pOPO));
493
494 const bool bUndo = mpView->IsUndoEnabled();
495 if( bUndo )
496 mpView->BegUndo(SdResId(STR_UNDO_INSERT_TEXTFRAME));
497 pPage->InsertObject(pTO.get());
498
499 /* can be bigger as the maximal allowed size:
500 limit object size if necessary */
501 Size aSize(aOutliner.CalcTextSize());
502 Size aMaxSize = mpDoc->GetMaxObjSize();
503 aSize.setHeight( std::min(aSize.Height(), aMaxSize.Height()) );
504 aSize.setWidth( std::min(aSize.Width(), aMaxSize.Width()) );
505 aSize = mpWindow->LogicToPixel(aSize);
506
507 // put it at the center of the window
508 Size aTemp(mpWindow->GetOutputSizePixel());
509 Point aPos(aTemp.Width() / 2, aTemp.Height() / 2);
510 aPos.AdjustX( -(aSize.Width() / 2) );
511 aPos.AdjustY( -(aSize.Height() / 2) );
512 aSize = mpWindow->PixelToLogic(aSize);
513 aPos = mpWindow->PixelToLogic(aPos);
514 pTO->SetLogicRect(::tools::Rectangle(aPos, aSize));
515
516 if (pDlg->IsLink())
517 {
518 pTO->SetTextLink(aFile, aFilterName );
519 }
520
521 if( bUndo )
522 {
524 mpView->EndUndo();
525 }
526 }
527 }
528}
529
531{
532 // selected file format: text, RTF or HTML (default is text)
533 EETextFormat nFormat = EETextFormat::Text;
534
535 if( aFilterName.indexOf( "Rich") != -1 )
536 nFormat = EETextFormat::Rtf;
537 else if( aFilterName.indexOf( "HTML" ) != -1 )
538 nFormat = EETextFormat::Html;
539
540 ::Outliner& rDocliner = static_cast<OutlineView*>(mpView)->GetOutliner();
541
542 std::vector<Paragraph*> aSelList;
543 rDocliner.GetView(0)->CreateSelectionList(aSelList);
544
545 Paragraph* pPara = aSelList.empty() ? nullptr : *(aSelList.begin());
546
547 // what should we insert?
548 while (pPara && !Outliner::HasParaFlag(pPara, ParaFlag::ISPAGE))
549 pPara = rDocliner.GetParent(pPara);
550
551 sal_Int32 nTargetPos = rDocliner.GetAbsPos(pPara) + 1;
552
553 // apply layout of predecessor page
554 sal_uInt16 nPage = 0;
555 pPara = rDocliner.GetParagraph( rDocliner.GetAbsPos( pPara ) - 1 );
556 while (pPara)
557 {
558 sal_Int32 nPos = rDocliner.GetAbsPos( pPara );
559 if ( Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
560 nPage++;
561 pPara = rDocliner.GetParagraph( nPos - 1 );
562 }
563 SdPage* pPage = mpDoc->GetSdPage(nPage, PageKind::Standard);
564 aLayoutName = pPage->GetLayoutName();
565 sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR);
566 if( nIndex != -1 )
567 aLayoutName = aLayoutName.copy(0, nIndex);
568
569 /* create our own outline since:
570 - it is possible that the document outliner is actually used in the
571 structuring mode
572 - the draw outliner of the drawing engine has to draw something in
573 between
574 - the global outliner could be used in SdPage::CreatePresObj */
575 ::Outliner aOutliner( &mpDoc->GetItemPool(), OutlinerMode::OutlineObject );
576 aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
577
578 // set reference device
579 aOutliner.SetRefDevice(SD_MOD()->GetVirtualRefDevice());
580 aOutliner.SetPaperSize(Size(0x7fffffff, 0x7fffffff));
581
582 SvStream* pStream = pMedium->GetInStream();
583 DBG_ASSERT( pStream, "No InStream!" );
584 pStream->Seek( 0 );
585
586 ErrCode nErr = aOutliner.Read(*pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes());
587
588 if (nErr || aOutliner.GetEditEngine().GetText().isEmpty())
589 {
590 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(),
591 VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR)));
592 xErrorBox->run();
593 }
594 else
595 {
596 sal_Int32 nParaCount = aOutliner.GetParagraphCount();
597
598 // for progress bar: number of level-0-paragraphs
599 sal_uInt16 nNewPages = 0;
600 pPara = aOutliner.GetParagraph( 0 );
601 while (pPara)
602 {
603 sal_Int32 nPos = aOutliner.GetAbsPos( pPara );
604 if( Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
605 nNewPages++;
606 pPara = aOutliner.GetParagraph( ++nPos );
607 }
608
609 mpDocSh->SetWaitCursor( false );
610
611 std::optional<SfxProgress> pProgress( std::in_place, mpDocSh, SdResId(STR_CREATE_PAGES), nNewPages);
612 pProgress->SetState( 0, 100 );
613
614 nNewPages = 0;
615
618 SdResId(STR_UNDO_INSERT_FILE), OUString(), 0, nViewShellId );
619
620 sal_Int32 nSourcePos = 0;
622 Paragraph* pSourcePara = aOutliner.GetParagraph( 0 );
623 while (pSourcePara)
624 {
625 sal_Int32 nPos = aOutliner.GetAbsPos( pSourcePara );
626 sal_Int16 nDepth = aOutliner.GetDepth( nPos );
627
628 // only take the last paragraph if it is filled
629 if (nSourcePos < nParaCount - 1 ||
630 !aOutliner.GetText(pSourcePara).isEmpty())
631 {
632 rDocliner.Insert( aOutliner.GetText(pSourcePara), nTargetPos, nDepth );
633 OUString aStyleSheetName( pStyleSheet->GetName() );
634 aStyleSheetName = aStyleSheetName.subView( 0, aStyleSheetName.getLength()-1 ) +
635 OUString::number( nDepth <= 0 ? 1 : nDepth+1 );
637 SfxStyleSheet* pOutlStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
638 rDocliner.SetStyleSheet( nTargetPos, pOutlStyle );
639 }
640
641 if( Outliner::HasParaFlag( pSourcePara, ParaFlag::ISPAGE ) )
642 {
643 nNewPages++;
644 pProgress->SetState( nNewPages );
645 }
646
647 pSourcePara = aOutliner.GetParagraph( ++nPos );
648 nTargetPos++;
649 nSourcePos++;
650 }
651
652 rDocliner.GetUndoManager().LeaveListAction();
653
654 pProgress.reset();
655
656 mpDocSh->SetWaitCursor( true );
657 }
658}
659
661{
662 OutlineView* pOlView = static_cast<OutlineView*>(mpView);
663
664 // transfer Outliner content to SdDrawDocument
665 pOlView->PrepareClose();
666
667 // read in like in the character mode
668 if (InsSDDinDrMode(pMedium))
669 {
670 ::Outliner* pOutliner = pOlView->GetViewByWindow(mpWindow)->GetOutliner();
671
672 // cut notification links temporarily
673 Link<Outliner::ParagraphHdlParam,void> aOldParagraphInsertedHdl = pOutliner->GetParaInsertedHdl();
675 Link<Outliner::ParagraphHdlParam,void> aOldParagraphRemovingHdl = pOutliner->GetParaRemovingHdl();
677 Link<Outliner::DepthChangeHdlParam,void> aOldDepthChangedHdl = pOutliner->GetDepthChangedHdl();
679 Link<::Outliner*,void> aOldBeginMovingHdl = pOutliner->GetBeginMovingHdl();
681 Link<::Outliner*,void> aOldEndMovingHdl = pOutliner->GetEndMovingHdl();
683
684 Link<EditStatus&,void> aOldStatusEventHdl = pOutliner->GetStatusEventHdl();
686
687 pOutliner->Clear();
688 pOlView->FillOutliner();
689
690 // set links again
691 pOutliner->SetParaInsertedHdl(aOldParagraphInsertedHdl);
692 pOutliner->SetParaRemovingHdl(aOldParagraphRemovingHdl);
693 pOutliner->SetDepthChangedHdl(aOldDepthChangedHdl);
694 pOutliner->SetBeginMovingHdl(aOldBeginMovingHdl);
695 pOutliner->SetEndMovingHdl(aOldEndMovingHdl);
696 pOutliner->SetStatusEventHdl(aOldStatusEventHdl);
697
698 return true;
699 }
700 else
701 return false;
702}
703
704void FuInsertFile::GetSupportedFilterVector( ::std::vector< OUString >& rFilterVector )
705{
707 std::shared_ptr<const SfxFilter> pSearchFilter;
708
709 rFilterVector.clear();
710
711 if( ( pSearchFilter = rMatcher.GetFilter4Mime( "text/plain" )) != nullptr )
712 rFilterVector.push_back( pSearchFilter->GetMimeType() );
713
714 if( ( pSearchFilter = rMatcher.GetFilter4Mime( "application/rtf" ) ) != nullptr )
715 rFilterVector.push_back( pSearchFilter->GetMimeType() );
716
717 if( ( pSearchFilter = rMatcher.GetFilter4Mime( "text/html" ) ) != nullptr )
718 rFilterVector.push_back( pSearchFilter->GetMimeType() );
719}
720
721} // end of namespace sd
722
723/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE) override
void InsertText(const OUString &rNew, bool bSelect=false)
void CreateSelectionList(std::vector< Paragraph * > &aSelList)
Outliner * GetOutliner() const
static bool HasParaFlag(const Paragraph *pPara, ParaFlag nFlag)
void SetEndMovingHdl(const Link< Outliner *, void > &rLink)
OUString GetText(Paragraph const *pPara, sal_Int32 nParaCount=1) const
const EditEngine & GetEditEngine() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
const Link< DepthChangeHdlParam, void > & GetDepthChangedHdl() const
void SetPaperSize(const Size &rSize)
void Clear()
sal_Int16 GetDepth(sal_Int32 nPara) const
void SetStyleSheet(sal_Int32 nPara, SfxStyleSheet *pStyle)
const Link< ParagraphHdlParam, void > & GetParaInsertedHdl() const
OutlinerView * GetView(size_t nIndex) const
Paragraph * GetParent(Paragraph const *pParagraph) const
sal_Int32 GetAbsPos(Paragraph const *pPara) const
void SetStatusEventHdl(const Link< EditStatus &, void > &rLink)
SfxUndoManager & GetUndoManager()
void SetParaInsertedHdl(const Link< ParagraphHdlParam, void > &rLink)
void SetStyleSheetPool(SfxStyleSheetPool *pSPool)
void SetRefDevice(OutputDevice *pRefDev)
void SetParaRemovingHdl(const Link< ParagraphHdlParam, void > &rLink)
void SetBeginMovingHdl(const Link< Outliner *, void > &rLink)
ErrCode Read(SvStream &rInput, const OUString &rBaseURL, EETextFormat, SvKeyValueIterator *pHTTPHeaderAttrs=nullptr)
Paragraph * Insert(const OUString &rText, sal_Int32 nAbsPos=EE_PARA_APPEND, sal_Int16 nDepth=0)
const Link< ParagraphHdlParam, void > & GetParaRemovingHdl() const
const Link< Outliner *, void > & GetEndMovingHdl() const
void SetDepthChangedHdl(const Link< DepthChangeHdlParam, void > &rLink)
Link< EditStatus &, void > const & GetStatusEventHdl() const
const Link< Outliner *, void > & GetBeginMovingHdl() const
sal_Int32 GetParagraphCount() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
virtual VclPtr< AbstractSdInsertPagesObjsDlg > CreateSdInsertPagesObjsDlg(weld::Window *pParent, const SdDrawDocument *pDoc, SfxMedium *pSfxMedium, const OUString &rFileName)=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
Definition: sdabstdlg.cxx:38
SAL_DLLPRIVATE bool InsertBookmarkAsPage(const std::vector< OUString > &rBookmarkList, std::vector< OUString > *pExchangeList, bool bLink, bool bReplace, sal_uInt16 nPgPos, bool bNoDialogs, ::sd::DrawDocShell *pBookmarkDocSh, bool bCopy, bool bMergeMasterPages, bool bPreservePageNames)
Insert pages into this document.
Definition: drawdoc3.cxx:375
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
SAL_DLLPRIVATE bool InsertBookmarkAsObject(const std::vector< OUString > &rBookmarkList, const std::vector< OUString > &rExchangeList, ::sd::DrawDocShell *pBookmarkDocSh, Point const *pObjPos, bool bCalcObjCount)
Definition: drawdoc3.cxx:966
SAL_DLLPRIVATE void RemoveUnnecessaryMasterPages(SdPage *pMaster=nullptr, bool bOnlyDuplicatePages=false, bool bUndo=true)
Definition: drawdoc3.cxx:1172
SAL_DLLPRIVATE DocumentType GetDocumentType() const
Definition: drawdoc.hxx:251
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
PageKind GetPageKind() const
Definition: sdpage.hxx:205
SfxStyleSheet * GetStyleSheetForPresObj(PresObjKind eObjKind) const
Definition: sdpage.cxx:625
virtual OUString GetLayoutName() const override
Definition: sdpage.hxx:255
bool IsUndoEnabled() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void BegUndo()
void EndUndo()
const SfxItemPool & GetItemPool() const
const Size & GetMaxObjSize() const
SfxStyleSheetBasePool * GetStyleSheetPool() const
SdrUndoFactory & GetSdrUndoFactory() const
SdrTextObj * GetTextEditObject() const
const OutlinerView * GetTextEditOutlinerView() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * GetPage() const
SdrPage & TRG_GetMasterPage() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
Size GetSize() const
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoInsertObject(SdrObject &rObject, bool bOrdNumDirect=false)
SfxFilterMatcher & GetFilterMatcher()
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4ClipBoardId(SotClipboardFormatId nId, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4Extension(const OUString &rExt, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4Mime(const OUString &rMime, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
static std::shared_ptr< const SfxFilter > GetDefaultFilterFromFactory(const OUString &rServiceName)
OUString GetBaseURL(bool bForSaving=false)
SvStream * GetInStream()
void SetWaitCursor(bool bSet) const
SvKeyValueIterator * GetHeaderAttributes()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
size_t LeaveListAction()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
ViewShellId GetViewShellId() const override
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static bool IsStorageFile(OUString const &rFileName)
sal_uInt64 Seek(sal_uInt64 nPos)
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual void DoExecute(SfxRequest &rReq) override
Definition: fuinsfil.cxx:122
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuinsfil.cxx:115
OUString aFile
chosen file name
Definition: fuinsfil.hxx:50
FuInsertFile(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuinsfil.cxx:105
void InsTextOrRTFinOlMode(SfxMedium *pMedium)
Definition: fuinsfil.cxx:530
OUString aFilterName
chosen file filter
Definition: fuinsfil.hxx:49
bool InsSDDinDrMode(SfxMedium *pMedium)
Definition: fuinsfil.cxx:312
bool InsSDDinOlMode(SfxMedium *pMedium)
Definition: fuinsfil.cxx:660
static void GetSupportedFilterVector(::std::vector< OUString > &rFilterVector)
Definition: fuinsfil.cxx:704
void InsTextOrRTFinDrMode(SfxMedium *pMedium)
Definition: fuinsfil.cxx:397
OUString aLayoutName
layout name of the currently inserted page
Definition: fuinsfil.hxx:48
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
ViewShell * mpViewShell
Definition: fupoor.hxx:145
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
::sd::View * mpView
Definition: fupoor.hxx:144
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
void FillOutliner()
creates outliner model from draw model
Definition: outlview.cxx:1000
OutlinerView * GetViewByWindow(vcl::Window const *pWin) const
Return a pointer to the OutlinerView corresponding to the window.
Definition: outlview.cxx:262
void PrepareClose()
updates draw model with all changes from outliner model
Definition: outlview.cxx:953
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
bool GetExchangeList(std::vector< OUString > &rExchangeList, std::vector< OUString > &rBookmarkList, const sal_uInt16 nType)
return parameter: pExchangeList == NULL -> all names are unique bNameOK == false -> cancel by user nT...
Definition: sdview2.cxx:852
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
OUString GetPath() const
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
void SetTitle(const OUString &rNewTitle)
OUString GetCurrentFilter() const
void SetContext(Context _eNewContext)
#define DBG_ASSERT(sCon, aError)
EETextFormat
#define ERRCODE_NONE
::std::pair< OUString, OUString > FilterDesc
Definition: fuinsfil.cxx:68
constexpr OUStringLiteral SD_LT_SEPARATOR
Definition: glob.hxx:49
sal_Int32 nIndex
sal_uInt16 nPos
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
sal_uIntPtr sal_uLong
RET_OK