LCOV - code coverage report
Current view: top level - sw/source/ui/chrdlg - pardlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 90 0.0 %
Date: 2014-04-14 Functions: 0 6 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 "hintids.hxx"
      21             : #include <sfx2/htmlmode.hxx>
      22             : #include <sfx2/tabdlg.hxx>
      23             : #include <svl/style.hxx>
      24             : #include <svtools/htmlcfg.hxx>
      25             : #include <svl/cjkoptions.hxx>
      26             : #include "docsh.hxx"
      27             : #include "wrtsh.hxx"
      28             : #include "frmatr.hxx"
      29             : #include "view.hxx"
      30             : #include "globals.hrc"
      31             : #include "swuipardlg.hxx"
      32             : #include "pagedesc.hxx"
      33             : #include "paratr.hxx"
      34             : #include "drpcps.hxx"
      35             : #include "uitool.hxx"
      36             : #include "viewopt.hxx"
      37             : #include <numpara.hxx>
      38             : #include "chrdlg.hrc"
      39             : #include "poolfmt.hrc"
      40             : #include <svx/svxids.hrc>
      41             : #include <svl/eitem.hxx>
      42             : #include <svl/intitem.hxx>
      43             : #include <svx/svxdlg.hxx>
      44             : #include <svx/dialogs.hrc>
      45             : #include <svx/flagsdef.hxx>
      46             : 
      47           0 : SwParaDlg::SwParaDlg(Window *pParent,
      48             :                     SwView& rVw,
      49             :                     const SfxItemSet& rCoreSet,
      50             :                     sal_uInt8 nDialogMode,
      51             :                     const OUString *pTitle,
      52             :                     sal_Bool bDraw,
      53             :                     const OString& sDefPage)
      54             :     : SfxTabDialog(pParent,
      55             :                  "ParagraphPropertiesDialog",
      56             :                  "modules/swriter/ui/paradialog.ui",
      57             :                  &rCoreSet,  0 != pTitle)
      58             :     , rView(rVw)
      59             :     , nDlgMode(nDialogMode)
      60             :     , bDrawParaDlg(bDraw)
      61             :     , m_nParaStd(0)
      62             :     , m_nParaAlign(0)
      63             :     , m_nParaExt(0)
      64             :     , m_nParaNumPara(0)
      65             :     , m_nParaDrpCps(0)
      66             :     , m_nParaBckGrnd(0)
      67           0 :     , m_nParaBorder(0)
      68             : {
      69           0 :     nHtmlMode = ::GetHtmlMode(rVw.GetDocShell());
      70           0 :     sal_Bool bHtmlMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
      71           0 :     if(pTitle)
      72             :     {
      73             :         // Update title
      74           0 :         SetText(GetText() + SW_RESSTR(STR_TEXTCOLL_HEADER) + *pTitle + OUString(')'));
      75             :     }
      76             :     // tabs common to paragraph and draw paragraphs (paragraphs inside a text box)
      77           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      78             : 
      79             :     OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageCreatorFunc fail!");
      80             :     OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH), "GetTabPageRangesFunc fail!");
      81           0 :     m_nParaStd = AddTabPage("labelTP_PARA_STD", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_STD_PARAGRAPH),
      82           0 :                             pFact->GetTabPageRangesFunc(RID_SVXPAGE_STD_PARAGRAPH) );
      83             : 
      84             :     OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageCreatorFunc fail!");
      85             :     OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH), "GetTabPageRangesFunc fail!");
      86           0 :     m_nParaAlign = AddTabPage( "labelTP_PARA_ALIGN", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_ALIGN_PARAGRAPH),
      87           0 :                                pFact->GetTabPageRangesFunc(RID_SVXPAGE_ALIGN_PARAGRAPH) );
      88             : 
      89           0 :     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
      90           0 :     if (!bDrawParaDlg && (!bHtmlMode || rHtmlOpt.IsPrintLayoutExtension()))
      91             :     {
      92             :         OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageCreatorFunc fail!");
      93             :         OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH), "GetTabPageRangesFunc fail!");
      94           0 :         m_nParaExt = AddTabPage( "labelTP_PARA_EXT", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_EXT_PARAGRAPH),
      95           0 :                                  pFact->GetTabPageRangesFunc(RID_SVXPAGE_EXT_PARAGRAPH) );
      96             : 
      97             :     }
      98             :     else
      99           0 :         RemoveTabPage("labelTP_PARA_EXT");
     100             : 
     101           0 :     SvtCJKOptions aCJKOptions;
     102           0 :     if(!bHtmlMode && aCJKOptions.IsAsianTypographyEnabled())
     103             :     {
     104             :         OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
     105             :         OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
     106           0 :         AddTabPage( "labelTP_PARA_ASIAN",  pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),
     107           0 :                                    pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
     108             :     }
     109             :     else
     110           0 :         RemoveTabPage("labelTP_PARA_ASIAN");
     111             : 
     112           0 :     sal_uInt16 nWhich(rCoreSet.GetPool()->GetWhich(SID_ATTR_LRSPACE));
     113           0 :     bool bLRValid = SFX_ITEM_AVAILABLE <= rCoreSet.GetItemState(nWhich);
     114           0 :     if(bHtmlMode || !bLRValid)
     115           0 :         RemoveTabPage("labelTP_TABULATOR");
     116             :     else
     117             :     {
     118             :         OSL_ENSURE(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), "GetTabPageCreatorFunc fail!");
     119             :         OSL_ENSURE(pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR), "GetTabPageRangesFunc fail!");
     120           0 :         AddTabPage( "labelTP_TABULATOR", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_TABULATOR), pFact->GetTabPageRangesFunc(RID_SVXPAGE_TABULATOR) );
     121             :     }
     122             : 
     123             :     // remove unwanted tabs for draw text box paragraph properties
     124           0 :     if (bDrawParaDlg)
     125             :     {
     126           0 :         RemoveTabPage("labelTP_NUMPARA");
     127           0 :         RemoveTabPage("labelTP_DROPCAPS");
     128           0 :         RemoveTabPage("labelTP_BACKGROUND");
     129           0 :         RemoveTabPage("labelTP_BORDER");
     130             :     }
     131             :     else
     132             :     {
     133           0 :         if(!(nDlgMode & DLG_ENVELOP))
     134           0 :             m_nParaNumPara = AddTabPage("labelTP_NUMPARA", SwParagraphNumTabPage::Create, SwParagraphNumTabPage::GetRanges);
     135             :         else
     136           0 :             RemoveTabPage("labelTP_NUMPARA");
     137             : 
     138           0 :         m_nParaDrpCps = AddTabPage("labelTP_DROPCAPS",  SwDropCapsPage::Create, SwDropCapsPage::GetRanges);
     139             : 
     140           0 :         if(!bHtmlMode || (nHtmlMode & (HTMLMODE_SOME_STYLES|HTMLMODE_FULL_STYLES)))
     141             :         {
     142             :             OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
     143             :             OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
     144           0 :             m_nParaBckGrnd = AddTabPage("labelTP_BACKGROUND", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
     145             :         }
     146             :         else
     147             :         {
     148           0 :             RemoveTabPage("labelTP_BACKGROUND");
     149             :         }
     150             : 
     151             :         OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
     152             :         OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
     153           0 :         m_nParaBorder = AddTabPage("labelTP_BORDER", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
     154             :     }
     155             : 
     156           0 :     if (!sDefPage.isEmpty())
     157           0 :         SetCurPageId(sDefPage);
     158           0 : }
     159             : 
     160           0 : SwParaDlg::~SwParaDlg()
     161             : {
     162           0 : }
     163             : 
     164           0 : void SwParaDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage)
     165             : {
     166           0 :     SwWrtShell& rSh = rView.GetWrtShell();
     167           0 :     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
     168             : 
     169             :     // Table borders cannot get any shade in Writer
     170           0 :     if (nId == m_nParaBorder)
     171             :     {
     172           0 :         aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_PARA));
     173           0 :         rPage.PageCreated(aSet);
     174             :     }
     175           0 :     else if( nId == m_nParaStd )
     176             :     {
     177             :         aSet.Put(SfxUInt16Item(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,
     178           0 :                             static_cast< sal_uInt16 >(rSh.GetAnyCurRect(RECT_PAGE_PRT).Width()) ));
     179             : 
     180           0 :         if (!bDrawParaDlg)
     181             :         {
     182             :             // See SvxStdParagraphTabPage::PageCreated: enable RegisterMode, AutoFirstLine, NegativeMode, ContextualMode
     183           0 :             aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,0x0002|0x0004|0x0008|0x0010));
     184           0 :             aSet.Put(SfxUInt32Item(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, MM50/10));
     185             : 
     186             :         }
     187           0 :         rPage.PageCreated(aSet);
     188             :     }
     189           0 :     else if( m_nParaAlign == nId)
     190             :     {
     191           0 :         if (!bDrawParaDlg)
     192             :         {
     193           0 :             aSet.Put(SfxBoolItem(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,true));
     194           0 :             rPage.PageCreated(aSet);
     195             :         }
     196             :     }
     197           0 :     else if( m_nParaExt == nId )
     198             :     {
     199             :         // pagebreak only when the cursor is in the body-area and not in a table
     200           0 :         const sal_uInt16 eType = rSh.GetFrmType(0,sal_True);
     201           0 :         if( !(FRMTYPE_BODY & eType) ||
     202           0 :             rSh.GetSelectionType() & nsSelectionType::SEL_TBL )
     203             :         {
     204           0 :             aSet.Put(SfxBoolItem(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,true));
     205           0 :             rPage.PageCreated(aSet);
     206             :         }
     207             :     }
     208           0 :     else if( m_nParaDrpCps == nId )
     209             :     {
     210           0 :         ((SwDropCapsPage&)rPage).SetFormat(sal_False);
     211             :     }
     212           0 :     else if( m_nParaBckGrnd == nId )
     213             :     {
     214           0 :       if(!( nHtmlMode & HTMLMODE_ON ) ||
     215           0 :         nHtmlMode & HTMLMODE_SOME_STYLES)
     216             :         {
     217           0 :             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
     218           0 :             rPage.PageCreated(aSet);
     219             :         }
     220             :     }
     221           0 :     else if( m_nParaNumPara == nId)
     222             :     {
     223           0 :         SwTxtFmtColl* pTmpColl = rSh.GetCurTxtFmtColl();
     224           0 :         if( pTmpColl && pTmpColl->IsAssignedToListLevelOfOutlineStyle() )
     225             :         {
     226           0 :             ((SwParagraphNumTabPage&)rPage).DisableOutline() ;
     227             :         }
     228             : 
     229           0 :         ((SwParagraphNumTabPage&)rPage).EnableNewStart();
     230           0 :         ListBox & rBox = ((SwParagraphNumTabPage&)rPage).GetStyleBox();
     231           0 :         SfxStyleSheetBasePool* pPool = rView.GetDocShell()->GetStyleSheetPool();
     232           0 :         pPool->SetSearchMask(SFX_STYLE_FAMILY_PSEUDO, SFXSTYLEBIT_ALL);
     233           0 :         const SfxStyleSheetBase* pBase = pPool->First();
     234           0 :         std::set<OUString> aNames;
     235           0 :         while(pBase)
     236             :         {
     237           0 :             aNames.insert(pBase->GetName());
     238           0 :             pBase = pPool->Next();
     239             :         }
     240           0 :         for(std::set<OUString>::const_iterator it = aNames.begin(); it != aNames.end(); ++it)
     241           0 :             rBox.InsertEntry(*it);
     242           0 :     }
     243             : 
     244           0 : }
     245             : 
     246             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10