LCOV - code coverage report
Current view: top level - libreoffice/cui/source/options - opthtml.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 135 0.7 %
Date: 2012-12-27 Functions: 2 12 16.7 %
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 <svtools/langtab.hxx>
      21             : #include <svtools/htmlcfg.hxx>
      22             : #include "opthtml.hxx"
      23             : #include "opthtml.hrc"
      24             : #include <cuires.hrc>
      25             : #include "helpid.hrc"
      26             : #include <dialmgr.hxx>
      27             : #include <sal/macros.h>
      28             : 
      29             : // modus convertion to the positions in the listbox
      30             : const sal_uInt16 aPosToExportArr[] =
      31             : {
      32             :     HTML_CFG_MSIE,
      33             :     HTML_CFG_NS40,
      34             :     HTML_CFG_WRITER
      35             : };
      36             : 
      37             : const sal_uInt16 aExportToPosArr[] =
      38             : {
      39             :     1,  //HTML 3.2 (removed, map to Netscape Navigator 4.0)
      40             :     0,  //MS Internet Explorer 4.0
      41             :     2,  //StarWriter
      42             :     1   //Netscape Navigator 4.0
      43             : };
      44             : // -----------------------------------------------------------------------
      45             : 
      46           0 : OfaHtmlTabPage::OfaHtmlTabPage(Window* pParent, const SfxItemSet& rSet) :
      47           0 :         SfxTabPage( pParent, CUI_RES( RID_OFAPAGE_HTMLOPT ), rSet ),
      48           0 :     aFontSizeGB     ( this, CUI_RES( GB_FONTSIZE       ) ),
      49           0 :     aSize1FT        ( this, CUI_RES( FT_SIZE1          ) ),
      50           0 :     aSize1NF        ( this, CUI_RES( NF_SIZE1          ) ),
      51           0 :     aSize2FT        ( this, CUI_RES( FT_SIZE2          ) ),
      52           0 :     aSize2NF        ( this, CUI_RES( NF_SIZE2          ) ),
      53           0 :     aSize3FT        ( this, CUI_RES( FT_SIZE3          ) ),
      54           0 :     aSize3NF        ( this, CUI_RES( NF_SIZE3          ) ),
      55           0 :     aSize4FT        ( this, CUI_RES( FT_SIZE4          ) ),
      56           0 :     aSize4NF        ( this, CUI_RES( NF_SIZE4          ) ),
      57           0 :     aSize5FT        ( this, CUI_RES( FT_SIZE5          ) ),
      58           0 :     aSize5NF        ( this, CUI_RES( NF_SIZE5          ) ),
      59           0 :     aSize6FT        ( this, CUI_RES( FT_SIZE6          ) ),
      60           0 :     aSize6NF        ( this, CUI_RES( NF_SIZE6          ) ),
      61           0 :     aSize7FT        ( this, CUI_RES( FT_SIZE7          ) ),
      62           0 :     aSize7NF        ( this, CUI_RES( NF_SIZE7          ) ),
      63           0 :     aImportGB       ( this, CUI_RES( GB_IMPORT     ) ),
      64           0 :     aNumbersEnglishUSCB ( this, CUI_RES( CB_NUMBERS_ENGLISH_US ) ),
      65           0 :     aUnknownTagCB   ( this, CUI_RES( CB_UNKNOWN_TAGS ) ),
      66           0 :     aIgnoreFontNamesCB( this, CUI_RES( CB_IGNORE_FONTNAMES ) ),
      67           0 :     aExportGB       ( this, CUI_RES( GB_EXPORT       ) ),
      68           0 :     aExportLB       ( this, CUI_RES( LB_EXPORT       ) ),
      69           0 :     aStarBasicCB    ( this, CUI_RES( CB_STARBASIC    ) ),
      70           0 :     aStarBasicWarningCB(this, CUI_RES( CB_STARBASIC_WARNING    ) ),
      71           0 :     aPrintExtensionCB( this,CUI_RES(CB_PRINT_EXTENSION )),
      72           0 :     aSaveGrfLocalCB ( this, CUI_RES( CB_LOCAL_GRF    ) ),
      73           0 :     aCharSetFT      ( this, CUI_RES( FT_CHARSET      ) ),
      74           0 :     aCharSetLB      ( this, CUI_RES( LB_CHARSET      ) )
      75             : 
      76             : {
      77           0 :     FreeResource();
      78             : 
      79             :     // replace placeholder with UI string from language list
      80           0 :     String aText( aNumbersEnglishUSCB.GetText());
      81           0 :     String aPlaceholder( RTL_CONSTASCII_USTRINGPARAM( "%ENGLISHUSLOCALE"));
      82             :     xub_StrLen nPos;
      83           0 :     if ((nPos = aText.Search( aPlaceholder)) != STRING_NOTFOUND)
      84             :     {
      85           0 :         SvtLanguageTable aLangTab;
      86           0 :         const String& rStr = aLangTab.GetString( LANGUAGE_ENGLISH_US);
      87           0 :         if (rStr.Len())
      88             :         {
      89           0 :             aText.Replace( nPos, aPlaceholder.Len(), rStr);
      90           0 :             aNumbersEnglishUSCB.SetText( aText);
      91           0 :         }
      92             :     }
      93             : 
      94           0 :     aExportLB.SetSelectHdl(LINK(this, OfaHtmlTabPage, ExportHdl_Impl));
      95           0 :     aStarBasicCB.SetClickHdl(LINK(this, OfaHtmlTabPage, CheckBoxHdl_Impl));
      96             : 
      97             :     // initialize the characterset listbox
      98           0 :     aCharSetLB.FillWithMimeAndSelectBest();
      99           0 : }
     100             : 
     101           0 : OfaHtmlTabPage::~OfaHtmlTabPage()
     102             : {
     103           0 : }
     104             : 
     105           0 : SfxTabPage* OfaHtmlTabPage::Create( Window* pParent,
     106             :                                 const SfxItemSet& rAttrSet )
     107             : {
     108           0 :     return new OfaHtmlTabPage(pParent, rAttrSet);
     109             : }
     110             : 
     111           0 : sal_Bool OfaHtmlTabPage::FillItemSet( SfxItemSet& )
     112             : {
     113           0 :     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
     114           0 :     if(aSize1NF.GetSavedValue() != aSize1NF.GetText())
     115           0 :         rHtmlOpt.SetFontSize(0, (sal_uInt16)aSize1NF.GetValue());
     116           0 :     if(aSize2NF.GetSavedValue() != aSize2NF.GetText())
     117           0 :         rHtmlOpt.SetFontSize(1, (sal_uInt16)aSize2NF.GetValue());
     118           0 :     if(aSize3NF.GetSavedValue() != aSize3NF.GetText())
     119           0 :         rHtmlOpt.SetFontSize(2, (sal_uInt16)aSize3NF.GetValue());
     120           0 :     if(aSize4NF.GetSavedValue() != aSize4NF.GetText())
     121           0 :         rHtmlOpt.SetFontSize(3, (sal_uInt16)aSize4NF.GetValue());
     122           0 :     if(aSize5NF.GetSavedValue() != aSize5NF.GetText())
     123           0 :         rHtmlOpt.SetFontSize(4, (sal_uInt16)aSize5NF.GetValue());
     124           0 :     if(aSize6NF.GetSavedValue() != aSize6NF.GetText())
     125           0 :         rHtmlOpt.SetFontSize(5, (sal_uInt16)aSize6NF.GetValue());
     126           0 :     if(aSize7NF.GetSavedValue() != aSize7NF.GetText())
     127           0 :         rHtmlOpt.SetFontSize(6, (sal_uInt16)aSize7NF.GetValue());
     128             : 
     129           0 :     if(aNumbersEnglishUSCB.IsChecked() != aNumbersEnglishUSCB.GetSavedValue())
     130           0 :         rHtmlOpt.SetNumbersEnglishUS(aNumbersEnglishUSCB.IsChecked());
     131             : 
     132           0 :     if(aUnknownTagCB.IsChecked() != aUnknownTagCB.GetSavedValue())
     133           0 :         rHtmlOpt.SetImportUnknown(aUnknownTagCB.IsChecked());
     134             : 
     135           0 :     if(aIgnoreFontNamesCB.IsChecked() != aIgnoreFontNamesCB.GetSavedValue())
     136           0 :         rHtmlOpt.SetIgnoreFontFamily(aIgnoreFontNamesCB.IsChecked());
     137             : 
     138           0 :     if(aExportLB.GetSelectEntryPos() != aExportLB.GetSavedValue())
     139           0 :         rHtmlOpt.SetExportMode(aPosToExportArr[aExportLB.GetSelectEntryPos()]);
     140             : 
     141           0 :     if(aStarBasicCB.IsChecked() != aStarBasicCB.GetSavedValue())
     142           0 :         rHtmlOpt.SetStarBasic(aStarBasicCB.IsChecked());
     143             : 
     144           0 :     if(aStarBasicWarningCB.IsChecked() != aStarBasicWarningCB.GetSavedValue())
     145           0 :         rHtmlOpt.SetStarBasicWarning(aStarBasicWarningCB.IsChecked());
     146             : 
     147           0 :     if(aSaveGrfLocalCB.IsChecked() != aSaveGrfLocalCB.GetSavedValue())
     148           0 :         rHtmlOpt.SetSaveGraphicsLocal(aSaveGrfLocalCB.IsChecked());
     149             : 
     150           0 :     if(aPrintExtensionCB.IsChecked() != aPrintExtensionCB.GetSavedValue())
     151           0 :         rHtmlOpt.SetPrintLayoutExtension(aPrintExtensionCB.IsChecked());
     152             : 
     153           0 :     if( aCharSetLB.GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
     154           0 :         rHtmlOpt.SetTextEncoding( aCharSetLB.GetSelectTextEncoding() );
     155             : 
     156           0 :     return sal_False;
     157             : }
     158             : 
     159           0 : void OfaHtmlTabPage::Reset( const SfxItemSet& )
     160             : {
     161           0 :     SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
     162           0 :     aSize1NF.SetValue(rHtmlOpt.GetFontSize(0));
     163           0 :     aSize2NF.SetValue(rHtmlOpt.GetFontSize(1));
     164           0 :     aSize3NF.SetValue(rHtmlOpt.GetFontSize(2));
     165           0 :     aSize4NF.SetValue(rHtmlOpt.GetFontSize(3));
     166           0 :     aSize5NF.SetValue(rHtmlOpt.GetFontSize(4));
     167           0 :     aSize6NF.SetValue(rHtmlOpt.GetFontSize(5));
     168           0 :     aSize7NF.SetValue(rHtmlOpt.GetFontSize(6));
     169           0 :     aNumbersEnglishUSCB.Check(rHtmlOpt.IsNumbersEnglishUS());
     170           0 :     aUnknownTagCB.Check(rHtmlOpt.IsImportUnknown());
     171           0 :     aIgnoreFontNamesCB.Check(rHtmlOpt.IsIgnoreFontFamily());
     172           0 :     sal_uInt16 nExport = rHtmlOpt.GetExportMode();
     173           0 :     if( nExport >= SAL_N_ELEMENTS( aExportToPosArr ) )
     174           0 :         nExport = 3;    // default for bad config entry is NS 4.0
     175           0 :     sal_uInt16 nPosArr = aExportToPosArr[ nExport ];
     176           0 :     aExportLB.SelectEntryPos( nPosArr );
     177           0 :     aExportLB.SaveValue();
     178             : 
     179           0 :     ExportHdl_Impl(&aExportLB);
     180             : 
     181           0 :     aStarBasicCB .Check(rHtmlOpt.IsStarBasic());
     182           0 :     aStarBasicWarningCB .Check(rHtmlOpt.IsStarBasicWarning());
     183           0 :     aStarBasicWarningCB.Enable(!aStarBasicCB.IsChecked());
     184           0 :     aSaveGrfLocalCB.Check(rHtmlOpt.IsSaveGraphicsLocal());
     185           0 :     aPrintExtensionCB.Check(rHtmlOpt.IsPrintLayoutExtension());
     186             : 
     187           0 :     aPrintExtensionCB.SaveValue();
     188           0 :     aStarBasicCB .SaveValue();
     189           0 :     aStarBasicWarningCB .SaveValue();
     190           0 :     aSaveGrfLocalCB.SaveValue();
     191           0 :     aSize1NF.SaveValue();
     192           0 :     aSize2NF.SaveValue();
     193           0 :     aSize3NF.SaveValue();
     194           0 :     aSize4NF.SaveValue();
     195           0 :     aSize5NF.SaveValue();
     196           0 :     aSize6NF.SaveValue();
     197           0 :     aSize7NF.SaveValue();
     198           0 :     aNumbersEnglishUSCB.SaveValue();
     199           0 :     aUnknownTagCB.SaveValue();
     200           0 :     aIgnoreFontNamesCB.SaveValue();
     201             : 
     202           0 :     if( !rHtmlOpt.IsDefaultTextEncoding() &&
     203           0 :         aCharSetLB.GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
     204           0 :         aCharSetLB.SelectTextEncoding( rHtmlOpt.GetTextEncoding() );
     205           0 : }
     206             : 
     207           0 : IMPL_LINK(OfaHtmlTabPage, ExportHdl_Impl, ListBox*, pBox)
     208             : {
     209           0 :     sal_uInt16 nExport = aPosToExportArr[ pBox->GetSelectEntryPos() ];
     210           0 :     switch( nExport )
     211             :     {
     212             :         case HTML_CFG_MSIE:
     213             :         case HTML_CFG_NS40  :
     214             :         case HTML_CFG_WRITER :
     215           0 :             aPrintExtensionCB.Enable(sal_True);
     216           0 :         break;
     217           0 :         default: aPrintExtensionCB.Enable(sal_False);
     218             :     }
     219             : 
     220           0 :     return 0;
     221             : }
     222             : 
     223           0 : IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, CheckBox*, pBox)
     224             : {
     225           0 :     aStarBasicWarningCB.Enable(!pBox->IsChecked());
     226           0 :     return 0;
     227           3 : }
     228             : 
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10