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