Update ooo320-m1
[ooovba.git] / sd / source / ui / dlg / dlgolbul.cxx
blobdb24d3fa61198da359c857085e593625ce087f85
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgolbul.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
38 #include "OutlineBulletDlg.hxx"
40 #ifndef _SVX_SVXIDS_HRC
41 #include <svx/svxids.hrc>
42 #endif
43 #include <sfx2/objsh.hxx>
44 #include <svx/drawitem.hxx>
45 #include <svx/bulitem.hxx>
46 #include <svx/eeitem.hxx>
48 #include <svx/numitem.hxx>
50 #include <svx/dialogs.hrc>
51 #include <svtools/intitem.hxx>
52 #include <svx/svdmark.hxx>
53 #include "View.hxx"
54 #include <svx/svdobj.hxx>
55 #include <svtools/style.hxx>
56 #include <drawdoc.hxx>
58 #ifndef _SD_SDRESID_HXX
59 #include "sdresid.hxx"
60 #endif
62 #include "glob.hrc"
63 #include "dlgolbul.hrc"
64 #include "bulmaper.hxx"
65 #include "DrawDocShell.hxx"
66 #include <svx/svxids.hrc>
67 #include <svtools/aeitem.hxx>
69 namespace sd {
71 /*************************************************************************
73 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
75 \************************************************************************/
77 OutlineBulletDlg::OutlineBulletDlg(
78 ::Window* pParent,
79 const SfxItemSet* pAttr,
80 ::sd::View* pView )
81 : SfxTabDialog ( pParent, SdResId(TAB_OUTLINEBULLET) ),
82 aInputSet ( *pAttr ),
83 bTitle ( FALSE ),
84 pSdView ( pView )
86 FreeResource();
88 aInputSet.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
89 aInputSet.Put( *pAttr );
91 pOutputSet = new SfxItemSet( *pAttr );
92 pOutputSet->ClearItem();
94 BOOL bOutliner = FALSE;
96 // Sonderbehandlung wenn eine Title Objekt selektiert wurde
97 if( pView )
99 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
100 const ULONG nCount = rMarkList.GetMarkCount();
101 for(ULONG nNum = 0; nNum < nCount; nNum++)
103 SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
104 if( pObj->GetObjInventor() == SdrInventor )
107 switch(pObj->GetObjIdentifier())
109 case OBJ_TITLETEXT:
110 bTitle = TRUE;
111 break;
112 case OBJ_OUTLINETEXT:
113 bOutliner = TRUE;
114 break;
120 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET))
122 const SvxNumBulletItem *pItem = NULL;
123 if(bOutliner)
125 SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
126 String aStyleName((SdResId(STR_LAYOUT_OUTLINE)));
127 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
128 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
129 if( pFirstStyleSheet )
130 pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, FALSE, (const SfxPoolItem**)&pItem);
133 if( pItem == NULL )
134 pItem = (SvxNumBulletItem*) aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
136 DBG_ASSERT( pItem, "Kein EE_PARA_NUMBULLET im Pool! [CL]" );
138 aInputSet.Put(*pItem, EE_PARA_NUMBULLET);
141 /* debug
142 if( SFX_ITEM_SET == aInputSet.GetItemState(EE_PARA_NUMBULLET, FALSE, &pItem ))
144 SvxNumRule& rItem = *((SvxNumBulletItem*)pItem)->GetNumRule();
145 for( int i = 0; i < 9; i++ )
147 SvxNumberFormat aNumberFormat = rItem.GetLevel(i);
152 if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET,TRUE) == SFX_ITEM_ON )
154 SvxNumBulletItem* pItem = (SvxNumBulletItem*)aInputSet.GetItem(EE_PARA_NUMBULLET,TRUE);
155 SvxNumRule* pRule = pItem->GetNumRule();
156 if(pRule)
158 SvxNumRule aNewRule( *pRule );
159 aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, TRUE );
161 SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
162 aInputSet.Put(aNewItem);
166 SetInputSet( &aInputSet );
168 if(!bTitle)
169 AddTabPage(RID_SVXPAGE_PICK_SINGLE_NUM);
170 else
171 RemoveTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
173 AddTabPage( RID_SVXPAGE_PICK_BULLET );
174 AddTabPage( RID_SVXPAGE_PICK_BMP );
175 AddTabPage(RID_SVXPAGE_NUM_OPTIONS );
176 AddTabPage(RID_SVXPAGE_NUM_POSITION );
180 OutlineBulletDlg::~OutlineBulletDlg()
182 delete pOutputSet;
185 void OutlineBulletDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
187 switch ( nId )
189 case RID_SVXPAGE_NUM_OPTIONS:
191 if( pSdView )
193 FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit();
194 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
195 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(USHORT)eMetric));
196 rPage.PageCreated(aSet);
199 break;
200 case RID_SVXPAGE_NUM_POSITION:
202 if( pSdView )
204 FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit();
205 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
206 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(USHORT)eMetric));
207 rPage.PageCreated(aSet);
210 break;
214 const SfxItemSet* OutlineBulletDlg::GetOutputItemSet() const
216 SfxItemSet aSet( *SfxTabDialog::GetOutputItemSet() );
217 pOutputSet->Put( aSet );
219 const SfxPoolItem *pItem = NULL;
220 if( SFX_ITEM_SET == pOutputSet->GetItemState(pOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), FALSE, &pItem ))
222 SdBulletMapper::MapFontsInNumRule( *((SvxNumBulletItem*)pItem)->GetNumRule(), *pOutputSet );
224 /* #i35937#
225 SfxUInt16Item aBulletState( EE_PARA_BULLETSTATE, 1 );
226 pOutputSet->Put(aBulletState);
230 /* #i35937#
231 SdBulletMapper::PostMapNumBulletForDialog( *pOutputSet );
234 if(bTitle && pOutputSet->GetItemState(EE_PARA_NUMBULLET,TRUE) == SFX_ITEM_ON )
236 SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)pOutputSet->GetItem(EE_PARA_NUMBULLET,TRUE);
237 SvxNumRule* pRule = pBulletItem->GetNumRule();
238 if(pRule)
239 pRule->SetFeatureFlag( NUM_NO_NUMBERS, FALSE );
242 return pOutputSet;
245 } // end of namespace sd