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