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