1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/container/XNameAccess.hpp>
24 #include "scitems.hxx"
25 #include <editeng/borderline.hxx>
26 #include <editeng/eeitem.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/objface.hxx>
32 #include <sfx2/request.hxx>
33 #include <svl/whiter.hxx>
34 #include <vcl/msgbox.hxx>
36 #include <svl/stritem.hxx>
37 #include <svl/zformat.hxx>
38 #include <svl/languageoptions.hxx>
39 #include <editeng/boxitem.hxx>
40 #include <editeng/langitem.hxx>
41 #include <svx/numinf.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/templdlg.hxx>
44 #include <sfx2/tplpitem.hxx>
45 #include <editeng/svxenum.hxx>
46 #include <svx/algitem.hxx>
47 #include <editeng/wghtitem.hxx>
48 #include <editeng/postitem.hxx>
49 #include <editeng/udlnitem.hxx>
50 #include <editeng/lineitem.hxx>
51 #include <editeng/colritem.hxx>
52 #include <editeng/brushitem.hxx>
53 #include <editeng/frmdiritem.hxx>
54 #include <editeng/scripttypeitem.hxx>
55 #include <svtools/colorcfg.hxx>
56 #include <editeng/shaditem.hxx>
57 #include <editeng/justifyitem.hxx>
59 #include "formatsh.hxx"
61 #include "globstr.hrc"
63 #include "patattr.hxx"
65 #include "stlpool.hxx"
66 #include "stlsheet.hxx"
67 #include "printfun.hxx"
68 #include "docpool.hxx"
69 #include "scresid.hxx"
70 #include "tabvwsh.hxx"
71 #include "undostyl.hxx"
72 #include "markdata.hxx"
73 #include "markarr.hxx"
78 #define FormatForSelection
79 #include "scslots.hxx"
81 #include "scabstdlg.hxx"
82 #include <editeng/fontitem.hxx>
84 using namespace ::com::sun::star
;
88 SvxCellHorJustify
lclConvertSlotToHAlign( sal_uInt16 nSlot
)
90 SvxCellHorJustify eHJustify
= SVX_HOR_JUSTIFY_STANDARD
;
93 case SID_ALIGN_ANY_HDEFAULT
: eHJustify
= SVX_HOR_JUSTIFY_STANDARD
; break;
94 case SID_ALIGN_ANY_LEFT
: eHJustify
= SVX_HOR_JUSTIFY_LEFT
; break;
95 case SID_ALIGN_ANY_HCENTER
: eHJustify
= SVX_HOR_JUSTIFY_CENTER
; break;
96 case SID_ALIGN_ANY_RIGHT
: eHJustify
= SVX_HOR_JUSTIFY_RIGHT
; break;
97 case SID_ALIGN_ANY_JUSTIFIED
: eHJustify
= SVX_HOR_JUSTIFY_BLOCK
; break;
98 default: OSL_FAIL( "lclConvertSlotToHAlign - invalid slot" );
103 SvxCellVerJustify
lclConvertSlotToVAlign( sal_uInt16 nSlot
)
105 SvxCellVerJustify eVJustify
= SVX_VER_JUSTIFY_STANDARD
;
108 case SID_ALIGN_ANY_VDEFAULT
: eVJustify
= SVX_VER_JUSTIFY_STANDARD
; break;
109 case SID_ALIGN_ANY_TOP
: eVJustify
= SVX_VER_JUSTIFY_TOP
; break;
110 case SID_ALIGN_ANY_VCENTER
: eVJustify
= SVX_VER_JUSTIFY_CENTER
; break;
111 case SID_ALIGN_ANY_BOTTOM
: eVJustify
= SVX_VER_JUSTIFY_BOTTOM
; break;
112 default: OSL_FAIL( "lclConvertSlotToVAlign - invalid slot" );
119 TYPEINIT1( ScFormatShell
, SfxShell
);
121 SFX_IMPL_INTERFACE(ScFormatShell
, SfxShell
, ScResId(SCSTR_FORMATSHELL
) )
123 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
|
124 SFX_VISIBILITY_SERVER
,
125 ScResId(RID_OBJECTBAR_FORMAT
));
130 ScFormatShell::ScFormatShell(ScViewData
* pData
) :
131 SfxShell(pData
->GetViewShell()),
134 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
136 SetPool( &pTabViewShell
->GetPool() );
137 ::svl::IUndoManager
* pMgr
= pViewData
->GetSfxDocShell()->GetUndoManager();
138 SetUndoManager( pMgr
);
139 if ( !pViewData
->GetDocument()->IsUndoEnabled() )
141 pMgr
->SetMaxUndoActionCount( 0 );
143 SetHelpId(HID_SCSHELL_FORMATSH
);
144 SetName(OUString("Format"));
147 ScFormatShell::~ScFormatShell()
151 //------------------------------------------------------------------
153 void ScFormatShell::GetStyleState( SfxItemSet
& rSet
)
155 ScDocument
* pDoc
= GetViewData()->GetDocument();
156 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
157 SfxStyleSheetBasePool
* pStylePool
= pDoc
->GetStyleSheetPool();
159 bool bProtected
= false;
160 SCTAB nTabCount
= pDoc
->GetTableCount();
161 for (SCTAB i
=0; i
<nTabCount
; i
++)
162 if (pDoc
->IsTabProtected(i
)) // look after protected table
165 SfxWhichIter
aIter(rSet
);
166 sal_uInt16 nWhich
= aIter
.FirstWhich();
167 sal_uInt16 nSlotId
= 0;
171 nSlotId
= SfxItemPool::IsWhich( nWhich
)
172 ? GetPool().GetSlotId( nWhich
)
177 case SID_STYLE_APPLY
:
179 rSet
.DisableItem( nSlotId
);
182 case SID_STYLE_FAMILY2
: // cell style sheets
184 SfxStyleSheet
* pStyleSheet
= (SfxStyleSheet
*)
185 pTabViewShell
->GetStyleSheetFromMarked();
188 rSet
.Put( SfxTemplateItem( nSlotId
, pStyleSheet
->GetName() ) );
190 rSet
.Put( SfxTemplateItem( nSlotId
, String() ) );
194 case SID_STYLE_FAMILY4
: // page style sheets
196 SCTAB nCurTab
= GetViewData()->GetTabNo();
197 String aPageStyle
= pDoc
->GetPageStyle( nCurTab
);
198 SfxStyleSheet
* pStyleSheet
= (SfxStyleSheet
*)pStylePool
->
199 Find( aPageStyle
, SFX_STYLE_FAMILY_PAGE
);
202 rSet
.Put( SfxTemplateItem( nSlotId
, aPageStyle
) );
204 rSet
.Put( SfxTemplateItem( nSlotId
, String() ) );
208 case SID_STYLE_WATERCAN
:
210 rSet
.Put( SfxBoolItem( nSlotId
, SC_MOD()->GetIsWaterCan() ) );
214 case SID_STYLE_UPDATE_BY_EXAMPLE
:
216 ISfxTemplateCommon
* pDesigner
= SFX_APP()->
217 GetCurrentTemplateCommon(pTabViewShell
->GetViewFrame()->GetBindings());
218 bool bPage
= pDesigner
&& SFX_STYLE_FAMILY_PAGE
== pDesigner
->GetActualFamily();
220 if ( bProtected
|| bPage
)
221 rSet
.DisableItem( nSlotId
);
226 case SID_STYLE_DELETE
:
230 ISfxTemplateCommon
* pDesigner
= SFX_APP()->
231 GetCurrentTemplateCommon(pTabViewShell
->GetViewFrame()->GetBindings());
232 bool bPage
= pDesigner
&& SFX_STYLE_FAMILY_PAGE
== pDesigner
->GetActualFamily();
234 if ( bProtected
&& !bPage
)
235 rSet
.DisableItem( nSlotId
);
243 nWhich
= aIter
.NextWhich();
247 //------------------------------------------------------------------
249 void ScFormatShell::ExecuteStyle( SfxRequest
& rReq
)
251 // in case of vertical toolbar
252 if ( !rReq
.GetArgs() )
254 pViewData
->GetDispatcher().Execute( SID_STYLE_DESIGNER
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
258 //--------------------------------------------------------------------
259 SfxBindings
& rBindings
= pViewData
->GetBindings();
260 const SfxItemSet
* pArgs
= rReq
.GetArgs();
261 const sal_uInt16 nSlotId
= rReq
.GetSlot();
262 const SCTAB nCurTab
= GetViewData()->GetTabNo();
263 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
264 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
265 ScDocument
* pDoc
= pDocSh
->GetDocument();
266 ScMarkData
& rMark
= GetViewData()->GetMarkData();
267 ScModule
* pScMod
= SC_MOD();
269 bool bUndo
= pDoc
->IsUndoEnabled();
271 if ( (nSlotId
== SID_STYLE_NEW
)
272 || (nSlotId
== SID_STYLE_EDIT
)
273 || (nSlotId
== SID_STYLE_DELETE
)
274 || (nSlotId
== SID_STYLE_HIDE
)
275 || (nSlotId
== SID_STYLE_SHOW
)
276 || (nSlotId
== SID_STYLE_APPLY
)
277 || (nSlotId
== SID_STYLE_WATERCAN
)
278 || (nSlotId
== SID_STYLE_FAMILY
)
279 || (nSlotId
== SID_STYLE_NEW_BY_EXAMPLE
)
280 || (nSlotId
== SID_STYLE_UPDATE_BY_EXAMPLE
) )
282 SfxStyleSheetBasePool
* pStylePool
= pDoc
->GetStyleSheetPool();
283 SfxStyleSheetBase
* pStyleSheet
= NULL
;
285 bool bStyleToMarked
= false;
286 bool bListAction
= false;
287 bool bAddUndo
= false; // add ScUndoModifyStyle (style modified)
288 ScStyleSaveData aOldData
; // for undo/redo
289 ScStyleSaveData aNewData
;
291 SfxStyleFamily eFamily
= SFX_STYLE_FAMILY_PARA
;
292 const SfxPoolItem
* pFamItem
;
293 if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_FAMILY
, sal_True
, &pFamItem
) )
294 eFamily
= (SfxStyleFamily
)((const SfxUInt16Item
*)pFamItem
)->GetValue();
295 else if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_FAMILYNAME
, sal_True
, &pFamItem
) )
297 String sFamily
= ((const SfxStringItem
*)pFamItem
)->GetValue();
298 if (sFamily
.CompareToAscii("CellStyles") == COMPARE_EQUAL
)
299 eFamily
= SFX_STYLE_FAMILY_PARA
;
300 else if (sFamily
.CompareToAscii("PageStyles") == COMPARE_EQUAL
)
301 eFamily
= SFX_STYLE_FAMILY_PAGE
;
305 sal_uInt16 nRetMask
= 0xffff;
307 pStylePool
->SetSearchMask( eFamily
, SFXSTYLEBIT_ALL
);
313 const SfxPoolItem
* pNameItem
;
314 if (pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nSlotId
, sal_True
, &pNameItem
))
315 aStyleName
= ((const SfxStringItem
*)pNameItem
)->GetValue();
317 const SfxPoolItem
* pRefItem
=NULL
;
318 if (pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( SID_STYLE_REFERENCE
, sal_True
, &pRefItem
))
321 aRefName
= ((const SfxStringItem
*)pRefItem
)->GetValue();
324 pStyleSheet
= &(pStylePool
->Make( aStyleName
, eFamily
,
325 SFXSTYLEBIT_USERDEF
) );
327 if ( pStyleSheet
&& pStyleSheet
->HasParentSupport() )
328 pStyleSheet
->SetParent(aRefName
);
332 case SID_STYLE_APPLY
:
334 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, SID_APPLY_STYLE
, false );
335 SFX_REQUEST_ARG( rReq
, pFamilyItem
, SfxStringItem
, SID_STYLE_FAMILYNAME
, false );
336 if ( pFamilyItem
&& pNameItem
)
338 com::sun::star::uno::Reference
< com::sun::star::style::XStyleFamiliesSupplier
> xModel(pDocSh
->GetModel(), com::sun::star::uno::UNO_QUERY
);
341 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xStyles
;
342 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xCont
= xModel
->getStyleFamilies();
343 xCont
->getByName(pFamilyItem
->GetValue()) >>= xStyles
;
344 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xInfo
;
345 xStyles
->getByName( pNameItem
->GetValue() ) >>= xInfo
;
347 xInfo
->getPropertyValue( OUString("DisplayName") ) >>= aUIName
;
348 if ( !aUIName
.isEmpty() )
349 rReq
.AppendItem( SfxStringItem( SID_STYLE_APPLY
, aUIName
) );
351 catch( com::sun::star::uno::Exception
& )
357 case SID_STYLE_DELETE
:
360 case SID_STYLE_NEW_BY_EXAMPLE
:
362 const SfxPoolItem
* pNameItem
;
363 if (pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nSlotId
, sal_True
, &pNameItem
))
364 aStyleName
= ((const SfxStringItem
*)pNameItem
)->GetValue();
365 pStyleSheet
= pStylePool
->Find( aStyleName
, eFamily
);
367 aOldData
.InitFromStyle( pStyleSheet
);
371 case SID_STYLE_WATERCAN
:
373 bool bWaterCan
= pScMod
->GetIsWaterCan();
377 const SfxPoolItem
* pItem
;
380 pArgs
->GetItemState( nSlotId
, sal_True
, &pItem
) )
382 const SfxStringItem
* pStrItem
= PTR_CAST(SfxStringItem
,pItem
);
385 aStyleName
= pStrItem
->GetValue();
386 pStyleSheet
= pStylePool
->Find( aStyleName
, eFamily
);
390 ((ScStyleSheetPool
*)pStylePool
)->
391 SetActualStyleSheet( pStyleSheet
);
398 if ( !bWaterCan
&& pStyleSheet
)
400 pScMod
->SetWaterCan( true );
401 pTabViewShell
->SetActivePointer( Pointer(POINTER_FILL
) );
406 pScMod
->SetWaterCan( false );
407 pTabViewShell
->SetActivePointer( Pointer(POINTER_ARROW
) );
417 // set new style for WaterCan-Mode
418 if ( nSlotId
== SID_STYLE_APPLY
&& pScMod
->GetIsWaterCan() && pStyleSheet
)
419 ((ScStyleSheetPool
*)pStylePool
)->SetActualStyleSheet( pStyleSheet
);
423 case SFX_STYLE_FAMILY_PARA
:
427 case SID_STYLE_DELETE
:
431 pTabViewShell
->RemoveStyleSheetInUse( pStyleSheet
);
432 pStylePool
->Remove( pStyleSheet
);
433 pTabViewShell
->InvalidateAttribs();
448 pStyleSheet
->SetHidden( nSlotId
== SID_STYLE_HIDE
);
449 pTabViewShell
->InvalidateAttribs();
457 case SID_STYLE_APPLY
:
459 if ( pStyleSheet
&& !pScMod
->GetIsWaterCan() )
461 // apply style sheet to document
462 pTabViewShell
->SetStyleSheetToMarked( (SfxStyleSheet
*)pStyleSheet
);
463 pTabViewShell
->InvalidateAttribs();
469 case SID_STYLE_NEW_BY_EXAMPLE
:
470 case SID_STYLE_UPDATE_BY_EXAMPLE
:
472 // create/replace style sheet by attributes
473 // at cursor position:
475 const ScPatternAttr
* pAttrItem
= NULL
;
477 // Die Abfrage, ob markiert ist, war hier immer falsch,
478 // darum jetzt gar nicht mehr, und einfach vom Cursor.
479 // Wenn Attribute aus der Selektion genommen werden sollen,
480 // muss noch darauf geachtet werden, Items aus Vorlagen nicht
481 // zu uebernehmen (GetSelectionPattern sammelt auch Items aus
482 // Vorlagen zusammen) (#44748#)
483 // pAttrItem = GetSelectionPattern();
485 // ScViewData* pViewData = GetViewData();
486 SCCOL nCol
= pViewData
->GetCurX();
487 SCROW nRow
= pViewData
->GetCurY();
488 pAttrItem
= pDoc
->GetPattern( nCol
, nRow
, nCurTab
);
490 SfxItemSet aAttrSet
= pAttrItem
->GetItemSet();
491 aAttrSet
.ClearItem( ATTR_MERGE
);
492 aAttrSet
.ClearItem( ATTR_MERGE_FLAG
);
493 // bedingte Formatierung und Gueltigkeit nicht uebernehmen,
494 // weil sie in der Vorlage nicht editiert werden koennen
495 aAttrSet
.ClearItem( ATTR_VALIDDATA
);
496 aAttrSet
.ClearItem( ATTR_CONDITIONAL
);
498 if ( SID_STYLE_NEW_BY_EXAMPLE
== nSlotId
)
502 String aUndo
= ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE
);
503 pDocSh
->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
507 bool bConvertBack
= false;
508 SfxStyleSheet
* pSheetInUse
= (SfxStyleSheet
*)
509 pTabViewShell
->GetStyleSheetFromMarked();
511 // wenn neuer Style vorhanden und in der Selektion
512 // verwendet wird, so darf der Parent nicht uebernommen
515 if ( pStyleSheet
&& pSheetInUse
&& pStyleSheet
== pSheetInUse
)
518 // wenn bereits vorhanden, erstmal entfernen...
521 // Style-Pointer zu Namen vor Erase,
522 // weil Zellen sonst ungueltige Pointer
524 //!!! bei Gelenheit mal eine Methode, die
525 // das fuer einen bestimmten Style macht
526 pDoc
->StylesToNames();
528 pStylePool
->Remove(pStyleSheet
);
531 // ...und neu anlegen
532 pStyleSheet
= &pStylePool
->Make( aStyleName
, eFamily
,
533 SFXSTYLEBIT_USERDEF
);
535 // wenn ein Style vorhanden ist, so wird dieser
536 // Parent der neuen Vorlage:
537 if ( pSheetInUse
&& pStyleSheet
->HasParentSupport() )
538 pStyleSheet
->SetParent( pSheetInUse
->GetName() );
541 // Namen zu Style-Pointer
542 pDoc
->UpdStlShtPtrsFrmNms();
544 pDoc
->GetPool()->CellStyleCreated( aStyleName
);
546 // Attribute uebernehmen und Style anwenden
547 pStyleSheet
->GetItemSet().Put( aAttrSet
);
548 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
550 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
551 // (pStyleSheet pointer is used!)
552 bStyleToMarked
= true;
554 else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
556 pStyleSheet
= (SfxStyleSheet
*)pTabViewShell
->GetStyleSheetFromMarked();
560 aOldData
.InitFromStyle( pStyleSheet
);
564 String aUndo
= ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE
);
565 pDocSh
->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
569 pStyleSheet
->GetItemSet().Put( aAttrSet
);
570 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
572 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
573 // (pStyleSheet pointer is used!)
574 bStyleToMarked
= true;
578 aNewData
.InitFromStyle( pStyleSheet
);
587 } // case SFX_STYLE_FAMILY_PARA:
590 case SFX_STYLE_FAMILY_PAGE
:
594 case SID_STYLE_DELETE
:
596 nRetMask
= ( NULL
!= pStyleSheet
);
599 if ( pDoc
->RemovePageStyleInUse( pStyleSheet
->GetName() ) )
601 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), nCurTab
).UpdatePages();
602 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
603 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
605 pStylePool
->Remove( pStyleSheet
);
606 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
607 pDocSh
->SetDocumentModified();
617 nRetMask
= ( NULL
!= pStyleSheet
);
620 pStyleSheet
->SetHidden( nSlotId
== SID_STYLE_HIDE
);
621 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
622 pDocSh
->SetDocumentModified();
628 case SID_STYLE_APPLY
:
630 nRetMask
= ( NULL
!= pStyleSheet
);
631 if ( pStyleSheet
&& !pScMod
->GetIsWaterCan() )
633 ScUndoApplyPageStyle
* pUndoAction
= 0;
634 SCTAB nTabCount
= pDoc
->GetTableCount();
635 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
636 for (; itr
!= itrEnd
&& *itr
< nTabCount
; ++itr
)
638 String aOldName
= pDoc
->GetPageStyle( *itr
);
639 if ( aOldName
!= aStyleName
)
641 pDoc
->SetPageStyle( *itr
, aStyleName
);
642 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), *itr
).UpdatePages();
644 pUndoAction
= new ScUndoApplyPageStyle( pDocSh
, aStyleName
);
645 pUndoAction
->AddSheetAction( *itr
, aOldName
);
650 pDocSh
->GetUndoManager()->AddUndoAction( pUndoAction
);
651 pDocSh
->SetDocumentModified();
652 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
653 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
654 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
661 case SID_STYLE_NEW_BY_EXAMPLE
:
663 const String
& rStrCurStyle
= pDoc
->GetPageStyle( nCurTab
);
665 if ( rStrCurStyle
!= aStyleName
)
667 SfxStyleSheetBase
* pCurStyle
= pStylePool
->Find( rStrCurStyle
, eFamily
);
668 SfxItemSet aAttrSet
= pCurStyle
->GetItemSet();
670 bool bUsed
= pDoc
->IsPageStyleInUse( aStyleName
, &nInTab
);
672 // wenn bereits vorhanden, erstmal entfernen...
674 pStylePool
->Remove( pStyleSheet
);
676 // ...und neu anlegen
677 pStyleSheet
= &pStylePool
->Make( aStyleName
, eFamily
,
678 SFXSTYLEBIT_USERDEF
);
680 // Attribute uebernehmen
681 pStyleSheet
->GetItemSet().Put( aAttrSet
);
682 pDocSh
->SetDocumentModified();
684 // wenn in Verwendung -> Update
686 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), nInTab
).UpdatePages();
688 aNewData
.InitFromStyle( pStyleSheet
);
698 } // switch ( nSlotId )
699 } // case SFX_STYLE_FAMILY_PAGE:
704 } // switch ( eFamily )
706 // Neu anlegen oder bearbeiten ueber Dialog:
707 if ( nSlotId
== SID_STYLE_NEW
|| nSlotId
== SID_STYLE_EDIT
)
711 SvxNumberInfoItem
* pNumberInfoItem
= NULL
;
713 SfxStyleFamily eFam
= pStyleSheet
->GetFamily();
714 SfxAbstractTabDialog
* pDlg
= NULL
;
717 // alte Items aus der Vorlage merken
718 SfxItemSet aOldSet
= pStyleSheet
->GetItemSet();
719 String aOldName
= pStyleSheet
->GetName();
723 case SFX_STYLE_FAMILY_PAGE
:
724 nRsc
= RID_SCDLG_STYLES_PAGE
;
727 case SFX_STYLE_FAMILY_PARA
:
730 SfxItemSet
& rSet
= pStyleSheet
->GetItemSet();
732 const SfxPoolItem
* pItem
;
733 if ( rSet
.GetItemState( ATTR_VALUE_FORMAT
,
734 false, &pItem
) == SFX_ITEM_SET
)
736 // NumberFormat Value aus Value und Language
737 // erzeugen und eintueten
739 ((SfxUInt32Item
*)pItem
)->GetValue();
741 ((SvxLanguageItem
*)&rSet
.Get(
742 ATTR_LANGUAGE_FORMAT
))->GetLanguage();
743 sal_uLong nLangFormat
= pDoc
->GetFormatTable()->
744 GetFormatForLanguageIfBuiltIn( nFormat
, eLang
);
745 if ( nLangFormat
!= nFormat
)
747 SfxUInt32Item
aNewItem( ATTR_VALUE_FORMAT
, nLangFormat
);
748 rSet
.Put( aNewItem
);
749 aOldSet
.Put( aNewItem
);
750 // auch in aOldSet fuer Vergleich nach dem Dialog,
751 // sonst geht evtl. eine Aenderung der Sprache verloren
755 pTabViewShell
->MakeNumberInfoItem( pDoc
, GetViewData(), &pNumberInfoItem
);
756 pDocSh
->PutItem( *pNumberInfoItem
);
757 nRsc
= RID_SCDLG_STYLES_PAR
;
759 // auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set:
760 // (wenn gar kein Item da ist, loescht der Dialog auch das
761 // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set)
763 if ( rSet
.GetItemState( ATTR_BORDER_INNER
, false ) != SFX_ITEM_SET
)
765 SvxBoxInfoItem
aBoxInfoItem( ATTR_BORDER_INNER
);
766 aBoxInfoItem
.SetTable(false); // keine inneren Linien
767 aBoxInfoItem
.SetDist(true);
768 aBoxInfoItem
.SetMinDist(false);
769 rSet
.Put( aBoxInfoItem
);
775 // If GetDefDialogParent is a dialog, it must be used
778 Window
* pParent
= Application::GetDefDialogParent();
779 if ( !pParent
|| !pParent
->IsDialog() )
781 // GetDefDialogParent currently doesn't return the window
782 // that was set with SetDefDialogParent (but dynamically finds the
783 // topmost parent of the focus window), so IsDialog above is FALSE
784 // even if called from the style catalog.
785 // -> Use NULL if a modal dialog is open, to enable the Dialog's
786 // default parent handling.
787 if ( Application::IsInModalMode() )
790 pParent
= pTabViewShell
->GetDialogParent();
793 pTabViewShell
->SetInFormatDialog(true);
795 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
796 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
798 pDlg
= pFact
->CreateScStyleDlg( pParent
, *pStyleSheet
, nRsc
, nRsc
);
799 OSL_ENSURE(pDlg
, "Dialog create fail!");
800 short nResult
= pDlg
->Execute();
801 pTabViewShell
->SetInFormatDialog(false);
803 if ( nResult
== RET_OK
)
805 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
809 nRetMask
= pStyleSheet
->GetMask();
811 // Attribut-Vergleiche (frueher in ModifyStyleSheet)
812 // jetzt hier mit den alten Werten (Style ist schon veraendert)
814 if ( SFX_STYLE_FAMILY_PARA
== eFam
)
816 SfxItemSet
& rNewSet
= pStyleSheet
->GetItemSet();
817 bool bNumFormatChanged
;
818 if ( ScGlobal::CheckWidthInvalidate(
819 bNumFormatChanged
, aOldSet
, rNewSet
) )
820 pDoc
->InvalidateTextWidth( NULL
, NULL
, bNumFormatChanged
);
822 SCTAB nTabCount
= pDoc
->GetTableCount();
823 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
824 if (pDoc
->IsStreamValid(nTab
))
825 pDoc
->SetStreamValid(nTab
, false);
827 sal_uLong nOldFormat
= ((const SfxUInt32Item
&)aOldSet
.
828 Get( ATTR_VALUE_FORMAT
)).GetValue();
829 sal_uLong nNewFormat
= ((const SfxUInt32Item
&)rNewSet
.
830 Get( ATTR_VALUE_FORMAT
)).GetValue();
831 if ( nNewFormat
!= nOldFormat
)
833 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
834 const SvNumberformat
* pOld
= pFormatter
->GetEntry( nOldFormat
);
835 const SvNumberformat
* pNew
= pFormatter
->GetEntry( nNewFormat
);
836 if ( pOld
&& pNew
&& pOld
->GetLanguage() != pNew
->GetLanguage() )
837 rNewSet
.Put( SvxLanguageItem(
838 pNew
->GetLanguage(), ATTR_LANGUAGE_FORMAT
) );
841 pDoc
->GetPool()->CellStyleCreated( pStyleSheet
->GetName() );
845 //! auch fuer Seitenvorlagen die Abfragen hier
847 String aNewName
= pStyleSheet
->GetName();
848 if ( aNewName
!= aOldName
&&
849 pDoc
->RenamePageStyleInUse( aOldName
, aNewName
) )
851 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
852 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
855 pDoc
->ModifyStyleSheet( *pStyleSheet
, *pOutSet
);
856 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
859 pDocSh
->SetDocumentModified();
861 if ( SFX_STYLE_FAMILY_PARA
== eFam
)
863 pTabViewShell
->UpdateNumberFormatter(
864 (const SvxNumberInfoItem
&)
865 *(pDocSh
->GetItem(SID_ATTR_NUMBERFORMAT_INFO
)) );
867 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
868 pTabViewShell
->InvalidateAttribs();
871 aNewData
.InitFromStyle( pStyleSheet
);
877 if ( nSlotId
== SID_STYLE_NEW
)
878 pStylePool
->Remove( pStyleSheet
);
881 // falls zwischendurch etwas mit dem temporaer geaenderten
882 // ItemSet gepainted wurde:
883 pDocSh
->PostPaintGridAll();
890 rReq
.SetReturnValue( SfxUInt16Item( nSlotId
, nRetMask
) );
892 if ( bAddUndo
&& bUndo
)
893 pDocSh
->GetUndoManager()->AddUndoAction(
894 new ScUndoModifyStyle( pDocSh
, eFamily
, aOldData
, aNewData
) );
896 if ( bStyleToMarked
)
898 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
899 // so redo will find the modified style
900 pTabViewShell
->SetStyleSheetToMarked( (SfxStyleSheet
*)pStyleSheet
);
901 pTabViewShell
->InvalidateAttribs();
905 pDocSh
->GetUndoManager()->LeaveListAction();
909 OSL_FAIL( "Unknown slot (ScViewShell::ExecuteStyle)" );
913 void ScFormatShell::ExecuteNumFormat( SfxRequest
& rReq
)
915 ScModule
* pScMod
= SC_MOD();
916 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
917 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
918 sal_uInt16 nSlot
= rReq
.GetSlot();
919 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
921 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
924 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
928 case SID_NUMBER_TWODEC
:
929 case SID_NUMBER_SCIENTIFIC
:
930 case SID_NUMBER_DATE
:
931 case SID_NUMBER_CURRENCY
:
932 case SID_NUMBER_PERCENT
:
933 case SID_NUMBER_STANDARD
:
934 case SID_NUMBER_FORMAT
:
935 case SID_NUMBER_INCDEC
:
936 case SID_NUMBER_DECDEC
:
937 case FID_DEFINE_NAME
:
940 case FID_INSERT_NAME
:
941 case SID_SPELL_DIALOG
:
942 case SID_HANGUL_HANJA_CONVERSION
:
944 pScMod
->InputEnterHandler();
945 pTabViewShell
->UpdateInputHandler();
953 short nType
= GetCurrentNumberFormatType();
954 SfxItemSet
aSet( GetPool(), nSlot
, nSlot
);
957 case SID_NUMBER_TWODEC
:
958 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
, 4 ); // Standard+4 = #.##0,00
961 case SID_NUMBER_SCIENTIFIC
:
962 if ((nType
& NUMBERFORMAT_SCIENTIFIC
))
963 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
965 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC
);
966 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& NUMBERFORMAT_SCIENTIFIC
)) );
967 rBindings
.Invalidate( nSlot
);
970 case SID_NUMBER_DATE
:
971 if ((nType
& NUMBERFORMAT_DATE
))
972 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
974 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_DATE
);
975 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& NUMBERFORMAT_DATE
)) );
976 rBindings
.Invalidate( nSlot
);
979 case SID_NUMBER_TIME
:
980 if ((nType
& NUMBERFORMAT_TIME
))
981 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
983 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_TIME
);
984 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& NUMBERFORMAT_TIME
)) );
985 rBindings
.Invalidate( nSlot
);
988 case SID_NUMBER_CURRENCY
:
989 if ((nType
& NUMBERFORMAT_CURRENCY
))
990 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
992 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_CURRENCY
);
993 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& NUMBERFORMAT_CURRENCY
)) );
994 rBindings
.Invalidate( nSlot
);
997 case SID_NUMBER_PERCENT
:
998 if ((nType
& NUMBERFORMAT_PERCENT
))
999 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
1001 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_PERCENT
);
1002 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& NUMBERFORMAT_PERCENT
)) );
1003 rBindings
.Invalidate( nSlot
);
1006 case SID_NUMBER_STANDARD
:
1007 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
);
1010 case SID_NUMBER_INCDEC
:
1011 pTabViewShell
->ChangeNumFmtDecimals( true );
1014 case SID_NUMBER_DECDEC
:
1015 pTabViewShell
->ChangeNumFmtDecimals( false );
1019 case SID_NUMBER_FORMAT
:
1022 // const SfxPoolItem* pItem;
1023 // if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET)
1025 // String aCode = ((const SfxStringItem*)pItem)->GetValue();
1026 // pTabViewShell->SetNumFmtByStr( aCode );
1030 // symphony version with format interpretation
1033 const SfxPoolItem
* pItem
;
1034 ScDocument
* pDoc
= pViewData
->GetDocument();
1035 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
1036 LanguageType eLanguage
= ScGlobal::eLnge
;
1037 sal_Int16 eType
= -1;
1038 sal_uInt32 nCurrentNumberFormat
;
1040 pDoc
->GetNumberFormat(pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo(), nCurrentNumberFormat
);
1041 const SvNumberformat
* pEntry
= pFormatter
->GetEntry(nCurrentNumberFormat
);
1045 eLanguage
= pEntry
->GetLanguage();
1046 eType
= pEntry
->GetType();
1049 //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY
1050 //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
1053 case NUMBERFORMAT_ALL
:
1054 case NUMBERFORMAT_NUMBER
:
1055 case NUMBERFORMAT_NUMBER
| NUMBERFORMAT_DEFINED
:
1056 case NUMBERFORMAT_PERCENT
:
1057 case NUMBERFORMAT_PERCENT
| NUMBERFORMAT_DEFINED
:
1058 case NUMBERFORMAT_CURRENCY
:
1059 case NUMBERFORMAT_CURRENCY
|NUMBERFORMAT_DEFINED
:
1066 if(SFX_ITEM_SET
== pReqArgs
->GetItemState(nSlot
, true, &pItem
) && eType
!= -1)
1068 String aCode
= ((const SfxStringItem
*)pItem
)->GetValue();
1069 sal_uInt16 aLen
= aCode
.Len();
1070 String
* sFormat
= new String
[4];
1071 String sTmpStr
= OUString();
1072 sal_uInt16
nCount(0);
1073 sal_uInt16
nStrCount(0);
1075 while(nCount
< aLen
)
1077 sal_Unicode cChar
= aCode
.GetChar(nCount
);
1079 if(cChar
== sal_Unicode(','))
1081 sFormat
[nStrCount
] = sTmpStr
;
1082 sTmpStr
= OUString();
1096 const sal_Bool bThousand
= (sal_Bool
)sFormat
[0].ToInt32();
1097 const sal_Bool bNegRed
= (sal_Bool
)sFormat
[1].ToInt32();
1098 const sal_uInt16 nPrecision
= (sal_uInt16
)sFormat
[2].ToInt32();
1099 const sal_uInt16 nLeadZeroes
= (sal_uInt16
)sFormat
[3].ToInt32();
1101 aCode
= pFormatter
->GenerateFormat(
1102 nCurrentNumberFormat
,//modify
1108 pTabViewShell
->SetNumFmtByStr(aCode
);
1114 case SID_ATTR_NUMBERFORMAT_VALUE
:
1117 const SfxPoolItem
* pItem
;
1118 if ( pReqArgs
->GetItemState( ATTR_VALUE_FORMAT
, sal_True
, &pItem
) == SFX_ITEM_SET
)
1120 // We have to accomplish this using ApplyAttributes()
1121 // because we also need the language information to be
1123 const SfxItemSet
& rOldSet
=
1124 pTabViewShell
->GetSelectionPattern()->GetItemSet();
1125 SfxItemPool
* pDocPool
= GetViewData()->GetDocument()->GetPool();
1126 SfxItemSet
aNewSet( *pDocPool
, ATTR_PATTERN_START
, ATTR_PATTERN_END
);
1127 aNewSet
.Put( *pItem
);
1128 pTabViewShell
->ApplyAttributes( &aNewSet
, &rOldSet
, sal_True
);
1133 case SID_NUMBER_TYPE_FORMAT
:
1136 const SfxPoolItem
* pItem
;
1137 if ( pReqArgs
->GetItemState( nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
1139 sal_uInt16 nFormat
= ((SfxInt16Item
*)pItem
)->GetValue();
1143 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
); //Modify
1146 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_NUMBER
, 2 ); //Modify
1149 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_PERCENT
);
1152 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_CURRENCY
);
1155 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_DATE
);
1158 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_TIME
);
1161 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC
);
1164 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_FRACTION
);
1167 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_LOGICAL
);
1170 pTabViewShell
->SetNumberFormat( NUMBERFORMAT_TEXT
);
1181 OSL_FAIL("falscher Slot bei ExecuteEdit");
1187 //------------------------------------------------------------------
1189 void ScFormatShell::ExecuteAlignment( SfxRequest
& rReq
)
1191 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1192 SfxBindings
& rBindings
= pViewData
->GetBindings();
1193 const SfxItemSet
* pSet
= rReq
.GetArgs();
1194 sal_uInt16 nSlot
= rReq
.GetSlot();
1196 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1200 // pseudo slots for Format menu
1201 case SID_ALIGN_ANY_HDEFAULT
:
1202 case SID_ALIGN_ANY_LEFT
:
1203 case SID_ALIGN_ANY_HCENTER
:
1204 case SID_ALIGN_ANY_RIGHT
:
1205 case SID_ALIGN_ANY_JUSTIFIED
:
1206 pTabViewShell
->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot
), ATTR_HOR_JUSTIFY
) );
1208 case SID_ALIGN_ANY_VDEFAULT
:
1209 case SID_ALIGN_ANY_TOP
:
1210 case SID_ALIGN_ANY_VCENTER
:
1211 case SID_ALIGN_ANY_BOTTOM
:
1212 pTabViewShell
->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot
), ATTR_VER_JUSTIFY
) );
1218 const SfxPoolItem
* pItem
= NULL
;
1219 if( pSet
->GetItemState(GetPool().GetWhich(nSlot
), sal_True
, &pItem
) == SFX_ITEM_SET
)
1224 case SID_ATTR_ALIGN_HOR_JUSTIFY
:
1225 case SID_ATTR_ALIGN_VER_JUSTIFY
:
1226 case SID_ATTR_ALIGN_INDENT
:
1227 case SID_ATTR_ALIGN_HYPHENATION
:
1228 case SID_ATTR_ALIGN_DEGREES
:
1229 case SID_ATTR_ALIGN_LOCKPOS
:
1230 case SID_ATTR_ALIGN_MARGIN
:
1231 case SID_ATTR_ALIGN_STACKED
:
1232 pTabViewShell
->ApplyAttr( *pItem
);
1235 case SID_H_ALIGNCELL
:
1237 SvxCellHorJustify eJust
= (SvxCellHorJustify
)((const SvxHorJustifyItem
*)pItem
)->GetValue();
1238 // #i78476# update alignment of text in cell edit mode
1239 pTabViewShell
->UpdateInputHandlerCellAdjust( eJust
);
1240 pTabViewShell
->ApplyAttr( SvxHorJustifyItem( eJust
, ATTR_HOR_JUSTIFY
) );
1243 case SID_V_ALIGNCELL
:
1244 pTabViewShell
->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify
)((const SvxVerJustifyItem
*)pItem
)->GetValue(), ATTR_VER_JUSTIFY
) );
1247 OSL_FAIL( "ExecuteAlignment: invalid slot" );
1253 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_LEFT
);
1254 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT
);
1255 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK
);
1256 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_CENTER
);
1257 rBindings
.Invalidate( SID_ALIGNLEFT
);
1258 rBindings
.Invalidate( SID_ALIGNRIGHT
);
1259 rBindings
.Invalidate( SID_ALIGNCENTERHOR
);
1260 rBindings
.Invalidate( SID_ALIGNBLOCK
);
1261 rBindings
.Invalidate( SID_ALIGNTOP
);
1262 rBindings
.Invalidate( SID_ALIGNBOTTOM
);
1263 rBindings
.Invalidate( SID_ALIGNCENTERVER
);
1264 rBindings
.Invalidate( SID_V_ALIGNCELL
);
1265 rBindings
.Invalidate( SID_H_ALIGNCELL
);
1266 // pseudo slots for Format menu
1267 rBindings
.Invalidate( SID_ALIGN_ANY_HDEFAULT
);
1268 rBindings
.Invalidate( SID_ALIGN_ANY_LEFT
);
1269 rBindings
.Invalidate( SID_ALIGN_ANY_HCENTER
);
1270 rBindings
.Invalidate( SID_ALIGN_ANY_RIGHT
);
1271 rBindings
.Invalidate( SID_ALIGN_ANY_JUSTIFIED
);
1272 rBindings
.Invalidate( SID_ALIGN_ANY_VDEFAULT
);
1273 rBindings
.Invalidate( SID_ALIGN_ANY_TOP
);
1274 rBindings
.Invalidate( SID_ALIGN_ANY_VCENTER
);
1275 rBindings
.Invalidate( SID_ALIGN_ANY_BOTTOM
);
1278 if( ! rReq
.IsAPI() )
1282 void ScFormatShell::ExecuteTextAttr( SfxRequest
& rReq
)
1284 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1285 SfxBindings
& rBindings
= pViewData
->GetBindings();
1286 const ScPatternAttr
* pAttrs
= pTabViewShell
->GetSelectionPattern();
1287 const SfxItemSet
* pSet
= rReq
.GetArgs();
1288 sal_uInt16 nSlot
= rReq
.GetSlot();
1289 SfxAllItemSet
* pNewSet
= 0;
1291 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1293 if ( (nSlot
== SID_ATTR_CHAR_WEIGHT
)
1294 ||(nSlot
== SID_ATTR_CHAR_POSTURE
)
1295 ||(nSlot
== SID_ATTR_CHAR_UNDERLINE
)
1296 ||(nSlot
== SID_ULINE_VAL_NONE
)
1297 ||(nSlot
== SID_ULINE_VAL_SINGLE
)
1298 ||(nSlot
== SID_ULINE_VAL_DOUBLE
)
1299 ||(nSlot
== SID_ULINE_VAL_DOTTED
) )
1301 pNewSet
= new SfxAllItemSet( GetPool() );
1305 case SID_ATTR_CHAR_WEIGHT
:
1307 // #i78017 establish the same behaviour as in Writer
1308 sal_uInt8 nScript
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
1310 SfxItemPool
& rPool
= GetPool();
1311 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1313 aSetItem
.PutItemForScriptType( nScript
, pSet
->Get( ATTR_FONT_WEIGHT
) );
1318 FontWeight eWeight
= WEIGHT_BOLD
;
1319 SvxScriptSetItem
aOldSetItem( nSlot
, rPool
);
1320 aOldSetItem
.GetItemSet().Put( pAttrs
->GetItemSet(), false );
1321 const SfxPoolItem
* pCore
= aOldSetItem
.GetItemOfScript( nScript
);
1322 if ( pCore
&& ((const SvxWeightItem
*)pCore
)->GetWeight() == WEIGHT_BOLD
)
1323 eWeight
= WEIGHT_NORMAL
;
1325 aSetItem
.PutItemForScriptType( nScript
, SvxWeightItem( eWeight
, ATTR_FONT_WEIGHT
) );
1327 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1328 pNewSet
->Put( aSetItem
.GetItemSet(), false );
1332 case SID_ATTR_CHAR_POSTURE
:
1334 // #i78017 establish the same behaviour as in Writer
1335 sal_uInt8 nScript
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
1337 SfxItemPool
& rPool
= GetPool();
1338 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1340 aSetItem
.PutItemForScriptType( nScript
, pSet
->Get( ATTR_FONT_POSTURE
) );
1345 FontItalic eItalic
= ITALIC_NORMAL
;
1346 SvxScriptSetItem
aOldSetItem( nSlot
, rPool
);
1347 aOldSetItem
.GetItemSet().Put( pAttrs
->GetItemSet(), false );
1348 const SfxPoolItem
* pCore
= aOldSetItem
.GetItemOfScript( nScript
);
1349 if ( pCore
&& ((const SvxPostureItem
*)pCore
)->GetPosture() == ITALIC_NORMAL
)
1350 eItalic
= ITALIC_NONE
;
1352 aSetItem
.PutItemForScriptType( nScript
, SvxPostureItem( eItalic
, ATTR_FONT_POSTURE
) );
1354 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1355 pNewSet
->Put( aSetItem
.GetItemSet(), false );
1359 case SID_ATTR_CHAR_UNDERLINE
:
1361 FontUnderline eUnderline
;
1365 const SfxPoolItem
& rUnderline
= pSet
->Get( ATTR_FONT_UNDERLINE
);
1367 if( rUnderline
.ISA(SvxUnderlineItem
) )
1369 pTabViewShell
->ApplyAttr( rUnderline
);
1370 pNewSet
->Put( rUnderline
,rUnderline
.Which() );
1372 else if ( rUnderline
.ISA(SvxTextLineItem
) )
1374 // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1375 const SvxTextLineItem
& rTextLineItem
= static_cast<const SvxTextLineItem
&>(rUnderline
);
1376 SvxUnderlineItem
aNewItem( rTextLineItem
.GetLineStyle(), rTextLineItem
.Which() );
1377 aNewItem
.SetColor( rTextLineItem
.GetColor() );
1378 pTabViewShell
->ApplyAttr( aNewItem
);
1379 pNewSet
->Put( aNewItem
, aNewItem
.Which() );
1384 SvxUnderlineItem
aUnderline( (const SvxUnderlineItem
&)
1386 ATTR_FONT_UNDERLINE
) );
1387 eUnderline
= (UNDERLINE_NONE
!= aUnderline
.GetLineStyle())
1390 aUnderline
.SetLineStyle( eUnderline
);
1391 pTabViewShell
->ApplyAttr( aUnderline
);
1392 pNewSet
->Put( aUnderline
,aUnderline
.Which() );
1397 case SID_ULINE_VAL_NONE
:
1398 pTabViewShell
->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE
, ATTR_FONT_UNDERLINE
) );
1400 case SID_ULINE_VAL_SINGLE
: // Toggles
1401 case SID_ULINE_VAL_DOUBLE
:
1402 case SID_ULINE_VAL_DOTTED
:
1404 FontUnderline eOld
= ((const SvxUnderlineItem
&)
1405 pAttrs
->GetItem(ATTR_FONT_UNDERLINE
)).GetLineStyle();
1406 FontUnderline eNew
= eOld
;
1409 case SID_ULINE_VAL_SINGLE
:
1410 eNew
= ( eOld
== UNDERLINE_SINGLE
) ? UNDERLINE_NONE
: UNDERLINE_SINGLE
;
1412 case SID_ULINE_VAL_DOUBLE
:
1413 eNew
= ( eOld
== UNDERLINE_DOUBLE
) ? UNDERLINE_NONE
: UNDERLINE_DOUBLE
;
1415 case SID_ULINE_VAL_DOTTED
:
1416 eNew
= ( eOld
== UNDERLINE_DOTTED
) ? UNDERLINE_NONE
: UNDERLINE_DOTTED
;
1419 pTabViewShell
->ApplyAttr( SvxUnderlineItem( eNew
, ATTR_FONT_UNDERLINE
) );
1426 rBindings
.Invalidate( nSlot
);
1431 * "Selbstgemachte" RadioButton-Funktionalitaet
1432 * Beim Toggle gibt es den Standard-State, d.h. kein
1433 * Button ist gedrueckt
1436 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
1437 const SfxPoolItem
* pItem
= NULL
;
1438 const SvxHorJustifyItem
* pHorJustify
= NULL
;
1439 const SvxVerJustifyItem
* pVerJustify
= NULL
;
1440 SvxCellHorJustify eHorJustify
= SVX_HOR_JUSTIFY_STANDARD
;
1441 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
1443 if (rAttrSet
.GetItemState(ATTR_HOR_JUSTIFY
, sal_True
,&pItem
) == SFX_ITEM_SET
)
1445 pHorJustify
= (const SvxHorJustifyItem
*)pItem
;
1446 eHorJustify
= SvxCellHorJustify( pHorJustify
->GetValue() );
1448 if (rAttrSet
.GetItemState(ATTR_VER_JUSTIFY
, sal_True
,&pItem
) == SFX_ITEM_SET
)
1450 pVerJustify
= (const SvxVerJustifyItem
*)pItem
;
1451 eVerJustify
= SvxCellVerJustify( pVerJustify
->GetValue() );
1457 rReq
.SetSlot( SID_H_ALIGNCELL
);
1458 rReq
.AppendItem( SvxHorJustifyItem(
1459 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_LEFT
) ?
1460 SVX_HOR_JUSTIFY_LEFT
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1461 ExecuteSlot( rReq
, GetInterface() );
1465 case SID_ALIGNRIGHT
:
1466 rReq
.SetSlot( SID_H_ALIGNCELL
);
1467 rReq
.AppendItem( SvxHorJustifyItem(
1468 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_RIGHT
) ?
1469 SVX_HOR_JUSTIFY_RIGHT
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1470 ExecuteSlot( rReq
, GetInterface() );
1474 case SID_ALIGNCENTERHOR
:
1475 rReq
.SetSlot( SID_H_ALIGNCELL
);
1476 rReq
.AppendItem( SvxHorJustifyItem(
1477 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_CENTER
) ?
1478 SVX_HOR_JUSTIFY_CENTER
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1479 ExecuteSlot( rReq
, GetInterface() );
1483 case SID_ALIGNBLOCK
:
1484 rReq
.SetSlot( SID_H_ALIGNCELL
);
1485 rReq
.AppendItem( SvxHorJustifyItem(
1486 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_BLOCK
) ?
1487 SVX_HOR_JUSTIFY_BLOCK
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1488 ExecuteSlot( rReq
, GetInterface() );
1493 rReq
.SetSlot( SID_V_ALIGNCELL
);
1494 rReq
.AppendItem( SvxVerJustifyItem(
1495 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_TOP
) ?
1496 SVX_VER_JUSTIFY_TOP
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1497 ExecuteSlot( rReq
, GetInterface() );
1501 case SID_ALIGNBOTTOM
:
1502 rReq
.SetSlot( SID_V_ALIGNCELL
);
1503 rReq
.AppendItem( SvxVerJustifyItem(
1504 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_BOTTOM
) ?
1505 SVX_VER_JUSTIFY_BOTTOM
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1506 ExecuteSlot( rReq
, GetInterface() );
1510 case SID_ALIGNCENTERVER
:
1511 rReq
.SetSlot( SID_V_ALIGNCELL
);
1512 rReq
.AppendItem( SvxVerJustifyItem(
1513 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_CENTER
) ?
1514 SVX_VER_JUSTIFY_CENTER
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1515 ExecuteSlot( rReq
, GetInterface() );
1529 rReq
.Done( *pNewSet
);
1539 //------------------------------------------------------------------
1541 void ScFormatShell::ExecuteAttr( SfxRequest
& rReq
)
1543 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1544 SfxBindings
& rBindings
= pViewData
->GetBindings();
1545 const SfxItemSet
* pNewAttrs
= rReq
.GetArgs();
1546 sal_uInt16 nSlot
= rReq
.GetSlot();
1548 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1549 ScDocument
* pDoc
= GetViewData()->GetDocument();
1554 case SID_ATTR_CHAR_ENDPREVIEW_FONT
:
1556 pDoc
->SetPreviewFont(NULL
);
1557 pTabViewShell
->UpdateSelectionArea( pDoc
->GetPreviewSelection() );
1560 case SID_ATTR_CHAR_COLOR
:
1561 case SID_ATTR_CHAR_FONT
:
1562 case SID_ATTR_CHAR_FONTHEIGHT
:
1563 pTabViewShell
->ExecuteCellFormatDlg(rReq
, "font"); // wenn ToolBar vertikal
1566 case SID_BACKGROUND_COLOR
:
1568 SvxBrushItem
aBrushItem( (const SvxBrushItem
&)
1569 pTabViewShell
->GetSelectionPattern()->GetItem( ATTR_BACKGROUND
) );
1570 aBrushItem
.SetColor( COL_TRANSPARENT
);
1571 pTabViewShell
->ApplyAttr( aBrushItem
);
1575 case SID_ATTR_ALIGN_LINEBREAK
: // ohne Parameter als Toggle
1577 const ScPatternAttr
* pAttrs
= pTabViewShell
->GetSelectionPattern();
1578 bool bOld
= ((const SfxBoolItem
&)pAttrs
->GetItem(ATTR_LINEBREAK
)).GetValue();
1579 SfxBoolItem
aBreakItem( ATTR_LINEBREAK
, !bOld
);
1580 pTabViewShell
->ApplyAttr( aBreakItem
);
1582 SfxAllItemSet
aNewSet( GetPool() );
1583 aNewSet
.Put( aBreakItem
,aBreakItem
.Which() );
1584 rReq
.Done( aNewSet
);
1586 rBindings
.Invalidate( nSlot
);
1595 case SID_ATTR_CHAR_PREVIEW_FONT
:
1597 SfxItemPool
& rPool
= GetPool();
1598 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
1599 const SvxFontItem
& rFont
= ( const SvxFontItem
&)pNewAttrs
->Get( nWhich
);
1600 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, rPool
);
1601 sal_uInt8 nScript
= pTabViewShell
->GetSelectionScriptType();
1602 aSetItem
.PutItemForScriptType( nScript
, rFont
);
1604 ScMarkData
aFuncMark( pViewData
->GetMarkData() );
1605 ScViewUtil::UnmarkFiltered( aFuncMark
, pDoc
);
1606 pDoc
->SetPreviewFont( aSetItem
.GetItemSet().Clone() );
1607 aFuncMark
.MarkToMulti();
1609 if ( !aFuncMark
.IsMarked() && !aFuncMark
.IsMultiMarked() )
1611 SCCOL nCol
= pViewData
->GetCurX();
1612 SCROW nRow
= pViewData
->GetCurY();
1613 SCTAB nTab
= pViewData
->GetTabNo();
1614 ScRange
aRange( nCol
, nRow
, nTab
);
1615 aFuncMark
.SetMarkArea( aRange
);
1617 pDoc
->SetPreviewSelection( aFuncMark
);
1618 pTabViewShell
->UpdateSelectionArea( aFuncMark
);
1621 case SID_ATTR_CHAR_OVERLINE
:
1622 case SID_ATTR_CHAR_STRIKEOUT
:
1623 case SID_ATTR_ALIGN_LINEBREAK
:
1624 case SID_ATTR_CHAR_COLOR
:
1625 case SID_ATTR_CHAR_CONTOUR
:
1626 case SID_ATTR_CHAR_SHADOWED
:
1627 case SID_ATTR_CHAR_RELIEF
:
1628 case SID_SCATTR_PROTECTION
:
1629 pTabViewShell
->ApplyAttr( pNewAttrs
->Get( pNewAttrs
->GetPool()->GetWhich( nSlot
) ) );
1630 rBindings
.Invalidate( nSlot
);
1631 rBindings
.Update( nSlot
);
1634 case SID_ATTR_CHAR_FONT
:
1635 case SID_ATTR_CHAR_FONTHEIGHT
:
1637 // #i78017 establish the same behaviour as in Writer
1638 sal_uInt8 nScript
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
1639 if (nSlot
== SID_ATTR_CHAR_FONT
)
1640 nScript
= pTabViewShell
->GetSelectionScriptType();
1642 SfxItemPool
& rPool
= GetPool();
1643 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1644 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
1645 aSetItem
.PutItemForScriptType( nScript
, pNewAttrs
->Get( nWhich
) );
1647 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1649 rBindings
.Invalidate( nSlot
);
1650 rBindings
.Update( nSlot
);
1654 case SID_FRAME_LINESTYLE
:
1656 // Default-Linie aktualisieren
1657 const ::editeng::SvxBorderLine
* pLine
=
1658 ((const SvxLineItem
&)
1659 pNewAttrs
->Get( SID_FRAME_LINESTYLE
)).
1664 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1668 pDefLine
->SetBorderLineStyle(
1669 pLine
->GetBorderLineStyle());
1670 pDefLine
->SetWidth( pLine
->GetWidth( ) );
1671 pTabViewShell
->SetSelectionFrameLines( pDefLine
, false );
1675 pTabViewShell
->SetDefaultFrameLine( pLine
);
1676 pTabViewShell
->GetDefaultFrameLine()->SetColor( COL_BLACK
);
1677 pTabViewShell
->SetSelectionFrameLines( pLine
, false );
1682 Color
aColorBlack( COL_BLACK
);
1683 ::editeng::SvxBorderLine
aDefLine( &aColorBlack
, 20,
1684 table::BorderLineStyle::SOLID
);
1685 pTabViewShell
->SetDefaultFrameLine( &aDefLine
);
1686 pTabViewShell
->SetSelectionFrameLines( NULL
, false );
1691 case SID_FRAME_LINECOLOR
:
1693 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1694 const Color
& rColor
= ((const SvxColorItem
&)
1695 pNewAttrs
->Get( SID_FRAME_LINECOLOR
)).
1698 // Default-Linie aktualisieren
1701 pDefLine
->SetColor( rColor
);
1702 pTabViewShell
->SetSelectionFrameLines( pDefLine
, sal_True
);
1706 ::editeng::SvxBorderLine
aDefLine( &rColor
, 20,
1707 table::BorderLineStyle::SOLID
);
1708 pTabViewShell
->SetDefaultFrameLine( &aDefLine
);
1709 pTabViewShell
->SetSelectionFrameLines( &aDefLine
, false );
1714 case SID_ATTR_BORDER_OUTER
:
1715 case SID_ATTR_BORDER
:
1717 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1718 const ScPatternAttr
* pOldAttrs
= pTabViewShell
->GetSelectionPattern();
1719 SfxItemSet
* pOldSet
=
1724 SfxItemSet
* pNewSet
=
1729 const SfxPoolItem
& rBorderAttr
=
1730 pOldAttrs
->GetItemSet().
1733 // Border-Items vom Controller auswerten:
1734 const SfxPoolItem
* pItem
= 0;
1736 if ( pNewAttrs
->GetItemState( ATTR_BORDER
, sal_True
, &pItem
)
1739 // The SvxFrameToolBoxControl toolbox controller uses a default
1740 // SvxBorderLine (all widths 0) to mark the lines that should be set.
1741 // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1742 // or NULL pointers for no lines.
1743 // -> Substitute existing lines with pDefLine only if widths are 0.
1744 SvxBoxItem
aBoxItem ( *(const SvxBoxItem
*)pItem
);
1745 if ( aBoxItem
.GetTop() && aBoxItem
.GetTop()->GetOutWidth() == 0 )
1746 aBoxItem
.SetLine( pDefLine
, BOX_LINE_TOP
);
1747 if ( aBoxItem
.GetBottom() && aBoxItem
.GetBottom()->GetOutWidth() == 0 )
1748 aBoxItem
.SetLine( pDefLine
, BOX_LINE_BOTTOM
);
1749 if ( aBoxItem
.GetLeft() && aBoxItem
.GetLeft()->GetOutWidth() == 0 )
1750 aBoxItem
.SetLine( pDefLine
, BOX_LINE_LEFT
);
1751 if ( aBoxItem
.GetRight() && aBoxItem
.GetRight()->GetOutWidth() == 0 )
1752 aBoxItem
.SetLine( pDefLine
, BOX_LINE_RIGHT
);
1753 pNewSet
->Put( aBoxItem
);
1754 rReq
.AppendItem( aBoxItem
);
1757 if ( pNewAttrs
->GetItemState( ATTR_BORDER_INNER
, sal_True
, &pItem
)
1760 SvxBoxInfoItem
aBoxInfoItem( *(const SvxBoxInfoItem
*)pItem
);
1761 if ( aBoxInfoItem
.GetHori() && aBoxInfoItem
.GetHori()->GetOutWidth() == 0 )
1762 aBoxInfoItem
.SetLine( pDefLine
, BOXINFO_LINE_HORI
);
1763 if ( aBoxInfoItem
.GetVert() && aBoxInfoItem
.GetVert()->GetOutWidth() == 0 )
1764 aBoxInfoItem
.SetLine( pDefLine
, BOXINFO_LINE_VERT
);
1765 pNewSet
->Put( aBoxInfoItem
);
1766 rReq
.AppendItem( aBoxInfoItem
);
1770 SvxBoxInfoItem
aBoxInfoItem( ATTR_BORDER_INNER
);
1771 aBoxInfoItem
.SetLine( NULL
, BOXINFO_LINE_HORI
);
1772 aBoxInfoItem
.SetLine( NULL
, BOXINFO_LINE_VERT
);
1773 pNewSet
->Put( aBoxInfoItem
);
1776 pOldSet
->Put( rBorderAttr
);
1777 pTabViewShell
->ApplyAttributes( pNewSet
, pOldSet
);
1784 case SID_ATTR_BORDER_DIAG_TLBR
:
1785 case SID_ATTR_BORDER_DIAG_BLTR
:
1787 const ScPatternAttr
* pOldAttrs
= pTabViewShell
->GetSelectionPattern();
1788 SfxItemSet
* pOldSet
= new SfxItemSet(pOldAttrs
->GetItemSet());
1789 SfxItemSet
* pNewSet
= new SfxItemSet(pOldAttrs
->GetItemSet());
1790 const SfxPoolItem
* pItem
= 0;
1792 if(SID_ATTR_BORDER_DIAG_TLBR
== nSlot
)
1794 if(SFX_ITEM_SET
== pNewAttrs
->GetItemState(ATTR_BORDER_TLBR
, true, &pItem
))
1796 SvxLineItem
aItem(ATTR_BORDER_TLBR
);
1797 aItem
.SetLine(((const SvxLineItem
&)pNewAttrs
->Get(ATTR_BORDER_TLBR
)).GetLine());
1798 pNewSet
->Put(aItem
);
1799 rReq
.AppendItem(aItem
);
1800 pTabViewShell
->ApplyAttributes(pNewSet
, pOldSet
);
1803 else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1805 if(SFX_ITEM_SET
== pNewAttrs
->GetItemState(ATTR_BORDER_BLTR
, true, &pItem
))
1807 SvxLineItem
aItem(ATTR_BORDER_BLTR
);
1808 aItem
.SetLine(((const SvxLineItem
&)pNewAttrs
->Get(ATTR_BORDER_BLTR
)).GetLine());
1809 pNewSet
->Put(aItem
);
1810 rReq
.AppendItem(aItem
);
1811 pTabViewShell
->ApplyAttributes(pNewSet
, pOldSet
);
1817 rBindings
.Invalidate(nSlot
);
1821 // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1823 case SID_BACKGROUND_COLOR
:
1825 const SvxColorItem rNewColorItem
= (const SvxColorItem
&)
1826 pNewAttrs
->Get( SID_BACKGROUND_COLOR
);
1828 SvxBrushItem
aBrushItem( (const SvxBrushItem
&)
1829 pTabViewShell
->GetSelectionPattern()->
1830 GetItem( ATTR_BACKGROUND
) );
1832 aBrushItem
.SetColor( rNewColorItem
.GetValue() );
1834 pTabViewShell
->ApplyAttr( aBrushItem
);
1838 case SID_ATTR_BRUSH
:
1840 SvxBrushItem
aBrushItem( (const SvxBrushItem
&)
1841 pTabViewShell
->GetSelectionPattern()->
1842 GetItem( ATTR_BACKGROUND
) );
1843 const SvxBrushItem
& rNewBrushItem
= (const SvxBrushItem
&)
1844 pNewAttrs
->Get( GetPool().GetWhich(nSlot
) );
1845 aBrushItem
.SetColor(rNewBrushItem
.GetColor());
1846 pTabViewShell
->ApplyAttr( aBrushItem
);
1850 case SID_ATTR_BORDER_SHADOW
:
1852 const SvxShadowItem
& rNewShadowItem
= (const SvxShadowItem
&)
1853 pNewAttrs
->Get( ATTR_SHADOW
);
1854 pTabViewShell
->ApplyAttr( rNewShadowItem
);
1862 if( ! rReq
.IsAPI() )
1863 if( ! rReq
.IsDone() )
1868 void ScFormatShell::GetAttrState( SfxItemSet
& rSet
)
1870 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1871 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
1872 //const ::editeng::SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine();
1873 const SvxBrushItem
& rBrushItem
= (const SvxBrushItem
&)rAttrSet
.Get( ATTR_BACKGROUND
);
1874 SfxWhichIter
aIter( rSet
);
1875 sal_uInt16 nWhich
= aIter
.FirstWhich();
1877 rSet
.Put( rAttrSet
, false );
1879 // choose font info according to selection script type
1880 sal_uInt8 nScript
= 0; // GetSelectionScriptType never returns 0
1881 if ( rSet
.GetItemState( ATTR_FONT
) != SFX_ITEM_UNKNOWN
)
1883 if (!nScript
) nScript
= pTabViewShell
->GetSelectionScriptType();
1884 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT
, nScript
);
1886 if ( rSet
.GetItemState( ATTR_FONT_HEIGHT
) != SFX_ITEM_UNKNOWN
)
1888 if (!nScript
) nScript
= pTabViewShell
->GetSelectionScriptType();
1889 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_HEIGHT
, nScript
);
1896 case SID_BACKGROUND_COLOR
:
1898 rSet
.Put( SvxColorItem( rBrushItem
.GetColor(), SID_BACKGROUND_COLOR
) );
1900 if(SFX_ITEM_DONTCARE
== rAttrSet
.GetItemState(ATTR_BACKGROUND
))
1902 rSet
.InvalidateItem(SID_BACKGROUND_COLOR
);
1906 case SID_FRAME_LINESTYLE
:
1907 case SID_FRAME_LINECOLOR
:
1909 // handled together because both need the cell border information for decisions
1910 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1912 editeng::SvxBorderLine
aLine(0,0,0,0);
1914 bool bColDisable
= 0, bStyleDisable
= 0;
1915 SvxBoxItem
aBoxItem(ATTR_BORDER
);
1916 SvxBoxInfoItem
aInfoItem(ATTR_BORDER_INNER
);
1918 pTabViewShell
->GetSelectionFrame(aBoxItem
, aInfoItem
);
1920 if( aBoxItem
.GetTop() )
1923 aCol
= aBoxItem
.GetTop()->GetColor() ;
1924 aLine
.SetColor(aCol
);
1925 aLine
.SetWidth( aBoxItem
.GetTop()->GetWidth());
1926 aLine
.SetBorderLineStyle( aBoxItem
.GetTop()->GetBorderLineStyle());
1929 if( aBoxItem
.GetBottom() )
1934 aCol
= aBoxItem
.GetBottom()->GetColor() ;
1935 aLine
.SetColor(aCol
);
1936 aLine
.SetWidth( aBoxItem
.GetBottom()->GetWidth());
1937 aLine
.SetBorderLineStyle( aBoxItem
.GetBottom()->GetBorderLineStyle());
1941 if(aCol
!= aBoxItem
.GetBottom()->GetColor() )
1943 if(!( aLine
== *(aBoxItem
.GetBottom())) )
1948 if( aBoxItem
.GetLeft() )
1953 aCol
= aBoxItem
.GetLeft()->GetColor() ;
1954 aLine
.SetColor(aCol
);
1955 aLine
.SetWidth( aBoxItem
.GetLeft()->GetWidth());
1956 aLine
.SetBorderLineStyle( aBoxItem
.GetLeft()->GetBorderLineStyle());
1960 if(aCol
!= aBoxItem
.GetLeft()->GetColor() )
1962 if(!( aLine
== *(aBoxItem
.GetLeft())) )
1967 if( aBoxItem
.GetRight() )
1972 aCol
= aBoxItem
.GetRight()->GetColor() ;
1973 aLine
.SetColor(aCol
);
1974 aLine
.SetWidth( aBoxItem
.GetRight()->GetWidth());
1975 aLine
.SetBorderLineStyle( aBoxItem
.GetRight()->GetBorderLineStyle());
1979 if(aCol
!= aBoxItem
.GetRight()->GetColor() )
1981 if(!( aLine
== *(aBoxItem
.GetRight())) )
1986 if( aInfoItem
.GetVert())
1991 aCol
= aInfoItem
.GetVert()->GetColor() ;
1992 aLine
.SetColor(aCol
);
1993 aLine
.SetWidth( aInfoItem
.GetVert()->GetWidth());
1994 aLine
.SetBorderLineStyle( aInfoItem
.GetVert()->GetBorderLineStyle());
1998 if(aCol
!= aInfoItem
.GetVert()->GetColor() )
2000 if(!( aLine
== *(aInfoItem
.GetVert())) )
2005 if( aInfoItem
.GetHori())
2010 aCol
= aInfoItem
.GetHori()->GetColor() ;
2011 aLine
.SetColor(aCol
);
2012 aLine
.SetWidth( aInfoItem
.GetHori()->GetWidth());
2013 aLine
.SetBorderLineStyle( aInfoItem
.GetHori()->GetBorderLineStyle());
2017 if(aCol
!= aInfoItem
.GetHori()->GetColor() )
2019 if(!( aLine
== *(aInfoItem
.GetHori())) )
2024 if( !aInfoItem
.IsValid( VALID_VERT
)
2025 || !aInfoItem
.IsValid( VALID_HORI
)
2026 || !aInfoItem
.IsValid( VALID_LEFT
)
2027 || !aInfoItem
.IsValid( VALID_RIGHT
)
2028 || !aInfoItem
.IsValid( VALID_TOP
)
2029 || !aInfoItem
.IsValid( VALID_BOTTOM
) )
2035 if(SID_FRAME_LINECOLOR
== nWhich
)
2037 if(bColDisable
) // if different lines have differernt colors
2039 aCol
= COL_TRANSPARENT
;
2040 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2041 rSet
.InvalidateItem(SID_FRAME_LINECOLOR
);
2043 else if( bCol
== 0 && bColDisable
== 0) // if no line available
2046 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2049 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2051 else // if( nWhich == SID_FRAME_LINESTYLE)
2053 if(bStyleDisable
) // if have several lines but don't have same style
2055 aLine
.SetWidth( 1 );
2056 SvxLineItem
aItem(SID_FRAME_LINESTYLE
);
2057 aItem
.SetLine(&aLine
);
2059 rSet
.InvalidateItem(SID_FRAME_LINESTYLE
);
2061 else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2063 SvxLineItem
aItem(SID_FRAME_LINESTYLE
);
2064 aItem
.SetLine(&aLine
);
2070 case SID_ATTR_BRUSH
:
2072 rSet
.Put( rBrushItem
, GetPool().GetWhich(nWhich
) );
2076 nWhich
= aIter
.NextWhich();
2079 // stuff for sidebar panels
2080 Invalidate(SID_ATTR_ALIGN_DEGREES
);
2081 Invalidate(SID_ATTR_ALIGN_STACKED
);
2084 //------------------------------------------------------------------
2086 void ScFormatShell::GetTextAttrState( SfxItemSet
& rSet
)
2088 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2089 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2090 rSet
.Put( rAttrSet
, false ); // ItemStates mitkopieren
2092 // choose font info according to selection script type
2093 sal_uInt8 nScript
= 0; // GetSelectionScriptType never returns 0
2094 if ( rSet
.GetItemState( ATTR_FONT_WEIGHT
) != SFX_ITEM_UNKNOWN
)
2096 if (!nScript
) nScript
= pTabViewShell
->GetSelectionScriptType();
2097 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_WEIGHT
, nScript
);
2099 if ( rSet
.GetItemState( ATTR_FONT_POSTURE
) != SFX_ITEM_UNKNOWN
)
2101 if (!nScript
) nScript
= pTabViewShell
->GetSelectionScriptType();
2102 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_POSTURE
, nScript
);
2105 SfxItemState eState
;
2106 // const SfxPoolItem* pItem;
2108 //--------------------------------------------------------------------
2109 // eigene Kontrolle ueber RadioButton-Funktionalitaet:
2110 //--------------------------------------------------------------------
2112 //------------------------
2114 eState
= rAttrSet
.GetItemState( ATTR_FONT_UNDERLINE
, sal_True
);
2115 if ( eState
== SFX_ITEM_DONTCARE
)
2117 rSet
.InvalidateItem( SID_ULINE_VAL_NONE
);
2118 rSet
.InvalidateItem( SID_ULINE_VAL_SINGLE
);
2119 rSet
.InvalidateItem( SID_ULINE_VAL_DOUBLE
);
2120 rSet
.InvalidateItem( SID_ULINE_VAL_DOTTED
);
2124 FontUnderline eUnderline
= ((const SvxUnderlineItem
&)
2125 rAttrSet
.Get(ATTR_FONT_UNDERLINE
)).GetLineStyle();
2126 sal_uInt16 nId
= SID_ULINE_VAL_NONE
;
2129 case UNDERLINE_SINGLE
: nId
= SID_ULINE_VAL_SINGLE
; break;
2130 case UNDERLINE_DOUBLE
: nId
= SID_ULINE_VAL_DOUBLE
; break;
2131 case UNDERLINE_DOTTED
: nId
= SID_ULINE_VAL_DOTTED
; break;
2135 rSet
.Put( SfxBoolItem( nId
, sal_True
) );
2138 //------------------------
2139 // horizontale Ausrichtung
2140 //------------------------
2142 const SvxHorJustifyItem
* pHorJustify
= NULL
;
2143 const SvxVerJustifyItem
* pVerJustify
= NULL
;
2144 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
2145 sal_uInt16 nWhich
= 0;
2146 bool bJustifyStd
= false;
2147 SfxBoolItem
aBoolItem ( 0, sal_True
);
2149 eState
= rAttrSet
.GetItemState( ATTR_HOR_JUSTIFY
, sal_True
,
2150 (const SfxPoolItem
**)&pHorJustify
);
2155 switch ( SvxCellHorJustify( pHorJustify
->GetValue() ) )
2157 case SVX_HOR_JUSTIFY_STANDARD
:
2160 case SVX_HOR_JUSTIFY_LEFT
:
2161 nWhich
= SID_ALIGNLEFT
;
2164 case SVX_HOR_JUSTIFY_RIGHT
:
2165 nWhich
= SID_ALIGNRIGHT
;
2168 case SVX_HOR_JUSTIFY_CENTER
:
2169 nWhich
= SID_ALIGNCENTERHOR
;
2172 case SVX_HOR_JUSTIFY_BLOCK
:
2173 nWhich
= SID_ALIGNBLOCK
;
2176 case SVX_HOR_JUSTIFY_REPEAT
:
2178 bJustifyStd
= sal_True
;
2184 case SFX_ITEM_DONTCARE
:
2185 rSet
.InvalidateItem( SID_ALIGNLEFT
);
2186 rSet
.InvalidateItem( SID_ALIGNRIGHT
);
2187 rSet
.InvalidateItem( SID_ALIGNCENTERHOR
);
2188 rSet
.InvalidateItem( SID_ALIGNBLOCK
);
2192 bJustifyStd
= sal_True
;
2198 aBoolItem
.SetWhich( nWhich
);
2199 rSet
.Put( aBoolItem
);
2201 else if ( bJustifyStd
)
2203 aBoolItem
.SetValue( false );
2204 aBoolItem
.SetWhich( SID_ALIGNLEFT
); rSet
.Put( aBoolItem
);
2205 aBoolItem
.SetWhich( SID_ALIGNRIGHT
); rSet
.Put( aBoolItem
);
2206 aBoolItem
.SetWhich( SID_ALIGNCENTERHOR
); rSet
.Put( aBoolItem
);
2207 aBoolItem
.SetWhich( SID_ALIGNBLOCK
); rSet
.Put( aBoolItem
);
2208 bJustifyStd
= false;
2211 //------------------------
2212 // vertikale Ausrichtung
2213 //------------------------
2216 aBoolItem
.SetValue( sal_True
);
2218 eState
= rAttrSet
.GetItemState( ATTR_VER_JUSTIFY
, sal_True
,
2219 (const SfxPoolItem
**)&pVerJustify
);
2225 eVerJustify
= SvxCellVerJustify( pVerJustify
->GetValue() );
2227 switch ( eVerJustify
)
2229 case SVX_VER_JUSTIFY_TOP
:
2230 nWhich
= SID_ALIGNTOP
;
2233 case SVX_VER_JUSTIFY_BOTTOM
:
2234 nWhich
= SID_ALIGNBOTTOM
;
2237 case SVX_VER_JUSTIFY_CENTER
:
2238 nWhich
= SID_ALIGNCENTERVER
;
2241 case SVX_VER_JUSTIFY_STANDARD
:
2243 bJustifyStd
= sal_True
;
2249 case SFX_ITEM_DONTCARE
:
2250 rSet
.InvalidateItem( SID_ALIGNTOP
);
2251 rSet
.InvalidateItem( SID_ALIGNBOTTOM
);
2252 rSet
.InvalidateItem( SID_ALIGNCENTERVER
);
2256 bJustifyStd
= sal_True
;
2262 aBoolItem
.SetWhich( nWhich
);
2263 rSet
.Put( aBoolItem
);
2265 else if ( bJustifyStd
)
2267 aBoolItem
.SetValue( false );
2268 aBoolItem
.SetWhich( SID_ALIGNTOP
); rSet
.Put( aBoolItem
);
2269 aBoolItem
.SetWhich( SID_ALIGNBOTTOM
); rSet
.Put( aBoolItem
);
2270 aBoolItem
.SetWhich( SID_ALIGNCENTERVER
); rSet
.Put( aBoolItem
);
2275 //------------------------------------------------------------------
2277 void ScFormatShell::GetBorderState( SfxItemSet
& rSet
)
2279 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2280 SvxBoxItem
aBoxItem( ATTR_BORDER
);
2281 SvxBoxInfoItem
aInfoItem( ATTR_BORDER_INNER
);
2283 pTabViewShell
->GetSelectionFrame( aBoxItem
, aInfoItem
);
2285 if ( rSet
.GetItemState( ATTR_BORDER
) != SFX_ITEM_UNKNOWN
)
2286 rSet
.Put( aBoxItem
);
2287 if ( rSet
.GetItemState( ATTR_BORDER_INNER
) != SFX_ITEM_UNKNOWN
)
2288 rSet
.Put( aInfoItem
);
2291 //------------------------------------------------------------------
2293 void ScFormatShell::GetAlignState( SfxItemSet
& rSet
)
2295 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2296 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2297 SfxWhichIter
aIter(rSet
);
2298 sal_uInt16 nWhich
= aIter
.FirstWhich();
2300 SvxCellHorJustify eHAlign
= SVX_HOR_JUSTIFY_STANDARD
;
2301 bool bHasHAlign
= rAttrSet
.GetItemState( ATTR_HOR_JUSTIFY
) != SFX_ITEM_DONTCARE
;
2303 eHAlign
= (SvxCellHorJustify
)((const SvxHorJustifyItem
&) rAttrSet
.Get( ATTR_HOR_JUSTIFY
)).GetValue();
2305 SvxCellVerJustify eVAlign
= SVX_VER_JUSTIFY_STANDARD
;
2306 bool bHasVAlign
= rAttrSet
.GetItemState( ATTR_VER_JUSTIFY
) != SFX_ITEM_DONTCARE
;
2308 eVAlign
= (SvxCellVerJustify
)((const SvxVerJustifyItem
&) rAttrSet
.Get( ATTR_VER_JUSTIFY
)).GetValue();
2314 case SID_H_ALIGNCELL
:
2316 rSet
.Put( SvxHorJustifyItem( eHAlign
, nWhich
));
2318 case SID_V_ALIGNCELL
:
2320 rSet
.Put( SvxVerJustifyItem( eVAlign
, nWhich
));
2323 // pseudo slots for Format menu
2324 case SID_ALIGN_ANY_HDEFAULT
:
2325 case SID_ALIGN_ANY_LEFT
:
2326 case SID_ALIGN_ANY_HCENTER
:
2327 case SID_ALIGN_ANY_RIGHT
:
2328 case SID_ALIGN_ANY_JUSTIFIED
:
2329 rSet
.Put( SfxBoolItem( nWhich
, bHasHAlign
&& (eHAlign
== lclConvertSlotToHAlign( nWhich
)) ) );
2331 case SID_ALIGN_ANY_VDEFAULT
:
2332 case SID_ALIGN_ANY_TOP
:
2333 case SID_ALIGN_ANY_VCENTER
:
2334 case SID_ALIGN_ANY_BOTTOM
:
2335 rSet
.Put( SfxBoolItem( nWhich
, bHasVAlign
&& (eVAlign
== lclConvertSlotToVAlign( nWhich
)) ) );
2338 nWhich
= aIter
.NextWhich();
2342 void ScFormatShell::GetNumFormatState( SfxItemSet
& rSet
)
2344 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2345 ScDocument
* pDoc
= pViewData
->GetDocument();
2346 short nType
= GetCurrentNumberFormatType();
2348 SfxWhichIter
aIter(rSet
);
2349 sal_uInt16 nWhich
= aIter
.FirstWhich();
2354 case SID_NUMBER_FORMAT
:
2356 // String aFormatCode; // bleibt leer, wenn dont-care
2358 // const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2359 // if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
2361 // sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2362 // ATTR_VALUE_FORMAT )).GetValue();
2364 // SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2365 // const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2366 // if ( pFormatEntry )
2367 // aFormatCode = pFormatEntry->GetFormatstring();
2370 // rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2373 // symphony version with format interpretation
2375 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2377 if(SFX_ITEM_DONTCARE
!= rAttrSet
.GetItemState(ATTR_VALUE_FORMAT
))
2379 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2380 sal_uInt32 nNumberFormat
= ((const SfxUInt32Item
&)rAttrSet
.Get(ATTR_VALUE_FORMAT
)).GetValue();
2381 bool bThousand(false);
2382 bool bNegRed(false);
2383 sal_uInt16
nPrecision(0);
2384 sal_uInt16
nLeadZeroes(0);
2386 pFormatter
->GetFormatSpecialInfo(nNumberFormat
,bThousand
, bNegRed
, nPrecision
, nLeadZeroes
);
2388 static String sBreak
= OUString(",");
2389 const String sThousand
= OUString::number(static_cast<sal_Int32
>(bThousand
));
2390 const String sNegRed
= OUString::number(static_cast<sal_Int32
>(bNegRed
));
2391 const String sPrecision
= OUString::number(nPrecision
);
2392 const String sLeadZeroes
= OUString::number(nLeadZeroes
);
2394 aFormat
+= sThousand
;
2398 aFormat
+= sPrecision
;
2400 aFormat
+= sLeadZeroes
;
2403 rSet
.Put(SfxStringItem(nWhich
, aFormat
));
2407 rSet
.InvalidateItem( nWhich
);
2412 case SID_NUMBER_TYPE_FORMAT
:
2414 sal_Int16 aFormatCode
= -1;
2415 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2416 if ( rAttrSet
.GetItemState( ATTR_VALUE_FORMAT
) >= SFX_ITEM_AVAILABLE
) //Modify for more robust
2418 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2419 sal_uInt32 nNumberFormat
= pTabViewShell
->GetSelectionPattern()->GetNumberFormat( pFormatter
);
2420 const SvNumberformat
* pFormatEntry
= pFormatter
->GetEntry( nNumberFormat
);
2421 bool bStandard
= false;
2425 aFormatCode
= pFormatEntry
->GetType();
2426 bStandard
= pFormatEntry
->IsStandard();
2431 case NUMBERFORMAT_NUMBER
:
2432 case NUMBERFORMAT_NUMBER
| NUMBERFORMAT_DEFINED
:
2433 //use format code and standard format code to judge whether it is General,
2434 //if (nNumberFormat == nStandardNumberFormat)
2440 case NUMBERFORMAT_PERCENT
:
2441 case NUMBERFORMAT_PERCENT
| NUMBERFORMAT_DEFINED
:
2444 case NUMBERFORMAT_CURRENCY
:
2445 case NUMBERFORMAT_CURRENCY
| NUMBERFORMAT_DEFINED
:
2448 case NUMBERFORMAT_DATE
:
2449 case NUMBERFORMAT_DATE
| NUMBERFORMAT_DEFINED
:
2451 case NUMBERFORMAT_DATETIME
:
2452 case NUMBERFORMAT_DATETIME
| NUMBERFORMAT_DEFINED
:
2455 case NUMBERFORMAT_TIME
:
2456 case NUMBERFORMAT_TIME
| NUMBERFORMAT_DEFINED
:
2459 case NUMBERFORMAT_SCIENTIFIC
:
2460 case NUMBERFORMAT_SCIENTIFIC
| NUMBERFORMAT_DEFINED
:
2463 case NUMBERFORMAT_FRACTION
:
2464 case NUMBERFORMAT_FRACTION
| NUMBERFORMAT_DEFINED
:
2467 case NUMBERFORMAT_LOGICAL
:
2468 case NUMBERFORMAT_LOGICAL
| NUMBERFORMAT_DEFINED
:
2471 case NUMBERFORMAT_TEXT
:
2472 case NUMBERFORMAT_TEXT
| NUMBERFORMAT_DEFINED
:
2476 aFormatCode
= -1; //for more roburst
2478 if( aFormatCode
== -1 )
2479 rSet
.InvalidateItem( nWhich
);
2481 rSet
.Put( SfxInt16Item( nWhich
, aFormatCode
) );
2485 rSet
.InvalidateItem( nWhich
);
2490 case SID_NUMBER_SCIENTIFIC
:
2491 rSet
.Put( SfxBoolItem(nWhich
, (nType
& NUMBERFORMAT_SCIENTIFIC
)) );
2493 case SID_NUMBER_DATE
:
2494 rSet
.Put( SfxBoolItem(nWhich
, (nType
& NUMBERFORMAT_DATE
)) );
2496 case SID_NUMBER_CURRENCY
:
2497 rSet
.Put( SfxBoolItem(nWhich
, (nType
& NUMBERFORMAT_CURRENCY
)) );
2499 case SID_NUMBER_PERCENT
:
2500 rSet
.Put( SfxBoolItem(nWhich
, (nType
& NUMBERFORMAT_PERCENT
)) );
2502 case SID_NUMBER_TIME
:
2503 rSet
.Put( SfxBoolItem(nWhich
, (nType
& NUMBERFORMAT_TIME
)) );
2506 nWhich
= aIter
.NextWhich();
2511 void ScFormatShell::ExecuteTextDirection( SfxRequest
& rReq
)
2513 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2514 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
2515 bool bEditMode
= false;
2516 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2519 SC_MOD()->InputEnterHandler();
2520 pTabViewShell
->UpdateInputHandler();
2522 sal_uInt16 nSlot
= rReq
.GetSlot();
2525 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
2526 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
2528 sal_Bool bVert
= (nSlot
== SID_TEXTDIRECTION_TOP_TO_BOTTOM
);
2529 ScPatternAttr
aAttr( GetViewData()->GetDocument()->GetPool() );
2530 SfxItemSet
& rItemSet
= aAttr
.GetItemSet();
2531 rItemSet
.Put( SfxBoolItem( ATTR_STACKED
, bVert
) );
2532 rItemSet
.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN
, bVert
) );
2533 pTabViewShell
->ApplySelectionPattern( aAttr
);
2534 pTabViewShell
->AdjustBlockHeight();
2538 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
2539 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
2541 SvxFrameDirection eDirection
= ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
) ?
2542 FRMDIR_HORI_LEFT_TOP
: FRMDIR_HORI_RIGHT_TOP
;
2543 pTabViewShell
->ApplyAttr( SvxFrameDirectionItem( eDirection
, ATTR_WRITINGDIR
) );
2548 SC_MOD()->SetInputMode( SC_INPUT_TABLE
);
2551 void ScFormatShell::GetTextDirectionState( SfxItemSet
& rSet
)
2553 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2554 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2556 sal_Bool bVertDontCare
=
2557 (rAttrSet
.GetItemState( ATTR_VERTICAL_ASIAN
) == SFX_ITEM_DONTCARE
) ||
2558 (rAttrSet
.GetItemState( ATTR_STACKED
) == SFX_ITEM_DONTCARE
);
2559 sal_Bool bLeftRight
= !bVertDontCare
&&
2560 !((const SfxBoolItem
&) rAttrSet
.Get( ATTR_STACKED
)).GetValue();
2561 sal_Bool bTopBottom
= !bVertDontCare
&& !bLeftRight
&&
2562 ((const SfxBoolItem
&) rAttrSet
.Get( ATTR_VERTICAL_ASIAN
)).GetValue();
2564 sal_Bool bBidiDontCare
= (rAttrSet
.GetItemState( ATTR_WRITINGDIR
) == SFX_ITEM_DONTCARE
);
2565 EEHorizontalTextDirection eBidiDir
= EE_HTEXTDIR_DEFAULT
;
2566 if ( !bBidiDontCare
)
2568 SvxFrameDirection eCellDir
= (SvxFrameDirection
)((const SvxFrameDirectionItem
&)
2569 rAttrSet
.Get( ATTR_WRITINGDIR
)).GetValue();
2570 if ( eCellDir
== FRMDIR_ENVIRONMENT
)
2571 eBidiDir
= (EEHorizontalTextDirection
)GetViewData()->GetDocument()->
2572 GetEditTextDirection( GetViewData()->GetTabNo() );
2573 else if ( eCellDir
== FRMDIR_HORI_RIGHT_TOP
)
2574 eBidiDir
= EE_HTEXTDIR_R2L
;
2576 eBidiDir
= EE_HTEXTDIR_L2R
;
2579 SvtLanguageOptions aLangOpt
;
2580 sal_Bool bDisableCTLFont
= !aLangOpt
.IsCTLFontEnabled();
2581 sal_Bool bDisableVerticalText
= !aLangOpt
.IsVerticalTextEnabled();
2583 SfxWhichIter
aIter( rSet
);
2584 sal_uInt16 nWhich
= aIter
.FirstWhich();
2589 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
2590 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
2591 if ( bDisableVerticalText
)
2592 rSet
.DisableItem( nWhich
);
2596 rSet
.InvalidateItem( nWhich
);
2597 else if ( nWhich
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
)
2598 rSet
.Put( SfxBoolItem( nWhich
, bLeftRight
) );
2600 rSet
.Put( SfxBoolItem( nWhich
, bTopBottom
) );
2604 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
2605 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
2606 if ( bDisableCTLFont
)
2607 rSet
.DisableItem( nWhich
);
2611 rSet
.DisableItem( nWhich
);
2612 else if ( bBidiDontCare
)
2613 rSet
.InvalidateItem( nWhich
);
2614 else if ( nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
)
2615 rSet
.Put( SfxBoolItem( nWhich
, eBidiDir
== EE_HTEXTDIR_L2R
) );
2617 rSet
.Put( SfxBoolItem( nWhich
, eBidiDir
== EE_HTEXTDIR_R2L
) );
2620 nWhich
= aIter
.NextWhich();
2624 void ScFormatShell::ExecFormatPaintbrush( SfxRequest
& rReq
)
2626 ScViewFunc
* pView
= pViewData
->GetView();
2627 if ( pView
->HasPaintBrush() )
2629 // cancel paintbrush mode
2630 pView
->ResetBrushDocument();
2634 sal_Bool bLock
= false;
2635 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2636 if( pArgs
&& pArgs
->Count() >= 1 )
2637 bLock
= static_cast<const SfxBoolItem
&>(pArgs
->Get(SID_FORMATPAINTBRUSH
)).GetValue();
2639 // in case of multi selection, deselect all and use the cursor position
2641 if ( pViewData
->GetSimpleArea(aDummy
) != SC_MARK_SIMPLE
)
2644 ScDocument
* pBrushDoc
= new ScDocument( SCDOCMODE_CLIP
);
2645 pView
->CopyToClip( pBrushDoc
, false, true );
2646 pView
->SetBrushDocument( pBrushDoc
, bLock
);
2650 void ScFormatShell::StateFormatPaintbrush( SfxItemSet
& rSet
)
2652 if ( pViewData
->HasEditView( pViewData
->GetActivePart() ) )
2653 rSet
.DisableItem( SID_FORMATPAINTBRUSH
);
2655 rSet
.Put( SfxBoolItem( SID_FORMATPAINTBRUSH
, pViewData
->GetView()->HasPaintBrush() ) );
2658 short ScFormatShell::GetCurrentNumberFormatType()
2660 short nType
= NUMBERFORMAT_ALL
;
2661 ScDocument
* pDoc
= GetViewData()->GetDocument();
2662 ScMarkData
aMark(GetViewData()->GetMarkData());
2663 const SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2667 // TODO: Find out how to get a selected table range in case multiple tables
2668 // are selected. Currently we only check for the current active table.
2670 if ( aMark
.IsMarked() || aMark
.IsMultiMarked() )
2672 aMark
.MarkToMulti();
2674 aMark
.GetMultiMarkArea(aRange
);
2676 const ScMarkArray
* pArray
= aMark
.GetArray();
2680 short nComboType
= NUMBERFORMAT_ALL
;
2681 bool bFirstItem
= true;
2682 for (SCCOL nCol
= aRange
.aStart
.Col(); nCol
<= aRange
.aEnd
.Col(); ++nCol
)
2684 const ScMarkArray
& rColArray
= pArray
[nCol
];
2685 if (!rColArray
.HasMarks())
2689 ScMarkArrayIter
aMarkIter(&rColArray
);
2690 while (aMarkIter
.Next(nRow1
, nRow2
))
2692 ScRange
aColRange(nCol
, nRow1
, aRange
.aStart
.Tab());
2693 aColRange
.aEnd
.SetRow(nRow2
);
2694 sal_uInt32 nNumFmt
= pDoc
->GetNumberFormat(aColRange
);
2695 const SvNumberformat
* pEntry
= pFormatter
->GetEntry(nNumFmt
);
2699 short nThisType
= pEntry
->GetType();
2703 nComboType
= nThisType
;
2705 else if (nComboType
!= nThisType
)
2706 // mixed number format type.
2707 return NUMBERFORMAT_ALL
;
2715 pDoc
->GetNumberFormat( pViewData
->GetCurX(), pViewData
->GetCurY(),
2716 pViewData
->GetTabNo(), nNumFmt
);
2717 const SvNumberformat
* pEntry
= pFormatter
->GetEntry( nNumFmt
);
2718 nType
= pEntry
? pEntry
->GetType() : 0;
2723 void ScFormatShell::ExecViewOptions( SfxRequest
& rReq
)
2725 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2726 SfxBindings
& rBindings
= pViewData
->GetBindings();
2727 const SfxItemSet
* pNewAttrs
= rReq
.GetArgs();
2731 sal_uInt16 nSlot
= rReq
.GetSlot();
2733 if( nSlot
== SID_SCGRIDSHOW
)
2736 ScViewData
* pLclViewData
= pTabViewShell
->GetViewData();
2737 const ScViewOptions
& rOldOpt
= pLclViewData
->GetOptions();
2738 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
2739 bool bState
= ((const SfxBoolItem
&)pNewAttrs
->Get( pNewAttrs
->GetPool()->GetWhich( nSlot
) )).GetValue();
2741 if ( (bool)rOldOpt
.GetOption( VOPT_GRID
) != bState
)
2743 ScViewOptions
rNewOpt(rOldOpt
);
2744 rNewOpt
.SetOption( VOPT_GRID
, bState
);
2745 pLclViewData
->SetOptions( rNewOpt
);
2746 pLclViewData
->GetDocument()->SetViewOptions( rNewOpt
);
2747 pDocSh
->SetDocumentModified();
2748 //add , write the change to sc view config
2749 ScModule
* pScMod
= SC_MOD();
2750 pScMod
->SetViewOptions( rNewOpt
);
2752 rBindings
.Invalidate( nSlot
);
2759 void ScFormatShell::GetViewOptions( SfxItemSet
& rSet
)
2761 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2764 ScViewOptions aViewOpt
= pTabViewShell
->GetViewData()->GetOptions();
2765 rSet
.ClearItem(SID_SCGRIDSHOW
);
2766 SfxBoolItem
aItem( SID_SCGRIDSHOW
, aViewOpt
.GetOption( VOPT_GRID
) );
2771 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */