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