LibreOffice Module sd (master) 1
docshel4.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 <sal/config.h>
21#include <sal/log.hxx>
22
23#include <memory>
24#include <utility>
25
26#include <DrawDocShell.hxx>
27#include <com/sun/star/document/PrinterIndependentLayout.hpp>
28#include <editeng/outlobj.hxx>
29#include <tools/urlobj.hxx>
30#include <svx/compatflags.hxx>
31#include <svx/svxids.hrc>
32#include <editeng/editeng.hxx>
33#include <editeng/editstat.hxx>
34#include <editeng/flstitem.hxx>
35#include <svl/flagitem.hxx>
36#include <sot/storage.hxx>
37#include <sfx2/dinfdlg.hxx>
38#include <sfx2/docfile.hxx>
39#include <sfx2/docfilt.hxx>
40#include <sfx2/dispatch.hxx>
41#include <svx/svdotext.hxx>
42#include <sfx2/printer.hxx>
43#include <svtools/ctrltool.hxx>
45#include <sot/formats.hxx>
46#include <sfx2/viewfrm.hxx>
47#include <vcl/syswin.hxx>
48#include <com/sun/star/drawing/XDrawPage.hpp>
49#include <com/sun/star/drawing/XDrawView.hpp>
50
51#include <app.hrc>
52#include <strings.hrc>
53#include <FrameView.hxx>
54#include <optsitem.hxx>
55#include <Outliner.hxx>
56#include <sdattr.hrc>
57#include <drawdoc.hxx>
58#include <ViewShell.hxx>
59#include <sdmod.hxx>
60#include <View.hxx>
61#include <EffectMigration.hxx>
63#include <sdpage.hxx>
64#include <sdresid.hxx>
65#include <DrawViewShell.hxx>
66#include <ViewShellBase.hxx>
67#include <OutlineView.hxx>
68#include <OutlineViewShell.hxx>
69#include <sdxmlwrp.hxx>
70#include <sdpptwrp.hxx>
71#include <sdcgmfilter.hxx>
72#include <sdgrffilter.hxx>
73#include <sdhtmlfilter.hxx>
74#include <sdpdffilter.hxx>
76#include <o3tl/string_view.hxx>
77
78#include <Window.hxx>
79#include <svl/intitem.hxx>
80
81using namespace ::com::sun::star;
82using namespace ::com::sun::star::uno;
83using ::sd::framework::FrameworkHelper;
84
85// PowerPoint-Filter
86constexpr OUStringLiteral pFilterPowerPoint97( u"MS PowerPoint 97" );
87constexpr OUStringLiteral pFilterPowerPoint97Template( u"MS PowerPoint 97 Vorlage" );
88constexpr OUStringLiteral pFilterPowerPoint97AutoPlay( u"MS PowerPoint 97 AutoPlay" );
89
90namespace sd {
91
96{
97 if (bCreate && !mpPrinter)
98 {
99 // create ItemSet with special pool area
100 auto pSet = std::make_unique<SfxItemSetFixed<
101 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
102 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
103 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT>>( GetPool() );
104 // set PrintOptionsSet
105 SdOptionsPrintItem aPrintItem( SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()) );
106 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
107 SfxPrinterChangeFlags nFlags =
108 (aPrintItem.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) |
109 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE);
110 aFlagItem.SetValue( static_cast<int>(nFlags) );
111
112 pSet->Put( aPrintItem );
113 pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
114 pSet->Put( aFlagItem );
115
116 mpPrinter = VclPtr<SfxPrinter>::Create(std::move(pSet));
117 mbOwnPrinter = true;
118
119 // set output quality
120 sal_uInt16 nQuality = aPrintItem.GetOptionsPrint().GetOutputQuality();
121
122 DrawModeFlags nMode = DrawModeFlags::Default;
123 // 1 == Grayscale, 2 == Black & White (with grayscale images)
124 if( nQuality == 1 )
125 nMode = DrawModeFlags::GrayLine | DrawModeFlags::GrayFill | DrawModeFlags::GrayText | DrawModeFlags::GrayBitmap | DrawModeFlags::GrayGradient;
126 else if( nQuality == 2 )
127 nMode = DrawModeFlags::BlackLine | DrawModeFlags::WhiteFill | DrawModeFlags::BlackText | DrawModeFlags::GrayBitmap | DrawModeFlags::WhiteGradient;
128
129 mpPrinter->SetDrawMode( nMode );
130
131 MapMode aMM (mpPrinter->GetMapMode());
132 aMM.SetMapUnit(MapUnit::Map100thMM);
133 mpPrinter->SetMapMode(aMM);
135 }
136 return mpPrinter;
137}
138
143{
144 if ( mpViewShell )
145 {
146 ::sd::View* pView = mpViewShell->GetView();
147 if ( pView->IsTextEdit() )
148 pView->SdrEndTextEdit();
149 }
150
151 if ( mpPrinter && mbOwnPrinter && (mpPrinter.get() != pNewPrinter) )
153
154 mpPrinter = pNewPrinter;
155 mbOwnPrinter = true;
156 if ( mpDoc->GetPrinterIndependentLayout() == css::document::PrinterIndependentLayout::DISABLED )
159}
160
162{
163 mpFontList.reset();
164 OutputDevice* pRefDevice = nullptr;
165 if ( mpDoc->GetPrinterIndependentLayout() == css::document::PrinterIndependentLayout::DISABLED )
166 pRefDevice = GetPrinter(true);
167 else
168 pRefDevice = SD_MOD()->GetVirtualRefDevice();
169 mpFontList.reset( new FontList(pRefDevice, nullptr) );
170 SvxFontListItem aFontListItem( mpFontList.get(), SID_ATTR_CHAR_FONTLIST );
171 PutItem( aFontListItem );
172}
173
175{
176 return GetPrinter(false);
177}
178
180{
181 // if we already have a printer, see if it's the same
182 if( mpPrinter )
183 {
184 // easy case
185 if( mpPrinter == pNewPrinter )
186 return;
187
188 // compare if it's the same printer with the same job setup
189 if( (mpPrinter->GetName() == pNewPrinter->GetName()) &&
190 (mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup()))
191 return;
192 }
193
194 SfxPrinter* const pSfxPrinter = dynamic_cast<SfxPrinter*>(pNewPrinter);
195 if (pSfxPrinter)
196 {
197 SetPrinter(pSfxPrinter);
198
199 // container owns printer
200 mbOwnPrinter = false;
201 }
202}
203
205{
206 if( !mpDoc )
207 return;
208
209 // Determine the device for which the output will be formatted.
210 VclPtr< OutputDevice > pRefDevice;
212 {
213 case css::document::PrinterIndependentLayout::DISABLED:
214 pRefDevice = mpPrinter.get();
215 break;
216
217 case css::document::PrinterIndependentLayout::ENABLED:
218 pRefDevice = SD_MOD()->GetVirtualRefDevice();
219 break;
220
221 default:
222 // We are confronted with an invalid or un-implemented
223 // layout mode. Use the printer as formatting device
224 // as a fall-back.
225 SAL_WARN( "sd", "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode");
226
227 pRefDevice = mpPrinter.get();
228 break;
229 }
230 mpDoc->SetRefDevice( pRefDevice.get() );
231
232 SdOutliner* pOutl = mpDoc->GetOutliner( false );
233
234 if( pOutl )
235 pOutl->SetRefDevice( pRefDevice );
236
237 SdOutliner* pInternalOutl = mpDoc->GetInternalOutliner( false );
238
239 if( pInternalOutl )
240 pInternalOutl->SetRefDevice( pRefDevice );
241}
242
246bool DrawDocShell::InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage )
247{
248 bool bRet = SfxObjectShell::InitNew( xStorage );
249
250 ::tools::Rectangle aVisArea( Point(0, 0), Size(14100, 10000) );
251 SetVisArea(aVisArea);
252
253 if (bRet)
254 {
255 if( !mbSdDataObj )
256 mpDoc->NewOrLoadCompleted(DocCreationMode::New); // otherwise calling
257 // NewOrLoadCompleted(NEW_LOADED) in
258 // SdDrawDocument::AllocModel()
259 }
260 return bRet;
261}
262
267{
268 // If this is an ODF file being loaded, then by default, use legacy processing
269 // (if required, it will be overridden in *::ReadUserDataSequence())
270 if (IsOwnStorageFormat(rMedium))
271 {
272 mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy, true); // for tdf#99729
273 mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::LegacySingleLineFontwork, true); // for tdf#148000
274 }
275
276 bool bRet = false;
277 bool bStartPresentation = false;
278 ErrCode nError = ERRCODE_NONE;
279
280 SfxItemSet& rSet = rMedium.GetItemSet();
281
282 if( ( SfxItemState::SET == rSet.GetItemState(SID_PREVIEW ) ) && rSet.Get( SID_PREVIEW ).GetValue() )
283 {
285 }
286
287 if( SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)&&
288 rSet.Get( SID_DOC_STARTPRESENTATION ).GetValue() )
289 {
290 bStartPresentation = true;
292 }
293
294 bRet = SfxObjectShell::Load( rMedium );
295 if (bRet)
296 {
298 rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false);
299 bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
300 }
301
302 if( bRet )
303 {
304 // for legacy markup in OOoXML filter, convert the animations now
307
308 // If we're an embedded OLE object, use tight bounds
309 // for our visArea. No point in showing the user lots of empty
310 // space. Had to remove the check for empty VisArea below,
311 // since XML load always sets a VisArea before.
312 //TODO/LATER: looks a little bit strange!
313 if( ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() )
314 {
316
317 if( pPage )
318 SetVisArea( pPage->GetAllObjBoundRect() );
319 }
320
322
323 const INetURLObject aUrl;
324 SfxObjectShell::SetAutoLoad( aUrl, 0, false );
325 }
326 else
327 {
328 if( nError == ERRCODE_IO_BROKENPACKAGE )
330
331 // TODO/LATER: correct error handling?!
332 //pStore->SetError(SVSTREAM_WRONGVERSION);
333 else
335 }
336
337 // tell SFX to change viewshell when in preview mode
338 if( IsPreview() || bStartPresentation )
339 {
340 GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
341 }
342
343 return bRet;
344}
345
350{
351 std::unique_ptr<weld::WaitObject> pWait;
352 if( mpViewShell )
353 pWait.reset(new weld::WaitObject(mpViewShell->GetFrameWeld()));
354
358
359 // TODO/LATER: nobody is interested in the error code?!
360 ErrCode nError = ERRCODE_NONE;
361 bool bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
362
363 // tell SFX to change viewshell when in preview mode
364 if( IsPreview() )
365 {
366 GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
367 }
368
369 return bRet;
370}
371
376 uno::Reference<text::XTextRange> const& xInsertPosition)
377{
378 const OUString aFilterName( rMedium.GetFilter()->GetFilterName() );
379 if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
380 aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" ||
381 aFilterName == "Impress MS PowerPoint 2007 XML VBA")
382 {
383 // As this is a MSFT format, we should use the "MS Compat"
384 // mode for spacing before and after paragraphs.
385
386 // This is copied from what is done for .ppt import in
387 // ImplSdPPTImport::Import() in sd/source/filter/ppt/pptin.cxx
388 // in. We need to tell both the edit engine of the draw outliner,
389 // and the document, to do "summation of paragraphs".
391 EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord();
392 nControlWord |= EEControlBits::ULSPACESUMMATION;
393 const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord );
394
396 }
397
398 if (aFilterName == "Impress MS PowerPoint 2007 XML")
399 {
400 // This is a "MS Compact" mode for connectors.
401 // The Libreoffice uses bounding rectangle of connected shapes but
402 // MSO uses snap rectangle when calculate the edge track.
403 mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect, true);
404
405 // compatibility flag for tdf#148966
406 mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::IgnoreBreakAfterMultilineField, true);
407 }
408
409 if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
410 aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" ||
411 aFilterName == "Impress MS PowerPoint 2007 XML VBA" ||
412 aFilterName == "Impress Office Open XML")
413 {
414 // We need to be able to set the default tab size for each text object.
415 // This is possible at the moment only for the whole document. See
416 // TextParagraphPropertiesContext constructor. So default tab width
417 // of the LibreOffice is 1270 but MSO is 2540 on general settings.
418 mpDoc->SetDefaultTabulator( 2540 );
419 }
420
421 const bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition);
422
423 SfxItemSet& rSet = rMedium.GetItemSet();
424 if( SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)&&
425 rSet.Get( SID_DOC_STARTPRESENTATION ).GetValue() )
426 {
428
429 // tell SFX to change viewshell when in preview mode
430 if( IsPreview() )
431 {
432 GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 1 ) );
433 }
434 }
435
436 return bRet;
437}
438
443{
444 const OUString aFilterName( rMedium.GetFilter()->GetFilterName() );
445 bool bRet = false;
446 bool bStartPresentation = false;
447
448 SetWaitCursor( true );
449
450 SfxItemSet& rSet = rMedium.GetItemSet();
451 if( ( SfxItemState::SET == rSet.GetItemState(SID_PREVIEW ) ) && rSet.Get( SID_PREVIEW ).GetValue() )
452 {
454 }
455
456 if( SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)&&
457 rSet.Get( SID_DOC_STARTPRESENTATION ).GetValue() )
458 {
459 bStartPresentation = true;
461 }
462
463 if( aFilterName == pFilterPowerPoint97
464 || aFilterName == pFilterPowerPoint97Template
465 || aFilterName == pFilterPowerPoint97AutoPlay)
466 {
468 bRet = SdPPTFilter( rMedium, *this ).Import();
469 }
470 else if (aFilterName.indexOf("impress8") >= 0 ||
471 aFilterName.indexOf("draw8") >= 0)
472 {
473 // TODO/LATER: nobody is interested in the error code?!
476 ErrCode nError = ERRCODE_NONE;
477 bRet = SdXMLFilter( rMedium, *this ).Import( nError );
478
479 }
480 else if (aFilterName.indexOf("StarOffice XML (Draw)") >= 0 ||
481 aFilterName.indexOf("StarOffice XML (Impress)") >= 0)
482 {
483 // TODO/LATER: nobody is interested in the error code?!
486 ErrCode nError = ERRCODE_NONE;
487 bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SOFFICE_FILEFORMAT_60 ).Import( nError );
488 }
489 else if (aFilterName == "CGM - Computer Graphics Metafile")
490 {
493 bRet = SdCGMFilter( rMedium, *this ).Import();
494 }
495 else if (aFilterName == "draw_pdf_import")
496 {
499 bRet = SdPdfFilter(rMedium, *this).Import();
500 }
501 else
502 {
505 bRet = SdGRFFilter( rMedium, *this ).Import();
506 }
507
509
510 // tell SFX to change viewshell when in preview mode
511 if( IsPreview() )
512 {
513 GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
514 }
515 SetWaitCursor( false );
516
517 // tell SFX to change viewshell when in preview mode
518 if( IsPreview() || bStartPresentation )
519 {
520 GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
521 }
522
523 return bRet;
524}
525
530{
532
533 //TODO/LATER: why this?!
534 if( GetCreateMode() == SfxObjectCreateMode::STANDARD )
536
537 bool bRet = SfxObjectShell::Save();
538
539 if( bRet )
541
542 return bRet;
543}
544
549{
550 mpDoc->setDocAccTitle(OUString());
551 if (SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst(this))
552 {
553 if (vcl::Window* pSysWin = pFrame1->GetWindow().GetSystemWindow())
554 {
555 pSysWin->SetAccessibleName(OUString());
556 }
557 }
559
560 //With custom animation, if Outliner is modified, update text before saving
561 if( mpViewShell )
562 {
564 if( pPage && pPage->getMainSequence()->getCount() )
565 {
568 if( pObj && pOutl && pOutl->IsModified() )
569 {
570 std::optional<OutlinerParaObject> pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() );
571 pObj->SetOutlinerParaObject( std::move(pNewText) );
572 pOutl->ClearModifyFlag();
573 }
574 }
575 }
576
577 //TODO/LATER: why this?!
578 if( GetCreateMode() == SfxObjectCreateMode::STANDARD )
580
581 bool bRet = SfxObjectShell::SaveAs( rMedium );
582
583 if( bRet )
584 bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export();
585
586 if( GetError() == ERRCODE_NONE )
588
589 return bRet;
590}
591
596{
597 bool bRet = false;
598
599 if( mpDoc->GetPageCount() )
600 {
601 std::shared_ptr<const SfxFilter> pMediumFilter = rMedium.GetFilter();
602 const OUString aTypeName( pMediumFilter->GetTypeName() );
603 std::unique_ptr<SdFilter> xFilter;
604
605 if( aTypeName.indexOf( "graphic_HTML" ) >= 0 )
606 {
607 xFilter = std::make_unique<SdHTMLFilter>(rMedium, *this);
608 }
609 else if( aTypeName.indexOf( "MS_PowerPoint_97" ) >= 0 )
610 {
611 xFilter = std::make_unique<SdPPTFilter>(rMedium, *this);
612 static_cast<SdPPTFilter*>(xFilter.get())->PreSaveBasic();
613 }
614 else if ( aTypeName.indexOf( "CGM_Computer_Graphics_Metafile" ) >= 0 )
615 {
616 xFilter = std::make_unique<SdCGMFilter>(rMedium, *this);
617 }
618 else if( aTypeName.indexOf( "draw8" ) >= 0 ||
619 aTypeName.indexOf( "impress8" ) >= 0 )
620 {
621 xFilter = std::make_unique<SdXMLFilter>(rMedium, *this);
622 }
623 else if( aTypeName.indexOf( "StarOffice_XML_Impress" ) >= 0 ||
624 aTypeName.indexOf( "StarOffice_XML_Draw" ) >= 0 )
625 {
626 xFilter = std::make_unique<SdXMLFilter>(rMedium, *this, SdXMLFilterMode::Normal, SOFFICE_FILEFORMAT_60);
627 }
628 else
629 {
630 xFilter = std::make_unique<SdGRFFilter>(rMedium, *this);
631 }
632
633 if (xFilter)
634 {
635 if ( mpViewShell )
636 {
637 ::sd::View* pView = mpViewShell->GetView();
638 if ( pView->IsTextEdit() )
639 pView->SdrEndTextEdit();
640 }
641
642 bRet = xFilter->Export();
643 }
644 }
645
646 return bRet;
647}
648
653bool DrawDocShell::SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage )
654{
655 bool bRet = false;
656
657 if( SfxObjectShell::SaveCompleted(xStorage) )
658 {
659 mpDoc->NbcSetChanged( false );
660
661 if( mpViewShell )
662 {
663 if( dynamic_cast< OutlineViewShell *>( mpViewShell ) != nullptr )
664 static_cast<OutlineView*>(mpViewShell->GetView())
665 ->GetOutliner().ClearModifyFlag();
666
668 if( pOutl )
669 {
671 if( pObj )
672 pObj->NbcSetOutlinerParaObject( pOutl->CreateParaObject() );
673
674 pOutl->ClearModifyFlag();
675 }
676 }
677
678 bRet = true;
679
683
684 if( pFrame )
685 pFrame->GetBindings().Invalidate( SID_NAVIGATOR_STATE, true );
686 }
687 return bRet;
688}
689
691{
692 return mpDoc->GetStyleSheetPool();
693}
694
695void DrawDocShell::GotoBookmark(std::u16string_view rBookmark)
696{
697 auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell );
698 if (!pDrawViewShell)
699 return;
700
702
703 bool bIsMasterPage = false;
704 sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND;
705 SdrObject* pObj = nullptr;
706
707 static constexpr std::u16string_view sInteraction( u"action?" );
708 if ( o3tl::starts_with(rBookmark, sInteraction ) )
709 {
710 static constexpr std::u16string_view sJump( u"jump=" );
711 if ( o3tl::starts_with(rBookmark.substr( sInteraction.size() ), sJump ) )
712 {
713 std::u16string_view aDestination( rBookmark.substr( sInteraction.size() + sJump.size() ) );
714 if ( o3tl::starts_with(aDestination, u"firstslide" ) )
715 {
716 nPageNumber = 1;
717 }
718 else if ( o3tl::starts_with(aDestination, u"lastslide" ) )
719 {
720 nPageNumber = mpDoc->GetPageCount() - 2;
721 }
722 else if ( o3tl::starts_with(aDestination, u"previousslide" ) )
723 {
724 SdPage* pPage = pDrawViewShell->GetActualPage();
725 nPageNumber = pPage->GetPageNum();
726 nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND;
727 }
728 else if ( o3tl::starts_with(aDestination, u"nextslide" ) )
729 {
730 SdPage* pPage = pDrawViewShell->GetActualPage();
731 nPageNumber = pPage->GetPageNum() + 2;
732 if ( nPageNumber >= mpDoc->GetPageCount() )
733 nPageNumber = SDRPAGE_NOTFOUND;
734 }
735 }
736 }
737 else
738 {
739 // Is the bookmark a page?
740 nPageNumber = mpDoc->GetPageByName( rBookmark, bIsMasterPage );
741
742 if (nPageNumber == SDRPAGE_NOTFOUND)
743 {
744 // Is the bookmark an object?
745 pObj = mpDoc->GetObj(rBookmark);
746
747 if (pObj)
748 {
749 nPageNumber = pObj->getSdrPageFromSdrObject()->GetPageNum();
750 }
751 }
752 }
753 if (nPageNumber != SDRPAGE_NOTFOUND)
754 {
755 // Jump to the bookmarked page. This is done in three steps.
756
757 SdPage* pPage;
758 if (bIsMasterPage)
759 pPage = static_cast<SdPage*>( mpDoc->GetMasterPage(nPageNumber) );
760 else
761 pPage = static_cast<SdPage*>( mpDoc->GetPage(nPageNumber) );
762
763 // 1.) Change the view shell to the edit view, the notes view,
764 // or the handout view.
765 PageKind eNewPageKind = pPage->GetPageKind();
766
767 if( (eNewPageKind != PageKind::Standard) && (mpDoc->GetDocumentType() == DocumentType::Draw) )
768 return;
769
770 if (eNewPageKind != pDrawViewShell->GetPageKind())
771 {
772 // change work area
773 GetFrameView()->SetPageKind(eNewPageKind);
774 OUString sViewURL;
775 switch (eNewPageKind)
776 {
778 sViewURL = FrameworkHelper::msImpressViewURL;
779 break;
780 case PageKind::Notes:
781 sViewURL = FrameworkHelper::msNotesViewURL;
782 break;
784 sViewURL = FrameworkHelper::msHandoutViewURL;
785 break;
786 default:
787 break;
788 }
789 if (!sViewURL.isEmpty())
790 {
791 std::shared_ptr<FrameworkHelper> pHelper (
792 FrameworkHelper::Instance(rBase));
793 pHelper->RequestView(
794 sViewURL,
795 FrameworkHelper::msCenterPaneURL);
796 pHelper->WaitForUpdate();
797
798 // Get the new DrawViewShell.
799 mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
800 pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell);
801 }
802 else
803 {
804 pDrawViewShell = nullptr;
805 }
806 }
807
808 if (pDrawViewShell != nullptr)
809 {
810 setEditMode(pDrawViewShell, bIsMasterPage);
811
812 // Make the bookmarked page the current page. This is done
813 // by using the API because this takes care of all the
814 // little things to be done. Especially writing the view
815 // data to the frame view.
816 sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2;
817 Reference<drawing::XDrawView> xController (rBase.GetController(), UNO_QUERY);
818 if (xController.is())
819 {
820 Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY);
821 xController->setCurrentPage (xDrawPage);
822 }
823 else
824 {
825 // As a fall back switch to the page via the core.
827 "DrawDocShell::GotoBookmark: can't switch page via API");
828 pDrawViewShell->SwitchPage(nSdPgNum);
829 }
830
831 // Do UnmarkAll here to stop the Navigator from reselecting the previously marked
832 // entry when a slide entry is selected.
833 pDrawViewShell->GetView()->UnmarkAll();
834 if (pObj != nullptr)
835 {
836 // show and select object
837 if (vcl::Window* pWindow = pDrawViewShell->GetActiveWindow())
838 pDrawViewShell->MakeVisible(pObj->GetSnapRect(), *pWindow);
839 pDrawViewShell->GetView()->MarkObj(
840 pObj,
841 pDrawViewShell->GetView()->GetSdrPageView());
842 }
843 }
844 }
845
846 if (SfxViewFrame* pViewFrame = (pDrawViewShell && pDrawViewShell->GetViewFrame())
847 ? pDrawViewShell->GetViewFrame()
849 {
850 SfxBindings& rBindings = pViewFrame->GetBindings();
851 rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
852 rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
853 }
854}
855
860{
861
862 std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
863
864 if (pFilter->IsOwnTemplateFormat())
865 {
866 /* now the StarDraw specialty:
867 we assign known layout names to the layout template of the first
868 page, we set the layout names of the affected masterpages and pages.
869 We inform all text objects of the affected standard, note and
870 masterpages about the name change.
871 */
872
873 OUString aLayoutName;
874
875 SfxStringItem const * pLayoutItem = rMedium.GetItemSet().GetItemIfSet(SID_TEMPLATE_NAME, false);
876 if( pLayoutItem )
877 {
878 aLayoutName = pLayoutItem->GetValue();
879 }
880 else
881 {
882 INetURLObject aURL( rMedium.GetName() );
883 aURL.removeExtension();
884 aLayoutName = aURL.getName();
885 }
886
887 if (aLayoutName.isEmpty())
888 {
890 for (sal_uInt32 i = 0; i < nCount; ++i)
891 {
892 OUString aOldPageLayoutName = mpDoc->GetMasterSdPage(i, PageKind::Standard)->GetLayoutName();
893 OUString aNewLayoutName = aLayoutName;
894 // Don't add suffix for the first master page
895 if( i > 0 )
896 aNewLayoutName += OUString::number(i);
897
898 mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aNewLayoutName);
899 }
900 }
901 }
902
903 return SfxObjectShell::SaveAsOwnFormat(rMedium);
904}
905
907 SotClipboardFormatId* pFormat,
908 OUString* pFullTypeName,
909 sal_Int32 nFileFormat,
910 bool bTemplate /* = false */) const
911{
912 if (nFileFormat == SOFFICE_FILEFORMAT_60)
913 {
915 {
916 *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
917 *pFormat = SotClipboardFormatId::STARDRAW_60;
918 *pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60);
919 }
920 else
921 {
923 *pFormat = SotClipboardFormatId::STARIMPRESS_60;
924 *pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60);
925 }
926 }
927 else if (nFileFormat == SOFFICE_FILEFORMAT_8)
928 {
930 {
931 *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
932 *pFormat = bTemplate ? SotClipboardFormatId::STARDRAW_8_TEMPLATE : SotClipboardFormatId::STARDRAW_8;
933 *pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API
934 }
935 else
936 {
938 *pFormat = bTemplate ? SotClipboardFormatId::STARIMPRESS_8_TEMPLATE : SotClipboardFormatId::STARIMPRESS_8;
939 *pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API
940 }
941 }
942}
943
945{
946 OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev ();
947 // Only when our parent does not have a reference device then we return
948 // our own.
949 if (pReferenceDevice == nullptr && mpDoc != nullptr)
950 pReferenceDevice = mpDoc->GetRefDevice ();
951 return pReferenceDevice;
952}
953
956void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL )
957{
958 SfxStringItem aStrItem( SID_FILE_NAME, rBookmarkURL );
959 SfxStringItem aReferer( SID_REFERER, GetMedium()->GetName() );
960 const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, nullptr };
962 pFrame->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs );
963}
964
965std::shared_ptr<SfxDocumentInfoDialog> DrawDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
966{
967 std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
968 DrawDocShell* pDocSh = dynamic_cast<DrawDocShell*>(SfxObjectShell::Current());
969 if( pDocSh == this )
970 {
971 xDlg->AddFontTabPage();
972 }
973 return xDlg;
974}
975
976void DrawDocShell::setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage)
977{
978 // Set the edit mode to either the normal edit mode or the
979 // master page mode.
980 EditMode eNewEditMode = EditMode::Page;
981 if (isMasterPage)
982 {
983 eNewEditMode = EditMode::MasterPage;
984 }
985
986 if (eNewEditMode != pDrawViewShell->GetEditMode())
987 {
988 // Set EditMode
989 pDrawViewShell->ChangeEditMode(eNewEditMode, false);
990 }
991}
992} // end of namespace sd
993
994/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawModeFlags
const OUString & GetValue() const
void SetMapUnit(MapUnit eUnit)
const OUString & GetName() const
const JobSetup & GetJobSetup() const
bool Import()
Definition: sdcgmfilter.cxx:49
void CreateFirstPages(SdDrawDocument const *pRefDocument=nullptr)
if the document does not contain at least one handout, one slide and one notes page with at least one...
Definition: drawdoc2.cxx:493
sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:222
SAL_DLLPRIVATE void setDocAccTitle(const OUString &rTitle)
Definition: drawdoc.hxx:123
SAL_DLLPRIVATE void SetSummationOfParagraphs(bool bOn=true)
Definition: drawdoc.hxx:405
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SAL_DLLPRIVATE SdOutliner * GetOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:912
void StopWorkStartupDelay()
Definition: drawdoc2.cxx:932
SAL_DLLPRIVATE void NbcSetChanged(bool bFlag)
Definition: drawdoc.cxx:679
SAL_DLLPRIVATE sal_uInt16 GetPageByName(std::u16string_view rPgName, bool &rbIsMasterPage) const
Return the first page that has the given name.
Definition: drawdoc2.cxx:126
SAL_DLLPRIVATE void RenameLayoutTemplate(const OUString &rOldLayoutName, const OUString &rNewName)
Definition: drawdoc4.cxx:1018
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
Definition: drawdoc2.cxx:217
SAL_DLLPRIVATE SdrObject * GetObj(std::u16string_view rObjName) const
Definition: drawdoc2.cxx:66
SAL_DLLPRIVATE void NewOrLoadCompleted(DocCreationMode eMode)
Definition: drawdoc.cxx:687
SAL_DLLPRIVATE sal_Int32 GetPrinterIndependentLayout() const
Get the flag that controls whether the formatting of the document depends on the current printer metr...
Definition: drawdoc.hxx:428
SAL_DLLPRIVATE void SetStartWithPresentation(bool bStartWithPresentation)
Definition: drawdoc.cxx:1059
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
bool Import()
these methods are necessary for the export to PowerPoint
Definition: sdpptwrp.cxx:145
PageKind GetPageKind() const
Definition: sdpage.hxx:205
std::shared_ptr< sd::MainSequence > const & getMainSequence()
returns a helper class to manipulate effects inside the main sequence
virtual OUString GetLayoutName() const override
Definition: sdpage.hxx:255
bool Import()
Definition: sdpdffilter.cxx:49
bool Export() override
Definition: sdxmlwrp.cxx:731
bool Import(ErrCode &nError)
Definition: sdxmlwrp.cxx:443
void SetCompatibilityFlag(SdrCompatibilityFlag eFlag, bool bEnabled)
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
void SetRefDevice(OutputDevice *pDev)
void SetDefaultTabulator(sal_uInt16 nVal)
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
SfxStyleSheetBasePool * GetStyleSheetPool() const
OutputDevice * GetRefDevice() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
void SetStarDrawPreviewMode(bool bPreview)
SdrTextObj * GetTextEditObject() const
virtual bool IsTextEdit() const final override
const SdrOutliner * GetTextEditOutliner() const
const tools::Rectangle & GetAllObjBoundRect() const
virtual void NbcSetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
virtual const tools::Rectangle & GetSnapRect() const
SdrPage * getSdrPageFromSdrObject() const
css::uno::Reference< css::uno::XInterface > const & getUnoPage()
sal_uInt16 GetPageNum() const
void Invalidate(sal_uInt16 nId)
void SetValue(sal_uInt16 nNewVal)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const std::shared_ptr< const SfxFilter > & GetFilter() const
SfxItemSet & GetItemSet() const
const OUString & GetName() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
virtual bool ImportFrom(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
void SetWaitCursor(bool bSet) const
void SetError(ErrCode rErr)
virtual OutputDevice * GetDocumentRefDev()
virtual bool Load(SfxMedium &rMedium)
void SetAutoLoad(const INetURLObject &, sal_uInt32 nTime, bool bReload)
static bool IsOwnStorageFormat(const SfxMedium &)
virtual bool SaveAs(SfxMedium &rMedium)
virtual void SetVisArea(const tools::Rectangle &rVisArea)
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual bool Save()
void FinishedLoading(SfxLoadedFlags nWhich=SfxLoadedFlags::ALL)
virtual bool SaveAsOwnFormat(SfxMedium &pMedium)
ErrCode GetError() const
SfxMedium * GetMedium() const
css::uno::Reference< css::embed::XStorage > const & GetStorage()
const tools::Rectangle & GetVisArea() const
SfxObjectCreateMode GetCreateMode() const
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
bool IsPreview() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void PutItem(const SfxPoolItem &rItem)
SfxItemPool & GetPool() const
const OUString & GetName() const
SfxViewShell * GetViewShell() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
css::uno::Reference< css::frame::XController > GetController() const
sal_Int32 GetVersion() const
void disposeAndClear()
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
#define SO3_SDRAW_CLASSID_60
#define SO3_SIMPRESS_CLASSID_60
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
Definition: docshel4.cxx:690
void SetPrinter(SfxPrinter *pNewPrinter)
Set new SfxPrinter (transfer of ownership)
Definition: docshel4.cxx:142
virtual OutputDevice * GetDocumentRefDev() override
Return the reference device for the current document.
Definition: docshel4.cxx:944
virtual bool Load(SfxMedium &rMedium) override
loads pools and document
Definition: docshel4.cxx:266
static void setEditMode(DrawViewShell *pDrawViewShell, bool isMasterPage)
Definition: docshel4.cxx:976
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nFileFormat, bool bTemplate=false) const override
Definition: docshel4.cxx:906
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage) override
Creates new document, opens streams.
Definition: docshel4.cxx:246
::sd::FrameView * GetFrameView()
Definition: docshel2.cxx:160
virtual bool Save() override
Writes pools and document to the open streams.
Definition: docshel4.cxx:529
virtual Printer * GetDocumentPrinter() override
Definition: docshel4.cxx:174
void UpdateRefDevice()
Definition: docshel4.cxx:204
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rSet) override
Definition: docshel4.cxx:965
void GotoBookmark(std::u16string_view rBookmark)
Definition: docshel4.cxx:695
virtual bool ConvertTo(SfxMedium &rMedium) override
save to foreign format
Definition: docshel4.cxx:595
::sd::ViewShell * mpViewShell
std::unique_ptr< FontList > mpFontList
virtual bool LoadFrom(SfxMedium &rMedium) override
loads content for organizer
Definition: docshel4.cxx:349
VclPtr< SfxPrinter > mpPrinter
DocumentType meDocType
virtual void OnDocumentPrinterChanged(Printer *pNewPrinter) override
Definition: docshel4.cxx:179
SfxPrinter * GetPrinter(bool bCreate)
Creates (if necessary) and returns a SfxPrinter.
Definition: docshel4.cxx:95
virtual bool ConvertFrom(SfxMedium &rMedium) override
load from a foreign format
Definition: docshel4.cxx:442
virtual bool SaveAs(SfxMedium &rMedium) override
Writes pools and document to the provided storage.
Definition: docshel4.cxx:548
virtual bool ImportFrom(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition) override
load from 3rd party format
Definition: docshel4.cxx:375
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage) override
Reopen own streams to ensure that nobody else can prevent use from opening them.
Definition: docshel4.cxx:653
SdDrawDocument * mpDoc
void OpenBookmark(const OUString &rBookmarkURL)
executes the SID_OPENDOC slot to let the framework open a document with the given URL and this docume...
Definition: docshel4.cxx:956
SdDrawDocument * GetDoc()
virtual bool SaveAsOwnFormat(SfxMedium &rMedium) override
If it should become a document template.
Definition: docshel4.cxx:859
void UpdateTablePointers()
Definition: docshell.cxx:368
void UpdateFontList()
Definition: docshel4.cxx:161
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
EditMode GetEditMode() const
virtual void ChangeEditMode(EditMode eMode, bool bIsLayerModeActive)
Set status (enabled/disabled) of menu SfxSlots.
Definition: drviews1.cxx:333
static void DocumentLoaded(SdDrawDocument &rDoc)
void SetPageKind(PageKind eKind)
Definition: FrameView.hxx:85
Show a textual overview of the text contents of all slides.
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
virtual SdPage * getCurrentPage() const =0
::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
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
int nCount
#define DBG_ASSERT(sCon, aError)
URL aURL
constexpr OUStringLiteral pFilterPowerPoint97AutoPlay(u"MS PowerPoint 97 AutoPlay")
constexpr OUStringLiteral pFilterPowerPoint97(u"MS PowerPoint 97")
constexpr OUStringLiteral pFilterPowerPoint97Template(u"MS PowerPoint 97 Vorlage")
float u
EEControlBits
#define ERRCODE_IO_BROKENPACKAGE
#define ERRCODE_ABORT
#define ERRCODE_NONE
#define SOFFICE_FILEFORMAT_8
#define SOFFICE_FILEFORMAT_60
SotClipboardFormatId
#define SAL_WARN(area, stream)
int i
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
#define ASPECT_CONTENT
EditMode
Definition: pres.hxx:53
PageKind
Definition: pres.hxx:45
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
@ Normal
standard load and save of the complete document
@ Organizer
only for import, only the styles are loaded
static SfxItemSet & rSet
Reference< XController > xController
#define SDRPAGE_NOTFOUND
SfxPrinterChangeFlags