LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - prltempl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 161 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          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             : #include <editeng/outliner.hxx>
      21             : 
      22             : #include <svx/dialogs.hrc>
      23             : #include <svx/svxdlg.hxx>
      24             : #include <editeng/flstitem.hxx>
      25             : #include <svx/drawitem.hxx>
      26             : #include <svl/style.hxx>
      27             : #include <svx/tabline.hxx>
      28             : #include <editeng/bulletitem.hxx>
      29             : #include <editeng/eeitem.hxx>
      30             : #include <editeng/brushitem.hxx>
      31             : #include <vcl/graph.hxx>
      32             : #include <editeng/lrspitem.hxx>
      33             : #include <editeng/numitem.hxx>
      34             : #include <svl/cjkoptions.hxx>
      35             : 
      36             : #include "DrawDocShell.hxx"
      37             : #include "glob.hrc"
      38             : #include "sdresid.hxx"
      39             : #include "prltempl.hxx"
      40             : #include "prltempl.hrc"
      41             : #include "bulmaper.hxx"
      42             : #include <svl/intitem.hxx>
      43             : #include <svx/svxgrahicitem.hxx>
      44             : #include <svx/flagsdef.hxx>
      45             : #include "drawdoc.hxx"
      46             : #define IS_OUTLINE(x) (x >= PO_OUTLINE_1 && x <= PO_OUTLINE_9)
      47             : 
      48             : /**
      49             :  * Constructor of Tab dialog: appends pages to the dialog
      50             :  */
      51           0 : SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh,
      52             :                                 vcl::Window* pParent,
      53             :                                 SdResId DlgId,
      54             :                                 SfxStyleSheetBase& rStyleBase,
      55             :                                 PresentationObjects _ePO,
      56             :                                 SfxStyleSheetBasePool* pSSPool ) :
      57             :         SfxTabDialog        ( pParent
      58             :                             , "DrawPRTLDialog"
      59             :                             , "modules/sdraw/ui/drawprtldialog.ui"),
      60             :         mpDocShell          ( pDocSh ),
      61             :         ePO                 ( _ePO ),
      62           0 :         aInputSet           ( *rStyleBase.GetItemSet().GetPool(), SID_PARAM_NUM_PRESET, SID_PARAM_CUR_NUM_LEVEL ),
      63             :         pOutSet             ( NULL ),
      64           0 :         pOrgSet             ( &rStyleBase.GetItemSet() )
      65             : {
      66           0 :     if( IS_OUTLINE(ePO))
      67             :     {
      68             :         // Unfortunately, the Itemsets of our style sheets are not discreet..
      69           0 :         const sal_uInt16* pPtr = pOrgSet->GetRanges();
      70             :         sal_uInt16 p1, p2;
      71           0 :         while( *pPtr )
      72             :         {
      73           0 :             p1 = pPtr[0];
      74           0 :             p2 = pPtr[1];
      75             : 
      76             :             // first, we make it discreet
      77           0 :             while(pPtr[2] && (pPtr[2] - p2 == 1))
      78             :             {
      79           0 :                 p2 = pPtr[3];
      80           0 :                 pPtr += 2;
      81             :             }
      82           0 :             aInputSet.MergeRange( p1, p2 );
      83           0 :             pPtr += 2;
      84             :         }
      85             : 
      86           0 :         aInputSet.Put( rStyleBase.GetItemSet() );
      87             : 
      88             :         // need parent-relationship
      89           0 :         const SfxItemSet* pParentItemSet = rStyleBase.GetItemSet().GetParent();
      90           0 :         if( pParentItemSet )
      91           0 :             aInputSet.SetParent( pParentItemSet );
      92             : 
      93           0 :         pOutSet = new SfxItemSet( rStyleBase.GetItemSet() );
      94           0 :         pOutSet->ClearItem();
      95             : 
      96           0 :         const SfxPoolItem *pItem = NULL;
      97             : 
      98             :         // If there is no bullet item in this stylesheet, we get it
      99             :         // from 'Outline 1' style sheet.
     100           0 :         if( SfxItemState::SET != aInputSet.GetItemState(EE_PARA_NUMBULLET, false, &pItem ))
     101             :         {
     102           0 :             OUString aStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " 1");
     103           0 :             SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( aStyleName, SD_STYLE_FAMILY_PSEUDO);
     104             : 
     105           0 :             if(pFirstStyleSheet)
     106           0 :                 if( SfxItemState::SET == pFirstStyleSheet->GetItemSet().GetItemState(EE_PARA_NUMBULLET, false, &pItem) )
     107           0 :                     aInputSet.Put( *pItem );
     108             :         }
     109             : 
     110             :         // preselect selected layer in dialog
     111           0 :         aInputSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, 1<<GetOutlineLevel()));
     112             : 
     113           0 :         SetInputSet( &aInputSet );
     114             :     }
     115             :     else
     116           0 :         SetInputSet( pOrgSet );
     117             : 
     118           0 :     SvxColorListItem aColorListItem(*static_cast<const SvxColorListItem*>( mpDocShell->GetItem( SID_COLOR_TABLE ) ) );
     119           0 :     SvxGradientListItem aGradientListItem(*static_cast<const SvxGradientListItem*>( mpDocShell->GetItem( SID_GRADIENT_LIST ) ) );
     120           0 :     SvxBitmapListItem aBitmapListItem(*static_cast<const SvxBitmapListItem*>( mpDocShell->GetItem( SID_BITMAP_LIST ) ) );
     121           0 :     SvxHatchListItem aHatchListItem(*static_cast<const SvxHatchListItem*>( mpDocShell->GetItem( SID_HATCH_LIST ) ) );
     122           0 :     SvxDashListItem aDashListItem(*static_cast<const SvxDashListItem*>( mpDocShell->GetItem( SID_DASH_LIST ) ) );
     123           0 :     SvxLineEndListItem aLineEndListItem(*static_cast<const SvxLineEndListItem*>( mpDocShell->GetItem( SID_LINEEND_LIST ) ) );
     124             : 
     125           0 :     pColorTab = aColorListItem.GetColorList();
     126           0 :     pDashList = aDashListItem.GetDashList();
     127           0 :     pLineEndList = aLineEndListItem.GetLineEndList();
     128           0 :     pGradientList = aGradientListItem.GetGradientList();
     129           0 :     pHatchingList = aHatchListItem.GetHatchList();
     130           0 :     pBitmapList = aBitmapListItem.GetBitmapList();
     131             : 
     132           0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     133             :     OSL_ENSURE(pFact, "Dialog creation failed!");
     134             : 
     135           0 :     mnLine = AddTabPage( "RID_SVXPAGE_LINE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_LINE ), 0 );
     136           0 :     mnArea = AddTabPage( "RID_SVXPAGE_AREA", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), 0 );
     137           0 :     mnShadow = AddTabPage( "RID_SVXPAGE_SHADOW", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_SHADOW ), 0 );
     138           0 :     mnTransparency = AddTabPage( "RID_SVXPAGE_TRANSPARENCE", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), 0 );
     139           0 :     mnFont = AddTabPage( "RID_SVXPAGE_CHAR_NAME", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), 0 );
     140           0 :     mnEffects = AddTabPage( "RID_SVXPAGE_CHAR_EFFECTS", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), 0 );
     141           0 :     mnParagr = AddTabPage( "RID_SVXPAGE_STD_PARAGRAPH", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_STD_PARAGRAPH ), 0 );
     142           0 :     mnTextAtt = AddTabPage( "RID_SVXPAGE_TEXTATTR", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TEXTATTR ), 0 );
     143           0 :     mnBullet = AddTabPage( "RID_SVXPAGE_PICK_BULLET", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BULLET ), 0 );
     144           0 :     mnNum = AddTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_SINGLE_NUM ), 0 );
     145           0 :     mnBitmap = AddTabPage( "RID_SVXPAGE_PICK_BMP", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PICK_BMP ), 0 );
     146           0 :     mnOptions = AddTabPage( "RID_SVXPAGE_NUM_OPTIONS", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUM_OPTIONS ), 0 );
     147           0 :     mnTab =  AddTabPage( "RID_SVXPAGE_TABULATOR", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TABULATOR ), 0 );
     148           0 :     mnAsian = AddTabPage( "RID_SVXPAGE_PARA_ASIAN", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PARA_ASIAN ), 0 );
     149           0 :     mnAlign = AddTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGN_PARAGRAPH ), 0 );
     150             : 
     151           0 :     SvtCJKOptions aCJKOptions;
     152           0 :     if( !aCJKOptions.IsAsianTypographyEnabled() )
     153           0 :         RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
     154             : 
     155           0 :     if (DlgId.GetId() == TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND)
     156             :     {
     157           0 :         RemoveTabPage( "RID_SVXPAGE_LINE");
     158             : 
     159           0 :         RemoveTabPage( "RID_SVXPAGE_SHADOW");
     160           0 :         RemoveTabPage( "RID_SVXPAGE_TRANSPARENCE");
     161           0 :         RemoveTabPage( "RID_SVXPAGE_CHAR_NAME");
     162           0 :         RemoveTabPage( "RID_SVXPAGE_CHAR_EFFECTS");
     163           0 :         RemoveTabPage( "RID_SVXPAGE_STD_PARAGRAPH");
     164           0 :         RemoveTabPage( "RID_SVXPAGE_TEXTATTR");
     165           0 :         RemoveTabPage( "RID_SVXPAGE_PICK_BULLET");
     166           0 :         RemoveTabPage( "RID_SVXPAGE_PICK_SINGLE_NUM");
     167           0 :         RemoveTabPage( "RID_SVXPAGE_PICK_BMP");
     168           0 :         RemoveTabPage( "RID_SVXPAGE_NUM_OPTIONS");
     169           0 :         RemoveTabPage( "RID_SVXPAGE_TABULATOR");
     170           0 :         RemoveTabPage( "RID_SVXPAGE_ALIGN_PARAGRAPH");
     171           0 :         RemoveTabPage( "RID_SVXPAGE_PARA_ASIAN" );
     172             :     }
     173             : 
     174             :     // set title and add corresponding pages to dialog
     175           0 :     OUString aTitle;
     176             : 
     177           0 :     switch( ePO )
     178             :     {
     179             :         case PO_TITLE:
     180           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_TITLE ));
     181           0 :         break;
     182             : 
     183             :         case PO_SUBTITLE:
     184           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_SUBTITLE ));
     185           0 :         break;
     186             : 
     187             :         case PO_BACKGROUND:
     188           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_BACKGROUND ));
     189           0 :         break;
     190             : 
     191             :         case PO_BACKGROUNDOBJECTS:
     192           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_BACKGROUNDOBJECTS ));
     193           0 :         break;
     194             : 
     195             :         case PO_OUTLINE_1:
     196             :         case PO_OUTLINE_2:
     197             :         case PO_OUTLINE_3:
     198             :         case PO_OUTLINE_4:
     199             :         case PO_OUTLINE_5:
     200             :         case PO_OUTLINE_6:
     201             :         case PO_OUTLINE_7:
     202             :         case PO_OUTLINE_8:
     203             :         case PO_OUTLINE_9:
     204           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_OUTLINE )) + " " +
     205           0 :                 OUString::number( ePO - PO_OUTLINE_1 + 1 );
     206           0 :         break;
     207             : 
     208             :         case PO_NOTES:
     209           0 :             aTitle = OUString(SdResId( STR_PSEUDOSHEET_NOTES ));
     210           0 :         break;
     211             :     }
     212           0 :     SetText( aTitle );
     213             : 
     214           0 :     nDlgType = 1; // template dialog
     215           0 :     nPageType = 0;
     216           0 :     nPos = 0;
     217             : 
     218           0 :     nColorTableState = ChangeType::NONE;
     219           0 :     nBitmapListState = ChangeType::NONE;
     220           0 :     nGradientListState = ChangeType::NONE;
     221           0 :     nHatchingListState = ChangeType::NONE;
     222           0 : }
     223             : 
     224           0 : SdPresLayoutTemplateDlg::~SdPresLayoutTemplateDlg()
     225             : {
     226           0 :     disposeOnce();
     227           0 : }
     228             : 
     229           0 : void SdPresLayoutTemplateDlg::dispose()
     230             : {
     231           0 :     delete pOutSet;
     232           0 :     SfxTabDialog::dispose();
     233           0 : }
     234             : 
     235           0 : void SdPresLayoutTemplateDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
     236             : {
     237           0 :     SfxAllItemSet aSet(*(aInputSet.GetPool()));
     238             : 
     239           0 :     if (nId == mnLine)
     240             :         {
     241           0 :             aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
     242           0 :             aSet.Put (SvxDashListItem(pDashList,SID_DASH_LIST));
     243           0 :             aSet.Put (SvxLineEndListItem(pLineEndList,SID_LINEEND_LIST));
     244           0 :             aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
     245           0 :         rPage.PageCreated(aSet);
     246             :         }
     247             : 
     248           0 :     else if (nId == mnArea)
     249             :         {
     250           0 :             aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
     251           0 :             aSet.Put (SvxGradientListItem(pGradientList,SID_GRADIENT_LIST));
     252           0 :             aSet.Put (SvxHatchListItem(pHatchingList,SID_HATCH_LIST));
     253           0 :             aSet.Put (SvxBitmapListItem(pBitmapList,SID_BITMAP_LIST));
     254           0 :             aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
     255           0 :             aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
     256           0 :             aSet.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
     257           0 :             rPage.PageCreated(aSet);
     258             :         }
     259             : 
     260           0 :     else if (nId == mnShadow)
     261             :         {
     262           0 :             aSet.Put (SvxColorListItem(pColorTab,SID_COLOR_TABLE));
     263           0 :             aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
     264           0 :             aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
     265           0 :             rPage.PageCreated(aSet);
     266             :         }
     267             : 
     268           0 :     else if (nId == mnTransparency)
     269             :         {
     270           0 :             aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
     271           0 :             aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType));
     272           0 :             rPage.PageCreated(aSet);
     273             :         }
     274             : 
     275           0 :     else if (nId == mnFont)
     276             :         {
     277           0 :             SvxFontListItem aItem(*static_cast<const SvxFontListItem*>(mpDocShell->GetItem( SID_ATTR_CHAR_FONTLIST) ) );
     278           0 :             aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
     279           0 :             rPage.PageCreated(aSet);
     280             :         }
     281             : 
     282           0 :     else if (nId == mnEffects)
     283             :         {
     284           0 :             rPage.PageCreated(aSet);
     285           0 :         }
     286           0 : }
     287             : 
     288           0 : const SfxItemSet* SdPresLayoutTemplateDlg::GetOutputItemSet() const
     289             : {
     290           0 :     if( pOutSet )
     291             :     {
     292           0 :         pOutSet->Put( *SfxTabDialog::GetOutputItemSet() );
     293             : 
     294           0 :         const SvxNumBulletItem *pSvxNumBulletItem = NULL;
     295           0 :         if( SfxItemState::SET == pOutSet->GetItemState(EE_PARA_NUMBULLET, false, reinterpret_cast<const SfxPoolItem**>(&pSvxNumBulletItem) ))
     296           0 :             SdBulletMapper::MapFontsInNumRule( *pSvxNumBulletItem->GetNumRule(), *pOutSet );
     297           0 :         return pOutSet;
     298             :     }
     299             :     else
     300           0 :         return SfxTabDialog::GetOutputItemSet();
     301             : }
     302             : 
     303           0 : sal_uInt16 SdPresLayoutTemplateDlg::GetOutlineLevel() const
     304             : {
     305           0 :     switch( ePO )
     306             :     {
     307           0 :     case PO_OUTLINE_1: return 0;
     308           0 :     case PO_OUTLINE_2: return 1;
     309           0 :     case PO_OUTLINE_3: return 2;
     310           0 :     case PO_OUTLINE_4: return 3;
     311           0 :     case PO_OUTLINE_5: return 4;
     312           0 :     case PO_OUTLINE_6: return 5;
     313           0 :     case PO_OUTLINE_7: return 6;
     314           0 :     case PO_OUTLINE_8: return 7;
     315           0 :     case PO_OUTLINE_9: return 8;
     316             :     default:
     317             :         DBG_ASSERT( false, "Wrong Po! [CL]");
     318             :     }
     319           0 :     return 0;
     320           0 : }
     321             : 
     322             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11