1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #ifdef SD_DLLIMPLEMENTATION 32 #undef SD_DLLIMPLEMENTATION 33 #endif 34 35 36 #include "eetext.hxx" 37 38 #include <svx/dialogs.hrc> 39 #include <editeng/flstitem.hxx> 40 #include <svx/drawitem.hxx> 41 #include <svl/style.hxx> 42 #include <svx/tabline.hxx> 43 #include <editeng/bulitem.hxx> 44 #include <editeng/eeitem.hxx> 45 #include <editeng/brshitem.hxx> 46 #include <vcl/graph.hxx> 47 #include <editeng/lrspitem.hxx> 48 #include <editeng/numitem.hxx> 49 #include <svl/cjkoptions.hxx> 50 51 #include "DrawDocShell.hxx" 52 #include "glob.hrc" 53 #include "sdresid.hxx" 54 #include "prltempl.hxx" 55 #include "prltempl.hrc" 56 #include "enumdlg.hrc" 57 //#include "enumdlg.hxx" 58 #include "bulmaper.hxx" 59 #include <svl/intitem.hxx> 60 #include <svx/svxgrahicitem.hxx> 61 #include <svx/flagsdef.hxx> 62 #include "drawdoc.hxx" 63 #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9) 64 65 /************************************************************************* 66 |* 67 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu 68 |* 69 \************************************************************************/ 70 71 SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh, 72 Window* pParent, 73 SdResId DlgId, 74 SfxStyleSheetBase& rStyleBase, 75 PresentationObjects _ePO, 76 SfxStyleSheetBasePool* pSSPool ) : 77 SfxTabDialog ( pParent, DlgId ), 78 mpDocShell ( pDocSh ), 79 ePO ( _ePO ), 80 aInputSet ( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ), 81 pOutSet ( NULL ), 82 pOrgSet ( &rStyleBase.GetItemSet() ) 83 { 84 if( IS_OUTLINE(ePO)) 85 { 86 // Leider sind die Itemsets unserer Stylesheets nicht discret.. 87 const sal_uInt16* pPtr = pOrgSet->GetRanges(); 88 sal_uInt16 p1, p2; 89 while( *pPtr ) 90 { 91 p1 = pPtr[0]; 92 p2 = pPtr[1]; 93 94 // erstmal das ganze discret machen 95 while(pPtr[2] && (pPtr[2] - p2 == 1)) 96 { 97 p2 = pPtr[3]; 98 pPtr += 2; 99 } 100 aInputSet.MergeRange( p1, p2 ); 101 pPtr += 2; 102 } 103 104 aInputSet.Put( rStyleBase.GetItemSet() ); 105 106 // need parent-relationship 107 const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();; 108 if( pParentItemSet ) 109 aInputSet.SetParent( pParentItemSet ); 110 111 pOutSet = new SfxItemSet( rStyleBase.GetItemSet() ); 112 pOutSet->ClearItem(); 113 114 const SfxPoolItem *pItem = NULL; 115 116 // Fals in diesem Stylesheet kein Bullet Item ist, holen wir uns 117 // das aus dem 'Outline 1' Stylesheet. 118 if( SFX_ITEM_SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem )) 119 { 120 String aStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE))); 121 aStyleName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " 1" ) ); 122 SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO); 123 124 if(pFirstStyleSheet) 125 if( SFX_ITEM_SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, sal_False, &pItem) ) 126 aInputSet.Put( *pItem ); 127 } 128 129 // gewaehlte Ebene im Dialog vorselektieren 130 aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel())); 131 132 SetInputSet( &aInputSet ); 133 } 134 else 135 SetInputSet( pOrgSet ); 136 137 FreeResource(); 138 139 SvxColorTableItem aColorTableItem(*( (const SvxColorTableItem*) 140 ( mpDocShell->GetItem( SID_COLOR_TABLE ) ) ) ); 141 SvxGradientListItem aGradientListItem(*( (const SvxGradientListItem*) 142 ( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) ) ); 143 SvxBitmapListItem aBitmapListItem(*( (const SvxBitmapListItem*) 144 ( mpDocShell->GetItem( SID_BITMAP_LIST ) ) ) ); 145 SvxHatchListItem aHatchListItem(*( (const SvxHatchListItem*) 146 ( mpDocShell->GetItem( SID_HATCH_LIST ) ) ) ); 147 SvxDashListItem aDashListItem(*( (const SvxDashListItem*) 148 ( mpDocShell->GetItem( SID_DASH_LIST ) ) ) ); 149 SvxLineEndListItem aLineEndListItem(*( (const SvxLineEndListItem*) 150 ( mpDocShell->GetItem( SID_LINEEND_LIST ) ) ) ); 151 152 pColorTab = aColorTableItem.GetColorTable(); 153 pDashList = aDashListItem.GetDashList(); 154 pLineEndList = aLineEndListItem.GetLineEndList(); 155 pGradientList = aGradientListItem.GetGradientList(); 156 pHatchingList = aHatchListItem.GetHatchList(); 157 pBitmapList = aBitmapListItem.GetBitmapList(); 158 159 switch( DlgId.GetId() ) 160 { 161 case TAB_PRES_LAYOUT_TEMPLATE: 162 { 163 AddTabPage( RID_SVXPAGE_LINE); 164 AddTabPage( RID_SVXPAGE_AREA); 165 AddTabPage( RID_SVXPAGE_SHADOW); 166 AddTabPage( RID_SVXPAGE_TRANSPARENCE); 167 AddTabPage( RID_SVXPAGE_CHAR_NAME ); 168 AddTabPage( RID_SVXPAGE_CHAR_EFFECTS ); 169 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH ); 170 AddTabPage( RID_SVXPAGE_TEXTATTR ); 171 AddTabPage( RID_SVXPAGE_PICK_BULLET ); 172 AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM ); 173 AddTabPage( RID_SVXPAGE_PICK_BMP ); 174 AddTabPage( RID_SVXPAGE_NUM_OPTIONS ); 175 AddTabPage( RID_SVXPAGE_TABULATOR ); 176 } 177 break; 178 179 case TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND: // background 180 AddTabPage( RID_SVXPAGE_AREA); 181 break; 182 } 183 184 // #112490# the tabpages Alignment, Tabs and Asian Typography are very 185 // usefull, except for the background style 186 if( DlgId.GetId() != TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND ) 187 { 188 SvtCJKOptions aCJKOptions; 189 if( aCJKOptions.IsAsianTypographyEnabled() ) 190 AddTabPage( RID_SVXPAGE_PARA_ASIAN ); 191 else 192 RemoveTabPage( RID_SVXPAGE_PARA_ASIAN ); 193 194 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH ); 195 } 196 197 // Titel setzen und 198 // entsprechende Seiten zum Dialog hinzufuegen 199 String aTitle; 200 201 switch( ePO ) 202 { 203 case PO_TITLE: 204 aTitle = String(SdResId( STR_PSEUDOSHEET_TITLE )); 205 break; 206 207 case PO_SUBTITLE: 208 aTitle = String(SdResId( STR_PSEUDOSHEET_SUBTITLE )); 209 break; 210 211 case PO_BACKGROUND: 212 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUND )); 213 break; 214 215 case PO_BACKGROUNDOBJECTS: 216 aTitle = String(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS )); 217 break; 218 219 case PO_OUTLINE_1: 220 case PO_OUTLINE_2: 221 case PO_OUTLINE_3: 222 case PO_OUTLINE_4: 223 case PO_OUTLINE_5: 224 case PO_OUTLINE_6: 225 case PO_OUTLINE_7: 226 case PO_OUTLINE_8: 227 case PO_OUTLINE_9: 228 aTitle = String(SdResId( STR_PSEUDOSHEET_OUTLINE )); 229 aTitle.Append( sal_Unicode(' ') ); 230 aTitle.Append( UniString::CreateFromInt32( ePO - PO_OUTLINE_1 + 1 ) ); 231 break; 232 233 case PO_NOTES: 234 aTitle = String(SdResId( STR_PSEUDOSHEET_NOTES )); 235 break; 236 } 237 SetText( aTitle ); 238 239 nDlgType = 1; // Vorlagen-Dialog 240 nPageType = 0; 241 nPos = 0; 242 243 nColorTableState = CT_NONE; 244 nBitmapListState = CT_NONE; 245 nGradientListState = CT_NONE; 246 nHatchingListState = CT_NONE; 247 } 248 249 // ----------------------------------------------------------------------- 250 251 SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg() 252 { 253 delete pOutSet; 254 } 255 256 // ----------------------------------------------------------------------- 257 258 void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) 259 { SfxAllItemSet aSet(*(aInputSet.GetPool())); 260 switch( nId ) 261 { 262 case RID_SVXPAGE_LINE: 263 { 264 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE)); 265 aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST)); 266 aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST)); 267 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); 268 269 rPage.PageCreated(aSet); 270 } 271 break; 272 273 case RID_SVXPAGE_AREA: 274 { 275 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE)); 276 aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST)); 277 aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST)); 278 aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST)); 279 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType)); 280 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); 281 aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos)); 282 rPage.PageCreated(aSet); 283 284 } 285 break; 286 287 case RID_SVXPAGE_SHADOW: 288 aSet.Put (SvxColorTableItem(pColorTab,SID_COLOR_TABLE)); //add CHINA001 289 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType)); 290 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); 291 rPage.PageCreated(aSet); 292 break; 293 294 case RID_SVXPAGE_TRANSPARENCE: 295 aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType)); 296 aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); 297 rPage.PageCreated(aSet); 298 break; 299 300 case RID_SVXPAGE_CHAR_NAME: 301 { 302 SvxFontListItem aItem(*( (const SvxFontListItem*) 303 ( mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) ) ); 304 305 aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST)); 306 rPage.PageCreated(aSet); 307 } 308 break; 309 310 case RID_SVXPAGE_CHAR_EFFECTS: 311 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP)); 312 rPage.PageCreated(aSet); 313 break; 314 315 case RID_SVXPAGE_STD_PARAGRAPH: 316 break; 317 } 318 } 319 320 const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const 321 { 322 if( pOutSet ) 323 { 324 pOutSet->Put( *SfxTabDialog::GetOutputItemSet() ); 325 326 const SvxNumBulletItem *pSvxNumBulletItem = NULL; 327 if( SFX_ITEM_SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, sal_False, (const SfxPoolItem**)&pSvxNumBulletItem )) 328 SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet ); 329 return pOutSet; 330 } 331 else 332 return SfxTabDialog::GetOutputItemSet(); 333 } 334 335 // --------------------------------------------------------------------- 336 // --------------------------------------------------------------------- 337 sal_uInt16 SdPresLayoutTemplateDlg::GetOutlineLevel() const 338 { 339 switch( ePO ) 340 { 341 case PO_OUTLINE_1: return 0; 342 case PO_OUTLINE_2: return 1; 343 case PO_OUTLINE_3: return 2; 344 case PO_OUTLINE_4: return 3; 345 case PO_OUTLINE_5: return 4; 346 case PO_OUTLINE_6: return 5; 347 case PO_OUTLINE_7: return 6; 348 case PO_OUTLINE_8: return 7; 349 case PO_OUTLINE_9: return 8; 350 default: 351 DBG_ASSERT( sal_False, "Falscher Po! [CL]"); 352 } 353 return 0; 354 } 355 356 357 358