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"
77 #define FormatForSelection
78 #include "scslots.hxx"
80 #include "scabstdlg.hxx"
81 #include <editeng/fontitem.hxx>
83 #include <boost/scoped_ptr.hpp>
85 using namespace ::com::sun::star
;
89 SvxCellHorJustify
lclConvertSlotToHAlign( sal_uInt16 nSlot
)
91 SvxCellHorJustify eHJustify
= SVX_HOR_JUSTIFY_STANDARD
;
94 case SID_ALIGN_ANY_HDEFAULT
: eHJustify
= SVX_HOR_JUSTIFY_STANDARD
; break;
95 case SID_ALIGN_ANY_LEFT
: eHJustify
= SVX_HOR_JUSTIFY_LEFT
; break;
96 case SID_ALIGN_ANY_HCENTER
: eHJustify
= SVX_HOR_JUSTIFY_CENTER
; break;
97 case SID_ALIGN_ANY_RIGHT
: eHJustify
= SVX_HOR_JUSTIFY_RIGHT
; break;
98 case SID_ALIGN_ANY_JUSTIFIED
: eHJustify
= SVX_HOR_JUSTIFY_BLOCK
; break;
99 default: OSL_FAIL( "lclConvertSlotToHAlign - invalid slot" );
104 SvxCellVerJustify
lclConvertSlotToVAlign( sal_uInt16 nSlot
)
106 SvxCellVerJustify eVJustify
= SVX_VER_JUSTIFY_STANDARD
;
109 case SID_ALIGN_ANY_VDEFAULT
: eVJustify
= SVX_VER_JUSTIFY_STANDARD
; break;
110 case SID_ALIGN_ANY_TOP
: eVJustify
= SVX_VER_JUSTIFY_TOP
; break;
111 case SID_ALIGN_ANY_VCENTER
: eVJustify
= SVX_VER_JUSTIFY_CENTER
; break;
112 case SID_ALIGN_ANY_BOTTOM
: eVJustify
= SVX_VER_JUSTIFY_BOTTOM
; break;
113 default: OSL_FAIL( "lclConvertSlotToVAlign - invalid slot" );
120 TYPEINIT1( ScFormatShell
, SfxShell
);
122 SFX_IMPL_INTERFACE(ScFormatShell
, SfxShell
)
124 void ScFormatShell::InitInterface_Impl()
126 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_SERVER
,
127 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 void ScFormatShell::GetStyleState( SfxItemSet
& rSet
)
153 ScDocument
* pDoc
= GetViewData()->GetDocument();
154 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
155 SfxStyleSheetBasePool
* pStylePool
= pDoc
->GetStyleSheetPool();
157 bool bProtected
= false;
158 SCTAB nTabCount
= pDoc
->GetTableCount();
159 for (SCTAB i
=0; i
<nTabCount
; i
++)
160 if (pDoc
->IsTabProtected(i
)) // look after protected table
163 SfxWhichIter
aIter(rSet
);
164 sal_uInt16 nWhich
= aIter
.FirstWhich();
165 sal_uInt16 nSlotId
= 0;
169 nSlotId
= SfxItemPool::IsWhich( nWhich
)
170 ? GetPool().GetSlotId( nWhich
)
175 case SID_STYLE_APPLY
:
177 rSet
.DisableItem( nSlotId
);
180 case SID_STYLE_FAMILY2
: // cell style sheets
182 SfxStyleSheet
* pStyleSheet
= const_cast<SfxStyleSheet
*>(
183 pTabViewShell
->GetStyleSheetFromMarked());
186 rSet
.Put( SfxTemplateItem( nSlotId
, pStyleSheet
->GetName() ) );
188 rSet
.Put( SfxTemplateItem( nSlotId
, OUString() ) );
192 case SID_STYLE_FAMILY4
: // page style sheets
194 SCTAB nCurTab
= GetViewData()->GetTabNo();
195 OUString aPageStyle
= pDoc
->GetPageStyle( nCurTab
);
196 SfxStyleSheet
* pStyleSheet
= pStylePool
? static_cast<SfxStyleSheet
*>(pStylePool
->
197 Find( aPageStyle
, SFX_STYLE_FAMILY_PAGE
)) : NULL
;
200 rSet
.Put( SfxTemplateItem( nSlotId
, aPageStyle
) );
202 rSet
.Put( SfxTemplateItem( nSlotId
, OUString() ) );
206 case SID_STYLE_WATERCAN
:
208 rSet
.Put( SfxBoolItem( nSlotId
, SC_MOD()->GetIsWaterCan() ) );
212 case SID_STYLE_UPDATE_BY_EXAMPLE
:
214 SfxPoolItem
* pItem
= NULL
;
215 pTabViewShell
->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY
, pItem
);
216 SfxUInt16Item
* pFamilyItem
= dynamic_cast<SfxUInt16Item
*>(pItem
);
218 bool bPage
= pFamilyItem
&& SFX_STYLE_FAMILY_PAGE
== SfxTemplate::NIdToSfxFamilyId(pFamilyItem
->GetValue());
221 if ( bProtected
|| bPage
)
222 rSet
.DisableItem( nSlotId
);
227 case SID_STYLE_DELETE
:
231 SfxPoolItem
* pItem
= NULL
;
232 pTabViewShell
->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY
, pItem
);
233 SfxUInt16Item
* pFamilyItem
= dynamic_cast<SfxUInt16Item
*>(pItem
);
234 bool bPage
= pFamilyItem
&& SFX_STYLE_FAMILY_PAGE
== SfxTemplate::NIdToSfxFamilyId(pFamilyItem
->GetValue());
237 if ( bProtected
&& !bPage
)
238 rSet
.DisableItem( nSlotId
);
246 nWhich
= aIter
.NextWhich();
250 void ScFormatShell::ExecuteStyle( SfxRequest
& rReq
)
252 // in case of vertical toolbar
253 if ( !rReq
.GetArgs() )
255 pViewData
->GetDispatcher().Execute( SID_STYLE_DESIGNER
, SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
);
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
& rDoc
= pDocSh
->GetDocument();
266 ScMarkData
& rMark
= GetViewData()->GetMarkData();
267 ScModule
* pScMod
= SC_MOD();
269 bool bUndo
= rDoc
.IsUndoEnabled();
270 SfxStyleSheetBasePool
* pStylePool
= rDoc
.GetStyleSheetPool();
272 if ( (nSlotId
== SID_STYLE_PREVIEW
)
273 || (nSlotId
== SID_STYLE_END_PREVIEW
) )
275 if (nSlotId
== SID_STYLE_PREVIEW
)
277 SfxStyleFamily eFamily
= SFX_STYLE_FAMILY_PARA
;
278 const SfxPoolItem
* pFamItem
;
279 if ( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( SID_STYLE_FAMILY
, true, &pFamItem
) )
280 eFamily
= (SfxStyleFamily
) static_cast<const SfxUInt16Item
*>(pFamItem
)->GetValue();
281 const SfxPoolItem
* pNameItem
;
283 if (pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( nSlotId
, true, &pNameItem
))
284 aStyleName
= static_cast<const SfxStringItem
*>(pNameItem
)->GetValue();
285 if ( eFamily
== SFX_STYLE_FAMILY_PARA
) // CellStyles
287 ScMarkData
aFuncMark( pViewData
->GetMarkData() );
288 ScViewUtil::UnmarkFiltered( aFuncMark
, &rDoc
);
289 aFuncMark
.MarkToMulti();
291 if ( !aFuncMark
.IsMarked() && !aFuncMark
.IsMultiMarked() )
293 SCCOL nCol
= pViewData
->GetCurX();
294 SCROW nRow
= pViewData
->GetCurY();
295 SCTAB nTab
= pViewData
->GetTabNo();
296 ScRange
aRange( nCol
, nRow
, nTab
);
297 aFuncMark
.SetMarkArea( aRange
);
299 rDoc
.SetPreviewSelection( aFuncMark
);
300 ScStyleSheet
* pPreviewStyle
= static_cast<ScStyleSheet
*>( pStylePool
->Find( aStyleName
, eFamily
) );
301 rDoc
.SetPreviewCellStyle( pPreviewStyle
);
302 ScPatternAttr
aAttr( *rDoc
.GetSelectionPattern( aFuncMark
) );
303 aAttr
.SetStyleSheet( pPreviewStyle
);
305 SfxItemSet
aItemSet( GetPool() );
307 ScPatternAttr
aNewAttrs( GetViewData()->GetDocument()->GetPool() );
308 SfxItemSet
& rNewSet
= aNewAttrs
.GetItemSet();
309 rNewSet
.Put( aItemSet
, false );
311 rDoc
.ApplySelectionPattern( aNewAttrs
, rDoc
.GetPreviewSelection() );
312 pTabViewShell
->UpdateSelectionArea( aFuncMark
, &aAttr
);
317 // No mark at all happens when creating a new document, in which
318 // case the selection pattern obtained would be empty (created of
319 // GetPool()) anyway and nothing needs to be applied.
320 ScMarkData
aPreviewMark( rDoc
.GetPreviewSelection());
321 if (aPreviewMark
.IsMarked() || aPreviewMark
.IsMultiMarked())
323 ScPatternAttr
aAttr( *rDoc
.GetSelectionPattern( aPreviewMark
) );
324 if ( ScStyleSheet
* pPreviewStyle
= rDoc
.GetPreviewCellStyle() )
325 aAttr
.SetStyleSheet( pPreviewStyle
);
326 rDoc
.SetPreviewCellStyle(NULL
);
328 SfxItemSet
aItemSet( GetPool() );
330 ScPatternAttr
aNewAttrs( GetViewData()->GetDocument()->GetPool() );
331 SfxItemSet
& rNewSet
= aNewAttrs
.GetItemSet();
332 rNewSet
.Put( aItemSet
, false );
333 rDoc
.ApplySelectionPattern( aNewAttrs
, aPreviewMark
);
334 pTabViewShell
->UpdateSelectionArea( aPreviewMark
, &aAttr
);
338 else if ( (nSlotId
== SID_STYLE_NEW
)
339 || (nSlotId
== SID_STYLE_EDIT
)
340 || (nSlotId
== SID_STYLE_DELETE
)
341 || (nSlotId
== SID_STYLE_HIDE
)
342 || (nSlotId
== SID_STYLE_SHOW
)
343 || (nSlotId
== SID_STYLE_APPLY
)
344 || (nSlotId
== SID_STYLE_WATERCAN
)
345 || (nSlotId
== SID_STYLE_FAMILY
)
346 || (nSlotId
== SID_STYLE_NEW_BY_EXAMPLE
)
347 || (nSlotId
== SID_STYLE_UPDATE_BY_EXAMPLE
) )
349 SfxStyleSheetBase
* pStyleSheet
= NULL
;
351 bool bStyleToMarked
= false;
352 bool bListAction
= false;
353 bool bAddUndo
= false; // add ScUndoModifyStyle (style modified)
354 ScStyleSaveData aOldData
; // for undo/redo
355 ScStyleSaveData aNewData
;
357 SfxStyleFamily eFamily
= SFX_STYLE_FAMILY_PARA
;
358 const SfxPoolItem
* pFamItem
;
359 if ( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( SID_STYLE_FAMILY
, true, &pFamItem
) )
360 eFamily
= (SfxStyleFamily
) static_cast<const SfxUInt16Item
*>(pFamItem
)->GetValue();
361 else if ( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( SID_STYLE_FAMILYNAME
, true, &pFamItem
) )
363 OUString sFamily
= static_cast<const SfxStringItem
*>(pFamItem
)->GetValue();
364 if (sFamily
== "CellStyles")
365 eFamily
= SFX_STYLE_FAMILY_PARA
;
366 else if (sFamily
== "PageStyles")
367 eFamily
= SFX_STYLE_FAMILY_PAGE
;
371 sal_uInt16 nRetMask
= 0xffff;
373 pStylePool
->SetSearchMask( eFamily
, SFXSTYLEBIT_ALL
);
379 const SfxPoolItem
* pNameItem
;
380 if (pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( nSlotId
, true, &pNameItem
))
381 aStyleName
= static_cast<const SfxStringItem
*>(pNameItem
)->GetValue();
383 const SfxPoolItem
* pRefItem
=NULL
;
384 if (pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( SID_STYLE_REFERENCE
, true, &pRefItem
))
387 aRefName
= static_cast<const SfxStringItem
*>(pRefItem
)->GetValue();
390 pStyleSheet
= &(pStylePool
->Make( aStyleName
, eFamily
,
391 SFXSTYLEBIT_USERDEF
) );
393 if ( pStyleSheet
&& pStyleSheet
->HasParentSupport() )
394 pStyleSheet
->SetParent(aRefName
);
398 case SID_STYLE_APPLY
:
400 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, SID_APPLY_STYLE
, false );
401 SFX_REQUEST_ARG( rReq
, pFamilyItem
, SfxStringItem
, SID_STYLE_FAMILYNAME
, false );
402 if ( pFamilyItem
&& pNameItem
)
404 com::sun::star::uno::Reference
< com::sun::star::style::XStyleFamiliesSupplier
> xModel(pDocSh
->GetModel(), com::sun::star::uno::UNO_QUERY
);
407 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xStyles
;
408 com::sun::star::uno::Reference
< com::sun::star::container::XNameAccess
> xCont
= xModel
->getStyleFamilies();
409 xCont
->getByName(pFamilyItem
->GetValue()) >>= xStyles
;
410 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> xInfo
;
411 xStyles
->getByName( pNameItem
->GetValue() ) >>= xInfo
;
413 xInfo
->getPropertyValue("DisplayName") >>= aUIName
;
414 if ( !aUIName
.isEmpty() )
415 rReq
.AppendItem( SfxStringItem( SID_STYLE_APPLY
, aUIName
) );
417 catch( com::sun::star::uno::Exception
& )
424 case SID_STYLE_DELETE
:
427 case SID_STYLE_NEW_BY_EXAMPLE
:
429 const SfxPoolItem
* pNameItem
;
430 if (pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( nSlotId
, true, &pNameItem
))
431 aStyleName
= static_cast<const SfxStringItem
*>(pNameItem
)->GetValue();
432 pStyleSheet
= pStylePool
->Find( aStyleName
, eFamily
);
434 aOldData
.InitFromStyle( pStyleSheet
);
438 case SID_STYLE_WATERCAN
:
440 bool bWaterCan
= pScMod
->GetIsWaterCan();
444 const SfxPoolItem
* pItem
;
446 if ( SfxItemState::SET
==
447 pArgs
->GetItemState( nSlotId
, true, &pItem
) )
449 const SfxStringItem
* pStrItem
= PTR_CAST(SfxStringItem
,pItem
);
452 aStyleName
= pStrItem
->GetValue();
453 pStyleSheet
= pStylePool
->Find( aStyleName
, eFamily
);
457 static_cast<ScStyleSheetPool
*>(pStylePool
)->
458 SetActualStyleSheet( pStyleSheet
);
465 if ( !bWaterCan
&& pStyleSheet
)
467 pScMod
->SetWaterCan( true );
468 pTabViewShell
->SetActivePointer( Pointer(PointerStyle::Fill
) );
473 pScMod
->SetWaterCan( false );
474 pTabViewShell
->SetActivePointer( Pointer(PointerStyle::Arrow
) );
484 // set new style for WaterCan-Mode
485 if ( nSlotId
== SID_STYLE_APPLY
&& pScMod
->GetIsWaterCan() && pStyleSheet
)
486 static_cast<ScStyleSheetPool
*>(pStylePool
)->SetActualStyleSheet( pStyleSheet
);
490 case SFX_STYLE_FAMILY_PARA
:
494 case SID_STYLE_DELETE
:
498 pTabViewShell
->RemoveStyleSheetInUse( pStyleSheet
);
499 pStylePool
->Remove( pStyleSheet
);
500 pTabViewShell
->InvalidateAttribs();
501 nRetMask
= sal_uInt16(true);
506 nRetMask
= sal_uInt16(false);
515 pStyleSheet
->SetHidden( nSlotId
== SID_STYLE_HIDE
);
516 pTabViewShell
->InvalidateAttribs();
520 nRetMask
= sal_uInt16(false);
524 case SID_STYLE_APPLY
:
526 if ( pStyleSheet
&& !pScMod
->GetIsWaterCan() )
528 // apply style sheet to document
529 pTabViewShell
->SetStyleSheetToMarked( static_cast<SfxStyleSheet
*>(pStyleSheet
) );
530 pTabViewShell
->InvalidateAttribs();
536 case SID_STYLE_NEW_BY_EXAMPLE
:
537 case SID_STYLE_UPDATE_BY_EXAMPLE
:
539 // create/replace style sheet by attributes
540 // at cursor position:
542 const ScPatternAttr
* pAttrItem
= NULL
;
544 // Die Abfrage, ob markiert ist, war hier immer falsch,
545 // darum jetzt gar nicht mehr, und einfach vom Cursor.
546 // Wenn Attribute aus der Selektion genommen werden sollen,
547 // muss noch darauf geachtet werden, Items aus Vorlagen nicht
548 // zu uebernehmen (GetSelectionPattern sammelt auch Items aus
549 // Vorlagen zusammen) (#44748#)
550 // pAttrItem = GetSelectionPattern();
552 // ScViewData* pViewData = GetViewData();
553 SCCOL nCol
= pViewData
->GetCurX();
554 SCROW nRow
= pViewData
->GetCurY();
555 pAttrItem
= rDoc
.GetPattern( nCol
, nRow
, nCurTab
);
557 SfxItemSet aAttrSet
= pAttrItem
->GetItemSet();
558 aAttrSet
.ClearItem( ATTR_MERGE
);
559 aAttrSet
.ClearItem( ATTR_MERGE_FLAG
);
560 // bedingte Formatierung und Gueltigkeit nicht uebernehmen,
561 // weil sie in der Vorlage nicht editiert werden koennen
562 aAttrSet
.ClearItem( ATTR_VALIDDATA
);
563 aAttrSet
.ClearItem( ATTR_CONDITIONAL
);
565 if ( SID_STYLE_NEW_BY_EXAMPLE
== nSlotId
)
569 OUString aUndo
= ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE
);
570 pDocSh
->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
574 bool bConvertBack
= false;
575 SfxStyleSheet
* pSheetInUse
= const_cast<SfxStyleSheet
*>(
576 pTabViewShell
->GetStyleSheetFromMarked());
578 // wenn neuer Style vorhanden und in der Selektion
579 // verwendet wird, so darf der Parent nicht uebernommen
582 if ( pStyleSheet
&& pSheetInUse
&& pStyleSheet
== pSheetInUse
)
585 // wenn bereits vorhanden, erstmal entfernen...
588 // Style-Pointer zu Namen vor Erase,
589 // weil Zellen sonst ungueltige Pointer
591 //!!! bei Gelenheit mal eine Methode, die
592 // das fuer einen bestimmten Style macht
593 rDoc
.StylesToNames();
595 pStylePool
->Remove(pStyleSheet
);
598 // ...und neu anlegen
599 pStyleSheet
= &pStylePool
->Make( aStyleName
, eFamily
,
600 SFXSTYLEBIT_USERDEF
);
602 // wenn ein Style vorhanden ist, so wird dieser
603 // Parent der neuen Vorlage:
604 if ( pSheetInUse
&& pStyleSheet
->HasParentSupport() )
605 pStyleSheet
->SetParent( pSheetInUse
->GetName() );
608 // Namen zu Style-Pointer
609 rDoc
.UpdStlShtPtrsFrmNms();
611 rDoc
.GetPool()->CellStyleCreated( aStyleName
, &rDoc
);
613 // Attribute uebernehmen und Style anwenden
614 pStyleSheet
->GetItemSet().Put( aAttrSet
);
615 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
617 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
618 // (pStyleSheet pointer is used!)
619 bStyleToMarked
= true;
621 else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
623 pStyleSheet
= const_cast<SfxStyleSheet
*>(pTabViewShell
->GetStyleSheetFromMarked());
627 aOldData
.InitFromStyle( pStyleSheet
);
631 OUString aUndo
= ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE
);
632 pDocSh
->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
636 pStyleSheet
->GetItemSet().Put( aAttrSet
);
637 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
639 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
640 // (pStyleSheet pointer is used!)
641 bStyleToMarked
= true;
645 aNewData
.InitFromStyle( pStyleSheet
);
654 } // case SFX_STYLE_FAMILY_PARA:
657 case SFX_STYLE_FAMILY_PAGE
:
661 case SID_STYLE_DELETE
:
663 nRetMask
= sal_uInt16( NULL
!= pStyleSheet
);
666 if ( rDoc
.RemovePageStyleInUse( pStyleSheet
->GetName() ) )
668 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), nCurTab
).UpdatePages();
669 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
670 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
672 pStylePool
->Remove( pStyleSheet
);
673 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
674 pDocSh
->SetDocumentModified();
684 nRetMask
= sal_uInt16( NULL
!= pStyleSheet
);
687 pStyleSheet
->SetHidden( nSlotId
== SID_STYLE_HIDE
);
688 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
689 pDocSh
->SetDocumentModified();
695 case SID_STYLE_APPLY
:
697 nRetMask
= sal_uInt16( NULL
!= pStyleSheet
);
698 if ( pStyleSheet
&& !pScMod
->GetIsWaterCan() )
700 ScUndoApplyPageStyle
* pUndoAction
= 0;
701 SCTAB nTabCount
= rDoc
.GetTableCount();
702 ScMarkData::iterator itr
= rMark
.begin(), itrEnd
= rMark
.end();
703 for (; itr
!= itrEnd
&& *itr
< nTabCount
; ++itr
)
705 OUString aOldName
= rDoc
.GetPageStyle( *itr
);
706 if ( aOldName
!= aStyleName
)
708 rDoc
.SetPageStyle( *itr
, aStyleName
);
709 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), *itr
).UpdatePages();
711 pUndoAction
= new ScUndoApplyPageStyle( pDocSh
, aStyleName
);
712 pUndoAction
->AddSheetAction( *itr
, aOldName
);
717 pDocSh
->GetUndoManager()->AddUndoAction( pUndoAction
);
718 pDocSh
->SetDocumentModified();
719 rBindings
.Invalidate( SID_STYLE_FAMILY4
);
720 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
721 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
728 case SID_STYLE_NEW_BY_EXAMPLE
:
730 const OUString
& rStrCurStyle
= rDoc
.GetPageStyle( nCurTab
);
732 if ( rStrCurStyle
!= aStyleName
)
734 SfxStyleSheetBase
* pCurStyle
= pStylePool
->Find( rStrCurStyle
, eFamily
);
735 SfxItemSet aAttrSet
= pCurStyle
->GetItemSet();
737 bool bUsed
= rDoc
.IsPageStyleInUse( aStyleName
, &nInTab
);
739 // wenn bereits vorhanden, erstmal entfernen...
741 pStylePool
->Remove( pStyleSheet
);
743 // ...und neu anlegen
744 pStyleSheet
= &pStylePool
->Make( aStyleName
, eFamily
,
745 SFXSTYLEBIT_USERDEF
);
747 // Attribute uebernehmen
748 pStyleSheet
->GetItemSet().Put( aAttrSet
);
749 pDocSh
->SetDocumentModified();
751 // wenn in Verwendung -> Update
753 ScPrintFunc( pDocSh
, pTabViewShell
->GetPrinter(true), nInTab
).UpdatePages();
755 aNewData
.InitFromStyle( pStyleSheet
);
758 nRetMask
= sal_uInt16(true);
765 } // switch ( nSlotId )
766 } // case SFX_STYLE_FAMILY_PAGE:
771 } // switch ( eFamily )
773 // Neu anlegen oder bearbeiten ueber Dialog:
774 if ( nSlotId
== SID_STYLE_NEW
|| nSlotId
== SID_STYLE_EDIT
)
778 SfxStyleFamily eFam
= pStyleSheet
->GetFamily();
779 boost::scoped_ptr
<SfxAbstractTabDialog
> pDlg
;
782 // alte Items aus der Vorlage merken
783 SfxItemSet aOldSet
= pStyleSheet
->GetItemSet();
784 OUString aOldName
= pStyleSheet
->GetName();
788 case SFX_STYLE_FAMILY_PAGE
:
789 nRsc
= RID_SCDLG_STYLES_PAGE
;
792 case SFX_STYLE_FAMILY_PARA
:
795 SfxItemSet
& rSet
= pStyleSheet
->GetItemSet();
797 const SfxPoolItem
* pItem
;
798 if ( rSet
.GetItemState( ATTR_VALUE_FORMAT
,
799 false, &pItem
) == SfxItemState::SET
)
801 // NumberFormat Value aus Value und Language
802 // erzeugen und eintueten
804 static_cast<const SfxUInt32Item
*>(pItem
)->GetValue();
806 static_cast<const SvxLanguageItem
*>(&rSet
.Get(
807 ATTR_LANGUAGE_FORMAT
))->GetLanguage();
808 sal_uLong nLangFormat
= rDoc
.GetFormatTable()->
809 GetFormatForLanguageIfBuiltIn( nFormat
, eLang
);
810 if ( nLangFormat
!= nFormat
)
812 SfxUInt32Item
aNewItem( ATTR_VALUE_FORMAT
, nLangFormat
);
813 rSet
.Put( aNewItem
);
814 aOldSet
.Put( aNewItem
);
815 // auch in aOldSet fuer Vergleich nach dem Dialog,
816 // sonst geht evtl. eine Aenderung der Sprache verloren
820 boost::scoped_ptr
<SvxNumberInfoItem
> pNumberInfoItem(
821 ScTabViewShell::MakeNumberInfoItem(&rDoc
, GetViewData()));
823 pDocSh
->PutItem( *pNumberInfoItem
);
824 nRsc
= RID_SCDLG_STYLES_PAR
;
826 // auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set:
827 // (wenn gar kein Item da ist, loescht der Dialog auch das
828 // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set)
830 if ( rSet
.GetItemState( ATTR_BORDER_INNER
, false ) != SfxItemState::SET
)
832 SvxBoxInfoItem
aBoxInfoItem( ATTR_BORDER_INNER
);
833 aBoxInfoItem
.SetTable(false); // keine inneren Linien
834 aBoxInfoItem
.SetDist(true);
835 aBoxInfoItem
.SetMinDist(false);
836 rSet
.Put( aBoxInfoItem
);
842 // If GetDefDialogParent is a dialog, it must be used
845 vcl::Window
* pParent
= Application::GetDefDialogParent();
846 if ( !pParent
|| !pParent
->IsDialog() )
848 // GetDefDialogParent currently doesn't return the window
849 // that was set with SetDefDialogParent (but dynamically finds the
850 // topmost parent of the focus window), so IsDialog above is FALSE
851 // even if called from the style catalog.
852 // -> Use NULL if a modal dialog is open, to enable the Dialog's
853 // default parent handling.
854 if ( Application::IsInModalMode() )
857 pParent
= pTabViewShell
->GetDialogParent();
860 pTabViewShell
->SetInFormatDialog(true);
862 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
863 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
865 pDlg
.reset(pFact
->CreateScStyleDlg( pParent
, *pStyleSheet
, nRsc
, nRsc
));
866 OSL_ENSURE(pDlg
, "Dialog create fail!");
867 short nResult
= pDlg
->Execute();
868 pTabViewShell
->SetInFormatDialog(false);
870 if ( nResult
== RET_OK
)
872 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
876 nRetMask
= pStyleSheet
->GetMask();
878 // Attribut-Vergleiche (frueher in ModifyStyleSheet)
879 // jetzt hier mit den alten Werten (Style ist schon veraendert)
881 if ( SFX_STYLE_FAMILY_PARA
== eFam
)
883 SfxItemSet
& rNewSet
= pStyleSheet
->GetItemSet();
884 bool bNumFormatChanged
;
885 if ( ScGlobal::CheckWidthInvalidate(
886 bNumFormatChanged
, rNewSet
, aOldSet
) )
887 rDoc
.InvalidateTextWidth( NULL
, NULL
, bNumFormatChanged
);
889 SCTAB nTabCount
= rDoc
.GetTableCount();
890 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
891 if (rDoc
.IsStreamValid(nTab
))
892 rDoc
.SetStreamValid(nTab
, false);
894 sal_uLong nOldFormat
= static_cast<const SfxUInt32Item
&>(aOldSet
.
895 Get( ATTR_VALUE_FORMAT
)).GetValue();
896 sal_uLong nNewFormat
= static_cast<const SfxUInt32Item
&>(rNewSet
.
897 Get( ATTR_VALUE_FORMAT
)).GetValue();
898 if ( nNewFormat
!= nOldFormat
)
900 SvNumberFormatter
* pFormatter
= rDoc
.GetFormatTable();
901 const SvNumberformat
* pOld
= pFormatter
->GetEntry( nOldFormat
);
902 const SvNumberformat
* pNew
= pFormatter
->GetEntry( nNewFormat
);
903 if ( pOld
&& pNew
&& pOld
->GetLanguage() != pNew
->GetLanguage() )
904 rNewSet
.Put( SvxLanguageItem(
905 pNew
->GetLanguage(), ATTR_LANGUAGE_FORMAT
) );
908 rDoc
.GetPool()->CellStyleCreated( pStyleSheet
->GetName(), &rDoc
);
912 //! auch fuer Seitenvorlagen die Abfragen hier
914 OUString aNewName
= pStyleSheet
->GetName();
915 if ( aNewName
!= aOldName
&&
916 rDoc
.RenamePageStyleInUse( aOldName
, aNewName
) )
918 rBindings
.Invalidate( SID_STATUS_PAGESTYLE
);
919 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
922 rDoc
.ModifyStyleSheet( *pStyleSheet
, *pOutSet
);
923 rBindings
.Invalidate( FID_RESET_PRINTZOOM
);
926 pDocSh
->SetDocumentModified();
928 if ( SFX_STYLE_FAMILY_PARA
== eFam
)
930 ScTabViewShell::UpdateNumberFormatter(
931 static_cast<const SvxNumberInfoItem
&>(
932 *(pDocSh
->GetItem(SID_ATTR_NUMBERFORMAT_INFO
)) ));
934 pTabViewShell
->UpdateStyleSheetInUse( pStyleSheet
);
935 pTabViewShell
->InvalidateAttribs();
938 aNewData
.InitFromStyle( pStyleSheet
);
944 if ( nSlotId
== SID_STYLE_NEW
)
945 pStylePool
->Remove( pStyleSheet
);
948 // falls zwischendurch etwas mit dem temporaer geaenderten
949 // ItemSet gepainted wurde:
950 pDocSh
->PostPaintGridAll();
956 rReq
.SetReturnValue( SfxUInt16Item( nSlotId
, nRetMask
) );
958 if ( bAddUndo
&& bUndo
)
959 pDocSh
->GetUndoManager()->AddUndoAction(
960 new ScUndoModifyStyle( pDocSh
, eFamily
, aOldData
, aNewData
) );
962 if ( bStyleToMarked
)
964 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
965 // so redo will find the modified style
966 pTabViewShell
->SetStyleSheetToMarked( static_cast<SfxStyleSheet
*>(pStyleSheet
) );
967 pTabViewShell
->InvalidateAttribs();
971 pDocSh
->GetUndoManager()->LeaveListAction();
975 OSL_FAIL( "Unknown slot (ScViewShell::ExecuteStyle)" );
979 void ScFormatShell::ExecuteNumFormat( SfxRequest
& rReq
)
981 ScModule
* pScMod
= SC_MOD();
982 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
983 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
984 sal_uInt16 nSlot
= rReq
.GetSlot();
985 SfxBindings
& rBindings
= pTabViewShell
->GetViewFrame()->GetBindings();
987 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
990 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
994 case SID_NUMBER_TWODEC
:
995 case SID_NUMBER_SCIENTIFIC
:
996 case SID_NUMBER_DATE
:
997 case SID_NUMBER_CURRENCY
:
998 case SID_NUMBER_PERCENT
:
999 case SID_NUMBER_STANDARD
:
1000 case SID_NUMBER_FORMAT
:
1001 case SID_NUMBER_INCDEC
:
1002 case SID_NUMBER_DECDEC
:
1003 case FID_DEFINE_NAME
:
1006 case FID_INSERT_NAME
:
1007 case SID_SPELL_DIALOG
:
1008 case SID_HANGUL_HANJA_CONVERSION
:
1010 pScMod
->InputEnterHandler();
1011 pTabViewShell
->UpdateInputHandler();
1019 short nType
= GetCurrentNumberFormatType();
1020 SfxItemSet
aSet( GetPool(), nSlot
, nSlot
);
1023 case SID_NUMBER_TWODEC
:
1024 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
, 4 ); // Standard+4 = #.##0,00
1027 case SID_NUMBER_SCIENTIFIC
:
1028 if ((nType
& css::util::NumberFormat::SCIENTIFIC
))
1029 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1031 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::SCIENTIFIC
);
1032 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& css::util::NumberFormat::SCIENTIFIC
)) );
1033 rBindings
.Invalidate( nSlot
);
1036 case SID_NUMBER_DATE
:
1037 if ((nType
& css::util::NumberFormat::DATE
))
1038 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1040 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::DATE
);
1041 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& css::util::NumberFormat::DATE
)) );
1042 rBindings
.Invalidate( nSlot
);
1045 case SID_NUMBER_TIME
:
1046 if ((nType
& css::util::NumberFormat::TIME
))
1047 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1049 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::TIME
);
1050 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& css::util::NumberFormat::TIME
)) );
1051 rBindings
.Invalidate( nSlot
);
1054 case SID_NUMBER_CURRENCY
:
1055 if ((nType
& css::util::NumberFormat::CURRENCY
))
1056 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1058 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::CURRENCY
);
1059 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& css::util::NumberFormat::CURRENCY
)) );
1060 rBindings
.Invalidate( nSlot
);
1063 case SID_NUMBER_PERCENT
:
1064 if ((nType
& css::util::NumberFormat::PERCENT
))
1065 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1067 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::PERCENT
);
1068 aSet
.Put( SfxBoolItem(nSlot
, !(nType
& css::util::NumberFormat::PERCENT
)) );
1069 rBindings
.Invalidate( nSlot
);
1072 case SID_NUMBER_STANDARD
:
1073 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
);
1076 case SID_NUMBER_INCDEC
:
1077 pTabViewShell
->ChangeNumFmtDecimals( true );
1080 case SID_NUMBER_DECDEC
:
1081 pTabViewShell
->ChangeNumFmtDecimals( false );
1085 case SID_NUMBER_FORMAT
:
1088 // const SfxPoolItem* pItem;
1089 // if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SfxItemState::SET)
1091 // String aCode = ((const SfxStringItem*)pItem)->GetValue();
1092 // pTabViewShell->SetNumFmtByStr( aCode );
1096 // symphony version with format interpretation
1099 const SfxPoolItem
* pItem
;
1100 ScDocument
* pDoc
= pViewData
->GetDocument();
1101 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
1102 LanguageType eLanguage
= ScGlobal::eLnge
;
1103 sal_Int16 eType
= -1;
1104 sal_uInt32 nCurrentNumberFormat
;
1106 pDoc
->GetNumberFormat(pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo(), nCurrentNumberFormat
);
1107 const SvNumberformat
* pEntry
= pFormatter
->GetEntry(nCurrentNumberFormat
);
1111 eLanguage
= pEntry
->GetLanguage();
1112 eType
= pEntry
->GetType();
1115 //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY/SCIENTIFIC
1116 //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
1119 case css::util::NumberFormat::ALL
:
1120 case css::util::NumberFormat::NUMBER
:
1121 case css::util::NumberFormat::NUMBER
| css::util::NumberFormat::DEFINED
:
1122 case css::util::NumberFormat::PERCENT
:
1123 case css::util::NumberFormat::PERCENT
| css::util::NumberFormat::DEFINED
:
1124 case css::util::NumberFormat::CURRENCY
:
1125 case css::util::NumberFormat::CURRENCY
|css::util::NumberFormat::DEFINED
:
1126 case css::util::NumberFormat::SCIENTIFIC
:
1127 case css::util::NumberFormat::SCIENTIFIC
|css::util::NumberFormat::DEFINED
:
1134 if(SfxItemState::SET
== pReqArgs
->GetItemState(nSlot
, true, &pItem
) && eType
!= -1)
1136 OUString aCode
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1137 sal_uInt16 aLen
= aCode
.getLength();
1138 OUString
* sFormat
= new OUString
[4];
1139 OUString sTmpStr
= "";
1140 sal_uInt16
nCount(0);
1141 sal_uInt16
nStrCount(0);
1143 while(nCount
< aLen
)
1145 sal_Unicode cChar
= aCode
[nCount
];
1149 sFormat
[nStrCount
] = sTmpStr
;
1155 sTmpStr
+= OUString(cChar
);
1164 const bool bThousand
= (bool)sFormat
[0].toInt32();
1165 const bool bNegRed
= (bool)sFormat
[1].toInt32();
1166 const sal_uInt16 nPrecision
= (sal_uInt16
)sFormat
[2].toInt32();
1167 const sal_uInt16 nLeadZeroes
= (sal_uInt16
)sFormat
[3].toInt32();
1169 aCode
= pFormatter
->GenerateFormat(
1170 nCurrentNumberFormat
,//modify
1176 pTabViewShell
->SetNumFmtByStr(aCode
);
1182 case SID_ATTR_NUMBERFORMAT_VALUE
:
1185 const SfxPoolItem
* pItem
;
1186 if ( pReqArgs
->GetItemState( ATTR_VALUE_FORMAT
, true, &pItem
) == SfxItemState::SET
)
1188 // We have to accomplish this using ApplyAttributes()
1189 // because we also need the language information to be
1191 const SfxItemSet
& rOldSet
=
1192 pTabViewShell
->GetSelectionPattern()->GetItemSet();
1193 SfxItemPool
* pDocPool
= GetViewData()->GetDocument()->GetPool();
1194 SfxItemSet
aNewSet( *pDocPool
, ATTR_PATTERN_START
, ATTR_PATTERN_END
);
1195 aNewSet
.Put( *pItem
);
1196 pTabViewShell
->ApplyAttributes( &aNewSet
, &rOldSet
, true );
1201 case SID_NUMBER_TYPE_FORMAT
:
1204 const SfxPoolItem
* pItem
;
1205 if ( pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SfxItemState::SET
)
1207 sal_uInt16 nFormat
= static_cast<const SfxInt16Item
*>(pItem
)->GetValue();
1211 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
); //Modify
1214 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::NUMBER
, 2 ); //Modify
1217 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::PERCENT
);
1220 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::CURRENCY
);
1223 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::DATE
);
1226 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::TIME
);
1229 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::SCIENTIFIC
);
1232 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::FRACTION
);
1235 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::LOGICAL
);
1238 pTabViewShell
->SetNumberFormat( css::util::NumberFormat::TEXT
);
1249 OSL_FAIL("falscher Slot bei ExecuteEdit");
1254 void ScFormatShell::ExecuteAlignment( SfxRequest
& rReq
)
1256 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1257 SfxBindings
& rBindings
= pViewData
->GetBindings();
1258 const SfxItemSet
* pSet
= rReq
.GetArgs();
1259 sal_uInt16 nSlot
= rReq
.GetSlot();
1261 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1265 // pseudo slots for Format menu
1266 case SID_ALIGN_ANY_HDEFAULT
:
1267 case SID_ALIGN_ANY_LEFT
:
1268 case SID_ALIGN_ANY_HCENTER
:
1269 case SID_ALIGN_ANY_RIGHT
:
1270 case SID_ALIGN_ANY_JUSTIFIED
:
1271 pTabViewShell
->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot
), ATTR_HOR_JUSTIFY
) );
1273 case SID_ALIGN_ANY_VDEFAULT
:
1274 case SID_ALIGN_ANY_TOP
:
1275 case SID_ALIGN_ANY_VCENTER
:
1276 case SID_ALIGN_ANY_BOTTOM
:
1277 pTabViewShell
->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot
), ATTR_VER_JUSTIFY
) );
1283 const SfxPoolItem
* pItem
= NULL
;
1284 if( pSet
->GetItemState(GetPool().GetWhich(nSlot
), true, &pItem
) == SfxItemState::SET
)
1289 case SID_ATTR_ALIGN_HOR_JUSTIFY
:
1290 case SID_ATTR_ALIGN_VER_JUSTIFY
:
1291 case SID_ATTR_ALIGN_INDENT
:
1292 case SID_ATTR_ALIGN_HYPHENATION
:
1293 case SID_ATTR_ALIGN_DEGREES
:
1294 case SID_ATTR_ALIGN_LOCKPOS
:
1295 case SID_ATTR_ALIGN_MARGIN
:
1296 case SID_ATTR_ALIGN_STACKED
:
1297 pTabViewShell
->ApplyAttr( *pItem
);
1300 case SID_H_ALIGNCELL
:
1302 SvxCellHorJustify eJust
= (SvxCellHorJustify
)static_cast<const SvxHorJustifyItem
*>(pItem
)->GetValue();
1303 // #i78476# update alignment of text in cell edit mode
1304 pTabViewShell
->UpdateInputHandlerCellAdjust( eJust
);
1305 pTabViewShell
->ApplyAttr( SvxHorJustifyItem( eJust
, ATTR_HOR_JUSTIFY
) );
1308 case SID_V_ALIGNCELL
:
1309 pTabViewShell
->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify
)static_cast<const SvxVerJustifyItem
*>(pItem
)->GetValue(), ATTR_VER_JUSTIFY
) );
1312 OSL_FAIL( "ExecuteAlignment: invalid slot" );
1318 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_LEFT
);
1319 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT
);
1320 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK
);
1321 rBindings
.Invalidate( SID_ATTR_PARA_ADJUST_CENTER
);
1322 rBindings
.Invalidate( SID_ALIGNLEFT
);
1323 rBindings
.Invalidate( SID_ALIGNRIGHT
);
1324 rBindings
.Invalidate( SID_ALIGNCENTERHOR
);
1325 rBindings
.Invalidate( SID_ALIGNBLOCK
);
1326 rBindings
.Invalidate( SID_ALIGNTOP
);
1327 rBindings
.Invalidate( SID_ALIGNBOTTOM
);
1328 rBindings
.Invalidate( SID_ALIGNCENTERVER
);
1329 rBindings
.Invalidate( SID_V_ALIGNCELL
);
1330 rBindings
.Invalidate( SID_H_ALIGNCELL
);
1331 // pseudo slots for Format menu
1332 rBindings
.Invalidate( SID_ALIGN_ANY_HDEFAULT
);
1333 rBindings
.Invalidate( SID_ALIGN_ANY_LEFT
);
1334 rBindings
.Invalidate( SID_ALIGN_ANY_HCENTER
);
1335 rBindings
.Invalidate( SID_ALIGN_ANY_RIGHT
);
1336 rBindings
.Invalidate( SID_ALIGN_ANY_JUSTIFIED
);
1337 rBindings
.Invalidate( SID_ALIGN_ANY_VDEFAULT
);
1338 rBindings
.Invalidate( SID_ALIGN_ANY_TOP
);
1339 rBindings
.Invalidate( SID_ALIGN_ANY_VCENTER
);
1340 rBindings
.Invalidate( SID_ALIGN_ANY_BOTTOM
);
1343 if( ! rReq
.IsAPI() )
1347 void ScFormatShell::ExecuteTextAttr( SfxRequest
& rReq
)
1349 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1350 SfxBindings
& rBindings
= pViewData
->GetBindings();
1351 const ScPatternAttr
* pAttrs
= pTabViewShell
->GetSelectionPattern();
1352 const SfxItemSet
* pSet
= rReq
.GetArgs();
1353 sal_uInt16 nSlot
= rReq
.GetSlot();
1354 SfxAllItemSet
* pNewSet
= 0;
1356 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1358 if ( (nSlot
== SID_ATTR_CHAR_WEIGHT
)
1359 ||(nSlot
== SID_ATTR_CHAR_POSTURE
)
1360 ||(nSlot
== SID_ATTR_CHAR_UNDERLINE
)
1361 ||(nSlot
== SID_ULINE_VAL_NONE
)
1362 ||(nSlot
== SID_ULINE_VAL_SINGLE
)
1363 ||(nSlot
== SID_ULINE_VAL_DOUBLE
)
1364 ||(nSlot
== SID_ULINE_VAL_DOTTED
) )
1366 pNewSet
= new SfxAllItemSet( GetPool() );
1370 case SID_ATTR_CHAR_WEIGHT
:
1372 // #i78017 establish the same behaviour as in Writer
1373 SvtScriptType nScript
= SvtScriptType::LATIN
| SvtScriptType::ASIAN
| SvtScriptType::COMPLEX
;
1375 SfxItemPool
& rPool
= GetPool();
1376 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1378 aSetItem
.PutItemForScriptType( nScript
, pSet
->Get( ATTR_FONT_WEIGHT
) );
1383 FontWeight eWeight
= WEIGHT_BOLD
;
1384 SvxScriptSetItem
aOldSetItem( nSlot
, rPool
);
1385 aOldSetItem
.GetItemSet().Put( pAttrs
->GetItemSet(), false );
1386 const SfxPoolItem
* pCore
= aOldSetItem
.GetItemOfScript( nScript
);
1387 if ( pCore
&& static_cast<const SvxWeightItem
*>(pCore
)->GetWeight() == WEIGHT_BOLD
)
1388 eWeight
= WEIGHT_NORMAL
;
1390 aSetItem
.PutItemForScriptType( nScript
, SvxWeightItem( eWeight
, ATTR_FONT_WEIGHT
) );
1392 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1393 pNewSet
->Put( aSetItem
.GetItemSet(), false );
1397 case SID_ATTR_CHAR_POSTURE
:
1399 // #i78017 establish the same behaviour as in Writer
1400 SvtScriptType nScript
= SvtScriptType::LATIN
| SvtScriptType::ASIAN
| SvtScriptType::COMPLEX
;
1402 SfxItemPool
& rPool
= GetPool();
1403 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1405 aSetItem
.PutItemForScriptType( nScript
, pSet
->Get( ATTR_FONT_POSTURE
) );
1410 FontItalic eItalic
= ITALIC_NORMAL
;
1411 SvxScriptSetItem
aOldSetItem( nSlot
, rPool
);
1412 aOldSetItem
.GetItemSet().Put( pAttrs
->GetItemSet(), false );
1413 const SfxPoolItem
* pCore
= aOldSetItem
.GetItemOfScript( nScript
);
1414 if ( pCore
&& static_cast<const SvxPostureItem
*>(pCore
)->GetPosture() == ITALIC_NORMAL
)
1415 eItalic
= ITALIC_NONE
;
1417 aSetItem
.PutItemForScriptType( nScript
, SvxPostureItem( eItalic
, ATTR_FONT_POSTURE
) );
1419 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1420 pNewSet
->Put( aSetItem
.GetItemSet(), false );
1424 case SID_ATTR_CHAR_UNDERLINE
:
1426 FontUnderline eUnderline
;
1430 const SfxPoolItem
& rUnderline
= pSet
->Get( ATTR_FONT_UNDERLINE
);
1432 if( rUnderline
.ISA(SvxUnderlineItem
) )
1434 pTabViewShell
->ApplyAttr( rUnderline
);
1435 pNewSet
->Put( rUnderline
,rUnderline
.Which() );
1437 else if ( rUnderline
.ISA(SvxTextLineItem
) )
1439 // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1440 const SvxTextLineItem
& rTextLineItem
= static_cast<const SvxTextLineItem
&>(rUnderline
);
1441 SvxUnderlineItem
aNewItem( rTextLineItem
.GetLineStyle(), rTextLineItem
.Which() );
1442 aNewItem
.SetColor( rTextLineItem
.GetColor() );
1443 pTabViewShell
->ApplyAttr( aNewItem
);
1444 pNewSet
->Put( aNewItem
, aNewItem
.Which() );
1449 SvxUnderlineItem
aUnderline( static_cast<const SvxUnderlineItem
&>(
1451 ATTR_FONT_UNDERLINE
) ) );
1452 eUnderline
= (UNDERLINE_NONE
!= aUnderline
.GetLineStyle())
1455 aUnderline
.SetLineStyle( eUnderline
);
1456 pTabViewShell
->ApplyAttr( aUnderline
);
1457 pNewSet
->Put( aUnderline
,aUnderline
.Which() );
1462 case SID_ULINE_VAL_NONE
:
1463 pTabViewShell
->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE
, ATTR_FONT_UNDERLINE
) );
1465 case SID_ULINE_VAL_SINGLE
: // Toggles
1466 case SID_ULINE_VAL_DOUBLE
:
1467 case SID_ULINE_VAL_DOTTED
:
1469 FontUnderline eOld
= static_cast<const SvxUnderlineItem
&>(
1470 pAttrs
->GetItem(ATTR_FONT_UNDERLINE
)).GetLineStyle();
1471 FontUnderline eNew
= eOld
;
1474 case SID_ULINE_VAL_SINGLE
:
1475 eNew
= ( eOld
== UNDERLINE_SINGLE
) ? UNDERLINE_NONE
: UNDERLINE_SINGLE
;
1477 case SID_ULINE_VAL_DOUBLE
:
1478 eNew
= ( eOld
== UNDERLINE_DOUBLE
) ? UNDERLINE_NONE
: UNDERLINE_DOUBLE
;
1480 case SID_ULINE_VAL_DOTTED
:
1481 eNew
= ( eOld
== UNDERLINE_DOTTED
) ? UNDERLINE_NONE
: UNDERLINE_DOTTED
;
1484 pTabViewShell
->ApplyAttr( SvxUnderlineItem( eNew
, ATTR_FONT_UNDERLINE
) );
1491 rBindings
.Invalidate( nSlot
);
1496 * "Selbstgemachte" RadioButton-Funktionalitaet
1497 * Beim Toggle gibt es den Standard-State, d.h. kein
1498 * Button ist gedrueckt
1501 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
1502 const SfxPoolItem
* pItem
= NULL
;
1503 const SvxHorJustifyItem
* pHorJustify
= NULL
;
1504 const SvxVerJustifyItem
* pVerJustify
= NULL
;
1505 SvxCellHorJustify eHorJustify
= SVX_HOR_JUSTIFY_STANDARD
;
1506 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
1508 if (rAttrSet
.GetItemState(ATTR_HOR_JUSTIFY
, true,&pItem
) == SfxItemState::SET
)
1510 pHorJustify
= static_cast<const SvxHorJustifyItem
*>(pItem
);
1511 eHorJustify
= SvxCellHorJustify( pHorJustify
->GetValue() );
1513 if (rAttrSet
.GetItemState(ATTR_VER_JUSTIFY
, true,&pItem
) == SfxItemState::SET
)
1515 pVerJustify
= static_cast<const SvxVerJustifyItem
*>(pItem
);
1516 eVerJustify
= SvxCellVerJustify( pVerJustify
->GetValue() );
1522 rReq
.SetSlot( SID_H_ALIGNCELL
);
1523 rReq
.AppendItem( SvxHorJustifyItem(
1524 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_LEFT
) ?
1525 SVX_HOR_JUSTIFY_LEFT
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1526 ExecuteSlot( rReq
, GetInterface() );
1529 case SID_ALIGNRIGHT
:
1530 rReq
.SetSlot( SID_H_ALIGNCELL
);
1531 rReq
.AppendItem( SvxHorJustifyItem(
1532 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_RIGHT
) ?
1533 SVX_HOR_JUSTIFY_RIGHT
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1534 ExecuteSlot( rReq
, GetInterface() );
1537 case SID_ALIGNCENTERHOR
:
1538 rReq
.SetSlot( SID_H_ALIGNCELL
);
1539 rReq
.AppendItem( SvxHorJustifyItem(
1540 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_CENTER
) ?
1541 SVX_HOR_JUSTIFY_CENTER
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1542 ExecuteSlot( rReq
, GetInterface() );
1545 case SID_ALIGNBLOCK
:
1546 rReq
.SetSlot( SID_H_ALIGNCELL
);
1547 rReq
.AppendItem( SvxHorJustifyItem(
1548 !pHorJustify
|| (eHorJustify
!= SVX_HOR_JUSTIFY_BLOCK
) ?
1549 SVX_HOR_JUSTIFY_BLOCK
: SVX_HOR_JUSTIFY_STANDARD
, SID_H_ALIGNCELL
) );
1550 ExecuteSlot( rReq
, GetInterface() );
1554 rReq
.SetSlot( SID_V_ALIGNCELL
);
1555 rReq
.AppendItem( SvxVerJustifyItem(
1556 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_TOP
) ?
1557 SVX_VER_JUSTIFY_TOP
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1558 ExecuteSlot( rReq
, GetInterface() );
1561 case SID_ALIGNBOTTOM
:
1562 rReq
.SetSlot( SID_V_ALIGNCELL
);
1563 rReq
.AppendItem( SvxVerJustifyItem(
1564 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_BOTTOM
) ?
1565 SVX_VER_JUSTIFY_BOTTOM
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1566 ExecuteSlot( rReq
, GetInterface() );
1569 case SID_ALIGNCENTERVER
:
1570 rReq
.SetSlot( SID_V_ALIGNCELL
);
1571 rReq
.AppendItem( SvxVerJustifyItem(
1572 !pVerJustify
|| (eVerJustify
!= SVX_VER_JUSTIFY_CENTER
) ?
1573 SVX_VER_JUSTIFY_CENTER
: SVX_VER_JUSTIFY_STANDARD
, SID_V_ALIGNCELL
) );
1574 ExecuteSlot( rReq
, GetInterface() );
1587 rReq
.Done( *pNewSet
);
1597 void ScFormatShell::ExecuteAttr( SfxRequest
& rReq
)
1599 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1600 SfxBindings
& rBindings
= pViewData
->GetBindings();
1601 const SfxItemSet
* pNewAttrs
= rReq
.GetArgs();
1602 sal_uInt16 nSlot
= rReq
.GetSlot();
1604 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
1605 ScDocument
* pDoc
= GetViewData()->GetDocument();
1610 case SID_ATTR_CHAR_ENDPREVIEW_FONT
:
1612 pDoc
->SetPreviewFont(NULL
);
1613 pTabViewShell
->UpdateSelectionArea( pDoc
->GetPreviewSelection() );
1616 case SID_ATTR_CHAR_COLOR
:
1617 case SID_ATTR_CHAR_FONT
:
1618 case SID_ATTR_CHAR_FONTHEIGHT
:
1619 pTabViewShell
->ExecuteCellFormatDlg(rReq
, "font"); // wenn ToolBar vertikal
1622 case SID_BACKGROUND_COLOR
:
1624 SvxBrushItem
aBrushItem( static_cast<const SvxBrushItem
&>(
1625 pTabViewShell
->GetSelectionPattern()->GetItem( ATTR_BACKGROUND
) ) );
1626 aBrushItem
.SetColor( COL_TRANSPARENT
);
1627 pTabViewShell
->ApplyAttr( aBrushItem
);
1631 case SID_ATTR_ALIGN_LINEBREAK
: // ohne Parameter als Toggle
1633 const ScPatternAttr
* pAttrs
= pTabViewShell
->GetSelectionPattern();
1634 bool bOld
= static_cast<const SfxBoolItem
&>(pAttrs
->GetItem(ATTR_LINEBREAK
)).GetValue();
1635 SfxBoolItem
aBreakItem( ATTR_LINEBREAK
, !bOld
);
1636 pTabViewShell
->ApplyAttr( aBreakItem
);
1638 SfxAllItemSet
aNewSet( GetPool() );
1639 aNewSet
.Put( aBreakItem
,aBreakItem
.Which() );
1640 rReq
.Done( aNewSet
);
1642 rBindings
.Invalidate( nSlot
);
1651 case SID_ATTR_CHAR_PREVIEW_FONT
:
1653 SfxItemPool
& rPool
= GetPool();
1654 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
1655 const SvxFontItem
& rFont
= static_cast<const SvxFontItem
&>(pNewAttrs
->Get( nWhich
));
1656 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, rPool
);
1657 SvtScriptType nScript
= pTabViewShell
->GetSelectionScriptType();
1658 aSetItem
.PutItemForScriptType( nScript
, rFont
);
1660 ScMarkData
aFuncMark( pViewData
->GetMarkData() );
1661 ScViewUtil::UnmarkFiltered( aFuncMark
, pDoc
);
1662 pDoc
->SetPreviewFont( aSetItem
.GetItemSet().Clone() );
1663 aFuncMark
.MarkToMulti();
1665 if ( !aFuncMark
.IsMarked() && !aFuncMark
.IsMultiMarked() )
1667 SCCOL nCol
= pViewData
->GetCurX();
1668 SCROW nRow
= pViewData
->GetCurY();
1669 SCTAB nTab
= pViewData
->GetTabNo();
1670 ScRange
aRange( nCol
, nRow
, nTab
);
1671 aFuncMark
.SetMarkArea( aRange
);
1673 pDoc
->SetPreviewSelection( aFuncMark
);
1674 pTabViewShell
->UpdateSelectionArea( aFuncMark
);
1677 case SID_ATTR_CHAR_OVERLINE
:
1678 case SID_ATTR_CHAR_STRIKEOUT
:
1679 case SID_ATTR_ALIGN_LINEBREAK
:
1680 case SID_ATTR_CHAR_COLOR
:
1681 case SID_ATTR_CHAR_CONTOUR
:
1682 case SID_ATTR_CHAR_SHADOWED
:
1683 case SID_ATTR_CHAR_RELIEF
:
1684 case SID_SCATTR_PROTECTION
:
1685 pTabViewShell
->ApplyAttr( pNewAttrs
->Get( pNewAttrs
->GetPool()->GetWhich( nSlot
) ) );
1686 rBindings
.Invalidate( nSlot
);
1687 rBindings
.Update( nSlot
);
1690 case SID_ATTR_CHAR_FONT
:
1691 case SID_ATTR_CHAR_FONTHEIGHT
:
1693 // #i78017 establish the same behaviour as in Writer
1694 SvtScriptType nScript
= SvtScriptType::LATIN
| SvtScriptType::ASIAN
| SvtScriptType::COMPLEX
;
1695 if (nSlot
== SID_ATTR_CHAR_FONT
)
1696 nScript
= pTabViewShell
->GetSelectionScriptType();
1698 SfxItemPool
& rPool
= GetPool();
1699 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
1700 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
1701 aSetItem
.PutItemForScriptType( nScript
, pNewAttrs
->Get( nWhich
) );
1703 pTabViewShell
->ApplyUserItemSet( aSetItem
.GetItemSet() );
1705 rBindings
.Invalidate( nSlot
);
1706 rBindings
.Update( nSlot
);
1710 case SID_FRAME_LINESTYLE
:
1712 // Default-Linie aktualisieren
1713 const ::editeng::SvxBorderLine
* pLine
=
1714 static_cast<const SvxLineItem
&>(
1715 pNewAttrs
->Get( SID_FRAME_LINESTYLE
)).
1720 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1724 pDefLine
->SetBorderLineStyle(
1725 pLine
->GetBorderLineStyle());
1726 pDefLine
->SetWidth( pLine
->GetWidth( ) );
1727 pTabViewShell
->SetSelectionFrameLines( pDefLine
, false );
1731 pTabViewShell
->SetDefaultFrameLine( pLine
);
1732 pTabViewShell
->GetDefaultFrameLine()->SetColor( COL_BLACK
);
1733 pTabViewShell
->SetSelectionFrameLines( pLine
, false );
1738 Color
aColorBlack( COL_BLACK
);
1739 ::editeng::SvxBorderLine
aDefLine( &aColorBlack
, 20,
1740 table::BorderLineStyle::SOLID
);
1741 pTabViewShell
->SetDefaultFrameLine( &aDefLine
);
1742 pTabViewShell
->SetSelectionFrameLines( NULL
, false );
1747 case SID_FRAME_LINECOLOR
:
1749 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1750 const Color
& rColor
= static_cast<const SvxColorItem
&>(
1751 pNewAttrs
->Get( SID_FRAME_LINECOLOR
)).
1754 // Default-Linie aktualisieren
1757 pDefLine
->SetColor( rColor
);
1758 pTabViewShell
->SetSelectionFrameLines( pDefLine
, true );
1762 ::editeng::SvxBorderLine
aDefLine( &rColor
, 20,
1763 table::BorderLineStyle::SOLID
);
1764 pTabViewShell
->SetDefaultFrameLine( &aDefLine
);
1765 pTabViewShell
->SetSelectionFrameLines( &aDefLine
, false );
1770 case SID_ATTR_BORDER_OUTER
:
1771 case SID_ATTR_BORDER
:
1773 ::editeng::SvxBorderLine
* pDefLine
= pTabViewShell
->GetDefaultFrameLine();
1774 const ScPatternAttr
* pOldAttrs
= pTabViewShell
->GetSelectionPattern();
1775 boost::scoped_ptr
<SfxItemSet
> pOldSet(
1779 ATTR_PATTERN_END
));
1780 boost::scoped_ptr
<SfxItemSet
> pNewSet(
1784 ATTR_PATTERN_END
));
1785 const SfxPoolItem
& rBorderAttr
=
1786 pOldAttrs
->GetItemSet().
1789 // Border-Items vom Controller auswerten:
1790 const SfxPoolItem
* pItem
= 0;
1792 if ( pNewAttrs
->GetItemState( ATTR_BORDER
, true, &pItem
)
1793 == SfxItemState::SET
)
1795 // The SvxFrameToolBoxControl toolbox controller uses a default
1796 // SvxBorderLine (all widths 0) to mark the lines that should be set.
1797 // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1798 // or NULL pointers for no lines.
1799 // -> Substitute existing lines with pDefLine only if widths are 0.
1800 SvxBoxItem
aBoxItem ( *static_cast<const SvxBoxItem
*>(pItem
));
1801 if ( aBoxItem
.GetTop() && aBoxItem
.GetTop()->GetOutWidth() == 0 )
1802 aBoxItem
.SetLine( pDefLine
, SvxBoxItemLine::TOP
);
1803 if ( aBoxItem
.GetBottom() && aBoxItem
.GetBottom()->GetOutWidth() == 0 )
1804 aBoxItem
.SetLine( pDefLine
, SvxBoxItemLine::BOTTOM
);
1805 if ( aBoxItem
.GetLeft() && aBoxItem
.GetLeft()->GetOutWidth() == 0 )
1806 aBoxItem
.SetLine( pDefLine
, SvxBoxItemLine::LEFT
);
1807 if ( aBoxItem
.GetRight() && aBoxItem
.GetRight()->GetOutWidth() == 0 )
1808 aBoxItem
.SetLine( pDefLine
, SvxBoxItemLine::RIGHT
);
1809 pNewSet
->Put( aBoxItem
);
1810 rReq
.AppendItem( aBoxItem
);
1813 if ( pNewAttrs
->GetItemState( ATTR_BORDER_INNER
, true, &pItem
)
1814 == SfxItemState::SET
)
1816 SvxBoxInfoItem
aBoxInfoItem( *static_cast<const SvxBoxInfoItem
*>(pItem
) );
1817 if ( aBoxInfoItem
.GetHori() && aBoxInfoItem
.GetHori()->GetOutWidth() == 0 )
1818 aBoxInfoItem
.SetLine( pDefLine
, SvxBoxInfoItemLine::HORI
);
1819 if ( aBoxInfoItem
.GetVert() && aBoxInfoItem
.GetVert()->GetOutWidth() == 0 )
1820 aBoxInfoItem
.SetLine( pDefLine
, SvxBoxInfoItemLine::VERT
);
1821 pNewSet
->Put( aBoxInfoItem
);
1822 rReq
.AppendItem( aBoxInfoItem
);
1826 SvxBoxInfoItem
aBoxInfoItem( ATTR_BORDER_INNER
);
1827 aBoxInfoItem
.SetLine( NULL
, SvxBoxInfoItemLine::HORI
);
1828 aBoxInfoItem
.SetLine( NULL
, SvxBoxInfoItemLine::VERT
);
1829 pNewSet
->Put( aBoxInfoItem
);
1832 pOldSet
->Put( rBorderAttr
);
1833 pTabViewShell
->ApplyAttributes( pNewSet
.get(), pOldSet
.get() );
1837 case SID_ATTR_BORDER_DIAG_TLBR
:
1838 case SID_ATTR_BORDER_DIAG_BLTR
:
1840 const ScPatternAttr
* pOldAttrs
= pTabViewShell
->GetSelectionPattern();
1841 boost::scoped_ptr
<SfxItemSet
> pOldSet(new SfxItemSet(pOldAttrs
->GetItemSet()));
1842 boost::scoped_ptr
<SfxItemSet
> pNewSet(new SfxItemSet(pOldAttrs
->GetItemSet()));
1843 const SfxPoolItem
* pItem
= 0;
1845 if(SID_ATTR_BORDER_DIAG_TLBR
== nSlot
)
1847 if(SfxItemState::SET
== pNewAttrs
->GetItemState(ATTR_BORDER_TLBR
, true, &pItem
))
1849 SvxLineItem
aItem(ATTR_BORDER_TLBR
);
1850 aItem
.SetLine(static_cast<const SvxLineItem
&>(pNewAttrs
->Get(ATTR_BORDER_TLBR
)).GetLine());
1851 pNewSet
->Put(aItem
);
1852 rReq
.AppendItem(aItem
);
1853 pTabViewShell
->ApplyAttributes(pNewSet
.get(), pOldSet
.get());
1856 else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1858 if(SfxItemState::SET
== pNewAttrs
->GetItemState(ATTR_BORDER_BLTR
, true, &pItem
))
1860 SvxLineItem
aItem(ATTR_BORDER_BLTR
);
1861 aItem
.SetLine(static_cast<const SvxLineItem
&>(pNewAttrs
->Get(ATTR_BORDER_BLTR
)).GetLine());
1862 pNewSet
->Put(aItem
);
1863 rReq
.AppendItem(aItem
);
1864 pTabViewShell
->ApplyAttributes(pNewSet
.get(), pOldSet
.get());
1868 rBindings
.Invalidate(nSlot
);
1872 // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1874 case SID_BACKGROUND_COLOR
:
1876 const SvxColorItem rNewColorItem
= static_cast<const SvxColorItem
&>(
1877 pNewAttrs
->Get( SID_BACKGROUND_COLOR
) );
1879 SvxBrushItem
aBrushItem( static_cast<const SvxBrushItem
&>(
1880 pTabViewShell
->GetSelectionPattern()->
1881 GetItem( ATTR_BACKGROUND
) ) );
1883 aBrushItem
.SetColor( rNewColorItem
.GetValue() );
1885 pTabViewShell
->ApplyAttr( aBrushItem
);
1889 case SID_ATTR_BRUSH
:
1891 SvxBrushItem
aBrushItem( static_cast<const SvxBrushItem
&>(
1892 pTabViewShell
->GetSelectionPattern()->
1893 GetItem( ATTR_BACKGROUND
) ) );
1894 const SvxBrushItem
& rNewBrushItem
= static_cast<const SvxBrushItem
&>(
1895 pNewAttrs
->Get( GetPool().GetWhich(nSlot
) ) );
1896 aBrushItem
.SetColor(rNewBrushItem
.GetColor());
1897 pTabViewShell
->ApplyAttr( aBrushItem
);
1901 case SID_ATTR_BORDER_SHADOW
:
1903 const SvxShadowItem
& rNewShadowItem
= static_cast<const SvxShadowItem
&>(
1904 pNewAttrs
->Get( ATTR_SHADOW
) );
1905 pTabViewShell
->ApplyAttr( rNewShadowItem
);
1913 if( ! rReq
.IsAPI() )
1914 if( ! rReq
.IsDone() )
1919 void ScFormatShell::GetAttrState( SfxItemSet
& rSet
)
1921 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
1922 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
1923 //const ::editeng::SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine();
1924 const SvxBrushItem
& rBrushItem
= static_cast<const SvxBrushItem
&>(rAttrSet
.Get( ATTR_BACKGROUND
));
1925 SfxWhichIter
aIter( rSet
);
1926 sal_uInt16 nWhich
= aIter
.FirstWhich();
1928 rSet
.Put( rAttrSet
, false );
1930 // choose font info according to selection script type
1931 SvtScriptType nScript
= SvtScriptType::NONE
; // GetSelectionScriptType never returns 0
1932 if ( rSet
.GetItemState( ATTR_FONT
) != SfxItemState::UNKNOWN
)
1934 if (nScript
== SvtScriptType::NONE
) nScript
= pTabViewShell
->GetSelectionScriptType();
1935 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT
, nScript
);
1937 if ( rSet
.GetItemState( ATTR_FONT_HEIGHT
) != SfxItemState::UNKNOWN
)
1939 if (nScript
== SvtScriptType::NONE
) nScript
= pTabViewShell
->GetSelectionScriptType();
1940 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_HEIGHT
, nScript
);
1947 case SID_BACKGROUND_COLOR
:
1949 rSet
.Put( SvxColorItem( rBrushItem
.GetColor(), SID_BACKGROUND_COLOR
) );
1951 if(SfxItemState::DONTCARE
== rAttrSet
.GetItemState(ATTR_BACKGROUND
))
1953 rSet
.InvalidateItem(SID_BACKGROUND_COLOR
);
1957 case SID_FRAME_LINESTYLE
:
1958 case SID_FRAME_LINECOLOR
:
1960 // handled together because both need the cell border information for decisions
1961 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1963 editeng::SvxBorderLine
aLine(0,0,0,false);
1965 bool bColDisable
= false, bStyleDisable
= false;
1966 SvxBoxItem
aBoxItem(ATTR_BORDER
);
1967 SvxBoxInfoItem
aInfoItem(ATTR_BORDER_INNER
);
1969 pTabViewShell
->GetSelectionFrame(aBoxItem
, aInfoItem
);
1971 if( aBoxItem
.GetTop() )
1974 aCol
= aBoxItem
.GetTop()->GetColor() ;
1975 aLine
.SetColor(aCol
);
1976 aLine
.SetWidth( aBoxItem
.GetTop()->GetWidth());
1977 aLine
.SetBorderLineStyle( aBoxItem
.GetTop()->GetBorderLineStyle());
1980 if( aBoxItem
.GetBottom() )
1985 aCol
= aBoxItem
.GetBottom()->GetColor() ;
1986 aLine
.SetColor(aCol
);
1987 aLine
.SetWidth( aBoxItem
.GetBottom()->GetWidth());
1988 aLine
.SetBorderLineStyle( aBoxItem
.GetBottom()->GetBorderLineStyle());
1992 if(aCol
!= aBoxItem
.GetBottom()->GetColor() )
1994 if(!( aLine
== *(aBoxItem
.GetBottom())) )
1995 bStyleDisable
= true;
1999 if( aBoxItem
.GetLeft() )
2004 aCol
= aBoxItem
.GetLeft()->GetColor() ;
2005 aLine
.SetColor(aCol
);
2006 aLine
.SetWidth( aBoxItem
.GetLeft()->GetWidth());
2007 aLine
.SetBorderLineStyle( aBoxItem
.GetLeft()->GetBorderLineStyle());
2011 if(aCol
!= aBoxItem
.GetLeft()->GetColor() )
2013 if(!( aLine
== *(aBoxItem
.GetLeft())) )
2014 bStyleDisable
= true;
2018 if( aBoxItem
.GetRight() )
2023 aCol
= aBoxItem
.GetRight()->GetColor() ;
2024 aLine
.SetColor(aCol
);
2025 aLine
.SetWidth( aBoxItem
.GetRight()->GetWidth());
2026 aLine
.SetBorderLineStyle( aBoxItem
.GetRight()->GetBorderLineStyle());
2030 if(aCol
!= aBoxItem
.GetRight()->GetColor() )
2032 if(!( aLine
== *(aBoxItem
.GetRight())) )
2033 bStyleDisable
= true;
2037 if( aInfoItem
.GetVert())
2042 aCol
= aInfoItem
.GetVert()->GetColor() ;
2043 aLine
.SetColor(aCol
);
2044 aLine
.SetWidth( aInfoItem
.GetVert()->GetWidth());
2045 aLine
.SetBorderLineStyle( aInfoItem
.GetVert()->GetBorderLineStyle());
2049 if(aCol
!= aInfoItem
.GetVert()->GetColor() )
2051 if(!( aLine
== *(aInfoItem
.GetVert())) )
2052 bStyleDisable
= true;
2056 if( aInfoItem
.GetHori())
2061 aCol
= aInfoItem
.GetHori()->GetColor() ;
2062 aLine
.SetColor(aCol
);
2063 aLine
.SetWidth( aInfoItem
.GetHori()->GetWidth());
2064 aLine
.SetBorderLineStyle( aInfoItem
.GetHori()->GetBorderLineStyle());
2068 if(aCol
!= aInfoItem
.GetHori()->GetColor() )
2070 if(!( aLine
== *(aInfoItem
.GetHori())) )
2071 bStyleDisable
= true;
2075 if( !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::VERT
)
2076 || !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::HORI
)
2077 || !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::LEFT
)
2078 || !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::RIGHT
)
2079 || !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::TOP
)
2080 || !aInfoItem
.IsValid( SvxBoxInfoItemValidFlags::BOTTOM
) )
2083 bStyleDisable
= true;
2086 if(SID_FRAME_LINECOLOR
== nWhich
)
2088 if(bColDisable
) // if different lines have differernt colors
2090 aCol
= COL_TRANSPARENT
;
2091 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2092 rSet
.InvalidateItem(SID_FRAME_LINECOLOR
);
2094 else if( !bCol
&& !bColDisable
) // if no line available
2097 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2100 rSet
.Put( SvxColorItem(aCol
, SID_FRAME_LINECOLOR
) );
2102 else // if( nWhich == SID_FRAME_LINESTYLE)
2104 if(bStyleDisable
) // if have several lines but don't have same style
2106 aLine
.SetWidth( 1 );
2107 SvxLineItem
aItem(SID_FRAME_LINESTYLE
);
2108 aItem
.SetLine(&aLine
);
2110 rSet
.InvalidateItem(SID_FRAME_LINESTYLE
);
2112 else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2114 SvxLineItem
aItem(SID_FRAME_LINESTYLE
);
2115 aItem
.SetLine(&aLine
);
2121 case SID_ATTR_BRUSH
:
2123 rSet
.Put( rBrushItem
, GetPool().GetWhich(nWhich
) );
2127 nWhich
= aIter
.NextWhich();
2130 // stuff for sidebar panels
2131 Invalidate(SID_ATTR_ALIGN_DEGREES
);
2132 Invalidate(SID_ATTR_ALIGN_STACKED
);
2135 void ScFormatShell::GetTextAttrState( SfxItemSet
& rSet
)
2137 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2138 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2139 rSet
.Put( rAttrSet
, false ); // ItemStates mitkopieren
2141 // choose font info according to selection script type
2142 SvtScriptType nScript
= SvtScriptType::NONE
; // GetSelectionScriptType never returns 0
2143 if ( rSet
.GetItemState( ATTR_FONT_WEIGHT
) != SfxItemState::UNKNOWN
)
2145 if (nScript
== SvtScriptType::NONE
) nScript
= pTabViewShell
->GetSelectionScriptType();
2146 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_WEIGHT
, nScript
);
2148 if ( rSet
.GetItemState( ATTR_FONT_POSTURE
) != SfxItemState::UNKNOWN
)
2150 if (nScript
== SvtScriptType::NONE
) nScript
= pTabViewShell
->GetSelectionScriptType();
2151 ScViewUtil::PutItemScript( rSet
, rAttrSet
, ATTR_FONT_POSTURE
, nScript
);
2154 SfxItemState eState
;
2155 // const SfxPoolItem* pItem;
2157 // eigene Kontrolle ueber RadioButton-Funktionalitaet:
2161 eState
= rAttrSet
.GetItemState( ATTR_FONT_UNDERLINE
, true );
2162 if ( eState
== SfxItemState::DONTCARE
)
2164 rSet
.InvalidateItem( SID_ULINE_VAL_NONE
);
2165 rSet
.InvalidateItem( SID_ULINE_VAL_SINGLE
);
2166 rSet
.InvalidateItem( SID_ULINE_VAL_DOUBLE
);
2167 rSet
.InvalidateItem( SID_ULINE_VAL_DOTTED
);
2171 FontUnderline eUnderline
= static_cast<const SvxUnderlineItem
&>(
2172 rAttrSet
.Get(ATTR_FONT_UNDERLINE
)).GetLineStyle();
2173 sal_uInt16 nId
= SID_ULINE_VAL_NONE
;
2176 case UNDERLINE_SINGLE
: nId
= SID_ULINE_VAL_SINGLE
; break;
2177 case UNDERLINE_DOUBLE
: nId
= SID_ULINE_VAL_DOUBLE
; break;
2178 case UNDERLINE_DOTTED
: nId
= SID_ULINE_VAL_DOTTED
; break;
2182 rSet
.Put( SfxBoolItem( nId
, true ) );
2185 // horizontale Ausrichtung
2187 const SvxHorJustifyItem
* pHorJustify
= NULL
;
2188 const SvxVerJustifyItem
* pVerJustify
= NULL
;
2189 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
2190 sal_uInt16 nWhich
= 0;
2191 bool bJustifyStd
= false;
2192 SfxBoolItem
aBoolItem ( 0, true );
2194 eState
= rAttrSet
.GetItemState( ATTR_HOR_JUSTIFY
, true,
2195 reinterpret_cast<const SfxPoolItem
**>(&pHorJustify
) );
2198 case SfxItemState::SET
:
2200 switch ( SvxCellHorJustify( pHorJustify
->GetValue() ) )
2202 case SVX_HOR_JUSTIFY_STANDARD
:
2205 case SVX_HOR_JUSTIFY_LEFT
:
2206 nWhich
= SID_ALIGNLEFT
;
2209 case SVX_HOR_JUSTIFY_RIGHT
:
2210 nWhich
= SID_ALIGNRIGHT
;
2213 case SVX_HOR_JUSTIFY_CENTER
:
2214 nWhich
= SID_ALIGNCENTERHOR
;
2217 case SVX_HOR_JUSTIFY_BLOCK
:
2218 nWhich
= SID_ALIGNBLOCK
;
2221 case SVX_HOR_JUSTIFY_REPEAT
:
2229 case SfxItemState::DONTCARE
:
2230 rSet
.InvalidateItem( SID_ALIGNLEFT
);
2231 rSet
.InvalidateItem( SID_ALIGNRIGHT
);
2232 rSet
.InvalidateItem( SID_ALIGNCENTERHOR
);
2233 rSet
.InvalidateItem( SID_ALIGNBLOCK
);
2243 aBoolItem
.SetWhich( nWhich
);
2244 rSet
.Put( aBoolItem
);
2246 else if ( bJustifyStd
)
2248 aBoolItem
.SetValue( false );
2249 aBoolItem
.SetWhich( SID_ALIGNLEFT
); rSet
.Put( aBoolItem
);
2250 aBoolItem
.SetWhich( SID_ALIGNRIGHT
); rSet
.Put( aBoolItem
);
2251 aBoolItem
.SetWhich( SID_ALIGNCENTERHOR
); rSet
.Put( aBoolItem
);
2252 aBoolItem
.SetWhich( SID_ALIGNBLOCK
); rSet
.Put( aBoolItem
);
2253 bJustifyStd
= false;
2256 // vertikale Ausrichtung
2259 aBoolItem
.SetValue( true );
2261 eState
= rAttrSet
.GetItemState( ATTR_VER_JUSTIFY
, true,
2262 reinterpret_cast<const SfxPoolItem
**>(&pVerJustify
) );
2266 case SfxItemState::SET
:
2268 eVerJustify
= SvxCellVerJustify( pVerJustify
->GetValue() );
2270 switch ( eVerJustify
)
2272 case SVX_VER_JUSTIFY_TOP
:
2273 nWhich
= SID_ALIGNTOP
;
2276 case SVX_VER_JUSTIFY_BOTTOM
:
2277 nWhich
= SID_ALIGNBOTTOM
;
2280 case SVX_VER_JUSTIFY_CENTER
:
2281 nWhich
= SID_ALIGNCENTERVER
;
2284 case SVX_VER_JUSTIFY_STANDARD
:
2292 case SfxItemState::DONTCARE
:
2293 rSet
.InvalidateItem( SID_ALIGNTOP
);
2294 rSet
.InvalidateItem( SID_ALIGNBOTTOM
);
2295 rSet
.InvalidateItem( SID_ALIGNCENTERVER
);
2305 aBoolItem
.SetWhich( nWhich
);
2306 rSet
.Put( aBoolItem
);
2308 else if ( bJustifyStd
)
2310 aBoolItem
.SetValue( false );
2311 aBoolItem
.SetWhich( SID_ALIGNTOP
); rSet
.Put( aBoolItem
);
2312 aBoolItem
.SetWhich( SID_ALIGNBOTTOM
); rSet
.Put( aBoolItem
);
2313 aBoolItem
.SetWhich( SID_ALIGNCENTERVER
); rSet
.Put( aBoolItem
);
2317 void ScFormatShell::GetBorderState( SfxItemSet
& rSet
)
2319 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2320 SvxBoxItem
aBoxItem( ATTR_BORDER
);
2321 SvxBoxInfoItem
aInfoItem( ATTR_BORDER_INNER
);
2323 pTabViewShell
->GetSelectionFrame( aBoxItem
, aInfoItem
);
2325 if ( rSet
.GetItemState( ATTR_BORDER
) != SfxItemState::UNKNOWN
)
2326 rSet
.Put( aBoxItem
);
2327 if ( rSet
.GetItemState( ATTR_BORDER_INNER
) != SfxItemState::UNKNOWN
)
2328 rSet
.Put( aInfoItem
);
2331 void ScFormatShell::GetAlignState( SfxItemSet
& rSet
)
2333 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2334 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2335 SfxWhichIter
aIter(rSet
);
2336 sal_uInt16 nWhich
= aIter
.FirstWhich();
2338 SvxCellHorJustify eHAlign
= SVX_HOR_JUSTIFY_STANDARD
;
2339 bool bHasHAlign
= rAttrSet
.GetItemState( ATTR_HOR_JUSTIFY
) != SfxItemState::DONTCARE
;
2341 eHAlign
= (SvxCellHorJustify
)static_cast<const SvxHorJustifyItem
&>(rAttrSet
.Get( ATTR_HOR_JUSTIFY
)).GetValue();
2343 SvxCellVerJustify eVAlign
= SVX_VER_JUSTIFY_STANDARD
;
2344 bool bHasVAlign
= rAttrSet
.GetItemState( ATTR_VER_JUSTIFY
) != SfxItemState::DONTCARE
;
2346 eVAlign
= (SvxCellVerJustify
)static_cast<const SvxVerJustifyItem
&>(rAttrSet
.Get( ATTR_VER_JUSTIFY
)).GetValue();
2352 case SID_H_ALIGNCELL
:
2354 rSet
.Put( SvxHorJustifyItem( eHAlign
, nWhich
));
2356 case SID_V_ALIGNCELL
:
2358 rSet
.Put( SvxVerJustifyItem( eVAlign
, nWhich
));
2361 // pseudo slots for Format menu
2362 case SID_ALIGN_ANY_HDEFAULT
:
2363 case SID_ALIGN_ANY_LEFT
:
2364 case SID_ALIGN_ANY_HCENTER
:
2365 case SID_ALIGN_ANY_RIGHT
:
2366 case SID_ALIGN_ANY_JUSTIFIED
:
2367 rSet
.Put( SfxBoolItem( nWhich
, bHasHAlign
&& (eHAlign
== lclConvertSlotToHAlign( nWhich
)) ) );
2369 case SID_ALIGN_ANY_VDEFAULT
:
2370 case SID_ALIGN_ANY_TOP
:
2371 case SID_ALIGN_ANY_VCENTER
:
2372 case SID_ALIGN_ANY_BOTTOM
:
2373 rSet
.Put( SfxBoolItem( nWhich
, bHasVAlign
&& (eVAlign
== lclConvertSlotToVAlign( nWhich
)) ) );
2376 nWhich
= aIter
.NextWhich();
2380 void ScFormatShell::GetNumFormatState( SfxItemSet
& rSet
)
2382 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2383 ScDocument
* pDoc
= pViewData
->GetDocument();
2384 short nType
= GetCurrentNumberFormatType();
2386 SfxWhichIter
aIter(rSet
);
2387 sal_uInt16 nWhich
= aIter
.FirstWhich();
2392 case SID_NUMBER_FORMAT
:
2394 // String aFormatCode; // bleibt leer, wenn dont-care
2396 // const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2397 // if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SfxItemState::DONTCARE )
2399 // sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2400 // ATTR_VALUE_FORMAT )).GetValue();
2402 // SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
2403 // const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2404 // if ( pFormatEntry )
2405 // aFormatCode = pFormatEntry->GetFormatstring();
2408 // rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2411 // symphony version with format interpretation
2413 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2415 if(SfxItemState::DONTCARE
!= rAttrSet
.GetItemState(ATTR_VALUE_FORMAT
))
2417 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2418 sal_uInt32 nNumberFormat
= static_cast<const SfxUInt32Item
&>(rAttrSet
.Get(ATTR_VALUE_FORMAT
)).GetValue();
2419 bool bThousand(false);
2420 bool bNegRed(false);
2421 sal_uInt16
nPrecision(0);
2422 sal_uInt16
nLeadZeroes(0);
2424 pFormatter
->GetFormatSpecialInfo(nNumberFormat
,bThousand
, bNegRed
, nPrecision
, nLeadZeroes
);
2426 const SvNumberformat
* pFormatEntry
= pFormatter
->GetEntry( nNumberFormat
);
2427 if (pFormatEntry
&& (pFormatEntry
->GetType() & css::util::NumberFormat::SCIENTIFIC
))
2429 // if scientific, bThousand is used for engineering notation
2430 const sal_uInt16 nIntegerDigits
= pFormatEntry
->GetFormatIntegerDigits();
2431 if (nIntegerDigits
> 0 && ((nIntegerDigits
% 3) == 0))
2437 static OUString sBreak
= ",";
2438 const OUString sThousand
= OUString::number(static_cast<sal_Int32
>(bThousand
));
2439 const OUString sNegRed
= OUString::number(static_cast<sal_Int32
>(bNegRed
));
2440 const OUString sPrecision
= OUString::number(nPrecision
);
2441 const OUString sLeadZeroes
= OUString::number(nLeadZeroes
);
2443 aFormat
+= sThousand
;
2447 aFormat
+= sPrecision
;
2449 aFormat
+= sLeadZeroes
;
2452 rSet
.Put(SfxStringItem(nWhich
, aFormat
));
2456 rSet
.InvalidateItem( nWhich
);
2461 case SID_NUMBER_TYPE_FORMAT
:
2463 sal_Int16 aFormatCode
= -1;
2464 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2465 if ( rAttrSet
.GetItemState( ATTR_VALUE_FORMAT
) >= SfxItemState::DEFAULT
) //Modify for more robust
2467 SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2468 sal_uInt32 nNumberFormat
= pTabViewShell
->GetSelectionPattern()->GetNumberFormat( pFormatter
);
2469 const SvNumberformat
* pFormatEntry
= pFormatter
->GetEntry( nNumberFormat
);
2470 bool bStandard
= false;
2474 aFormatCode
= pFormatEntry
->GetType();
2475 bStandard
= pFormatEntry
->IsStandard();
2480 case css::util::NumberFormat::NUMBER
:
2481 case css::util::NumberFormat::NUMBER
| css::util::NumberFormat::DEFINED
:
2482 //use format code and standard format code to judge whether it is General,
2483 //if (nNumberFormat == nStandardNumberFormat)
2489 case css::util::NumberFormat::PERCENT
:
2490 case css::util::NumberFormat::PERCENT
| css::util::NumberFormat::DEFINED
:
2493 case css::util::NumberFormat::CURRENCY
:
2494 case css::util::NumberFormat::CURRENCY
| css::util::NumberFormat::DEFINED
:
2497 case css::util::NumberFormat::DATE
:
2498 case css::util::NumberFormat::DATE
| css::util::NumberFormat::DEFINED
:
2500 case css::util::NumberFormat::DATETIME
:
2501 case css::util::NumberFormat::DATETIME
| css::util::NumberFormat::DEFINED
:
2504 case css::util::NumberFormat::TIME
:
2505 case css::util::NumberFormat::TIME
| css::util::NumberFormat::DEFINED
:
2508 case css::util::NumberFormat::SCIENTIFIC
:
2509 case css::util::NumberFormat::SCIENTIFIC
| css::util::NumberFormat::DEFINED
:
2512 case css::util::NumberFormat::FRACTION
:
2513 case css::util::NumberFormat::FRACTION
| css::util::NumberFormat::DEFINED
:
2516 case css::util::NumberFormat::LOGICAL
:
2517 case css::util::NumberFormat::LOGICAL
| css::util::NumberFormat::DEFINED
:
2520 case css::util::NumberFormat::TEXT
:
2521 case css::util::NumberFormat::TEXT
| css::util::NumberFormat::DEFINED
:
2525 aFormatCode
= -1; //for more roburst
2527 if( aFormatCode
== -1 )
2528 rSet
.InvalidateItem( nWhich
);
2530 rSet
.Put( SfxInt16Item( nWhich
, aFormatCode
) );
2534 rSet
.InvalidateItem( nWhich
);
2539 case SID_NUMBER_SCIENTIFIC
:
2540 rSet
.Put( SfxBoolItem(nWhich
, (nType
& css::util::NumberFormat::SCIENTIFIC
)) );
2542 case SID_NUMBER_DATE
:
2543 rSet
.Put( SfxBoolItem(nWhich
, (nType
& css::util::NumberFormat::DATE
)) );
2545 case SID_NUMBER_CURRENCY
:
2546 rSet
.Put( SfxBoolItem(nWhich
, (nType
& css::util::NumberFormat::CURRENCY
)) );
2548 case SID_NUMBER_PERCENT
:
2549 rSet
.Put( SfxBoolItem(nWhich
, (nType
& css::util::NumberFormat::PERCENT
)) );
2551 case SID_NUMBER_TIME
:
2552 rSet
.Put( SfxBoolItem(nWhich
, (nType
& css::util::NumberFormat::TIME
)) );
2555 nWhich
= aIter
.NextWhich();
2559 void ScFormatShell::ExecuteTextDirection( SfxRequest
& rReq
)
2561 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2562 pTabViewShell
->HideListBox(); // Autofilter-DropDown-Listbox
2563 bool bEditMode
= false;
2564 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2567 SC_MOD()->InputEnterHandler();
2568 pTabViewShell
->UpdateInputHandler();
2570 sal_uInt16 nSlot
= rReq
.GetSlot();
2573 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
2574 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
2576 bool bVert
= (nSlot
== SID_TEXTDIRECTION_TOP_TO_BOTTOM
);
2577 ScPatternAttr
aAttr( GetViewData()->GetDocument()->GetPool() );
2578 SfxItemSet
& rItemSet
= aAttr
.GetItemSet();
2579 rItemSet
.Put( SfxBoolItem( ATTR_STACKED
, bVert
) );
2580 rItemSet
.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN
, bVert
) );
2581 pTabViewShell
->ApplySelectionPattern( aAttr
);
2582 pTabViewShell
->AdjustBlockHeight();
2586 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
2587 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
2589 SvxFrameDirection eDirection
= ( nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
) ?
2590 FRMDIR_HORI_LEFT_TOP
: FRMDIR_HORI_RIGHT_TOP
;
2591 pTabViewShell
->ApplyAttr( SvxFrameDirectionItem( eDirection
, ATTR_WRITINGDIR
) );
2596 SC_MOD()->SetInputMode( SC_INPUT_TABLE
);
2599 void ScFormatShell::GetTextDirectionState( SfxItemSet
& rSet
)
2601 ScTabViewShell
* pTabViewShell
= GetViewData()->GetViewShell();
2602 const SfxItemSet
& rAttrSet
= pTabViewShell
->GetSelectionPattern()->GetItemSet();
2604 bool bVertDontCare
=
2605 (rAttrSet
.GetItemState( ATTR_VERTICAL_ASIAN
) == SfxItemState::DONTCARE
) ||
2606 (rAttrSet
.GetItemState( ATTR_STACKED
) == SfxItemState::DONTCARE
);
2607 bool bLeftRight
= !bVertDontCare
&&
2608 !static_cast<const SfxBoolItem
&>(rAttrSet
.Get( ATTR_STACKED
)).GetValue();
2609 bool bTopBottom
= !bVertDontCare
&& !bLeftRight
&&
2610 static_cast<const SfxBoolItem
&>(rAttrSet
.Get( ATTR_VERTICAL_ASIAN
)).GetValue();
2612 bool bBidiDontCare
= (rAttrSet
.GetItemState( ATTR_WRITINGDIR
) == SfxItemState::DONTCARE
);
2613 EEHorizontalTextDirection eBidiDir
= EE_HTEXTDIR_DEFAULT
;
2614 if ( !bBidiDontCare
)
2616 SvxFrameDirection eCellDir
= (SvxFrameDirection
)static_cast<const SvxFrameDirectionItem
&>(
2617 rAttrSet
.Get( ATTR_WRITINGDIR
)).GetValue();
2618 if ( eCellDir
== FRMDIR_ENVIRONMENT
)
2619 eBidiDir
= (EEHorizontalTextDirection
)GetViewData()->GetDocument()->
2620 GetEditTextDirection( GetViewData()->GetTabNo() );
2621 else if ( eCellDir
== FRMDIR_HORI_RIGHT_TOP
)
2622 eBidiDir
= EE_HTEXTDIR_R2L
;
2624 eBidiDir
= EE_HTEXTDIR_L2R
;
2627 SvtLanguageOptions aLangOpt
;
2628 bool bDisableCTLFont
= !aLangOpt
.IsCTLFontEnabled();
2629 bool bDisableVerticalText
= !aLangOpt
.IsVerticalTextEnabled();
2631 SfxWhichIter
aIter( rSet
);
2632 sal_uInt16 nWhich
= aIter
.FirstWhich();
2637 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
2638 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
2639 if ( bDisableVerticalText
)
2640 rSet
.DisableItem( nWhich
);
2644 rSet
.InvalidateItem( nWhich
);
2645 else if ( nWhich
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
)
2646 rSet
.Put( SfxBoolItem( nWhich
, bLeftRight
) );
2648 rSet
.Put( SfxBoolItem( nWhich
, bTopBottom
) );
2652 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
2653 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
2654 if ( bDisableCTLFont
)
2655 rSet
.DisableItem( nWhich
);
2659 rSet
.DisableItem( nWhich
);
2660 else if ( bBidiDontCare
)
2661 rSet
.InvalidateItem( nWhich
);
2662 else if ( nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
)
2663 rSet
.Put( SfxBoolItem( nWhich
, eBidiDir
== EE_HTEXTDIR_L2R
) );
2665 rSet
.Put( SfxBoolItem( nWhich
, eBidiDir
== EE_HTEXTDIR_R2L
) );
2668 nWhich
= aIter
.NextWhich();
2672 void ScFormatShell::ExecFormatPaintbrush( SfxRequest
& rReq
)
2674 ScViewFunc
* pView
= pViewData
->GetView();
2675 if ( pView
->HasPaintBrush() )
2677 // cancel paintbrush mode
2678 pView
->ResetBrushDocument();
2683 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2684 if( pArgs
&& pArgs
->Count() >= 1 )
2685 bLock
= static_cast<const SfxBoolItem
&>(pArgs
->Get(SID_FORMATPAINTBRUSH
)).GetValue();
2687 // in case of multi selection, deselect all and use the cursor position
2689 if ( pViewData
->GetSimpleArea(aDummy
) != SC_MARK_SIMPLE
)
2692 ScDocument
* pBrushDoc
= new ScDocument( SCDOCMODE_CLIP
);
2693 pView
->CopyToClip( pBrushDoc
, false, true );
2694 pView
->SetBrushDocument( pBrushDoc
, bLock
);
2698 void ScFormatShell::StateFormatPaintbrush( SfxItemSet
& rSet
)
2700 if ( pViewData
->HasEditView( pViewData
->GetActivePart() ) )
2701 rSet
.DisableItem( SID_FORMATPAINTBRUSH
);
2703 rSet
.Put( SfxBoolItem( SID_FORMATPAINTBRUSH
, pViewData
->GetView()->HasPaintBrush() ) );
2706 short ScFormatShell::GetCurrentNumberFormatType()
2708 short nType
= css::util::NumberFormat::ALL
;
2709 ScDocument
* pDoc
= GetViewData()->GetDocument();
2710 ScMarkData
aMark(GetViewData()->GetMarkData());
2711 const SvNumberFormatter
* pFormatter
= pDoc
->GetFormatTable();
2715 // TODO: Find out how to get a selected table range in case multiple tables
2716 // are selected. Currently we only check for the current active table.
2718 if ( aMark
.IsMarked() || aMark
.IsMultiMarked() )
2720 aMark
.MarkToMulti();
2722 aMark
.GetMultiMarkArea(aRange
);
2724 const ScMarkArray
* pArray
= aMark
.GetArray();
2728 short nComboType
= css::util::NumberFormat::ALL
;
2729 bool bFirstItem
= true;
2730 for (SCCOL nCol
= aRange
.aStart
.Col(); nCol
<= aRange
.aEnd
.Col(); ++nCol
)
2732 const ScMarkArray
& rColArray
= pArray
[nCol
];
2733 if (!rColArray
.HasMarks())
2737 ScMarkArrayIter
aMarkIter(&rColArray
);
2738 while (aMarkIter
.Next(nRow1
, nRow2
))
2740 ScRange
aColRange(nCol
, nRow1
, aRange
.aStart
.Tab());
2741 aColRange
.aEnd
.SetRow(nRow2
);
2742 sal_uInt32 nNumFmt
= pDoc
->GetNumberFormat(aColRange
);
2743 const SvNumberformat
* pEntry
= pFormatter
->GetEntry(nNumFmt
);
2747 short nThisType
= pEntry
->GetType();
2751 nComboType
= nThisType
;
2753 else if (nComboType
!= nThisType
)
2754 // mixed number format type.
2755 return css::util::NumberFormat::ALL
;
2763 pDoc
->GetNumberFormat( pViewData
->GetCurX(), pViewData
->GetCurY(),
2764 pViewData
->GetTabNo(), nNumFmt
);
2765 const SvNumberformat
* pEntry
= pFormatter
->GetEntry( nNumFmt
);
2766 nType
= pEntry
? pEntry
->GetType() : 0;
2771 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */