LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/config - optload.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 474 0.0 %
Date: 2013-07-09 Functions: 0 38 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 <officecfg/Office/Writer.hxx>
      21             : #include <comphelper/string.hxx>
      22             : #include <tools/shl.hxx>
      23             : #include <swtypes.hxx>
      24             : #include <helpid.h>
      25             : #include <uiitems.hxx>
      26             : #include <modcfg.hxx>
      27             : #include "swmodule.hxx"
      28             : #include "usrpref.hxx"
      29             : #include "wrtsh.hxx"
      30             : #include "linkenum.hxx"
      31             : #include <uitool.hxx>
      32             : #include <view.hxx>
      33             : 
      34             : #include "globals.hrc"
      35             : #include "cmdid.h"
      36             : 
      37             : #include "optload.hrc"
      38             : #include "optload.hxx"
      39             : #include <svx/dlgutil.hxx>
      40             : #include <sfx2/htmlmode.hxx>
      41             : #include <fldmgr.hxx>
      42             : #include <poolfmt.hxx>
      43             : #include <expfld.hxx>
      44             : #include <caption.hxx>
      45             : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      46             : 
      47             : #include <svtools/insdlg.hxx>
      48             : #include "svtools/treelistentry.hxx"
      49             : #include <comphelper/classids.hxx>
      50             : #include <unotools/configmgr.hxx>
      51             : #include <docsh.hxx>
      52             : #include <config.hrc>
      53             : #include <SwStyleNameMapper.hxx>
      54             : #include <numrule.hxx>
      55             : #include <SwNodeNum.hxx>
      56             : 
      57             : #include <doc.hxx>
      58             : #include <svl/cjkoptions.hxx>
      59             : 
      60             : using namespace ::com::sun::star;
      61             : 
      62             : #include <svl/eitem.hxx>
      63             : 
      64           0 : SwLoadOptPage::SwLoadOptPage(Window* pParent, const SfxItemSet& rSet)
      65             :     : SfxTabPage(pParent, "OptGeneralPage",
      66             :         "modules/swriter/ui/optgeneralpage.ui", rSet)
      67             :     , m_pWrtShell(NULL)
      68             :     , m_nLastTab(0)
      69           0 :     , m_nOldLinkMode(MANUAL)
      70             : {
      71           0 :     get(m_pAlwaysRB, "always");
      72           0 :     get(m_pRequestRB, "onrequest");
      73           0 :     get(m_pNeverRB, "never");
      74           0 :     get(m_pAutoUpdateFields, "updatefields");
      75           0 :     get(m_pAutoUpdateCharts, "updatecharts");
      76           0 :     get(m_pMetricLB, "metric");
      77           0 :     get(m_pTabFT, "tablabel");
      78           0 :     get(m_pTabMF, "tab");
      79           0 :     get(m_pUseSquaredPageMode, "squaremode");
      80           0 :     get(m_pUseCharUnit, "usecharunit");
      81           0 :     get(m_pWordCountED, "wordcount");
      82             : 
      83           0 :     SvxStringArray aMetricArr( SW_RES( STR_ARR_METRIC ) );
      84           0 :     for ( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
      85             :     {
      86           0 :         String sMetric = aMetricArr.GetStringByPos( i );
      87           0 :         FieldUnit eFUnit = (FieldUnit)aMetricArr.GetValue( i );
      88             : 
      89           0 :         switch ( eFUnit )
      90             :         {
      91             :             case FUNIT_MM:
      92             :             case FUNIT_CM:
      93             :             case FUNIT_POINT:
      94             :             case FUNIT_PICA:
      95             :             case FUNIT_INCH:
      96             :             {
      97             :                 // use only these metrics
      98           0 :                 sal_uInt16 nPos = m_pMetricLB->InsertEntry( sMetric );
      99           0 :                 m_pMetricLB->SetEntryData( nPos, (void*)(sal_IntPtr)eFUnit );
     100             :             }
     101             :             default:; //prevent warning
     102             :         }
     103           0 :     }
     104           0 :     m_pMetricLB->SetSelectHdl(LINK(this, SwLoadOptPage, MetricHdl));
     105             : 
     106             :     const SfxPoolItem* pItem;
     107           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem )
     108           0 :         && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)
     109             :     {
     110           0 :         m_pTabFT->Hide();
     111           0 :         m_pTabMF->Hide();
     112             :     }
     113             : 
     114           0 :     SvtCJKOptions aCJKOptions;
     115           0 :     if(!aCJKOptions.IsAsianTypographyEnabled())
     116             :     {
     117           0 :         m_pUseSquaredPageMode->Hide();
     118           0 :         m_pUseCharUnit->Hide();
     119           0 :     }
     120           0 : }
     121             : 
     122           0 : SfxTabPage* SwLoadOptPage::Create( Window* pParent,
     123             :                                 const SfxItemSet& rAttrSet )
     124             : {
     125           0 :     return new SwLoadOptPage(pParent, rAttrSet );
     126             : }
     127             : 
     128           0 : sal_Bool SwLoadOptPage::FillItemSet( SfxItemSet& rSet )
     129             : {
     130           0 :     sal_Bool bRet = sal_False;
     131           0 :     SwModule* pMod = SW_MOD();
     132             : 
     133           0 :     sal_uInt16 nNewLinkMode = AUTOMATIC;
     134           0 :     if (m_pNeverRB->IsChecked())
     135           0 :         nNewLinkMode = NEVER;
     136           0 :     else if (m_pRequestRB->IsChecked())
     137           0 :         nNewLinkMode = MANUAL;
     138             : 
     139           0 :     SwFldUpdateFlags eFldFlags = m_pAutoUpdateFields->IsChecked() ?
     140           0 :         m_pAutoUpdateCharts->IsChecked() ? AUTOUPD_FIELD_AND_CHARTS : AUTOUPD_FIELD_ONLY : AUTOUPD_OFF;
     141             : 
     142           0 :     if(m_pAutoUpdateFields->IsChecked() != m_pAutoUpdateFields->GetSavedValue() ||
     143           0 :             m_pAutoUpdateCharts->IsChecked() != m_pAutoUpdateCharts->GetSavedValue())
     144             :     {
     145           0 :         pMod->ApplyFldUpdateFlags(eFldFlags);
     146           0 :         if(m_pWrtShell)
     147             :         {
     148           0 :             m_pWrtShell->SetFldUpdateFlags(eFldFlags);
     149           0 :             m_pWrtShell->SetModified();
     150             :         }
     151             :     }
     152             : 
     153           0 :     if (nNewLinkMode != m_nOldLinkMode)
     154             :     {
     155           0 :         pMod->ApplyLinkMode(nNewLinkMode);
     156           0 :         if (m_pWrtShell)
     157             :         {
     158           0 :             m_pWrtShell->SetLinkUpdMode( nNewLinkMode );
     159           0 :             m_pWrtShell->SetModified();
     160             :         }
     161             : 
     162           0 :         bRet = sal_True;
     163             :     }
     164             : 
     165           0 :     const sal_uInt16 nMPos = m_pMetricLB->GetSelectEntryPos();
     166           0 :     if ( nMPos != m_pMetricLB->GetSavedValue() )
     167             :     {
     168             :         // Double-Cast for VA3.0
     169           0 :         sal_uInt16 nFieldUnit = (sal_uInt16)(sal_IntPtr)m_pMetricLB->GetEntryData( nMPos );
     170           0 :         rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nFieldUnit ) );
     171           0 :         bRet = sal_True;
     172             :     }
     173             : 
     174           0 :     if(m_pTabMF->IsVisible() && m_pTabMF->GetText() != m_pTabMF->GetSavedValue())
     175             :     {
     176             :         rSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
     177           0 :                     (sal_uInt16)m_pTabMF->Denormalize(m_pTabMF->GetValue(FUNIT_TWIP))));
     178           0 :         bRet = sal_True;
     179             :     }
     180             : 
     181           0 :     sal_Bool bIsUseCharUnitFlag = m_pUseCharUnit->IsChecked();
     182           0 :     SvtCJKOptions aCJKOptions;
     183           0 :         bIsUseCharUnitFlag = bIsUseCharUnitFlag && aCJKOptions.IsAsianTypographyEnabled();
     184           0 :     if( bIsUseCharUnitFlag != m_pUseCharUnit->GetSavedValue())
     185             :     {
     186           0 :         rSet.Put(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, bIsUseCharUnitFlag ));
     187           0 :         bRet = sal_True;
     188             :     }
     189             : 
     190           0 :     if (m_pWordCountED->GetText() != m_pWordCountED->GetSavedValue())
     191             :     {
     192             :         boost::shared_ptr< comphelper::ConfigurationChanges > batch(
     193           0 :             comphelper::ConfigurationChanges::create());
     194           0 :         officecfg::Office::Writer::WordCount::AdditionalSeparators::set(m_pWordCountED->GetText(), batch);
     195           0 :         batch->commit();
     196           0 :         bRet = sal_True;
     197             :     }
     198             : 
     199           0 :     sal_Bool bIsSquaredPageModeFlag = m_pUseSquaredPageMode->IsChecked();
     200           0 :     if ( bIsSquaredPageModeFlag != m_pUseSquaredPageMode->GetSavedValue() )
     201             :     {
     202           0 :         pMod->ApplyDefaultPageMode( bIsSquaredPageModeFlag );
     203           0 :         if ( m_pWrtShell )
     204             :         {
     205           0 :             SwDoc* pDoc = m_pWrtShell->GetDoc();
     206           0 :             pDoc->SetDefaultPageMode( bIsSquaredPageModeFlag );
     207           0 :             m_pWrtShell->SetModified();
     208             :         }
     209           0 :         bRet = sal_True;
     210             :     }
     211             : 
     212           0 :     return bRet;
     213             : }
     214             : 
     215           0 : void SwLoadOptPage::Reset( const SfxItemSet& rSet)
     216             : {
     217           0 :     const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref(sal_False);
     218             :     const SfxPoolItem* pItem;
     219             : 
     220           0 :     if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_WRTSHELL, sal_False, &pItem))
     221           0 :         m_pWrtShell = (SwWrtShell*)((const SwPtrItem*)pItem)->GetValue();
     222             : 
     223           0 :     SwFldUpdateFlags eFldFlags = AUTOUPD_GLOBALSETTING;
     224           0 :     m_nOldLinkMode = GLOBALSETTING;
     225           0 :     if (m_pWrtShell)
     226             :     {
     227           0 :         eFldFlags = m_pWrtShell->GetFldUpdateFlags(sal_True);
     228           0 :         m_nOldLinkMode = m_pWrtShell->GetLinkUpdMode(sal_True);
     229             :     }
     230           0 :     if(GLOBALSETTING == m_nOldLinkMode)
     231           0 :         m_nOldLinkMode = pUsrPref->GetUpdateLinkMode();
     232           0 :     if(AUTOUPD_GLOBALSETTING == eFldFlags)
     233           0 :         eFldFlags = pUsrPref->GetFldUpdateFlags();
     234             : 
     235           0 :     m_pAutoUpdateFields->Check(eFldFlags != AUTOUPD_OFF);
     236           0 :     m_pAutoUpdateCharts->Check(eFldFlags == AUTOUPD_FIELD_AND_CHARTS);
     237             : 
     238           0 :     switch (m_nOldLinkMode)
     239             :     {
     240           0 :         case NEVER:     m_pNeverRB->Check();   break;
     241           0 :         case MANUAL:    m_pRequestRB->Check(); break;
     242           0 :         case AUTOMATIC: m_pAlwaysRB->Check();  break;
     243             :     }
     244             : 
     245           0 :     m_pAutoUpdateFields->SaveValue();
     246           0 :     m_pAutoUpdateCharts->SaveValue();
     247           0 :     m_pMetricLB->SetNoSelection();
     248           0 :     if ( rSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
     249             :     {
     250           0 :         const SfxUInt16Item& rItem = (SfxUInt16Item&)rSet.Get( SID_ATTR_METRIC );
     251           0 :         FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
     252             : 
     253           0 :         for ( sal_uInt16 i = 0; i < m_pMetricLB->GetEntryCount(); ++i )
     254             :         {
     255           0 :             if ( (int)(sal_IntPtr)m_pMetricLB->GetEntryData( i ) == (int)eFieldUnit )
     256             :             {
     257           0 :                 m_pMetricLB->SelectEntryPos( i );
     258           0 :                 break;
     259             :             }
     260             :         }
     261           0 :         ::SetFieldUnit(*m_pTabMF, eFieldUnit);
     262             :     }
     263           0 :     m_pMetricLB->SaveValue();
     264           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem))
     265             :     {
     266           0 :         m_nLastTab = ((SfxUInt16Item*)pItem)->GetValue();
     267           0 :         m_pTabMF->SetValue(m_pTabMF->Normalize(m_nLastTab), FUNIT_TWIP);
     268             :     }
     269           0 :     m_pTabMF->SaveValue();
     270             : 
     271             :     //default page mode loading
     272           0 :     if(m_pWrtShell)
     273             :     {
     274           0 :         bool bSquaredPageMode = m_pWrtShell->GetDoc()->IsSquaredPageMode();
     275           0 :         m_pUseSquaredPageMode->Check( bSquaredPageMode );
     276           0 :         m_pUseSquaredPageMode->SaveValue();
     277             :     }
     278             : 
     279           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_APPLYCHARUNIT, sal_False, &pItem))
     280             :     {
     281           0 :         bool bUseCharUnit = ((const SfxBoolItem*)pItem)->GetValue();
     282           0 :         m_pUseCharUnit->Check(bUseCharUnit);
     283             :     }
     284             :     else
     285             :     {
     286           0 :         m_pUseCharUnit->Check(pUsrPref->IsApplyCharUnit());
     287             :     }
     288           0 :     m_pUseCharUnit->SaveValue();
     289             : 
     290           0 :     m_pWordCountED->SetText(officecfg::Office::Writer::WordCount::AdditionalSeparators::get());
     291           0 :     m_pWordCountED->SaveValue();
     292           0 : }
     293             : 
     294           0 : IMPL_LINK_NOARG(SwLoadOptPage, MetricHdl)
     295             : {
     296           0 :     const sal_uInt16 nMPos = m_pMetricLB->GetSelectEntryPos();
     297           0 :     if(nMPos != USHRT_MAX)
     298             :     {
     299             :         // Double-Cast for VA3.0
     300           0 :         FieldUnit eFieldUnit = (FieldUnit)(sal_IntPtr)m_pMetricLB->GetEntryData( nMPos );
     301           0 :         sal_Bool bModified = m_pTabMF->IsModified();
     302             :         long nVal = bModified ?
     303           0 :             sal::static_int_cast<sal_Int32, sal_Int64 >( m_pTabMF->Denormalize( m_pTabMF->GetValue( FUNIT_TWIP ) )) :
     304           0 :                 m_nLastTab;
     305           0 :         ::SetFieldUnit( *m_pTabMF, eFieldUnit );
     306           0 :         m_pTabMF->SetValue( m_pTabMF->Normalize( nVal ), FUNIT_TWIP );
     307           0 :         if(!bModified)
     308           0 :             m_pTabMF->ClearModifyFlag();
     309             :     }
     310             : 
     311           0 :     return 0;
     312             : }
     313             : 
     314           0 : SwCaptionOptDlg::SwCaptionOptDlg(Window* pParent, const SfxItemSet& rSet) :
     315           0 :     SfxNoLayoutSingleTabDialog(pParent, rSet, 0)
     316             : {
     317             :     // create TabPage
     318           0 :     SetTabPage((SwCaptionOptPage*) SwCaptionOptPage::Create(this, rSet));
     319           0 : }
     320             : 
     321           0 : SwCaptionOptDlg::~SwCaptionOptDlg()
     322             : {
     323           0 : }
     324             : 
     325           0 : SwCaptionPreview::SwCaptionPreview( Window* pParent )
     326           0 :     : Window( pParent )
     327             : {
     328           0 :     Init();
     329           0 : }
     330             : 
     331           0 : SwCaptionPreview::SwCaptionPreview( Window* pParent, const ResId& rResId )
     332           0 :     : Window( pParent, rResId )
     333             : {
     334           0 :     Init();
     335           0 : }
     336             : 
     337           0 : void SwCaptionPreview::Init()
     338             : {
     339           0 :     maDrawPos = Point( 4, 6 );
     340             : 
     341           0 :     Wallpaper   aBack( GetSettings().GetStyleSettings().GetWindowColor() );
     342           0 :     SetBackground( aBack );
     343           0 :     SetFillColor( aBack.GetColor() );
     344           0 :     SetLineColor( aBack.GetColor() );
     345           0 :     SetBorderStyle( WINDOW_BORDER_MONO );
     346           0 :     Font aFont(GetFont());
     347           0 :     aFont.SetHeight(aFont.GetHeight() * 120 / 100 );
     348           0 :     SetFont(aFont);
     349           0 : }
     350             : 
     351           0 : void SwCaptionPreview::SetPreviewText( const String& rText )
     352             : {
     353           0 :     if( rText != maText )
     354             :     {
     355           0 :         maText = rText;
     356           0 :         Invalidate();
     357             :     }
     358           0 : }
     359             : 
     360           0 : void SwCaptionPreview::Paint( const Rectangle& rRect )
     361             : {
     362           0 :     Window::Paint( rRect );
     363             : 
     364           0 :     DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
     365           0 :     DrawText( Point( 4, 6 ), maText );
     366           0 : }
     367             : 
     368           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSwCaptionPreview(Window* pParent, VclBuilder::stringmap &)
     369             : {
     370           0 :     return new SwCaptionPreview(pParent);
     371             : }
     372             : 
     373           0 : SwCaptionOptPage::SwCaptionOptPage( Window* pParent, const SfxItemSet& rSet )
     374             :     : SfxTabPage(pParent, SW_RES(TP_OPTCAPTION_PAGE), rSet),
     375             :     aCheckFT        (this, SW_RES(FT_OBJECTS    )),
     376             :     aCheckLB        (this, SW_RES(CLB_OBJECTS   )),
     377             :     aFtCaptionOrder(this, SW_RES( FT_ORDER )),
     378             :     aLbCaptionOrder(this, SW_RES( LB_ORDER )),
     379             :     aPreview        (this, SW_RES(WIN_PREVIEW   )),
     380             :     aSettingsGroupFL(this, SW_RES(FL_SETTINGS_2 )),
     381             :     aCategoryText   (this, SW_RES(TXT_CATEGORY  )),
     382             :     aCategoryBox    (this, SW_RES(BOX_CATEGORY  )),
     383             :     aFormatText     (this, SW_RES(TXT_FORMAT    )),
     384             :     aFormatBox      (this, SW_RES(BOX_FORMAT    )),
     385             :     aNumberingSeparatorFT(this, SW_RES(FT_NUM_SEP  )),
     386             :     aNumberingSeparatorED(this, SW_RES(ED_NUM_SEP  )),
     387             :     aTextText       (this, SW_RES(TXT_TEXT      )),
     388             :     aTextEdit       (this, SW_RES(EDT_TEXT      )),
     389             :     aPosText        (this, SW_RES(TXT_POS       )),
     390             :     aPosBox         (this, SW_RES(BOX_POS       )),
     391             :     aNumCaptFL      (this, SW_RES(FL_NUMCAPT    )),
     392             :     aFtLevel        (this, SW_RES(FT_LEVEL      )),
     393             :     aLbLevel        (this, SW_RES(LB_LEVEL      )),
     394             :     aFtDelim        (this, SW_RES(FT_SEPARATOR  )),
     395             :     aEdDelim        (this, SW_RES(ED_SEPARATOR  )),
     396             :     aCategoryFL     (this, SW_RES(FL_CATEGORY   )),
     397             :     aCharStyleFT    (this, SW_RES(FT_CHARSTYLE  )),
     398             :     aCharStyleLB    (this, SW_RES(LB_CHARSTYLE  )),
     399             :     aApplyBorderCB  (this, SW_RES(CB_APPLYBORDER)),
     400             : 
     401             :     sSWTable        (SW_RES(STR_TABLE           )),
     402             :     sSWFrame        (SW_RES(STR_FRAME           )),
     403             :     sSWGraphic      (SW_RES(STR_GRAPHIC         )),
     404             :     sOLE            (SW_RES(STR_OLE             )),
     405             : 
     406             :     sBegin          (SW_RESSTR(STR_BEGINNING            )),
     407             :     sEnd            (SW_RESSTR(STR_END                  )),
     408             :     sAbove          (SW_RESSTR(STR_ABOVE                )),
     409             :     sBelow          (SW_RESSTR(STR_CP_BELOW             )),
     410             :     sNone           (SW_RESSTR( STR_CATEGORY_NONE )),
     411             : 
     412           0 :     pMgr            (new SwFldMgr()),
     413           0 :     bHTMLMode(sal_False)
     414             : {
     415           0 :     Wallpaper   aBack( GetSettings().GetStyleSettings().GetWindowColor() );
     416           0 :     aPreview.SetBackground( aBack );
     417             : 
     418           0 :     SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_ABB, sIllustration );
     419           0 :     SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_TABLE, sTable );
     420           0 :     SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_FRAME, sText );
     421           0 :     SwStyleNameMapper::FillUIName( RES_POOLCOLL_LABEL_DRAWING, sDrawing );
     422             : 
     423             :     sal_uInt16 i, nCount;
     424           0 :     SwWrtShell *pSh = ::GetActiveWrtShell();
     425             : 
     426             :     // aFormatBox
     427           0 :     sal_uInt16 nSelFmt = SVX_NUM_ARABIC;
     428           0 :     if (pSh)
     429             :     {
     430           0 :         nCount = pMgr->GetFldTypeCount();
     431             :         SwFieldType* pFldType;
     432           0 :         for ( i = nCount; i; )
     433             :         {
     434           0 :             pFldType = pMgr->GetFldType(USHRT_MAX, --i);
     435           0 :             if (pFldType->GetName().equals(aCategoryBox.GetText()))
     436             :             {
     437           0 :                 nSelFmt = (sal_uInt16)((SwSetExpFieldType*)pFldType)->GetSeqFormat();
     438           0 :                 break;
     439             :             }
     440             :         }
     441             : 
     442           0 :         ::FillCharStyleListBox( aCharStyleLB, pSh->GetView().GetDocShell(), true, true );
     443             :     }
     444             : 
     445             : 
     446           0 :     nCount = pMgr->GetFormatCount(TYP_SEQFLD, false);
     447           0 :     for ( i = 0; i < nCount; ++i )
     448             :     {
     449           0 :         aFormatBox.InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
     450           0 :         sal_uInt16 nFmtId = pMgr->GetFormatId(TYP_SEQFLD, i);
     451           0 :         aFormatBox.SetEntryData( i, reinterpret_cast<void*>(nFmtId) );
     452           0 :         if( nFmtId == nSelFmt )
     453           0 :             aFormatBox.SelectEntryPos( i );
     454             :     }
     455             : 
     456           0 :     for (i = 0; i < MAXLEVEL; i++)
     457           0 :         aLbLevel.InsertEntry(OUString::number(i + 1));
     458             : 
     459           0 :     sal_Unicode nLvl = MAXLEVEL;
     460           0 :     OUString sDelim(": ");
     461             : 
     462           0 :     if (pSh)
     463             :     {
     464             :         SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
     465           0 :                                             RES_SETEXPFLD, aCategoryBox.GetText() );
     466           0 :         if( pFldType )
     467             :         {
     468           0 :             sDelim = pFldType->GetDelimiter();
     469           0 :             nLvl = pFldType->GetOutlineLvl();
     470             :         }
     471             :     }
     472             : 
     473           0 :     aLbLevel.SelectEntryPos( nLvl < MAXLEVEL ? nLvl + 1 : 0 );
     474           0 :     aEdDelim.SetText( sDelim );
     475             : 
     476           0 :     aCheckLB.SetHelpId(HID_OPTCAPTION_CLB);
     477             : 
     478           0 :     FreeResource();
     479             : 
     480           0 :     Link aLk = LINK( this, SwCaptionOptPage, ModifyHdl );
     481           0 :     aCategoryBox.SetModifyHdl( aLk );
     482           0 :     aNumberingSeparatorED.SetModifyHdl( aLk );
     483           0 :     aTextEdit   .SetModifyHdl( aLk );
     484             : 
     485           0 :     aLk = LINK(this, SwCaptionOptPage, SelectHdl);
     486           0 :     aCategoryBox.SetSelectHdl( aLk );
     487           0 :     aFormatBox  .SetSelectHdl( aLk );
     488             : 
     489           0 :     aLbCaptionOrder.SetSelectHdl( LINK(this, SwCaptionOptPage, OrderHdl));
     490             : 
     491           0 :     aCheckLB.SetSelectHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
     492           0 :     aCheckLB.SetCheckButtonHdl( LINK(this, SwCaptionOptPage, ShowEntryHdl) );
     493           0 :     aCheckLB.SetDeselectHdl( LINK(this, SwCaptionOptPage, SaveEntryHdl) );
     494           0 : }
     495             : 
     496           0 : SwCaptionOptPage::~SwCaptionOptPage()
     497             : {
     498           0 :     DelUserData();
     499           0 :     delete pMgr;
     500           0 : }
     501             : 
     502           0 : SfxTabPage* SwCaptionOptPage::Create( Window* pParent,
     503             :                                 const SfxItemSet& rAttrSet )
     504             : {
     505           0 :     return new SwCaptionOptPage(pParent, rAttrSet );
     506             : }
     507             : 
     508           0 : sal_Bool SwCaptionOptPage::FillItemSet( SfxItemSet&  )
     509             : {
     510           0 :     sal_Bool bRet = sal_False;
     511           0 :     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     512             : 
     513           0 :     SaveEntry(aCheckLB.FirstSelected());    // apply current entry
     514             : 
     515           0 :     SvTreeListEntry* pEntry = aCheckLB.First();
     516             : 
     517           0 :     while (pEntry)
     518             :     {
     519           0 :         InsCaptionOpt* pData = (InsCaptionOpt*)pEntry->GetUserData();
     520           0 :         bRet |= pModOpt->SetCapOption(bHTMLMode, pData);
     521           0 :         pEntry = aCheckLB.Next(pEntry);
     522             :     }
     523             : 
     524           0 :     sal_uInt16 nCheckCount = aCheckLB.GetCheckedEntryCount();
     525           0 :     pModOpt->SetInsWithCaption( bHTMLMode, nCheckCount > 0 );
     526             : 
     527           0 :     sal_Int32 nPos = aLbCaptionOrder.GetSelectEntryPos();
     528           0 :     pModOpt->SetCaptionOrderNumberingFirst(nPos == 1 ? sal_True : sal_False );
     529             : 
     530           0 :     return bRet;
     531             : }
     532             : 
     533           0 : void SwCaptionOptPage::Reset( const SfxItemSet& rSet)
     534             : {
     535             :     const SfxPoolItem* pItem;
     536           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem))
     537             :     {
     538           0 :         bHTMLMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
     539             :     }
     540             : 
     541           0 :     DelUserData();
     542           0 :     aCheckLB.GetModel()->Clear();   // remove all entries
     543             : 
     544             :     // Writer objects
     545           0 :     sal_uInt16 nPos = 0;
     546           0 :     aCheckLB.InsertEntry(sSWTable);
     547           0 :     SetOptions(nPos++, TABLE_CAP);
     548           0 :     aCheckLB.InsertEntry(sSWFrame);
     549           0 :     SetOptions(nPos++, FRAME_CAP);
     550           0 :     aCheckLB.InsertEntry(sSWGraphic);
     551           0 :     SetOptions(nPos++, GRAPHIC_CAP);
     552             : 
     553             :     // get Productname and -version
     554           0 :     OUString sWithoutVersion( utl::ConfigManager::getProductName() );
     555             :     OUString sComplete(
     556           0 :         sWithoutVersion + OUString(" ") +
     557           0 :         utl::ConfigManager::getProductVersion() );
     558             : 
     559           0 :     SvObjectServerList aObjS;
     560           0 :     aObjS.FillInsertObjects();
     561           0 :     aObjS.Remove( SvGlobalName( SO3_SW_CLASSID ) ); // remove Writer-ID
     562             : 
     563           0 :     for ( sal_uLong i = 0; i < aObjS.Count(); ++i )
     564             :     {
     565           0 :         const SvGlobalName &rOleId = aObjS[i].GetClassName();
     566           0 :         const String* pClassName = &aObjS[i].GetHumanName();
     567           0 :         if ( rOleId == SvGlobalName( SO3_OUT_CLASSID ) )
     568           0 :             pClassName = &sOLE;
     569           0 :         String sClass( *pClassName );
     570             :         // don't show product version
     571           0 :         sClass.SearchAndReplace( sComplete, sWithoutVersion );
     572           0 :         aCheckLB.InsertEntry( sClass );
     573           0 :         SetOptions( nPos++, OLE_CAP, &rOleId );
     574           0 :     }
     575             :     aLbCaptionOrder.SelectEntryPos(
     576           0 :         SW_MOD()->GetModuleConfig()->IsCaptionOrderNumberingFirst() ? 1 : 0);
     577           0 :     ModifyHdl();
     578           0 : }
     579             : 
     580           0 : void SwCaptionOptPage::SetOptions(const sal_uInt16 nPos,
     581             :         const SwCapObjType eObjType, const SvGlobalName *pOleId)
     582             : {
     583           0 :     SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
     584           0 :     const InsCaptionOpt* pOpt = pModOpt->GetCapOption(bHTMLMode, eObjType, pOleId);
     585             : 
     586           0 :     if (pOpt)
     587             :     {
     588           0 :         aCheckLB.SetEntryData(nPos, new InsCaptionOpt(*pOpt));
     589           0 :         aCheckLB.CheckEntryPos(nPos, pOpt->UseCaption());
     590             :     }
     591             :     else
     592           0 :         aCheckLB.SetEntryData(nPos, new InsCaptionOpt(eObjType, pOleId));
     593           0 : }
     594             : 
     595           0 : void SwCaptionOptPage::DelUserData()
     596             : {
     597           0 :     SvTreeListEntry* pEntry = aCheckLB.First();
     598             : 
     599           0 :     while (pEntry)
     600             :     {
     601           0 :         delete (InsCaptionOpt*)pEntry->GetUserData();
     602           0 :         pEntry->SetUserData(0);
     603           0 :         pEntry = aCheckLB.Next(pEntry);
     604             :     }
     605           0 : }
     606             : 
     607           0 : IMPL_LINK_NOARG(SwCaptionOptPage, ShowEntryHdl)
     608             : {
     609           0 :     SvTreeListEntry* pSelEntry = aCheckLB.FirstSelected();
     610             : 
     611           0 :     if (pSelEntry)
     612             :     {
     613           0 :         sal_Bool bChecked = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pSelEntry));
     614             : 
     615           0 :         aSettingsGroupFL.Enable( bChecked );
     616           0 :         aCategoryText.Enable( bChecked );
     617           0 :         aCategoryBox.Enable( bChecked );
     618           0 :         aFormatText.Enable( bChecked );
     619           0 :         aFormatBox.Enable( bChecked );
     620           0 :         sal_Bool bNumSep = bChecked && aLbCaptionOrder.GetSelectEntryPos() == 1;
     621           0 :         aNumberingSeparatorED.Enable( bNumSep );
     622           0 :         aNumberingSeparatorFT.Enable( bNumSep );
     623           0 :         aTextText.Enable( bChecked );
     624           0 :         aTextEdit.Enable( bChecked );
     625           0 :         aPosText.Enable( bChecked );
     626           0 :         aPosBox.Enable( bChecked );
     627           0 :         aNumCaptFL.Enable( bChecked );
     628           0 :         aFtLevel.Enable( bChecked );
     629           0 :         aLbLevel.Enable( bChecked );
     630           0 :         aFtDelim.Enable( bChecked );
     631           0 :         aEdDelim.Enable( bChecked );
     632           0 :         aCategoryFL.Enable( bChecked );
     633           0 :         aCharStyleFT.Enable( bChecked );
     634           0 :         aCharStyleLB.Enable( bChecked );
     635           0 :         aApplyBorderCB.Enable( bChecked );
     636           0 :         aPreview.Enable( bChecked );
     637             : 
     638           0 :         SwWrtShell *pSh = ::GetActiveWrtShell();
     639             : 
     640           0 :         InsCaptionOpt* pOpt = (InsCaptionOpt*)pSelEntry->GetUserData();
     641             : 
     642           0 :         aCategoryBox.Clear();
     643           0 :         aCategoryBox.InsertEntry( sNone );
     644           0 :         if (pSh)
     645             :         {
     646           0 :             sal_uInt16 nCount = pMgr->GetFldTypeCount();
     647             : 
     648           0 :             for (sal_uInt16 i = 0; i < nCount; i++)
     649             :             {
     650           0 :                 SwFieldType *pType = pMgr->GetFldType( USHRT_MAX, i );
     651           0 :                 if( pType->Which() == RES_SETEXPFLD &&
     652           0 :                     ((SwSetExpFieldType *) pType)->GetType() & nsSwGetSetExpType::GSE_SEQ )
     653           0 :                     aCategoryBox.InsertEntry(SwBoxEntry(pType->GetName()));
     654             :             }
     655             :         }
     656             :         else
     657             :         {
     658           0 :             aCategoryBox.InsertEntry(SwBoxEntry(sIllustration));
     659           0 :             aCategoryBox.InsertEntry(SwBoxEntry(sTable));
     660           0 :             aCategoryBox.InsertEntry(SwBoxEntry(sText));
     661           0 :             aCategoryBox.InsertEntry(SwBoxEntry(sDrawing));
     662             :         }
     663             : 
     664           0 :         if(pOpt->GetCategory().Len())
     665           0 :             aCategoryBox.SetText(pOpt->GetCategory());
     666             :         else
     667           0 :             aCategoryBox.SetText( sNone );
     668           0 :         if (pOpt->GetCategory().Len() &&
     669           0 :             aCategoryBox.GetEntryPos(OUString(pOpt->GetCategory())) == COMBOBOX_ENTRY_NOTFOUND)
     670           0 :             aCategoryBox.InsertEntry(pOpt->GetCategory());
     671           0 :         if (aCategoryBox.GetText().isEmpty())
     672             :         {
     673           0 :             sal_uInt16 nPos = 0;
     674           0 :             switch(pOpt->GetObjType())
     675             :             {
     676             :                 case OLE_CAP:
     677           0 :                 case GRAPHIC_CAP:       nPos = 1;   break;
     678           0 :                 case TABLE_CAP:         nPos = 2;   break;
     679           0 :                 case FRAME_CAP:         nPos = 3;   break;
     680             :             }
     681           0 :             aCategoryBox.SetText(aCategoryBox.GetEntry(nPos).GetName());
     682             :         }
     683             : 
     684           0 :         for (sal_uInt16 i = 0; i < aFormatBox.GetEntryCount(); i++)
     685             :         {
     686           0 :             if (pOpt->GetNumType() == (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(i))
     687             :             {
     688           0 :                 aFormatBox.SelectEntryPos(i);
     689           0 :                 break;
     690             :             }
     691             :         }
     692           0 :         aTextEdit.SetText(pOpt->GetCaption());
     693             : 
     694           0 :         aPosBox.Clear();
     695           0 :         switch (pOpt->GetObjType())
     696             :         {
     697             :             case GRAPHIC_CAP:
     698             :             case TABLE_CAP:
     699             :             case OLE_CAP:
     700           0 :                 aPosBox.InsertEntry(sAbove);
     701           0 :                 aPosBox.InsertEntry(sBelow);
     702           0 :                 break;
     703             :             case FRAME_CAP:
     704           0 :                 aPosBox.InsertEntry(sBegin);
     705           0 :                 aPosBox.InsertEntry(sEnd);
     706           0 :                 break;
     707             :         }
     708           0 :         aPosBox.SelectEntryPos(pOpt->GetPos());
     709           0 :         aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP &&
     710           0 :                 pOpt->GetObjType() != OLE_CAP &&
     711           0 :                 aPosText.IsEnabled() );
     712           0 :         aPosBox.SelectEntryPos(pOpt->GetPos());
     713             : 
     714           0 :         sal_uInt16 nLevelPos = ( pOpt->GetLevel() < MAXLEVEL ) ? pOpt->GetLevel() + 1 : 0;
     715           0 :         aLbLevel.SelectEntryPos( nLevelPos );
     716           0 :         aEdDelim.SetText(pOpt->GetSeparator());
     717           0 :         aNumberingSeparatorED.SetText( pOpt->GetNumSeparator() );
     718           0 :         if(pOpt->GetCharacterStyle().Len())
     719           0 :             aCharStyleLB.SelectEntry( pOpt->GetCharacterStyle() );
     720             :         else
     721           0 :             aCharStyleLB.SelectEntryPos( 0 );
     722           0 :         aApplyBorderCB.Enable( aCategoryBox.IsEnabled() &&
     723           0 :                 pOpt->GetObjType() != TABLE_CAP && pOpt->GetObjType() != FRAME_CAP );
     724           0 :         aApplyBorderCB.Check( pOpt->CopyAttributes() );
     725             :     }
     726             : 
     727           0 :     ModifyHdl();
     728             : 
     729           0 :     return 0;
     730             : }
     731             : 
     732           0 : IMPL_LINK_NOARG(SwCaptionOptPage, SaveEntryHdl)
     733             : {
     734           0 :     SvTreeListEntry* pEntry = aCheckLB.GetHdlEntry();
     735             : 
     736           0 :     if (pEntry) // save all
     737           0 :         SaveEntry(pEntry);
     738             : 
     739           0 :     return 0;
     740             : }
     741             : 
     742           0 : void SwCaptionOptPage::SaveEntry(SvTreeListEntry* pEntry)
     743             : {
     744           0 :     if (pEntry)
     745             :     {
     746           0 :         InsCaptionOpt* pOpt = (InsCaptionOpt*)pEntry->GetUserData();
     747             : 
     748           0 :         pOpt->UseCaption() = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pEntry));
     749           0 :         String aName( aCategoryBox.GetText() );
     750           0 :         if(aName == sNone)
     751           0 :             pOpt->SetCategory(aEmptyStr);
     752             :         else
     753           0 :             pOpt->SetCategory(comphelper::string::strip(aName, ' '));
     754           0 :         pOpt->SetNumType((sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(aFormatBox.GetSelectEntryPos()));
     755           0 :         pOpt->SetCaption(aTextEdit.IsEnabled() ? aTextEdit.GetText() : OUString(aEmptyStr) );
     756           0 :         pOpt->SetPos(aPosBox.GetSelectEntryPos());
     757           0 :         sal_uInt16 nPos = aLbLevel.GetSelectEntryPos();
     758           0 :         sal_uInt16 nLevel = ( nPos > 0 && nPos != LISTBOX_ENTRY_NOTFOUND ) ? nPos - 1 : MAXLEVEL;
     759           0 :         pOpt->SetLevel(nLevel);
     760           0 :         pOpt->SetSeparator(aEdDelim.GetText());
     761           0 :         pOpt->SetNumSeparator( aNumberingSeparatorED.GetText());
     762           0 :         if(!aCharStyleLB.GetSelectEntryPos())
     763           0 :             pOpt->SetCharacterStyle(aEmptyStr);
     764             :         else
     765           0 :             pOpt->SetCharacterStyle(aCharStyleLB.GetSelectEntry());
     766           0 :         pOpt->CopyAttributes() = aApplyBorderCB.IsChecked();
     767             :     }
     768           0 : }
     769             : 
     770           0 : IMPL_LINK_NOARG(SwCaptionOptPage, ModifyHdl)
     771             : {
     772           0 :     String sFldTypeName = aCategoryBox.GetText();
     773             : 
     774           0 :     SfxNoLayoutSingleTabDialog *pDlg = dynamic_cast<SfxNoLayoutSingleTabDialog*>(GetParentDialog());
     775           0 :     PushButton *pBtn = pDlg ? pDlg->GetOKButton() : NULL;
     776           0 :     if (pBtn)
     777           0 :         pBtn->Enable(sFldTypeName.Len() != 0);
     778           0 :     sal_Bool bEnable = aCategoryBox.IsEnabled() && sFldTypeName != sNone;
     779             : 
     780           0 :     aFormatText.Enable(bEnable);
     781           0 :     aFormatBox.Enable(bEnable);
     782           0 :     aTextText.Enable(bEnable);
     783           0 :     aTextEdit.Enable(bEnable);
     784             : 
     785           0 :     DrawSample();
     786           0 :     return 0;
     787             : }
     788             : 
     789           0 : IMPL_LINK_NOARG_INLINE_START(SwCaptionOptPage, SelectHdl)
     790             : {
     791           0 :     DrawSample();
     792           0 :     return 0;
     793             : }
     794           0 : IMPL_LINK_NOARG_INLINE_END(SwCaptionOptPage, SelectHdl)
     795             : 
     796           0 : IMPL_LINK( SwCaptionOptPage, OrderHdl, ListBox*, pBox )
     797             : {
     798           0 :     DrawSample();
     799             : 
     800           0 :     SvTreeListEntry* pSelEntry = aCheckLB.FirstSelected();
     801           0 :     sal_Bool bChecked = sal_False;
     802           0 :     if (pSelEntry)
     803             :     {
     804           0 :         bChecked = aCheckLB.IsChecked((sal_uInt16)aCheckLB.GetModel()->GetAbsPos(pSelEntry));
     805             :     }
     806             : 
     807           0 :     sal_Int32 nPos = pBox->GetSelectEntryPos();
     808           0 :     aNumberingSeparatorFT.Enable( bChecked && nPos == 1 );
     809           0 :     aNumberingSeparatorED.Enable( bChecked && nPos == 1 );
     810           0 :     return 0;
     811             : }
     812             : 
     813           0 : void SwCaptionOptPage::DrawSample()
     814             : {
     815           0 :     String aStr;
     816             : 
     817           0 :     if( aCategoryBox.GetText() != OUString(sNone))
     818             :     {
     819             :         //#i61007# order of captions
     820           0 :         bool bOrderNumberingFirst = aLbCaptionOrder.GetSelectEntryPos() == 1;
     821             :         // number
     822             :         sal_uInt16 nNumFmt = (sal_uInt16)(sal_uLong)aFormatBox.GetEntryData(
     823           0 :                                         aFormatBox.GetSelectEntryPos() );
     824           0 :         if( SVX_NUM_NUMBER_NONE != nNumFmt )
     825             :         {
     826             :             //#i61007# order of captions
     827           0 :             if( !bOrderNumberingFirst )
     828             :             {
     829             :                 // category
     830           0 :                 aStr += aCategoryBox.GetText();
     831           0 :                 aStr += ' ';
     832             :             }
     833             : 
     834           0 :             SwWrtShell *pSh = ::GetActiveWrtShell();
     835           0 :             String sFldTypeName( aCategoryBox.GetText() );
     836           0 :             if (pSh)
     837             :             {
     838             :                 SwSetExpFieldType* pFldType = (SwSetExpFieldType*)pMgr->GetFldType(
     839           0 :                                                 RES_SETEXPFLD, sFldTypeName );
     840           0 :                 if( pFldType && pFldType->GetOutlineLvl() < MAXLEVEL )
     841             :                 {
     842           0 :                     sal_uInt8 nLvl = pFldType->GetOutlineLvl();
     843           0 :                     SwNumberTree::tNumberVector aNumVector;
     844           0 :                     for( sal_uInt8 i = 0; i <= nLvl; ++i )
     845           0 :                         aNumVector.push_back(1);
     846             : 
     847             :                     String sNumber( pSh->GetOutlineNumRule()->MakeNumString(
     848           0 :                                                             aNumVector, sal_False ));
     849           0 :                     if( sNumber.Len() )
     850           0 :                         (aStr += sNumber) += pFldType->GetDelimiter();
     851             :                 }
     852             :             }
     853             : 
     854           0 :             switch( nNumFmt )
     855             :             {
     856           0 :                 case SVX_NUM_CHARS_UPPER_LETTER:    aStr += 'A'; break;
     857           0 :                 case SVX_NUM_CHARS_UPPER_LETTER_N:  aStr += 'A'; break;
     858           0 :                 case SVX_NUM_CHARS_LOWER_LETTER:    aStr += 'a'; break;
     859           0 :                 case SVX_NUM_CHARS_LOWER_LETTER_N:  aStr += 'a'; break;
     860           0 :                 case SVX_NUM_ROMAN_UPPER:           aStr += 'I'; break;
     861           0 :                 case SVX_NUM_ROMAN_LOWER:           aStr += 'i'; break;
     862             :                 //case ARABIC:
     863           0 :                 default:                    aStr += '1'; break;
     864           0 :             }
     865             :         }
     866             :         //#i61007# order of captions
     867           0 :         if( bOrderNumberingFirst )
     868             :         {
     869           0 :             aStr += aNumberingSeparatorED.GetText();
     870           0 :             aStr += aCategoryBox.GetText();
     871             :         }
     872           0 :         aStr += aTextEdit.GetText();
     873             :     }
     874           0 :     aPreview.SetPreviewText( aStr );
     875           0 : }
     876             : 
     877             : // Description: ComboBox without Spaces
     878           0 : void CaptionComboBox::KeyInput(const KeyEvent& rEvt)
     879             : {
     880           0 :     if( rEvt.GetKeyCode().GetCode() != KEY_SPACE )
     881           0 :         SwComboBox::KeyInput(rEvt);
     882           0 : }
     883             : 
     884             : 
     885             : 
     886             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10