1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27
28 #include <hintids.hxx>
29
30 #include <tools/datetime.hxx>
31 #include <vcl/svapp.hxx>
32 #include <unotools/collatorwrapper.hxx>
33 #include <svl/urihelper.hxx>
34 #include <svl/stritem.hxx>
35 #include <unotools/syslocale.hxx>
36 #include <sfx2/app.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/docfilt.hxx>
39 #include <editeng/pmdlitem.hxx>
40 #ifndef _SVX_TSTPITEM_HXX //autogen
41 #include <editeng/tstpitem.hxx>
42 #endif
43 #include <editeng/boxitem.hxx>
44 #include <editeng/sizeitem.hxx>
45 #include <svx/pageitem.hxx>
46 #include <editeng/lrspitem.hxx>
47 #include <svl/style.hxx>
48 #ifndef _VCL_LSTBOX_HXX //autogen
49 #include <vcl/lstbox.hxx>
50 #endif
51 #include <unotools/localedatawrapper.hxx>
52 #include <com/sun/star/frame/XDispatch.hpp>
53 #include <com/sun/star/frame/XDispatchProvider.hpp>
54 #include <com/sun/star/util/XURLTransformer.hpp>
55 #include <comphelper/processfactory.hxx>
56 #include <sfx2/viewfrm.hxx>
57 #include <fmtornt.hxx>
58 #include <tabcol.hxx>
59 #include <edtwin.hxx>
60 #include <fmtfsize.hxx>
61 #include <fmthdft.hxx>
62 #include <fmtpdsc.hxx>
63 #include <wview.hxx>
64 #include <uiitems.hxx>
65 #ifndef _DOCSH_HXX
66 #include <docsh.hxx>
67 #endif
68 #include <wrtsh.hxx>
69 #include <swmodule.hxx>
70 #ifndef _VIEW_HXX
71 #include <view.hxx>
72 #endif
73 #include <uitool.hxx>
74 #include <frmatr.hxx>
75 #include <paratr.hxx>
76 #include <fmtcol.hxx>
77 #include <poolfmt.hxx>
78 #include "usrpref.hxx"
79
80 #ifndef _ERROR_H
81 #include <error.h>
82 #endif
83 #ifndef _CMDID_H
84 #include <cmdid.h>
85 #endif
86 #ifndef _GLOBALS_HRC
87 #include <globals.hrc>
88 #endif
89 #ifndef _UTLUI_HRC
90 #include <utlui.hrc>
91 #endif
92 #include <doc.hxx>
93 #include <docary.hxx>
94 #include <charfmt.hxx>
95 #include <SwStyleNameMapper.hxx>
96 // 50 cm 28350
97 //
98 #define MAXHEIGHT 28350
99 #define MAXWIDTH 28350
100
101 using namespace ::com::sun::star;
102 /*--------------------------------------------------------------------
103 Beschreibung: Allgemeine List von StringPointern
104 --------------------------------------------------------------------*/
105
106
107 /*--------------------------------------------------------------------
108 Beschreibung: Metric umschalten
109 --------------------------------------------------------------------*/
110
111
SetMetric(MetricFormatter & rCtrl,FieldUnit eUnit)112 void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
113 {
114 SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP));
115 SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP));
116
117 rCtrl.SetUnit(eUnit);
118
119 rCtrl.SetMin(nMin, FUNIT_TWIP);
120 rCtrl.SetMax(nMax, FUNIT_TWIP);
121 }
122
123 /*--------------------------------------------------------------------
124 Beschreibung: Boxinfo-Attribut setzen
125 --------------------------------------------------------------------*/
126
127
PrepareBoxInfo(SfxItemSet & rSet,const SwWrtShell & rSh)128 void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
129 {
130 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
131 const SfxPoolItem *pBoxInfo;
132 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
133 sal_True, &pBoxInfo))
134 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
135
136 // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
137 rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert
138 aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1);
139 // Abstandsfeld immer anzeigen
140 aBoxInfo.SetDist ((sal_Bool) sal_True);
141 // Minimalgroesse in Tabellen und Absaetzen setzen
142 aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
143 // Default-Abstand immer setzen
144 aBoxInfo.SetDefDist (MIN_BORDER_DIST);
145 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
146 aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode());
147
148 rSet.Put(aBoxInfo);
149 }
150
151 /*--------------------------------------------------------------------
152 Beschreibung: Header Footer fuellen
153 --------------------------------------------------------------------*/
154
155
FillHdFt(SwFrmFmt * pFmt,const SfxItemSet & rSet)156 void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet)
157 {
158 SwAttrSet aSet(pFmt->GetAttrSet());
159 aSet.Put(rSet);
160
161 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
162 const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC);
163
164 // Groesse umsetzen
165 //
166 SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE,
167 rSize.GetSize().Width(),
168 rSize.GetSize().Height());
169 aSet.Put(aFrmSize);
170 pFmt->SetFmtAttr(aSet);
171 }
172
173 /*--------------------------------------------------------------------
174 Beschreibung: PageDesc <-> in Sets wandeln und zurueck
175 --------------------------------------------------------------------*/
176
177
ItemSetToPageDesc(const SfxItemSet & rSet,SwPageDesc & rPageDesc)178 void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
179 {
180 SwFrmFmt& rMaster = rPageDesc.GetMaster();
181
182 // alle allgemeinen Rahmen-Attribute uebertragen
183 //
184 rMaster.SetFmtAttr(rSet);
185
186 // PageData
187 //
188 if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET)
189 {
190 const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
191
192 sal_uInt16 nUse = (sal_uInt16)rPageItem.GetPageUsage();
193 if(nUse & 0x04)
194 nUse |= 0x03;
195 if(nUse)
196 rPageDesc.SetUseOn( (UseOnPage) nUse );
197 rPageDesc.SetLandscape(rPageItem.IsLandscape());
198 SvxNumberType aNumType;
199 aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) );
200 rPageDesc.SetNumType(aNumType);
201 }
202 // Groesse
203 //
204 if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET)
205 {
206 const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
207 SwFmtFrmSize aSize(ATT_FIX_SIZE);
208 aSize.SetSize(rSizeItem.GetSize());
209 rMaster.SetFmtAttr(aSize);
210 }
211 // Kopzeilen-Attribute auswerten
212 //
213 const SfxPoolItem* pItem;
214 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET,
215 sal_False, &pItem ) )
216 {
217 const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
218 const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON);
219
220 if(rHeaderOn.GetValue())
221 {
222 // Werte uebernehmen
223 if(!rMaster.GetHeader().IsActive())
224 rMaster.SetFmtAttr(SwFmtHeader(sal_True));
225
226 // Das Headerformat rausholen und anpassen
227 //
228 SwFmtHeader aHeaderFmt(rMaster.GetHeader());
229 SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt();
230 ASSERT(pHeaderFmt != 0, "kein HeaderFormat");
231
232 ::FillHdFt(pHeaderFmt, rHeaderSet);
233
234 rPageDesc.ChgHeaderShare(((const SfxBoolItem&)
235 rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
236 }
237 else
238 { // Header ausschalten
239 //
240 if(rMaster.GetHeader().IsActive())
241 {
242 rMaster.SetFmtAttr(SwFmtHeader(sal_Bool(sal_False)));
243 rPageDesc.ChgHeaderShare(sal_False);
244 }
245 }
246 }
247
248 // Fusszeilen-Attribute auswerten
249 //
250 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET,
251 sal_False, &pItem ) )
252 {
253 const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
254 const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON);
255
256 if(rFooterOn.GetValue())
257 {
258 // Werte uebernehmen
259 if(!rMaster.GetFooter().IsActive())
260 rMaster.SetFmtAttr(SwFmtFooter(sal_True));
261
262 // Das Footerformat rausholen und anpassen
263 //
264 SwFmtFooter aFooterFmt(rMaster.GetFooter());
265 SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt();
266 ASSERT(pFooterFmt != 0, "kein FooterFormat");
267
268 ::FillHdFt(pFooterFmt, rFooterSet);
269
270 rPageDesc.ChgFooterShare(((const SfxBoolItem&)
271 rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
272 }
273 else
274 { // Footer ausschalten
275 //
276 if(rMaster.GetFooter().IsActive())
277 {
278 rMaster.SetFmtAttr(SwFmtFooter(sal_Bool(sal_False)));
279 rPageDesc.ChgFooterShare(sal_False);
280 }
281 }
282 }
283
284 // Fussnoten
285 //
286 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO,
287 sal_False, &pItem ) )
288 rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() );
289
290
291 //
292 // Columns
293 //
294
295 // Registerhaltigkeit
296
297 if(SFX_ITEM_SET == rSet.GetItemState(
298 SID_SWREGISTER_MODE, sal_False, &pItem))
299 {
300 sal_Bool bSet = ((const SfxBoolItem*)pItem)->GetValue();
301 if(!bSet)
302 rPageDesc.SetRegisterFmtColl(0);
303 else if(SFX_ITEM_SET == rSet.GetItemState(
304 SID_SWREGISTER_COLLECTION, sal_False, &pItem))
305 {
306 const String& rColl = ((const SfxStringItem*)pItem)->GetValue();
307 SwDoc& rDoc = *rMaster.GetDoc();
308 SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
309 if( !pColl )
310 {
311 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
312 if( USHRT_MAX != nId )
313 pColl = rDoc.GetTxtCollFromPool( nId );
314 else
315 pColl = rDoc.MakeTxtFmtColl( rColl,
316 (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() );
317 }
318 if( pColl )
319 pColl->SetFmtAttr( SwRegisterItem ( sal_True ));
320 rPageDesc.SetRegisterFmtColl( pColl );
321 }
322 }
323 }
324
325 /*--------------------------------------------------------------------
326 Beschreibung:
327 --------------------------------------------------------------------*/
328
329
PageDescToItemSet(const SwPageDesc & rPageDesc,SfxItemSet & rSet)330 void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
331 {
332 const SwFrmFmt& rMaster = rPageDesc.GetMaster();
333
334 // Seitendaten
335 //
336 SvxPageItem aPageItem(SID_ATTR_PAGE);
337 aPageItem.SetDescName(rPageDesc.GetName());
338 aPageItem.SetPageUsage(rPageDesc.GetUseOn());
339 aPageItem.SetLandscape(rPageDesc.GetLandscape());
340 aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
341 rSet.Put(aPageItem);
342
343 // Groesse
344 SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize());
345 rSet.Put(aSizeItem);
346
347 // Maximale Groesse
348 SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT));
349 rSet.Put(aMaxSizeItem);
350
351 // Raender, Umrandung und das andere Zeug
352 //
353 rSet.Put(rMaster.GetAttrSet());
354
355 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
356 const SfxPoolItem *pBoxInfo;
357 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
358 sal_True, &pBoxInfo) )
359 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
360
361 aBoxInfo.SetTable( sal_False );
362 // Abstandsfeld immer anzeigen
363 aBoxInfo.SetDist( sal_True);
364 // Minimalgroesse in Tabellen und Absaetzen setzen
365 aBoxInfo.SetMinDist( sal_False );
366 // Default-Abstand immer setzen
367 aBoxInfo.SetDefDist( MIN_BORDER_DIST );
368 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
369 aBoxInfo.SetValid( VALID_DISABLE );
370 rSet.Put( aBoxInfo );
371
372
373 SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, aEmptyStr);
374 if(rPageDesc.GetFollow())
375 aFollow.SetValue(rPageDesc.GetFollow()->GetName());
376 rSet.Put(aFollow);
377
378 // Header
379 //
380 if(rMaster.GetHeader().IsActive())
381 {
382 const SwFmtHeader &rHeaderFmt = rMaster.GetHeader();
383 const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt();
384 ASSERT(pHeaderFmt != 0, kein HeaderFormat.);
385
386 // HeaderInfo, Raender, Hintergrund, Umrandung
387 //
388 SfxItemSet aHeaderSet( *rSet.GetPool(),
389 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
390 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
391 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
392 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
393 0);
394
395 // dynamische oder feste Hoehe
396 //
397 SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True);
398 aHeaderSet.Put(aOn);
399
400 const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize();
401 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
402 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
403 aHeaderSet.Put(aDynamic);
404
405 // Links gleich rechts
406 //
407 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared());
408 aHeaderSet.Put(aShared);
409
410 // Groesse
411 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
412 aHeaderSet.Put(aSize);
413
414 // Rahmen-Attribute umschaufeln
415 //
416 aHeaderSet.Put(pHeaderFmt->GetAttrSet());
417 aHeaderSet.Put( aBoxInfo );
418
419 // SetItem erzeugen
420 //
421 SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet);
422 rSet.Put(aSetItem);
423 }
424
425 // Footer
426 if(rMaster.GetFooter().IsActive())
427 {
428 const SwFmtFooter &rFooterFmt = rMaster.GetFooter();
429 const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt();
430 ASSERT(pFooterFmt != 0, kein FooterFormat.);
431
432 // FooterInfo, Raender, Hintergrund, Umrandung
433 //
434 SfxItemSet aFooterSet( *rSet.GetPool(),
435 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
436 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
437 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
438 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
439 0);
440
441 // dynamische oder feste Hoehe
442 //
443 SfxBoolItem aOn(SID_ATTR_PAGE_ON, sal_True);
444 aFooterSet.Put(aOn);
445
446 const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize();
447 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
448 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
449 aFooterSet.Put(aDynamic);
450
451 // Links gleich rechts
452 //
453 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared());
454 aFooterSet.Put(aShared);
455
456 // Groesse
457 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
458 aFooterSet.Put(aSize);
459
460 // Rahmen-Attribute umschaufeln
461 //
462 aFooterSet.Put(pFooterFmt->GetAttrSet());
463 aFooterSet.Put( aBoxInfo );
464
465 // SetItem erzeugen
466 //
467 SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet);
468 rSet.Put(aSetItem);
469 }
470
471 // Fussnoten einbauen
472 //
473 SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo();
474 SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo);
475 rSet.Put(aFtnItem);
476
477 // Registerhaltigkeit
478
479 const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl();
480 SwRegisterItem aReg(pCol != 0);
481 aReg.SetWhich(SID_SWREGISTER_MODE);
482 rSet.Put(aReg);
483 if(pCol)
484 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName()));
485
486 }
487
488
489 /*--------------------------------------------------------------------
490 Beschreibung: DefaultTabs setzen
491 --------------------------------------------------------------------*/
492
493
MakeDefTabs(SwTwips nDefDist,SvxTabStopItem & rTabs)494 void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
495 {
496 if( rTabs.Count() )
497 return;
498 {
499 SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
500 rTabs.Insert( aSwTabStop );
501 }
502 }
503
504 /*--------------------------------------------------------------------
505 Beschreibung: Abstand zwischen zwei Tabs
506 --------------------------------------------------------------------*/
507
508
GetTabDist(const SvxTabStopItem & rTabs)509 sal_uInt16 GetTabDist(const SvxTabStopItem& rTabs)
510 {
511 sal_uInt16 nDefDist;
512 if( rTabs.Count() )
513 nDefDist = (sal_uInt16)( rTabs[0].GetTabPos() );
514 else
515 nDefDist = 1134; // 2cm
516 return nDefDist;
517 }
518
519
520 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
SfxToSwPageDescAttr(const SwWrtShell & rShell,SfxItemSet & rSet)521 void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
522 {
523 const SfxPoolItem* pItem;
524 SwFmtPageDesc aPgDesc;
525
526 sal_Bool bChanged = sal_False;
527 // Seitennummer
528 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, sal_False, &pItem))
529 {
530 aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue());
531 bChanged = sal_True;
532 }
533 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, sal_False, &pItem ))
534 {
535 const String& rDescName = ((SvxPageModelItem*)pItem)->GetValue();
536 if( rDescName.Len() ) // kein Name -> PageDesc ausschalten!
537 {
538 // nur loeschen, wenn PageDesc eingschaltet wird!
539 rSet.ClearItem( RES_BREAK );
540 SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName(
541 rDescName, sal_True );
542 if( pDesc )
543 aPgDesc.RegisterToPageDesc( *pDesc );
544 }
545 rSet.ClearItem( SID_ATTR_PARA_MODEL );
546 bChanged = sal_True;
547 }
548 else
549 {
550 SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC );
551 rShell.GetCurAttr( aCoreSet );
552 if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
553 {
554 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
555 {
556 aPgDesc.RegisterToPageDesc( *((SwFmtPageDesc*)pItem)->GetPageDesc() );
557 }
558 }
559 }
560
561
562 if(bChanged)
563 rSet.Put( aPgDesc );
564 }
565
566
567 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
SwToSfxPageDescAttr(SfxItemSet & rCoreSet)568 void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
569 {
570 const SfxPoolItem* pItem = 0;
571 String aName;
572 sal_uInt16 nPageNum = 0;
573 sal_Bool bPut = sal_True;
574 switch( rCoreSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
575 {
576 case SFX_ITEM_SET:
577 {
578 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
579 {
580 aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName();
581 nPageNum = ((SwFmtPageDesc*)pItem)->GetNumOffset();
582 }
583 rCoreSet.ClearItem( RES_PAGEDESC );
584 // Seitennummer
585 }
586 break;
587
588 case SFX_ITEM_AVAILABLE:
589 break;
590
591 default:
592 bPut = sal_False;
593 }
594 SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, nPageNum );
595 rCoreSet.Put( aPageNum );
596
597 if(bPut)
598 rCoreSet.Put( SvxPageModelItem( aName, sal_True, SID_ATTR_PARA_MODEL ) );
599 }
600
601 /*--------------------------------------------------------------------
602 Beschreibung: Metric ermitteln
603 --------------------------------------------------------------------*/
604
605
GetDfltMetric(sal_Bool bWeb)606 FieldUnit GetDfltMetric(sal_Bool bWeb)
607 {
608 return SW_MOD()->GetUsrPref(bWeb)->GetMetric();
609 }
610
611 /*--------------------------------------------------------------------
612 Beschreibung: Metric ermitteln
613 --------------------------------------------------------------------*/
614
615
SetDfltMetric(FieldUnit eMetric,sal_Bool bWeb)616 void SetDfltMetric( FieldUnit eMetric, sal_Bool bWeb )
617 {
618 SW_MOD()->ApplyUserMetric(eMetric, bWeb);
619 }
620
621 /*-----------------09.04.98 16:58-------------------
622
623 --------------------------------------------------*/
InsertStringSorted(const String & rEntry,ListBox & rToFill,sal_uInt16 nOffset)624 sal_uInt16 InsertStringSorted(const String& rEntry, ListBox& rToFill, sal_uInt16 nOffset )
625 {
626 sal_uInt16 i = nOffset;
627 CollatorWrapper& rCaseColl = ::GetAppCaseCollator();
628
629 for( ; i < rToFill.GetEntryCount(); i++ )
630 {
631 if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry ))
632 break;
633 }
634 return rToFill.InsertEntry(rEntry, i);
635 }
FillCharStyleListBox(ListBox & rToFill,SwDocShell * pDocSh,sal_Bool bSorted,sal_Bool bWithDefault)636 void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, sal_Bool bSorted, sal_Bool bWithDefault)
637 {
638 sal_Bool bHasOffset = rToFill.GetEntryCount() > 0;
639 SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool();
640 pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL);
641 SwDoc* pDoc = pDocSh->GetDoc();
642 const SfxStyleSheetBase* pBase = pPool->First();
643 String sStandard;
644 SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard );
645 while(pBase)
646 {
647 if(bWithDefault || pBase->GetName() != sStandard)
648 {
649 sal_uInt16 nPos;
650 if(bSorted)
651 nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset );
652 else
653 nPos = rToFill.InsertEntry(pBase->GetName());
654 long nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
655 rToFill.SetEntryData( nPos, (void*) (nPoolId));
656 }
657 pBase = pPool->Next();
658 }
659 // non-pool styles
660 const SwCharFmts* pFmts = pDoc->GetCharFmts();
661 for(sal_uInt16 i = 0; i < pFmts->Count(); i++)
662 {
663 const SwCharFmt* pFmt = (*pFmts)[i];
664 if(pFmt->IsDefault())
665 continue;
666 const String& rName = pFmt->GetName();
667 if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND)
668 {
669 sal_uInt16 nPos;
670 if(bSorted)
671 nPos = InsertStringSorted(rName, rToFill, bHasOffset );
672 else
673 nPos = rToFill.InsertEntry(rName);
674 long nPoolId = USHRT_MAX;
675 rToFill.SetEntryData( nPos, (void*) (nPoolId));
676 }
677 }
678 };
679
680 /* -----------------27.04.98 08:26-------------------
681 *
682 * --------------------------------------------------*/
GetTableWidth(SwFrmFmt * pFmt,SwTabCols & rCols,sal_uInt16 * pPercent,SwWrtShell * pSh)683 SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, sal_uInt16 *pPercent,
684 SwWrtShell* pSh )
685 {
686 //Die Breite zu besorgen ist etwas komplizierter.
687 SwTwips nWidth = 0;
688 const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient();
689 switch(eOri)
690 {
691 case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break;
692 case text::HoriOrientation::LEFT_AND_WIDTH:
693 case text::HoriOrientation::LEFT:
694 case text::HoriOrientation::RIGHT:
695 case text::HoriOrientation::CENTER:
696 nWidth = pFmt->GetFrmSize().GetWidth();
697 break;
698 default:
699 {
700 if(pSh)
701 {
702 const SwFrmFmt *pFlyFmt;
703 if ( 0 == (pFlyFmt = pSh->GetFlyFrmFmt()) )
704 {
705 nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width();
706 }
707 else
708 {
709 nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width();
710 }
711 }
712 else
713 {
714 DBG_ERROR("wo soll die Breite denn herkommen?");
715 }
716 const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace();
717 nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft());
718 }
719 }
720 if (pPercent)
721 *pPercent = pFmt->GetFrmSize().GetWidthPercent();
722 return nWidth;
723 }
724
725 /*------------------------------------------------------------------------*/
726
GetAppLangDateTimeString(const DateTime & rDT)727 String GetAppLangDateTimeString( const DateTime& rDT )
728 {
729 const SvtSysLocale aSysLocale;
730 const LocaleDataWrapper& rAppLclData = aSysLocale.GetLocaleData();
731 String sRet( rAppLclData.getDate( rDT ));
732 ( sRet += ' ' ) += rAppLclData.getTime( rDT, sal_False, sal_False );
733 return sRet;
734 }
735
736 /*-- 26.01.2006 08:06:33---------------------------------------------------
737
738 -----------------------------------------------------------------------*/
ExecuteMenuCommand(PopupMenu & rMenu,SfxViewFrame & rViewFrame,sal_uInt16 nId)739 bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, sal_uInt16 nId )
740 {
741 bool bRet = false;
742 sal_uInt16 nItemCount = rMenu.GetItemCount();
743 String sCommand;
744 for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem)
745 {
746 PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) );
747 if(pPopup)
748 {
749 sCommand = pPopup->GetItemCommand(nId);
750 if(sCommand.Len())
751 break;
752 }
753 }
754 if(sCommand.Len())
755 {
756 uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame().GetFrameInterface();
757 uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY );
758 util::URL aURL;
759 aURL.Complete = sCommand;
760 uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
761 xTrans->parseStrict( aURL );
762 uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
763 if( xDisp.is() )
764 {
765 uno::Sequence< beans::PropertyValue > aSeq;
766 xDisp->dispatch( aURL, aSeq );
767 bRet = true;
768 }
769 }
770 return bRet;
771 }
772