merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / utlui / uitool.cxx
blobae4a8348a7210bcfc2e226db8b1545a3d09d4bcf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: uitool.cxx,v $
10 * $Revision: 1.26 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
37 #include <tools/datetime.hxx>
38 #include <vcl/svapp.hxx>
39 #include <unotools/collatorwrapper.hxx>
40 #include <svtools/urihelper.hxx>
41 #include <svtools/stritem.hxx>
42 #include <svtools/syslocale.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/docfile.hxx>
45 #include <sfx2/docfilt.hxx>
46 #include <svx/pmdlitem.hxx>
47 #ifndef _SVX_TSTPITEM_HXX //autogen
48 #include <svx/tstpitem.hxx>
49 #endif
50 #include <svx/boxitem.hxx>
51 #include <svx/sizeitem.hxx>
52 #include <svx/pageitem.hxx>
53 #include <svx/lrspitem.hxx>
54 #include <svtools/style.hxx>
55 #ifndef _VCL_LSTBOX_HXX //autogen
56 #include <vcl/lstbox.hxx>
57 #endif
58 #include <unotools/localedatawrapper.hxx>
59 #include <com/sun/star/frame/XDispatch.hpp>
60 #include <com/sun/star/frame/XDispatchProvider.hpp>
61 #include <com/sun/star/util/XURLTransformer.hpp>
62 #include <comphelper/processfactory.hxx>
63 #include <sfx2/viewfrm.hxx>
64 #include <fmtornt.hxx>
65 #include <tabcol.hxx>
66 #include <edtwin.hxx>
67 #include <fmtfsize.hxx>
68 #include <fmthdft.hxx>
69 #include <fmtpdsc.hxx>
70 #include <wview.hxx>
71 #include <uiitems.hxx>
72 #ifndef _DOCSH_HXX
73 #include <docsh.hxx>
74 #endif
75 #include <wrtsh.hxx>
76 #include <swmodule.hxx>
77 #ifndef _VIEW_HXX
78 #include <view.hxx>
79 #endif
80 #include <uitool.hxx>
81 #include <frmatr.hxx>
82 #include <paratr.hxx>
83 #include <fmtcol.hxx>
84 #include <poolfmt.hxx>
85 #include "usrpref.hxx"
87 #ifndef _ERROR_H
88 #include <error.h>
89 #endif
90 #ifndef _CMDID_H
91 #include <cmdid.h>
92 #endif
93 #ifndef _GLOBALS_HRC
94 #include <globals.hrc>
95 #endif
96 #ifndef _UTLUI_HRC
97 #include <utlui.hrc>
98 #endif
99 #include <doc.hxx>
100 #include <docary.hxx>
101 #include <charfmt.hxx>
102 #include <SwStyleNameMapper.hxx>
103 // 50 cm 28350
105 #define MAXHEIGHT 28350
106 #define MAXWIDTH 28350
108 using namespace ::com::sun::star;
109 /*--------------------------------------------------------------------
110 Beschreibung: Allgemeine List von StringPointern
111 --------------------------------------------------------------------*/
114 /*--------------------------------------------------------------------
115 Beschreibung: Metric umschalten
116 --------------------------------------------------------------------*/
119 void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
121 SwTwips nMin = static_cast< SwTwips >(rCtrl.GetMin(FUNIT_TWIP));
122 SwTwips nMax = static_cast< SwTwips >(rCtrl.GetMax(FUNIT_TWIP));
124 rCtrl.SetUnit(eUnit);
126 rCtrl.SetMin(nMin, FUNIT_TWIP);
127 rCtrl.SetMax(nMax, FUNIT_TWIP);
130 /*--------------------------------------------------------------------
131 Beschreibung: Boxinfo-Attribut setzen
132 --------------------------------------------------------------------*/
135 void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
137 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
138 const SfxPoolItem *pBoxInfo;
139 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
140 TRUE, &pBoxInfo))
141 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
143 // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
144 rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert
145 aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1);
146 // Abstandsfeld immer anzeigen
147 aBoxInfo.SetDist ((BOOL) TRUE);
148 // Minimalgroesse in Tabellen und Absaetzen setzen
149 aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
150 // Default-Abstand immer setzen
151 aBoxInfo.SetDefDist (MIN_BORDER_DIST);
152 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
153 aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode());
155 rSet.Put(aBoxInfo);
158 /*--------------------------------------------------------------------
159 Beschreibung: Header Footer fuellen
160 --------------------------------------------------------------------*/
163 void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet)
165 SwAttrSet aSet(pFmt->GetAttrSet());
166 aSet.Put(rSet);
168 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
169 const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC);
171 // Groesse umsetzen
173 SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE,
174 rSize.GetSize().Width(),
175 rSize.GetSize().Height());
176 aSet.Put(aFrmSize);
177 pFmt->SetFmtAttr(aSet);
180 /*--------------------------------------------------------------------
181 Beschreibung: PageDesc <-> in Sets wandeln und zurueck
182 --------------------------------------------------------------------*/
185 void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
187 SwFrmFmt& rMaster = rPageDesc.GetMaster();
189 // alle allgemeinen Rahmen-Attribute uebertragen
191 rMaster.SetFmtAttr(rSet);
193 // PageData
195 if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET)
197 const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
199 USHORT nUse = (USHORT)rPageItem.GetPageUsage();
200 if(nUse & 0x04)
201 nUse |= 0x03;
202 if(nUse)
203 rPageDesc.SetUseOn( (UseOnPage) nUse );
204 rPageDesc.SetLandscape(rPageItem.IsLandscape());
205 SvxNumberType aNumType;
206 aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) );
207 rPageDesc.SetNumType(aNumType);
209 // Groesse
211 if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET)
213 const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
214 SwFmtFrmSize aSize(ATT_FIX_SIZE);
215 aSize.SetSize(rSizeItem.GetSize());
216 rMaster.SetFmtAttr(aSize);
218 // Kopzeilen-Attribute auswerten
220 const SfxPoolItem* pItem;
221 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET,
222 FALSE, &pItem ) )
224 const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
225 const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON);
227 if(rHeaderOn.GetValue())
229 // Werte uebernehmen
230 if(!rMaster.GetHeader().IsActive())
231 rMaster.SetFmtAttr(SwFmtHeader(TRUE));
233 // Das Headerformat rausholen und anpassen
235 SwFmtHeader aHeaderFmt(rMaster.GetHeader());
236 SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt();
237 ASSERT(pHeaderFmt != 0, "kein HeaderFormat");
239 ::FillHdFt(pHeaderFmt, rHeaderSet);
241 rPageDesc.ChgHeaderShare(((const SfxBoolItem&)
242 rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
244 else
245 { // Header ausschalten
247 if(rMaster.GetHeader().IsActive())
249 rMaster.SetFmtAttr(SwFmtHeader(BOOL(FALSE)));
250 rPageDesc.ChgHeaderShare(FALSE);
255 // Fusszeilen-Attribute auswerten
257 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET,
258 FALSE, &pItem ) )
260 const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
261 const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON);
263 if(rFooterOn.GetValue())
265 // Werte uebernehmen
266 if(!rMaster.GetFooter().IsActive())
267 rMaster.SetFmtAttr(SwFmtFooter(TRUE));
269 // Das Footerformat rausholen und anpassen
271 SwFmtFooter aFooterFmt(rMaster.GetFooter());
272 SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt();
273 ASSERT(pFooterFmt != 0, "kein FooterFormat");
275 ::FillHdFt(pFooterFmt, rFooterSet);
277 rPageDesc.ChgFooterShare(((const SfxBoolItem&)
278 rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
280 else
281 { // Footer ausschalten
283 if(rMaster.GetFooter().IsActive())
285 rMaster.SetFmtAttr(SwFmtFooter(BOOL(FALSE)));
286 rPageDesc.ChgFooterShare(FALSE);
291 // Fussnoten
293 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO,
294 FALSE, &pItem ) )
295 rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() );
299 // Columns
302 // Registerhaltigkeit
304 if(SFX_ITEM_SET == rSet.GetItemState(
305 SID_SWREGISTER_MODE, FALSE, &pItem))
307 BOOL bSet = ((const SfxBoolItem*)pItem)->GetValue();
308 if(!bSet)
309 rPageDesc.SetRegisterFmtColl(0);
310 else if(SFX_ITEM_SET == rSet.GetItemState(
311 SID_SWREGISTER_COLLECTION, FALSE, &pItem))
313 const String& rColl = ((const SfxStringItem*)pItem)->GetValue();
314 SwDoc& rDoc = *rMaster.GetDoc();
315 SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
316 if( !pColl )
318 USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
319 if( USHRT_MAX != nId )
320 pColl = rDoc.GetTxtCollFromPool( nId );
321 else
322 pColl = rDoc.MakeTxtFmtColl( rColl,
323 (SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() );
325 if( pColl )
326 pColl->SetFmtAttr( SwRegisterItem ( TRUE ));
327 rPageDesc.SetRegisterFmtColl( pColl );
332 /*--------------------------------------------------------------------
333 Beschreibung:
334 --------------------------------------------------------------------*/
337 void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
339 const SwFrmFmt& rMaster = rPageDesc.GetMaster();
341 // Seitendaten
343 SvxPageItem aPageItem(SID_ATTR_PAGE);
344 aPageItem.SetDescName(rPageDesc.GetName());
345 aPageItem.SetPageUsage(rPageDesc.GetUseOn());
346 aPageItem.SetLandscape(rPageDesc.GetLandscape());
347 aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
348 rSet.Put(aPageItem);
350 // Groesse
351 SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize());
352 rSet.Put(aSizeItem);
354 // Maximale Groesse
355 SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT));
356 rSet.Put(aMaxSizeItem);
358 // Raender, Umrandung und das andere Zeug
360 rSet.Put(rMaster.GetAttrSet());
362 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
363 const SfxPoolItem *pBoxInfo;
364 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
365 TRUE, &pBoxInfo) )
366 aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
368 aBoxInfo.SetTable( FALSE );
369 // Abstandsfeld immer anzeigen
370 aBoxInfo.SetDist( TRUE);
371 // Minimalgroesse in Tabellen und Absaetzen setzen
372 aBoxInfo.SetMinDist( FALSE );
373 // Default-Abstand immer setzen
374 aBoxInfo.SetDefDist( MIN_BORDER_DIST );
375 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
376 aBoxInfo.SetValid( VALID_DISABLE );
377 rSet.Put( aBoxInfo );
380 SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, aEmptyStr);
381 if(rPageDesc.GetFollow())
382 aFollow.SetValue(rPageDesc.GetFollow()->GetName());
383 rSet.Put(aFollow);
385 // Header
387 if(rMaster.GetHeader().IsActive())
389 const SwFmtHeader &rHeaderFmt = rMaster.GetHeader();
390 const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt();
391 ASSERT(pHeaderFmt != 0, kein HeaderFormat.);
393 // HeaderInfo, Raender, Hintergrund, Umrandung
395 SfxItemSet aHeaderSet( *rSet.GetPool(),
396 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
397 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
398 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
399 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
402 // dynamische oder feste Hoehe
404 SfxBoolItem aOn(SID_ATTR_PAGE_ON, TRUE);
405 aHeaderSet.Put(aOn);
407 const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize();
408 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
409 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
410 aHeaderSet.Put(aDynamic);
412 // Links gleich rechts
414 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared());
415 aHeaderSet.Put(aShared);
417 // Groesse
418 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
419 aHeaderSet.Put(aSize);
421 // Rahmen-Attribute umschaufeln
423 aHeaderSet.Put(pHeaderFmt->GetAttrSet());
424 aHeaderSet.Put( aBoxInfo );
426 // SetItem erzeugen
428 SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet);
429 rSet.Put(aSetItem);
432 // Footer
433 if(rMaster.GetFooter().IsActive())
435 const SwFmtFooter &rFooterFmt = rMaster.GetFooter();
436 const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt();
437 ASSERT(pFooterFmt != 0, kein FooterFormat.);
439 // FooterInfo, Raender, Hintergrund, Umrandung
441 SfxItemSet aFooterSet( *rSet.GetPool(),
442 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
443 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
444 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
445 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
448 // dynamische oder feste Hoehe
450 SfxBoolItem aOn(SID_ATTR_PAGE_ON, TRUE);
451 aFooterSet.Put(aOn);
453 const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize();
454 const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
455 SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
456 aFooterSet.Put(aDynamic);
458 // Links gleich rechts
460 SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared());
461 aFooterSet.Put(aShared);
463 // Groesse
464 SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
465 aFooterSet.Put(aSize);
467 // Rahmen-Attribute umschaufeln
469 aFooterSet.Put(pFooterFmt->GetAttrSet());
470 aFooterSet.Put( aBoxInfo );
472 // SetItem erzeugen
474 SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet);
475 rSet.Put(aSetItem);
478 // Fussnoten einbauen
480 SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo();
481 SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo);
482 rSet.Put(aFtnItem);
484 // Registerhaltigkeit
486 const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl();
487 SwRegisterItem aReg(pCol != 0);
488 aReg.SetWhich(SID_SWREGISTER_MODE);
489 rSet.Put(aReg);
490 if(pCol)
491 rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName()));
496 /*--------------------------------------------------------------------
497 Beschreibung: DefaultTabs setzen
498 --------------------------------------------------------------------*/
501 void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
503 if( rTabs.Count() )
504 return;
506 SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
507 rTabs.Insert( aSwTabStop );
511 /*--------------------------------------------------------------------
512 Beschreibung: Abstand zwischen zwei Tabs
513 --------------------------------------------------------------------*/
516 USHORT GetTabDist(const SvxTabStopItem& rTabs)
518 USHORT nDefDist;
519 if( rTabs.Count() )
520 nDefDist = (USHORT)( rTabs[0].GetTabPos() );
521 else
522 nDefDist = 1134; // 2cm
523 return nDefDist;
527 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
528 void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
530 const SfxPoolItem* pItem;
531 SwFmtPageDesc aPgDesc;
533 BOOL bChanged = FALSE;
534 // Seitennummer
535 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, FALSE, &pItem))
537 aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue());
538 bChanged = TRUE;
540 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, FALSE, &pItem ))
542 const String& rDescName = ((SvxPageModelItem*)pItem)->GetValue();
543 if( rDescName.Len() ) // kein Name -> PageDesc ausschalten!
545 // nur loeschen, wenn PageDesc eingschaltet wird!
546 rSet.ClearItem( RES_BREAK );
547 SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName(
548 rDescName, TRUE );
549 if( pDesc )
550 pDesc->Add( &aPgDesc );
552 rSet.ClearItem( SID_ATTR_PARA_MODEL );
553 bChanged = TRUE;
555 else
557 SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC );
558 rShell.GetCurAttr( aCoreSet );
559 if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, TRUE, &pItem ) )
561 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
563 ((SwFmtPageDesc*)pItem)->GetPageDesc()->Add(&aPgDesc);
569 if(bChanged)
570 rSet.Put( aPgDesc );
574 // erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
575 void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
577 const SfxPoolItem* pItem = 0;
578 String aName;
579 USHORT nPageNum = 0;
580 BOOL bPut = TRUE;
581 switch( rCoreSet.GetItemState( RES_PAGEDESC, TRUE, &pItem ) )
583 case SFX_ITEM_SET:
585 if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
587 aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName();
588 nPageNum = ((SwFmtPageDesc*)pItem)->GetNumOffset();
590 rCoreSet.ClearItem( RES_PAGEDESC );
591 // Seitennummer
593 break;
595 case SFX_ITEM_AVAILABLE:
596 break;
598 default:
599 bPut = FALSE;
601 SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, nPageNum );
602 rCoreSet.Put( aPageNum );
604 if(bPut)
605 rCoreSet.Put( SvxPageModelItem( aName, TRUE, SID_ATTR_PARA_MODEL ) );
608 /*--------------------------------------------------------------------
609 Beschreibung: Metric ermitteln
610 --------------------------------------------------------------------*/
613 FieldUnit GetDfltMetric(BOOL bWeb)
615 return SW_MOD()->GetUsrPref(bWeb)->GetMetric();
618 /*--------------------------------------------------------------------
619 Beschreibung: Metric ermitteln
620 --------------------------------------------------------------------*/
623 void SetDfltMetric( FieldUnit eMetric, BOOL bWeb )
625 SW_MOD()->ApplyUserMetric(eMetric, bWeb);
628 /*-----------------09.04.98 16:58-------------------
630 --------------------------------------------------*/
631 USHORT InsertStringSorted(const String& rEntry, ListBox& rToFill, USHORT nOffset )
633 USHORT i = nOffset;
634 CollatorWrapper& rCaseColl = ::GetAppCaseCollator();
636 for( ; i < rToFill.GetEntryCount(); i++ )
638 if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry ))
639 break;
641 return rToFill.InsertEntry(rEntry, i);
643 void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, BOOL bSorted, BOOL bWithDefault)
645 BOOL bHasOffset = rToFill.GetEntryCount() > 0;
646 SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool();
647 pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL);
648 SwDoc* pDoc = pDocSh->GetDoc();
649 const SfxStyleSheetBase* pBase = pPool->First();
650 String sStandard;
651 SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard );
652 while(pBase)
654 if(bWithDefault || pBase->GetName() != sStandard)
656 USHORT nPos;
657 if(bSorted)
658 nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset );
659 else
660 nPos = rToFill.InsertEntry(pBase->GetName());
661 long nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
662 rToFill.SetEntryData( nPos, (void*) (nPoolId));
664 pBase = pPool->Next();
666 // non-pool styles
667 const SwCharFmts* pFmts = pDoc->GetCharFmts();
668 for(USHORT i = 0; i < pFmts->Count(); i++)
670 const SwCharFmt* pFmt = (*pFmts)[i];
671 if(pFmt->IsDefault())
672 continue;
673 const String& rName = pFmt->GetName();
674 if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND)
676 USHORT nPos;
677 if(bSorted)
678 nPos = InsertStringSorted(rName, rToFill, bHasOffset );
679 else
680 nPos = rToFill.InsertEntry(rName);
681 long nPoolId = USHRT_MAX;
682 rToFill.SetEntryData( nPos, (void*) (nPoolId));
687 /* -----------------27.04.98 08:26-------------------
689 * --------------------------------------------------*/
690 SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, USHORT *pPercent,
691 SwWrtShell* pSh )
693 //Die Breite zu besorgen ist etwas komplizierter.
694 SwTwips nWidth = 0;
695 const sal_Int16 eOri = pFmt->GetHoriOrient().GetHoriOrient();
696 switch(eOri)
698 case text::HoriOrientation::FULL: nWidth = rCols.GetRight(); break;
699 case text::HoriOrientation::LEFT_AND_WIDTH:
700 case text::HoriOrientation::LEFT:
701 case text::HoriOrientation::RIGHT:
702 case text::HoriOrientation::CENTER:
703 nWidth = pFmt->GetFrmSize().GetWidth();
704 break;
705 default:
707 if(pSh)
709 const SwFrmFmt *pFlyFmt;
710 if ( 0 == (pFlyFmt = pSh->GetFlyFrmFmt()) )
712 nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width();
714 else
716 nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width();
719 else
721 DBG_ERROR("wo soll die Breite denn herkommen?");
723 const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace();
724 nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft());
727 if (pPercent)
728 *pPercent = pFmt->GetFrmSize().GetWidthPercent();
729 return nWidth;
732 /*------------------------------------------------------------------------*/
734 String GetAppLangDateTimeString( const DateTime& rDT )
736 const LocaleDataWrapper& rAppLclData = SvtSysLocale().GetLocaleData();
737 String sRet( rAppLclData.getDate( rDT ));
738 ( sRet += ' ' ) += rAppLclData.getTime( rDT, FALSE, FALSE );
739 return sRet;
742 /*----------------------------------------------------------------------------
743 * add a new function which can get and set the current "SID_ATTR_APPLYCHARUNIT" value
744 *---------------------------------------------------------------------------*/
745 BOOL HasCharUnit( BOOL bWeb)
747 return SW_MOD()->GetUsrPref(bWeb)->IsApplyCharUnit();
750 void SetApplyCharUnit(BOOL bApplyChar, BOOL bWeb)
752 SW_MOD()->ApplyUserCharUnit(bApplyChar, bWeb);
755 /*-- 26.01.2006 08:06:33---------------------------------------------------
757 -----------------------------------------------------------------------*/
758 bool ExecuteMenuCommand( PopupMenu& rMenu, SfxViewFrame& rViewFrame, USHORT nId )
760 bool bRet = false;
761 USHORT nItemCount = rMenu.GetItemCount();
762 String sCommand;
763 for( USHORT nItem = 0; nItem < nItemCount; ++nItem)
765 PopupMenu* pPopup = rMenu.GetPopupMenu( rMenu.GetItemId( nItem ) );
766 if(pPopup)
768 sCommand = pPopup->GetItemCommand(nId);
769 if(sCommand.Len())
770 break;
773 if(sCommand.Len())
775 uno::Reference< frame::XFrame > xFrame = rViewFrame.GetFrame()->GetFrameInterface();
776 uno::Reference < frame::XDispatchProvider > xProv( xFrame, uno::UNO_QUERY );
777 util::URL aURL;
778 aURL.Complete = sCommand;
779 uno::Reference < util::XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
780 xTrans->parseStrict( aURL );
781 uno::Reference< frame::XDispatch > xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
782 if( xDisp.is() )
784 uno::Sequence< beans::PropertyValue > aSeq;
785 xDisp->dispatch( aURL, aSeq );
786 bRet = true;
789 return bRet;