1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir //------------------------------------------------------------------ 33cdf0e10cSrcweir 34cdf0e10cSrcweir //svdraw.hxx 35cdf0e10cSrcweir #define _SDR_NOITEMS 36cdf0e10cSrcweir #define _SDR_NOTOUCH 37cdf0e10cSrcweir #define _SDR_NOTRANSFORM 38cdf0e10cSrcweir #define _SI_NOSBXCONTROLS 39cdf0e10cSrcweir #define _VCONT_HXX 40cdf0e10cSrcweir #define _SI_NOOTHERFORMS 41cdf0e10cSrcweir #define _VCTRLS_HXX 42cdf0e10cSrcweir #define _SI_NOCONTROL 43cdf0e10cSrcweir #define _SETBRW_HXX 44cdf0e10cSrcweir #define _VCBRW_HXX 45cdf0e10cSrcweir #define _SI_NOSBXCONTROLS 46cdf0e10cSrcweir 47cdf0e10cSrcweir //------------------------------------------------------------------ 48cdf0e10cSrcweir 49cdf0e10cSrcweir #include "scitems.hxx" 50cdf0e10cSrcweir #include <editeng/eeitem.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include <sfx2/app.hxx> 53cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 54cdf0e10cSrcweir #include <sfx2/objface.hxx> 55cdf0e10cSrcweir #include <sfx2/request.hxx> 56cdf0e10cSrcweir #include <svl/whiter.hxx> 57cdf0e10cSrcweir #include <vcl/msgbox.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE 60cdf0e10cSrcweir #include <svl/stritem.hxx> 61cdf0e10cSrcweir #include <svl/zformat.hxx> 62cdf0e10cSrcweir #include <svl/languageoptions.hxx> 63cdf0e10cSrcweir #include <editeng/boxitem.hxx> 64cdf0e10cSrcweir #include <editeng/langitem.hxx> 65cdf0e10cSrcweir #include <svx/numinf.hxx> 66cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 67cdf0e10cSrcweir #include <sfx2/templdlg.hxx> 68cdf0e10cSrcweir #include <sfx2/tplpitem.hxx> 69cdf0e10cSrcweir #include <editeng/svxenum.hxx> 70cdf0e10cSrcweir #include <svx/algitem.hxx> 71cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 72cdf0e10cSrcweir #include <editeng/postitem.hxx> 73cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 74cdf0e10cSrcweir #include <editeng/bolnitem.hxx> 75cdf0e10cSrcweir #include <editeng/colritem.hxx> 76cdf0e10cSrcweir #include <editeng/brshitem.hxx> 77cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 78cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx> 79cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 80cdf0e10cSrcweir #include <editeng/shaditem.hxx> 81cdf0e10cSrcweir 82cdf0e10cSrcweir #include "formatsh.hxx" 83cdf0e10cSrcweir #include "sc.hrc" 84cdf0e10cSrcweir #include "globstr.hrc" 85cdf0e10cSrcweir #include "docsh.hxx" 86cdf0e10cSrcweir #include "patattr.hxx" 87cdf0e10cSrcweir #include "scmod.hxx" 88cdf0e10cSrcweir //CHINA001 #include "styledlg.hxx" 89cdf0e10cSrcweir #include "attrdlg.hrc" 90cdf0e10cSrcweir #include "stlpool.hxx" 91cdf0e10cSrcweir #include "stlsheet.hxx" 92cdf0e10cSrcweir #include "printfun.hxx" 93cdf0e10cSrcweir #include "docpool.hxx" 94cdf0e10cSrcweir #include "scresid.hxx" 95cdf0e10cSrcweir #include "tabvwsh.hxx" 96cdf0e10cSrcweir #include "undostyl.hxx" 97cdf0e10cSrcweir 98cdf0e10cSrcweir 99cdf0e10cSrcweir #define ScFormatShell 100cdf0e10cSrcweir #define TableFont 101cdf0e10cSrcweir #define FormatForSelection 102cdf0e10cSrcweir #include "scslots.hxx" 103cdf0e10cSrcweir 104cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001 105cdf0e10cSrcweir 106cdf0e10cSrcweir namespace { 107cdf0e10cSrcweir 108cdf0e10cSrcweir SvxCellHorJustify lclConvertSlotToHAlign( sal_uInt16 nSlot ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD; 111cdf0e10cSrcweir switch( nSlot ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir case SID_ALIGN_ANY_HDEFAULT: eHJustify = SVX_HOR_JUSTIFY_STANDARD; break; 114cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT: eHJustify = SVX_HOR_JUSTIFY_LEFT; break; 115cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER: eHJustify = SVX_HOR_JUSTIFY_CENTER; break; 116cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT: eHJustify = SVX_HOR_JUSTIFY_RIGHT; break; 117cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED: eHJustify = SVX_HOR_JUSTIFY_BLOCK; break; 118cdf0e10cSrcweir default: DBG_ERRORFILE( "lclConvertSlotToHAlign - invalid slot" ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir return eHJustify; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir SvxCellVerJustify lclConvertSlotToVAlign( sal_uInt16 nSlot ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD; 126cdf0e10cSrcweir switch( nSlot ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir case SID_ALIGN_ANY_VDEFAULT: eVJustify = SVX_VER_JUSTIFY_STANDARD; break; 129cdf0e10cSrcweir case SID_ALIGN_ANY_TOP: eVJustify = SVX_VER_JUSTIFY_TOP; break; 130cdf0e10cSrcweir case SID_ALIGN_ANY_VCENTER: eVJustify = SVX_VER_JUSTIFY_CENTER; break; 131cdf0e10cSrcweir case SID_ALIGN_ANY_BOTTOM: eVJustify = SVX_VER_JUSTIFY_BOTTOM; break; 132cdf0e10cSrcweir default: DBG_ERRORFILE( "lclConvertSlotToVAlign - invalid slot" ); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir return eVJustify; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir } // namespace 138cdf0e10cSrcweir 139cdf0e10cSrcweir TYPEINIT1( ScFormatShell, SfxShell ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | 144cdf0e10cSrcweir SFX_VISIBILITY_SERVER, 145cdf0e10cSrcweir ScResId(RID_OBJECTBAR_FORMAT)); 146cdf0e10cSrcweir 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir 150cdf0e10cSrcweir ScFormatShell::ScFormatShell(ScViewData* pData) : 151cdf0e10cSrcweir SfxShell(pData->GetViewShell()), 152cdf0e10cSrcweir pViewData(pData) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir SetPool( &pTabViewShell->GetPool() ); 157cdf0e10cSrcweir ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); 158cdf0e10cSrcweir SetUndoManager( pMgr ); 159cdf0e10cSrcweir if ( !pViewData->GetDocument()->IsUndoEnabled() ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir pMgr->SetMaxUndoActionCount( 0 ); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir SetHelpId(HID_SCSHELL_FORMATSH); 164cdf0e10cSrcweir SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format"))); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir ScFormatShell::~ScFormatShell() 168cdf0e10cSrcweir { 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir //------------------------------------------------------------------ 172cdf0e10cSrcweir 173cdf0e10cSrcweir void __EXPORT ScFormatShell::GetStyleState( SfxItemSet& rSet ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument(); 176cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 177cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir sal_Bool bProtected = sal_False; 180cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 181cdf0e10cSrcweir for (SCTAB i=0; i<nTabCount; i++) 182cdf0e10cSrcweir if (pDoc->IsTabProtected(i)) // ueberhaupt eine Tabelle geschuetzt? 183cdf0e10cSrcweir bProtected = sal_True; 184cdf0e10cSrcweir 185cdf0e10cSrcweir SfxWhichIter aIter(rSet); 186cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 187cdf0e10cSrcweir sal_uInt16 nSlotId = 0; 188cdf0e10cSrcweir 189cdf0e10cSrcweir while ( nWhich ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir nSlotId = SfxItemPool::IsWhich( nWhich ) 192cdf0e10cSrcweir ? GetPool().GetSlotId( nWhich ) 193cdf0e10cSrcweir : nWhich; 194cdf0e10cSrcweir 195cdf0e10cSrcweir switch ( nSlotId ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir case SID_STYLE_APPLY: 198cdf0e10cSrcweir if ( !pStylePool ) 199cdf0e10cSrcweir rSet.DisableItem( nSlotId ); 200cdf0e10cSrcweir break; 201cdf0e10cSrcweir 202cdf0e10cSrcweir case SID_STYLE_FAMILY2: // Zellvorlagen 203cdf0e10cSrcweir { 204cdf0e10cSrcweir SfxStyleSheet* pStyleSheet = (SfxStyleSheet*) 205cdf0e10cSrcweir pTabViewShell->GetStyleSheetFromMarked(); 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( pStyleSheet ) 208cdf0e10cSrcweir rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) ); 209cdf0e10cSrcweir else 210cdf0e10cSrcweir rSet.Put( SfxTemplateItem( nSlotId, String() ) ); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir break; 213cdf0e10cSrcweir 214cdf0e10cSrcweir case SID_STYLE_FAMILY4: // Seitenvorlagen 215cdf0e10cSrcweir { 216cdf0e10cSrcweir SCTAB nCurTab = GetViewData()->GetTabNo(); 217cdf0e10cSrcweir String aPageStyle = pDoc->GetPageStyle( nCurTab ); 218cdf0e10cSrcweir SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStylePool-> 219cdf0e10cSrcweir Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir if ( pStyleSheet ) 222cdf0e10cSrcweir rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) ); 223cdf0e10cSrcweir else 224cdf0e10cSrcweir rSet.Put( SfxTemplateItem( nSlotId, String() ) ); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir break; 227cdf0e10cSrcweir 228cdf0e10cSrcweir case SID_STYLE_WATERCAN: 229cdf0e10cSrcweir { 230cdf0e10cSrcweir rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) ); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir 234cdf0e10cSrcweir case SID_STYLE_UPDATE_BY_EXAMPLE: 235cdf0e10cSrcweir { 236cdf0e10cSrcweir ISfxTemplateCommon* pDesigner = SFX_APP()-> 237cdf0e10cSrcweir GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); 238cdf0e10cSrcweir sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); 239cdf0e10cSrcweir 240cdf0e10cSrcweir if ( bProtected || bPage ) 241cdf0e10cSrcweir rSet.DisableItem( nSlotId ); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir break; 244cdf0e10cSrcweir 245cdf0e10cSrcweir case SID_STYLE_EDIT: 246cdf0e10cSrcweir case SID_STYLE_DELETE: 247cdf0e10cSrcweir { 248cdf0e10cSrcweir ISfxTemplateCommon* pDesigner = SFX_APP()-> 249cdf0e10cSrcweir GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); 250cdf0e10cSrcweir sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); 251cdf0e10cSrcweir 252cdf0e10cSrcweir if ( bProtected && !bPage ) 253cdf0e10cSrcweir rSet.DisableItem( nSlotId ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir break; 256cdf0e10cSrcweir 257cdf0e10cSrcweir default: 258cdf0e10cSrcweir break; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir nWhich = aIter.NextWhich(); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir //------------------------------------------------------------------ 266cdf0e10cSrcweir 267cdf0e10cSrcweir void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir // Wenn ToolBar vertikal : 270cdf0e10cSrcweir if ( !rReq.GetArgs() ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); 273cdf0e10cSrcweir return; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir //-------------------------------------------------------------------- 277cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 278cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 279cdf0e10cSrcweir const sal_uInt16 nSlotId = rReq.GetSlot(); 280cdf0e10cSrcweir const SCTAB nCurTab = GetViewData()->GetTabNo(); 281cdf0e10cSrcweir ScDocShell* pDocSh = GetViewData()->GetDocShell(); 282cdf0e10cSrcweir ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell(); 283cdf0e10cSrcweir ScDocument* pDoc = pDocSh->GetDocument(); 284cdf0e10cSrcweir ScMarkData& rMark = GetViewData()->GetMarkData(); 285cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 286cdf0e10cSrcweir String aRefName; 287cdf0e10cSrcweir sal_Bool bUndo = pDoc->IsUndoEnabled(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir if ( (nSlotId == SID_STYLE_NEW) 290cdf0e10cSrcweir || (nSlotId == SID_STYLE_EDIT) 291cdf0e10cSrcweir || (nSlotId == SID_STYLE_DELETE) 292cdf0e10cSrcweir || (nSlotId == SID_STYLE_APPLY) 293cdf0e10cSrcweir || (nSlotId == SID_STYLE_WATERCAN) 294cdf0e10cSrcweir || (nSlotId == SID_STYLE_FAMILY) 295cdf0e10cSrcweir || (nSlotId == SID_STYLE_NEW_BY_EXAMPLE) 296cdf0e10cSrcweir || (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); 299cdf0e10cSrcweir SfxStyleSheetBase* pStyleSheet = NULL; 300cdf0e10cSrcweir 301cdf0e10cSrcweir sal_Bool bStyleToMarked = sal_False; 302cdf0e10cSrcweir sal_Bool bListAction = sal_False; 303cdf0e10cSrcweir sal_Bool bAddUndo = sal_False; // add ScUndoModifyStyle (style modified) 304cdf0e10cSrcweir ScStyleSaveData aOldData; // for undo/redo 305cdf0e10cSrcweir ScStyleSaveData aNewData; 306cdf0e10cSrcweir 307cdf0e10cSrcweir SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA; 308cdf0e10cSrcweir const SfxPoolItem* pFamItem; 309cdf0e10cSrcweir if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, sal_True, &pFamItem ) ) 310cdf0e10cSrcweir eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue(); 311cdf0e10cSrcweir else 312cdf0e10cSrcweir if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, sal_True, &pFamItem ) ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir String sFamily = ((const SfxStringItem*)pFamItem)->GetValue(); 315cdf0e10cSrcweir if (sFamily.CompareToAscii("CellStyles") == COMPARE_EQUAL) 316cdf0e10cSrcweir eFamily = SFX_STYLE_FAMILY_PARA; 317cdf0e10cSrcweir else 318cdf0e10cSrcweir if (sFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL) 319cdf0e10cSrcweir eFamily = SFX_STYLE_FAMILY_PAGE; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir String aStyleName; 323cdf0e10cSrcweir sal_uInt16 nRetMask = 0xffff; 324cdf0e10cSrcweir // #96983# only stylist sends focus to sheet 325cdf0e10cSrcweir // sal_Bool bGrabFocus = ( SID_STYLE_APPLY == nSlotId ); 326cdf0e10cSrcweir 327cdf0e10cSrcweir pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL ); 328cdf0e10cSrcweir 329cdf0e10cSrcweir switch ( nSlotId ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir case SID_STYLE_NEW: 332cdf0e10cSrcweir { 333cdf0e10cSrcweir const SfxPoolItem* pNameItem; 334cdf0e10cSrcweir if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem )) 335cdf0e10cSrcweir aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); 336cdf0e10cSrcweir 337cdf0e10cSrcweir const SfxPoolItem* pRefItem=NULL; 338cdf0e10cSrcweir if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, sal_True, &pRefItem )) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir if(pRefItem!=NULL) 341cdf0e10cSrcweir aRefName = ((const SfxStringItem*)pRefItem)->GetValue(); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir pStyleSheet = &(pStylePool->Make( aStyleName, eFamily, 345cdf0e10cSrcweir SFXSTYLEBIT_USERDEF ) ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir if ( pStyleSheet && pStyleSheet->HasParentSupport() ) 348cdf0e10cSrcweir pStyleSheet->SetParent(aRefName); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir break; 351cdf0e10cSrcweir 352cdf0e10cSrcweir case SID_STYLE_APPLY: 353cdf0e10cSrcweir { 354cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False ); 355cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False ); 356cdf0e10cSrcweir if ( pFamilyItem && pNameItem ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), com::sun::star::uno::UNO_QUERY); 359cdf0e10cSrcweir try 360cdf0e10cSrcweir { 361cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xStyles; 362cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xCont = xModel->getStyleFamilies(); 363cdf0e10cSrcweir xCont->getByName(pFamilyItem->GetValue()) >>= xStyles; 364cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xInfo; 365cdf0e10cSrcweir xStyles->getByName( pNameItem->GetValue() ) >>= xInfo; 366cdf0e10cSrcweir ::rtl::OUString aUIName; 367cdf0e10cSrcweir xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName; 368cdf0e10cSrcweir if ( aUIName.getLength() ) 369cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) ); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir catch( com::sun::star::uno::Exception& ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir } 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir case SID_STYLE_EDIT: 377cdf0e10cSrcweir case SID_STYLE_DELETE: 378cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 379cdf0e10cSrcweir { 380cdf0e10cSrcweir const SfxPoolItem* pNameItem; 381cdf0e10cSrcweir if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem )) 382cdf0e10cSrcweir aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); 383cdf0e10cSrcweir pStyleSheet = pStylePool->Find( aStyleName, eFamily ); 384cdf0e10cSrcweir 385cdf0e10cSrcweir aOldData.InitFromStyle( pStyleSheet ); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir break; 388cdf0e10cSrcweir 389cdf0e10cSrcweir case SID_STYLE_WATERCAN: 390cdf0e10cSrcweir { 391cdf0e10cSrcweir sal_Bool bWaterCan = pScMod->GetIsWaterCan(); 392cdf0e10cSrcweir 393cdf0e10cSrcweir if( !bWaterCan ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir const SfxPoolItem* pItem; 396cdf0e10cSrcweir 397cdf0e10cSrcweir if ( SFX_ITEM_SET == 398cdf0e10cSrcweir pArgs->GetItemState( nSlotId, sal_True, &pItem ) ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem); 401cdf0e10cSrcweir if ( pStrItem ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir aStyleName = pStrItem->GetValue(); 404cdf0e10cSrcweir pStyleSheet = pStylePool->Find( aStyleName, eFamily ); 405cdf0e10cSrcweir 406cdf0e10cSrcweir if ( pStyleSheet ) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir ((ScStyleSheetPool*)pStylePool)-> 409cdf0e10cSrcweir SetActualStyleSheet( pStyleSheet ); 410cdf0e10cSrcweir rReq.Done(); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir } 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir if ( !bWaterCan && pStyleSheet ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir pScMod->SetWaterCan( sal_True ); 419cdf0e10cSrcweir pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) ); 420cdf0e10cSrcweir rReq.Done(); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir else 423cdf0e10cSrcweir { 424cdf0e10cSrcweir pScMod->SetWaterCan( sal_False ); 425cdf0e10cSrcweir pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) ); 426cdf0e10cSrcweir rReq.Done(); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir } 429cdf0e10cSrcweir break; 430cdf0e10cSrcweir 431cdf0e10cSrcweir default: 432cdf0e10cSrcweir break; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir // Neuen Style fuer WaterCan-Mode setzen 436cdf0e10cSrcweir if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet ) 437cdf0e10cSrcweir ((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet ); 438cdf0e10cSrcweir 439cdf0e10cSrcweir switch ( eFamily ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: 442cdf0e10cSrcweir { 443cdf0e10cSrcweir switch ( nSlotId ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir case SID_STYLE_DELETE: 446cdf0e10cSrcweir { 447cdf0e10cSrcweir if ( pStyleSheet ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir pTabViewShell->RemoveStyleSheetInUse( pStyleSheet ); 450cdf0e10cSrcweir pStylePool->Remove( pStyleSheet ); 451cdf0e10cSrcweir pTabViewShell->InvalidateAttribs(); 452cdf0e10cSrcweir nRetMask = sal_True; 453cdf0e10cSrcweir bAddUndo = sal_True; 454cdf0e10cSrcweir rReq.Done(); 455cdf0e10cSrcweir } 456cdf0e10cSrcweir else 457cdf0e10cSrcweir nRetMask = sal_False; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir break; 460cdf0e10cSrcweir 461cdf0e10cSrcweir case SID_STYLE_APPLY: 462cdf0e10cSrcweir { 463cdf0e10cSrcweir if ( pStyleSheet && !pScMod->GetIsWaterCan() ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir // Anwenden der Vorlage auf das Dokument 466cdf0e10cSrcweir pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); 467cdf0e10cSrcweir pTabViewShell->InvalidateAttribs(); 468cdf0e10cSrcweir rReq.Done(); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471cdf0e10cSrcweir break; 472cdf0e10cSrcweir 473cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 474cdf0e10cSrcweir case SID_STYLE_UPDATE_BY_EXAMPLE: 475cdf0e10cSrcweir { 476cdf0e10cSrcweir // Vorlage erzeugen/ersetzen durch Attribute 477cdf0e10cSrcweir // an der Cursor-Position: 478cdf0e10cSrcweir 479cdf0e10cSrcweir const ScPatternAttr* pAttrItem = NULL; 480cdf0e10cSrcweir 481cdf0e10cSrcweir // Die Abfrage, ob markiert ist, war hier immer falsch, 482cdf0e10cSrcweir // darum jetzt gar nicht mehr, und einfach vom Cursor. 483cdf0e10cSrcweir // Wenn Attribute aus der Selektion genommen werden sollen, 484cdf0e10cSrcweir // muss noch darauf geachtet werden, Items aus Vorlagen nicht 485cdf0e10cSrcweir // zu uebernehmen (GetSelectionPattern sammelt auch Items aus 486cdf0e10cSrcweir // Vorlagen zusammen) (#44748#) 487cdf0e10cSrcweir // pAttrItem = GetSelectionPattern(); 488cdf0e10cSrcweir 489cdf0e10cSrcweir // ScViewData* pViewData = GetViewData(); 490cdf0e10cSrcweir SCCOL nCol = pViewData->GetCurX(); 491cdf0e10cSrcweir SCROW nRow = pViewData->GetCurY(); 492cdf0e10cSrcweir pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab ); 493cdf0e10cSrcweir 494cdf0e10cSrcweir SfxItemSet aAttrSet = pAttrItem->GetItemSet(); 495cdf0e10cSrcweir aAttrSet.ClearItem( ATTR_MERGE ); 496cdf0e10cSrcweir aAttrSet.ClearItem( ATTR_MERGE_FLAG ); 497cdf0e10cSrcweir // bedingte Formatierung und Gueltigkeit nicht uebernehmen, 498cdf0e10cSrcweir // weil sie in der Vorlage nicht editiert werden koennen 499cdf0e10cSrcweir aAttrSet.ClearItem( ATTR_VALIDDATA ); 500cdf0e10cSrcweir aAttrSet.ClearItem( ATTR_CONDITIONAL ); 501cdf0e10cSrcweir 502cdf0e10cSrcweir if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir if ( bUndo ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE ); 507cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 508cdf0e10cSrcweir bListAction = sal_True; 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir sal_Bool bConvertBack = sal_False; 512cdf0e10cSrcweir SfxStyleSheet* pSheetInUse = (SfxStyleSheet*) 513cdf0e10cSrcweir pTabViewShell->GetStyleSheetFromMarked(); 514cdf0e10cSrcweir 515cdf0e10cSrcweir // wenn neuer Style vorhanden und in der Selektion 516cdf0e10cSrcweir // verwendet wird, so darf der Parent nicht uebernommen 517cdf0e10cSrcweir // werden: 518cdf0e10cSrcweir 519cdf0e10cSrcweir if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse ) 520cdf0e10cSrcweir pSheetInUse = NULL; 521cdf0e10cSrcweir 522cdf0e10cSrcweir // wenn bereits vorhanden, erstmal entfernen... 523cdf0e10cSrcweir if ( pStyleSheet ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir // Style-Pointer zu Namen vor Erase, 526cdf0e10cSrcweir // weil Zellen sonst ungueltige Pointer 527cdf0e10cSrcweir // enthalten. 528cdf0e10cSrcweir //!!! bei Gelenheit mal eine Methode, die 529cdf0e10cSrcweir // das fuer einen bestimmten Style macht 530cdf0e10cSrcweir pDoc->StylesToNames(); 531cdf0e10cSrcweir bConvertBack = sal_True; 532cdf0e10cSrcweir pStylePool->Remove(pStyleSheet); 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir // ...und neu anlegen 536cdf0e10cSrcweir pStyleSheet = &pStylePool->Make( aStyleName, eFamily, 537cdf0e10cSrcweir SFXSTYLEBIT_USERDEF ); 538cdf0e10cSrcweir 539cdf0e10cSrcweir // wenn ein Style vorhanden ist, so wird dieser 540cdf0e10cSrcweir // Parent der neuen Vorlage: 541cdf0e10cSrcweir if ( pSheetInUse && pStyleSheet->HasParentSupport() ) 542cdf0e10cSrcweir pStyleSheet->SetParent( pSheetInUse->GetName() ); 543cdf0e10cSrcweir 544cdf0e10cSrcweir if ( bConvertBack ) 545cdf0e10cSrcweir // Namen zu Style-Pointer 546cdf0e10cSrcweir pDoc->UpdStlShtPtrsFrmNms(); 547cdf0e10cSrcweir else 548cdf0e10cSrcweir pDoc->GetPool()->CellStyleCreated( aStyleName ); 549cdf0e10cSrcweir 550cdf0e10cSrcweir // Attribute uebernehmen und Style anwenden 551cdf0e10cSrcweir pStyleSheet->GetItemSet().Put( aAttrSet ); 552cdf0e10cSrcweir pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 553cdf0e10cSrcweir 554cdf0e10cSrcweir // call SetStyleSheetToMarked after adding the ScUndoModifyStyle 555cdf0e10cSrcweir // (pStyleSheet pointer is used!) 556cdf0e10cSrcweir bStyleToMarked = sal_True; 557cdf0e10cSrcweir } 558cdf0e10cSrcweir else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked(); 561cdf0e10cSrcweir 562cdf0e10cSrcweir if ( pStyleSheet ) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir aOldData.InitFromStyle( pStyleSheet ); 565cdf0e10cSrcweir 566cdf0e10cSrcweir if ( bUndo ) 567cdf0e10cSrcweir { 568cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE ); 569cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 570cdf0e10cSrcweir bListAction = sal_True; 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir pStyleSheet->GetItemSet().Put( aAttrSet ); 574cdf0e10cSrcweir pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 575cdf0e10cSrcweir 576cdf0e10cSrcweir // call SetStyleSheetToMarked after adding the ScUndoModifyStyle 577cdf0e10cSrcweir // (pStyleSheet pointer is used!) 578cdf0e10cSrcweir bStyleToMarked = sal_True; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir } 581cdf0e10cSrcweir 582cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet ); 583cdf0e10cSrcweir bAddUndo = sal_True; 584cdf0e10cSrcweir rReq.Done(); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir break; 587cdf0e10cSrcweir 588cdf0e10cSrcweir default: 589cdf0e10cSrcweir break; 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } // case SFX_STYLE_FAMILY_PARA: 592cdf0e10cSrcweir break; 593cdf0e10cSrcweir 594cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: 595cdf0e10cSrcweir { 596cdf0e10cSrcweir switch ( nSlotId ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir case SID_STYLE_DELETE: 599cdf0e10cSrcweir { 600cdf0e10cSrcweir nRetMask = ( NULL != pStyleSheet ); 601cdf0e10cSrcweir if ( pStyleSheet ) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nCurTab ).UpdatePages(); 606cdf0e10cSrcweir rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 607cdf0e10cSrcweir rBindings.Invalidate( FID_RESET_PRINTZOOM ); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir pStylePool->Remove( pStyleSheet ); 610cdf0e10cSrcweir rBindings.Invalidate( SID_STYLE_FAMILY4 ); 611cdf0e10cSrcweir pDocSh->SetDocumentModified(); 612cdf0e10cSrcweir bAddUndo = sal_True; 613cdf0e10cSrcweir rReq.Done(); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir } 616cdf0e10cSrcweir break; 617cdf0e10cSrcweir 618cdf0e10cSrcweir case SID_STYLE_APPLY: 619cdf0e10cSrcweir { 620cdf0e10cSrcweir nRetMask = ( NULL != pStyleSheet ); 621cdf0e10cSrcweir if ( pStyleSheet && !pScMod->GetIsWaterCan() ) 622cdf0e10cSrcweir { 623cdf0e10cSrcweir ScUndoApplyPageStyle* pUndoAction = 0; 624cdf0e10cSrcweir for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab ) 625cdf0e10cSrcweir { 626cdf0e10cSrcweir if( rMark.GetTableSelect( nTab ) ) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir String aOldName = pDoc->GetPageStyle( nTab ); 629cdf0e10cSrcweir if ( aOldName != aStyleName ) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir pDoc->SetPageStyle( nTab, aStyleName ); 632cdf0e10cSrcweir ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nTab ).UpdatePages(); 633cdf0e10cSrcweir if( !pUndoAction ) 634cdf0e10cSrcweir pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName ); 635cdf0e10cSrcweir pUndoAction->AddSheetAction( nTab, aOldName ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir } 638cdf0e10cSrcweir } 639cdf0e10cSrcweir if( pUndoAction ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir pDocSh->GetUndoManager()->AddUndoAction( pUndoAction ); 642cdf0e10cSrcweir pDocSh->SetDocumentModified(); 643cdf0e10cSrcweir rBindings.Invalidate( SID_STYLE_FAMILY4 ); 644cdf0e10cSrcweir rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 645cdf0e10cSrcweir rBindings.Invalidate( FID_RESET_PRINTZOOM ); 646cdf0e10cSrcweir } 647cdf0e10cSrcweir rReq.Done(); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir break; 651cdf0e10cSrcweir 652cdf0e10cSrcweir case SID_STYLE_NEW_BY_EXAMPLE: 653cdf0e10cSrcweir { 654cdf0e10cSrcweir const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab ); 655cdf0e10cSrcweir 656cdf0e10cSrcweir if ( rStrCurStyle != aStyleName ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily ); 659cdf0e10cSrcweir SfxItemSet aAttrSet = pCurStyle->GetItemSet(); 660cdf0e10cSrcweir SCTAB nInTab; 661cdf0e10cSrcweir sal_Bool bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab ); 662cdf0e10cSrcweir 663cdf0e10cSrcweir // wenn bereits vorhanden, erstmal entfernen... 664cdf0e10cSrcweir if ( pStyleSheet ) 665cdf0e10cSrcweir pStylePool->Remove( pStyleSheet ); 666cdf0e10cSrcweir 667cdf0e10cSrcweir // ...und neu anlegen 668cdf0e10cSrcweir pStyleSheet = &pStylePool->Make( aStyleName, eFamily, 669cdf0e10cSrcweir SFXSTYLEBIT_USERDEF ); 670cdf0e10cSrcweir 671cdf0e10cSrcweir // Attribute uebernehmen 672cdf0e10cSrcweir pStyleSheet->GetItemSet().Put( aAttrSet ); 673cdf0e10cSrcweir pDocSh->SetDocumentModified(); 674cdf0e10cSrcweir 675cdf0e10cSrcweir // wenn in Verwendung -> Update 676cdf0e10cSrcweir if ( bUsed ) 677cdf0e10cSrcweir ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nInTab ).UpdatePages(); 678cdf0e10cSrcweir 679cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet ); 680cdf0e10cSrcweir bAddUndo = sal_True; 681cdf0e10cSrcweir rReq.Done(); 682cdf0e10cSrcweir nRetMask = sal_True; 683cdf0e10cSrcweir } 684cdf0e10cSrcweir } 685cdf0e10cSrcweir break; 686cdf0e10cSrcweir 687cdf0e10cSrcweir default: 688cdf0e10cSrcweir break; 689cdf0e10cSrcweir } // switch ( nSlotId ) 690cdf0e10cSrcweir } // case SFX_STYLE_FAMILY_PAGE: 691cdf0e10cSrcweir break; 692cdf0e10cSrcweir 693cdf0e10cSrcweir default: 694cdf0e10cSrcweir break; 695cdf0e10cSrcweir } // switch ( eFamily ) 696cdf0e10cSrcweir 697cdf0e10cSrcweir // Neu anlegen oder bearbeiten ueber Dialog: 698cdf0e10cSrcweir if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir if ( pStyleSheet ) 701cdf0e10cSrcweir { 702cdf0e10cSrcweir SvxNumberInfoItem* pNumberInfoItem = NULL; 703cdf0e10cSrcweir 704cdf0e10cSrcweir SfxStyleFamily eFam = pStyleSheet->GetFamily(); 705cdf0e10cSrcweir // ScDocument* pDoc = GetViewData()->GetDocument(); 706cdf0e10cSrcweir // ScDocShell* pDocSh = GetViewData()->GetDocShell(); 707cdf0e10cSrcweir //CHINA001 ScStyleDlg* pDlg = NULL; 708cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = NULL; //CHINA001 709cdf0e10cSrcweir sal_uInt16 nRsc = 0; 710cdf0e10cSrcweir 711cdf0e10cSrcweir // #37034#/#37245# alte Items aus der Vorlage merken 712cdf0e10cSrcweir SfxItemSet aOldSet = pStyleSheet->GetItemSet(); 713cdf0e10cSrcweir String aOldName = pStyleSheet->GetName(); 714cdf0e10cSrcweir 715cdf0e10cSrcweir switch ( eFam ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: 718cdf0e10cSrcweir nRsc = RID_SCDLG_STYLES_PAGE; 719cdf0e10cSrcweir break; 720cdf0e10cSrcweir 721cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: 722cdf0e10cSrcweir default: 723cdf0e10cSrcweir { 724cdf0e10cSrcweir SfxItemSet& rSet = pStyleSheet->GetItemSet(); 725cdf0e10cSrcweir 726cdf0e10cSrcweir const SfxPoolItem* pItem; 727cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_VALUE_FORMAT, 728cdf0e10cSrcweir sal_False, &pItem ) == SFX_ITEM_SET ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir // NumberFormat Value aus Value und Language 731cdf0e10cSrcweir // erzeugen und eintueten 732cdf0e10cSrcweir sal_uLong nFormat = 733cdf0e10cSrcweir ((SfxUInt32Item*)pItem)->GetValue(); 734cdf0e10cSrcweir LanguageType eLang = 735cdf0e10cSrcweir ((SvxLanguageItem*)&rSet.Get( 736cdf0e10cSrcweir ATTR_LANGUAGE_FORMAT ))->GetLanguage(); 737cdf0e10cSrcweir sal_uLong nLangFormat = pDoc->GetFormatTable()-> 738cdf0e10cSrcweir GetFormatForLanguageIfBuiltIn( nFormat, eLang ); 739cdf0e10cSrcweir if ( nLangFormat != nFormat ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat ); 742cdf0e10cSrcweir rSet.Put( aNewItem ); 743cdf0e10cSrcweir aOldSet.Put( aNewItem ); 744cdf0e10cSrcweir // auch in aOldSet fuer Vergleich nach dem Dialog, 745cdf0e10cSrcweir // sonst geht evtl. eine Aenderung der Sprache verloren 746cdf0e10cSrcweir } 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem ); 750cdf0e10cSrcweir pDocSh->PutItem( *pNumberInfoItem ); 751cdf0e10cSrcweir nRsc = RID_SCDLG_STYLES_PAR; 752cdf0e10cSrcweir 753cdf0e10cSrcweir // auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set: 754cdf0e10cSrcweir // (wenn gar kein Item da ist, loescht der Dialog auch das 755cdf0e10cSrcweir // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set) 756cdf0e10cSrcweir 757cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_BORDER_INNER, sal_False ) != SFX_ITEM_SET ) 758cdf0e10cSrcweir { 759cdf0e10cSrcweir SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); 760cdf0e10cSrcweir aBoxInfoItem.SetTable(sal_False); // keine inneren Linien 761cdf0e10cSrcweir aBoxInfoItem.SetDist(sal_True); 762cdf0e10cSrcweir aBoxInfoItem.SetMinDist(sal_False); 763cdf0e10cSrcweir rSet.Put( aBoxInfoItem ); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir } 766cdf0e10cSrcweir break; 767cdf0e10cSrcweir } 768cdf0e10cSrcweir 769cdf0e10cSrcweir // If GetDefDialogParent is a dialog, it must be used 770cdf0e10cSrcweir // (style catalog) 771cdf0e10cSrcweir 772cdf0e10cSrcweir Window* pParent = Application::GetDefDialogParent(); 773cdf0e10cSrcweir if ( !pParent || !pParent->IsDialog() ) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir // #107256# GetDefDialogParent currently doesn't return the window 776cdf0e10cSrcweir // that was set with SetDefDialogParent (but dynamically finds the 777cdf0e10cSrcweir // topmost parent of the focus window), so IsDialog above is FALSE 778cdf0e10cSrcweir // even if called from the style catalog. 779cdf0e10cSrcweir // -> Use NULL if a modal dialog is open, to enable the Dialog's 780cdf0e10cSrcweir // default parent handling. 781cdf0e10cSrcweir if ( Application::IsInModalMode() ) 782cdf0e10cSrcweir pParent = NULL; 783cdf0e10cSrcweir else 784cdf0e10cSrcweir pParent = pTabViewShell->GetDialogParent(); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir pTabViewShell->SetInFormatDialog(sal_True); 788cdf0e10cSrcweir 789cdf0e10cSrcweir //CHINA001 pDlg = new ScStyleDlg( pParent, *pStyleSheet, nRsc ); 790cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 791cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 792cdf0e10cSrcweir 793cdf0e10cSrcweir pDlg = pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc ); 794cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 795cdf0e10cSrcweir short nResult = pDlg->Execute(); 796cdf0e10cSrcweir pTabViewShell->SetInFormatDialog(sal_False); 797cdf0e10cSrcweir 798cdf0e10cSrcweir if ( nResult == RET_OK ) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 801cdf0e10cSrcweir 802cdf0e10cSrcweir if ( pOutSet ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir nRetMask = pStyleSheet->GetMask(); 805cdf0e10cSrcweir 806cdf0e10cSrcweir // #37034#/#37245# Attribut-Vergleiche (frueher in ModifyStyleSheet) 807cdf0e10cSrcweir // jetzt hier mit den alten Werten (Style ist schon veraendert) 808cdf0e10cSrcweir 809cdf0e10cSrcweir if ( SFX_STYLE_FAMILY_PARA == eFam ) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir // pDoc->CellStyleChanged( *pStyleSheet, aOldSet ); 812cdf0e10cSrcweir 813cdf0e10cSrcweir SfxItemSet& rNewSet = pStyleSheet->GetItemSet(); 814cdf0e10cSrcweir sal_Bool bNumFormatChanged; 815cdf0e10cSrcweir if ( ScGlobal::CheckWidthInvalidate( 816cdf0e10cSrcweir bNumFormatChanged, aOldSet, rNewSet ) ) 817cdf0e10cSrcweir pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged ); 818cdf0e10cSrcweir 819cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 820cdf0e10cSrcweir for (SCTAB nTab=0; nTab<nTabCount; nTab++) 821cdf0e10cSrcweir if (pDoc->IsStreamValid(nTab)) 822cdf0e10cSrcweir pDoc->SetStreamValid(nTab, sal_False); 823cdf0e10cSrcweir 824cdf0e10cSrcweir sal_uLong nOldFormat = ((const SfxUInt32Item&)aOldSet. 825cdf0e10cSrcweir Get( ATTR_VALUE_FORMAT )).GetValue(); 826cdf0e10cSrcweir sal_uLong nNewFormat = ((const SfxUInt32Item&)rNewSet. 827cdf0e10cSrcweir Get( ATTR_VALUE_FORMAT )).GetValue(); 828cdf0e10cSrcweir if ( nNewFormat != nOldFormat ) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 831cdf0e10cSrcweir const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat ); 832cdf0e10cSrcweir const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat ); 833cdf0e10cSrcweir if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() ) 834cdf0e10cSrcweir rNewSet.Put( SvxLanguageItem( 835cdf0e10cSrcweir pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) ); 836cdf0e10cSrcweir } 837cdf0e10cSrcweir 838cdf0e10cSrcweir pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() ); 839cdf0e10cSrcweir } 840cdf0e10cSrcweir else 841cdf0e10cSrcweir { 842cdf0e10cSrcweir //! auch fuer Seitenvorlagen die Abfragen hier 843cdf0e10cSrcweir 844cdf0e10cSrcweir String aNewName = pStyleSheet->GetName(); 845cdf0e10cSrcweir if ( aNewName != aOldName && 846cdf0e10cSrcweir pDoc->RenamePageStyleInUse( aOldName, aNewName ) ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 849cdf0e10cSrcweir rBindings.Invalidate( FID_RESET_PRINTZOOM ); 850cdf0e10cSrcweir } 851cdf0e10cSrcweir 852cdf0e10cSrcweir pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet ); 853cdf0e10cSrcweir rBindings.Invalidate( FID_RESET_PRINTZOOM ); 854cdf0e10cSrcweir } 855cdf0e10cSrcweir 856cdf0e10cSrcweir pDocSh->SetDocumentModified(); 857cdf0e10cSrcweir 858cdf0e10cSrcweir if ( SFX_STYLE_FAMILY_PARA == eFam ) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir pTabViewShell->UpdateNumberFormatter( pDoc, 861cdf0e10cSrcweir (const SvxNumberInfoItem&) 862cdf0e10cSrcweir *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) ); 863cdf0e10cSrcweir 864cdf0e10cSrcweir pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 865cdf0e10cSrcweir pTabViewShell->InvalidateAttribs(); 866cdf0e10cSrcweir } 867cdf0e10cSrcweir 868cdf0e10cSrcweir aNewData.InitFromStyle( pStyleSheet ); 869cdf0e10cSrcweir bAddUndo = sal_True; 870cdf0e10cSrcweir } 871cdf0e10cSrcweir } 872cdf0e10cSrcweir else 873cdf0e10cSrcweir { 874cdf0e10cSrcweir if ( nSlotId == SID_STYLE_NEW ) 875cdf0e10cSrcweir pStylePool->Remove( pStyleSheet ); 876cdf0e10cSrcweir else 877cdf0e10cSrcweir { 878cdf0e10cSrcweir // falls zwischendurch etwas mit dem temporaer geaenderten 879cdf0e10cSrcweir // ItemSet gepainted wurde: 880cdf0e10cSrcweir pDocSh->PostPaintGridAll(); 881cdf0e10cSrcweir } 882cdf0e10cSrcweir } 883cdf0e10cSrcweir delete pDlg; 884cdf0e10cSrcweir } 885cdf0e10cSrcweir } 886cdf0e10cSrcweir 887cdf0e10cSrcweir // if ( nRetMask != 0xffff )// Irgendein Wert MUSS geliefert werden JN 888cdf0e10cSrcweir rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) ); 889cdf0e10cSrcweir 890cdf0e10cSrcweir // #96983# only stylist sends focus to sheet 891cdf0e10cSrcweir // if ( bGrabFocus ) 892cdf0e10cSrcweir // pTabViewShell->GetActiveWin()->GrabFocus(); 893cdf0e10cSrcweir 894cdf0e10cSrcweir if ( bAddUndo && bUndo) 895cdf0e10cSrcweir pDocSh->GetUndoManager()->AddUndoAction( 896cdf0e10cSrcweir new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) ); 897cdf0e10cSrcweir 898cdf0e10cSrcweir if ( bStyleToMarked ) 899cdf0e10cSrcweir { 900cdf0e10cSrcweir // call SetStyleSheetToMarked after adding the ScUndoModifyStyle, 901cdf0e10cSrcweir // so redo will find the modified style 902cdf0e10cSrcweir pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); 903cdf0e10cSrcweir pTabViewShell->InvalidateAttribs(); 904cdf0e10cSrcweir } 905cdf0e10cSrcweir 906cdf0e10cSrcweir if ( bListAction ) 907cdf0e10cSrcweir pDocSh->GetUndoManager()->LeaveListAction(); 908cdf0e10cSrcweir } 909cdf0e10cSrcweir else 910cdf0e10cSrcweir { 911cdf0e10cSrcweir DBG_ERROR( "Unknown slot (ScViewShell::ExecuteStyle)" ); 912cdf0e10cSrcweir } 913cdf0e10cSrcweir } 914cdf0e10cSrcweir 915cdf0e10cSrcweir void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) 916cdf0e10cSrcweir { 917cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 918cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 919cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 920cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 921cdf0e10cSrcweir 922cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 923cdf0e10cSrcweir 924cdf0e10cSrcweir // Eingabe beenden 925cdf0e10cSrcweir if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) 926cdf0e10cSrcweir { 927cdf0e10cSrcweir switch ( nSlot ) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir case SID_NUMBER_TWODEC: 930cdf0e10cSrcweir case SID_NUMBER_SCIENTIFIC: 931cdf0e10cSrcweir case SID_NUMBER_DATE: 932cdf0e10cSrcweir case SID_NUMBER_CURRENCY: 933cdf0e10cSrcweir case SID_NUMBER_PERCENT: 934cdf0e10cSrcweir case SID_NUMBER_STANDARD: 935cdf0e10cSrcweir case SID_NUMBER_FORMAT: 936cdf0e10cSrcweir case SID_NUMBER_INCDEC: 937cdf0e10cSrcweir case SID_NUMBER_DECDEC: 938cdf0e10cSrcweir case FID_DEFINE_NAME: 939cdf0e10cSrcweir case FID_USE_NAME: 940cdf0e10cSrcweir case FID_INSERT_NAME: 941cdf0e10cSrcweir case SID_SPELL_DIALOG: 942cdf0e10cSrcweir case SID_HANGUL_HANJA_CONVERSION: 943cdf0e10cSrcweir 944cdf0e10cSrcweir pScMod->InputEnterHandler(); 945cdf0e10cSrcweir pTabViewShell->UpdateInputHandler(); 946cdf0e10cSrcweir break; 947cdf0e10cSrcweir 948cdf0e10cSrcweir default: 949cdf0e10cSrcweir break; 950cdf0e10cSrcweir } 951cdf0e10cSrcweir } 952cdf0e10cSrcweir 953cdf0e10cSrcweir switch ( nSlot ) 954cdf0e10cSrcweir { 955cdf0e10cSrcweir case SID_NUMBER_TWODEC: 956cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 ); // Standard+4 = #.##0,00 957cdf0e10cSrcweir rReq.Done(); 958cdf0e10cSrcweir break; 959cdf0e10cSrcweir case SID_NUMBER_SCIENTIFIC: 960cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC ); 961cdf0e10cSrcweir rReq.Done(); 962cdf0e10cSrcweir break; 963cdf0e10cSrcweir case SID_NUMBER_DATE: 964cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE ); 965cdf0e10cSrcweir rReq.Done(); 966cdf0e10cSrcweir break; 967cdf0e10cSrcweir case SID_NUMBER_TIME: 968cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME ); 969cdf0e10cSrcweir rReq.Done(); 970cdf0e10cSrcweir break; 971cdf0e10cSrcweir case SID_NUMBER_CURRENCY: 972cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY ); 973cdf0e10cSrcweir rReq.Done(); 974cdf0e10cSrcweir break; 975cdf0e10cSrcweir case SID_NUMBER_PERCENT: 976cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT ); 977cdf0e10cSrcweir rReq.Done(); 978cdf0e10cSrcweir break; 979cdf0e10cSrcweir case SID_NUMBER_STANDARD: 980cdf0e10cSrcweir pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER ); 981cdf0e10cSrcweir rReq.Done(); 982cdf0e10cSrcweir break; 983cdf0e10cSrcweir case SID_NUMBER_INCDEC: 984cdf0e10cSrcweir pTabViewShell->ChangeNumFmtDecimals( sal_True ); 985cdf0e10cSrcweir rReq.Done(); 986cdf0e10cSrcweir break; 987cdf0e10cSrcweir case SID_NUMBER_DECDEC: 988cdf0e10cSrcweir pTabViewShell->ChangeNumFmtDecimals( sal_False ); 989cdf0e10cSrcweir rReq.Done(); 990cdf0e10cSrcweir break; 991cdf0e10cSrcweir 992cdf0e10cSrcweir case SID_NUMBER_FORMAT: 9934e8031e0SArmin Le Grand //if ( pReqArgs ) 9944e8031e0SArmin Le Grand //{ 9954e8031e0SArmin Le Grand // const SfxPoolItem* pItem; 9964e8031e0SArmin Le Grand // if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET) 9974e8031e0SArmin Le Grand // { 9984e8031e0SArmin Le Grand // String aCode = ((const SfxStringItem*)pItem)->GetValue(); 9994e8031e0SArmin Le Grand // pTabViewShell->SetNumFmtByStr( aCode ); 10004e8031e0SArmin Le Grand // } 10014e8031e0SArmin Le Grand //} 10024e8031e0SArmin Le Grand 10034e8031e0SArmin Le Grand // symphony version with format interpretation 1004cdf0e10cSrcweir if(pReqArgs) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir const SfxPoolItem* pItem; 10074e8031e0SArmin Le Grand ScDocument* pDoc = pViewData->GetDocument(); 10084e8031e0SArmin Le Grand SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 10094e8031e0SArmin Le Grand LanguageType eLanguage = ScGlobal::eLnge; 10104e8031e0SArmin Le Grand sal_Int16 eType = -1; 10114e8031e0SArmin Le Grand sal_uInt32 nCurrentNumberFormat; 10124e8031e0SArmin Le Grand 10134e8031e0SArmin Le Grand pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat); 10144e8031e0SArmin Le Grand const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat); 10154e8031e0SArmin Le Grand 10164e8031e0SArmin Le Grand if(pEntry) 10174e8031e0SArmin Le Grand { 10184e8031e0SArmin Le Grand eLanguage = pEntry->GetLanguage(); 10194e8031e0SArmin Le Grand eType = pEntry->GetType(); 10204e8031e0SArmin Le Grand } 10214e8031e0SArmin Le Grand 10224e8031e0SArmin Le Grand //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY 10234e8031e0SArmin Le Grand //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable 10244e8031e0SArmin Le Grand switch(eType) 10254e8031e0SArmin Le Grand { 10264e8031e0SArmin Le Grand case NUMBERFORMAT_ALL: 10274e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER: 10284e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED: 10294e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT: 10304e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED: 10314e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY: 10324e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY|NUMBERFORMAT_DEFINED: 10334e8031e0SArmin Le Grand eType = 0; 10344e8031e0SArmin Le Grand break; 10354e8031e0SArmin Le Grand default: 10364e8031e0SArmin Le Grand eType =-1; 10374e8031e0SArmin Le Grand } 10384e8031e0SArmin Le Grand 10394e8031e0SArmin Le Grand if(SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1) 1040cdf0e10cSrcweir { 1041cdf0e10cSrcweir String aCode = ((const SfxStringItem*)pItem)->GetValue(); 10424e8031e0SArmin Le Grand sal_uInt16 aLen = aCode.Len(); 10434e8031e0SArmin Le Grand String* sFormat = new String[4]; 10444e8031e0SArmin Le Grand String sTmpStr = String::CreateFromAscii(""); 10454e8031e0SArmin Le Grand sal_uInt16 nCount(0); 10464e8031e0SArmin Le Grand sal_uInt16 nStrCount(0); 10474e8031e0SArmin Le Grand 10484e8031e0SArmin Le Grand while(nCount < aLen) 10494e8031e0SArmin Le Grand { 10504e8031e0SArmin Le Grand sal_Unicode cChar = aCode.GetChar(nCount); 10514e8031e0SArmin Le Grand 10524e8031e0SArmin Le Grand if(cChar == sal_Unicode(',')) 10534e8031e0SArmin Le Grand { 10544e8031e0SArmin Le Grand sFormat[nStrCount] = sTmpStr; 10554e8031e0SArmin Le Grand sTmpStr = String::CreateFromAscii(""); 10564e8031e0SArmin Le Grand nStrCount++; 10574e8031e0SArmin Le Grand } 10584e8031e0SArmin Le Grand else 10594e8031e0SArmin Le Grand { 10604e8031e0SArmin Le Grand sTmpStr += cChar; 10614e8031e0SArmin Le Grand } 10624e8031e0SArmin Le Grand 10634e8031e0SArmin Le Grand nCount++; 10644e8031e0SArmin Le Grand 10654e8031e0SArmin Le Grand if(nStrCount > 3) 10664e8031e0SArmin Le Grand break; 10674e8031e0SArmin Le Grand } 10684e8031e0SArmin Le Grand 10694e8031e0SArmin Le Grand const sal_Bool bThousand = (sal_Bool)sFormat[0].ToInt32(); 10704e8031e0SArmin Le Grand const sal_Bool bNegRed = (sal_Bool)sFormat[1].ToInt32(); 10714e8031e0SArmin Le Grand const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].ToInt32(); 10724e8031e0SArmin Le Grand const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].ToInt32(); 10734e8031e0SArmin Le Grand 10744e8031e0SArmin Le Grand pFormatter->GenerateFormat( 10754e8031e0SArmin Le Grand aCode, 10764e8031e0SArmin Le Grand nCurrentNumberFormat,//modify 10774e8031e0SArmin Le Grand eLanguage, 10784e8031e0SArmin Le Grand bThousand, 10794e8031e0SArmin Le Grand bNegRed, 10804e8031e0SArmin Le Grand nPrecision, 10814e8031e0SArmin Le Grand nLeadZeroes); 1082cdf0e10cSrcweir pTabViewShell->SetNumFmtByStr(aCode); 10834e8031e0SArmin Le Grand delete[] sFormat; 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir break; 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir case SID_ATTR_NUMBERFORMAT_VALUE: 1089cdf0e10cSrcweir if ( pReqArgs ) 1090cdf0e10cSrcweir { 1091cdf0e10cSrcweir const SfxPoolItem* pItem; 1092cdf0e10cSrcweir if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET ) 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir // We have to accomplish this using ApplyAttributes() 1095cdf0e10cSrcweir // because we also need the language information to be 1096cdf0e10cSrcweir // considered. 1097cdf0e10cSrcweir const SfxItemSet& rOldSet = 1098cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()->GetItemSet(); 1099cdf0e10cSrcweir SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool(); 1100cdf0e10cSrcweir SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END ); 1101cdf0e10cSrcweir aNewSet.Put( *pItem ); 1102cdf0e10cSrcweir pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True ); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir break; 1106cdf0e10cSrcweir 11074e8031e0SArmin Le Grand case SID_NUMBER_TYPE_FORMAT: 11084e8031e0SArmin Le Grand { 11094e8031e0SArmin Le Grand SfxInt16Item aFormatItem((const SfxInt16Item&)rReq.GetArgs()->Get(nSlot)); 11104e8031e0SArmin Le Grand sal_uInt16 nFormat = aFormatItem.GetValue(); 11114e8031e0SArmin Le Grand switch(nFormat) 11124e8031e0SArmin Le Grand { 11134e8031e0SArmin Le Grand case 0: 11144e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER); //Modify 11154e8031e0SArmin Le Grand break; 11164e8031e0SArmin Le Grand case 1: 11174e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 2 ); //Modify 11184e8031e0SArmin Le Grand break; 11194e8031e0SArmin Le Grand case 2: 11204e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT ); 11214e8031e0SArmin Le Grand break; 11224e8031e0SArmin Le Grand case 3: 11234e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY ); 11244e8031e0SArmin Le Grand break; 11254e8031e0SArmin Le Grand case 4: 11264e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE ); 11274e8031e0SArmin Le Grand break; 11284e8031e0SArmin Le Grand case 5: 11294e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME ); 11304e8031e0SArmin Le Grand break; 11314e8031e0SArmin Le Grand case 6: 11324e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC ); 11334e8031e0SArmin Le Grand break; 11344e8031e0SArmin Le Grand case 7: 11354e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_FRACTION ); 11364e8031e0SArmin Le Grand break; 11374e8031e0SArmin Le Grand case 8: 11384e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_LOGICAL ); 11394e8031e0SArmin Le Grand break; 11404e8031e0SArmin Le Grand case 9: 11414e8031e0SArmin Le Grand pTabViewShell->SetNumberFormat( NUMBERFORMAT_TEXT ); 11424e8031e0SArmin Le Grand break; 11434e8031e0SArmin Le Grand default: 11444e8031e0SArmin Le Grand ; 11454e8031e0SArmin Le Grand } 11464e8031e0SArmin Le Grand rReq.Done(); 11474e8031e0SArmin Le Grand } 11484e8031e0SArmin Le Grand break; 11494e8031e0SArmin Le Grand 1150cdf0e10cSrcweir default: 1151cdf0e10cSrcweir DBG_ERROR("falscher Slot bei ExecuteEdit"); 1152cdf0e10cSrcweir break; 1153cdf0e10cSrcweir } 1154cdf0e10cSrcweir } 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir //------------------------------------------------------------------ 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir #define APPLY_HOR_JUSTIFY(j) \ 1160cdf0e10cSrcweir { \ 1161cdf0e10cSrcweir if ( !pHorJustify || (eHorJustify != (j) ) ) \ 1162cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \ 1163cdf0e10cSrcweir else \ 1164cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \ 1165cdf0e10cSrcweir } 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir #define APPLY_VER_JUSTIFY(j) \ 1168cdf0e10cSrcweir { \ 1169cdf0e10cSrcweir if ( !pVerJustify || (eVerJustify != (j) ) ) \ 1170cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \ 1171cdf0e10cSrcweir else \ 1172cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \ 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir void ScFormatShell::ExecuteAlignment( SfxRequest& rReq ) 1176cdf0e10cSrcweir { 1177cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1178cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 1179cdf0e10cSrcweir const SfxItemSet* pSet = rReq.GetArgs(); 1180cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1181cdf0e10cSrcweir 1182cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1183cdf0e10cSrcweir 1184cdf0e10cSrcweir switch( nSlot ) 1185cdf0e10cSrcweir { 1186cdf0e10cSrcweir // pseudo slots for Format menu 1187cdf0e10cSrcweir case SID_ALIGN_ANY_HDEFAULT: 1188cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT: 1189cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER: 1190cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT: 1191cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED: 1192cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) ); 1193cdf0e10cSrcweir break; 1194cdf0e10cSrcweir case SID_ALIGN_ANY_VDEFAULT: 1195cdf0e10cSrcweir case SID_ALIGN_ANY_TOP: 1196cdf0e10cSrcweir case SID_ALIGN_ANY_VCENTER: 1197cdf0e10cSrcweir case SID_ALIGN_ANY_BOTTOM: 1198cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) ); 1199cdf0e10cSrcweir break; 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir default: 1202cdf0e10cSrcweir if( pSet ) 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 1205cdf0e10cSrcweir if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem ) == SFX_ITEM_SET ) 1206cdf0e10cSrcweir { 1207cdf0e10cSrcweir 1208cdf0e10cSrcweir switch ( nSlot ) 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir case SID_ATTR_ALIGN_HOR_JUSTIFY: 1211cdf0e10cSrcweir case SID_ATTR_ALIGN_VER_JUSTIFY: 1212cdf0e10cSrcweir case SID_ATTR_ALIGN_INDENT: 1213cdf0e10cSrcweir case SID_ATTR_ALIGN_HYPHENATION: 1214cdf0e10cSrcweir case SID_ATTR_ALIGN_DEGREES: 1215cdf0e10cSrcweir case SID_ATTR_ALIGN_LOCKPOS: 1216cdf0e10cSrcweir case SID_ATTR_ALIGN_MARGIN: 1217cdf0e10cSrcweir case SID_ATTR_ALIGN_STACKED: 1218cdf0e10cSrcweir pTabViewShell->ApplyAttr( *pItem ); 1219cdf0e10cSrcweir break; 1220cdf0e10cSrcweir 1221cdf0e10cSrcweir case SID_H_ALIGNCELL: 1222cdf0e10cSrcweir { 1223cdf0e10cSrcweir SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue(); 1224cdf0e10cSrcweir // #i78476# update alignment of text in cell edit mode 1225cdf0e10cSrcweir pTabViewShell->UpdateInputHandlerCellAdjust( eJust ); 1226cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) ); 1227cdf0e10cSrcweir } 1228cdf0e10cSrcweir break; 1229cdf0e10cSrcweir case SID_V_ALIGNCELL: 1230cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) ); 1231cdf0e10cSrcweir break; 1232cdf0e10cSrcweir default: 1233cdf0e10cSrcweir DBG_ERROR( "ExecuteAlignment: invalid slot" ); 1234cdf0e10cSrcweir return; 1235cdf0e10cSrcweir } 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir } 1238cdf0e10cSrcweir } 1239*512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT ); 1240*512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT ); 1241*512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK ); 1242*512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER); 1243cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNLEFT ); 1244cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNRIGHT ); 1245cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNCENTERHOR ); 1246cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNBLOCK ); 1247cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNTOP ); 1248cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNBOTTOM ); 1249cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNCENTERVER ); 1250cdf0e10cSrcweir rBindings.Invalidate( SID_V_ALIGNCELL ); 1251cdf0e10cSrcweir rBindings.Invalidate( SID_H_ALIGNCELL ); 1252cdf0e10cSrcweir // pseudo slots for Format menu 1253cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT ); 1254cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_LEFT ); 1255cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_HCENTER ); 1256cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_RIGHT ); 1257cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED ); 1258cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT ); 1259cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_TOP ); 1260cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_VCENTER ); 1261cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM ); 1262cdf0e10cSrcweir rBindings.Update(); 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir if( ! rReq.IsAPI() ) 1265cdf0e10cSrcweir rReq.Done(); 1266cdf0e10cSrcweir } 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq ) 1269cdf0e10cSrcweir { 1270cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1271cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 1272cdf0e10cSrcweir const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); 1273cdf0e10cSrcweir const SfxItemSet* pSet = rReq.GetArgs(); 1274cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1275cdf0e10cSrcweir SfxAllItemSet* pNewSet = 0; 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir if ( (nSlot == SID_ATTR_CHAR_WEIGHT) 1280cdf0e10cSrcweir ||(nSlot == SID_ATTR_CHAR_POSTURE) 1281cdf0e10cSrcweir ||(nSlot == SID_ATTR_CHAR_UNDERLINE) 1282cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_NONE) 1283cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_SINGLE) 1284cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_DOUBLE) 1285cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_DOTTED) ) 1286cdf0e10cSrcweir { 1287cdf0e10cSrcweir pNewSet = new SfxAllItemSet( GetPool() ); 1288cdf0e10cSrcweir 1289cdf0e10cSrcweir switch ( nSlot ) 1290cdf0e10cSrcweir { 1291cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT: 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 1294cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 1297cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 1298cdf0e10cSrcweir if ( pSet ) 1299cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) ); 1300cdf0e10cSrcweir else 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir // toggle manually 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir FontWeight eWeight = WEIGHT_BOLD; 1305cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 1306cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False ); 1307cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 1308cdf0e10cSrcweir if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD ) 1309cdf0e10cSrcweir eWeight = WEIGHT_NORMAL; 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) ); 1312cdf0e10cSrcweir } 1313cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1314cdf0e10cSrcweir pNewSet->Put( aSetItem.GetItemSet(), sal_False ); 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir break; 1317cdf0e10cSrcweir 1318cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE: 1319cdf0e10cSrcweir { 1320cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 1321cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 1324cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 1325cdf0e10cSrcweir if ( pSet ) 1326cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) ); 1327cdf0e10cSrcweir else 1328cdf0e10cSrcweir { 1329cdf0e10cSrcweir // toggle manually 1330cdf0e10cSrcweir 1331cdf0e10cSrcweir FontItalic eItalic = ITALIC_NORMAL; 1332cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 1333cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False ); 1334cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 1335cdf0e10cSrcweir if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL ) 1336cdf0e10cSrcweir eItalic = ITALIC_NONE; 1337cdf0e10cSrcweir 1338cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) ); 1339cdf0e10cSrcweir } 1340cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1341cdf0e10cSrcweir pNewSet->Put( aSetItem.GetItemSet(), sal_False ); 1342cdf0e10cSrcweir } 1343cdf0e10cSrcweir break; 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE: 1346cdf0e10cSrcweir { 1347cdf0e10cSrcweir FontUnderline eUnderline; 1348cdf0e10cSrcweir 1349cdf0e10cSrcweir if( pSet ) 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE ); 1352cdf0e10cSrcweir 1353cdf0e10cSrcweir if( rUnderline.ISA(SvxUnderlineItem) ) 1354cdf0e10cSrcweir { 1355cdf0e10cSrcweir pTabViewShell->ApplyAttr( rUnderline ); 1356cdf0e10cSrcweir pNewSet->Put( rUnderline,rUnderline.Which() ); 1357cdf0e10cSrcweir } 1358cdf0e10cSrcweir else if ( rUnderline.ISA(SvxTextLineItem) ) 1359cdf0e10cSrcweir { 1360cdf0e10cSrcweir // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem) 1361cdf0e10cSrcweir const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline); 1362cdf0e10cSrcweir SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() ); 1363cdf0e10cSrcweir aNewItem.SetColor( rTextLineItem.GetColor() ); 1364cdf0e10cSrcweir pTabViewShell->ApplyAttr( aNewItem ); 1365cdf0e10cSrcweir pNewSet->Put( aNewItem, aNewItem.Which() ); 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir else 1369cdf0e10cSrcweir { 1370cdf0e10cSrcweir SvxUnderlineItem aUnderline( (const SvxUnderlineItem&) 1371cdf0e10cSrcweir pAttrs->GetItem( 1372cdf0e10cSrcweir ATTR_FONT_UNDERLINE ) ); 1373cdf0e10cSrcweir eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle()) 1374cdf0e10cSrcweir ? UNDERLINE_NONE 1375cdf0e10cSrcweir : UNDERLINE_SINGLE; 1376cdf0e10cSrcweir aUnderline.SetLineStyle( eUnderline ); 1377cdf0e10cSrcweir pTabViewShell->ApplyAttr( aUnderline ); 1378cdf0e10cSrcweir pNewSet->Put( aUnderline,aUnderline.Which() ); 1379cdf0e10cSrcweir } 1380cdf0e10cSrcweir } 1381cdf0e10cSrcweir break; 1382cdf0e10cSrcweir 1383cdf0e10cSrcweir case SID_ULINE_VAL_NONE: 1384cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) ); 1385cdf0e10cSrcweir break; 1386cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE: // Toggles 1387cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE: 1388cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED: 1389cdf0e10cSrcweir { 1390cdf0e10cSrcweir FontUnderline eOld = ((const SvxUnderlineItem&) 1391cdf0e10cSrcweir pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle(); 1392cdf0e10cSrcweir FontUnderline eNew = eOld; 1393cdf0e10cSrcweir switch (nSlot) 1394cdf0e10cSrcweir { 1395cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE: 1396cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 1397cdf0e10cSrcweir break; 1398cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE: 1399cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; 1400cdf0e10cSrcweir break; 1401cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED: 1402cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; 1403cdf0e10cSrcweir break; 1404cdf0e10cSrcweir } 1405cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) ); 1406cdf0e10cSrcweir } 1407cdf0e10cSrcweir break; 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir default: 1410cdf0e10cSrcweir break; 1411cdf0e10cSrcweir } 1412cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1413cdf0e10cSrcweir } 1414cdf0e10cSrcweir else 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir /* 1417cdf0e10cSrcweir * "Selbstgemachte" RadioButton-Funktionalitaet 1418cdf0e10cSrcweir * Beim Toggle gibt es den Standard-State, d.h. kein 1419cdf0e10cSrcweir * Button ist gedrueckt 1420cdf0e10cSrcweir */ 1421cdf0e10cSrcweir 1422cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 1423cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 1424cdf0e10cSrcweir const SvxHorJustifyItem* pHorJustify = NULL; 1425cdf0e10cSrcweir const SvxVerJustifyItem* pVerJustify = NULL; 1426cdf0e10cSrcweir SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; 1427cdf0e10cSrcweir SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; 1428cdf0e10cSrcweir 1429cdf0e10cSrcweir if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir pHorJustify = (const SvxHorJustifyItem*)pItem; 1432cdf0e10cSrcweir eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); 1433cdf0e10cSrcweir } 1434cdf0e10cSrcweir if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET) 1435cdf0e10cSrcweir { 1436cdf0e10cSrcweir pVerJustify = (const SvxVerJustifyItem*)pItem; 1437cdf0e10cSrcweir eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); 1438cdf0e10cSrcweir } 1439cdf0e10cSrcweir 1440cdf0e10cSrcweir switch ( nSlot ) 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir case SID_ALIGNLEFT: 1443cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL ); 1444cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem( 1445cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ? 1446cdf0e10cSrcweir SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1447cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1448cdf0e10cSrcweir return; 1449cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT ); 1450cdf0e10cSrcweir //break; 1451cdf0e10cSrcweir 1452cdf0e10cSrcweir case SID_ALIGNRIGHT: 1453cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL ); 1454cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem( 1455cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ? 1456cdf0e10cSrcweir SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1457cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1458cdf0e10cSrcweir return; 1459cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT ); 1460cdf0e10cSrcweir //break; 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir case SID_ALIGNCENTERHOR: 1463cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL ); 1464cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem( 1465cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ? 1466cdf0e10cSrcweir SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1467cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1468cdf0e10cSrcweir return; 1469cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER ); 1470cdf0e10cSrcweir //break; 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir case SID_ALIGNBLOCK: 1473cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL ); 1474cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem( 1475cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ? 1476cdf0e10cSrcweir SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1477cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1478cdf0e10cSrcweir return; 1479cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK ); 1480cdf0e10cSrcweir //break; 1481cdf0e10cSrcweir 1482cdf0e10cSrcweir case SID_ALIGNTOP: 1483cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL ); 1484cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem( 1485cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ? 1486cdf0e10cSrcweir SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1487cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1488cdf0e10cSrcweir return; 1489cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP ); 1490cdf0e10cSrcweir //break; 1491cdf0e10cSrcweir 1492cdf0e10cSrcweir case SID_ALIGNBOTTOM: 1493cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL ); 1494cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem( 1495cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ? 1496cdf0e10cSrcweir SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1497cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1498cdf0e10cSrcweir return; 1499cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM ); 1500cdf0e10cSrcweir //break; 1501cdf0e10cSrcweir 1502cdf0e10cSrcweir case SID_ALIGNCENTERVER: 1503cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL ); 1504cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem( 1505cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ? 1506cdf0e10cSrcweir SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1507cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() ); 1508cdf0e10cSrcweir return; 1509cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER ); 1510cdf0e10cSrcweir //break; 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir default: 1513cdf0e10cSrcweir break; 1514cdf0e10cSrcweir } 1515cdf0e10cSrcweir 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir rBindings.Update(); 1519cdf0e10cSrcweir // rReq.Done(); 1520cdf0e10cSrcweir 1521cdf0e10cSrcweir if( pNewSet ) 1522cdf0e10cSrcweir { 1523cdf0e10cSrcweir rReq.Done( *pNewSet ); 1524cdf0e10cSrcweir delete pNewSet; 1525cdf0e10cSrcweir } 1526cdf0e10cSrcweir else 1527cdf0e10cSrcweir { 1528cdf0e10cSrcweir rReq.Done(); 1529cdf0e10cSrcweir } 1530cdf0e10cSrcweir 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir 1533cdf0e10cSrcweir #undef APPLY_HOR_JUSTIFY 1534cdf0e10cSrcweir #undef APPLY_VER_JUSTIFY 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir //------------------------------------------------------------------ 1537cdf0e10cSrcweir 1538cdf0e10cSrcweir void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) 1539cdf0e10cSrcweir { 1540cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1541cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 1542cdf0e10cSrcweir const SfxItemSet* pNewAttrs = rReq.GetArgs(); 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir if ( !pNewAttrs ) 1547cdf0e10cSrcweir { 1548cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1549cdf0e10cSrcweir 1550cdf0e10cSrcweir switch ( nSlot ) 1551cdf0e10cSrcweir { 1552cdf0e10cSrcweir case SID_ATTR_CHAR_FONT: 1553cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT: 1554cdf0e10cSrcweir pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal 1555cdf0e10cSrcweir break; 1556cdf0e10cSrcweir 1557cdf0e10cSrcweir case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle 1558cdf0e10cSrcweir { 1559cdf0e10cSrcweir const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); 1560cdf0e10cSrcweir sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue(); 1561cdf0e10cSrcweir SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld ); 1562cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBreakItem ); 1563cdf0e10cSrcweir 1564cdf0e10cSrcweir SfxAllItemSet aNewSet( GetPool() ); 1565cdf0e10cSrcweir aNewSet.Put( aBreakItem,aBreakItem.Which() ); 1566cdf0e10cSrcweir rReq.Done( aNewSet ); 1567cdf0e10cSrcweir 1568cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1569cdf0e10cSrcweir } 1570cdf0e10cSrcweir break; 1571cdf0e10cSrcweir 1572cdf0e10cSrcweir case SID_BACKGROUND_COLOR: 1573cdf0e10cSrcweir { 1574cdf0e10cSrcweir // SID_BACKGROUND_COLOR without arguments -> set transparent background 1575cdf0e10cSrcweir 1576cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&) 1577cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()-> 1578cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) ); 1579cdf0e10cSrcweir 1580cdf0e10cSrcweir aBrushItem.SetColor( COL_TRANSPARENT ); 1581cdf0e10cSrcweir 1582cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem ); 1583cdf0e10cSrcweir } 1584cdf0e10cSrcweir break; 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir } 1587cdf0e10cSrcweir else 1588cdf0e10cSrcweir { 1589cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1590cdf0e10cSrcweir 1591cdf0e10cSrcweir switch ( nSlot ) 1592cdf0e10cSrcweir { 1593cdf0e10cSrcweir case SID_ATTR_CHAR_OVERLINE: 1594cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT: 1595cdf0e10cSrcweir case SID_ATTR_ALIGN_LINEBREAK: 1596cdf0e10cSrcweir case SID_ATTR_CHAR_COLOR: 1597cdf0e10cSrcweir case SID_ATTR_CHAR_CONTOUR: 1598cdf0e10cSrcweir case SID_ATTR_CHAR_SHADOWED: 1599cdf0e10cSrcweir case SID_ATTR_CHAR_RELIEF: 1600cdf0e10cSrcweir case SID_SCATTR_PROTECTION : 1601cdf0e10cSrcweir pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) ); 1602cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1603cdf0e10cSrcweir rBindings.Update( nSlot ); 1604cdf0e10cSrcweir break; 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir case SID_ATTR_CHAR_FONT: 1607cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT: 1608cdf0e10cSrcweir { 1609cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 1610cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1611cdf0e10cSrcweir if (nSlot == SID_ATTR_CHAR_FONT) 1612cdf0e10cSrcweir nScript = pTabViewShell->GetSelectionScriptType(); 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 1615cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 1616cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich( nSlot ); 1617cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) ); 1618cdf0e10cSrcweir 1619cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1620cdf0e10cSrcweir 1621cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1622cdf0e10cSrcweir rBindings.Update( nSlot ); 1623cdf0e10cSrcweir } 1624cdf0e10cSrcweir break; 1625cdf0e10cSrcweir 1626cdf0e10cSrcweir case SID_FRAME_LINESTYLE: 1627cdf0e10cSrcweir { 1628cdf0e10cSrcweir // Default-Linie aktualisieren 1629cdf0e10cSrcweir const SvxBorderLine* pLine = 1630cdf0e10cSrcweir ((const SvxLineItem&) 1631cdf0e10cSrcweir pNewAttrs->Get( SID_FRAME_LINESTYLE )). 1632cdf0e10cSrcweir GetLine(); 1633cdf0e10cSrcweir 1634cdf0e10cSrcweir if ( pLine ) 1635cdf0e10cSrcweir { 1636cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1637cdf0e10cSrcweir 1638cdf0e10cSrcweir if ( pDefLine ) 1639cdf0e10cSrcweir { 1640cdf0e10cSrcweir pDefLine->SetOutWidth( pLine->GetOutWidth() ); 1641cdf0e10cSrcweir pDefLine->SetInWidth ( pLine->GetInWidth() ); 1642cdf0e10cSrcweir pDefLine->SetDistance( pLine->GetDistance() ); 1643cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False ); 1644cdf0e10cSrcweir } 1645cdf0e10cSrcweir else 1646cdf0e10cSrcweir { 1647cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( pLine ); 1648cdf0e10cSrcweir pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK ); 1649cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pLine, sal_False ); 1650cdf0e10cSrcweir } 1651cdf0e10cSrcweir } 1652cdf0e10cSrcweir else 1653cdf0e10cSrcweir { 1654cdf0e10cSrcweir Color aColorBlack( COL_BLACK ); 1655cdf0e10cSrcweir SvxBorderLine aDefLine( &aColorBlack, 20, 0, 0 ); 1656cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( &aDefLine ); 1657cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( NULL, sal_False ); 1658cdf0e10cSrcweir } 1659cdf0e10cSrcweir } 1660cdf0e10cSrcweir break; 1661cdf0e10cSrcweir 1662cdf0e10cSrcweir case SID_FRAME_LINECOLOR: 1663cdf0e10cSrcweir { 1664cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1665cdf0e10cSrcweir const Color& rColor = ((const SvxColorItem&) 1666cdf0e10cSrcweir pNewAttrs->Get( SID_FRAME_LINECOLOR )). 1667cdf0e10cSrcweir GetValue(); 1668cdf0e10cSrcweir 1669cdf0e10cSrcweir // Default-Linie aktualisieren 1670cdf0e10cSrcweir if ( pDefLine ) 1671cdf0e10cSrcweir { 1672cdf0e10cSrcweir pDefLine->SetColor( rColor ); 1673cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True ); 1674cdf0e10cSrcweir } 1675cdf0e10cSrcweir else 1676cdf0e10cSrcweir { 1677cdf0e10cSrcweir SvxBorderLine aDefLine( &rColor, 20, 0, 0 ); 1678cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( &aDefLine ); 1679cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False ); 1680cdf0e10cSrcweir } 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir break; 1683cdf0e10cSrcweir 1684cdf0e10cSrcweir case SID_ATTR_BORDER_OUTER: 1685cdf0e10cSrcweir case SID_ATTR_BORDER: 1686cdf0e10cSrcweir { 1687cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1688cdf0e10cSrcweir const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern(); 1689cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument(); 1690cdf0e10cSrcweir SfxItemSet* pOldSet = 1691cdf0e10cSrcweir new SfxItemSet( 1692cdf0e10cSrcweir *(pDoc->GetPool()), 1693cdf0e10cSrcweir ATTR_PATTERN_START, 1694cdf0e10cSrcweir ATTR_PATTERN_END ); 1695cdf0e10cSrcweir SfxItemSet* pNewSet = 1696cdf0e10cSrcweir new SfxItemSet( 1697cdf0e10cSrcweir *(pDoc->GetPool()), 1698cdf0e10cSrcweir ATTR_PATTERN_START, 1699cdf0e10cSrcweir ATTR_PATTERN_END ); 1700cdf0e10cSrcweir const SfxPoolItem& rBorderAttr = 1701cdf0e10cSrcweir pOldAttrs->GetItemSet(). 1702cdf0e10cSrcweir Get( ATTR_BORDER ); 1703cdf0e10cSrcweir 1704cdf0e10cSrcweir // Border-Items vom Controller auswerten: 1705cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 1706cdf0e10cSrcweir 1707cdf0e10cSrcweir if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem ) 1708cdf0e10cSrcweir == SFX_ITEM_SET ) 1709cdf0e10cSrcweir { 1710cdf0e10cSrcweir // #100959# The SvxFrameToolBoxControl toolbox controller uses a default 1711cdf0e10cSrcweir // SvxBorderLine (all widths 0) to mark the lines that should be set. 1712cdf0e10cSrcweir // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0) 1713cdf0e10cSrcweir // or NULL pointers for no lines. 1714cdf0e10cSrcweir // -> Substitute existing lines with pDefLine only if widths are 0. 1715cdf0e10cSrcweir SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem ); 1716cdf0e10cSrcweir if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 ) 1717cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_TOP ); 1718cdf0e10cSrcweir if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 ) 1719cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM ); 1720cdf0e10cSrcweir if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 ) 1721cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT ); 1722cdf0e10cSrcweir if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 ) 1723cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT ); 1724cdf0e10cSrcweir pNewSet->Put( aBoxItem ); 1725cdf0e10cSrcweir rReq.AppendItem( aBoxItem ); 1726cdf0e10cSrcweir } 1727cdf0e10cSrcweir 1728cdf0e10cSrcweir if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem ) 1729cdf0e10cSrcweir == SFX_ITEM_SET ) 1730cdf0e10cSrcweir { 1731cdf0e10cSrcweir SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem ); 1732cdf0e10cSrcweir if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 ) 1733cdf0e10cSrcweir aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI ); 1734cdf0e10cSrcweir if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 ) 1735cdf0e10cSrcweir aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT ); 1736cdf0e10cSrcweir pNewSet->Put( aBoxInfoItem ); 1737cdf0e10cSrcweir rReq.AppendItem( aBoxInfoItem ); 1738cdf0e10cSrcweir } 1739cdf0e10cSrcweir else 1740cdf0e10cSrcweir { 1741cdf0e10cSrcweir SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); 1742cdf0e10cSrcweir aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI ); 1743cdf0e10cSrcweir aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT ); 1744cdf0e10cSrcweir pNewSet->Put( aBoxInfoItem ); 1745cdf0e10cSrcweir } 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir pOldSet->Put( rBorderAttr ); 1748cdf0e10cSrcweir pTabViewShell->ApplyAttributes( pNewSet, pOldSet ); 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir delete pOldSet; 1751cdf0e10cSrcweir delete pNewSet; 1752cdf0e10cSrcweir } 1753cdf0e10cSrcweir break; 1754cdf0e10cSrcweir 1755facb16e7SArmin Le Grand case SID_ATTR_BORDER_DIAG_TLBR: 1756facb16e7SArmin Le Grand case SID_ATTR_BORDER_DIAG_BLTR: 1757facb16e7SArmin Le Grand { 1758facb16e7SArmin Le Grand ScDocument* pDoc = GetViewData()->GetDocument(); 1759facb16e7SArmin Le Grand const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern(); 1760facb16e7SArmin Le Grand SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet()); 1761facb16e7SArmin Le Grand SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet()); 1762facb16e7SArmin Le Grand const SfxPoolItem* pItem = 0; 1763facb16e7SArmin Le Grand 1764facb16e7SArmin Le Grand if(SID_ATTR_BORDER_DIAG_TLBR == nSlot) 1765facb16e7SArmin Le Grand { 1766facb16e7SArmin Le Grand if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem)) 1767facb16e7SArmin Le Grand { 1768facb16e7SArmin Le Grand SvxLineItem aItem(ATTR_BORDER_TLBR); 1769facb16e7SArmin Le Grand aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine()); 1770facb16e7SArmin Le Grand pNewSet->Put(aItem); 1771facb16e7SArmin Le Grand rReq.AppendItem(aItem); 1772facb16e7SArmin Le Grand pTabViewShell->ApplyAttributes(pNewSet, pOldSet); 1773facb16e7SArmin Le Grand } 1774facb16e7SArmin Le Grand } 1775facb16e7SArmin Le Grand else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR ) 1776facb16e7SArmin Le Grand { 1777facb16e7SArmin Le Grand if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem )) 1778facb16e7SArmin Le Grand { 1779facb16e7SArmin Le Grand SvxLineItem aItem(ATTR_BORDER_BLTR); 1780facb16e7SArmin Le Grand aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine()); 1781facb16e7SArmin Le Grand pNewSet->Put(aItem); 1782facb16e7SArmin Le Grand rReq.AppendItem(aItem); 1783facb16e7SArmin Le Grand pTabViewShell->ApplyAttributes(pNewSet, pOldSet); 1784facb16e7SArmin Le Grand } 1785facb16e7SArmin Le Grand } 1786facb16e7SArmin Le Grand 1787facb16e7SArmin Le Grand delete pOldSet; 1788facb16e7SArmin Le Grand delete pNewSet; 1789facb16e7SArmin Le Grand rBindings.Invalidate(nSlot); 1790facb16e7SArmin Le Grand } 1791facb16e7SArmin Le Grand break; 1792facb16e7SArmin Le Grand 1793cdf0e10cSrcweir // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs 1794cdf0e10cSrcweir // gesetzt werden: 1795cdf0e10cSrcweir case SID_BACKGROUND_COLOR: 1796cdf0e10cSrcweir { 1797cdf0e10cSrcweir const SvxColorItem rNewColorItem = (const SvxColorItem&) 1798cdf0e10cSrcweir pNewAttrs->Get( SID_BACKGROUND_COLOR ); 1799cdf0e10cSrcweir 1800cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&) 1801cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()-> 1802cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) ); 1803cdf0e10cSrcweir 1804cdf0e10cSrcweir aBrushItem.SetColor( rNewColorItem.GetValue() ); 1805cdf0e10cSrcweir 1806cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem ); 1807cdf0e10cSrcweir } 1808cdf0e10cSrcweir break; 1809cdf0e10cSrcweir 1810cdf0e10cSrcweir case SID_ATTR_BRUSH: 1811cdf0e10cSrcweir { 1812cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&) 1813cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()-> 1814cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) ); 1815cdf0e10cSrcweir const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&) 1816cdf0e10cSrcweir pNewAttrs->Get( GetPool().GetWhich(nSlot) ); 1817cdf0e10cSrcweir aBrushItem.SetColor(rNewBrushItem.GetColor()); 1818cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem ); 1819cdf0e10cSrcweir } 1820cdf0e10cSrcweir break; 1821cdf0e10cSrcweir 1822cdf0e10cSrcweir case SID_ATTR_BORDER_SHADOW: 1823cdf0e10cSrcweir { 1824cdf0e10cSrcweir const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&) 1825cdf0e10cSrcweir pNewAttrs->Get( ATTR_SHADOW ); 1826cdf0e10cSrcweir pTabViewShell->ApplyAttr( rNewShadowItem ); 1827cdf0e10cSrcweir } 1828cdf0e10cSrcweir break; 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir default: 1831cdf0e10cSrcweir break; 1832cdf0e10cSrcweir } 1833cdf0e10cSrcweir 1834cdf0e10cSrcweir if( ! rReq.IsAPI() ) 1835cdf0e10cSrcweir if( ! rReq.IsDone() ) 1836cdf0e10cSrcweir rReq.Done(); 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir } 1839cdf0e10cSrcweir 1840cdf0e10cSrcweir void ScFormatShell::GetAttrState( SfxItemSet& rSet ) 1841cdf0e10cSrcweir { 1842cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1843cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 1844cdf0e10cSrcweir const SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine(); 1845cdf0e10cSrcweir const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND ); 1846cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 1847cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 1848cdf0e10cSrcweir 1849cdf0e10cSrcweir rSet.Put( rAttrSet, sal_False ); 1850cdf0e10cSrcweir 1851cdf0e10cSrcweir // choose font info according to selection script type 1852cdf0e10cSrcweir sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0 1853cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN ) 1854cdf0e10cSrcweir { 1855cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 1856cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript ); 1857cdf0e10cSrcweir } 1858cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN ) 1859cdf0e10cSrcweir { 1860cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 1861cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript ); 1862cdf0e10cSrcweir } 1863cdf0e10cSrcweir 1864cdf0e10cSrcweir while ( nWhich ) 1865cdf0e10cSrcweir { 1866cdf0e10cSrcweir switch(nWhich) 1867cdf0e10cSrcweir { 1868cdf0e10cSrcweir case SID_BACKGROUND_COLOR: 1869cdf0e10cSrcweir { 1870cdf0e10cSrcweir rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) ); 1871facb16e7SArmin Le Grand 1872facb16e7SArmin Le Grand if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND)) 1873facb16e7SArmin Le Grand { 1874facb16e7SArmin Le Grand rSet.InvalidateItem(SID_BACKGROUND_COLOR); 1875facb16e7SArmin Le Grand } 1876cdf0e10cSrcweir } 1877cdf0e10cSrcweir break; 1878facb16e7SArmin Le Grand case SID_FRAME_LINESTYLE: 1879cdf0e10cSrcweir case SID_FRAME_LINECOLOR: 1880cdf0e10cSrcweir { 1881facb16e7SArmin Le Grand // handled together because both need the cell border information for decisions 1882facb16e7SArmin Le Grand // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) ); 1883facb16e7SArmin Le Grand Color aCol = 0; 1884facb16e7SArmin Le Grand sal_uInt16 nOut = 0, nIn = 0, nDis = 0; 1885facb16e7SArmin Le Grand SvxBorderLine aLine(0,0,0,0); 1886facb16e7SArmin Le Grand bool bCol = 0; 1887facb16e7SArmin Le Grand bool bColDisable = 0, bStyleDisable = 0; 1888facb16e7SArmin Le Grand SvxBoxItem aBoxItem(ATTR_BORDER); 1889facb16e7SArmin Le Grand SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER); 1890facb16e7SArmin Le Grand 1891facb16e7SArmin Le Grand pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem); 1892facb16e7SArmin Le Grand 1893facb16e7SArmin Le Grand if( aBoxItem.GetTop() ) 1894facb16e7SArmin Le Grand { 1895facb16e7SArmin Le Grand bCol = 1; 1896facb16e7SArmin Le Grand aCol = aBoxItem.GetTop()->GetColor() ; 1897facb16e7SArmin Le Grand aLine.SetColor(aCol); 1898facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth()); 1899facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth()); 1900facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetTop()->GetDistance()); 1901facb16e7SArmin Le Grand } 1902facb16e7SArmin Le Grand 1903facb16e7SArmin Le Grand if( aBoxItem.GetBottom() ) 1904facb16e7SArmin Le Grand { 1905facb16e7SArmin Le Grand if(bCol == 0) 1906facb16e7SArmin Le Grand { 1907facb16e7SArmin Le Grand bCol = 1; 1908facb16e7SArmin Le Grand aCol = aBoxItem.GetBottom()->GetColor() ; 1909facb16e7SArmin Le Grand aLine.SetColor(aCol); 1910facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth()); 1911facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth()); 1912facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetBottom()->GetDistance()); 1913facb16e7SArmin Le Grand } 1914facb16e7SArmin Le Grand else 1915facb16e7SArmin Le Grand { 1916facb16e7SArmin Le Grand if(aCol != aBoxItem.GetBottom()->GetColor() ) 1917facb16e7SArmin Le Grand bColDisable = 1; 1918facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetBottom())) ) 1919facb16e7SArmin Le Grand bStyleDisable = 1; 1920facb16e7SArmin Le Grand } 1921facb16e7SArmin Le Grand } 1922facb16e7SArmin Le Grand 1923facb16e7SArmin Le Grand if( aBoxItem.GetLeft() ) 1924facb16e7SArmin Le Grand { 1925facb16e7SArmin Le Grand if(bCol == 0) 1926facb16e7SArmin Le Grand { 1927facb16e7SArmin Le Grand bCol = 1; 1928facb16e7SArmin Le Grand aCol = aBoxItem.GetLeft()->GetColor() ; 1929facb16e7SArmin Le Grand aLine.SetColor(aCol); 1930facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth()); 1931facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth()); 1932facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetLeft()->GetDistance()); 1933facb16e7SArmin Le Grand } 1934facb16e7SArmin Le Grand else 1935facb16e7SArmin Le Grand { 1936facb16e7SArmin Le Grand if(aCol != aBoxItem.GetLeft()->GetColor() ) 1937facb16e7SArmin Le Grand bColDisable = 1; 1938facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetLeft())) ) 1939facb16e7SArmin Le Grand bStyleDisable = 1; 1940facb16e7SArmin Le Grand } 1941facb16e7SArmin Le Grand } 1942facb16e7SArmin Le Grand 1943facb16e7SArmin Le Grand if( aBoxItem.GetRight() ) 1944facb16e7SArmin Le Grand { 1945facb16e7SArmin Le Grand if(bCol == 0) 1946facb16e7SArmin Le Grand { 1947facb16e7SArmin Le Grand bCol = 1; 1948facb16e7SArmin Le Grand aCol = aBoxItem.GetRight()->GetColor() ; 1949facb16e7SArmin Le Grand aLine.SetColor(aCol); 1950facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth()); 1951facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth()); 1952facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetRight()->GetDistance()); 1953facb16e7SArmin Le Grand } 1954facb16e7SArmin Le Grand else 1955facb16e7SArmin Le Grand { 1956facb16e7SArmin Le Grand if(aCol != aBoxItem.GetRight()->GetColor() ) 1957facb16e7SArmin Le Grand bColDisable = 1; 1958facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetRight())) ) 1959facb16e7SArmin Le Grand bStyleDisable = 1; 1960facb16e7SArmin Le Grand } 1961facb16e7SArmin Le Grand } 1962facb16e7SArmin Le Grand 1963facb16e7SArmin Le Grand if( aInfoItem.GetVert()) 1964facb16e7SArmin Le Grand { 1965facb16e7SArmin Le Grand if(bCol == 0) 1966facb16e7SArmin Le Grand { 1967facb16e7SArmin Le Grand bCol = 1; 1968facb16e7SArmin Le Grand aCol = aInfoItem.GetVert()->GetColor() ; 1969facb16e7SArmin Le Grand aLine.SetColor(aCol); 1970facb16e7SArmin Le Grand aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth()); 1971facb16e7SArmin Le Grand aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth()); 1972facb16e7SArmin Le Grand aLine.SetDistance( aInfoItem.GetVert()->GetDistance()); 1973facb16e7SArmin Le Grand } 1974facb16e7SArmin Le Grand else 1975facb16e7SArmin Le Grand { 1976facb16e7SArmin Le Grand if(aCol != aInfoItem.GetVert()->GetColor() ) 1977facb16e7SArmin Le Grand bColDisable = 1; 1978facb16e7SArmin Le Grand if(!( aLine == *(aInfoItem.GetVert())) ) 1979facb16e7SArmin Le Grand bStyleDisable = 1; 1980facb16e7SArmin Le Grand } 1981facb16e7SArmin Le Grand } 1982facb16e7SArmin Le Grand 1983facb16e7SArmin Le Grand if( aInfoItem.GetHori()) 1984facb16e7SArmin Le Grand { 1985facb16e7SArmin Le Grand if(bCol == 0) 1986facb16e7SArmin Le Grand { 1987facb16e7SArmin Le Grand bCol = 1; 1988facb16e7SArmin Le Grand aCol = aInfoItem.GetHori()->GetColor() ; 1989facb16e7SArmin Le Grand aLine.SetColor(aCol); 1990facb16e7SArmin Le Grand aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth()); 1991facb16e7SArmin Le Grand aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth()); 1992facb16e7SArmin Le Grand aLine.SetDistance( aInfoItem.GetHori()->GetDistance()); 1993facb16e7SArmin Le Grand } 1994facb16e7SArmin Le Grand else 1995facb16e7SArmin Le Grand { 1996facb16e7SArmin Le Grand if(aCol != aInfoItem.GetHori()->GetColor() ) 1997facb16e7SArmin Le Grand bColDisable = 1; 1998facb16e7SArmin Le Grand if(!( aLine == *(aInfoItem.GetHori())) ) 1999facb16e7SArmin Le Grand bStyleDisable = 1; 2000facb16e7SArmin Le Grand } 2001facb16e7SArmin Le Grand } 2002facb16e7SArmin Le Grand 2003facb16e7SArmin Le Grand if( !aInfoItem.IsValid( VALID_VERT ) 2004facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_HORI ) 2005facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_LEFT ) 2006facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_RIGHT ) 2007facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_TOP ) 2008facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_BOTTOM ) ) 2009facb16e7SArmin Le Grand { 2010facb16e7SArmin Le Grand bColDisable = 1; 2011facb16e7SArmin Le Grand bStyleDisable = 1; 2012facb16e7SArmin Le Grand } 2013facb16e7SArmin Le Grand 2014facb16e7SArmin Le Grand if(SID_FRAME_LINECOLOR == nWhich) 2015facb16e7SArmin Le Grand { 2016facb16e7SArmin Le Grand if(bColDisable) // if different lines have differernt colors 2017facb16e7SArmin Le Grand { 2018facb16e7SArmin Le Grand aCol = COL_TRANSPARENT; 2019facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2020facb16e7SArmin Le Grand rSet.InvalidateItem(SID_FRAME_LINECOLOR); 2021facb16e7SArmin Le Grand } 2022facb16e7SArmin Le Grand else if( bCol == 0 && bColDisable == 0) // if no line available 2023facb16e7SArmin Le Grand { 2024facb16e7SArmin Le Grand aCol = COL_AUTO; 2025facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2026facb16e7SArmin Le Grand } 2027facb16e7SArmin Le Grand else 2028facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2029facb16e7SArmin Le Grand } 2030facb16e7SArmin Le Grand else // if( nWhich == SID_FRAME_LINESTYLE) 2031facb16e7SArmin Le Grand { 2032facb16e7SArmin Le Grand if(bStyleDisable) // if have several lines but don't have same style 2033facb16e7SArmin Le Grand { 2034facb16e7SArmin Le Grand aLine.SetOutWidth( 1 ); 2035facb16e7SArmin Le Grand aLine.SetInWidth( 0 ); 2036facb16e7SArmin Le Grand aLine.SetDistance( 0 ); 2037facb16e7SArmin Le Grand SvxLineItem aItem(SID_FRAME_LINESTYLE); 2038facb16e7SArmin Le Grand aItem.SetLine(&aLine); 2039facb16e7SArmin Le Grand rSet.Put( aItem ); 2040facb16e7SArmin Le Grand rSet.InvalidateItem(SID_FRAME_LINESTYLE); 2041facb16e7SArmin Le Grand } 2042facb16e7SArmin Le Grand else // all the lines have same style or no line availavle, use initial value (0,0,0,0) 2043facb16e7SArmin Le Grand { 2044facb16e7SArmin Le Grand SvxLineItem aItem(SID_FRAME_LINESTYLE); 2045facb16e7SArmin Le Grand aItem.SetLine(&aLine); 2046facb16e7SArmin Le Grand rSet.Put( aItem ); 2047facb16e7SArmin Le Grand } 2048facb16e7SArmin Le Grand } 2049cdf0e10cSrcweir } 2050cdf0e10cSrcweir break; 2051cdf0e10cSrcweir case SID_ATTR_BRUSH: 2052cdf0e10cSrcweir { 2053cdf0e10cSrcweir rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) ); 2054cdf0e10cSrcweir } 2055cdf0e10cSrcweir break; 2056cdf0e10cSrcweir /* case SID_ATTR_ALIGN_LINEBREAK: 2057cdf0e10cSrcweir { 2058cdf0e10cSrcweir const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK ); 2059cdf0e10cSrcweir rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) ); 2060cdf0e10cSrcweir } 2061cdf0e10cSrcweir break; 2062cdf0e10cSrcweir */ 2063cdf0e10cSrcweir } 2064cdf0e10cSrcweir nWhich = aIter.NextWhich(); 2065cdf0e10cSrcweir } 2066facb16e7SArmin Le Grand 2067facb16e7SArmin Le Grand if(nWhich) 2068facb16e7SArmin Le Grand { 2069facb16e7SArmin Le Grand // stuff for sidebar panels 2070facb16e7SArmin Le Grand Invalidate(SID_ATTR_ALIGN_DEGREES); 2071facb16e7SArmin Le Grand Invalidate(SID_ATTR_ALIGN_STACKED); 2072facb16e7SArmin Le Grand } 2073cdf0e10cSrcweir } 2074cdf0e10cSrcweir 2075cdf0e10cSrcweir //------------------------------------------------------------------ 2076cdf0e10cSrcweir 2077cdf0e10cSrcweir void ScFormatShell::GetTextAttrState( SfxItemSet& rSet ) 2078cdf0e10cSrcweir { 2079cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2080cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2081cdf0e10cSrcweir rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren 2082cdf0e10cSrcweir 2083cdf0e10cSrcweir // choose font info according to selection script type 2084cdf0e10cSrcweir sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0 2085cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN ) 2086cdf0e10cSrcweir { 2087cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 2088cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript ); 2089cdf0e10cSrcweir } 2090cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN ) 2091cdf0e10cSrcweir { 2092cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 2093cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript ); 2094cdf0e10cSrcweir } 2095cdf0e10cSrcweir 2096cdf0e10cSrcweir SfxItemState eState; 2097cdf0e10cSrcweir // const SfxPoolItem* pItem; 2098cdf0e10cSrcweir 2099cdf0e10cSrcweir //-------------------------------------------------------------------- 2100cdf0e10cSrcweir // eigene Kontrolle ueber RadioButton-Funktionalitaet: 2101cdf0e10cSrcweir //-------------------------------------------------------------------- 2102cdf0e10cSrcweir // Unterstreichung 2103cdf0e10cSrcweir //------------------------ 2104cdf0e10cSrcweir 2105cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True ); 2106cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE ) 2107cdf0e10cSrcweir { 2108cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_NONE ); 2109cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); 2110cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); 2111cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); 2112cdf0e10cSrcweir } 2113cdf0e10cSrcweir else 2114cdf0e10cSrcweir { 2115cdf0e10cSrcweir FontUnderline eUnderline = ((const SvxUnderlineItem&) 2116cdf0e10cSrcweir rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle(); 2117cdf0e10cSrcweir sal_uInt16 nId = SID_ULINE_VAL_NONE; 2118cdf0e10cSrcweir switch (eUnderline) 2119cdf0e10cSrcweir { 2120cdf0e10cSrcweir case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; 2121cdf0e10cSrcweir case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; 2122cdf0e10cSrcweir case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; 2123cdf0e10cSrcweir default: 2124cdf0e10cSrcweir break; 2125cdf0e10cSrcweir } 2126cdf0e10cSrcweir rSet.Put( SfxBoolItem( nId, sal_True ) ); 2127cdf0e10cSrcweir } 2128cdf0e10cSrcweir 2129cdf0e10cSrcweir //------------------------ 2130cdf0e10cSrcweir // horizontale Ausrichtung 2131cdf0e10cSrcweir //------------------------ 2132cdf0e10cSrcweir 2133cdf0e10cSrcweir const SvxHorJustifyItem* pHorJustify = NULL; 2134cdf0e10cSrcweir const SvxVerJustifyItem* pVerJustify = NULL; 2135cdf0e10cSrcweir SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; 2136cdf0e10cSrcweir SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; 2137cdf0e10cSrcweir sal_uInt16 nWhich = 0; 2138cdf0e10cSrcweir sal_Bool bJustifyStd = sal_False; 2139cdf0e10cSrcweir SfxBoolItem aBoolItem ( 0, sal_True ); 2140cdf0e10cSrcweir 2141cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True, 2142cdf0e10cSrcweir (const SfxPoolItem**)&pHorJustify ); 2143cdf0e10cSrcweir switch ( eState ) 2144cdf0e10cSrcweir { 2145cdf0e10cSrcweir case SFX_ITEM_SET: 2146cdf0e10cSrcweir { 2147cdf0e10cSrcweir eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); 2148cdf0e10cSrcweir 2149cdf0e10cSrcweir switch ( SvxCellHorJustify( pHorJustify->GetValue() ) ) 2150cdf0e10cSrcweir { 2151cdf0e10cSrcweir case SVX_HOR_JUSTIFY_STANDARD: 2152cdf0e10cSrcweir break; 2153cdf0e10cSrcweir 2154cdf0e10cSrcweir case SVX_HOR_JUSTIFY_LEFT: 2155cdf0e10cSrcweir nWhich = SID_ALIGNLEFT; 2156cdf0e10cSrcweir break; 2157cdf0e10cSrcweir 2158cdf0e10cSrcweir case SVX_HOR_JUSTIFY_RIGHT: 2159cdf0e10cSrcweir nWhich = SID_ALIGNRIGHT; 2160cdf0e10cSrcweir break; 2161cdf0e10cSrcweir 2162cdf0e10cSrcweir case SVX_HOR_JUSTIFY_CENTER: 2163cdf0e10cSrcweir nWhich = SID_ALIGNCENTERHOR; 2164cdf0e10cSrcweir break; 2165cdf0e10cSrcweir 2166cdf0e10cSrcweir case SVX_HOR_JUSTIFY_BLOCK: 2167cdf0e10cSrcweir nWhich = SID_ALIGNBLOCK; 2168cdf0e10cSrcweir break; 2169cdf0e10cSrcweir 2170cdf0e10cSrcweir case SVX_HOR_JUSTIFY_REPEAT: 2171cdf0e10cSrcweir default: 2172cdf0e10cSrcweir bJustifyStd = sal_True; 2173cdf0e10cSrcweir break; 2174cdf0e10cSrcweir } 2175cdf0e10cSrcweir } 2176cdf0e10cSrcweir break; 2177cdf0e10cSrcweir 2178cdf0e10cSrcweir case SFX_ITEM_DONTCARE: 2179cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNLEFT ); 2180cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNRIGHT ); 2181cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNCENTERHOR ); 2182cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNBLOCK ); 2183cdf0e10cSrcweir break; 2184cdf0e10cSrcweir 2185cdf0e10cSrcweir default: 2186cdf0e10cSrcweir bJustifyStd = sal_True; 2187cdf0e10cSrcweir break; 2188cdf0e10cSrcweir } 2189cdf0e10cSrcweir 2190cdf0e10cSrcweir if ( nWhich ) 2191cdf0e10cSrcweir { 2192cdf0e10cSrcweir aBoolItem.SetWhich( nWhich ); 2193cdf0e10cSrcweir rSet.Put( aBoolItem ); 2194cdf0e10cSrcweir } 2195cdf0e10cSrcweir else if ( bJustifyStd ) 2196cdf0e10cSrcweir { 2197cdf0e10cSrcweir aBoolItem.SetValue( sal_False ); 2198cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem ); 2199cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem ); 2200cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem ); 2201cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem ); 2202cdf0e10cSrcweir bJustifyStd = sal_False; 2203cdf0e10cSrcweir } 2204cdf0e10cSrcweir 2205cdf0e10cSrcweir //------------------------ 2206cdf0e10cSrcweir // vertikale Ausrichtung 2207cdf0e10cSrcweir //------------------------ 2208cdf0e10cSrcweir 2209cdf0e10cSrcweir nWhich = 0; 2210cdf0e10cSrcweir aBoolItem.SetValue( sal_True ); 2211cdf0e10cSrcweir 2212cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True, 2213cdf0e10cSrcweir (const SfxPoolItem**)&pVerJustify ); 2214cdf0e10cSrcweir 2215cdf0e10cSrcweir switch ( eState ) 2216cdf0e10cSrcweir { 2217cdf0e10cSrcweir case SFX_ITEM_SET: 2218cdf0e10cSrcweir { 2219cdf0e10cSrcweir eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); 2220cdf0e10cSrcweir 2221cdf0e10cSrcweir switch ( eVerJustify ) 2222cdf0e10cSrcweir { 2223cdf0e10cSrcweir case SVX_VER_JUSTIFY_TOP: 2224cdf0e10cSrcweir nWhich = SID_ALIGNTOP; 2225cdf0e10cSrcweir break; 2226cdf0e10cSrcweir 2227cdf0e10cSrcweir case SVX_VER_JUSTIFY_BOTTOM: 2228cdf0e10cSrcweir nWhich = SID_ALIGNBOTTOM; 2229cdf0e10cSrcweir break; 2230cdf0e10cSrcweir 2231cdf0e10cSrcweir case SVX_VER_JUSTIFY_CENTER: 2232cdf0e10cSrcweir nWhich = SID_ALIGNCENTERVER; 2233cdf0e10cSrcweir break; 2234cdf0e10cSrcweir 2235cdf0e10cSrcweir case SVX_VER_JUSTIFY_STANDARD: 2236cdf0e10cSrcweir default: 2237cdf0e10cSrcweir bJustifyStd = sal_True; 2238cdf0e10cSrcweir break; 2239cdf0e10cSrcweir } 2240cdf0e10cSrcweir } 2241cdf0e10cSrcweir break; 2242cdf0e10cSrcweir 2243cdf0e10cSrcweir case SFX_ITEM_DONTCARE: 2244cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNTOP ); 2245cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNBOTTOM ); 2246cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNCENTERVER ); 2247cdf0e10cSrcweir break; 2248cdf0e10cSrcweir 2249cdf0e10cSrcweir default: 2250cdf0e10cSrcweir bJustifyStd = sal_True; 2251cdf0e10cSrcweir break; 2252cdf0e10cSrcweir } 2253cdf0e10cSrcweir 2254cdf0e10cSrcweir if ( nWhich ) 2255cdf0e10cSrcweir { 2256cdf0e10cSrcweir aBoolItem.SetWhich( nWhich ); 2257cdf0e10cSrcweir rSet.Put( aBoolItem ); 2258cdf0e10cSrcweir } 2259cdf0e10cSrcweir else if ( bJustifyStd ) 2260cdf0e10cSrcweir { 2261cdf0e10cSrcweir aBoolItem.SetValue( sal_False ); 2262cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem ); 2263cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem ); 2264cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem ); 2265cdf0e10cSrcweir } 2266cdf0e10cSrcweir } 2267cdf0e10cSrcweir 2268cdf0e10cSrcweir 2269cdf0e10cSrcweir //------------------------------------------------------------------ 2270cdf0e10cSrcweir 2271cdf0e10cSrcweir void ScFormatShell::GetBorderState( SfxItemSet& rSet ) 2272cdf0e10cSrcweir { 2273cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2274cdf0e10cSrcweir SvxBoxItem aBoxItem( ATTR_BORDER ); 2275cdf0e10cSrcweir SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER ); 2276cdf0e10cSrcweir 2277cdf0e10cSrcweir pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem ); 2278cdf0e10cSrcweir 2279cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN ) 2280cdf0e10cSrcweir rSet.Put( aBoxItem ); 2281cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN ) 2282cdf0e10cSrcweir rSet.Put( aInfoItem ); 2283cdf0e10cSrcweir } 2284cdf0e10cSrcweir 2285cdf0e10cSrcweir //------------------------------------------------------------------ 2286cdf0e10cSrcweir 2287cdf0e10cSrcweir void ScFormatShell::GetAlignState( SfxItemSet& rSet ) 2288cdf0e10cSrcweir { 2289cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2290cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2291cdf0e10cSrcweir SfxWhichIter aIter(rSet); 2292cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 2293cdf0e10cSrcweir 2294cdf0e10cSrcweir SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD; 2295cdf0e10cSrcweir bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE; 2296cdf0e10cSrcweir if( bHasHAlign ) 2297cdf0e10cSrcweir eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue(); 2298cdf0e10cSrcweir 2299cdf0e10cSrcweir SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD; 2300cdf0e10cSrcweir bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE; 2301cdf0e10cSrcweir if( bHasVAlign ) 2302cdf0e10cSrcweir eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue(); 2303cdf0e10cSrcweir 2304cdf0e10cSrcweir while ( nWhich ) 2305cdf0e10cSrcweir { 2306cdf0e10cSrcweir switch ( nWhich ) 2307cdf0e10cSrcweir { 2308cdf0e10cSrcweir case SID_H_ALIGNCELL: 2309cdf0e10cSrcweir if ( bHasHAlign ) 2310cdf0e10cSrcweir rSet.Put( SvxHorJustifyItem( eHAlign, nWhich )); 2311cdf0e10cSrcweir break; 2312cdf0e10cSrcweir case SID_V_ALIGNCELL: 2313cdf0e10cSrcweir if ( bHasVAlign ) 2314cdf0e10cSrcweir rSet.Put( SvxVerJustifyItem( eVAlign, nWhich )); 2315cdf0e10cSrcweir break; 2316cdf0e10cSrcweir 2317cdf0e10cSrcweir // pseudo slots for Format menu 2318cdf0e10cSrcweir case SID_ALIGN_ANY_HDEFAULT: 2319cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT: 2320cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER: 2321cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT: 2322cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED: 2323cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) ); 2324cdf0e10cSrcweir break; 2325cdf0e10cSrcweir case SID_ALIGN_ANY_VDEFAULT: 2326cdf0e10cSrcweir case SID_ALIGN_ANY_TOP: 2327cdf0e10cSrcweir case SID_ALIGN_ANY_VCENTER: 2328cdf0e10cSrcweir case SID_ALIGN_ANY_BOTTOM: 2329cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) ); 2330cdf0e10cSrcweir break; 2331cdf0e10cSrcweir } 2332cdf0e10cSrcweir nWhich = aIter.NextWhich(); 2333cdf0e10cSrcweir } 2334cdf0e10cSrcweir } 2335cdf0e10cSrcweir 2336cdf0e10cSrcweir void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) 2337cdf0e10cSrcweir { 2338cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2339cdf0e10cSrcweir 2340cdf0e10cSrcweir // ScViewData* pViewData = GetViewData(); 2341cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 2342cdf0e10cSrcweir 2343cdf0e10cSrcweir SfxWhichIter aIter(rSet); 2344cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 2345cdf0e10cSrcweir while ( nWhich ) 2346cdf0e10cSrcweir { 2347cdf0e10cSrcweir switch ( nWhich ) 2348cdf0e10cSrcweir { 2349cdf0e10cSrcweir case SID_NUMBER_FORMAT: 23504e8031e0SArmin Le Grand //{ 23514e8031e0SArmin Le Grand // String aFormatCode; // bleibt leer, wenn dont-care 23524e8031e0SArmin Le Grand // 23534e8031e0SArmin Le Grand // const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 23544e8031e0SArmin Le Grand // if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE ) 23554e8031e0SArmin Le Grand // { 23564e8031e0SArmin Le Grand // sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get( 23574e8031e0SArmin Le Grand // ATTR_VALUE_FORMAT )).GetValue(); 23584e8031e0SArmin Le Grand // 23594e8031e0SArmin Le Grand // SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 23604e8031e0SArmin Le Grand // const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); 23614e8031e0SArmin Le Grand // if ( pFormatEntry ) 23624e8031e0SArmin Le Grand // aFormatCode = pFormatEntry->GetFormatstring(); 23634e8031e0SArmin Le Grand // } 23644e8031e0SArmin Le Grand // 23654e8031e0SArmin Le Grand // rSet.Put( SfxStringItem( nWhich, aFormatCode ) ); 23664e8031e0SArmin Le Grand //} 2367cdf0e10cSrcweir 23684e8031e0SArmin Le Grand // symphony version with format interpretation 23694e8031e0SArmin Le Grand { 2370cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 23714e8031e0SArmin Le Grand 23724e8031e0SArmin Le Grand if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT)) 2373cdf0e10cSrcweir { 2374cdf0e10cSrcweir SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 23754e8031e0SArmin Le Grand sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue(); 23764e8031e0SArmin Le Grand sal_Bool bThousand(false); 23774e8031e0SArmin Le Grand sal_Bool bNegRed(false); 23784e8031e0SArmin Le Grand sal_uInt16 nPrecision(0); 23794e8031e0SArmin Le Grand sal_uInt16 nLeadZeroes(0); 2380cdf0e10cSrcweir 23814e8031e0SArmin Le Grand pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes); 23824e8031e0SArmin Le Grand String aFormat; 23834e8031e0SArmin Le Grand static String sBreak = String::CreateFromAscii(","); 23844e8031e0SArmin Le Grand const String sThousand = String::CreateFromInt32(bThousand); 23854e8031e0SArmin Le Grand const String sNegRed = String::CreateFromInt32(bNegRed); 23864e8031e0SArmin Le Grand const String sPrecision = String::CreateFromInt32(nPrecision); 23874e8031e0SArmin Le Grand const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes); 23884e8031e0SArmin Le Grand 23894e8031e0SArmin Le Grand aFormat += sThousand; 23904e8031e0SArmin Le Grand aFormat += sBreak; 23914e8031e0SArmin Le Grand aFormat += sNegRed; 23924e8031e0SArmin Le Grand aFormat += sBreak; 23934e8031e0SArmin Le Grand aFormat += sPrecision; 23944e8031e0SArmin Le Grand aFormat += sBreak; 23954e8031e0SArmin Le Grand aFormat += sLeadZeroes; 23964e8031e0SArmin Le Grand aFormat += sBreak; 23974e8031e0SArmin Le Grand 23984e8031e0SArmin Le Grand rSet.Put(SfxStringItem(nWhich, aFormat)); 23994e8031e0SArmin Le Grand } 24004e8031e0SArmin Le Grand else 24014e8031e0SArmin Le Grand { 24024e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich ); 24034e8031e0SArmin Le Grand } 2404cdf0e10cSrcweir } 2405cdf0e10cSrcweir break; 2406cdf0e10cSrcweir 24074e8031e0SArmin Le Grand case SID_NUMBER_TYPE_FORMAT: 24084e8031e0SArmin Le Grand { 24094e8031e0SArmin Le Grand sal_Int16 aFormatCode = -1; 24104e8031e0SArmin Le Grand const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 24114e8031e0SArmin Le Grand if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust 24124e8031e0SArmin Le Grand { 24134e8031e0SArmin Le Grand SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 24144e8031e0SArmin Le Grand sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter ); 24154e8031e0SArmin Le Grand const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); 24164e8031e0SArmin Le Grand bool bStandard = false; 24174e8031e0SArmin Le Grand 24184e8031e0SArmin Le Grand if ( pFormatEntry ) 24194e8031e0SArmin Le Grand { 24204e8031e0SArmin Le Grand aFormatCode = pFormatEntry->GetType(); 24214e8031e0SArmin Le Grand bStandard = pFormatEntry->IsStandard(); 24224e8031e0SArmin Le Grand } 24234e8031e0SArmin Le Grand 24244e8031e0SArmin Le Grand switch(aFormatCode) 24254e8031e0SArmin Le Grand { 24264e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER: 24274e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED: 24284e8031e0SArmin Le Grand //use format code and standard format code to judge whether it is General, 24294e8031e0SArmin Le Grand //if (nNumberFormat == nStandardNumberFormat) 24304e8031e0SArmin Le Grand if (bStandard) 24314e8031e0SArmin Le Grand aFormatCode = 0; 24324e8031e0SArmin Le Grand else 24334e8031e0SArmin Le Grand aFormatCode = 1; 24344e8031e0SArmin Le Grand break; 24354e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT: 24364e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED: 24374e8031e0SArmin Le Grand aFormatCode = 2; 24384e8031e0SArmin Le Grand break; 24394e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY: 24404e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED: 24414e8031e0SArmin Le Grand aFormatCode = 3; 24424e8031e0SArmin Le Grand break; 24434e8031e0SArmin Le Grand case NUMBERFORMAT_DATE: 24444e8031e0SArmin Le Grand case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED: 24454e8031e0SArmin Le Grand //Add 24464e8031e0SArmin Le Grand case NUMBERFORMAT_DATETIME: 24474e8031e0SArmin Le Grand case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED: 24484e8031e0SArmin Le Grand aFormatCode = 4; 24494e8031e0SArmin Le Grand break; 24504e8031e0SArmin Le Grand case NUMBERFORMAT_TIME: 24514e8031e0SArmin Le Grand case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED: 24524e8031e0SArmin Le Grand aFormatCode = 5; 24534e8031e0SArmin Le Grand break; 24544e8031e0SArmin Le Grand case NUMBERFORMAT_SCIENTIFIC: 24554e8031e0SArmin Le Grand case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED: 24564e8031e0SArmin Le Grand aFormatCode = 6; 24574e8031e0SArmin Le Grand break; 24584e8031e0SArmin Le Grand case NUMBERFORMAT_FRACTION: 24594e8031e0SArmin Le Grand case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED: 24604e8031e0SArmin Le Grand aFormatCode = 7; 24614e8031e0SArmin Le Grand break; 24624e8031e0SArmin Le Grand case NUMBERFORMAT_LOGICAL: 24634e8031e0SArmin Le Grand case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED: 24644e8031e0SArmin Le Grand aFormatCode = 8; 24654e8031e0SArmin Le Grand break; 24664e8031e0SArmin Le Grand case NUMBERFORMAT_TEXT: 24674e8031e0SArmin Le Grand case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED: 24684e8031e0SArmin Le Grand aFormatCode = 9; 24694e8031e0SArmin Le Grand break; 24704e8031e0SArmin Le Grand default: 24714e8031e0SArmin Le Grand aFormatCode = -1; //for more roburst 24724e8031e0SArmin Le Grand } 24734e8031e0SArmin Le Grand if( aFormatCode == -1 ) 24744e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich ); 24754e8031e0SArmin Le Grand else 24764e8031e0SArmin Le Grand rSet.Put( SfxInt16Item( nWhich, aFormatCode ) ); 24774e8031e0SArmin Le Grand } 24784e8031e0SArmin Le Grand else 24794e8031e0SArmin Le Grand { 24804e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich ); 24814e8031e0SArmin Le Grand } 24824e8031e0SArmin Le Grand 24834e8031e0SArmin Le Grand } 24844e8031e0SArmin Le Grand break; 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir nWhich = aIter.NextWhich(); 2487cdf0e10cSrcweir } 2488cdf0e10cSrcweir } 2489cdf0e10cSrcweir 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq ) 2492cdf0e10cSrcweir { 2493cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2494cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 2495cdf0e10cSrcweir if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) 2496cdf0e10cSrcweir { 2497cdf0e10cSrcweir SC_MOD()->InputEnterHandler(); 2498cdf0e10cSrcweir pTabViewShell->UpdateInputHandler(); 2499cdf0e10cSrcweir } 2500cdf0e10cSrcweir 2501cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 2502cdf0e10cSrcweir switch( nSlot ) 2503cdf0e10cSrcweir { 2504cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 2505cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 2506cdf0e10cSrcweir { 2507cdf0e10cSrcweir sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM); 2508cdf0e10cSrcweir ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() ); 2509cdf0e10cSrcweir SfxItemSet& rItemSet = aAttr.GetItemSet(); 2510cdf0e10cSrcweir rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) ); 2511cdf0e10cSrcweir rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) ); 2512cdf0e10cSrcweir pTabViewShell->ApplySelectionPattern( aAttr ); 2513cdf0e10cSrcweir pTabViewShell->AdjustBlockHeight(); 2514cdf0e10cSrcweir } 2515cdf0e10cSrcweir break; 2516cdf0e10cSrcweir 2517cdf0e10cSrcweir case SID_ATTR_PARA_LEFT_TO_RIGHT: 2518cdf0e10cSrcweir case SID_ATTR_PARA_RIGHT_TO_LEFT: 2519cdf0e10cSrcweir { 2520cdf0e10cSrcweir SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ? 2521cdf0e10cSrcweir FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP; 2522cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) ); 2523cdf0e10cSrcweir } 2524cdf0e10cSrcweir break; 2525cdf0e10cSrcweir } 2526cdf0e10cSrcweir } 2527cdf0e10cSrcweir 2528cdf0e10cSrcweir void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet ) 2529cdf0e10cSrcweir { 2530cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2531cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2532cdf0e10cSrcweir 2533cdf0e10cSrcweir sal_Bool bVertDontCare = 2534cdf0e10cSrcweir (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) || 2535cdf0e10cSrcweir (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE); 2536cdf0e10cSrcweir sal_Bool bLeftRight = !bVertDontCare && 2537cdf0e10cSrcweir !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue(); 2538cdf0e10cSrcweir sal_Bool bTopBottom = !bVertDontCare && !bLeftRight && 2539cdf0e10cSrcweir ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue(); 2540cdf0e10cSrcweir 2541cdf0e10cSrcweir sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE); 2542cdf0e10cSrcweir EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT; 2543cdf0e10cSrcweir if ( !bBidiDontCare ) 2544cdf0e10cSrcweir { 2545cdf0e10cSrcweir SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&) 2546cdf0e10cSrcweir rAttrSet.Get( ATTR_WRITINGDIR )).GetValue(); 2547cdf0e10cSrcweir if ( eCellDir == FRMDIR_ENVIRONMENT ) 2548cdf0e10cSrcweir eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()-> 2549cdf0e10cSrcweir GetEditTextDirection( GetViewData()->GetTabNo() ); 2550cdf0e10cSrcweir else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP ) 2551cdf0e10cSrcweir eBidiDir = EE_HTEXTDIR_R2L; 2552cdf0e10cSrcweir else 2553cdf0e10cSrcweir eBidiDir = EE_HTEXTDIR_L2R; 2554cdf0e10cSrcweir } 2555cdf0e10cSrcweir 2556cdf0e10cSrcweir SvtLanguageOptions aLangOpt; 2557cdf0e10cSrcweir sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled(); 2558cdf0e10cSrcweir sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled(); 2559cdf0e10cSrcweir 2560cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 2561cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 2562cdf0e10cSrcweir while( nWhich ) 2563cdf0e10cSrcweir { 2564cdf0e10cSrcweir switch( nWhich ) 2565cdf0e10cSrcweir { 2566cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 2567cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 2568cdf0e10cSrcweir if ( bDisableVerticalText ) 2569cdf0e10cSrcweir rSet.DisableItem( nWhich ); 2570cdf0e10cSrcweir else 2571cdf0e10cSrcweir { 2572cdf0e10cSrcweir if( bVertDontCare ) 2573cdf0e10cSrcweir rSet.InvalidateItem( nWhich ); 2574cdf0e10cSrcweir else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT ) 2575cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bLeftRight ) ); 2576cdf0e10cSrcweir else 2577cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bTopBottom ) ); 2578cdf0e10cSrcweir } 2579cdf0e10cSrcweir break; 2580cdf0e10cSrcweir 2581cdf0e10cSrcweir case SID_ATTR_PARA_LEFT_TO_RIGHT: 2582cdf0e10cSrcweir case SID_ATTR_PARA_RIGHT_TO_LEFT: 2583cdf0e10cSrcweir if ( bDisableCTLFont ) 2584cdf0e10cSrcweir rSet.DisableItem( nWhich ); 2585cdf0e10cSrcweir else 2586cdf0e10cSrcweir { 2587cdf0e10cSrcweir if ( bTopBottom ) 2588cdf0e10cSrcweir rSet.DisableItem( nWhich ); 2589cdf0e10cSrcweir else if ( bBidiDontCare ) 2590cdf0e10cSrcweir rSet.InvalidateItem( nWhich ); 2591cdf0e10cSrcweir else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT ) 2592cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) ); 2593cdf0e10cSrcweir else 2594cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) ); 2595cdf0e10cSrcweir } 2596cdf0e10cSrcweir } 2597cdf0e10cSrcweir nWhich = aIter.NextWhich(); 2598cdf0e10cSrcweir } 2599cdf0e10cSrcweir } 2600cdf0e10cSrcweir 2601cdf0e10cSrcweir void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq ) 2602cdf0e10cSrcweir { 2603cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView(); 2604cdf0e10cSrcweir if ( pView->HasPaintBrush() ) 2605cdf0e10cSrcweir { 2606cdf0e10cSrcweir // cancel paintbrush mode 2607cdf0e10cSrcweir pView->ResetBrushDocument(); 2608cdf0e10cSrcweir } 2609cdf0e10cSrcweir else 2610cdf0e10cSrcweir { 2611cdf0e10cSrcweir sal_Bool bLock = sal_False; 2612cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs(); 2613cdf0e10cSrcweir if( pArgs && pArgs->Count() >= 1 ) 2614cdf0e10cSrcweir bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue(); 2615cdf0e10cSrcweir 2616cdf0e10cSrcweir // in case of multi selection, deselect all and use the cursor position 2617cdf0e10cSrcweir ScRange aDummy; 2618cdf0e10cSrcweir if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE ) 2619cdf0e10cSrcweir pView->Unmark(); 2620cdf0e10cSrcweir 2621cdf0e10cSrcweir ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP ); 2622cdf0e10cSrcweir pView->CopyToClip( pBrushDoc, sal_False, sal_True ); 2623cdf0e10cSrcweir pView->SetBrushDocument( pBrushDoc, bLock ); 2624cdf0e10cSrcweir } 2625cdf0e10cSrcweir } 2626cdf0e10cSrcweir 2627cdf0e10cSrcweir void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet ) 2628cdf0e10cSrcweir { 2629cdf0e10cSrcweir if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) 2630cdf0e10cSrcweir rSet.DisableItem( SID_FORMATPAINTBRUSH ); 2631cdf0e10cSrcweir else 2632cdf0e10cSrcweir rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) ); 2633cdf0e10cSrcweir } 2634cdf0e10cSrcweir 2635facb16e7SArmin Le Grand void ScFormatShell::ExecViewOptions( SfxRequest& rReq ) 2636facb16e7SArmin Le Grand { 2637facb16e7SArmin Le Grand ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2638facb16e7SArmin Le Grand SfxBindings& rBindings = pViewData->GetBindings(); 2639facb16e7SArmin Le Grand const SfxItemSet* pNewAttrs = rReq.GetArgs(); 2640facb16e7SArmin Le Grand 2641facb16e7SArmin Le Grand if ( pNewAttrs ) 2642facb16e7SArmin Le Grand { 2643facb16e7SArmin Le Grand sal_uInt16 nSlot = rReq.GetSlot(); 2644facb16e7SArmin Le Grand 2645facb16e7SArmin Le Grand if( nSlot == SID_SCGRIDSHOW) 2646facb16e7SArmin Le Grand { 2647facb16e7SArmin Le Grand 2648facb16e7SArmin Le Grand ScViewData* pViewData = pTabViewShell->GetViewData(); 2649facb16e7SArmin Le Grand const ScViewOptions& rOldOpt = pViewData->GetOptions(); 2650facb16e7SArmin Le Grand ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 2651facb16e7SArmin Le Grand bool bState = ((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue(); 2652facb16e7SArmin Le Grand 2653facb16e7SArmin Le Grand if ( (bool)rOldOpt.GetOption( VOPT_GRID ) != bState) 2654facb16e7SArmin Le Grand { 2655facb16e7SArmin Le Grand ScViewOptions rNewOpt(rOldOpt); 2656facb16e7SArmin Le Grand rNewOpt.SetOption( VOPT_GRID, bState); 2657facb16e7SArmin Le Grand pViewData->SetOptions( rNewOpt ); 2658facb16e7SArmin Le Grand pViewData->GetDocument()->SetViewOptions( rNewOpt ); 2659facb16e7SArmin Le Grand pDocSh->SetDocumentModified(); 2660facb16e7SArmin Le Grand //add , write the change to sc view config 2661facb16e7SArmin Le Grand ScModule* pScMod = SC_MOD(); 2662facb16e7SArmin Le Grand pScMod->SetViewOptions( rNewOpt ); 2663facb16e7SArmin Le Grand //add end 2664facb16e7SArmin Le Grand rBindings.Invalidate( nSlot ); 2665facb16e7SArmin Le Grand } 2666facb16e7SArmin Le Grand } 2667facb16e7SArmin Le Grand } 2668facb16e7SArmin Le Grand 2669facb16e7SArmin Le Grand } 2670facb16e7SArmin Le Grand 2671facb16e7SArmin Le Grand void ScFormatShell::GetViewOptions( SfxItemSet& rSet ) 2672facb16e7SArmin Le Grand { 2673facb16e7SArmin Le Grand ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2674facb16e7SArmin Le Grand if( pTabViewShell ) 2675facb16e7SArmin Le Grand { 2676facb16e7SArmin Le Grand ScViewOptions aViewOpt = pTabViewShell->GetViewData()->GetOptions(); 2677facb16e7SArmin Le Grand rSet.ClearItem(SID_SCGRIDSHOW); 2678facb16e7SArmin Le Grand SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) ); 2679facb16e7SArmin Le Grand rSet.Put(aItem); 2680facb16e7SArmin Le Grand } 2681facb16e7SArmin Le Grand } 2682facb16e7SArmin Le Grand 2683facb16e7SArmin Le Grand // eof 2684