xref: /trunk/main/sd/source/ui/docshell/docshel4.cxx (revision 4d7c9de0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawDocShell.hxx"
28 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
29 #include <tools/urlobj.hxx>
30 #include <sfx2/progress.hxx>
31 #include <vcl/waitobj.hxx>
32 #ifndef _SVXIDS_HRC
33 #include <svx/svxids.hrc>
34 #endif
35 #include <editeng/flstitem.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <svl/aeitem.hxx>
38 #include <svl/flagitem.hxx>
39 #include <sot/storage.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <sfx2/docfilt.hxx>
42 #ifndef _DISPATCH_HXX //autogen
43 #include <sfx2/dispatch.hxx>
44 #endif
45 #include <svx/svdotext.hxx>
46 #include <svl/style.hxx>
47 #include <sfx2/printer.hxx>
48 #include <svtools/ctrltool.hxx>
49 #ifndef _SFX_ECODE_HXX //autogen
50 #include <svtools/sfxecode.hxx>
51 #endif
52 #include <sot/clsids.hxx>
53 #include <sot/formats.hxx>
54 #include <sfx2/request.hxx>
55 #ifdef TF_STARONE
56 #include "unomodel.hxx"
57 #endif
58 
59 #include <unotools/fltrcfg.hxx>
60 #include <sfx2/frame.hxx>
61 #include <sfx2/viewfrm.hxx>
62 //#include <svx/svxmsbas.hxx>
63 #include <unotools/saveopt.hxx>
64 #include <com/sun/star/drawing/XDrawPage.hpp>
65 #include <com/sun/star/drawing/XDrawView.hpp>
66 #include <comphelper/processfactory.hxx>
67 
68 #include "app.hrc"
69 #include "glob.hrc"
70 #include "strings.hrc"
71 #include "strmname.h"
72 #ifndef SD_FRAMW_VIEW_HXX
73 #include "FrameView.hxx"
74 #endif
75 #include "optsitem.hxx"
76 #include "Outliner.hxx"
77 #include "sdattr.hxx"
78 #include "drawdoc.hxx"
79 #include "ViewShell.hxx"
80 #include "app.hxx"
81 #include "View.hxx"
82 #include "sdpage.hxx"
83 #include "sdresid.hxx"
84 #include "DrawViewShell.hxx"
85 #include "ViewShellBase.hxx"
86 #include "Window.hxx"
87 #include "sdmod.hxx"
88 #include "OutlineViewShell.hxx"
89 #include "sdxmlwrp.hxx"
90 #include "sdpptwrp.hxx"
91 #include "sdcgmfilter.hxx"
92 #include "sdgrffilter.hxx"
93 #include "sdhtmlfilter.hxx"
94 #include "framework/FrameworkHelper.hxx"
95 
96 #include <sfx2/viewfrm.hxx>
97 #include "SdUnoDrawView.hxx"
98 using namespace ::com::sun::star;
99 using namespace ::com::sun::star::uno;
100 using ::sd::framework::FrameworkHelper;
101 
102 
103 namespace sd {
104 
105 /*************************************************************************
106 |*
107 |* SfxPrinter ggf. erzeugen und zurueckgeben
108 |*
109 \************************************************************************/
110 
GetPrinter(sal_Bool bCreate)111 SfxPrinter* DrawDocShell::GetPrinter(sal_Bool bCreate)
112 {
113 	if (bCreate && !mpPrinter)
114 	{
115 		// ItemSet mit speziellem Poolbereich anlegen
116 		SfxItemSet* pSet = new SfxItemSet( GetPool(),
117 							SID_PRINTER_NOTFOUND_WARN,	SID_PRINTER_NOTFOUND_WARN,
118 							SID_PRINTER_CHANGESTODOC,	SID_PRINTER_CHANGESTODOC,
119 							ATTR_OPTIONS_PRINT, 		ATTR_OPTIONS_PRINT,
120 							0 );
121 		// PrintOptionsSet setzen
122 		SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT,
123 							SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()));
124 		SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
125 		sal_uInt16		nFlags = 0;
126 
127 		nFlags =  (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
128 				(aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
129 		aFlagItem.SetValue( nFlags );
130 
131 		pSet->Put( aPrintItem );
132 		pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
133 		pSet->Put( aFlagItem );
134 
135 		mpPrinter = new SfxPrinter(pSet);
136 		mbOwnPrinter = sal_True;
137 
138 		// Ausgabequalitaet setzen
139 		sal_uInt16 nQuality = aPrintItem.GetOptionsPrint().GetOutputQuality();
140 
141 		sal_uLong nMode = DRAWMODE_DEFAULT;
142 
143         if( nQuality == 1 )
144 			nMode = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT;
145 		else if( nQuality == 2 )
146 			nMode = DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP | DRAWMODE_WHITEGRADIENT;
147 
148 		mpPrinter->SetDrawMode( nMode );
149 
150 		MapMode aMM (mpPrinter->GetMapMode());
151 		aMM.SetMapUnit(MAP_100TH_MM);
152 		mpPrinter->SetMapMode(aMM);
153         UpdateRefDevice();
154 	}
155 	return mpPrinter;
156 }
157 
158 /*************************************************************************
159 |*
160 |* neuen SfxPrinter setzen (Eigentuemeruebergang)
161 |*
162 \************************************************************************/
163 
SetPrinter(SfxPrinter * pNewPrinter)164 void DrawDocShell::SetPrinter(SfxPrinter *pNewPrinter)
165 {
166 	if ( mpViewShell )
167 	{
168 		::sd::View* pView = mpViewShell->GetView();
169 		if ( pView->IsTextEdit() )
170 			pView->SdrEndTextEdit();
171 	}
172 
173 	if ( mpPrinter && mbOwnPrinter && (mpPrinter != pNewPrinter) )
174 	{
175 		delete mpPrinter;
176 	}
177 
178 	mpPrinter = pNewPrinter;
179 	mbOwnPrinter = sal_True;
180     if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED )
181 		UpdateFontList();
182     UpdateRefDevice();
183 }
184 
UpdateFontList()185 void DrawDocShell::UpdateFontList()
186 {
187 	delete mpFontList;
188     OutputDevice* pRefDevice = NULL;
189     if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED )
190 		pRefDevice = GetPrinter(sal_True);
191 	else
192 		pRefDevice = SD_MOD()->GetVirtualRefDevice();
193 	mpFontList = new FontList( pRefDevice, NULL, sal_False );
194     SvxFontListItem aFontListItem( mpFontList, SID_ATTR_CHAR_FONTLIST );
195 	PutItem( aFontListItem );
196 }
197 
198 /*************************************************************************
199 |*
200 |*
201 |*
202 \************************************************************************/
GetDocumentPrinter()203 Printer* DrawDocShell::GetDocumentPrinter()
204 {
205 	return GetPrinter(sal_False);
206 }
207 
208 /*************************************************************************
209 |*
210 |*
211 |*
212 \************************************************************************/
OnDocumentPrinterChanged(Printer * pNewPrinter)213 void DrawDocShell::OnDocumentPrinterChanged(Printer* pNewPrinter)
214 {
215 	// if we already have a printer, see if its the same
216 	if( mpPrinter )
217 	{
218 		// easy case
219 		if( mpPrinter == pNewPrinter )
220 			return;
221 
222 		// compare if its the same printer with the same job setup
223 		if( (mpPrinter->GetName() == pNewPrinter->GetName()) &&
224 			(mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup()))
225 			return;
226 	}
227 
228 	//	if (mpPrinter->IsA(SfxPrinter))
229 	{
230 		// Da kein RTTI verfuegbar, wird hart gecasted (...)
231 		SetPrinter((SfxPrinter*) pNewPrinter);
232 
233 		// Printer gehoert dem Container
234 		mbOwnPrinter = sal_False;
235 	}
236 }
237 
238 /*************************************************************************
239 |*
240 |*
241 |*
242 \************************************************************************/
UpdateRefDevice()243 void DrawDocShell::UpdateRefDevice()
244 {
245 	if( mpDoc )
246 	{
247         // Determine the device for which the output will be formatted.
248         OutputDevice* pRefDevice = NULL;
249         switch (mpDoc->GetPrinterIndependentLayout())
250         {
251             case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
252                 pRefDevice = mpPrinter;
253                 break;
254 
255             case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
256                 pRefDevice = SD_MOD()->GetVirtualRefDevice();
257                 break;
258 
259             default:
260                 // We are confronted with an invalid or un-implemented
261                 // layout mode.  Use the printer as formatting device
262                 // as a fall-back.
263                 DBG_ASSERT(false, "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode");
264 
265                 pRefDevice = mpPrinter;
266                 break;
267         }
268 		mpDoc->SetRefDevice( pRefDevice );
269 
270 		::sd::Outliner* pOutl = mpDoc->GetOutliner( sal_False );
271 
272 		if( pOutl )
273 			pOutl->SetRefDevice( pRefDevice );
274 
275 		::sd::Outliner* pInternalOutl = mpDoc->GetInternalOutliner( sal_False );
276 
277 		if( pInternalOutl )
278 			pInternalOutl->SetRefDevice( pRefDevice );
279 	}
280 }
281 
282 /*************************************************************************
283 |*
284 |* InitNew, (Dokument wird neu erzeugt): Streams oeffnen
285 |*
286 \************************************************************************/
287 
InitNew(const::com::sun::star::uno::Reference<::com::sun::star::embed::XStorage> & xStorage)288 sal_Bool DrawDocShell::InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
289 {
290 	sal_Bool bRet = sal_False;
291 
292     bRet = SfxObjectShell::InitNew( xStorage );
293 
294 	Rectangle aVisArea( Point(0, 0), Size(14100, 10000) );
295 	SetVisArea(aVisArea);
296 
297 	if (bRet)
298 	{
299 		if( !mbSdDataObj )
300 			mpDoc->NewOrLoadCompleted(NEW_DOC);  // otherwise calling
301 			                                    // NewOrLoadCompleted(NEW_LOADED) in
302 												// SdDrawDocument::AllocModel()
303 	}
304 	return bRet;
305 }
306 
307 /*************************************************************************
308 |*
309 |* Load: Pools und Dokument laden
310 |*
311 \************************************************************************/
312 
Load(SfxMedium & rMedium)313 sal_Bool DrawDocShell::Load( SfxMedium& rMedium )
314 {
315     mbNewDocument = sal_False;
316 
317 	sal_Bool	bRet = sal_False;
318 	bool	bStartPresentation = false;
319     ErrCode nError = ERRCODE_NONE;
320 
321     SfxItemSet* pSet = rMedium.GetItemSet();
322 
323 
324 	if( pSet )
325 	{
326 		if( (  SFX_ITEM_SET == pSet->GetItemState(SID_PREVIEW ) ) && ( (SfxBoolItem&) ( pSet->Get( SID_PREVIEW ) ) ).GetValue() )
327 		{
328 			mpDoc->SetStarDrawPreviewMode( sal_True );
329 		}
330 
331 		if( SFX_ITEM_SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&&
332 			( (SfxBoolItem&) ( pSet->Get( SID_DOC_STARTPRESENTATION ) ) ).GetValue() )
333 		{
334 			bStartPresentation = true;
335 			mpDoc->SetStartWithPresentation( true );
336 		}
337 	}
338 
339     bRet = SfxObjectShell::Load( rMedium );
340 	if( bRet )
341 	{
342         bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
343 	}
344 
345 	if( bRet )
346 	{
347 		UpdateTablePointers();
348 
349         // #108451# If we're an embedded OLE object, use tight bounds
350         // for our visArea. No point in showing the user lots of empty
351         // space. Had to remove the check for empty VisArea below,
352         // since XML load always sets a VisArea before.
353         //TODO/LATER: looks a little bit strange!
354         if( ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() )
355 		{
356 			SdPage* pPage = mpDoc->GetSdPage( 0, PK_STANDARD );
357 
358 			if( pPage )
359 				SetVisArea( Rectangle( pPage->GetAllObjBoundRect() ) );
360 		}
361 
362 		FinishedLoading( SFX_LOADED_ALL );
363 
364         const INetURLObject aUrl;
365         SfxObjectShell::SetAutoLoad( aUrl, 0, sal_False );
366 	}
367 	else
368 	{
369         if( nError == ERRCODE_IO_BROKENPACKAGE )
370             SetError( ERRCODE_IO_BROKENPACKAGE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
371 
372         // TODO/LATER: correct error handling?!
373         //pStore->SetError( SVSTREAM_WRONGVERSION, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
374         else
375             SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
376 	}
377 
378 	// tell SFX to change viewshell when in preview mode
379 	if( IsPreview() || bStartPresentation )
380 	{
381 		SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
382 		if( pMediumSet )
383 			pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
384 	}
385 
386 	return bRet;
387 }
388 
389 /*************************************************************************
390 |*
391 |* LoadFrom: Inhalte fuer Organizer laden
392 |*
393 \************************************************************************/
394 
LoadFrom(SfxMedium & rMedium)395 sal_Bool DrawDocShell::LoadFrom( SfxMedium& rMedium )
396 {
397     mbNewDocument = sal_False;
398 
399 	WaitObject* pWait = NULL;
400 	if( mpViewShell )
401 		pWait = new WaitObject( (Window*) mpViewShell->GetActiveWindow() );
402 
403 	sal_Bool bRet = sal_False;
404 
405         /*
406         // #90691# return to old behaviour (before #80365#): construct own medium
407         SfxMedium aMedium(xStorage);
408 
409 		// #90691# for having a progress bar nonetheless for XML copy it
410 		// from the local DocShell medium (GetMedium()) to the constructed one
411 		SfxMedium* pLocalMedium = GetMedium();
412 		if(pLocalMedium)
413 		{
414 			SfxItemSet* pLocalItemSet = pLocalMedium->GetItemSet();
415 			SfxItemSet* pDestItemSet = aMedium.GetItemSet();
416 
417 			if(pLocalItemSet && pDestItemSet)
418 			{
419 				const SfxUnoAnyItem* pItem = static_cast<
420                     const SfxUnoAnyItem*>(
421                         pLocalItemSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL));
422 
423 				if(pItem)
424 				{
425 					pDestItemSet->Put(*pItem);
426 				}
427 			}
428         }                           */
429 
430 		mpDoc->NewOrLoadCompleted( NEW_DOC );
431 		mpDoc->CreateFirstPages();
432 		mpDoc->StopWorkStartupDelay();
433 
434         // TODO/LATER: nobody is interested in the error code?!
435         ErrCode nError = ERRCODE_NONE;
436         bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
437 
438 
439 	// tell SFX to change viewshell when in preview mode
440 	if( IsPreview() )
441 	{
442 		SfxItemSet *pSet = GetMedium()->GetItemSet();
443 
444 		if( pSet )
445 			pSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
446 	}
447 
448 	delete pWait;
449 
450 	return bRet;
451 }
452 
453 /*************************************************************************
454 |*
455 |* ConvertFrom: aus Fremdformat laden
456 |*
457 \************************************************************************/
458 
ConvertFrom(SfxMedium & rMedium)459 sal_Bool DrawDocShell::ConvertFrom( SfxMedium& rMedium )
460 {
461     mbNewDocument = sal_False;
462 
463 	const String	aFilterName( rMedium.GetFilter()->GetFilterName() );
464 	sal_Bool			bRet = sal_False;
465 	bool	bStartPresentation = false;
466 
467 	SetWaitCursor( sal_True );
468 
469     SfxItemSet* pSet = rMedium.GetItemSet();
470 	if( pSet )
471 	{
472 		if( (  SFX_ITEM_SET == pSet->GetItemState(SID_PREVIEW ) ) && ( (SfxBoolItem&) ( pSet->Get( SID_PREVIEW ) ) ).GetValue() )
473 		{
474 			mpDoc->SetStarDrawPreviewMode( sal_True );
475 		}
476 
477 		if( SFX_ITEM_SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&&
478 			( (SfxBoolItem&) ( pSet->Get( SID_DOC_STARTPRESENTATION ) ) ).GetValue() )
479 		{
480 			bStartPresentation = true;
481 			mpDoc->SetStartWithPresentation( true );
482 		}
483 	}
484 
485 	if( aFilterName == pFilterPowerPoint97 || aFilterName == pFilterPowerPoint97Template)
486 	{
487 		mpDoc->StopWorkStartupDelay();
488         bRet = SdPPTFilter( rMedium, *this, sal_True ).Import();
489 	}
490 	else if (aFilterName.SearchAscii("impress8" )  != STRING_NOTFOUND ||
491 		     aFilterName.SearchAscii("draw8")  != STRING_NOTFOUND )
492 	{
493         // TODO/LATER: nobody is interested in the error code?!
494 		mpDoc->CreateFirstPages();
495 		mpDoc->StopWorkStartupDelay();
496         ErrCode nError = ERRCODE_NONE;
497         bRet = SdXMLFilter( rMedium, *this, sal_True ).Import( nError );
498 
499 	}
500 	else if (aFilterName.SearchAscii("StarOffice XML (Draw)" )  != STRING_NOTFOUND || aFilterName.SearchAscii("StarOffice XML (Impress)")  != STRING_NOTFOUND )
501 	{
502         // TODO/LATER: nobody is interested in the error code?!
503 		mpDoc->CreateFirstPages();
504 		mpDoc->StopWorkStartupDelay();
505         ErrCode nError = ERRCODE_NONE;
506         bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 ).Import( nError );
507 	}
508 	else if( aFilterName.EqualsAscii( "CGM - Computer Graphics Metafile" ) )
509 	{
510 		mpDoc->CreateFirstPages();
511 		mpDoc->StopWorkStartupDelay();
512         bRet = SdCGMFilter( rMedium, *this, sal_True ).Import();
513 	}
514 	else
515 	{
516 		mpDoc->CreateFirstPages();
517 		mpDoc->StopWorkStartupDelay();
518         bRet = SdGRFFilter( rMedium, *this ).Import();
519 	}
520 
521 	FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
522 
523 	// tell SFX to change viewshell when in preview mode
524 	if( IsPreview() )
525 	{
526 		SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
527 
528 		if( pMediumSet )
529 			pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
530 	}
531 	SetWaitCursor( sal_False );
532 
533 	// tell SFX to change viewshell when in preview mode
534 	if( IsPreview() || bStartPresentation )
535 	{
536 		SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
537 		if( pMediumSet )
538 			pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
539 	}
540 
541 	return bRet;
542 }
543 
544 /*************************************************************************
545 |*
546 |* Save: Pools und Dokument in die offenen Streams schreiben
547 |*
548 \************************************************************************/
549 
Save()550 sal_Bool DrawDocShell::Save()
551 {
552 	mpDoc->StopWorkStartupDelay();
553 
554     //TODO/LATER: why this?!
555 	if( GetCreateMode() == SFX_CREATE_MODE_STANDARD )
556         SfxObjectShell::SetVisArea( Rectangle() );
557 
558     sal_Bool bRet = SfxObjectShell::Save();
559 
560 	if( bRet )
561 	{
562 		// #86834# Call UpdateDocInfoForSave() before export
563 		UpdateDocInfoForSave();
564 
565         bRet = SdXMLFilter( *GetMedium(), *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( GetMedium()->GetStorage() ) ).Export();
566 	}
567 
568 	return bRet;
569 }
570 
571 /*************************************************************************
572 |*
573 |* SaveAs: Pools und Dokument in den angegebenen Storage sichern
574 |*
575 \************************************************************************/
576 
SaveAs(SfxMedium & rMedium)577 sal_Bool DrawDocShell::SaveAs( SfxMedium& rMedium )
578 {
579 	mpDoc->setDocAccTitle(String());
580 	SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
581 	if (pFrame1)
582 	{
583 		::Window* pWindow = &pFrame1->GetWindow();
584 		if ( pWindow )
585 		{
586 			::Window* pSysWin = pWindow->GetSystemWindow();
587 			if ( pSysWin )
588 			{
589 				pSysWin->SetAccessibleName(String());
590 			}
591 		}
592 	}
593 	mpDoc->StopWorkStartupDelay();
594 
595     //TODO/LATER: why this?!
596 	if( GetCreateMode() == SFX_CREATE_MODE_STANDARD )
597         SfxObjectShell::SetVisArea( Rectangle() );
598 
599 	sal_uInt32	nVBWarning = ERRCODE_NONE;
600     sal_Bool    bRet = SfxObjectShell::SaveAs( rMedium );
601 
602 	if( bRet )
603 	{
604         // #86834# Call UpdateDocInfoForSave() before export
605         UpdateDocInfoForSave();
606         bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export();
607     }
608 
609 	if( GetError() == ERRCODE_NONE )
610 		SetError( nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
611 
612 	return bRet;
613 }
614 
615 /*************************************************************************
616 |*
617 |* ConvertTo: im Fremdformat speichern
618 |*
619 \************************************************************************/
620 
ConvertTo(SfxMedium & rMedium)621 sal_Bool DrawDocShell::ConvertTo( SfxMedium& rMedium )
622 {
623 	sal_Bool bRet = sal_False;
624 
625 	if( mpDoc->GetPageCount() )
626 	{
627 		const SfxFilter*	pMediumFilter = rMedium.GetFilter();
628 		const String		aTypeName( pMediumFilter->GetTypeName() );
629 		SdFilter*			pFilter = NULL;
630 
631 		if( aTypeName.SearchAscii( "graphic_HTML" ) != STRING_NOTFOUND )
632 		{
633 			pFilter = new SdHTMLFilter( rMedium, *this, sal_True );
634 		}
635 		else if( aTypeName.SearchAscii( "MS_PowerPoint_97" ) != STRING_NOTFOUND )
636 		{
637 			pFilter = new SdPPTFilter( rMedium, *this, sal_True );
638 			((SdPPTFilter*)pFilter)->PreSaveBasic();
639 		}
640 		else if ( aTypeName.SearchAscii( "CGM_Computer_Graphics_Metafile" ) != STRING_NOTFOUND )
641 		{
642 			pFilter = new SdCGMFilter( rMedium, *this, sal_True );
643 		}
644 		else if( ( aTypeName.SearchAscii( "draw8" ) != STRING_NOTFOUND ) ||
645 				 ( aTypeName.SearchAscii( "impress8" ) != STRING_NOTFOUND ) )
646 		{
647 			pFilter = new SdXMLFilter( rMedium, *this, sal_True );
648 			UpdateDocInfoForSave();
649 		}
650 		else if( ( aTypeName.SearchAscii( "StarOffice_XML_Impress" ) != STRING_NOTFOUND ) ||
651 				 ( aTypeName.SearchAscii( "StarOffice_XML_Draw" ) != STRING_NOTFOUND ) )
652 		{
653 			pFilter = new SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 );
654 			UpdateDocInfoForSave();
655 		}
656 		else
657 		{
658 			pFilter = new SdGRFFilter( rMedium, *this );
659 		}
660 
661 		if( pFilter )
662 		{
663 			const sal_uLong	nOldSwapMode = mpDoc->GetSwapGraphicsMode();
664 
665 			mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
666 
667 			bRet = pFilter->Export();
668 			if( !bRet )
669 				mpDoc->SetSwapGraphicsMode( nOldSwapMode );
670 
671 			delete pFilter;
672 		}
673 	}
674 
675 	return  bRet;
676 }
677 
678 /*************************************************************************
679 |*
680 |* SaveCompleted: die eigenen Streams wieder oeffnen, damit kein anderer
681 |*								  sie "besetzt"
682 |*
683 \************************************************************************/
684 
SaveCompleted(const::com::sun::star::uno::Reference<::com::sun::star::embed::XStorage> & xStorage)685 sal_Bool DrawDocShell::SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
686 {
687 	sal_Bool bRet = sal_False;
688 
689     if( SfxObjectShell::SaveCompleted(xStorage) )
690 	{
691 		mpDoc->NbcSetChanged( sal_False );
692 
693 		if( mpViewShell )
694 		{
695 			if( mpViewShell->ISA( OutlineViewShell ) )
696 				static_cast<OutlineView*>(mpViewShell->GetView())
697                     ->GetOutliner()->ClearModifyFlag();
698 
699 			SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner();
700 			if( pOutl )
701 			{
702 				SdrObject* pObj = mpViewShell->GetView()->GetTextEditObject();
703 				if( pObj )
704 					pObj->NbcSetOutlinerParaObject( pOutl->CreateParaObject() );
705 
706 				pOutl->ClearModifyFlag();
707 			}
708 		}
709 
710 		bRet = sal_True;
711 
712 		SfxViewFrame* pFrame = ( mpViewShell && mpViewShell->GetViewFrame() ) ?
713 							   mpViewShell->GetViewFrame() :
714 							   SfxViewFrame::Current();
715 
716 		if( pFrame )
717 			pFrame->GetBindings().Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
718 	}
719 	return bRet;
720 }
721 
722 /*************************************************************************
723 |*
724 |* Referenz auf Dokument
725 |*
726 \************************************************************************/
727 
GetDoc()728 SdDrawDocument* DrawDocShell::GetDoc()
729 {
730 	return mpDoc;
731 }
732 
733 /*************************************************************************
734 |*
735 |* Referenz auf Dokument
736 |*
737 \************************************************************************/
738 
GetStyleSheetPool()739 SfxStyleSheetBasePool* DrawDocShell::GetStyleSheetPool()
740 {
741 	return( (SfxStyleSheetBasePool*) mpDoc->GetStyleSheetPool() );
742 }
743 
744 /*************************************************************************
745 |*
746 |* Sprung zu Bookmark
747 |*
748 \************************************************************************/
749 
GotoBookmark(const String & rBookmark)750 sal_Bool DrawDocShell::GotoBookmark(const String& rBookmark)
751 {
752 	sal_Bool bFound = sal_False;
753 
754 	if (mpViewShell && mpViewShell->ISA(DrawViewShell))
755 	{
756 		DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(mpViewShell);
757         ViewShellBase& rBase (mpViewShell->GetViewShellBase());
758 
759 		sal_Bool bIsMasterPage = sal_False;
760 		sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND;
761 		SdrObject* pObj = NULL;
762 
763 		rtl::OUString sBookmark( rBookmark );
764 		const rtl::OUString sInteraction( RTL_CONSTASCII_USTRINGPARAM( "action?" ) );
765 		if ( sBookmark.match( sInteraction ) )
766 		{
767 			const rtl::OUString sJump( RTL_CONSTASCII_USTRINGPARAM( "jump=" ) );
768 			if ( sBookmark.match( sJump, sInteraction.getLength() ) )
769 			{
770 				rtl::OUString aDestination( sBookmark.copy( sInteraction.getLength() + sJump.getLength() ) );
771 				if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "firstslide" ) ) ) )
772 				{
773 					nPageNumber = 1;
774 				}
775 				else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "lastslide" ) ) ) )
776 				{
777 					nPageNumber = mpDoc->GetPageCount() - 2;
778 				}
779 				else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "previousslide" ) ) ) )
780 				{
781                     SdPage* pPage = pDrawViewShell->GetActualPage();
782                     nPageNumber = pPage->GetPageNum();
783 					nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND;
784 				}
785 				else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "nextslide" ) ) ) )
786 				{
787                     SdPage* pPage = pDrawViewShell->GetActualPage();
788                     nPageNumber = pPage->GetPageNum() + 2;
789 					if ( nPageNumber >= mpDoc->GetPageCount() )
790 						nPageNumber = SDRPAGE_NOTFOUND;
791 				}
792 			}
793 		}
794 		else
795 		{
796 			String aBookmark( rBookmark );
797 
798 			// Ist das Bookmark eine Seite?
799 			nPageNumber = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
800 
801 			if (nPageNumber == SDRPAGE_NOTFOUND)
802 			{
803 				// Ist das Bookmark ein Objekt?
804 				pObj = mpDoc->GetObj(aBookmark);
805 
806 				if (pObj)
807 				{
808 					nPageNumber = pObj->GetPage()->GetPageNum();
809 				}
810 			}
811 		}
812 		if (nPageNumber != SDRPAGE_NOTFOUND)
813 		{
814 			// Jump to the bookmarked page.  This is done in three steps.
815 
816 			bFound = sal_True;
817 			SdPage* pPage;
818             if (bIsMasterPage)
819                 pPage = (SdPage*) mpDoc->GetMasterPage(nPageNumber);
820             else
821                 pPage = (SdPage*) mpDoc->GetPage(nPageNumber);
822 
823             // 1.) Change the view shell to the edit view, the notes view,
824             // or the handout view.
825 			PageKind eNewPageKind = pPage->GetPageKind();
826 
827 			if( (eNewPageKind != PK_STANDARD) && (mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) )
828 				return sal_False;
829 
830 			if (eNewPageKind != pDrawViewShell->GetPageKind())
831 			{
832 				// Arbeitsbereich wechseln
833 				GetFrameView()->SetPageKind(eNewPageKind);
834                 ::rtl::OUString sViewURL;
835                 switch (eNewPageKind)
836                 {
837                     case PK_STANDARD:
838                         sViewURL = FrameworkHelper::msImpressViewURL;
839                         break;
840                     case PK_NOTES:
841                         sViewURL = FrameworkHelper::msNotesViewURL;
842                         break;
843                     case PK_HANDOUT:
844                         sViewURL = FrameworkHelper::msHandoutViewURL;
845                         break;
846                     default:
847                         break;
848                 }
849                 if (sViewURL.getLength() > 0)
850                 {
851                     ::boost::shared_ptr<FrameworkHelper> pHelper (
852                         FrameworkHelper::Instance(rBase));
853                     pHelper->RequestView(
854                         sViewURL,
855                         FrameworkHelper::msCenterPaneURL);
856                     pHelper->WaitForUpdate();
857 
858                     // Get the new DrawViewShell.
859                     mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
860                     pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell);
861                 }
862                 else
863                 {
864                     pDrawViewShell = NULL;
865                 }
866             }
867 
868             if (pDrawViewShell != NULL)
869             {
870                 // Set the edit mode to either the normal edit mode or the
871                 // master page mode.
872                 EditMode eNewEditMode = EM_PAGE;
873                 if (bIsMasterPage)
874                 {
875                     eNewEditMode = EM_MASTERPAGE;
876                 }
877 
878                 if (eNewEditMode != pDrawViewShell->GetEditMode())
879                 {
880                     // EditMode setzen
881                     pDrawViewShell->ChangeEditMode(eNewEditMode, sal_False);
882                 }
883 
884                 // Make the bookmarked page the current page.  This is done
885                 // by using the API because this takes care of all the
886                 // little things to be done.  Especially writing the view
887                 // data to the frame view (see bug #107803#).
888                 sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2;
889                 Reference<drawing::XDrawView> xController (rBase.GetController(), UNO_QUERY);
890                 if (xController.is())
891                 {
892                     Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY);
893                     xController->setCurrentPage (xDrawPage);
894                 }
895                 else
896                 {
897                     // As a fall back switch to the page via the core.
898                     DBG_ASSERT (xController.is(),
899                         "DrawDocShell::GotoBookmark: can't switch page via API");
900                     pDrawViewShell->SwitchPage(nSdPgNum);
901                 }
902 
903                 if (pObj != NULL)
904                 {
905                     // Objekt einblenden und selektieren
906                     pDrawViewShell->MakeVisible(pObj->GetLogicRect(),
907                         *pDrawViewShell->GetActiveWindow());
908                     pDrawViewShell->GetView()->UnmarkAll();
909                     pDrawViewShell->GetView()->MarkObj(
910                         pObj,
911                         pDrawViewShell->GetView()->GetSdrPageView(), sal_False);
912                 }
913             }
914         }
915 
916         SfxBindings& rBindings = (pDrawViewShell->GetViewFrame()!=NULL
917             ? pDrawViewShell->GetViewFrame()
918             : SfxViewFrame::Current() )->GetBindings();
919 
920         rBindings.Invalidate(SID_NAVIGATOR_STATE, sal_True, sal_False);
921         rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
922     }
923 
924 	return (bFound);
925 }
926 
927 //Solution: If  object  is marked , return true , else return false .
IsMarked(SdrObject * pObject)928 sal_Bool DrawDocShell::IsMarked(  SdrObject* pObject  )
929 {
930        sal_Bool bisMarked =sal_False;
931 
932 	 if (mpViewShell && mpViewShell->ISA(DrawViewShell))
933 	{
934 		DrawViewShell* pDrViewSh = (DrawViewShell*) mpViewShell;
935 		if (pObject )
936 		{
937 		      bisMarked = pDrViewSh->GetView()->IsObjMarked(pObject);
938 		}
939 	 }
940 	return  bisMarked;
941 }
942 //Solution: If  object  is marked , return true , else return false .
GetObjectIsmarked(const String & rBookmark)943 sal_Bool DrawDocShell::GetObjectIsmarked(const String& rBookmark)
944 {
945     OSL_TRACE("GotoBookmark %s",
946         ::rtl::OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
947      sal_Bool bUnMark = sal_False;
948 
949 	if (mpViewShell && mpViewShell->ISA(DrawViewShell))
950 	{
951 		DrawViewShell* pDrViewSh = (DrawViewShell*) mpViewShell;
952 
953 		String aBookmark( rBookmark );
954 
955 		if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') )
956 			aBookmark = rBookmark.Copy( 1 );
957 
958 		// Ist das Bookmark eine Seite?
959 		sal_Bool        bIsMasterPage;
960         sal_uInt16      nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
961 		SdrObject*  pObj = NULL;
962 
963 		if (nPgNum == SDRPAGE_NOTFOUND)
964 		{
965 			// Ist das Bookmark ein Objekt?
966 			pObj = mpDoc->GetObj(aBookmark);
967 
968 			if (pObj)
969 			{
970 				nPgNum = pObj->GetPage()->GetPageNum();
971 			}
972 		}
973 
974 		if (nPgNum != SDRPAGE_NOTFOUND)
975 		{
976 			/**********************************************************
977 			* Zur Seite springen
978 			**********************************************************/
979 
980 			SdPage* pPage = (SdPage*) mpDoc->GetPage(nPgNum);
981 
982 			PageKind eNewPageKind = pPage->GetPageKind();
983 
984 			if (eNewPageKind != pDrViewSh->GetPageKind())
985 			{
986 				// Arbeitsbereich wechseln
987 				GetFrameView()->SetPageKind(eNewPageKind);
988 				( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
989 				  mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->
990 				  GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
991 
992 				// Die aktuelle ViewShell hat sich geaendert!
993 				pDrViewSh = (DrawViewShell*) mpViewShell;
994 			}
995 
996 			EditMode eNewEditMode = EM_PAGE;
997 
998 			if( bIsMasterPage )
999 			{
1000 				eNewEditMode = EM_MASTERPAGE;
1001 			}
1002 
1003 			if (eNewEditMode != pDrViewSh->GetEditMode())
1004 			{
1005 				// EditMode setzen
1006 				pDrViewSh->ChangeEditMode(eNewEditMode, sal_False);
1007 			}
1008 
1009 			// Jump to the page.  This is done by using the API because this
1010 			// takes care of all the little things to be done.  Especially
1011 			// writing the view data to the frame view (see bug #107803#).
1012 			sal_uInt16 nSdPgNum = (nPgNum - 1) / 2;
1013             SdUnoDrawView* pUnoDrawView = new SdUnoDrawView (
1014                 pDrViewSh->GetViewShellBase().GetDrawController(),
1015                 *pDrViewSh,
1016                 *pDrViewSh->GetView());
1017             if (pUnoDrawView != NULL)
1018             {
1019                 ::com::sun::star::uno::Reference<
1020                       ::com::sun::star::drawing::XDrawPage> xDrawPage (
1021                           pPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY);
1022                 pUnoDrawView->setCurrentPage (xDrawPage);
1023             }
1024             else
1025             {
1026                 // As a fall back switch to the page via the core.
1027                 DBG_ASSERT (pUnoDrawView!=NULL,
1028                     "SdDrawDocShell::GotoBookmark: can't switch page via API");
1029                 pDrViewSh->SwitchPage(nSdPgNum);
1030             }
1031 			delete pUnoDrawView;
1032 
1033 
1034 			if (pObj)
1035 			{
1036 				// Objekt einblenden und selektieren
1037 				pDrViewSh->MakeVisible(pObj->GetLogicRect(),
1038 									   *pDrViewSh->GetActiveWindow());
1039 
1040 		         bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
1041 
1042 
1043 			}
1044 		}
1045 	}
1046 
1047 	return ( bUnMark);
1048 }
1049 //Solution: realize multi-selection of objects
GotoTreeBookmark(const String & rBookmark)1050 sal_Bool DrawDocShell::GotoTreeBookmark(const String& rBookmark)
1051 {
1052     OSL_TRACE("GotoBookmark %s",
1053         ::rtl::OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
1054 	sal_Bool bFound = sal_False;
1055 
1056 	if (mpViewShell && mpViewShell->ISA(DrawViewShell))
1057 	{
1058 		DrawViewShell* pDrViewSh = (DrawViewShell*) mpViewShell;
1059 
1060 		String aBookmark( rBookmark );
1061 
1062 		if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') )
1063 			aBookmark = rBookmark.Copy( 1 );
1064 
1065 		// Ist das Bookmark eine Seite?
1066 		sal_Bool        bIsMasterPage;
1067         sal_uInt16      nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
1068 		SdrObject*  pObj = NULL;
1069 
1070 		if (nPgNum == SDRPAGE_NOTFOUND)
1071 		{
1072 			// Ist das Bookmark ein Objekt?
1073 			pObj = mpDoc->GetObj(aBookmark);
1074 
1075 			if (pObj)
1076 			{
1077 				nPgNum = pObj->GetPage()->GetPageNum();
1078 			}
1079 		}
1080 
1081 		if (nPgNum != SDRPAGE_NOTFOUND)
1082 		{
1083 			/**********************************************************
1084 			* Zur Seite springen
1085 			**********************************************************/
1086 			bFound = sal_True;
1087 			SdPage* pPage = (SdPage*) mpDoc->GetPage(nPgNum);
1088 
1089 			PageKind eNewPageKind = pPage->GetPageKind();
1090 
1091 			if (eNewPageKind != pDrViewSh->GetPageKind())
1092 			{
1093 				// Arbeitsbereich wechseln
1094 				GetFrameView()->SetPageKind(eNewPageKind);
1095 				( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
1096 				  mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->
1097 				  GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
1098 
1099 				// Die aktuelle ViewShell hat sich geaendert!
1100 				pDrViewSh = (DrawViewShell*) mpViewShell;
1101 			}
1102 
1103 			EditMode eNewEditMode = EM_PAGE;
1104 
1105 			if( bIsMasterPage )
1106 			{
1107 				eNewEditMode = EM_MASTERPAGE;
1108 			}
1109 
1110 			if (eNewEditMode != pDrViewSh->GetEditMode())
1111 			{
1112 				// EditMode setzen
1113 				pDrViewSh->ChangeEditMode(eNewEditMode, sal_False);
1114 			}
1115 
1116 			// Jump to the page.  This is done by using the API because this
1117 			// takes care of all the little things to be done.  Especially
1118 			// writing the view data to the frame view (see bug #107803#).
1119 			sal_uInt16 nSdPgNum = (nPgNum - 1) / 2;
1120             SdUnoDrawView* pUnoDrawView = new SdUnoDrawView (
1121                 pDrViewSh->GetViewShellBase().GetDrawController(),
1122                 *pDrViewSh,
1123                 *pDrViewSh->GetView());
1124             if (pUnoDrawView != NULL)
1125             {
1126                 ::com::sun::star::uno::Reference<
1127                       ::com::sun::star::drawing::XDrawPage> xDrawPage (
1128                           pPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY);
1129                 pUnoDrawView->setCurrentPage (xDrawPage);
1130             }
1131             else
1132             {
1133                 // As a fall back switch to the page via the core.
1134                 DBG_ASSERT (pUnoDrawView!=NULL,
1135                     "SdDrawDocShell::GotoBookmark: can't switch page via API");
1136                 pDrViewSh->SwitchPage(nSdPgNum);
1137             }
1138 			delete pUnoDrawView;
1139 
1140 
1141 			if (pObj)
1142 			{
1143 				// Objekt einblenden und selektieren
1144 				pDrViewSh->MakeVisible(pObj->GetLogicRect(),
1145 									   *pDrViewSh->GetActiveWindow());
1146 		              sal_Bool bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
1147 				pDrViewSh->GetView()->MarkObj(pObj, pDrViewSh->GetView()->GetSdrPageView(), bUnMark);
1148 			}
1149 		}
1150 
1151 		SfxBindings& rBindings = ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
1152 								 mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings();
1153 
1154 		rBindings.Invalidate(SID_NAVIGATOR_STATE, sal_True, sal_False);
1155 		rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
1156 	}
1157 
1158 	return (bFound);
1159 }
1160 /*************************************************************************
1161 |*
1162 |* SaveAsOwnFormat: wenn es eine Dokumentvorlage werden soll,
1163 |*
1164 \************************************************************************/
1165 #include <tools/urlobj.hxx>
1166 
SaveAsOwnFormat(SfxMedium & rMedium)1167 sal_Bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium )
1168 {
1169 
1170 	const SfxFilter* pFilter = rMedium.GetFilter();
1171 
1172 	if (pFilter->IsOwnTemplateFormat())
1173 	{
1174 		// jetzt die StarDraw-Spezialitaeten:
1175 		// die Layoutvorlagen der ersten Seite werden mit dem jetzt
1176 		// bekannten Layoutnamen versehen, die Layoutnamen der betroffenen
1177 		// Masterpages und Seiten werden gesetzt;
1178 		// alle Textobjekte der betroffenen Standard-, Notiz- und
1179 		// Masterpages werden ueber die Namensaenderung informiert
1180 
1181 		String aLayoutName;
1182 
1183 		SfxStringItem* pLayoutItem;
1184 		if( rMedium.GetItemSet()->GetItemState(SID_TEMPLATE_NAME, sal_False, (const SfxPoolItem**) & pLayoutItem ) == SFX_ITEM_SET )
1185 		{
1186 			aLayoutName = pLayoutItem->GetValue();
1187 		}
1188 		else
1189 		{
1190 			INetURLObject aURL( rMedium.GetName() );
1191 			aURL.removeExtension();
1192 			aLayoutName = aURL.getName();
1193 		}
1194 
1195 		if( aLayoutName.Len() )
1196 		{
1197 			sal_uInt32 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
1198 			for(sal_uInt32 i = 0; i < nCount; i++)
1199 			{
1200 				String aOldPageLayoutName = mpDoc->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName();
1201 				String aNewLayoutName = aLayoutName;
1202 				// Don't add suffix for the first master page
1203 				if( i > 0 )
1204 					aNewLayoutName += String::CreateFromInt32(i);
1205 
1206 				mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aNewLayoutName);
1207 			}
1208 		}
1209 	}
1210 
1211 	return SfxObjectShell::SaveAsOwnFormat(rMedium);
1212 }
1213 
1214 /*************************************************************************
1215 |*
1216 |* FillClass
1217 |*
1218 \************************************************************************/
1219 
FillClass(SvGlobalName * pClassName,sal_uInt32 * pFormat,String *,String * pFullTypeName,String * pShortTypeName,sal_Int32 nFileFormat,sal_Bool bTemplate) const1220 void DrawDocShell::FillClass(SvGlobalName* pClassName,
1221 										sal_uInt32*  pFormat,
1222 										String* ,
1223 										String* pFullTypeName,
1224                                         String* pShortTypeName,
1225 										sal_Int32 nFileFormat,
1226 										sal_Bool bTemplate /* = sal_False */) const
1227 {
1228 	if (nFileFormat == SOFFICE_FILEFORMAT_60)
1229 	{
1230         if ( meDocType == DOCUMENT_TYPE_DRAW )
1231         {
1232                 *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
1233                 *pFormat = SOT_FORMATSTR_ID_STARDRAW_60;
1234                 *pFullTypeName = String(SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60));
1235         }
1236         else
1237         {
1238                 *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
1239                 *pFormat = SOT_FORMATSTR_ID_STARIMPRESS_60;
1240                 *pFullTypeName = String(SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60));
1241         }
1242 	}
1243 	else if (nFileFormat == SOFFICE_FILEFORMAT_8)
1244 	{
1245         if ( meDocType == DOCUMENT_TYPE_DRAW )
1246         {
1247                 *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
1248                 *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARDRAW_8_TEMPLATE : SOT_FORMATSTR_ID_STARDRAW_8;
1249                 *pFullTypeName = String(RTL_CONSTASCII_USTRINGPARAM("Draw 8"));	// HACK: method will be removed with new storage API
1250         }
1251         else
1252         {
1253                 *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
1254                 *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARIMPRESS_8_TEMPLATE : SOT_FORMATSTR_ID_STARIMPRESS_8;
1255                 *pFullTypeName = String(RTL_CONSTASCII_USTRINGPARAM("Impress 8")); // HACK: method will be removed with new storage API
1256         }
1257 	}
1258 
1259 	*pShortTypeName = String(SdResId( (meDocType == DOCUMENT_TYPE_DRAW) ?
1260 									  STR_GRAPHIC_DOCUMENT : STR_IMPRESS_DOCUMENT ));
1261 }
1262 
GetDocumentRefDev(void)1263 OutputDevice* DrawDocShell::GetDocumentRefDev (void)
1264 {
1265     OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev ();
1266     // Only when our parent does not have a reference device then we return
1267     // our own.
1268     if (pReferenceDevice == NULL && mpDoc != NULL)
1269         pReferenceDevice = mpDoc->GetRefDevice ();
1270     return pReferenceDevice;
1271 }
1272 
1273 /** executes the SID_OPENDOC slot to let the framework open a document
1274 	with the given URL and this document as a referer */
OpenBookmark(const String & rBookmarkURL)1275 void DrawDocShell::OpenBookmark( const String& rBookmarkURL )
1276 {
1277     SfxStringItem   aStrItem( SID_FILE_NAME, rBookmarkURL );
1278     SfxStringItem   aReferer( SID_REFERER, GetMedium()->GetName() );
1279 	const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, 0 };
1280 	( mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs );
1281 }
1282 
setDocAccTitle(const String & rTitle)1283 void DrawDocShell::setDocAccTitle( const String& rTitle )
1284 {
1285 	if (mpDoc )
1286 	{
1287 		mpDoc->setDocAccTitle( rTitle );
1288 	}
1289 }
getDocAccTitle() const1290 const String DrawDocShell::getDocAccTitle() const
1291 {
1292 	String sRet;
1293 	if  (mpDoc)
1294 	{
1295 		sRet =  mpDoc->getDocAccTitle();
1296 	}
1297 
1298 	return sRet;
1299 }
setDocReadOnly(sal_Bool bReadOnly)1300 void DrawDocShell::setDocReadOnly( sal_Bool bReadOnly)
1301 {
1302 	if (mpDoc )
1303 	{
1304 		mpDoc->setDocReadOnly( bReadOnly );
1305 	}
1306 }
getDocReadOnly() const1307 sal_Bool DrawDocShell::getDocReadOnly() const
1308 {
1309 	if  (mpDoc)
1310 	{
1311 		return mpDoc->getDocReadOnly();
1312 	}
1313 
1314 	return sal_False;
1315 }
1316 } // end of namespace sd
1317