bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / dlg / dlgolbul.cxx
blobb0ab85b323947f2eb42c6d12198f6c0f7501bd9f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "OutlineBulletDlg.hxx"
22 #include <svx/svxids.hrc>
23 #include <sfx2/objsh.hxx>
24 #include <svx/drawitem.hxx>
25 #include <editeng/bulletitem.hxx>
26 #include <editeng/eeitem.hxx>
28 #include <editeng/numitem.hxx>
30 #include <svx/dialogs.hrc>
31 #include <svl/intitem.hxx>
32 #include <svx/svdmark.hxx>
33 #include "View.hxx"
34 #include <svx/svdobj.hxx>
35 #include <svl/style.hxx>
36 #include <drawdoc.hxx>
38 #include "sdresid.hxx"
40 #include "glob.hrc"
41 #include "dlgolbul.hrc"
42 #include "bulmaper.hxx"
43 #include "DrawDocShell.hxx"
44 #include <svl/aeitem.hxx>
46 namespace sd {
48 /**
49 * Constructor of tab dialog: append pages to the dialog
51 OutlineBulletDlg::OutlineBulletDlg(
52 ::Window* pParent,
53 const SfxItemSet* pAttr,
54 ::sd::View* pView )
55 : SfxTabDialog ( pParent, SdResId(TAB_OUTLINEBULLET) ),
56 aInputSet ( *pAttr ),
57 bTitle ( sal_False ),
58 pSdView ( pView )
60 FreeResource();
62 aInputSet.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
63 aInputSet.Put( *pAttr );
65 pOutputSet = new SfxItemSet( *pAttr );
66 pOutputSet->ClearItem();
68 sal_Bool bOutliner = sal_False;
70 // special treatment if a title object is selected
71 if( pView )
73 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
74 const sal_uLong nCount = rMarkList.GetMarkCount();
75 for(sal_uLong nNum = 0; nNum < nCount; nNum++)
77 SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
78 if( pObj->GetObjInventor() == SdrInventor )
81 switch(pObj->GetObjIdentifier())
83 case OBJ_TITLETEXT:
84 bTitle = sal_True;
85 break;
86 case OBJ_OUTLINETEXT:
87 bOutliner = sal_True;
88 break;
94 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET))
96 const SvxNumBulletItem *pItem = NULL;
97 if(bOutliner)
99 SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
100 String aStyleName((SdResId(STR_LAYOUT_OUTLINE)));
101 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
102 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
103 if( pFirstStyleSheet )
104 pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem);
107 if( pItem == NULL )
108 pItem = (SvxNumBulletItem*) aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
110 DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in Pool! [CL]" );
112 aInputSet.Put(*pItem, EE_PARA_NUMBULLET);
115 if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
117 SvxNumBulletItem* pItem = (SvxNumBulletItem*)aInputSet.GetItem(EE_PARA_NUMBULLET,sal_True);
118 SvxNumRule* pRule = pItem->GetNumRule();
119 if(pRule)
121 SvxNumRule aNewRule( *pRule );
122 aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True );
124 SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
125 aInputSet.Put(aNewItem);
129 SetInputSet( &aInputSet );
131 if(!bTitle)
132 AddTabPage(RID_SVXPAGE_PICK_SINGLE_NUM);
133 else
134 RemoveTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
136 AddTabPage( RID_SVXPAGE_PICK_BULLET );
137 AddTabPage( RID_SVXPAGE_PICK_BMP );
138 AddTabPage(RID_SVXPAGE_NUM_OPTIONS );
139 AddTabPage(RID_SVXPAGE_NUM_POSITION );
143 OutlineBulletDlg::~OutlineBulletDlg()
145 delete pOutputSet;
148 void OutlineBulletDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
150 switch ( nId )
152 case RID_SVXPAGE_NUM_OPTIONS:
154 if( pSdView )
156 FieldUnit eMetric = pSdView->GetDoc().GetUIUnit();
157 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
158 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
159 rPage.PageCreated(aSet);
162 break;
163 case RID_SVXPAGE_NUM_POSITION:
165 if( pSdView )
167 FieldUnit eMetric = pSdView->GetDoc().GetUIUnit();
168 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
169 aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
170 rPage.PageCreated(aSet);
173 break;
177 const SfxItemSet* OutlineBulletDlg::GetOutputItemSet() const
179 SfxItemSet aSet( *SfxTabDialog::GetOutputItemSet() );
180 pOutputSet->Put( aSet );
182 const SfxPoolItem *pItem = NULL;
183 if( SFX_ITEM_SET == pOutputSet->GetItemState(pOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), sal_False, &pItem ))
185 SdBulletMapper::MapFontsInNumRule( *((SvxNumBulletItem*)pItem)->GetNumRule(), *pOutputSet );
187 // #i35937 - removed EE_PARA_BULLETSTATE setting
191 if(bTitle && pOutputSet->GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
193 SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)pOutputSet->GetItem(EE_PARA_NUMBULLET,sal_True);
194 SvxNumRule* pRule = pBulletItem->GetNumRule();
195 if(pRule)
196 pRule->SetFeatureFlag( NUM_NO_NUMBERS, sal_False );
199 return pOutputSet;
202 } // end of namespace sd
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */