1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #ifdef SD_DLLIMPLEMENTATION 32 #undef SD_DLLIMPLEMENTATION 33 #endif 34 35 #include "OutlineBulletDlg.hxx" 36 37 #ifndef _SVX_SVXIDS_HRC 38 #include <svx/svxids.hrc> 39 #endif 40 #include <sfx2/objsh.hxx> 41 #include <svx/drawitem.hxx> 42 #include <editeng/bulitem.hxx> 43 #include <editeng/eeitem.hxx> 44 45 #include <editeng/numitem.hxx> 46 47 #include <svx/dialogs.hrc> 48 #include <svl/intitem.hxx> 49 #include <svx/svdmark.hxx> 50 #include "View.hxx" 51 #include <svx/svdobj.hxx> 52 #include <svl/style.hxx> 53 #include <drawdoc.hxx> 54 55 #ifndef _SD_SDRESID_HXX 56 #include "sdresid.hxx" 57 #endif 58 59 #include "glob.hrc" 60 #include "dlgolbul.hrc" 61 #include "bulmaper.hxx" 62 #include "DrawDocShell.hxx" 63 #include <svx/svxids.hrc> 64 #include <svl/aeitem.hxx> 65 66 namespace sd { 67 68 /************************************************************************* 69 |* 70 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu 71 |* 72 \************************************************************************/ 73 74 OutlineBulletDlg::OutlineBulletDlg( 75 ::Window* pParent, 76 const SfxItemSet* pAttr, 77 ::sd::View* pView ) 78 : SfxTabDialog ( pParent, SdResId(TAB_OUTLINEBULLET) ), 79 aInputSet ( *pAttr ), 80 bTitle ( sal_False ), 81 pSdView ( pView ) 82 { 83 FreeResource(); 84 85 aInputSet.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ); 86 aInputSet.Put( *pAttr ); 87 88 pOutputSet = new SfxItemSet( *pAttr ); 89 pOutputSet->ClearItem(); 90 91 sal_Bool bOutliner = sal_False; 92 93 // Sonderbehandlung wenn eine Title Objekt selektiert wurde 94 if( pView ) 95 { 96 const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 97 const sal_uLong nCount = rMarkList.GetMarkCount(); 98 for(sal_uLong nNum = 0; nNum < nCount; nNum++) 99 { 100 SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj(); 101 if( pObj->GetObjInventor() == SdrInventor ) 102 { 103 104 switch(pObj->GetObjIdentifier()) 105 { 106 case OBJ_TITLETEXT: 107 bTitle = sal_True; 108 break; 109 case OBJ_OUTLINETEXT: 110 bOutliner = sal_True; 111 break; 112 } 113 } 114 } 115 } 116 117 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET)) 118 { 119 const SvxNumBulletItem *pItem = NULL; 120 if(bOutliner) 121 { 122 SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool(); 123 String aStyleName((SdResId(STR_LAYOUT_OUTLINE))); 124 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) ); 125 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO); 126 if( pFirstStyleSheet ) 127 pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem); 128 } 129 130 if( pItem == NULL ) 131 pItem = (SvxNumBulletItem*) aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); 132 133 DBG_ASSERT( pItem, "Kein EE_PARA_NUMBULLET im Pool! [CL]" ); 134 135 aInputSet.Put(*pItem, EE_PARA_NUMBULLET); 136 } 137 138 /* debug 139 if( SFX_ITEM_SET == aInputSet.GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem )) 140 { 141 SvxNumRule& rItem = *((SvxNumBulletItem*)pItem)->GetNumRule(); 142 for( int i = 0; i < 9; i++ ) 143 { 144 SvxNumberFormat aNumberFormat = rItem.GetLevel(i); 145 } 146 } 147 */ 148 149 if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON ) 150 { 151 SvxNumBulletItem* pItem = (SvxNumBulletItem*)aInputSet.GetItem(EE_PARA_NUMBULLET,sal_True); 152 SvxNumRule* pRule = pItem->GetNumRule(); 153 if(pRule) 154 { 155 SvxNumRule aNewRule( *pRule ); 156 aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True ); 157 158 SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); 159 aInputSet.Put(aNewItem); 160 } 161 } 162 163 SetInputSet( &aInputSet ); 164 165 if(!bTitle) 166 AddTabPage(RID_SVXPAGE_PICK_SINGLE_NUM); 167 else 168 RemoveTabPage( RID_SVXPAGE_PICK_SINGLE_NUM ); 169 170 AddTabPage( RID_SVXPAGE_PICK_BULLET ); 171 AddTabPage( RID_SVXPAGE_PICK_BMP ); 172 AddTabPage(RID_SVXPAGE_NUM_OPTIONS ); 173 AddTabPage(RID_SVXPAGE_NUM_POSITION ); 174 175 } 176 177 OutlineBulletDlg::~OutlineBulletDlg() 178 { 179 delete pOutputSet; 180 } 181 182 void OutlineBulletDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) 183 { 184 switch ( nId ) 185 { 186 case RID_SVXPAGE_NUM_OPTIONS: 187 { 188 if( pSdView ) 189 { 190 FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit(); 191 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); 192 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric)); 193 rPage.PageCreated(aSet); 194 } 195 } 196 break; 197 case RID_SVXPAGE_NUM_POSITION: 198 { 199 if( pSdView ) 200 { 201 FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit(); 202 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); 203 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric)); 204 rPage.PageCreated(aSet); 205 } 206 } 207 break; 208 } 209 } 210 211 const SfxItemSet* OutlineBulletDlg::GetOutputItemSet() const 212 { 213 SfxItemSet aSet( *SfxTabDialog::GetOutputItemSet() ); 214 pOutputSet->Put( aSet ); 215 216 const SfxPoolItem *pItem = NULL; 217 if( SFX_ITEM_SET == pOutputSet->GetItemState(pOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), sal_False, &pItem )) 218 { 219 SdBulletMapper::MapFontsInNumRule( *((SvxNumBulletItem*)pItem)->GetNumRule(), *pOutputSet ); 220 221 /* #i35937# 222 SfxUInt16Item aBulletState( EE_PARA_BULLETSTATE, 1 ); 223 pOutputSet->Put(aBulletState); 224 */ 225 } 226 227 /* #i35937# 228 SdBulletMapper::PostMapNumBulletForDialog( *pOutputSet ); 229 */ 230 231 if(bTitle && pOutputSet->GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON ) 232 { 233 SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)pOutputSet->GetItem(EE_PARA_NUMBULLET,sal_True); 234 SvxNumRule* pRule = pBulletItem->GetNumRule(); 235 if(pRule) 236 pRule->SetFeatureFlag( NUM_NO_NUMBERS, sal_False ); 237 } 238 239 return pOutputSet; 240 } 241 242 } // end of namespace sd 243