/src/libreoffice/sd/source/ui/docshell/docshel4.cxx
Line | Count | Source |
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 <sfx2/infobar.hxx> |
42 | | #include <svx/svdotext.hxx> |
43 | | #include <sfx2/printer.hxx> |
44 | | #include <svtools/ctrltool.hxx> |
45 | | #include <comphelper/classids.hxx> |
46 | | #include <comphelper/scopeguard.hxx> |
47 | | #include <sot/formats.hxx> |
48 | | #include <sfx2/viewfrm.hxx> |
49 | | #include <vcl/syswin.hxx> |
50 | | #include <com/sun/star/drawing/XDrawPage.hpp> |
51 | | #include <com/sun/star/drawing/XDrawView.hpp> |
52 | | #include <tools/debug.hxx> |
53 | | |
54 | | #include <app.hrc> |
55 | | #include <strings.hrc> |
56 | | #include <FrameView.hxx> |
57 | | #include <optsitem.hxx> |
58 | | #include <Outliner.hxx> |
59 | | #include <sdattr.hrc> |
60 | | #include <drawdoc.hxx> |
61 | | #include <ViewShell.hxx> |
62 | | #include <sdmod.hxx> |
63 | | #include <View.hxx> |
64 | | #include <EffectMigration.hxx> |
65 | | #include <CustomAnimationEffect.hxx> |
66 | | #include <sdpage.hxx> |
67 | | #include <sdresid.hxx> |
68 | | #include <DrawViewShell.hxx> |
69 | | #include <ViewShellBase.hxx> |
70 | | #include <OutlineView.hxx> |
71 | | #include <OutlineViewShell.hxx> |
72 | | #include <sdxmlwrp.hxx> |
73 | | #include <sdpptwrp.hxx> |
74 | | #include <sdcgmfilter.hxx> |
75 | | #include <sdgrffilter.hxx> |
76 | | #include <sdhtmlfilter.hxx> |
77 | | #include <sdpdffilter.hxx> |
78 | | #include <framework/FrameworkHelper.hxx> |
79 | | #include <o3tl/string_view.hxx> |
80 | | |
81 | | #include <Window.hxx> |
82 | | #include <svl/intitem.hxx> |
83 | | #include <DrawController.hxx> |
84 | | #include <ResourceId.hxx> |
85 | | |
86 | | using namespace ::com::sun::star; |
87 | | using namespace ::com::sun::star::uno; |
88 | | using ::sd::framework::FrameworkHelper; |
89 | | |
90 | | // PowerPoint-Filter |
91 | | constexpr OUStringLiteral pFilterPowerPoint97( u"MS PowerPoint 97" ); |
92 | | constexpr OUStringLiteral pFilterPowerPoint97Template( u"MS PowerPoint 97 Vorlage" ); |
93 | | constexpr OUStringLiteral pFilterPowerPoint97AutoPlay( u"MS PowerPoint 97 AutoPlay" ); |
94 | | |
95 | | namespace sd { |
96 | | |
97 | | /** |
98 | | * Creates (if necessary) and returns a SfxPrinter |
99 | | */ |
100 | | SfxPrinter* DrawDocShell::GetPrinter(bool bCreate) |
101 | 59.2k | { |
102 | 59.2k | if (bCreate && !mpPrinter) |
103 | 36.3k | { |
104 | | // create ItemSet with special pool area |
105 | 36.3k | auto pSet = std::make_unique<SfxItemSetFixed< |
106 | 36.3k | SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, |
107 | 36.3k | SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, |
108 | 36.3k | ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT>>( GetPool() ); |
109 | | // set PrintOptionsSet |
110 | 36.3k | SdOptionsPrintItem aPrintItem(SdModule::get()->GetSdOptions(mpDoc->GetDocumentType())); |
111 | 36.3k | SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC ); |
112 | 36.3k | SfxPrinterChangeFlags nFlags = |
113 | 36.3k | (aPrintItem.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) | |
114 | 36.3k | (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE); |
115 | 36.3k | aFlagItem.SetValue( static_cast<int>(nFlags) ); |
116 | | |
117 | 36.3k | pSet->Put( aPrintItem ); |
118 | 36.3k | pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) ); |
119 | 36.3k | pSet->Put( aFlagItem ); |
120 | | |
121 | 36.3k | mpPrinter = VclPtr<SfxPrinter>::Create(std::move(pSet)); |
122 | 36.3k | mbOwnPrinter = true; |
123 | | |
124 | | // set output quality |
125 | 36.3k | sal_uInt16 nQuality = aPrintItem.GetOptionsPrint().GetOutputQuality(); |
126 | | |
127 | 36.3k | DrawModeFlags nMode = DrawModeFlags::Default; |
128 | | // 1 == Grayscale, 2 == Black & White (with grayscale images) |
129 | 36.3k | if( nQuality == 1 ) |
130 | 0 | nMode = DrawModeFlags::GrayLine | DrawModeFlags::GrayFill | DrawModeFlags::GrayText | DrawModeFlags::GrayBitmap | DrawModeFlags::GrayGradient; |
131 | 36.3k | else if( nQuality == 2 ) |
132 | 0 | nMode = DrawModeFlags::BlackLine | DrawModeFlags::WhiteFill | DrawModeFlags::BlackText | DrawModeFlags::GrayBitmap | DrawModeFlags::WhiteGradient; |
133 | | |
134 | 36.3k | mpPrinter->SetDrawMode( nMode ); |
135 | | |
136 | 36.3k | MapMode aMM (mpPrinter->GetMapMode()); |
137 | 36.3k | aMM.SetMapUnit(MapUnit::Map100thMM); |
138 | 36.3k | mpPrinter->SetMapMode(aMM); |
139 | 36.3k | UpdateRefDevice(); |
140 | 36.3k | } |
141 | 59.2k | return mpPrinter; |
142 | 59.2k | } |
143 | | |
144 | | /** |
145 | | * Set new SfxPrinter (transfer of ownership) |
146 | | */ |
147 | | void DrawDocShell::SetPrinter(SfxPrinter *pNewPrinter) |
148 | 3.64k | { |
149 | 3.64k | if ( mpViewShell ) |
150 | 0 | { |
151 | 0 | ::sd::View* pView = mpViewShell->GetView(); |
152 | 0 | if ( pView->IsTextEdit() ) |
153 | 0 | pView->SdrEndTextEdit(); |
154 | 0 | } |
155 | | |
156 | 3.64k | if ( mpPrinter && mbOwnPrinter && (mpPrinter.get() != pNewPrinter) ) |
157 | 3.64k | mpPrinter.disposeAndClear(); |
158 | | |
159 | 3.64k | mpPrinter = pNewPrinter; |
160 | 3.64k | mbOwnPrinter = true; |
161 | 3.64k | if ( mpDoc->GetPrinterIndependentLayout() == css::document::PrinterIndependentLayout::DISABLED ) |
162 | 1.45k | UpdateFontList(); |
163 | 3.64k | UpdateRefDevice(); |
164 | 3.64k | } |
165 | | |
166 | | void DrawDocShell::UpdateFontList() |
167 | 37.7k | { |
168 | 37.7k | mpFontList.reset(); |
169 | 37.7k | OutputDevice* pRefDevice = nullptr; |
170 | 37.7k | if ( mpDoc->GetPrinterIndependentLayout() == css::document::PrinterIndependentLayout::DISABLED ) |
171 | 37.7k | pRefDevice = GetPrinter(true); |
172 | 0 | else |
173 | 0 | pRefDevice = SdModule::get()->GetVirtualRefDevice(); |
174 | 37.7k | mpFontList.reset( new FontList(pRefDevice, nullptr) ); |
175 | 37.7k | SvxFontListItem aFontListItem( mpFontList.get(), SID_ATTR_CHAR_FONTLIST ); |
176 | 37.7k | PutItem( aFontListItem ); |
177 | 37.7k | } |
178 | | |
179 | | Printer* DrawDocShell::GetDocumentPrinter() |
180 | 0 | { |
181 | 0 | return GetPrinter(false); |
182 | 0 | } |
183 | | |
184 | | void DrawDocShell::OnDocumentPrinterChanged(Printer* pNewPrinter) |
185 | 0 | { |
186 | | // if we already have a printer, see if it's the same |
187 | 0 | if( mpPrinter ) |
188 | 0 | { |
189 | | // easy case |
190 | 0 | if( mpPrinter == pNewPrinter ) |
191 | 0 | return; |
192 | | |
193 | | // compare if it's the same printer with the same job setup |
194 | 0 | if( (mpPrinter->GetName() == pNewPrinter->GetName()) && |
195 | 0 | (mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup())) |
196 | 0 | return; |
197 | 0 | } |
198 | | |
199 | 0 | SfxPrinter* const pSfxPrinter = dynamic_cast<SfxPrinter*>(pNewPrinter); |
200 | 0 | if (pSfxPrinter) |
201 | 0 | { |
202 | 0 | SetPrinter(pSfxPrinter); |
203 | | |
204 | | // container owns printer |
205 | 0 | mbOwnPrinter = false; |
206 | 0 | } |
207 | 0 | } |
208 | | |
209 | | void DrawDocShell::UpdateRefDevice() |
210 | 114k | { |
211 | 114k | if( !mpDoc ) |
212 | 36.3k | return; |
213 | | |
214 | | // Determine the device for which the output will be formatted. |
215 | 78.0k | VclPtr< OutputDevice > pRefDevice; |
216 | 78.0k | switch (mpDoc->GetPrinterIndependentLayout()) |
217 | 78.0k | { |
218 | 74.1k | case css::document::PrinterIndependentLayout::DISABLED: |
219 | 74.1k | pRefDevice = mpPrinter.get(); |
220 | 74.1k | break; |
221 | | |
222 | 3.94k | case css::document::PrinterIndependentLayout::ENABLED: |
223 | 3.94k | pRefDevice = SdModule::get()->GetVirtualRefDevice(); |
224 | 3.94k | break; |
225 | | |
226 | 0 | default: |
227 | | // We are confronted with an invalid or un-implemented |
228 | | // layout mode. Use the printer as formatting device |
229 | | // as a fall-back. |
230 | 0 | SAL_WARN( "sd", "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode"); |
231 | | |
232 | 0 | pRefDevice = mpPrinter.get(); |
233 | 0 | break; |
234 | 78.0k | } |
235 | 78.0k | mpDoc->SetRefDevice( pRefDevice.get() ); |
236 | | |
237 | 78.0k | SdOutliner* pOutl = mpDoc->GetOutliner( false ); |
238 | | |
239 | 78.0k | if( pOutl ) |
240 | 0 | pOutl->SetRefDevice( pRefDevice ); |
241 | | |
242 | 78.0k | SdOutliner* pInternalOutl = mpDoc->GetInternalOutliner( false ); |
243 | | |
244 | 78.0k | if( pInternalOutl ) |
245 | 5.40k | pInternalOutl->SetRefDevice( pRefDevice ); |
246 | 78.0k | } |
247 | | |
248 | | /** |
249 | | * Creates new document, opens streams |
250 | | */ |
251 | | bool DrawDocShell::InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) |
252 | 21.1k | { |
253 | 21.1k | bool bRet = SfxObjectShell::InitNew( xStorage ); |
254 | | |
255 | 21.1k | ::tools::Rectangle aVisArea( Point(0, 0), Size(14100, 10000) ); |
256 | 21.1k | SetVisArea(aVisArea); |
257 | | |
258 | 21.1k | if (bRet) |
259 | 21.1k | { |
260 | 21.1k | if( !mbSdDataObj ) |
261 | 21.1k | mpDoc->NewOrLoadCompleted(DocCreationMode::New); // otherwise calling |
262 | | // NewOrLoadCompleted(NEW_LOADED) in |
263 | | // SdDrawDocument::AllocModel() |
264 | 21.1k | } |
265 | 21.1k | return bRet; |
266 | 21.1k | } |
267 | | |
268 | | /** |
269 | | * loads pools and document |
270 | | */ |
271 | | bool DrawDocShell::Load( SfxMedium& rMedium ) |
272 | 0 | { |
273 | | // If this is an ODF file being loaded, then by default, use legacy processing |
274 | | // (if required, it will be overridden in *::ReadUserDataSequence()) |
275 | 0 | if (IsOwnStorageFormat(rMedium)) |
276 | 0 | { |
277 | 0 | mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy, true); // for tdf#99729 |
278 | 0 | mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::LegacyFontwork, true); // for tdf#148000 |
279 | 0 | } |
280 | |
|
281 | 0 | bool bRet = false; |
282 | 0 | bool bStartPresentation = false; |
283 | 0 | ErrCode nError = ERRCODE_NONE; |
284 | |
|
285 | 0 | SfxItemSet& rSet = rMedium.GetItemSet(); |
286 | |
|
287 | 0 | if( ( SfxItemState::SET == rSet.GetItemState(SID_PREVIEW ) ) && rSet.Get( SID_PREVIEW ).GetValue() ) |
288 | 0 | { |
289 | 0 | mpDoc->SetStarDrawPreviewMode( true ); |
290 | 0 | } |
291 | |
|
292 | 0 | bRet = SfxObjectShell::Load( rMedium ); |
293 | 0 | if (bRet) |
294 | 0 | { |
295 | 0 | comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = getEmbeddedObjectContainer(); |
296 | 0 | rEmbeddedObjectContainer.setUserAllowsLinkUpdate(false); |
297 | 0 | bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError ); |
298 | 0 | } |
299 | |
|
300 | 0 | if( bRet ) |
301 | 0 | { |
302 | 0 | SdDrawDocument* pDoc = GetDoc(); |
303 | | |
304 | | // for legacy markup in OOoXML filter, convert the animations now |
305 | 0 | EffectMigration::DocumentLoaded(*pDoc); |
306 | 0 | UpdateTablePointers(); |
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 | 0 | if( ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() ) |
314 | 0 | { |
315 | 0 | SdPage* pPage = mpDoc->GetSdPage( 0, PageKind::Standard ); |
316 | |
|
317 | 0 | if( pPage ) |
318 | 0 | SetVisArea( pPage->GetAllObjBoundRect() ); |
319 | 0 | } |
320 | |
|
321 | 0 | FinishedLoading(); |
322 | |
|
323 | 0 | const INetURLObject aUrl; |
324 | 0 | SfxObjectShell::SetAutoLoad( aUrl, 0, false ); |
325 | |
|
326 | 0 | const sal_uInt16 nMasterPages = pDoc->GetMasterSdPageCount(PageKind::Standard); |
327 | 0 | if (nMasterPages > 100) |
328 | 0 | { |
329 | 0 | const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); |
330 | 0 | OUString sMasterPages = rLocaleData.getNum(nMasterPages, 0, true, false); |
331 | 0 | AppendInfoBarWhenReady(u"toomanymasterpages"_ustr, SdResId(STR_MANY_MASTER_PAGES).replaceFirst("%n", sMasterPages), |
332 | 0 | SdResId(STR_MANY_MASTER_PAGES_DETAIL), InfobarType::INFO); |
333 | 0 | } |
334 | 0 | } |
335 | 0 | else |
336 | 0 | { |
337 | 0 | if( nError == ERRCODE_IO_BROKENPACKAGE ) |
338 | 0 | SetError(ERRCODE_IO_BROKENPACKAGE); |
339 | | |
340 | | // TODO/LATER: correct error handling?! |
341 | | //pStore->SetError(SVSTREAM_WRONGVERSION); |
342 | 0 | else |
343 | 0 | SetError(ERRCODE_ABORT); |
344 | 0 | } |
345 | |
|
346 | 0 | if (SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)) |
347 | 0 | { |
348 | 0 | sal_uInt16 nStartingSlide = rSet.Get(SID_DOC_STARTPRESENTATION).GetValue(); |
349 | 0 | if (nStartingSlide == 0) |
350 | 0 | { |
351 | 0 | OUString sStartPage = mpDoc->getPresentationSettings().maPresPage; |
352 | 0 | if (!sStartPage.isEmpty()) |
353 | 0 | { |
354 | 0 | bool bIsMasterPage = false; |
355 | 0 | sal_uInt16 nPageNumb = mpDoc->GetPageByName(sStartPage, bIsMasterPage); |
356 | 0 | nStartingSlide = (nPageNumb + 1) / 2; |
357 | 0 | } |
358 | 0 | else |
359 | 0 | nStartingSlide = 1; |
360 | 0 | } |
361 | 0 | bStartPresentation = nStartingSlide; |
362 | 0 | mpDoc->SetStartWithPresentation(nStartingSlide); |
363 | 0 | } |
364 | | |
365 | | // tell SFX to change viewshell when in preview mode |
366 | 0 | if( IsPreview() || bStartPresentation ) |
367 | 0 | { |
368 | 0 | GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) ); |
369 | 0 | } |
370 | |
|
371 | 0 | return bRet; |
372 | 0 | } |
373 | | |
374 | | /** |
375 | | * loads content for organizer |
376 | | */ |
377 | | bool DrawDocShell::LoadFrom( SfxMedium& rMedium ) |
378 | 0 | { |
379 | 0 | std::unique_ptr<weld::WaitObject> pWait; |
380 | 0 | if( mpViewShell ) |
381 | 0 | pWait.reset(new weld::WaitObject(mpViewShell->GetFrameWeld())); |
382 | |
|
383 | 0 | mpDoc->NewOrLoadCompleted( DocCreationMode::New ); |
384 | 0 | mpDoc->CreateFirstPages(); |
385 | 0 | mpDoc->StopWorkStartupDelay(); |
386 | | |
387 | | // TODO/LATER: nobody is interested in the error code?! |
388 | 0 | ErrCode nError = ERRCODE_NONE; |
389 | 0 | bool bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError ); |
390 | | |
391 | | // tell SFX to change viewshell when in preview mode |
392 | 0 | if( IsPreview() ) |
393 | 0 | { |
394 | 0 | GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 5 ) ); |
395 | 0 | } |
396 | |
|
397 | 0 | return bRet; |
398 | 0 | } |
399 | | |
400 | | /** |
401 | | * load from 3rd party format |
402 | | */ |
403 | | bool DrawDocShell::ImportFrom(SfxMedium &rMedium, |
404 | | uno::Reference<text::XTextRange> const& xInsertPosition) |
405 | 0 | { |
406 | 0 | const OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); |
407 | 0 | const bool bIsPowerPointECMA = aFilterName.startsWith("Impress MS PowerPoint 2007 XML"); |
408 | 0 | const bool bIsPowerPointISO29500 = aFilterName.startsWith("Impress Office Open XML"); // 2010+ |
409 | 0 | if (bIsPowerPointECMA || bIsPowerPointISO29500) |
410 | 0 | { |
411 | | // As this is a MSFT format, we should use the "MS Compat" |
412 | | // mode for spacing before and after paragraphs. |
413 | | |
414 | | // This is copied from what is done for .ppt import in |
415 | | // ImplSdPPTImport::Import() in sd/source/filter/ppt/pptin.cxx |
416 | | // in. We need to tell both the edit engine of the draw outliner, |
417 | | // and the document, to do "summation of paragraphs". |
418 | 0 | SdrOutliner& rOutl = mpDoc->GetDrawOutliner(); |
419 | 0 | EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord(); |
420 | 0 | nControlWord |= EEControlBits::ULSPACESUMMATION; |
421 | 0 | const_cast<EditEngine&>(rOutl.GetEditEngine()).SetControlWord( nControlWord ); |
422 | |
|
423 | 0 | mpDoc->SetSummationOfParagraphs(); |
424 | | |
425 | | // tdf#149756 tdf#152545 |
426 | | // This is a "MS Compact" mode for connectors. |
427 | | // The Libreoffice uses bounding rectangle of connected shapes but |
428 | | // MSO uses snap rectangle when calculate the edge track. |
429 | 0 | mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect, true); |
430 | | |
431 | | // compatibility flag for tdf#148966 |
432 | 0 | mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::IgnoreBreakAfterMultilineField, true); |
433 | | |
434 | | // tdf#168010: PowerPoint ignores empty trailing lines in autoshrink text when scaling font |
435 | | // (same as Impress), but takes into account in layout: |
436 | 0 | mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout, true); |
437 | | |
438 | | // tdf#96389 |
439 | | // We need to be able to set the default tab size for each text object. |
440 | | // This is possible at the moment only for the whole document. See |
441 | | // TextParagraphPropertiesContext constructor. So default tab width |
442 | | // of the LibreOffice is 1270 but MSO is 2540 on general settings. |
443 | 0 | mpDoc->SetDefaultTabulator( 2540 ); |
444 | 0 | } |
445 | |
|
446 | 0 | comphelper::ScopeGuard undoGuard([this, wasUndo = mpDoc->IsUndoEnabled()] |
447 | 0 | { mpDoc->EnableUndo(wasUndo); }); |
448 | 0 | if (xInsertPosition) // insert mode |
449 | 0 | { |
450 | 0 | undoGuard.dismiss(); |
451 | 0 | } |
452 | 0 | else // initial loading of the document |
453 | 0 | { |
454 | 0 | mpDoc->EnableUndo(false); |
455 | 0 | } |
456 | |
|
457 | 0 | const bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition); |
458 | |
|
459 | 0 | SfxItemSet& rSet = rMedium.GetItemSet(); |
460 | 0 | if (SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)) |
461 | 0 | { |
462 | 0 | sal_uInt16 nStartingSlide = rSet.Get(SID_DOC_STARTPRESENTATION).GetValue(); |
463 | 0 | if (nStartingSlide == 0) |
464 | 0 | { |
465 | 0 | OUString sStartPage = mpDoc->getPresentationSettings().maPresPage; |
466 | 0 | if (!sStartPage.isEmpty()) |
467 | 0 | { |
468 | 0 | bool bIsMasterPage = false; |
469 | 0 | sal_uInt16 nPageNumb = mpDoc->GetPageByName(sStartPage, bIsMasterPage); |
470 | 0 | nStartingSlide = (nPageNumb + 1) / 2; |
471 | 0 | } |
472 | 0 | else |
473 | 0 | nStartingSlide = 1; |
474 | 0 | } |
475 | 0 | mpDoc->SetStartWithPresentation(nStartingSlide); |
476 | | |
477 | | // tell SFX to change viewshell when in preview mode |
478 | 0 | if (IsPreview()) |
479 | 0 | { |
480 | 0 | GetMedium()->GetItemSet().Put(SfxUInt16Item(SID_VIEW_ID, 1)); |
481 | 0 | } |
482 | 0 | } |
483 | |
|
484 | 0 | return bRet; |
485 | 0 | } |
486 | | |
487 | | /** |
488 | | * load from a foreign format |
489 | | */ |
490 | | bool DrawDocShell::ConvertFrom( SfxMedium& rMedium ) |
491 | 0 | { |
492 | 0 | const OUString aFilterName( rMedium.GetFilter()->GetFilterName() ); |
493 | 0 | bool bRet = false; |
494 | 0 | bool bStartPresentation = false; |
495 | |
|
496 | 0 | SetWaitCursor( true ); |
497 | |
|
498 | 0 | SfxItemSet& rSet = rMedium.GetItemSet(); |
499 | 0 | if( ( SfxItemState::SET == rSet.GetItemState(SID_PREVIEW ) ) && rSet.Get( SID_PREVIEW ).GetValue() ) |
500 | 0 | { |
501 | 0 | mpDoc->SetStarDrawPreviewMode( true ); |
502 | 0 | } |
503 | |
|
504 | 0 | if (SfxItemState::SET == rSet.GetItemState(SID_DOC_STARTPRESENTATION)) |
505 | 0 | { |
506 | 0 | sal_uInt16 nStartingSlide = rSet.Get(SID_DOC_STARTPRESENTATION).GetValue(); |
507 | 0 | if (nStartingSlide == 0) |
508 | 0 | { |
509 | 0 | OUString sStartPage = mpDoc->getPresentationSettings().maPresPage; |
510 | 0 | if (!sStartPage.isEmpty()) |
511 | 0 | { |
512 | 0 | bool bIsMasterPage = false; |
513 | 0 | sal_uInt16 nPageNumb = mpDoc->GetPageByName(sStartPage, bIsMasterPage); |
514 | 0 | nStartingSlide = (nPageNumb + 1) / 2; |
515 | 0 | } |
516 | 0 | else |
517 | 0 | nStartingSlide = 1; |
518 | 0 | } |
519 | 0 | bStartPresentation = nStartingSlide; |
520 | 0 | mpDoc->SetStartWithPresentation(nStartingSlide); |
521 | 0 | } |
522 | |
|
523 | 0 | if( aFilterName == pFilterPowerPoint97 |
524 | 0 | || aFilterName == pFilterPowerPoint97Template |
525 | 0 | || aFilterName == pFilterPowerPoint97AutoPlay) |
526 | 0 | { |
527 | 0 | mpDoc->StopWorkStartupDelay(); |
528 | 0 | bRet = SdPPTFilter( rMedium, *this ).Import(); |
529 | 0 | } |
530 | 0 | else if (aFilterName.indexOf("impress8") >= 0 || |
531 | 0 | aFilterName.indexOf("draw8") >= 0) |
532 | 0 | { |
533 | | // TODO/LATER: nobody is interested in the error code?! |
534 | 0 | mpDoc->CreateFirstPages(); |
535 | 0 | mpDoc->StopWorkStartupDelay(); |
536 | 0 | ErrCode nError = ERRCODE_NONE; |
537 | 0 | bRet = SdXMLFilter( rMedium, *this ).Import( nError ); |
538 | |
|
539 | 0 | } |
540 | 0 | else if (aFilterName.indexOf("StarOffice XML (Draw)") >= 0 || |
541 | 0 | aFilterName.indexOf("StarOffice XML (Impress)") >= 0) |
542 | 0 | { |
543 | | // TODO/LATER: nobody is interested in the error code?! |
544 | 0 | mpDoc->CreateFirstPages(); |
545 | 0 | mpDoc->StopWorkStartupDelay(); |
546 | 0 | ErrCode nError = ERRCODE_NONE; |
547 | 0 | bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SOFFICE_FILEFORMAT_60 ).Import( nError ); |
548 | 0 | } |
549 | 0 | else if (aFilterName == "CGM - Computer Graphics Metafile") |
550 | 0 | { |
551 | 0 | mpDoc->CreateFirstPages(); |
552 | 0 | mpDoc->StopWorkStartupDelay(); |
553 | 0 | bRet = SdCGMFilter( rMedium, *this ).Import(); |
554 | 0 | } |
555 | 0 | else if (aFilterName == "draw_pdf_import") |
556 | 0 | { |
557 | 0 | mpDoc->CreateFirstPages(); |
558 | 0 | mpDoc->StopWorkStartupDelay(); |
559 | 0 | bRet = SdPdfFilter(rMedium, *this).Import(); |
560 | 0 | } |
561 | 0 | else |
562 | 0 | { |
563 | 0 | mpDoc->CreateFirstPages(); |
564 | 0 | mpDoc->StopWorkStartupDelay(); |
565 | 0 | bRet = SdGRFFilter( rMedium, *this ).Import(); |
566 | 0 | } |
567 | |
|
568 | 0 | FinishedLoading(); |
569 | | |
570 | | // tell SFX to change viewshell when in preview mode |
571 | 0 | if( IsPreview() ) |
572 | 0 | { |
573 | 0 | GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, 5 ) ); |
574 | 0 | } |
575 | 0 | SetWaitCursor( false ); |
576 | | |
577 | | // tell SFX to change viewshell when in preview mode |
578 | 0 | if( IsPreview() || bStartPresentation ) |
579 | 0 | { |
580 | 0 | GetMedium()->GetItemSet().Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) ); |
581 | 0 | } |
582 | |
|
583 | 0 | return bRet; |
584 | 0 | } |
585 | | |
586 | | /** |
587 | | * Writes pools and document to the open streams |
588 | | */ |
589 | | bool DrawDocShell::Save() |
590 | 0 | { |
591 | 0 | mpDoc->StopWorkStartupDelay(); |
592 | | |
593 | | //TODO/LATER: why this?! |
594 | 0 | if( GetCreateMode() == SfxObjectCreateMode::STANDARD ) |
595 | 0 | SfxObjectShell::SetVisArea( ::tools::Rectangle() ); |
596 | |
|
597 | 0 | bool bRet = SfxObjectShell::Save(); |
598 | |
|
599 | 0 | if( bRet ) |
600 | 0 | bRet = SdXMLFilter( *GetMedium(), *this, SdXMLFilterMode::Normal, SotStorage::GetVersion( GetMedium()->GetStorage() ) ).Export(); |
601 | |
|
602 | 0 | return bRet; |
603 | 0 | } |
604 | | |
605 | | /** |
606 | | * Writes pools and document to the provided storage |
607 | | */ |
608 | | bool DrawDocShell::SaveAs( SfxMedium& rMedium ) |
609 | 0 | { |
610 | 0 | mpDoc->setDocAccTitle(OUString()); |
611 | 0 | if (SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst(this)) |
612 | 0 | { |
613 | 0 | if (vcl::Window* pSysWin = pFrame1->GetWindow().GetSystemWindow()) |
614 | 0 | { |
615 | 0 | pSysWin->SetAccessibleName(OUString()); |
616 | 0 | } |
617 | 0 | } |
618 | 0 | mpDoc->StopWorkStartupDelay(); |
619 | | |
620 | | //With custom animation, if Outliner is modified, update text before saving |
621 | 0 | if( mpViewShell ) |
622 | 0 | { |
623 | 0 | SdPage* pPage = mpViewShell->getCurrentPage(); |
624 | 0 | if( pPage && pPage->getMainSequence()->getCount() ) |
625 | 0 | { |
626 | 0 | SdrObject* pObj = mpViewShell->GetView()->GetTextEditObject(); |
627 | 0 | SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner(); |
628 | 0 | if( pObj && pOutl && pOutl->IsModified() ) |
629 | 0 | { |
630 | 0 | std::optional<OutlinerParaObject> pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() ); |
631 | 0 | pObj->SetOutlinerParaObject( std::move(pNewText) ); |
632 | 0 | pOutl->ClearModifyFlag(); |
633 | 0 | } |
634 | 0 | } |
635 | 0 | } |
636 | | |
637 | | //TODO/LATER: why this?! |
638 | 0 | if( GetCreateMode() == SfxObjectCreateMode::STANDARD ) |
639 | 0 | SfxObjectShell::SetVisArea( ::tools::Rectangle() ); |
640 | |
|
641 | 0 | bool bRet = SfxObjectShell::SaveAs( rMedium ); |
642 | |
|
643 | 0 | if( bRet ) |
644 | 0 | bRet = SdXMLFilter( rMedium, *this, SdXMLFilterMode::Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export(); |
645 | |
|
646 | 0 | if( GetErrorIgnoreWarning() == ERRCODE_NONE ) |
647 | 0 | SetError(ERRCODE_NONE); |
648 | |
|
649 | 0 | return bRet; |
650 | 0 | } |
651 | | |
652 | | /** |
653 | | * save to foreign format |
654 | | */ |
655 | | bool DrawDocShell::ConvertTo( SfxMedium& rMedium ) |
656 | 0 | { |
657 | 0 | bool bRet = false; |
658 | |
|
659 | 0 | if( mpDoc->GetPageCount() ) |
660 | 0 | { |
661 | 0 | std::shared_ptr<const SfxFilter> pMediumFilter = rMedium.GetFilter(); |
662 | 0 | const OUString aTypeName( pMediumFilter->GetTypeName() ); |
663 | 0 | std::unique_ptr<SdFilter> xFilter; |
664 | |
|
665 | 0 | if( aTypeName.indexOf( "graphic_HTML" ) >= 0 ) |
666 | 0 | { |
667 | 0 | xFilter = std::make_unique<SdHTMLFilter>(rMedium, *this); |
668 | 0 | } |
669 | 0 | else if( aTypeName.indexOf( "MS_PowerPoint_97" ) >= 0 ) |
670 | 0 | { |
671 | 0 | xFilter = std::make_unique<SdPPTFilter>(rMedium, *this); |
672 | 0 | static_cast<SdPPTFilter*>(xFilter.get())->PreSaveBasic(); |
673 | 0 | } |
674 | 0 | else if ( aTypeName.indexOf( "CGM_Computer_Graphics_Metafile" ) >= 0 ) |
675 | 0 | { |
676 | 0 | xFilter = std::make_unique<SdCGMFilter>(rMedium, *this); |
677 | 0 | } |
678 | 0 | else if( aTypeName.indexOf( "draw8" ) >= 0 || |
679 | 0 | aTypeName.indexOf( "impress8" ) >= 0 ) |
680 | 0 | { |
681 | 0 | xFilter = std::make_unique<SdXMLFilter>(rMedium, *this); |
682 | 0 | } |
683 | 0 | else if( aTypeName.indexOf( "StarOffice_XML_Impress" ) >= 0 || |
684 | 0 | aTypeName.indexOf( "StarOffice_XML_Draw" ) >= 0 ) |
685 | 0 | { |
686 | 0 | xFilter = std::make_unique<SdXMLFilter>(rMedium, *this, SdXMLFilterMode::Normal, SOFFICE_FILEFORMAT_60); |
687 | 0 | } |
688 | 0 | else |
689 | 0 | { |
690 | 0 | xFilter = std::make_unique<SdGRFFilter>(rMedium, *this); |
691 | 0 | } |
692 | |
|
693 | 0 | if (xFilter) |
694 | 0 | { |
695 | 0 | if ( mpViewShell ) |
696 | 0 | { |
697 | 0 | ::sd::View* pView = mpViewShell->GetView(); |
698 | 0 | if ( pView->IsTextEdit() ) |
699 | 0 | pView->SdrEndTextEdit(); |
700 | 0 | } |
701 | |
|
702 | 0 | bRet = xFilter->Export(); |
703 | 0 | } |
704 | 0 | } |
705 | |
|
706 | 0 | return bRet; |
707 | 0 | } |
708 | | |
709 | | /** |
710 | | * Reopen own streams to ensure that nobody else can prevent use from opening |
711 | | * them. |
712 | | */ |
713 | | bool DrawDocShell::SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ) |
714 | 0 | { |
715 | 0 | bool bRet = false; |
716 | |
|
717 | 0 | if( SfxObjectShell::SaveCompleted(xStorage) ) |
718 | 0 | { |
719 | 0 | mpDoc->NbcSetChanged( false ); |
720 | |
|
721 | 0 | if( mpViewShell ) |
722 | 0 | { |
723 | 0 | if( dynamic_cast< OutlineViewShell *>( mpViewShell ) != nullptr ) |
724 | 0 | static_cast<OutlineView*>(mpViewShell->GetView()) |
725 | 0 | ->GetOutliner().ClearModifyFlag(); |
726 | |
|
727 | 0 | SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner(); |
728 | 0 | if( pOutl ) |
729 | 0 | { |
730 | 0 | SdrObject* pObj = mpViewShell->GetView()->GetTextEditObject(); |
731 | 0 | if( pObj ) |
732 | 0 | pObj->NbcSetOutlinerParaObject( pOutl->CreateParaObject() ); |
733 | |
|
734 | 0 | pOutl->ClearModifyFlag(); |
735 | 0 | } |
736 | 0 | } |
737 | |
|
738 | 0 | bRet = true; |
739 | |
|
740 | 0 | SfxViewFrame* pFrame = ( mpViewShell && mpViewShell->GetViewFrame() ) ? |
741 | 0 | mpViewShell->GetViewFrame() : |
742 | 0 | SfxViewFrame::Current(); |
743 | |
|
744 | 0 | if( pFrame ) |
745 | 0 | pFrame->GetBindings().Invalidate( SID_NAVIGATOR_STATE, true ); |
746 | 0 | } |
747 | 0 | return bRet; |
748 | 0 | } |
749 | | |
750 | | SfxStyleSheetBasePool* DrawDocShell::GetStyleSheetPool() |
751 | 0 | { |
752 | 0 | return mpDoc->GetStyleSheetPool(); |
753 | 0 | } |
754 | | |
755 | | void DrawDocShell::GotoBookmark(std::u16string_view rBookmark) |
756 | 0 | { |
757 | 0 | auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ); |
758 | 0 | if (!pDrawViewShell) |
759 | 0 | return; |
760 | | |
761 | 0 | ViewShellBase& rBase (mpViewShell->GetViewShellBase()); |
762 | |
|
763 | 0 | bool bIsMasterPage = false; |
764 | 0 | sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND; |
765 | 0 | SdrObject* pObj = nullptr; |
766 | |
|
767 | 0 | static constexpr std::u16string_view sInteraction( u"action?" ); |
768 | 0 | if ( o3tl::starts_with(rBookmark, sInteraction ) ) |
769 | 0 | { |
770 | 0 | static constexpr std::u16string_view sJump( u"jump=" ); |
771 | 0 | if ( o3tl::starts_with(rBookmark.substr( sInteraction.size() ), sJump ) ) |
772 | 0 | { |
773 | 0 | std::u16string_view aDestination( rBookmark.substr( sInteraction.size() + sJump.size() ) ); |
774 | 0 | if ( o3tl::starts_with(aDestination, u"firstslide" ) ) |
775 | 0 | { |
776 | 0 | nPageNumber = 1; |
777 | 0 | } |
778 | 0 | else if ( o3tl::starts_with(aDestination, u"lastslide" ) ) |
779 | 0 | { |
780 | 0 | nPageNumber = mpDoc->GetPageCount() - 2; |
781 | 0 | } |
782 | 0 | else if ( o3tl::starts_with(aDestination, u"previousslide" ) ) |
783 | 0 | { |
784 | 0 | SdPage* pPage = pDrawViewShell->GetActualPage(); |
785 | 0 | nPageNumber = pPage->GetPageNum(); |
786 | 0 | nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND; |
787 | 0 | } |
788 | 0 | else if ( o3tl::starts_with(aDestination, u"nextslide" ) ) |
789 | 0 | { |
790 | 0 | SdPage* pPage = pDrawViewShell->GetActualPage(); |
791 | 0 | nPageNumber = pPage->GetPageNum() + 2; |
792 | 0 | if ( nPageNumber >= mpDoc->GetPageCount() ) |
793 | 0 | nPageNumber = SDRPAGE_NOTFOUND; |
794 | 0 | } |
795 | 0 | } |
796 | 0 | } |
797 | 0 | else |
798 | 0 | { |
799 | | // Is the bookmark a page? |
800 | 0 | nPageNumber = mpDoc->GetPageByName( rBookmark, bIsMasterPage ); |
801 | |
|
802 | 0 | if (nPageNumber == SDRPAGE_NOTFOUND) |
803 | 0 | { |
804 | | // Is the bookmark an object? |
805 | 0 | pObj = mpDoc->GetObj(rBookmark); |
806 | |
|
807 | 0 | if (pObj) |
808 | 0 | { |
809 | 0 | nPageNumber = pObj->getSdrPageFromSdrObject()->GetPageNum(); |
810 | 0 | } |
811 | 0 | } |
812 | 0 | } |
813 | 0 | if (nPageNumber != SDRPAGE_NOTFOUND) |
814 | 0 | { |
815 | | // Jump to the bookmarked page. This is done in three steps. |
816 | |
|
817 | 0 | SdPage* pPage; |
818 | 0 | if (bIsMasterPage) |
819 | 0 | pPage = static_cast<SdPage*>( mpDoc->GetMasterPage(nPageNumber) ); |
820 | 0 | else |
821 | 0 | pPage = static_cast<SdPage*>( mpDoc->GetPage(nPageNumber) ); |
822 | | |
823 | | // 1.) Change the view shell to the edit view, the notes view, |
824 | | // or the handout view. |
825 | 0 | PageKind eNewPageKind = pPage->GetPageKind(); |
826 | |
|
827 | 0 | if( (eNewPageKind != PageKind::Standard) && (mpDoc->GetDocumentType() == DocumentType::Draw) ) |
828 | 0 | return; |
829 | | |
830 | 0 | if (eNewPageKind != pDrawViewShell->GetPageKind()) |
831 | 0 | { |
832 | | // change work area |
833 | 0 | GetFrameView()->SetPageKind(eNewPageKind); |
834 | 0 | OUString sViewURL; |
835 | 0 | switch (eNewPageKind) |
836 | 0 | { |
837 | 0 | case PageKind::Standard: |
838 | 0 | sViewURL = FrameworkHelper::msImpressViewURL; |
839 | 0 | break; |
840 | 0 | case PageKind::Notes: |
841 | 0 | sViewURL = FrameworkHelper::msNotesViewURL; |
842 | 0 | break; |
843 | 0 | case PageKind::Handout: |
844 | 0 | sViewURL = FrameworkHelper::msHandoutViewURL; |
845 | 0 | break; |
846 | 0 | default: |
847 | 0 | break; |
848 | 0 | } |
849 | 0 | if (!sViewURL.isEmpty()) |
850 | 0 | { |
851 | 0 | std::shared_ptr<FrameworkHelper> pHelper ( |
852 | 0 | FrameworkHelper::Instance(rBase)); |
853 | 0 | pHelper->RequestView( |
854 | 0 | sViewURL, |
855 | 0 | FrameworkHelper::msCenterPaneURL); |
856 | 0 | pHelper->WaitForUpdate(); |
857 | | |
858 | | // Get the new DrawViewShell. |
859 | 0 | mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); |
860 | 0 | pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell); |
861 | 0 | } |
862 | 0 | else |
863 | 0 | { |
864 | 0 | pDrawViewShell = nullptr; |
865 | 0 | } |
866 | 0 | } |
867 | | |
868 | 0 | if (pDrawViewShell != nullptr) |
869 | 0 | { |
870 | 0 | setEditMode(pDrawViewShell, bIsMasterPage); |
871 | | |
872 | | // Make the bookmarked page the current page. This is done |
873 | | // by using the API because this takes care of all the |
874 | | // little things to be done. Especially writing the view |
875 | | // data to the frame view. |
876 | 0 | sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2; |
877 | 0 | DrawController* pDrawController = rBase.GetDrawController(); |
878 | 0 | if (pDrawController) |
879 | 0 | { |
880 | 0 | Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY); |
881 | 0 | pDrawController->setCurrentPage (xDrawPage); |
882 | 0 | } |
883 | 0 | else |
884 | 0 | { |
885 | | // As a fall back switch to the page via the core. |
886 | 0 | DBG_ASSERT (pDrawController, |
887 | 0 | "DrawDocShell::GotoBookmark: can't switch page via API"); |
888 | 0 | pDrawViewShell->SwitchPage(nSdPgNum); |
889 | 0 | } |
890 | | |
891 | | // Do UnmarkAll here to stop the Navigator from reselecting the previously marked |
892 | | // entry when a slide entry is selected. |
893 | 0 | pDrawViewShell->GetView()->UnmarkAll(); |
894 | 0 | if (pObj != nullptr) |
895 | 0 | { |
896 | | // show and select object |
897 | 0 | if (vcl::Window* pWindow = pDrawViewShell->GetActiveWindow()) |
898 | 0 | pDrawViewShell->MakeVisible(pObj->GetSnapRect(), *pWindow); |
899 | 0 | pDrawViewShell->GetView()->MarkObj( |
900 | 0 | pObj, |
901 | 0 | pDrawViewShell->GetView()->GetSdrPageView()); |
902 | 0 | } |
903 | 0 | } |
904 | 0 | } |
905 | | |
906 | 0 | if (SfxViewFrame* pViewFrame = (pDrawViewShell && pDrawViewShell->GetViewFrame()) |
907 | 0 | ? pDrawViewShell->GetViewFrame() |
908 | 0 | : SfxViewFrame::Current()) |
909 | 0 | { |
910 | 0 | SfxBindings& rBindings = pViewFrame->GetBindings(); |
911 | 0 | rBindings.Invalidate(SID_NAVIGATOR_STATE, true); |
912 | 0 | rBindings.Invalidate(SID_NAVIGATOR_PAGENAME); |
913 | 0 | } |
914 | 0 | } |
915 | | |
916 | | /** |
917 | | * If it should become a document template. |
918 | | */ |
919 | | bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium ) |
920 | 0 | { |
921 | |
|
922 | 0 | std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter(); |
923 | |
|
924 | 0 | if (pFilter->IsOwnTemplateFormat()) |
925 | 0 | { |
926 | | /* now the StarDraw specialty: |
927 | | we assign known layout names to the layout template of the first |
928 | | page, we set the layout names of the affected masterpages and pages. |
929 | | We inform all text objects of the affected standard, note and |
930 | | masterpages about the name change. |
931 | | */ |
932 | |
|
933 | 0 | OUString aLayoutName; |
934 | |
|
935 | 0 | SfxStringItem const * pLayoutItem = rMedium.GetItemSet().GetItemIfSet(SID_TEMPLATE_NAME, false); |
936 | 0 | if( pLayoutItem ) |
937 | 0 | { |
938 | 0 | aLayoutName = pLayoutItem->GetValue(); |
939 | 0 | } |
940 | 0 | else |
941 | 0 | { |
942 | 0 | INetURLObject aURL( rMedium.GetName() ); |
943 | 0 | aURL.removeExtension(); |
944 | 0 | aLayoutName = aURL.getName(); |
945 | 0 | } |
946 | |
|
947 | 0 | if (aLayoutName.isEmpty()) |
948 | 0 | { |
949 | 0 | sal_uInt32 nCount = mpDoc->GetMasterSdPageCount(PageKind::Standard); |
950 | 0 | for (sal_uInt32 i = 0; i < nCount; ++i) |
951 | 0 | { |
952 | 0 | OUString aOldPageLayoutName = mpDoc->GetMasterSdPage(i, PageKind::Standard)->GetLayoutName(); |
953 | 0 | OUString aNewLayoutName = aLayoutName; |
954 | | // Don't add suffix for the first master page |
955 | 0 | if( i > 0 ) |
956 | 0 | aNewLayoutName += OUString::number(i); |
957 | |
|
958 | 0 | mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aNewLayoutName); |
959 | 0 | } |
960 | 0 | } |
961 | 0 | } |
962 | |
|
963 | 0 | return SfxObjectShell::SaveAsOwnFormat(rMedium); |
964 | 0 | } |
965 | | |
966 | | void DrawDocShell::FillClass(SvGlobalName* pClassName, |
967 | | SotClipboardFormatId* pFormat, |
968 | | OUString* pFullTypeName, |
969 | | sal_Int32 nFileFormat, |
970 | | bool bTemplate /* = false */) const |
971 | 16.1k | { |
972 | 16.1k | if (nFileFormat == SOFFICE_FILEFORMAT_60) |
973 | 0 | { |
974 | 0 | if ( meDocType == DocumentType::Draw ) |
975 | 0 | { |
976 | 0 | *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60); |
977 | 0 | *pFormat = SotClipboardFormatId::STARDRAW_60; |
978 | 0 | *pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60); |
979 | 0 | } |
980 | 0 | else |
981 | 0 | { |
982 | 0 | *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60); |
983 | 0 | *pFormat = SotClipboardFormatId::STARIMPRESS_60; |
984 | 0 | *pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60); |
985 | 0 | } |
986 | 0 | } |
987 | 16.1k | else if (nFileFormat == SOFFICE_FILEFORMAT_8) |
988 | 16.1k | { |
989 | 16.1k | if ( meDocType == DocumentType::Draw ) |
990 | 0 | { |
991 | 0 | *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60); |
992 | 0 | *pFormat = bTemplate ? SotClipboardFormatId::STARDRAW_8_TEMPLATE : SotClipboardFormatId::STARDRAW_8; |
993 | 0 | *pFullTypeName = SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API |
994 | 0 | } |
995 | 16.1k | else |
996 | 16.1k | { |
997 | 16.1k | *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60); |
998 | 16.1k | *pFormat = bTemplate ? SotClipboardFormatId::STARIMPRESS_8_TEMPLATE : SotClipboardFormatId::STARIMPRESS_8; |
999 | 16.1k | *pFullTypeName = SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_80); // HACK: method will be removed with new storage API |
1000 | 16.1k | } |
1001 | 16.1k | } |
1002 | 16.1k | } |
1003 | | |
1004 | | OutputDevice* DrawDocShell::GetDocumentRefDev() |
1005 | 0 | { |
1006 | 0 | OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev (); |
1007 | | // Only when our parent does not have a reference device then we return |
1008 | | // our own. |
1009 | 0 | if (pReferenceDevice == nullptr && mpDoc != nullptr) |
1010 | 0 | pReferenceDevice = mpDoc->GetRefDevice (); |
1011 | 0 | return pReferenceDevice; |
1012 | 0 | } |
1013 | | |
1014 | | /** executes the SID_OPENDOC slot to let the framework open a document |
1015 | | with the given URL and this document as a referer */ |
1016 | | void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL ) |
1017 | 0 | { |
1018 | 0 | SfxStringItem aStrItem( SID_FILE_NAME, rBookmarkURL ); |
1019 | 0 | SfxStringItem aReferer( SID_REFERER, GetMedium()->GetName() ); |
1020 | 0 | SfxUInt16Item aPresentation( SID_DOC_STARTPRESENTATION ); |
1021 | 0 | const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, &aPresentation, nullptr }; |
1022 | |
|
1023 | 0 | if (SfxViewFrame* pFrame = mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current()) |
1024 | 0 | pFrame->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs ); |
1025 | 0 | } |
1026 | | |
1027 | | std::shared_ptr<SfxDocumentInfoDialog> DrawDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) |
1028 | 0 | { |
1029 | 0 | std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet); |
1030 | 0 | DrawDocShell* pDocSh = dynamic_cast<DrawDocShell*>(SfxObjectShell::Current()); |
1031 | 0 | if( pDocSh == this ) |
1032 | 0 | { |
1033 | 0 | xDlg->AddFontTabPage(); |
1034 | 0 | } |
1035 | 0 | return xDlg; |
1036 | 0 | } |
1037 | | |
1038 | | void DrawDocShell::setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage) |
1039 | 0 | { |
1040 | | // Set the edit mode to either the normal edit mode or the |
1041 | | // master page mode. |
1042 | 0 | EditMode eNewEditMode = EditMode::Page; |
1043 | 0 | if (isMasterPage) |
1044 | 0 | { |
1045 | 0 | eNewEditMode = EditMode::MasterPage; |
1046 | 0 | } |
1047 | |
|
1048 | 0 | if (eNewEditMode != pDrawViewShell->GetEditMode()) |
1049 | 0 | { |
1050 | | // Set EditMode |
1051 | 0 | pDrawViewShell->ChangeEditMode(eNewEditMode, false); |
1052 | 0 | } |
1053 | 0 | } |
1054 | | } // end of namespace sd |
1055 | | |
1056 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |