xref: /aoo41x/main/sd/source/ui/dlg/dlgolbul.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #ifdef SD_DLLIMPLEMENTATION
28 #undef SD_DLLIMPLEMENTATION
29 #endif
30 
31 #include "OutlineBulletDlg.hxx"
32 
33 #ifndef _SVX_SVXIDS_HRC
34 #include <svx/svxids.hrc>
35 #endif
36 #include <sfx2/objsh.hxx>
37 #include <svx/drawitem.hxx>
38 #include <editeng/bulitem.hxx>
39 #include <editeng/eeitem.hxx>
40 
41 #include <editeng/numitem.hxx>
42 
43 #include <svx/dialogs.hrc>
44 #include <svl/intitem.hxx>
45 #include <svx/svdmark.hxx>
46 #include "View.hxx"
47 #include <svx/svdobj.hxx>
48 #include <svl/style.hxx>
49 #include <drawdoc.hxx>
50 
51 #ifndef _SD_SDRESID_HXX
52 #include "sdresid.hxx"
53 #endif
54 
55 #include "glob.hrc"
56 #include "dlgolbul.hrc"
57 #include "bulmaper.hxx"
58 #include "DrawDocShell.hxx"
59 #include <svx/svxids.hrc>
60 #include <svl/aeitem.hxx>
61 
62 namespace sd {
63 
64 /*************************************************************************
65 |*
66 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
67 |*
68 \************************************************************************/
69 
OutlineBulletDlg(::Window * pParent,const SfxItemSet * pAttr,::sd::View * pView)70 OutlineBulletDlg::OutlineBulletDlg(
71     ::Window* pParent,
72     const SfxItemSet* pAttr,
73     ::sd::View* pView )
74     : SfxTabDialog	( pParent, SdResId(TAB_OUTLINEBULLET) ),
75       aInputSet		( *pAttr ),
76       bTitle			( sal_False ),
77       pSdView			( pView )
78 {
79 	FreeResource();
80 
81 	aInputSet.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
82 	aInputSet.Put( *pAttr );
83 
84 	pOutputSet = new SfxItemSet( *pAttr );
85 	pOutputSet->ClearItem();
86 
87 	sal_Bool bOutliner = sal_False;
88 
89 	// Sonderbehandlung wenn eine Title Objekt selektiert wurde
90 	if( pView )
91 	{
92 		const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
93 		const sal_uLong nCount = rMarkList.GetMarkCount();
94 		for(sal_uLong nNum = 0; nNum < nCount; nNum++)
95 		{
96 			SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
97 			if( pObj->GetObjInventor() == SdrInventor )
98 			{
99 
100 				switch(pObj->GetObjIdentifier())
101 				{
102 				case OBJ_TITLETEXT:
103 					bTitle = sal_True;
104 					break;
105 				case OBJ_OUTLINETEXT:
106 					bOutliner = sal_True;
107 					break;
108 				}
109 			}
110 		}
111 	}
112 
113 	if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET))
114 	{
115 		const SvxNumBulletItem *pItem = NULL;
116 		if(bOutliner)
117 		{
118 			SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
119 			String aStyleName((SdResId(STR_LAYOUT_OUTLINE)));
120 			aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
121 			SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
122 			if( pFirstStyleSheet )
123 				pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem);
124 		}
125 
126 		if( pItem == NULL )
127 			pItem = (SvxNumBulletItem*) aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
128 
129 		DBG_ASSERT( pItem, "Kein EE_PARA_NUMBULLET im Pool! [CL]" );
130 
131 		aInputSet.Put(*pItem, EE_PARA_NUMBULLET);
132 	}
133 
134 	/* debug
135 	if( SFX_ITEM_SET == aInputSet.GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem ))
136 	{
137 		SvxNumRule& rItem = *((SvxNumBulletItem*)pItem)->GetNumRule();
138 		for( int i = 0; i < 9; i++ )
139 		{
140 			SvxNumberFormat aNumberFormat = rItem.GetLevel(i);
141 		}
142 	}
143 	*/
144 
145 	if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
146 	{
147 		SvxNumBulletItem* pItem = (SvxNumBulletItem*)aInputSet.GetItem(EE_PARA_NUMBULLET,sal_True);
148 		SvxNumRule* pRule = pItem->GetNumRule();
149 		if(pRule)
150 		{
151 			SvxNumRule aNewRule( *pRule );
152 			aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True );
153 
154 			SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
155 			aInputSet.Put(aNewItem);
156 		}
157 	}
158 
159 	SetInputSet( &aInputSet );
160 
161 	if(!bTitle)
162 		AddTabPage(RID_SVXPAGE_PICK_SINGLE_NUM);
163 	else
164 		RemoveTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
165 
166 	AddTabPage( RID_SVXPAGE_PICK_BULLET  );
167 	AddTabPage( RID_SVXPAGE_PICK_BMP   );
168 	AddTabPage(RID_SVXPAGE_NUM_OPTIONS 	);
169 	AddTabPage(RID_SVXPAGE_NUM_POSITION	);
170 
171 }
172 
~OutlineBulletDlg()173 OutlineBulletDlg::~OutlineBulletDlg()
174 {
175 	delete pOutputSet;
176 }
177 
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)178 void OutlineBulletDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
179 {
180 	switch ( nId )
181 	{
182 		case RID_SVXPAGE_NUM_OPTIONS:
183 		{
184 			if( pSdView )
185 			{
186 				FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit();
187 				SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
188 				aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
189 				rPage.PageCreated(aSet);
190 			}
191 		}
192 		break;
193 		case RID_SVXPAGE_NUM_POSITION:
194 		{
195 			if( pSdView )
196 			{
197 				FieldUnit eMetric = pSdView->GetDoc()->GetUIUnit();
198 				SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
199 				aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
200 				rPage.PageCreated(aSet);
201 			}
202 		}
203 		break;
204 	}
205 }
206 
GetOutputItemSet() const207 const SfxItemSet* OutlineBulletDlg::GetOutputItemSet() const
208 {
209 	SfxItemSet aSet( *SfxTabDialog::GetOutputItemSet() );
210 	pOutputSet->Put( aSet );
211 
212 	const SfxPoolItem *pItem = NULL;
213 	if( SFX_ITEM_SET == pOutputSet->GetItemState(pOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), sal_False, &pItem ))
214 	{
215 		SdBulletMapper::MapFontsInNumRule( *((SvxNumBulletItem*)pItem)->GetNumRule(), *pOutputSet );
216 
217 /* #i35937#
218 		SfxUInt16Item aBulletState( EE_PARA_BULLETSTATE, 1 );
219 		pOutputSet->Put(aBulletState);
220 */
221 	}
222 
223 /* #i35937#
224 	SdBulletMapper::PostMapNumBulletForDialog( *pOutputSet );
225 */
226 
227 	if(bTitle && pOutputSet->GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
228 	{
229 		SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)pOutputSet->GetItem(EE_PARA_NUMBULLET,sal_True);
230 		SvxNumRule* pRule = pBulletItem->GetNumRule();
231 		if(pRule)
232 			pRule->SetFeatureFlag( NUM_NO_NUMBERS, sal_False );
233 	}
234 
235 	return pOutputSet;
236 }
237 
238 } // end of namespace sd
239