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