Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svl/lckbitem.hxx>
31 : : #include <sfx2/frame.hxx>
32 : : #include <sfx2/viewfrm.hxx>
33 : : #include <unotools/moduleoptions.hxx>
34 : : #include "framework/FrameworkHelper.hxx"
35 : :
36 : : #include <svx/dialogs.hrc>
37 : :
38 : : #include <editeng/langitem.hxx>
39 : : #include <editeng/editdata.hxx>
40 : : #include <vcl/msgbox.hxx>
41 : : #include <editeng/svxenum.hxx>
42 : : #include <sfx2/dispatch.hxx>
43 : : #include <sfx2/request.hxx>
44 : : #include <sfx2/printer.hxx>
45 : : #include <sfx2/docfile.hxx>
46 : : #include <editeng/paperinf.hxx>
47 : : #include <editeng/eeitem.hxx>
48 : : #include <unotools/useroptions.hxx>
49 : : #include <com/sun/star/uno/Sequence.h>
50 : :
51 : : #include "app.hrc"
52 : : #include "glob.hrc"
53 : : #include "strings.hrc"
54 : : #include "res_bmp.hrc"
55 : :
56 : : #include "sdmod.hxx"
57 : : #include "pres.hxx"
58 : : #include "optsitem.hxx"
59 : : #include "ViewShell.hxx"
60 : : #include "sdattr.hxx"
61 : : #include "sdpage.hxx"
62 : : #include "DrawDocShell.hxx"
63 : : #include "drawdoc.hxx"
64 : : #include "assclass.hxx"
65 : : #include "sdenumdef.hxx"
66 : : #include "sdresid.hxx"
67 : : #include "OutlineViewShell.hxx"
68 : : #include "ViewShellBase.hxx"
69 : : #include "FrameView.hxx"
70 : : #include "FactoryIds.hxx"
71 : : #include "sdabstdlg.hxx"
72 : : #include <memory>
73 : : #include <boost/shared_ptr.hpp>
74 : : #include <boost/scoped_array.hpp>
75 : : #include "slideshow.hxx"
76 : :
77 : : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
78 : : #include <com/sun/star/document/XDocumentProperties.hpp>
79 : :
80 : :
81 : : using ::sd::framework::FrameworkHelper;
82 : : using ::com::sun::star::uno::Reference;
83 : : using ::com::sun::star::frame::XFrame;
84 : : using ::com::sun::star::uno::Sequence;
85 : :
86 : : namespace {
87 : :
88 : 0 : class OutlineToImpressFinalizer
89 : : {
90 : : public:
91 : : OutlineToImpressFinalizer (
92 : : ::sd::ViewShellBase& rBase,
93 : : SdDrawDocument& rDocument,
94 : : SvLockBytes& rBytes);
95 [ # # ]: 0 : virtual ~OutlineToImpressFinalizer (void) {};
96 : : void operator() (bool bEventSeen);
97 : : private:
98 : : ::sd::ViewShellBase& mrBase;
99 : : SdDrawDocument& mrDocument;
100 : : ::boost::shared_ptr<SvMemoryStream> mpStream;
101 : : };
102 : :
103 : :
104 : : } //end of anonymous namespace
105 : :
106 : :
107 : : /*************************************************************************
108 : : |*
109 : : |* Execute
110 : : |*
111 : : \************************************************************************/
112 : :
113 : 0 : void SdModule::Execute(SfxRequest& rReq)
114 : : {
115 : 0 : const SfxItemSet* pSet = rReq.GetArgs();
116 : 0 : sal_uLong nSlotId = rReq.GetSlot();
117 : :
118 [ # # # # : 0 : switch ( nSlotId )
# # # # ]
119 : : {
120 : : case SID_NEWDOC:
121 : : {
122 : 0 : SFX_APP()->ExecuteSlot(rReq, SFX_APP()->GetInterface());
123 : : }
124 : 0 : break;
125 : :
126 : : case SID_AUTOSPELL_CHECK:
127 : : {
128 : : // automatische Rechtschreibpruefung
129 : : const SfxPoolItem* pItem;
130 [ # # ][ # # ]: 0 : if( pSet && SFX_ITEM_SET == pSet->GetItemState(
[ # # ]
131 [ # # ]: 0 : SID_AUTOSPELL_CHECK, sal_False, &pItem ) )
132 : : {
133 : 0 : sal_Bool bOnlineSpelling = ( (const SfxBoolItem*) pItem )->GetValue();
134 : : // am Dokument sichern:
135 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
136 [ # # ]: 0 : if( pDocSh )
137 : : {
138 [ # # ]: 0 : SdDrawDocument* pDoc = pDocSh->GetDoc();
139 [ # # ]: 0 : pDoc->SetOnlineSpell( bOnlineSpelling );
140 : : }
141 : : }
142 : : }
143 : 0 : break;
144 : :
145 : : case SID_ATTR_METRIC:
146 : : {
147 : : const SfxPoolItem* pItem;
148 [ # # ][ # # ]: 0 : if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_ATTR_METRIC, sal_True, &pItem ) )
[ # # ][ # # ]
149 : : {
150 : 0 : FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue();
151 [ # # ]: 0 : switch( eUnit )
152 : : {
153 : : case FUNIT_MM: // nur die Einheiten, die auch im Dialog stehen
154 : : case FUNIT_CM:
155 : : case FUNIT_INCH:
156 : : case FUNIT_PICA:
157 : : case FUNIT_POINT:
158 : : {
159 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
160 [ # # ]: 0 : if(pDocSh)
161 : : {
162 [ # # ]: 0 : DocumentType eDocType = pDocSh->GetDoc()->GetDocumentType();
163 : :
164 [ # # ]: 0 : PutItem( *pItem );
165 [ # # ]: 0 : SdOptions* pOptions = GetSdOptions( eDocType );
166 [ # # ]: 0 : if(pOptions)
167 [ # # ]: 0 : pOptions->SetMetric( (sal_uInt16)eUnit );
168 [ # # ]: 0 : rReq.Done();
169 : : }
170 : : }
171 : 0 : break;
172 : : default:
173 : 0 : break;
174 : : }
175 : : }
176 : :
177 : : }
178 : 0 : break;
179 : :
180 : : case SID_ATTR_LANGUAGE:
181 : : case SID_ATTR_CHAR_CJK_LANGUAGE:
182 : : case SID_ATTR_CHAR_CTL_LANGUAGE:
183 : : {
184 : : const SfxPoolItem* pItem;
185 [ # # ][ # # ]: 0 : if( pSet &&
[ # # ][ # # ]
[ # # ]
186 : : (
187 [ # # ]: 0 : SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_LANGUAGE, sal_False, &pItem ) ||
188 [ # # ]: 0 : SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem ) ||
189 [ # # ]: 0 : SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem )
190 : : )
191 : : )
192 : : {
193 : : // am Dokument sichern:
194 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
195 [ # # ]: 0 : if ( pDocSh )
196 : : {
197 : 0 : LanguageType eLanguage = ( (SvxLanguageItem*)pItem )->GetValue();
198 [ # # ]: 0 : SdDrawDocument* pDoc = pDocSh->GetDoc();
199 : :
200 [ # # ]: 0 : if( nSlotId == SID_ATTR_CHAR_CJK_LANGUAGE )
201 [ # # ]: 0 : pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE_CJK );
202 [ # # ]: 0 : else if( nSlotId == SID_ATTR_CHAR_CTL_LANGUAGE )
203 [ # # ]: 0 : pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE_CTL );
204 : : else
205 [ # # ]: 0 : pDoc->SetLanguage( eLanguage, EE_CHAR_LANGUAGE );
206 : :
207 [ # # ]: 0 : if( pDoc->GetOnlineSpell() )
208 : : {
209 [ # # ]: 0 : pDoc->StopOnlineSpelling();
210 [ # # ]: 0 : pDoc->StartOnlineSpelling();
211 : : }
212 : : }
213 : : }
214 : : }
215 : 0 : break;
216 : :
217 : : case SID_SD_AUTOPILOT:
218 : : case SID_NEWSD:
219 : : {
220 : 0 : SfxFrame* pFrame = ExecuteNewDocument( rReq );
221 : : // if a frame was created, set it as return value
222 [ # # ]: 0 : if(pFrame)
223 [ # # ]: 0 : rReq.SetReturnValue(SfxFrameItem(0, pFrame));
224 : : }
225 : :
226 : 0 : break;
227 : :
228 : : case SID_OPENHYPERLINK:
229 : : case SID_OPENDOC:
230 : : {
231 : 0 : sal_Bool bIntercept = sal_False;
232 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
233 [ # # ]: 0 : if (pDocShell)
234 : : {
235 : 0 : ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
236 [ # # ]: 0 : if (pViewShell)
237 : : {
238 [ # # ]: 0 : if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) )
239 : : {
240 : : // Prevent documents from opening while the slide
241 : : // show is running, except when this request comes
242 : : // from a shape interaction.
243 [ # # ]: 0 : if (rReq.GetArgs() == NULL)
244 : : {
245 : 0 : bIntercept = sal_True;
246 : : }
247 : : }
248 : : }
249 : : }
250 : :
251 [ # # ]: 0 : if (!bIntercept)
252 : : {
253 : 0 : SFX_APP()->ExecuteSlot(rReq, SFX_APP()->GetInterface());
254 : : }
255 : : else
256 : : {
257 [ # # ][ # # ]: 0 : ErrorBox(NULL, WB_OK, String(SdResId(STR_CANT_PERFORM_IN_LIVEMODE))).Execute();
[ # # ][ # # ]
[ # # ]
258 : :
259 : 0 : SFX_REQUEST_ARG( rReq, pLinkItem, SfxLinkItem, SID_DONELINK, sal_False );
260 [ # # ]: 0 : if( pLinkItem )
261 : 0 : pLinkItem->GetValue().Call( 0 );
262 : : }
263 : : }
264 : 0 : break;
265 : :
266 : : case SID_OUTLINE_TO_IMPRESS:
267 : 0 : OutlineToImpress (rReq);
268 : 0 : break;
269 : :
270 : : default:
271 : 0 : break;
272 : : }
273 : 0 : }
274 : :
275 : :
276 : :
277 : :
278 : 0 : void SdModule::OutlineToImpress (SfxRequest& rRequest)
279 : : {
280 : 0 : const SfxItemSet* pSet = rRequest.GetArgs();
281 : :
282 [ # # ]: 0 : if (pSet)
283 : : {
284 : 0 : SvLockBytes* pBytes = ((SfxLockBytesItem&) pSet->Get(SID_OUTLINE_TO_IMPRESS)).GetValue();
285 : :
286 [ # # ]: 0 : if (pBytes)
287 : : {
288 : 0 : SfxObjectShellLock xDocShell;
289 : : ::sd::DrawDocShell* pDocSh;
290 : : xDocShell = pDocSh = new ::sd::DrawDocShell(
291 [ # # ][ # # ]: 0 : SFX_CREATE_MODE_STANDARD, sal_False);
[ # # ]
292 [ # # ]: 0 : if(pDocSh)
293 : : {
294 [ # # ]: 0 : pDocSh->DoInitNew(NULL);
295 [ # # ]: 0 : SdDrawDocument* pDoc = pDocSh->GetDoc();
296 [ # # ]: 0 : if(pDoc)
297 : : {
298 [ # # ]: 0 : pDoc->CreateFirstPages();
299 [ # # ]: 0 : pDoc->StopWorkStartupDelay();
300 : : }
301 : :
302 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rRequest, pFrmItem, SfxFrameItem, SID_DOCFRAME, sal_False);
303 [ # # ]: 0 : SfxViewFrame::LoadDocumentIntoFrame( *pDocSh, pFrmItem, ::sd::OUTLINE_FACTORY_ID );
304 : :
305 : 0 : ::sd::ViewShell* pViewSh = pDocSh->GetViewShell();
306 : :
307 [ # # ]: 0 : if (pViewSh)
308 : : {
309 : : // AutoLayouts muessen fertig sein
310 [ # # ]: 0 : pDoc->StopWorkStartupDelay();
311 : :
312 [ # # ]: 0 : SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
313 : :
314 : : // When the view frame has not been just created we have
315 : : // to switch synchronously to the outline view.
316 : : // (Otherwise the request will be ignored anyway.)
317 : : ::sd::ViewShellBase* pBase
318 [ # # ][ # # ]: 0 : = dynamic_cast< ::sd::ViewShellBase*>(pViewFrame->GetViewShell());
319 [ # # ]: 0 : if (pBase != NULL)
320 : : {
321 : : ::boost::shared_ptr<FrameworkHelper> pHelper (
322 [ # # ]: 0 : FrameworkHelper::Instance(*pBase));
323 : : pHelper->RequestView(
324 : : FrameworkHelper::msOutlineViewURL,
325 [ # # ]: 0 : FrameworkHelper::msCenterPaneURL);
326 : :
327 : : pHelper->RunOnResourceActivation(
328 : : FrameworkHelper::CreateResourceId(
329 : : FrameworkHelper::msOutlineViewURL,
330 : : FrameworkHelper::msCenterPaneURL),
331 [ # # ][ # # ]: 0 : OutlineToImpressFinalizer(*pBase, *pDoc, *pBytes));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
332 : : }
333 : : }
334 [ # # ]: 0 : }
335 : : }
336 : : }
337 : :
338 : 0 : rRequest.IsDone();
339 : 0 : }
340 : :
341 : :
342 : :
343 : :
344 : : /*************************************************************************
345 : : |*
346 : : |* GetState
347 : : |*
348 : : \************************************************************************/
349 : :
350 : : static bool bOnce = false;
351 : :
352 : 448 : void SdModule::GetState(SfxItemSet& rItemSet)
353 : : {
354 : : // Autopilot waehrend der Praesentation disablen
355 [ - + ]: 448 : if (rItemSet.GetItemState(SID_SD_AUTOPILOT) != SFX_ITEM_UNKNOWN)
356 : : {
357 [ # # ][ # # ]: 0 : if (!SvtModuleOptions().IsImpress())
358 : : {
359 : 0 : rItemSet.DisableItem(SID_SD_AUTOPILOT);
360 : : }
361 : : else
362 : : {
363 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
364 [ # # ]: 0 : if (pDocShell)
365 : : {
366 : 0 : ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
367 [ # # ]: 0 : if (pViewShell)
368 : : {
369 [ # # ]: 0 : if( sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ) )
370 : : {
371 : 0 : rItemSet.DisableItem(SID_SD_AUTOPILOT);
372 : : }
373 : : }
374 : : }
375 : : }
376 : : }
377 : :
378 [ + + ]: 448 : if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_METRIC ) )
379 : : {
380 [ + - ][ + - ]: 169 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
381 [ + - ]: 169 : if(pDocSh)
382 : : {
383 : 169 : DocumentType eDocType = pDocSh->GetDoc()->GetDocumentType();
384 : :
385 : 169 : SdOptions* pOptions = GetSdOptions(eDocType);
386 [ + - ]: 169 : rItemSet.Put( SfxUInt16Item( SID_ATTR_METRIC, pOptions->GetMetric() ) );
387 : : }
388 : : }
389 : :
390 : : // der Status von SID_OPENDOC wird von der Basisklasse bestimmt
391 [ + + ]: 448 : if (rItemSet.GetItemState(SID_OPENDOC) != SFX_ITEM_UNKNOWN)
392 : : {
393 : 219 : const SfxPoolItem* pItem = SFX_APP()->GetSlotState(SID_OPENDOC, SFX_APP()->GetInterface());
394 [ + - ]: 219 : if (pItem)
395 : 219 : rItemSet.Put(*pItem);
396 : : }
397 : :
398 : : // der Status von SID_OPENHYPERLINK wird von der Basisklasse bestimmt
399 [ - + ]: 448 : if (rItemSet.GetItemState(SID_OPENHYPERLINK) != SFX_ITEM_UNKNOWN)
400 : : {
401 : 0 : const SfxPoolItem* pItem = SFX_APP()->GetSlotState(SID_OPENHYPERLINK, SFX_APP()->GetInterface());
402 [ # # ]: 0 : if (pItem)
403 : 0 : rItemSet.Put(*pItem);
404 : : }
405 : :
406 [ - + ]: 448 : if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_AUTOSPELL_CHECK ) )
407 : : {
408 : : ::sd::DrawDocShell* pDocSh =
409 [ # # ][ # # ]: 0 : PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
410 [ # # ]: 0 : if( pDocSh )
411 : : {
412 : 0 : SdDrawDocument* pDoc = pDocSh->GetDoc();
413 [ # # ]: 0 : rItemSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, pDoc->GetOnlineSpell() ) );
414 : : }
415 : : }
416 : :
417 [ - + ]: 448 : if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_LANGUAGE ) )
418 : : {
419 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
420 [ # # ]: 0 : if( pDocSh )
421 [ # # ]: 0 : rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE ), SID_ATTR_LANGUAGE ) );
422 : : }
423 : :
424 [ - + ]: 448 : if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE ) )
425 : : {
426 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
427 [ # # ]: 0 : if( pDocSh )
428 [ # # ]: 0 : rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CJK ), SID_ATTR_CHAR_CJK_LANGUAGE ) );
429 : : }
430 : :
431 [ - + ]: 448 : if( SFX_ITEM_AVAILABLE == rItemSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE ) )
432 : : {
433 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
434 [ # # ]: 0 : if( pDocSh )
435 [ # # ]: 0 : rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CTL ), SID_ATTR_CHAR_CTL_LANGUAGE ) );
436 : : }
437 : :
438 [ + + ]: 448 : if ( !bOnce )
439 : : {
440 [ + - ][ + - ]: 351 : ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
441 [ + - ]: 351 : if( pDocShell ) // Impress or Draw ?
442 : : {
443 : 351 : ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
444 : :
445 [ + + ][ + + ]: 351 : if( pViewShell && (pDocShell->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) )
[ + - ]
446 : : {
447 : : // add our event listener as soon as possible
448 [ + - ]: 8 : Application::AddEventListener( LINK( this, SdModule, EventListenerHdl ) );
449 : 8 : bOnce = true;
450 : : }
451 : : }
452 : : }
453 : 448 : }
454 : :
455 : 77878 : IMPL_LINK( SdModule, EventListenerHdl, VclSimpleEvent*, pEvent )
456 : : {
457 [ + - ][ - + ]: 77878 : if( pEvent && (pEvent->GetId() == VCLEVENT_WINDOW_COMMAND) && static_cast<VclWindowEvent*>(pEvent)->GetData() )
[ # # ][ - + ]
458 : : {
459 : 0 : const CommandEvent& rEvent = *(const CommandEvent*)static_cast<VclWindowEvent*>(pEvent)->GetData();
460 : :
461 [ # # ]: 0 : if( rEvent.GetCommand() == COMMAND_MEDIA )
462 : : {
463 [ # # ]: 0 : switch( rEvent.GetMediaCommand() )
464 : : {
465 : : case MEDIA_COMMAND_PLAY:
466 : : {
467 [ # # ][ # # ]: 0 : ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
468 [ # # ]: 0 : if( pDocShell ) // Impress or Draw ?
469 : : {
470 : 0 : ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
471 : :
472 : : // #i97925# start the presentation if and only if an Impress document is focused
473 [ # # ][ # # ]: 0 : if( pViewShell && (pDocShell->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) )
[ # # ]
474 : 0 : pViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION );
475 : : }
476 : : }
477 : 0 : break;
478 : :
479 : : default:
480 : 0 : break;
481 : : }
482 : : }
483 : : }
484 : 77878 : return 0;
485 : : }
486 : :
487 : :
488 : 0 : void SdModule::AddSummaryPage (SfxViewFrame* pViewFrame, SdDrawDocument* pDocument)
489 : : {
490 [ # # ][ # # ]: 0 : if( !pViewFrame || !pViewFrame->GetDispatcher() || !pDocument )
[ # # ][ # # ]
491 : 0 : return;
492 : :
493 : : pViewFrame->GetDispatcher()->Execute(SID_SUMMARY_PAGE,
494 : 0 : SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
495 : :
496 : : OSL_ASSERT (pDocument!=NULL);
497 : :
498 : 0 : sal_Int32 nPageCount = pDocument->GetSdPageCount (PK_STANDARD);
499 : :
500 : : // We need at least two pages: the summary page and one to use as
501 : : // template to take the transition parameters from.
502 [ # # ]: 0 : if (nPageCount >= 2)
503 : : {
504 : : // Get a page from which to retrieve the transition parameters.
505 : 0 : SdPage* pTemplatePage = pDocument->GetSdPage (0, PK_STANDARD);
506 : : OSL_ASSERT (pTemplatePage!=NULL);
507 : :
508 : : // The summary page, if it exists, is the last page.
509 : : SdPage* pSummaryPage = pDocument->GetSdPage (
510 : 0 : (sal_uInt16)nPageCount-1, PK_STANDARD);
511 : : OSL_ASSERT (pSummaryPage!=NULL);
512 : :
513 : : // Take the change mode of the template page as indication of the
514 : : // document's kiosk mode.
515 : 0 : pSummaryPage->setTransitionDuration(pTemplatePage->getTransitionDuration());
516 : 0 : pSummaryPage->SetPresChange(pTemplatePage->GetPresChange());
517 : 0 : pSummaryPage->SetTime(pTemplatePage->GetTime());
518 : 0 : pSummaryPage->SetSound(pTemplatePage->IsSoundOn());
519 [ # # ]: 0 : pSummaryPage->SetSoundFile(pTemplatePage->GetSoundFile());
520 : 0 : pSummaryPage->setTransitionType(pTemplatePage->getTransitionType());
521 : 0 : pSummaryPage->setTransitionSubtype(pTemplatePage->getTransitionSubtype());
522 : 0 : pSummaryPage->setTransitionDirection(pTemplatePage->getTransitionDirection());
523 : 0 : pSummaryPage->setTransitionFadeColor(pTemplatePage->getTransitionFadeColor());
524 : 0 : pSummaryPage->setTransitionDuration(pTemplatePage->getTransitionDuration());
525 : : }
526 : : }
527 : :
528 : 0 : SfxFrame* SdModule::CreateFromTemplate( const String& rTemplatePath, const Reference< XFrame >& i_rFrame )
529 : : {
530 : 0 : SfxFrame* pFrame = 0;
531 : :
532 : 0 : SfxObjectShellLock xDocShell;
533 : :
534 [ # # ][ # # ]: 0 : SfxItemSet* pSet = new SfxAllItemSet( SFX_APP()->GetPool() );
[ # # ]
535 [ # # ][ # # ]: 0 : pSet->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) );
[ # # ]
536 : :
537 [ # # ][ # # ]: 0 : sal_uLong lErr = SFX_APP()->LoadTemplate( xDocShell, rTemplatePath, sal_True, pSet );
538 : :
539 : 0 : SfxObjectShell* pDocShell = xDocShell;
540 : :
541 [ # # ]: 0 : if( lErr )
542 : : {
543 [ # # ]: 0 : ErrorHandler::HandleError(lErr);
544 : : }
545 [ # # ]: 0 : else if( pDocShell )
546 : : {
547 [ # # ]: 0 : SfxViewFrame* pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pDocShell, i_rFrame );
548 : : OSL_ENSURE( pViewFrame, "SdModule::CreateFromTemplate: no view frame - was the document really loaded?" );
549 [ # # ][ # # ]: 0 : pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL;
550 : : }
551 : :
552 [ # # ]: 0 : return pFrame;
553 : :
554 : : }
555 : :
556 : 0 : SfxFrame* SdModule::ExecuteNewDocument( SfxRequest& rReq )
557 : : {
558 : 0 : SfxFrame* pFrame = 0;
559 [ # # ][ # # ]: 0 : if ( SvtModuleOptions().IsImpress() )
560 : : {
561 : 0 : Reference< XFrame > xTargetFrame;
562 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pFrmItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False);
563 [ # # ]: 0 : if ( pFrmItem )
564 [ # # ]: 0 : xTargetFrame = pFrmItem->GetFrame();
565 : :
566 : 0 : bool bMakeLayoutVisible = false;
567 : 0 : SfxViewFrame* pViewFrame = NULL;
568 : :
569 [ # # ]: 0 : SdOptions* pOpt = GetSdOptions(DOCUMENT_TYPE_IMPRESS);
570 [ # # ]: 0 : bool bStartWithTemplate = pOpt->IsStartWithTemplate();
571 : :
572 : 0 : bool bNewDocDirect = rReq.GetSlot() == SID_NEWSD;
573 [ # # ][ # # ]: 0 : if( bNewDocDirect && !bStartWithTemplate )
574 : : {
575 : : //we start without wizard
576 : :
577 : : //check whether we should load a template document
578 : 0 : const ::rtl::OUString aServiceName( "com.sun.star.presentation.PresentationDocument" );
579 [ # # ][ # # ]: 0 : String aStandardTemplate( SfxObjectFactory::GetStandardTemplate( aServiceName ) );
[ # # ]
580 : :
581 [ # # ]: 0 : if( aStandardTemplate.Len() > 0 )
582 : : {
583 : : //load a template document
584 [ # # ]: 0 : pFrame = CreateFromTemplate( aStandardTemplate, xTargetFrame );
585 : : }
586 : : else
587 : : {
588 : : //create an empty document
589 [ # # ]: 0 : pFrame = CreateEmptyDocument( DOCUMENT_TYPE_IMPRESS, xTargetFrame );
590 : 0 : bMakeLayoutVisible = true;
591 [ # # ]: 0 : }
592 : : }
593 : : else
594 : : {
595 [ # # ]: 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
596 [ # # ][ # # ]: 0 : boost::scoped_ptr< AbstractAssistentDlg > pPilotDlg( pFact ? pFact->CreateAssistentDlg( NULL, !bNewDocDirect ) : 0 );
597 : :
598 : : // Open the Pilot
599 [ # # ][ # # ]: 0 : if( pPilotDlg.get() && pPilotDlg->Execute()==RET_OK )
[ # # ][ # # ]
600 : : {
601 [ # # ]: 0 : const String aDocPath( pPilotDlg->GetDocPath());
602 [ # # ]: 0 : const sal_Bool bIsDocEmpty = pPilotDlg->IsDocEmpty();
603 : :
604 : : // So that you can open the document without AutoLayout-Dialog
605 [ # # ]: 0 : pOpt->SetStartWithTemplate(sal_False);
606 [ # # ][ # # ]: 0 : if(bNewDocDirect && !pPilotDlg->GetStartWithFlag())
[ # # ][ # # ]
607 : 0 : bStartWithTemplate = sal_False;
608 : :
609 [ # # ][ # # ]: 0 : if( pPilotDlg->GetStartType() == ST_OPEN )
610 : : {
611 [ # # ]: 0 : String aFileToOpen = aDocPath;
612 : :
613 : : DBG_ASSERT( aFileToOpen.Len()!=0, "The autopilot should have asked for a file itself already!" );
614 [ # # ]: 0 : if(aFileToOpen.Len() != 0)
615 : : {
616 [ # # ]: 0 : com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > aPasswrd( pPilotDlg->GetPassword() );
617 : :
618 [ # # ]: 0 : SfxStringItem aFile( SID_FILE_NAME, aFileToOpen );
619 [ # # ][ # # ]: 0 : SfxStringItem aReferer( SID_REFERER, rtl::OUString());
[ # # ]
620 [ # # ][ # # ]: 0 : SfxUnoAnyItem aPassword( SID_ENCRYPTIONDATA, com::sun::star::uno::makeAny(aPasswrd) );
621 : :
622 [ # # ]: 0 : if ( xTargetFrame.is() )
623 : : {
624 [ # # ]: 0 : SfxAllItemSet aSet( *rReq.GetArgs()->GetPool() );
625 [ # # ]: 0 : aSet.Put( aFile );
626 [ # # ]: 0 : aSet.Put( aReferer );
627 : : // Put the password into the request
628 : : // only if it is not empty.
629 [ # # ]: 0 : if (aPasswrd.getLength() > 0)
630 [ # # ]: 0 : aSet.Put( aPassword );
631 : :
632 [ # # ]: 0 : const SfxPoolItem* pRet = SfxFrame::OpenDocumentSynchron( aSet, xTargetFrame );
633 [ # # ][ # # ]: 0 : const SfxViewFrameItem* pFrameItem = PTR_CAST( SfxViewFrameItem, pRet );
[ # # ][ # # ]
634 [ # # ][ # # ]: 0 : if ( pFrameItem && pFrameItem->GetFrame() )
[ # # ]
635 [ # # ][ # # ]: 0 : pFrame = &pFrameItem->GetFrame()->GetFrame();
636 : : }
637 : : else
638 : : {
639 [ # # ][ # # ]: 0 : SfxRequest aRequest (SID_OPENDOC, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool());
640 [ # # ]: 0 : aRequest.AppendItem (aFile);
641 [ # # ]: 0 : aRequest.AppendItem (aReferer);
642 : : // Put the password into the request
643 : : // only if it is not empty.
644 [ # # ]: 0 : if (aPasswrd.getLength() > 0)
645 [ # # ]: 0 : aRequest.AppendItem (aPassword);
646 : : aRequest.AppendItem (SfxStringItem (
647 : : SID_TARGETNAME,
648 [ # # ][ # # ]: 0 : rtl::OUString("_default")));
[ # # ][ # # ]
[ # # ][ # # ]
649 : : try
650 : : {
651 [ # # ][ # # ]: 0 : const SfxPoolItem* pRet = SFX_APP()->ExecuteSlot (aRequest);
652 [ # # ][ # # ]: 0 : const SfxViewFrameItem* pFrameItem = PTR_CAST( SfxViewFrameItem, pRet );
[ # # ][ # # ]
653 [ # # ]: 0 : if ( pFrameItem )
654 [ # # ]: 0 : pFrame = &pFrameItem->GetFrame()->GetFrame();
655 : : }
656 [ # # ]: 0 : catch (const ::com::sun::star::uno::Exception&)
657 : : {
658 : : DBG_ASSERT (sal_False, "caught IllegalArgumentException while loading document from Impress autopilot");
659 [ # # ]: 0 : }
660 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
661 : : }
662 : :
663 [ # # ]: 0 : pOpt->SetStartWithTemplate(bStartWithTemplate);
664 [ # # ][ # # ]: 0 : if(bNewDocDirect && !bStartWithTemplate)
665 : : {
666 [ # # ]: 0 : boost::scoped_ptr< SfxItemSet > pRet( CreateItemSet( SID_SD_EDITOPTIONS ) );
667 [ # # ]: 0 : if(pRet.get())
668 [ # # ][ # # ]: 0 : ApplyItemSet( SID_SD_EDITOPTIONS, *pRet.get() );
669 : :
670 [ # # ]: 0 : }
671 : : }
672 : : else
673 : : {
674 [ # # ]: 0 : SfxObjectShellLock xShell( pPilotDlg->GetDocument() );
675 : 0 : SfxObjectShell* pShell = xShell;
676 [ # # ]: 0 : if( pShell )
677 : : {
678 [ # # ]: 0 : pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pShell, xTargetFrame );
679 : : DBG_ASSERT( pViewFrame, "no ViewFrame!!" );
680 [ # # ][ # # ]: 0 : pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL;
681 : :
682 [ # # ][ # # ]: 0 : if(bNewDocDirect && !bStartWithTemplate)
683 : : {
684 [ # # ]: 0 : boost::scoped_ptr< SfxItemSet > pRet( CreateItemSet( SID_SD_EDITOPTIONS ) );
685 [ # # ]: 0 : if(pRet.get())
686 [ # # ][ # # ]: 0 : ApplyItemSet( SID_SD_EDITOPTIONS, *pRet.get() );
687 : : }
688 : :
689 [ # # ][ # # ]: 0 : if( pShell && pViewFrame )
690 : : {
691 : : ::sd::DrawDocShell* pDocShell =
692 [ # # ][ # # ]: 0 : PTR_CAST(::sd::DrawDocShell,pShell);
[ # # ][ # # ]
693 [ # # ]: 0 : SdDrawDocument* pDoc = pDocShell->GetDoc();
694 : :
695 : : ::sd::ViewShellBase* pBase =
696 : : ::sd::ViewShellBase::GetViewShellBase (
697 [ # # ]: 0 : pViewFrame);
698 : : OSL_ASSERT (pBase!=NULL);
699 [ # # ]: 0 : ::boost::shared_ptr<sd::ViewShell> pViewSh = pBase->GetMainViewShell();
700 [ # # ]: 0 : SdOptions* pOptions = GetSdOptions(pDoc->GetDocumentType());
701 : :
702 [ # # ][ # # ]: 0 : if (pOptions && pViewSh.get())
[ # # ]
703 : : {
704 : : // The AutoPilot-document shall be open without its own options
705 [ # # ]: 0 : ::sd::FrameView* pFrameView = pViewSh->GetFrameView();
706 [ # # ]: 0 : pFrameView->Update(pOptions);
707 [ # # ]: 0 : pViewSh->ReadFrameViewData(pFrameView);
708 : : }
709 : :
710 [ # # ][ # # ]: 0 : ChangeMedium( pDocShell, pViewFrame, pPilotDlg->GetOutputMedium() );
711 : :
712 [ # # ][ # # ]: 0 : if(pPilotDlg->IsSummary())
713 [ # # ]: 0 : AddSummaryPage(pViewFrame, pDoc);
714 : :
715 : : // empty document
716 [ # # ][ # # ]: 0 : if((aDocPath.Len() == 0) && pViewFrame && pViewFrame->GetDispatcher())
[ # # ][ # # ]
717 : : {
718 [ # # ]: 0 : SfxBoolItem aIsChangedItem(SID_MODIFYPAGE, !bIsDocEmpty);
719 [ # # ]: 0 : SfxUInt32Item eAutoLayout( ID_VAL_WHATLAYOUT, (sal_uInt32) AUTOLAYOUT_TITLE );
720 : : pViewFrame->GetDispatcher()->Execute(SID_MODIFYPAGE,
721 [ # # ][ # # ]: 0 : SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aIsChangedItem, &eAutoLayout, 0L);
[ # # ]
722 : : }
723 : :
724 : : // clear document info
725 : : using namespace ::com::sun::star;
726 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
727 [ # # ][ # # ]: 0 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
728 : : uno::Reference<document::XDocumentProperties>
729 [ # # ][ # # ]: 0 : xDocProps(xDPS->getDocumentProperties());
730 : : DBG_ASSERT(xDocProps.is(), "no DocumentProperties");
731 [ # # ]: 0 : xDocProps->resetUserData(
732 [ # # ][ # # ]: 0 : SvtUserOptions().GetFullName() );
[ # # ][ # # ]
733 [ # # ][ # # ]: 0 : xDocProps->setTemplateName(xDocProps->getTitle());
[ # # ][ # # ]
734 [ # # ][ # # ]: 0 : xDocProps->setTemplateURL(pPilotDlg->GetDocPath());
[ # # ][ # # ]
[ # # ]
735 : :
736 [ # # ]: 0 : pDoc->SetChanged(!bIsDocEmpty);
737 : :
738 [ # # ]: 0 : pDocShell->SetUseUserData(sal_True);
739 : :
740 : : // clear UNDO stack after autopilot
741 [ # # ]: 0 : pDocShell->ClearUndoBuffer();
742 : :
743 [ # # ]: 0 : bMakeLayoutVisible = true;
744 : : }
745 : : }
746 [ # # ][ # # ]: 0 : pOpt->SetStartWithTemplate(bStartWithTemplate);
747 [ # # ]: 0 : }
748 [ # # ]: 0 : }
749 : : }
750 : :
751 [ # # ][ # # ]: 0 : if (bMakeLayoutVisible && pViewFrame!=NULL)
752 : : {
753 : : // Make the layout menu visible in the tool pane.
754 [ # # ]: 0 : ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase(pViewFrame);
755 [ # # ]: 0 : if (pBase != NULL)
756 : : {
757 : : FrameworkHelper::Instance(*pBase)->RequestTaskPanel(
758 [ # # ][ # # ]: 0 : FrameworkHelper::msLayoutTaskPanelURL);
[ # # ]
759 : : }
760 : 0 : }
761 : : }
762 : :
763 : 0 : return pFrame;
764 : : }
765 : :
766 : 0 : SfxFrame* SdModule::CreateEmptyDocument( DocumentType eDocType, const Reference< XFrame >& i_rFrame )
767 : : {
768 : 0 : SfxFrame* pFrame = 0;
769 : :
770 : 0 : SfxObjectShellLock xDocShell;
771 : : ::sd::DrawDocShell* pNewDocSh;
772 [ # # ][ # # ]: 0 : xDocShell = pNewDocSh = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD,sal_False,eDocType);
[ # # ]
773 [ # # ]: 0 : if(pNewDocSh)
774 : : {
775 [ # # ]: 0 : pNewDocSh->DoInitNew(NULL);
776 [ # # ]: 0 : SdDrawDocument* pDoc = pNewDocSh->GetDoc();
777 [ # # ]: 0 : if(pDoc)
778 : : {
779 [ # # ]: 0 : pDoc->CreateFirstPages();
780 [ # # ]: 0 : pDoc->StopWorkStartupDelay();
781 : : }
782 : :
783 [ # # ]: 0 : SfxViewFrame* pViewFrame = SfxViewFrame::LoadDocumentIntoFrame( *pNewDocSh, i_rFrame );
784 : : OSL_ENSURE( pViewFrame, "SdModule::CreateEmptyDocument: no view frame - was the document really loaded?" );
785 [ # # ][ # # ]: 0 : pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL;
786 : : }
787 : :
788 [ # # ]: 0 : return pFrame;
789 : : }
790 : :
791 : 0 : void SdModule::ChangeMedium( ::sd::DrawDocShell* pDocShell, SfxViewFrame* pViewFrame, const sal_Int32 eMedium )
792 : : {
793 [ # # ]: 0 : if( !pDocShell )
794 : : return;
795 : :
796 [ # # ]: 0 : SdDrawDocument* pDoc = pDocShell->GetDoc();
797 [ # # ]: 0 : if( !pDoc )
798 : : return;
799 : :
800 : : // settings for the Outputmedium
801 : 0 : Size aNewSize;
802 : 0 : sal_uInt32 nLeft = 0;
803 : 0 : sal_uInt32 nRight = 0;
804 : 0 : sal_uInt32 nLower = 0;
805 : 0 : sal_uInt32 nUpper = 0;
806 [ # # # # : 0 : switch(eMedium)
# ]
807 : : {
808 : : case OUTPUT_PAGE:
809 : : case OUTPUT_OVERHEAD:
810 : : {
811 [ # # ]: 0 : SfxPrinter* pPrinter = pDocShell->GetPrinter(sal_True);
812 : :
813 [ # # ][ # # ]: 0 : if( pPrinter && pPrinter->IsValid())
[ # # ]
814 : : {
815 : : // Der Printer gibt leider kein exaktes
816 : : // Format (z.B. A4) zurueck
817 [ # # ]: 0 : Size aSize(pPrinter->GetPaperSize());
818 [ # # ]: 0 : Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, MAP_100TH_MM, sal_True);
819 : :
820 [ # # ]: 0 : if (ePaper != PAPER_USER)
821 : : {
822 : : // Korrekte Size holen
823 [ # # ]: 0 : aSize = SvxPaperInfo::GetPaperSize(ePaper, MAP_100TH_MM);
824 : : }
825 : :
826 [ # # ]: 0 : if (aSize.Height() > aSize.Width())
827 : : {
828 : : // Stets Querformat
829 : 0 : aNewSize.Width() = aSize.Height();
830 : 0 : aNewSize.Height() = aSize.Width();
831 : : }
832 : : else
833 : : {
834 : 0 : aNewSize = aSize;
835 : : }
836 : : }
837 : : else
838 : : {
839 : 0 : aNewSize=Size(29700, 21000);
840 : : }
841 : :
842 [ # # ]: 0 : if (eMedium == OUTPUT_PAGE)
843 : : {
844 : 0 : nLeft =1000;
845 : 0 : nRight=1000;
846 : 0 : nUpper=1000;
847 : 0 : nLower=1000;
848 : : }
849 : : else
850 : : {
851 : 0 : nLeft =0;
852 : 0 : nRight=0;
853 : 0 : nUpper=0;
854 : 0 : nLower=0;
855 : : }
856 : : }
857 : 0 : break;
858 : :
859 : : case OUTPUT_SLIDE:
860 : : {
861 : 0 : aNewSize = Size(27000, 18000);
862 : 0 : nLeft =0;
863 : 0 : nRight=0;
864 : 0 : nUpper=0;
865 : 0 : nLower=0;
866 : : }
867 : 0 : break;
868 : :
869 : : case OUTPUT_WIDESCREEN:
870 : : {
871 : 0 : aNewSize = Size(28000, 15750);
872 : 0 : nLeft =0;
873 : 0 : nRight=0;
874 : 0 : nUpper=0;
875 : 0 : nLower=0;
876 : : }
877 : 0 : break;
878 : :
879 : : case OUTPUT_PRESENTATION:
880 : : {
881 : 0 : aNewSize = Size(28000, 21000);
882 : 0 : nLeft =0;
883 : 0 : nRight=0;
884 : 0 : nUpper=0;
885 : 0 : nLower=0;
886 : : }
887 : 0 : break;
888 : : }
889 : :
890 : 0 : sal_Bool bScaleAll = sal_True;
891 [ # # ]: 0 : sal_uInt16 nPageCnt = pDoc->GetMasterSdPageCount(PK_STANDARD);
892 : : sal_uInt16 i;
893 : : SdPage* pPage;
894 : :
895 : : // master pages first
896 [ # # ]: 0 : for (i = 0; i < nPageCnt; i++)
897 : : {
898 [ # # ]: 0 : pPage = pDoc->GetMasterSdPage(i, PK_STANDARD);
899 : :
900 [ # # ]: 0 : if (pPage)
901 : : {
902 [ # # ]: 0 : if(eMedium != OUTPUT_ORIGINAL)
903 : : {
904 [ # # ]: 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
905 [ # # ]: 0 : pPage->ScaleObjects(aNewSize, aBorderRect, bScaleAll);
906 [ # # ]: 0 : pPage->SetSize(aNewSize);
907 [ # # ]: 0 : pPage->SetBorder(nLeft, nUpper, nRight, nLower);
908 : : }
909 [ # # ]: 0 : SdPage* pNotesPage = pDoc->GetMasterSdPage(i, PK_NOTES);
910 : : DBG_ASSERT( pNotesPage, "Wrong page ordering!" );
911 [ # # ][ # # ]: 0 : if( pNotesPage ) pNotesPage->CreateTitleAndLayout();
912 [ # # ]: 0 : pPage->CreateTitleAndLayout();
913 : : }
914 : : }
915 : :
916 [ # # ]: 0 : nPageCnt = pDoc->GetSdPageCount(PK_STANDARD);
917 : :
918 : : // then slides
919 [ # # ]: 0 : for (i = 0; i < nPageCnt; i++)
920 : : {
921 [ # # ]: 0 : pPage = pDoc->GetSdPage(i, PK_STANDARD);
922 : :
923 [ # # ]: 0 : if (pPage)
924 : : {
925 [ # # ]: 0 : if(eMedium != OUTPUT_ORIGINAL)
926 : : {
927 [ # # ]: 0 : Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
928 [ # # ]: 0 : pPage->ScaleObjects(aNewSize, aBorderRect, bScaleAll);
929 [ # # ]: 0 : pPage->SetSize(aNewSize);
930 [ # # ]: 0 : pPage->SetBorder(nLeft, nUpper, nRight, nLower);
931 : : }
932 [ # # ]: 0 : SdPage* pNotesPage = pDoc->GetSdPage(i, PK_NOTES);
933 : : DBG_ASSERT( pNotesPage, "Wrong page ordering!" );
934 [ # # ][ # # ]: 0 : if( pNotesPage ) pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
935 [ # # ]: 0 : pPage->SetAutoLayout( pPage->GetAutoLayout() );
936 : : }
937 : : }
938 : :
939 [ # # ]: 0 : SdPage* pHandoutPage = pDoc->GetSdPage(0, PK_HANDOUT);
940 [ # # ]: 0 : pHandoutPage->CreateTitleAndLayout(sal_True);
941 : :
942 [ # # ][ # # ]: 0 : if( (eMedium != OUTPUT_ORIGINAL) && pViewFrame && pViewFrame->GetDispatcher())
[ # # ][ # # ]
943 : : {
944 [ # # ]: 0 : pViewFrame->GetDispatcher()->Execute(SID_SIZE_PAGE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
945 : : }
946 : : }
947 : :
948 : :
949 : :
950 : :
951 : : //===== OutlineToImpressFinalize ==============================================
952 : :
953 : : namespace {
954 : :
955 : 0 : OutlineToImpressFinalizer::OutlineToImpressFinalizer (
956 : : ::sd::ViewShellBase& rBase,
957 : : SdDrawDocument& rDocument,
958 : : SvLockBytes& rBytes)
959 : : : mrBase(rBase),
960 : : mrDocument(rDocument),
961 : 0 : mpStream()
962 : : {
963 : : // The given stream has a lifetime shorter than this new
964 : : // OutlineToImpressFinalizer object. Therefore a local copy of the
965 : : // stream is created.
966 [ # # ]: 0 : const SvStream* pStream (rBytes.GetStream());
967 [ # # ]: 0 : if (pStream != NULL)
968 : : {
969 : : // Create a memory stream and prepare to fill it with the content of
970 : : // the original stream.
971 [ # # ][ # # ]: 0 : mpStream.reset(new SvMemoryStream());
[ # # ]
972 : : static const sal_Size nBufferSize = 4096;
973 [ # # ]: 0 : ::boost::scoped_array<sal_Int8> pBuffer (new sal_Int8[nBufferSize]);
974 : :
975 : 0 : sal_Size nReadPosition (0);
976 : 0 : bool bLoop (true);
977 [ # # ]: 0 : while (bLoop)
978 : : {
979 : : // Read the next part of the original stream.
980 : 0 : sal_Size nReadByteCount (0);
981 : : const ErrCode nErrorCode (
982 : : rBytes.ReadAt(
983 : : nReadPosition,
984 : 0 : reinterpret_cast<void*>(pBuffer.get()),
985 : : nBufferSize,
986 [ # # ]: 0 : &nReadByteCount));
987 : :
988 : : // Check the error code and stop copying the stream data when an
989 : : // error has occurred.
990 [ # # # ]: 0 : switch (nErrorCode)
991 : : {
992 : : case ERRCODE_NONE:
993 [ # # ]: 0 : if (nReadByteCount == 0)
994 : 0 : bLoop = false;
995 : 0 : break;
996 : : case ERRCODE_IO_PENDING:
997 : 0 : break;
998 : :
999 : : default:
1000 : 0 : bLoop = false;
1001 : 0 : nReadByteCount = 0;
1002 : 0 : break;
1003 : : }
1004 : :
1005 : : // Append the read bytes to the end of the memory stream.
1006 [ # # ]: 0 : if (nReadByteCount > 0)
1007 : : {
1008 [ # # ]: 0 : mpStream->Write(reinterpret_cast<void*>(pBuffer.get()), nReadByteCount);
1009 : 0 : nReadPosition += nReadByteCount;
1010 : : }
1011 : : }
1012 : :
1013 : : // Rewind the memory stream so that in the operator() method its
1014 : : // content is properly read.
1015 [ # # ][ # # ]: 0 : mpStream->Seek(STREAM_SEEK_TO_BEGIN);
1016 : : }
1017 : 0 : }
1018 : :
1019 : :
1020 : :
1021 : :
1022 : 0 : void OutlineToImpressFinalizer::operator() (bool)
1023 : : {
1024 : : // Fetch the new outline view shell.
1025 : : ::sd::OutlineViewShell* pOutlineShell
1026 [ # # ][ # # ]: 0 : = dynamic_cast<sd::OutlineViewShell*>(FrameworkHelper::Instance(mrBase)->GetViewShell(FrameworkHelper::msCenterPaneURL).get());
[ # # ]
1027 : :
1028 [ # # ][ # # ]: 0 : if (pOutlineShell != NULL && mpStream.get() != NULL)
[ # # ]
1029 : : {
1030 : 0 : sd::OutlineView* pView = static_cast<sd::OutlineView*>(pOutlineShell->GetView());
1031 : : // mba: the stream can't contain any relative URLs, because we don't
1032 : : // have any information about a BaseURL!
1033 [ # # ]: 0 : if ( pOutlineShell->Read(*mpStream, String(), EE_FORMAT_RTF) == 0 )
1034 : : {
1035 : : }
1036 : :
1037 : : // Call UpdatePreview once for every slide to resync the
1038 : : // document with the outliner of the OutlineViewShell.
1039 : 0 : sal_uInt16 nPageCount (mrDocument.GetSdPageCount(PK_STANDARD));
1040 [ # # ]: 0 : for (sal_uInt16 nIndex=0; nIndex<nPageCount; nIndex++)
1041 : : {
1042 : 0 : SdPage* pPage = mrDocument.GetSdPage(nIndex, PK_STANDARD);
1043 : : // Make the page the actual page so that the
1044 : : // following UpdatePreview() call accesses the
1045 : : // correct paragraphs.
1046 : 0 : pView->SetActualPage(pPage);
1047 : 0 : pOutlineShell->UpdatePreview(pPage, true);
1048 : : }
1049 : : // Select the first slide.
1050 : 0 : SdPage* pPage = mrDocument.GetSdPage(0, PK_STANDARD);
1051 : 0 : pView->SetActualPage(pPage);
1052 : 0 : pOutlineShell->UpdatePreview(pPage, true);
1053 : : }
1054 : :
1055 : :
1056 : : // Undo-Stack needs to be cleared, else the user may remove the
1057 : : // only drawpage and this is a state we cannot handle ATM.
1058 : 0 : ::sd::DrawDocShell* pDocShell = mrDocument.GetDocSh();
1059 [ # # ]: 0 : if( pDocShell )
1060 : 0 : pDocShell->ClearUndoBuffer();
1061 : 0 : }
1062 : :
1063 : :
1064 : : } // end of anonymous namespace
1065 : :
1066 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|