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