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