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