xref: /trunk/main/sd/source/ui/app/sdmod2.cxx (revision 5829e3e6)
15b190011SAndrew Rist /**************************************************************
2*5829e3e6Smseidel  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5829e3e6Smseidel  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5829e3e6Smseidel  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19*5829e3e6Smseidel  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <editeng/eeitem.hxx>
27cdf0e10cSrcweir #include <editeng/flditem.hxx>
28cdf0e10cSrcweir #include <sfx2/printer.hxx>
29cdf0e10cSrcweir #include <svl/inethist.hxx>
30cdf0e10cSrcweir #include <svl/poolitem.hxx>
31cdf0e10cSrcweir #include <svl/flagitem.hxx>
32cdf0e10cSrcweir #include <unotools/useroptions.hxx>
33cdf0e10cSrcweir #include <sfx2/bindings.hxx>
34cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
36cdf0e10cSrcweir #include <sfx2/docfile.hxx>
37cdf0e10cSrcweir #include <sfx2/request.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <editeng/measfld.hxx>
40cdf0e10cSrcweir #include <editeng/editstat.hxx>
41cdf0e10cSrcweir #include <editeng/editeng.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <svx/dialogs.hrc>
44cdf0e10cSrcweir #include <svx/svdotext.hxx>
45cdf0e10cSrcweir #include <svx/svdpagv.hxx>
46cdf0e10cSrcweir #include <svx/svdopage.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <sfx2/sfxdlg.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
52cdf0e10cSrcweir 
53*5829e3e6Smseidel #define _SD_DLL // fuer SD_MOD()
54cdf0e10cSrcweir #include "sdmod.hxx"
55cdf0e10cSrcweir #include "sddll.hxx"
56cdf0e10cSrcweir #include "app.hrc"
57cdf0e10cSrcweir #include "glob.hrc"
58cdf0e10cSrcweir #include "strings.hrc"
59cdf0e10cSrcweir #include "res_bmp.hrc"
60cdf0e10cSrcweir #include "ViewShell.hxx"
61cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX
62cdf0e10cSrcweir #include "FrameView.hxx"
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir #include "sdattr.hxx"
65cdf0e10cSrcweir #include "tpoption.hrc"
66cdf0e10cSrcweir #include "optsitem.hxx"
67cdf0e10cSrcweir #include "DrawDocShell.hxx"
68cdf0e10cSrcweir #include "drawdoc.hxx"
69cdf0e10cSrcweir #include "Outliner.hxx"
70cdf0e10cSrcweir #include "sdresid.hxx"
71cdf0e10cSrcweir #include "pres.hxx"
72cdf0e10cSrcweir #include "DrawViewShell.hxx"
73cdf0e10cSrcweir #include "OutlineViewShell.hxx"
74cdf0e10cSrcweir #include "OutlineView.hxx"
75cdf0e10cSrcweir #include "ViewShellBase.hxx"
76cdf0e10cSrcweir #include "sdpage.hxx"
77cdf0e10cSrcweir #include "sdxfer.hxx"
78cdf0e10cSrcweir #include "sdabstdlg.hxx"
79cdf0e10cSrcweir #include "tpoption.hrc"
80cdf0e10cSrcweir #include "prntopts.hrc"
81cdf0e10cSrcweir #include <svl/intitem.hxx>
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /** retrieves the page that is currently painted. This will only be the master page
84cdf0e10cSrcweir 	if the current drawn view only shows the master page*/
GetCurrentPage(sd::ViewShell * pViewSh,EditFieldInfo * pInfo,bool & bMasterView)85cdf0e10cSrcweir static SdPage* GetCurrentPage( sd::ViewShell* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	if( !pInfo )
88cdf0e10cSrcweir 		return 0;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	bMasterView = false;
91cdf0e10cSrcweir 	SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
92cdf0e10cSrcweir 	SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	// special case, someone already set the current page on the EditFieldInfo
95cdf0e10cSrcweir 	// This is used from the svx::UnoGraphicsExporter f.e.
96cdf0e10cSrcweir 	if( pPage )
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir 		bMasterView = false;
99cdf0e10cSrcweir 		return pPage;
100cdf0e10cSrcweir 	}
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	// first try to check if we are inside the outline view
103cdf0e10cSrcweir 	sd::OutlineView* pSdView = NULL;
104cdf0e10cSrcweir 	if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
105cdf0e10cSrcweir 		pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
106cdf0e10cSrcweir 
107*5829e3e6Smseidel 	if (pSdView != NULL && (pOutliner == pSdView->GetOutliner()))
108*5829e3e6Smseidel 	{
109*5829e3e6Smseidel 		// outline mode
110*5829e3e6Smseidel 		int nPgNum = 0;
111*5829e3e6Smseidel 		Outliner* pOutl = pSdView->GetOutliner();
112*5829e3e6Smseidel 		long nPos = pInfo->GetPara();
113*5829e3e6Smseidel 		sal_uLong nParaPos = 0;
114cdf0e10cSrcweir 
115*5829e3e6Smseidel 		for( Paragraph* pPara = pOutl->GetParagraph( 0 ); pPara && nPos >= 0; pPara = pOutl->GetParagraph( ++nParaPos ), nPos-- )
116*5829e3e6Smseidel 		{
117*5829e3e6Smseidel 			if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
118*5829e3e6Smseidel 				nPgNum++;
119*5829e3e6Smseidel 		}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		pPage = pViewSh->GetDoc()->GetSdPage( (sal_uInt16)nPgNum, PK_STANDARD );
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir 	else
124cdf0e10cSrcweir 	{
125cdf0e10cSrcweir 		// draw mode, slide mode and preview. Get the processed page from the outliner
126cdf0e10cSrcweir 		if(pOutliner)
127cdf0e10cSrcweir 		{
128cdf0e10cSrcweir 			pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
129cdf0e10cSrcweir 		}
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 		// The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
132cdf0e10cSrcweir 		// is no longer needed. I debugged and checked all usages of PageNumber decompositions
133cdf0e10cSrcweir 		// which all use the new possibility of setting the visualized page at the SdrOutliner.
134cdf0e10cSrcweir 
135*5829e3e6Smseidel 		// if all else failed, get the current page from the object that is
13630acf5e8Spfg 		// currently formatted from the document
137cdf0e10cSrcweir 		if(!pPage)
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 			if( pTextObj )
142cdf0e10cSrcweir 			{
143cdf0e10cSrcweir 				pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
144cdf0e10cSrcweir 			}
145cdf0e10cSrcweir 		}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		if(pPage)
148cdf0e10cSrcweir 		{
149cdf0e10cSrcweir 			bMasterView = pPage && pPage->IsMasterPage();
150cdf0e10cSrcweir 		}
151cdf0e10cSrcweir 	}
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	return pPage;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir /*************************************************************************
157cdf0e10cSrcweir |* Link fuer CalcFieldValue des Outliners
158cdf0e10cSrcweir \************************************************************************/
159cdf0e10cSrcweir 
IMPL_LINK(SdModule,CalcFieldValueHdl,EditFieldInfo *,pInfo)160cdf0e10cSrcweir IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	if (pInfo)
163cdf0e10cSrcweir 	{
164cdf0e10cSrcweir 		const SvxFieldData* pField = pInfo->GetField().GetField();
165*5829e3e6Smseidel 		::sd::DrawDocShell* pDocShell = NULL;
166cdf0e10cSrcweir 		SdDrawDocument* pDoc = 0;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 		SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
169*5829e3e6Smseidel 		if( pSdrOutliner )
170*5829e3e6Smseidel 		{
171*5829e3e6Smseidel 			const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			if( pTextObj )
174cdf0e10cSrcweir 				pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 			if( pDoc )
177*5829e3e6Smseidel 				pDocShell = pDoc->GetDocSh();
178*5829e3e6Smseidel 		}
179cdf0e10cSrcweir 
180*5829e3e6Smseidel 		if( !pDocShell )
181*5829e3e6Smseidel 			pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 		const SvxDateField* pDateField = 0;
184cdf0e10cSrcweir 		const SvxExtTimeField* pExtTimeField = 0;
185cdf0e10cSrcweir 		const SvxExtFileField* pExtFileField = 0;
186cdf0e10cSrcweir 		const SvxAuthorField* pAuthorField = 0;
187cdf0e10cSrcweir 		const SvxURLField* pURLField = 0;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 		if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
192cdf0e10cSrcweir 			pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 		else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
195cdf0e10cSrcweir 		{
196cdf0e10cSrcweir 			LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
197cdf0e10cSrcweir 			pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
198cdf0e10cSrcweir 		}
199cdf0e10cSrcweir 		else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
200cdf0e10cSrcweir 		{
201cdf0e10cSrcweir 			if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
202cdf0e10cSrcweir 			{
203cdf0e10cSrcweir 				String aName;
204cdf0e10cSrcweir 				if( pDocShell->HasName() )
205cdf0e10cSrcweir 					aName = pDocShell->GetMedium()->GetName();
206cdf0e10cSrcweir 				else
207cdf0e10cSrcweir 					aName = pDocShell->GetName();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 				const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
210cdf0e10cSrcweir 			}
211cdf0e10cSrcweir 			pInfo->SetRepresentation( pExtFileField->GetFormatted() );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		}
214*5829e3e6Smseidel 		else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0 )
215cdf0e10cSrcweir 		{
216cdf0e10cSrcweir 			if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
217cdf0e10cSrcweir 			{
218*5829e3e6Smseidel 				SvtUserOptions aUserOptions;
219*5829e3e6Smseidel 				SvxAuthorField aAuthorField(
220*5829e3e6Smseidel 						aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
221*5829e3e6Smseidel 						pAuthorField->GetType(), pAuthorField->GetFormat() );
222cdf0e10cSrcweir 
223*5829e3e6Smseidel 				*(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
224cdf0e10cSrcweir 			}
225cdf0e10cSrcweir 			pInfo->SetRepresentation( pAuthorField->GetFormatted() );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 		}
228*5829e3e6Smseidel 		else if( dynamic_cast< const SvxPageField* >(pField) )
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			String aRepresentation;
231cdf0e10cSrcweir 			aRepresentation += sal_Unicode( ' ' );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 			::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
234cdf0e10cSrcweir 			if(pViewSh == NULL)
235*5829e3e6Smseidel 			{
236*5829e3e6Smseidel 				::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
237*5829e3e6Smseidel 				if(pBase)
238*5829e3e6Smseidel 					pViewSh = pBase->GetMainViewShell().get();
239*5829e3e6Smseidel 			}
240cdf0e10cSrcweir 			if( !pDoc && pViewSh )
241cdf0e10cSrcweir 				pDoc = pViewSh->GetDoc();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 			bool bMasterView;
244cdf0e10cSrcweir 			SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 			if( pPage && pDoc && !bMasterView )
247cdf0e10cSrcweir 			{
248cdf0e10cSrcweir 				int nPgNum;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 				if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
251cdf0e10cSrcweir 				{
252cdf0e10cSrcweir 					nPgNum = pViewSh->GetPrintedHandoutPageNum();
253cdf0e10cSrcweir 				}
254cdf0e10cSrcweir 				else
255cdf0e10cSrcweir 				{
256cdf0e10cSrcweir 					nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
257cdf0e10cSrcweir 				}
258cdf0e10cSrcweir 				aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
259cdf0e10cSrcweir 			}
260cdf0e10cSrcweir 			else
261cdf0e10cSrcweir 			{
262cdf0e10cSrcweir 				static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_NUMBER ) );
263cdf0e10cSrcweir 				aRepresentation = aNumberText;
264cdf0e10cSrcweir 			}
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 			pInfo->SetRepresentation( aRepresentation );
267cdf0e10cSrcweir 		}
268*5829e3e6Smseidel 		else if( dynamic_cast< const SvxPagesField* >(pField) )
269cdf0e10cSrcweir 		{
270cdf0e10cSrcweir 			String aRepresentation;
271cdf0e10cSrcweir 			aRepresentation += sal_Unicode( ' ' );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 			::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
274cdf0e10cSrcweir 			if(pViewSh == NULL)
275*5829e3e6Smseidel 			{
276*5829e3e6Smseidel 				::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
277*5829e3e6Smseidel 				if(pBase)
278*5829e3e6Smseidel 					pViewSh = pBase->GetMainViewShell().get();
279*5829e3e6Smseidel 			}
280cdf0e10cSrcweir 			if( !pDoc && pViewSh )
281cdf0e10cSrcweir 				pDoc = pViewSh->GetDoc();
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 			bool bMasterView;
284cdf0e10cSrcweir 			SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
285cdf0e10cSrcweir 
286*5829e3e6Smseidel 			sal_uInt16 nPageCount = 0;
287*5829e3e6Smseidel 
288*5829e3e6Smseidel 			if( !bMasterView )
289*5829e3e6Smseidel 			{
290*5829e3e6Smseidel 				if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
291*5829e3e6Smseidel 				{
292*5829e3e6Smseidel 					nPageCount = pViewSh->GetPrintedHandoutPageCount();
293*5829e3e6Smseidel 				}
294*5829e3e6Smseidel 				else if( pDoc )
295*5829e3e6Smseidel 				{
296*5829e3e6Smseidel 					nPageCount = (sal_uInt16)pDoc->GetSdPageCount(PK_STANDARD);
297*5829e3e6Smseidel 				}
298*5829e3e6Smseidel 			}
299*5829e3e6Smseidel 
300*5829e3e6Smseidel 			if( nPageCount > 0 )
301*5829e3e6Smseidel 			{
302cdf0e10cSrcweir 				aRepresentation = pDoc->CreatePageNumValue(nPageCount);
303cdf0e10cSrcweir 			}
304cdf0e10cSrcweir 			else
305cdf0e10cSrcweir 			{
306cdf0e10cSrcweir 				static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_COUNT ) );
307cdf0e10cSrcweir 				aRepresentation = aNumberText;
308cdf0e10cSrcweir 			}
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 			pInfo->SetRepresentation( aRepresentation );
311cdf0e10cSrcweir 		}
312cdf0e10cSrcweir 		else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
313cdf0e10cSrcweir 		{
314cdf0e10cSrcweir 			switch ( pURLField->GetFormat() )
315cdf0e10cSrcweir 			{
316cdf0e10cSrcweir 				case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
317cdf0e10cSrcweir 				case SVXURLFORMAT_REPR:
318cdf0e10cSrcweir 					pInfo->SetRepresentation( pURLField->GetRepresentation() );
319cdf0e10cSrcweir 					break;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 				case SVXURLFORMAT_URL:
322cdf0e10cSrcweir 					pInfo->SetRepresentation( pURLField->GetURL() );
323cdf0e10cSrcweir 					break;
324cdf0e10cSrcweir 			}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 			String aURL = pURLField->GetURL();
327cdf0e10cSrcweir 
328*5829e3e6Smseidel 			svtools::ColorConfig aConfig;
329*5829e3e6Smseidel 			svtools::ColorConfigEntry eEntry =
330*5829e3e6Smseidel 				INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
331cdf0e10cSrcweir 			pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
332cdf0e10cSrcweir 		}
333cdf0e10cSrcweir 		else if ( dynamic_cast< const SdrMeasureField* >(pField))
334cdf0e10cSrcweir 		{
335cdf0e10cSrcweir 			pInfo->ClearFldColor();
336cdf0e10cSrcweir 		}
337cdf0e10cSrcweir 		else
338cdf0e10cSrcweir 		{
339cdf0e10cSrcweir 			String aRepresentation;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 			bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
342cdf0e10cSrcweir 			bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
343cdf0e10cSrcweir 			bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 			if( bHeaderField || bFooterField || bDateTimeField )
346cdf0e10cSrcweir 			{
347cdf0e10cSrcweir 				sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
348cdf0e10cSrcweir 				bool bMasterView = false;
349cdf0e10cSrcweir 				SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 				if( (pPage == NULL) || bMasterView )
352cdf0e10cSrcweir 				{
353cdf0e10cSrcweir 					if( bHeaderField )
354cdf0e10cSrcweir 					{
355cdf0e10cSrcweir 						static String aHeaderStr( SdResId( STR_FIELD_PLACEHOLDER_HEADER ) );
356cdf0e10cSrcweir 						aRepresentation = aHeaderStr;
357cdf0e10cSrcweir 					}
358cdf0e10cSrcweir 					else if (bFooterField )
359cdf0e10cSrcweir 					{
360cdf0e10cSrcweir 						static String aFooterStr( SdResId( STR_FIELD_PLACEHOLDER_FOOTER ) );
361cdf0e10cSrcweir 						aRepresentation = aFooterStr;
362cdf0e10cSrcweir 					}
363cdf0e10cSrcweir 					else if (bDateTimeField )
364cdf0e10cSrcweir 					{
365cdf0e10cSrcweir 						static String aDateTimeStr( SdResId( STR_FIELD_PLACEHOLDER_DATETIME ) );
366cdf0e10cSrcweir 						aRepresentation = aDateTimeStr;
367cdf0e10cSrcweir 					}
368cdf0e10cSrcweir 				}
369cdf0e10cSrcweir 				else
370cdf0e10cSrcweir 				{
371cdf0e10cSrcweir 					const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 					if( bHeaderField )
374cdf0e10cSrcweir 					{
375cdf0e10cSrcweir 						aRepresentation = rSettings.maHeaderText;
376cdf0e10cSrcweir 					}
377cdf0e10cSrcweir 					else if( bFooterField )
378cdf0e10cSrcweir 					{
379cdf0e10cSrcweir 						aRepresentation = rSettings.maFooterText;
380cdf0e10cSrcweir 					}
381cdf0e10cSrcweir 					else if( bDateTimeField )
382cdf0e10cSrcweir 					{
383cdf0e10cSrcweir 						if( rSettings.mbDateTimeIsFixed )
384cdf0e10cSrcweir 						{
385cdf0e10cSrcweir 							aRepresentation = rSettings.maDateTimeText;
386cdf0e10cSrcweir 						}
387cdf0e10cSrcweir 						else
388cdf0e10cSrcweir 						{
389cdf0e10cSrcweir 							Date aDate;
390cdf0e10cSrcweir 							Time aTime;
391cdf0e10cSrcweir 							LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
392cdf0e10cSrcweir 							aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
393cdf0e10cSrcweir 						}
394cdf0e10cSrcweir 					}
395cdf0e10cSrcweir 				}
396cdf0e10cSrcweir 			}
397cdf0e10cSrcweir 			else
398cdf0e10cSrcweir 			{
399cdf0e10cSrcweir 				DBG_ERROR("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
400cdf0e10cSrcweir 			}
401cdf0e10cSrcweir 
402*5829e3e6Smseidel 			if( aRepresentation.Len() == 0 ) // TODO: Edit engine doesn't handle empty fields?
403cdf0e10cSrcweir 				aRepresentation += sal_Unicode( ' ' );
404cdf0e10cSrcweir 			pInfo->SetRepresentation( aRepresentation );
405cdf0e10cSrcweir 		}
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	return(0);
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 
413cdf0e10cSrcweir /*************************************************************************
414cdf0e10cSrcweir |* virt. Methoden fuer Optionendialog
415cdf0e10cSrcweir \************************************************************************/
CreateItemSet(sal_uInt16 nSlot)416cdf0e10cSrcweir SfxItemSet*	 SdModule::CreateItemSet( sal_uInt16 nSlot )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	::sd::FrameView* pFrameView = NULL;
419cdf0e10cSrcweir 	::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
420cdf0e10cSrcweir 	SdDrawDocument* pDoc = NULL;
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	// Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
423cdf0e10cSrcweir 	DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
424cdf0e10cSrcweir 	if( nSlot == SID_SD_GRAPHIC_OPTIONS )
425cdf0e10cSrcweir 		eDocType = DOCUMENT_TYPE_DRAW;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	::sd::ViewShell* pViewShell = NULL;
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 	if (pDocSh)
430cdf0e10cSrcweir 	{
431cdf0e10cSrcweir 		pDoc = pDocSh->GetDoc();
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		// Wenn der Optionsdialog zum Dokumenttyp identisch ist,
434cdf0e10cSrcweir 		// kann auch die FrameView mit uebergeben werden:
435cdf0e10cSrcweir 		if( pDoc && eDocType == pDoc->GetDocumentType() )
436cdf0e10cSrcweir 			pFrameView = pDocSh->GetFrameView();
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 		pViewShell = pDocSh->GetViewShell();
439cdf0e10cSrcweir 		if (pViewShell != NULL)
440*5829e3e6Smseidel 			pViewShell->WriteFrameViewData();
441cdf0e10cSrcweir 	}
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	SdOptions* pOptions = GetSdOptions(eDocType);
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	// Pool hat standardmaessig MapUnit Twips (Baeh!)
446cdf0e10cSrcweir 	SfxItemPool& rPool = GetPool();
447cdf0e10cSrcweir 	rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 	SfxItemSet*	 pRet = new SfxItemSet( rPool,
450cdf0e10cSrcweir 						SID_ATTR_METRIC, SID_ATTR_METRIC,
451cdf0e10cSrcweir 						SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 						ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
454cdf0e10cSrcweir 						ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
455cdf0e10cSrcweir 						ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 						ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 						ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 						ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 						SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
464cdf0e10cSrcweir 						0 );
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	// TP_OPTIONS_LAYOUT:
467cdf0e10cSrcweir 	pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 	sal_uInt16 nDefTab = 0;
470cdf0e10cSrcweir 	if( pFrameView)
471cdf0e10cSrcweir 		nDefTab = pDoc->GetDefaultTabulator();
472cdf0e10cSrcweir 	else
473cdf0e10cSrcweir 		nDefTab = pOptions->GetDefTab();
474cdf0e10cSrcweir 	pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	FieldUnit nMetric = (FieldUnit)0xffff;
477cdf0e10cSrcweir 	if( pFrameView)
478cdf0e10cSrcweir 		nMetric = pDoc->GetUIUnit();
479cdf0e10cSrcweir 	else
480cdf0e10cSrcweir 		nMetric = (FieldUnit)pOptions->GetMetric();
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	if( nMetric == (FieldUnit)0xffff )
483cdf0e10cSrcweir 		nMetric = GetFieldUnit();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 	// TP_OPTIONS_CONTENTS:
488cdf0e10cSrcweir 	pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 	// TP_OPTIONS_MISC:
491*5829e3e6Smseidel 	SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
492*5829e3e6Smseidel 	if ( pFrameView )
493*5829e3e6Smseidel 	{
494*5829e3e6Smseidel 		aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
495*5829e3e6Smseidel 		aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
496*5829e3e6Smseidel 			(sal_uInt16)pDoc->GetPrinterIndependentLayout());
497*5829e3e6Smseidel 	}
498cdf0e10cSrcweir 	pRet->Put( aSdOptionsMiscItem );
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	// TP_OPTIONS_SNAP:
502cdf0e10cSrcweir 	pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	// TP_SCALE:
505cdf0e10cSrcweir 	sal_uInt32 nW = 10L;
506cdf0e10cSrcweir 	sal_uInt32 nH = 10L;
507cdf0e10cSrcweir 	sal_Int32  nX;
508cdf0e10cSrcweir 	sal_Int32  nY;
509cdf0e10cSrcweir 	if( pDocSh )
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir 		SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
512cdf0e10cSrcweir 		Size aSize(pPage->GetSize());
513cdf0e10cSrcweir 		nW = aSize.Width();
514cdf0e10cSrcweir 		nH = aSize.Height();
515cdf0e10cSrcweir 	}
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	if(pFrameView)
518cdf0e10cSrcweir 	{
519*5829e3e6Smseidel 		const Fraction& rFraction = pDoc->GetUIScale();
520cdf0e10cSrcweir 		nX=rFraction.GetNumerator();
521cdf0e10cSrcweir 		nY=rFraction.GetDenominator();
522cdf0e10cSrcweir 	}
523cdf0e10cSrcweir 	else
524cdf0e10cSrcweir 	{
525cdf0e10cSrcweir 		// Optionen aus Configdatei holen
526cdf0e10cSrcweir 		pOptions->GetScale( nX, nY );
527cdf0e10cSrcweir 	}
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
530cdf0e10cSrcweir 	pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
531cdf0e10cSrcweir 	pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
532cdf0e10cSrcweir 	pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	// TP_OPTIONS_PRINT:
536cdf0e10cSrcweir 	pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	// RID_SVXPAGE_GRID:
539cdf0e10cSrcweir 	pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	return pRet;
542cdf0e10cSrcweir }
ApplyItemSet(sal_uInt16 nSlot,const SfxItemSet & rSet)543cdf0e10cSrcweir void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir 	const SfxPoolItem*	pItem = NULL;
546cdf0e10cSrcweir 	sal_Bool bNewDefTab = sal_False;
547cdf0e10cSrcweir 	sal_Bool bNewPrintOptions = sal_False;
548cdf0e10cSrcweir 	sal_Bool bMiscOptions = sal_False;
549cdf0e10cSrcweir 
550cdf0e10cSrcweir 	::sd::FrameView* pFrameView = NULL;
551cdf0e10cSrcweir 	::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
552cdf0e10cSrcweir 	SdDrawDocument* pDoc = NULL;
553cdf0e10cSrcweir 	// Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
554cdf0e10cSrcweir 	DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
555cdf0e10cSrcweir 	if( nSlot == SID_SD_GRAPHIC_OPTIONS )
556cdf0e10cSrcweir 		eDocType = DOCUMENT_TYPE_DRAW;
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 	::sd::ViewShell* pViewShell = NULL;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 	if (pDocSh)
561cdf0e10cSrcweir 	{
562cdf0e10cSrcweir 		pDoc = pDocSh->GetDoc();
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 		// Wenn der Optionsdialog zum Dokumenttyp identisch ist,
565cdf0e10cSrcweir 		// kann auch die FrameView mit uebergeben werden:
566cdf0e10cSrcweir 		if( pDoc && eDocType == pDoc->GetDocumentType() )
567cdf0e10cSrcweir 			pFrameView = pDocSh->GetFrameView();
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 		pViewShell = pDocSh->GetViewShell();
570*5829e3e6Smseidel 		if (pViewShell != NULL)
571*5829e3e6Smseidel 			pViewShell->WriteFrameViewData();
572cdf0e10cSrcweir 	}
573cdf0e10cSrcweir 	SdOptions* pOptions = GetSdOptions(eDocType);
574cdf0e10cSrcweir 	// Raster
575cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
576cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pItem ))
577cdf0e10cSrcweir 	{
578cdf0e10cSrcweir 		const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
579cdf0e10cSrcweir 		pGridItem->SetOptions( pOptions );
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 	// Layout
583cdf0e10cSrcweir 	const SdOptionsLayoutItem* pLayoutItem = NULL;
584cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
585cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pLayoutItem ))
586cdf0e10cSrcweir 	{
587cdf0e10cSrcweir 		pLayoutItem->SetOptions( pOptions );
588cdf0e10cSrcweir 	}
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 	// Metric
591cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, sal_False, &pItem ) )
592cdf0e10cSrcweir 	{
593cdf0e10cSrcweir 		if( pDoc && eDocType == pDoc->GetDocumentType() )
594cdf0e10cSrcweir 			PutItem( *pItem );
595cdf0e10cSrcweir 		pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
596cdf0e10cSrcweir 	}
597cdf0e10cSrcweir 	sal_uInt16 nDefTab = pOptions->GetDefTab();
598cdf0e10cSrcweir 	// Default-Tabulator
599cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, sal_False, &pItem ) )
600cdf0e10cSrcweir 	{
601cdf0e10cSrcweir 		nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
602cdf0e10cSrcweir 		pOptions->SetDefTab( nDefTab );
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 		bNewDefTab = sal_True;
605cdf0e10cSrcweir 	}
606cdf0e10cSrcweir 
607*5829e3e6Smseidel 	// Massstab
608*5829e3e6Smseidel 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, sal_False, &pItem ) )
609*5829e3e6Smseidel 	{
610*5829e3e6Smseidel 		sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
611*5829e3e6Smseidel 		if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, sal_False, &pItem ) )
612*5829e3e6Smseidel 		{
613*5829e3e6Smseidel 			sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
614*5829e3e6Smseidel 			pOptions->SetScale( nX, nY );
615*5829e3e6Smseidel 
616*5829e3e6Smseidel 			// #92067# Apply to document only if doc type match
617*5829e3e6Smseidel 			if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
618*5829e3e6Smseidel 			{
619*5829e3e6Smseidel 				pDoc->SetUIScale( Fraction( nX, nY ) );
620*5829e3e6Smseidel 				if( pViewShell )
621*5829e3e6Smseidel 					pViewShell->SetRuler( pViewShell->HasRuler() );
622*5829e3e6Smseidel 			}
623*5829e3e6Smseidel 		}
624*5829e3e6Smseidel 	}
625*5829e3e6Smseidel 
626*5829e3e6Smseidel 	// Contents
627cdf0e10cSrcweir 	const SdOptionsContentsItem* pContentsItem = NULL;
628cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
629cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pContentsItem ))
630cdf0e10cSrcweir 	{
631cdf0e10cSrcweir 		pContentsItem->SetOptions( pOptions );
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir 
634*5829e3e6Smseidel 	// Misc
635cdf0e10cSrcweir 	const SdOptionsMiscItem* pMiscItem = NULL;
636cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
637cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pMiscItem ))
638cdf0e10cSrcweir 	{
639cdf0e10cSrcweir 		pMiscItem->SetOptions( pOptions );
640cdf0e10cSrcweir 		bMiscOptions = sal_True;
641cdf0e10cSrcweir 	}
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 	// Fangen/Einrasten
644cdf0e10cSrcweir 	const SdOptionsSnapItem* pSnapItem = NULL;
645cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
646cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pSnapItem ))
647cdf0e10cSrcweir 	{
648cdf0e10cSrcweir 		pSnapItem->SetOptions( pOptions );
649cdf0e10cSrcweir 	}
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 	SfxItemSet aPrintSet( GetPool(),
652cdf0e10cSrcweir 					SID_PRINTER_NOTFOUND_WARN,	SID_PRINTER_NOTFOUND_WARN,
653cdf0e10cSrcweir 					SID_PRINTER_CHANGESTODOC,	SID_PRINTER_CHANGESTODOC,
654cdf0e10cSrcweir 					ATTR_OPTIONS_PRINT, 		ATTR_OPTIONS_PRINT,
655cdf0e10cSrcweir 					0 );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 	// Drucken
658cdf0e10cSrcweir 	const SdOptionsPrintItem* pPrintItem = NULL;
659cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
660cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**) &pPrintItem ))
661cdf0e10cSrcweir 	{
662cdf0e10cSrcweir 		pPrintItem->SetOptions( pOptions );
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		// PrintOptionsSet setzen
665cdf0e10cSrcweir 		SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
666cdf0e10cSrcweir 		SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
667cdf0e10cSrcweir 		sal_uInt16		nFlags = 0;
668cdf0e10cSrcweir 
669*5829e3e6Smseidel 		nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
670*5829e3e6Smseidel 				 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
671cdf0e10cSrcweir 		aFlagItem.SetValue( nFlags );
672cdf0e10cSrcweir 
673cdf0e10cSrcweir 		aPrintSet.Put( aPrintItem );
674cdf0e10cSrcweir 		aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
675cdf0e10cSrcweir 		aPrintSet.Put( aFlagItem );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 		bNewPrintOptions = sal_True;
678cdf0e10cSrcweir 	}
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 	// Nur, wenn auch der Dokumenttyp uebereinstimmt...
681cdf0e10cSrcweir 	if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
682cdf0e10cSrcweir 	{
683cdf0e10cSrcweir 		if( bNewPrintOptions )
684cdf0e10cSrcweir 		{
685cdf0e10cSrcweir 			pDocSh->GetPrinter(sal_True)->SetOptions( aPrintSet );
686cdf0e10cSrcweir 		}
687cdf0e10cSrcweir 
688*5829e3e6Smseidel 		// Am Modell den DefTab setzen
689cdf0e10cSrcweir 		if( bNewDefTab )
690cdf0e10cSrcweir 		{
691cdf0e10cSrcweir 			SdDrawDocument* pDocument = pDocSh->GetDoc();
692cdf0e10cSrcweir 			pDocument->SetDefaultTabulator( nDefTab );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 			::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
695cdf0e10cSrcweir 			if( pOutl )
696cdf0e10cSrcweir 				pOutl->SetDefTab( nDefTab );
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 			::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( sal_False );
699cdf0e10cSrcweir 			if( pInternalOutl )
700cdf0e10cSrcweir 				pInternalOutl->SetDefTab( nDefTab );
701cdf0e10cSrcweir 		}
702cdf0e10cSrcweir 		if ( bMiscOptions )
703cdf0e10cSrcweir 		{
704*5829e3e6Smseidel 			pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
705cdf0e10cSrcweir 			sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
706cdf0e10cSrcweir 			sal_uInt32 nCntrl;
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 			SdDrawDocument* pDocument = pDocSh->GetDoc();
70946d2a04eSHerbert Dürr 			SdrOutliner& rOutl = pDocument->GetDrawOutliner( NULL );
710cdf0e10cSrcweir 			nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
711cdf0e10cSrcweir 			rOutl.SetControlWord( nCntrl | nSum );
712cdf0e10cSrcweir 			::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
713cdf0e10cSrcweir 			if( pOutl )
714cdf0e10cSrcweir 			{
715cdf0e10cSrcweir 				nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
716cdf0e10cSrcweir 				pOutl->SetControlWord( nCntrl | nSum );
717cdf0e10cSrcweir 			}
718cdf0e10cSrcweir 			pOutl = pDocument->GetInternalOutliner( sal_False );
719cdf0e10cSrcweir 			if( pOutl )
720cdf0e10cSrcweir 			{
721cdf0e10cSrcweir 				nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
722cdf0e10cSrcweir 				pOutl->SetControlWord( nCntrl | nSum );
723cdf0e10cSrcweir 			}
724cdf0e10cSrcweir 
725*5829e3e6Smseidel 			// Set printer independent layout mode.
726cdf0e10cSrcweir 			if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
727*5829e3e6Smseidel 				pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
728cdf0e10cSrcweir 		}
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	pOptions->StoreConfig();
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	// Nur, wenn auch der Dokumenttyp uebereinstimmt...
734cdf0e10cSrcweir 	if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
735cdf0e10cSrcweir 	{
736cdf0e10cSrcweir 		FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
737cdf0e10cSrcweir 		pDoc->SetUIUnit(eUIUnit);
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 		if (pViewShell)
740cdf0e10cSrcweir 		{
741cdf0e10cSrcweir 			// #74495# make sure no one is in text edit mode, cause there
742cdf0e10cSrcweir 			// are some pointers remembered else (!)
743cdf0e10cSrcweir 			if(pViewShell->GetView())
744cdf0e10cSrcweir 				pViewShell->GetView()->SdrEndTextEdit();
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 			::sd::FrameView* pFrame = pViewShell->GetFrameView();
747cdf0e10cSrcweir 			pFrame->Update(pOptions);
748cdf0e10cSrcweir 			pViewShell->ReadFrameViewData(pFrame);
749cdf0e10cSrcweir 			pViewShell->SetUIUnit(eUIUnit);
750cdf0e10cSrcweir 			pViewShell->SetDefTabHRuler( nDefTab );
751cdf0e10cSrcweir 		}
752cdf0e10cSrcweir 	}
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 	if( pViewShell && pViewShell->GetViewFrame() )
755cdf0e10cSrcweir 		pViewShell->GetViewFrame()->GetBindings().InvalidateAll( sal_True );
756cdf0e10cSrcweir }
757cdf0e10cSrcweir 
CreateTabPage(sal_uInt16 nId,Window * pParent,const SfxItemSet & rSet)758cdf0e10cSrcweir SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
759cdf0e10cSrcweir {
760cdf0e10cSrcweir 	SfxTabPage* pRet = NULL;
761cdf0e10cSrcweir 	SfxAllItemSet aSet(*(rSet.GetPool()));
762cdf0e10cSrcweir 	SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
763cdf0e10cSrcweir 	if( pFact )
764cdf0e10cSrcweir 	{
765cdf0e10cSrcweir 		switch(nId)
766cdf0e10cSrcweir 		{
767cdf0e10cSrcweir 			case SID_SD_TP_CONTENTS:
768cdf0e10cSrcweir 			case SID_SI_TP_CONTENTS:
769cdf0e10cSrcweir 			{	::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
770cdf0e10cSrcweir 				if( fnCreatePage )
771cdf0e10cSrcweir 					pRet = (*fnCreatePage)( pParent, rSet );
772cdf0e10cSrcweir 			}
773cdf0e10cSrcweir 			break;
774cdf0e10cSrcweir 			case SID_SD_TP_SNAP:
775cdf0e10cSrcweir 			case SID_SI_TP_SNAP:
776cdf0e10cSrcweir 			{	::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
777cdf0e10cSrcweir 				if( fnCreatePage )
778cdf0e10cSrcweir 					pRet = (*fnCreatePage)( pParent, rSet );
779cdf0e10cSrcweir 			}
780cdf0e10cSrcweir 			break;
781cdf0e10cSrcweir 			case SID_SD_TP_PRINT:
782cdf0e10cSrcweir 			case SID_SI_TP_PRINT:
783cdf0e10cSrcweir 			{
784cdf0e10cSrcweir 				::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
785cdf0e10cSrcweir 				if( fnCreatePage )
786cdf0e10cSrcweir 				{
787cdf0e10cSrcweir 					pRet = (*fnCreatePage)( pParent, rSet );
788cdf0e10cSrcweir 					if(SID_SD_TP_PRINT == nId)
789cdf0e10cSrcweir 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
790cdf0e10cSrcweir 					pRet->PageCreated(aSet);
791cdf0e10cSrcweir 				}
792cdf0e10cSrcweir 			}
793cdf0e10cSrcweir 			break;
794cdf0e10cSrcweir 			case SID_SI_TP_MISC:
795cdf0e10cSrcweir 			case SID_SD_TP_MISC:
796cdf0e10cSrcweir 			{
797cdf0e10cSrcweir 				::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
798cdf0e10cSrcweir 				if( fnCreatePage )
799cdf0e10cSrcweir 				{
800cdf0e10cSrcweir 					pRet = (*fnCreatePage)( pParent, rSet );
801cdf0e10cSrcweir 					if(SID_SD_TP_MISC == nId)
802cdf0e10cSrcweir 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
803cdf0e10cSrcweir 					else
804cdf0e10cSrcweir 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
805cdf0e10cSrcweir 					pRet->PageCreated(aSet);
806cdf0e10cSrcweir 				}
807cdf0e10cSrcweir 			}
808cdf0e10cSrcweir 			break;
809cdf0e10cSrcweir 			case RID_OFA_TP_INTERNATIONAL_SD:
810cdf0e10cSrcweir 			case RID_OFA_TP_INTERNATIONAL_IMPR:
811cdf0e10cSrcweir 			case RID_SVXPAGE_TEXTANIMATION :
812cdf0e10cSrcweir 			{
813cdf0e10cSrcweir 				SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
814cdf0e10cSrcweir 				if ( pSfxFact )
815cdf0e10cSrcweir 				{
816cdf0e10cSrcweir 					::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
817cdf0e10cSrcweir 					if ( fnCreatePage )
818cdf0e10cSrcweir 						pRet = (*fnCreatePage)( pParent, rSet );
819cdf0e10cSrcweir 				}
820cdf0e10cSrcweir 			}
821cdf0e10cSrcweir 			break;
822cdf0e10cSrcweir 		}
823cdf0e10cSrcweir 		DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
824cdf0e10cSrcweir 	}
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	return pRet;
827cdf0e10cSrcweir }
828