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