Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #ifdef SD_DLLIMPLEMENTATION
22 : #undef SD_DLLIMPLEMENTATION
23 : #endif
24 :
25 : #include "OutlineBulletDlg.hxx"
26 :
27 : #include <svx/svxids.hrc>
28 : #include <sfx2/objsh.hxx>
29 : #include <svx/drawitem.hxx>
30 : #include <editeng/bulitem.hxx>
31 : #include <editeng/eeitem.hxx>
32 :
33 : #include <editeng/numitem.hxx>
34 :
35 : #include <svx/dialogs.hrc>
36 : #include <svl/intitem.hxx>
37 : #include <svx/svdmark.hxx>
38 : #include "View.hxx"
39 : #include <svx/svdobj.hxx>
40 : #include <svl/style.hxx>
41 : #include <drawdoc.hxx>
42 :
43 : #include "sdresid.hxx"
44 :
45 : #include "glob.hrc"
46 : #include "dlgolbul.hrc"
47 : #include "bulmaper.hxx"
48 : #include "DrawDocShell.hxx"
49 : #include <svl/aeitem.hxx>
50 :
51 : namespace sd {
52 :
53 : /*************************************************************************
54 : |*
55 : |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
56 : |*
57 : \************************************************************************/
58 :
59 0 : OutlineBulletDlg::OutlineBulletDlg(
60 : ::Window* pParent,
61 : const SfxItemSet* pAttr,
62 : ::sd::View* pView )
63 : : SfxTabDialog ( pParent, SdResId(TAB_OUTLINEBULLET) ),
64 : aInputSet ( *pAttr ),
65 : bTitle ( sal_False ),
66 0 : pSdView ( pView )
67 : {
68 0 : FreeResource();
69 :
70 0 : aInputSet.MergeRange( SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL );
71 0 : aInputSet.Put( *pAttr );
72 :
73 0 : pOutputSet = new SfxItemSet( *pAttr );
74 0 : pOutputSet->ClearItem();
75 :
76 0 : sal_Bool bOutliner = sal_False;
77 :
78 : // Sonderbehandlung wenn eine Title Objekt selektiert wurde
79 0 : if( pView )
80 : {
81 0 : const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
82 0 : const sal_uLong nCount = rMarkList.GetMarkCount();
83 0 : for(sal_uLong nNum = 0; nNum < nCount; nNum++)
84 : {
85 0 : SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
86 0 : if( pObj->GetObjInventor() == SdrInventor )
87 : {
88 :
89 0 : switch(pObj->GetObjIdentifier())
90 : {
91 : case OBJ_TITLETEXT:
92 0 : bTitle = sal_True;
93 0 : break;
94 : case OBJ_OUTLINETEXT:
95 0 : bOutliner = sal_True;
96 0 : break;
97 : }
98 : }
99 : }
100 : }
101 :
102 0 : if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET))
103 : {
104 0 : const SvxNumBulletItem *pItem = NULL;
105 0 : if(bOutliner)
106 : {
107 0 : SfxStyleSheetBasePool* pSSPool = pView->GetDocSh()->GetStyleSheetPool();
108 0 : String aStyleName((SdResId(STR_LAYOUT_OUTLINE)));
109 0 : aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) );
110 0 : SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
111 0 : if( pFirstStyleSheet )
112 0 : pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pItem);
113 : }
114 :
115 0 : if( pItem == NULL )
116 0 : pItem = (SvxNumBulletItem*) aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
117 :
118 : DBG_ASSERT( pItem, "Kein EE_PARA_NUMBULLET im Pool! [CL]" );
119 :
120 0 : aInputSet.Put(*pItem, EE_PARA_NUMBULLET);
121 : }
122 :
123 0 : if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
124 : {
125 0 : SvxNumBulletItem* pItem = (SvxNumBulletItem*)aInputSet.GetItem(EE_PARA_NUMBULLET,sal_True);
126 0 : SvxNumRule* pRule = pItem->GetNumRule();
127 0 : if(pRule)
128 : {
129 0 : SvxNumRule aNewRule( *pRule );
130 0 : aNewRule.SetFeatureFlag( NUM_NO_NUMBERS, sal_True );
131 :
132 0 : SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET );
133 0 : aInputSet.Put(aNewItem);
134 : }
135 : }
136 :
137 0 : SetInputSet( &aInputSet );
138 :
139 0 : if(!bTitle)
140 0 : AddTabPage(RID_SVXPAGE_PICK_SINGLE_NUM);
141 : else
142 0 : RemoveTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
143 :
144 0 : AddTabPage( RID_SVXPAGE_PICK_BULLET );
145 0 : AddTabPage( RID_SVXPAGE_PICK_BMP );
146 0 : AddTabPage(RID_SVXPAGE_NUM_OPTIONS );
147 0 : AddTabPage(RID_SVXPAGE_NUM_POSITION );
148 :
149 0 : }
150 :
151 0 : OutlineBulletDlg::~OutlineBulletDlg()
152 : {
153 0 : delete pOutputSet;
154 0 : }
155 :
156 0 : void OutlineBulletDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
157 : {
158 0 : switch ( nId )
159 : {
160 : case RID_SVXPAGE_NUM_OPTIONS:
161 : {
162 0 : if( pSdView )
163 : {
164 0 : FieldUnit eMetric = pSdView->GetDoc().GetUIUnit();
165 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
166 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
167 0 : rPage.PageCreated(aSet);
168 : }
169 : }
170 0 : break;
171 : case RID_SVXPAGE_NUM_POSITION:
172 : {
173 0 : if( pSdView )
174 : {
175 0 : FieldUnit eMetric = pSdView->GetDoc().GetUIUnit();
176 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
177 0 : aSet.Put ( SfxAllEnumItem(SID_METRIC_ITEM,(sal_uInt16)eMetric));
178 0 : rPage.PageCreated(aSet);
179 : }
180 : }
181 0 : break;
182 : }
183 0 : }
184 :
185 0 : const SfxItemSet* OutlineBulletDlg::GetOutputItemSet() const
186 : {
187 0 : SfxItemSet aSet( *SfxTabDialog::GetOutputItemSet() );
188 0 : pOutputSet->Put( aSet );
189 :
190 0 : const SfxPoolItem *pItem = NULL;
191 0 : if( SFX_ITEM_SET == pOutputSet->GetItemState(pOutputSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE), sal_False, &pItem ))
192 : {
193 0 : SdBulletMapper::MapFontsInNumRule( *((SvxNumBulletItem*)pItem)->GetNumRule(), *pOutputSet );
194 :
195 : // #i35937 - removed EE_PARA_BULLETSTATE setting
196 : }
197 :
198 :
199 0 : if(bTitle && pOutputSet->GetItemState(EE_PARA_NUMBULLET,sal_True) == SFX_ITEM_ON )
200 : {
201 0 : SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)pOutputSet->GetItem(EE_PARA_NUMBULLET,sal_True);
202 0 : SvxNumRule* pRule = pBulletItem->GetNumRule();
203 0 : if(pRule)
204 0 : pRule->SetFeatureFlag( NUM_NO_NUMBERS, sal_False );
205 : }
206 :
207 0 : return pOutputSet;
208 : }
209 :
210 0 : } // end of namespace sd
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|