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 <vcl/msgbox.hxx>
23 : #include <svl/whiter.hxx>
24 : #include <svl/stritem.hxx>
25 : #include <svl/itemiter.hxx>
26 : #include <svl/ctloptions.hxx>
27 : #include <swmodule.hxx>
28 : #include <sfx2/bindings.hxx>
29 : #include <sfx2/request.hxx>
30 : #include <editeng/fhgtitem.hxx>
31 : #include <editeng/adjustitem.hxx>
32 : #include <editeng/lspcitem.hxx>
33 : #include <editeng/lrspitem.hxx>
34 : #include <editeng/udlnitem.hxx>
35 : #include <editeng/escapementitem.hxx>
36 : #include <sfx2/htmlmode.hxx>
37 : #include <editeng/scripttypeitem.hxx>
38 : #include <editeng/frmdiritem.hxx>
39 : #include "paratr.hxx"
40 :
41 : #include <fmtinfmt.hxx>
42 : #include <docsh.hxx>
43 : #include <wrtsh.hxx>
44 : #include <view.hxx>
45 : #include <viewopt.hxx>
46 : #include <uitool.hxx>
47 : #include <textsh.hxx>
48 : #include <num.hxx>
49 : #include <swundo.hxx>
50 : #include <fmtcol.hxx>
51 :
52 : #include <cmdid.h>
53 : #include <globals.h>
54 : #include <shells.hrc>
55 : #include <SwStyleNameMapper.hxx>
56 : #include "swabstdlg.hxx"
57 : #include "chrdlg.hrc"
58 : const SwTwips lFontInc = 2 * 20; // ==> PointToTwips(2)
59 : const SwTwips lFontMaxSz = 72 * 20; // ==> PointToTwips(72)
60 :
61 :
62 :
63 :
64 0 : void SwTextShell::ExecCharAttr(SfxRequest &rReq)
65 : {
66 0 : SwWrtShell &rSh = GetShell();
67 0 : const SfxItemSet *pArgs = rReq.GetArgs();
68 0 : int eState = STATE_TOGGLE;
69 0 : sal_uInt16 nWhich = rReq.GetSlot();
70 :
71 0 : if(pArgs )
72 : {
73 : const SfxPoolItem* pItem;
74 0 : pArgs->GetItemState(nWhich, sal_False, &pItem);
75 : eState = ((const SfxBoolItem &) pArgs->
76 0 : Get( nWhich )).GetValue() ? STATE_ON : STATE_OFF;
77 : }
78 :
79 :
80 0 : SfxItemSet aSet( GetPool(), RES_CHRATR_BEGIN, RES_CHRATR_END-1 );
81 0 : if (STATE_TOGGLE == eState)
82 0 : rSh.GetCurAttr( aSet );
83 :
84 0 : switch ( nWhich )
85 : {
86 : case FN_SET_SUB_SCRIPT:
87 : case FN_SET_SUPER_SCRIPT:
88 : {
89 0 : SvxEscapement eEscape = SVX_ESCAPEMENT_SUBSCRIPT;
90 0 : switch (eState)
91 : {
92 : case STATE_TOGGLE:
93 : {
94 : short nTmpEsc = ((const SvxEscapementItem&)
95 0 : aSet.Get( RES_CHRATR_ESCAPEMENT )).GetEsc();
96 : eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
97 : SVX_ESCAPEMENT_SUPERSCRIPT:
98 0 : SVX_ESCAPEMENT_SUBSCRIPT;
99 0 : if( (nWhich == FN_SET_SUB_SCRIPT && nTmpEsc < 0) ||
100 0 : (nWhich == FN_SET_SUPER_SCRIPT && nTmpEsc > 0) )
101 0 : eEscape = SVX_ESCAPEMENT_OFF;
102 :
103 0 : SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
104 0 : if( nWhich == FN_SET_SUB_SCRIPT )
105 : rBind.SetState( SfxBoolItem( FN_SET_SUPER_SCRIPT,
106 0 : sal_False ) );
107 : else
108 : rBind.SetState( SfxBoolItem( FN_SET_SUB_SCRIPT,
109 0 : sal_False ) );
110 :
111 : }
112 0 : break;
113 : case STATE_ON:
114 : eEscape = nWhich == FN_SET_SUPER_SCRIPT ?
115 : SVX_ESCAPEMENT_SUPERSCRIPT:
116 0 : SVX_ESCAPEMENT_SUBSCRIPT;
117 0 : break;
118 : case STATE_OFF:
119 0 : eEscape = SVX_ESCAPEMENT_OFF;
120 0 : break;
121 : }
122 0 : SvxEscapementItem aEscape( eEscape, RES_CHRATR_ESCAPEMENT );
123 0 : if(eEscape == SVX_ESCAPEMENT_SUPERSCRIPT)
124 0 : aEscape.GetEsc() = DFLT_ESC_AUTO_SUPER;
125 0 : else if(eEscape == SVX_ESCAPEMENT_SUBSCRIPT)
126 0 : aEscape.GetEsc() = DFLT_ESC_AUTO_SUB;
127 0 : rSh.SetAttr( aEscape );
128 0 : rReq.AppendItem( aEscape );
129 0 : rReq.Done();
130 : }
131 0 : break;
132 :
133 : case FN_UPDATE_STYLE_BY_EXAMPLE:
134 0 : rSh.QuickUpdateStyle();
135 0 : rReq.Done();
136 0 : break;
137 : case FN_UNDERLINE_DOUBLE:
138 : {
139 : FontUnderline eUnderline = ((const SvxUnderlineItem&)
140 0 : aSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
141 0 : switch( eState )
142 : {
143 : case STATE_TOGGLE:
144 : eUnderline = eUnderline == UNDERLINE_DOUBLE ?
145 : UNDERLINE_NONE :
146 0 : UNDERLINE_DOUBLE;
147 0 : break;
148 : case STATE_ON:
149 0 : eUnderline = UNDERLINE_DOUBLE;
150 0 : break;
151 : case STATE_OFF:
152 0 : eUnderline = UNDERLINE_NONE;
153 0 : break;
154 : }
155 0 : SvxUnderlineItem aUnderline(eUnderline, RES_CHRATR_UNDERLINE );
156 0 : rSh.SetAttr( aUnderline );
157 0 : rReq.AppendItem( aUnderline );
158 0 : rReq.Done();
159 : }
160 0 : break;
161 : case FN_REMOVE_DIRECT_CHAR_FORMATS:
162 0 : if( !rSh.HasReadonlySel() && rSh.IsEndPara())
163 0 : rSh.DontExpandFmt();
164 0 : break;
165 : default:
166 : OSL_FAIL("wrong dispatcher");
167 0 : return;
168 0 : }
169 : }
170 :
171 :
172 0 : void SwTextShell::ExecCharAttrArgs(SfxRequest &rReq)
173 : {
174 0 : sal_uInt16 nSlot = rReq.GetSlot();
175 0 : const SfxItemSet* pArgs = rReq.GetArgs();
176 0 : bool bArgs = pArgs != 0 && pArgs->Count() > 0;
177 0 : int bGrow = sal_False;
178 0 : SwWrtShell& rWrtSh = GetShell();
179 0 : SwTxtFmtColl* pColl = 0;
180 :
181 : // Is only set if the whole paragraph is selected and AutoUpdateFmt is set.
182 0 : if( rWrtSh.HasSelection() && rWrtSh.IsSelFullPara() )
183 : {
184 0 : pColl = rWrtSh.GetCurTxtFmtColl();
185 0 : if(pColl && !pColl->IsAutoUpdateFmt())
186 0 : pColl = 0;
187 : }
188 0 : SfxItemPool& rPool = GetPool();
189 0 : sal_uInt16 nWhich = rPool.GetWhich(nSlot);
190 0 : switch ( nSlot )
191 : {
192 : case FN_TXTATR_INET:
193 : // Special treatment of the PoolId of the SwFmtInetFmt
194 0 : if(bArgs)
195 : {
196 0 : const SfxPoolItem& rItem = pArgs->Get(nWhich );
197 :
198 0 : SwFmtINetFmt aINetFmt((const SwFmtINetFmt&)rItem);
199 0 : if( USHRT_MAX == aINetFmt.GetVisitedFmtId() )
200 : {
201 : aINetFmt.SetVisitedFmtId(
202 0 : SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetVisitedFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
203 : }
204 0 : if( USHRT_MAX == aINetFmt.GetINetFmtId() )
205 : {
206 : aINetFmt.SetINetFmtId(
207 0 : SwStyleNameMapper::GetPoolIdFromUIName( aINetFmt.GetINetFmt(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT));
208 : }
209 :
210 0 : if ( pColl )
211 0 : pColl->SetFmtAttr( aINetFmt );
212 0 : else rWrtSh.SetAttr( aINetFmt );
213 0 : rReq.Done();
214 : }
215 0 : break;
216 :
217 : case FN_GROW_FONT_SIZE:
218 0 : bGrow = sal_True;
219 : // No break !!
220 : case FN_SHRINK_FONT_SIZE:
221 : {
222 0 : SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
223 0 : rWrtSh.GetCurAttr( aSetItem.GetItemSet() );
224 0 : SfxItemSet aAttrSet( rPool, aSetItem.GetItemSet().GetRanges() );
225 :
226 : const SfxPoolItem* pI;
227 : static const sal_uInt16 aScrTypes[] = {
228 : SCRIPTTYPE_LATIN, SCRIPTTYPE_ASIAN, SCRIPTTYPE_COMPLEX, 0 };
229 0 : sal_uInt16 nScriptType = rWrtSh.GetScriptType();
230 0 : for( const sal_uInt16* pScrpTyp = aScrTypes; *pScrpTyp; ++pScrpTyp )
231 0 : if( ( nScriptType & *pScrpTyp ) &&
232 0 : 0 != ( pI = aSetItem.GetItemOfScript( *pScrpTyp )))
233 : {
234 0 : SvxFontHeightItem aSize( *(const SvxFontHeightItem*)pI );
235 0 : SwTwips lSize = (SwTwips) aSize.GetHeight();
236 :
237 0 : if (bGrow)
238 : {
239 0 : if( lSize == lFontMaxSz )
240 0 : break; // That's all, further up is not possible
241 0 : if( ( lSize += lFontInc ) > lFontMaxSz )
242 0 : lSize = lFontMaxSz;
243 : }
244 : else
245 : {
246 0 : if( 4 == lSize )
247 0 : break;
248 0 : if( ( lSize -= lFontInc ) < 4 )
249 0 : lSize = 4;
250 : }
251 0 : aSize.SetHeight( lSize );
252 0 : aAttrSet.Put( aSize );
253 : }
254 0 : if( aAttrSet.Count() )
255 : {
256 0 : if( pColl )
257 0 : pColl->SetFmtAttr( aAttrSet );
258 : else
259 0 : rWrtSh.SetAttr( aAttrSet );
260 : }
261 0 : rReq.Done();
262 : }
263 0 : break;
264 :
265 : default:
266 : OSL_FAIL("wrong dispatcher");
267 0 : return;
268 : }
269 : }
270 :
271 0 : void SwTextShell::ExecParaAttr(SfxRequest &rReq)
272 : {
273 : SvxAdjust eAdjst;
274 : sal_uInt8 ePropL;
275 0 : const SfxItemSet* pArgs = rReq.GetArgs();
276 :
277 : // Get both attributes immediately isn't more expensive!!
278 0 : SfxItemSet aSet( GetPool(),
279 : RES_PARATR_LINESPACING, RES_PARATR_ADJUST,
280 : RES_FRAMEDIR, RES_FRAMEDIR,
281 0 : 0 );
282 :
283 0 : sal_uInt16 nSlot = rReq.GetSlot();
284 0 : switch (nSlot)
285 : {
286 : case SID_ATTR_PARA_ADJUST:
287 : {
288 0 : if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_PARATR_ADJUST) )
289 : {
290 0 : const SvxAdjustItem& rAdj = (const SvxAdjustItem&) pArgs->Get(RES_PARATR_ADJUST);
291 0 : SvxAdjustItem aAdj( rAdj.GetAdjust(), RES_PARATR_ADJUST );
292 0 : if ( rAdj.GetAdjust() == SVX_ADJUST_BLOCK )
293 : {
294 0 : aAdj.SetLastBlock( rAdj.GetLastBlock() );
295 0 : aAdj.SetOneWord( rAdj.GetOneWord() );
296 : }
297 :
298 0 : aSet.Put(aAdj);
299 : }
300 : }
301 0 : break;
302 0 : case SID_ATTR_PARA_ADJUST_LEFT: eAdjst = SVX_ADJUST_LEFT; goto SET_ADJUST;
303 0 : case SID_ATTR_PARA_ADJUST_RIGHT: eAdjst = SVX_ADJUST_RIGHT; goto SET_ADJUST;
304 0 : case SID_ATTR_PARA_ADJUST_CENTER: eAdjst = SVX_ADJUST_CENTER; goto SET_ADJUST;
305 0 : case SID_ATTR_PARA_ADJUST_BLOCK: eAdjst = SVX_ADJUST_BLOCK; goto SET_ADJUST;
306 : SET_ADJUST:
307 : {
308 0 : aSet.Put(SvxAdjustItem(eAdjst,RES_PARATR_ADJUST));
309 0 : rReq.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot), sal_True ) );
310 : }
311 0 : break;
312 :
313 : case SID_ATTR_PARA_LINESPACE:
314 0 : if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( GetPool().GetWhich(nSlot) ))
315 : {
316 : SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pArgs->Get(
317 0 : GetPool().GetWhich(nSlot));
318 0 : aSet.Put( aLineSpace );
319 : }
320 0 : break;
321 0 : case SID_ATTR_PARA_LINESPACE_10: ePropL = 100; goto SET_LINESPACE;
322 0 : case SID_ATTR_PARA_LINESPACE_15: ePropL = 150; goto SET_LINESPACE;
323 0 : case SID_ATTR_PARA_LINESPACE_20: ePropL = 200; goto SET_LINESPACE;
324 :
325 : SET_LINESPACE:
326 : {
327 :
328 0 : SvxLineSpacingItem aLineSpacing(ePropL, RES_PARATR_LINESPACING );
329 0 : aLineSpacing.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
330 0 : if( 100 == ePropL )
331 0 : aLineSpacing.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
332 : else
333 0 : aLineSpacing.SetPropLineSpace(ePropL);
334 0 : aSet.Put( aLineSpacing );
335 : }
336 0 : break;
337 :
338 : case SID_ATTR_PARA_LEFT_TO_RIGHT :
339 : case SID_ATTR_PARA_RIGHT_TO_LEFT :
340 : {
341 0 : SfxItemSet aAdjustSet( GetPool(),
342 0 : RES_PARATR_ADJUST, RES_PARATR_ADJUST );
343 0 : GetShell().GetCurAttr(aAdjustSet);
344 0 : bool bChgAdjust = false;
345 0 : SfxItemState eAdjustState = aAdjustSet.GetItemState(RES_PARATR_ADJUST, sal_False);
346 0 : if(eAdjustState >= SFX_ITEM_DEFAULT)
347 : {
348 : int eAdjust = (int)(( const SvxAdjustItem& )
349 0 : aAdjustSet.Get(RES_PARATR_ADJUST)).GetAdjust();
350 0 : bChgAdjust = (SVX_ADJUST_LEFT == eAdjust && SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot) ||
351 0 : (SVX_ADJUST_RIGHT == eAdjust && SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot);
352 : }
353 : else
354 0 : bChgAdjust = true;
355 :
356 : SvxFrameDirection eFrmDirection =
357 : (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
358 0 : FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
359 0 : aSet.Put( SvxFrameDirectionItem( eFrmDirection, RES_FRAMEDIR ) );
360 :
361 0 : if (bChgAdjust)
362 : {
363 : SvxAdjust eAdjust = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot) ?
364 0 : SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
365 0 : SvxAdjustItem aAdjust( eAdjust, RES_PARATR_ADJUST );
366 0 : aSet.Put( aAdjust );
367 0 : aAdjust.SetWhich(SID_ATTR_PARA_ADJUST);
368 0 : GetView().GetViewFrame()->GetBindings().SetState( aAdjust );
369 : // Toggle numbering alignment
370 0 : const SwNumRule* pCurRule = GetShell().GetCurNumRule();
371 0 : if( pCurRule )
372 : {
373 0 : SvxNumRule aRule = pCurRule->MakeSvxNumRule();
374 :
375 0 : for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
376 : {
377 0 : SvxNumberFormat aFmt(aRule.GetLevel(i));
378 0 : if(SVX_ADJUST_LEFT == aFmt.GetNumAdjust())
379 0 : aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
380 :
381 0 : else if(SVX_ADJUST_RIGHT == aFmt.GetNumAdjust())
382 0 : aFmt.SetNumAdjust( SVX_ADJUST_LEFT );
383 :
384 0 : aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
385 0 : }
386 0 : SwNumRule aSetRule( pCurRule->GetName(),
387 0 : pCurRule->Get( 0 ).GetPositionAndSpaceMode() );
388 0 : aSetRule.SetSvxRule( aRule, GetShell().GetDoc());
389 0 : aSetRule.SetAutoRule( sal_True );
390 : // no start or continuation of a list - list style is only changed
391 0 : GetShell().SetCurNumRule( aSetRule, false );
392 0 : }
393 0 : }
394 : }
395 0 : break;
396 :
397 : default:
398 : OSL_FAIL("wrong dispatcher");
399 0 : return;
400 : }
401 0 : SwWrtShell& rWrtSh = GetShell();
402 0 : SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
403 0 : if(pColl && pColl->IsAutoUpdateFmt())
404 : {
405 0 : rWrtSh.AutoUpdatePara(pColl, aSet);
406 : }
407 : else
408 0 : rWrtSh.SetAttr( aSet );
409 0 : rReq.Done();
410 : }
411 :
412 0 : void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
413 : {
414 0 : SwWrtShell &rSh = GetShell();
415 0 : const SfxItemSet *pArgs = rReq.GetArgs();
416 0 : const SfxPoolItem *pItem = 0;
417 :
418 0 : sal_uInt16 nSlot = rReq.GetSlot();
419 0 : if(pArgs)
420 0 : pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
421 0 : switch ( nSlot )
422 : {
423 : case FN_DROP_CHAR_STYLE_NAME:
424 0 : if( pItem )
425 : {
426 0 : String sCharStyleName = ((const SfxStringItem*)pItem)->GetValue();
427 0 : SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP, 0L);
428 0 : rSh.GetCurAttr(aSet);
429 0 : SwFmtDrop aDropItem((const SwFmtDrop&)aSet.Get(RES_PARATR_DROP));
430 0 : SwCharFmt* pFmt = 0;
431 0 : if(sCharStyleName.Len())
432 0 : pFmt = rSh.FindCharFmtByName( sCharStyleName );
433 0 : aDropItem.SetCharFmt( pFmt );
434 0 : aSet.Put(aDropItem);
435 0 : rSh.SetAttr(aSet);
436 : }
437 0 : break;
438 : case FN_FORMAT_DROPCAPS:
439 : {
440 0 : if(pItem)
441 : {
442 0 : rSh.SetAttr(*pItem);
443 0 : rReq.Done();
444 : }
445 : else
446 : {
447 0 : SfxItemSet aSet(GetPool(), RES_PARATR_DROP, RES_PARATR_DROP,
448 0 : HINT_END, HINT_END, 0);
449 0 : rSh.GetCurAttr(aSet);
450 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
451 : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
452 :
453 0 : SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aSet,
454 0 : rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), DLG_SWDROPCAPS );
455 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
456 0 : if (pDlg->Execute() == RET_OK)
457 : {
458 0 : rSh.StartAction();
459 0 : rSh.StartUndo( UNDO_START );
460 0 : if ( SFX_ITEM_SET == aSet.GetItemState(HINT_END,sal_False,&pItem) )
461 : {
462 0 : if ( !((SfxStringItem*)pItem)->GetValue().isEmpty() )
463 0 : rSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
464 : }
465 0 : rSh.SetAttr(*pDlg->GetOutputItemSet());
466 0 : rSh.StartUndo( UNDO_END );
467 0 : rSh.EndAction();
468 0 : rReq.Done(*pDlg->GetOutputItemSet());
469 : }
470 0 : delete pDlg;
471 : }
472 : }
473 0 : break;
474 : case SID_ATTR_PARA_PAGEBREAK:
475 0 : if(pItem)
476 : {
477 0 : rSh.SetAttr( *pItem );
478 0 : rReq.Done();
479 : }
480 0 : break;
481 : case SID_ATTR_PARA_MODEL:
482 : {
483 0 : if(pItem)
484 : {
485 0 : SfxItemSet aCoreSet( GetPool(),
486 : RES_PAGEDESC, RES_PAGEDESC,
487 0 : SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, 0);
488 0 : aCoreSet.Put(*pItem);
489 0 : SfxToSwPageDescAttr( rSh, aCoreSet);
490 0 : rSh.SetAttr(aCoreSet);
491 0 : rReq.Done();
492 : }
493 : }
494 0 : break;
495 :
496 : default:
497 : OSL_FAIL("wrong dispatcher");
498 0 : return;
499 : }
500 : }
501 :
502 :
503 :
504 7277 : void SwTextShell::GetAttrState(SfxItemSet &rSet)
505 : {
506 7277 : SwWrtShell &rSh = GetShell();
507 7277 : SfxItemPool& rPool = GetPool();
508 7277 : SfxItemSet aCoreSet(rPool, aTxtFmtCollSetRange);
509 7277 : rSh.GetCurAttr(aCoreSet); // Request *all* text attributes from the core.
510 :
511 14554 : SfxWhichIter aIter(rSet);
512 7277 : sal_uInt16 nSlot = aIter.FirstWhich();
513 7277 : sal_Bool bFlag = sal_False;
514 14554 : SfxBoolItem aFlagItem;
515 7277 : const SfxPoolItem* pItem = 0;
516 7277 : int eAdjust = -1; // Illegal value to recognize DONTCARE.
517 7277 : SfxItemState eState = aCoreSet.GetItemState(RES_PARATR_ADJUST, sal_False, &pItem);
518 :
519 7277 : if( SFX_ITEM_DEFAULT == eState )
520 7275 : pItem = &rPool.GetDefaultItem(RES_PARATR_ADJUST);
521 7277 : if( SFX_ITEM_DEFAULT <= eState )
522 7275 : eAdjust = (int)(( SvxAdjustItem* ) pItem)->GetAdjust();
523 :
524 7277 : short nEsc = 0;
525 7277 : eState = aCoreSet.GetItemState(RES_CHRATR_ESCAPEMENT, sal_False, &pItem);
526 7277 : if( SFX_ITEM_DEFAULT == eState )
527 7277 : pItem = &rPool.GetDefaultItem(RES_CHRATR_ESCAPEMENT);
528 7277 : if( eState >= SFX_ITEM_DEFAULT )
529 7277 : nEsc = ((SvxEscapementItem* )pItem)->GetEsc();
530 :
531 7277 : sal_uInt16 nLineSpace = 0;
532 7277 : eState = aCoreSet.GetItemState(RES_PARATR_LINESPACING, sal_False, &pItem);
533 7277 : if( SFX_ITEM_DEFAULT == eState )
534 7277 : pItem = &rPool.GetDefaultItem(RES_PARATR_LINESPACING);
535 14554 : if( SFX_ITEM_DEFAULT <= eState &&
536 7277 : ((SvxLineSpacingItem* )pItem)->GetLineSpaceRule() == SVX_LINE_SPACE_AUTO )
537 : {
538 7277 : if(SVX_INTER_LINE_SPACE_OFF ==
539 7277 : ((SvxLineSpacingItem* )pItem)->GetInterLineSpaceRule())
540 7277 : nLineSpace = 100;
541 : else
542 0 : nLineSpace = ((SvxLineSpacingItem* )pItem)->GetPropLineSpace();
543 : }
544 :
545 25432 : while (nSlot)
546 : {
547 10878 : switch(nSlot)
548 : {
549 : case FN_SET_SUPER_SCRIPT:
550 624 : bFlag = 0 < nEsc;
551 624 : break;
552 : case FN_SET_SUB_SCRIPT:
553 624 : bFlag = 0 > nEsc;
554 624 : break;
555 : case SID_ATTR_PARA_ADJUST_LEFT:
556 624 : if (eAdjust == -1)
557 : {
558 2 : rSet.InvalidateItem( nSlot );
559 2 : nSlot = 0;
560 : }
561 : else
562 622 : bFlag = SVX_ADJUST_LEFT == eAdjust;
563 624 : break;
564 : case SID_ATTR_PARA_ADJUST_RIGHT:
565 624 : if (eAdjust == -1)
566 : {
567 2 : rSet.InvalidateItem( nSlot );
568 2 : nSlot = 0;
569 : }
570 : else
571 622 : bFlag = SVX_ADJUST_RIGHT == eAdjust;
572 624 : break;
573 : case SID_ATTR_PARA_ADJUST_CENTER:
574 624 : if (eAdjust == -1)
575 : {
576 2 : rSet.InvalidateItem( nSlot );
577 2 : nSlot = 0;
578 : }
579 : else
580 622 : bFlag = SVX_ADJUST_CENTER == eAdjust;
581 624 : break;
582 : case SID_ATTR_PARA_ADJUST_BLOCK:
583 : {
584 624 : if (eAdjust == -1)
585 : {
586 2 : rSet.InvalidateItem( nSlot );
587 2 : nSlot = 0;
588 : }
589 : else
590 : {
591 622 : bFlag = SVX_ADJUST_BLOCK == eAdjust;
592 622 : sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
593 622 : if((nHtmlMode & HTMLMODE_ON) && !(nHtmlMode & HTMLMODE_FULL_STYLES ))
594 : {
595 2 : rSet.DisableItem( nSlot );
596 2 : nSlot = 0;
597 : }
598 : }
599 : }
600 624 : break;
601 : case SID_ATTR_PARA_LINESPACE_10:
602 624 : bFlag = nLineSpace == 100;
603 624 : break;
604 : case SID_ATTR_PARA_LINESPACE_15:
605 624 : bFlag = nLineSpace == 150;
606 624 : break;
607 : case SID_ATTR_PARA_LINESPACE_20:
608 624 : bFlag = nLineSpace == 200;
609 624 : break;
610 : case FN_GROW_FONT_SIZE:
611 : case FN_SHRINK_FONT_SIZE:
612 : {
613 : SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT,
614 1248 : *rSet.GetPool() );
615 1248 : aSetItem.GetItemSet().Put( aCoreSet, sal_False );
616 1248 : if( !aSetItem.GetItemOfScript( rSh.GetScriptType() ))
617 0 : rSet.DisableItem( nSlot );
618 1248 : nSlot = 0;
619 : }
620 1248 : break;
621 : case FN_UNDERLINE_DOUBLE:
622 : {
623 0 : eState = aCoreSet.GetItemState(RES_CHRATR_UNDERLINE);
624 0 : if( eState >= SFX_ITEM_DEFAULT )
625 : {
626 : FontUnderline eUnderline = ((const SvxUnderlineItem&)
627 0 : aCoreSet.Get(RES_CHRATR_UNDERLINE)).GetLineStyle();
628 0 : rSet.Put(SfxBoolItem(nSlot, eUnderline == UNDERLINE_DOUBLE));
629 : }
630 : else
631 0 : rSet.InvalidateItem(nSlot);
632 0 : nSlot = 0;
633 : }
634 0 : break;
635 : case SID_ATTR_PARA_ADJUST:
636 0 : if (eAdjust == -1)
637 0 : rSet.InvalidateItem( nSlot );
638 : else
639 0 : rSet.Put(SvxAdjustItem((SvxAdjust)eAdjust, SID_ATTR_PARA_ADJUST ));
640 0 : nSlot = 0;
641 0 : break;
642 : case SID_ATTR_PARA_LRSPACE:
643 : {
644 264 : eState = aCoreSet.GetItemState(RES_LR_SPACE);
645 264 : if( eState >= SFX_ITEM_DEFAULT )
646 : {
647 264 : SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aCoreSet.Get( RES_LR_SPACE ) );
648 264 : aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
649 264 : rSet.Put(aLR);
650 : }
651 : else
652 0 : rSet.InvalidateItem(nSlot);
653 264 : nSlot = 0;
654 : }
655 :
656 : case SID_ATTR_PARA_LEFT_TO_RIGHT :
657 : case SID_ATTR_PARA_RIGHT_TO_LEFT :
658 : {
659 2268 : if ( !SW_MOD()->GetCTLOptions().IsCTLFontEnabled() )
660 : {
661 2268 : rSet.DisableItem( nSlot );
662 2268 : nSlot = 0;
663 : }
664 : else
665 : {
666 : // is the item set?
667 0 : sal_uInt16 nHtmlMode = GetHtmlMode(rSh.GetView().GetDocShell());
668 0 : if((!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES))) &&
669 0 : aCoreSet.GetItemState( RES_FRAMEDIR, sal_False ) >= SFX_ITEM_DEFAULT)
670 : {
671 : SvxFrameDirection eFrmDir = (SvxFrameDirection)
672 0 : ((const SvxFrameDirectionItem& )aCoreSet.Get(RES_FRAMEDIR)).GetValue();
673 0 : if (FRMDIR_ENVIRONMENT == eFrmDir)
674 : {
675 0 : eFrmDir = rSh.IsInRightToLeftText() ?
676 0 : FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
677 : }
678 0 : bFlag = (SID_ATTR_PARA_LEFT_TO_RIGHT == nSlot &&
679 0 : FRMDIR_HORI_LEFT_TOP == eFrmDir) ||
680 0 : (SID_ATTR_PARA_RIGHT_TO_LEFT == nSlot &&
681 0 : FRMDIR_HORI_RIGHT_TOP == eFrmDir);
682 : }
683 : else
684 : {
685 0 : rSet.InvalidateItem(nSlot);
686 0 : nSlot = 0;
687 : }
688 : }
689 : }
690 2268 : break;
691 :
692 : case SID_ATTR_CHAR_LANGUAGE:
693 : case SID_ATTR_CHAR_KERNING:
694 : case RES_PARATR_DROP:
695 : {
696 : #if OSL_DEBUG_LEVEL > 1
697 : const SfxPoolItem& rItem = aCoreSet.Get(GetPool().GetWhich(nSlot), sal_True);
698 : rSet.Put(rItem);
699 : #else
700 0 : rSet.Put(aCoreSet.Get( GetPool().GetWhich(nSlot), sal_True));
701 : #endif
702 0 : nSlot = 0;
703 : }
704 0 : break;
705 : case SID_ATTR_PARA_MODEL:
706 : {
707 0 : SfxItemSet aTemp(GetPool(),
708 : RES_PAGEDESC,RES_PAGEDESC,
709 : SID_ATTR_PARA_MODEL,SID_ATTR_PARA_MODEL,
710 0 : 0L);
711 0 : aTemp.Put(aCoreSet);
712 0 : ::SwToSfxPageDescAttr(aTemp);
713 0 : rSet.Put(aTemp.Get(SID_ATTR_PARA_MODEL));
714 0 : nSlot = 0;
715 : }
716 0 : break;
717 : case RES_TXTATR_INETFMT:
718 : {
719 0 : SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
720 0 : rSh.GetCurAttr(aSet);
721 0 : const SfxPoolItem& rItem = aSet.Get(RES_TXTATR_INETFMT, sal_True);
722 0 : rSet.Put(rItem);
723 0 : nSlot = 0;
724 : }
725 0 : break;
726 :
727 : default:
728 : // Do nothing
729 1746 : nSlot = 0;
730 1746 : break;
731 :
732 : }
733 10878 : if( nSlot )
734 : {
735 5606 : aFlagItem.SetWhich( nSlot );
736 5606 : aFlagItem.SetValue( bFlag );
737 5606 : rSet.Put( aFlagItem );
738 : }
739 10878 : nSlot = aIter.NextWhich();
740 : }
741 :
742 14554 : rSet.Put(aCoreSet,sal_False);
743 7376 : }
744 :
745 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|