Skip to content

Commit

Permalink
use officecfg for SvxHtmlOptions
Browse files Browse the repository at this point in the history
Change-Id: Ie7db7d20509e45fd87d8460c7fae6c0131e0a1f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119494
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
  • Loading branch information
Noel Grandin committed Jul 26, 2021
1 parent 6e07c40 commit da9bba7
Show file tree
Hide file tree
Showing 22 changed files with 176 additions and 505 deletions.
89 changes: 53 additions & 36 deletions cui/source/options/opthtml.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <svtools/langtab.hxx>
#include <svtools/htmlcfg.hxx>
#include <comphelper/configuration.hxx>
#include <officecfg/Office/Common.hxx>
#include "opthtml.hxx"


Expand Down Expand Up @@ -72,68 +74,83 @@ std::unique_ptr<SfxTabPage> OfaHtmlTabPage::Create( weld::Container* pPage, weld

bool OfaHtmlTabPage::FillItemSet( SfxItemSet* )
{
SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
std::shared_ptr<comphelper::ConfigurationChanges> xChanges = comphelper::ConfigurationChanges::create();
if(m_xSize1NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(0, static_cast<sal_uInt16>(m_xSize1NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::set(
static_cast<sal_uInt16>(m_xSize1NF->get_value()), xChanges);
if(m_xSize2NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(1, static_cast<sal_uInt16>(m_xSize2NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::set(
static_cast<sal_uInt16>(m_xSize2NF->get_value()), xChanges);
if(m_xSize3NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(2, static_cast<sal_uInt16>(m_xSize3NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::set(
static_cast<sal_uInt16>(m_xSize3NF->get_value()), xChanges);
if(m_xSize4NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(3, static_cast<sal_uInt16>(m_xSize4NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::set(
static_cast<sal_uInt16>(m_xSize4NF->get_value()), xChanges);
if(m_xSize5NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(4, static_cast<sal_uInt16>(m_xSize5NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::set(
static_cast<sal_uInt16>(m_xSize5NF->get_value()), xChanges);
if(m_xSize6NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(5, static_cast<sal_uInt16>(m_xSize6NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::set(
static_cast<sal_uInt16>(m_xSize6NF->get_value()), xChanges);
if(m_xSize7NF->get_value_changed_from_saved())
rHtmlOpt.SetFontSize(6, static_cast<sal_uInt16>(m_xSize7NF->get_value()));
officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::set(
static_cast<sal_uInt16>(m_xSize7NF->get_value()), xChanges);

if(m_xNumbersEnglishUSCB->get_state_changed_from_saved())
rHtmlOpt.SetNumbersEnglishUS(m_xNumbersEnglishUSCB->get_active());
officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::set(
m_xNumbersEnglishUSCB->get_active(), xChanges);

if(m_xUnknownTagCB->get_state_changed_from_saved())
rHtmlOpt.SetImportUnknown(m_xUnknownTagCB->get_active());
officecfg::Office::Common::Filter::HTML::Import::UnknownTag::set(
m_xUnknownTagCB->get_active(), xChanges);

if(m_xIgnoreFontNamesCB->get_state_changed_from_saved())
rHtmlOpt.SetIgnoreFontFamily(m_xIgnoreFontNamesCB->get_active());
officecfg::Office::Common::Filter::HTML::Import::FontSetting::set(
m_xIgnoreFontNamesCB->get_active(), xChanges);

if(m_xStarBasicCB->get_state_changed_from_saved())
rHtmlOpt.SetStarBasic(m_xStarBasicCB->get_active());
officecfg::Office::Common::Filter::HTML::Export::Basic::set(
m_xStarBasicCB->get_active(), xChanges);

if(m_xStarBasicWarningCB->get_state_changed_from_saved())
rHtmlOpt.SetStarBasicWarning(m_xStarBasicWarningCB->get_active());
officecfg::Office::Common::Filter::HTML::Export::Warning::set(
m_xStarBasicWarningCB->get_active(), xChanges);

if(m_xSaveGrfLocalCB->get_state_changed_from_saved())
rHtmlOpt.SetSaveGraphicsLocal(m_xSaveGrfLocalCB->get_active());
officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::set(
m_xSaveGrfLocalCB->get_active(), xChanges);

if(m_xPrintExtensionCB->get_state_changed_from_saved())
rHtmlOpt.SetPrintLayoutExtension(m_xPrintExtensionCB->get_active());
officecfg::Office::Common::Filter::HTML::Export::PrintLayout::set(
m_xPrintExtensionCB->get_active(), xChanges);

if( m_xCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
rHtmlOpt.SetTextEncoding( m_xCharSetLB->GetSelectTextEncoding() );
if( m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() )
officecfg::Office::Common::Filter::HTML::Export::Encoding::set(
m_xCharSetLB->GetSelectTextEncoding(), xChanges );

xChanges->commit();
return false;
}

void OfaHtmlTabPage::Reset( const SfxItemSet* )
{
SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
m_xSize1NF->set_value(rHtmlOpt.GetFontSize(0));
m_xSize2NF->set_value(rHtmlOpt.GetFontSize(1));
m_xSize3NF->set_value(rHtmlOpt.GetFontSize(2));
m_xSize4NF->set_value(rHtmlOpt.GetFontSize(3));
m_xSize5NF->set_value(rHtmlOpt.GetFontSize(4));
m_xSize6NF->set_value(rHtmlOpt.GetFontSize(5));
m_xSize7NF->set_value(rHtmlOpt.GetFontSize(6));
m_xNumbersEnglishUSCB->set_active(rHtmlOpt.IsNumbersEnglishUS());
m_xUnknownTagCB->set_active(rHtmlOpt.IsImportUnknown());
m_xIgnoreFontNamesCB->set_active(rHtmlOpt.IsIgnoreFontFamily());

m_xStarBasicCB->set_active(rHtmlOpt.IsStarBasic());
m_xStarBasicWarningCB->set_active(rHtmlOpt.IsStarBasicWarning());
m_xSize1NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get());
m_xSize2NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get());
m_xSize3NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get());
m_xSize4NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get());
m_xSize5NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get());
m_xSize6NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get());
m_xSize7NF->set_value(officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get());
m_xNumbersEnglishUSCB->set_active(officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get());
m_xUnknownTagCB->set_active(officecfg::Office::Common::Filter::HTML::Import::UnknownTag::get());
m_xIgnoreFontNamesCB->set_active(officecfg::Office::Common::Filter::HTML::Import::FontSetting::get());

m_xStarBasicCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Basic::get());
m_xStarBasicWarningCB->set_active(officecfg::Office::Common::Filter::HTML::Export::Warning::get());
m_xStarBasicWarningCB->set_sensitive(!m_xStarBasicCB->get_active());
m_xSaveGrfLocalCB->set_active(rHtmlOpt.IsSaveGraphicsLocal());
m_xPrintExtensionCB->set_active(rHtmlOpt.IsPrintLayoutExtension());
m_xSaveGrfLocalCB->set_active(officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get());
m_xPrintExtensionCB->set_active(SvxHtmlOptions::IsPrintLayoutExtension());

m_xPrintExtensionCB->save_state();
m_xStarBasicCB->save_state();
Expand All @@ -150,9 +167,9 @@ void OfaHtmlTabPage::Reset( const SfxItemSet* )
m_xUnknownTagCB->save_state();
m_xIgnoreFontNamesCB->save_state();

if( !rHtmlOpt.IsDefaultTextEncoding() &&
m_xCharSetLB->GetSelectTextEncoding() != rHtmlOpt.GetTextEncoding() )
m_xCharSetLB->SelectTextEncoding( rHtmlOpt.GetTextEncoding() );
if( !SvxHtmlOptions::IsDefaultTextEncoding() &&
m_xCharSetLB->GetSelectTextEncoding() != SvxHtmlOptions::GetTextEncoding() )
m_xCharSetLB->SelectTextEncoding( SvxHtmlOptions::GetTextEncoding() );
}

IMPL_LINK(OfaHtmlTabPage, CheckBoxHdl_Impl, weld::Toggleable&, rBox, void)
Expand Down
3 changes: 1 addition & 2 deletions dbaccess/source/ui/misc/TokenWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ OHTMLImportExport::OHTMLImportExport(const svx::ODataAccessDescriptor& _aDataDes
#endif
{
// set HTML configuration
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
m_eDestEnc = rHtmlOptions.GetTextEncoding();
m_eDestEnc = SvxHtmlOptions::GetTextEncoding();
strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource)));
sIndent[0] = 0;
}
Expand Down
58 changes: 11 additions & 47 deletions include/svtools/htmlcfg.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,30 @@
*/
#pragma once

#include <unotools/configitem.hxx>
#include <svtools/svtdllapi.h>
#include <memory>
#include <rtl/textenc.h>

#define HTML_FONT_COUNT 7

// !!!be aware!!!: the following defines are _not_ used as values in the configuration file
// this is because of compatibility reasons
#define HTML_CFG_MSIE 1 // Internet Explorer
#define HTML_CFG_WRITER 2 // Writer
#define HTML_CFG_NS40 3 // Netscape 4.0
#define HTML_CFG_MSIE 1 // Internet Explorer
#define HTML_CFG_WRITER 2 // Writer
#define HTML_CFG_NS40 3 // Netscape 4.0

#define HTML_CFG_MAX HTML_CFG_NS40

struct HtmlOptions_Impl;

class SVT_DLLPUBLIC SvxHtmlOptions final : public utl::ConfigItem
namespace SvxHtmlOptions
{
std::unique_ptr<HtmlOptions_Impl> pImpl;
static const css::uno::Sequence<OUString>& GetPropertyNames();
void Load( const css::uno::Sequence< OUString >& rPropertyNames );

virtual void ImplCommit() override;

public:
SvxHtmlOptions();
virtual ~SvxHtmlOptions() override;

virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override;

sal_uInt16 GetFontSize(sal_uInt16 nPos) const;
void SetFontSize(sal_uInt16 nPos, sal_uInt16 nSize);

bool IsImportUnknown() const;
void SetImportUnknown(bool bSet);

sal_uInt16 GetExportMode() const;

bool IsStarBasic() const;
void SetStarBasic(bool bSet);

bool IsStarBasicWarning() const;
void SetStarBasicWarning(bool bSet);

bool IsSaveGraphicsLocal() const;
void SetSaveGraphicsLocal(bool bSet);

bool IsPrintLayoutExtension() const;
void SetPrintLayoutExtension(bool bSet);
SVT_DLLPUBLIC sal_uInt16 GetFontSize(sal_uInt16 nPos);

bool IsIgnoreFontFamily() const;
void SetIgnoreFontFamily(bool bSet);
SVT_DLLPUBLIC sal_uInt16 GetExportMode();

bool IsDefaultTextEncoding() const;
rtl_TextEncoding GetTextEncoding() const;
void SetTextEncoding( rtl_TextEncoding );
static SvxHtmlOptions& Get();
SVT_DLLPUBLIC bool IsPrintLayoutExtension();

bool IsNumbersEnglishUS() const;
void SetNumbersEnglishUS(bool bSet);
SVT_DLLPUBLIC bool IsDefaultTextEncoding();
SVT_DLLPUBLIC rtl_TextEncoding GetTextEncoding();
SVT_DLLPUBLIC void SetTextEncoding(rtl_TextEncoding);
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
8 changes: 4 additions & 4 deletions sc/source/filter/html/htmlexp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <rtl/strbuf.hxx>
#include <officecfg/Office/Common.hxx>

using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
Expand Down Expand Up @@ -213,9 +214,8 @@ ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const OUString& rBaseURL, ScDocume
sIndent[0] = 0;

// set HTML configuration
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
eDestEnc = (pDoc->IsClipOrUndo() ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding());
bCopyLocalFileToINet = rHtmlOptions.IsSaveGraphicsLocal();
eDestEnc = (pDoc->IsClipOrUndo() ? RTL_TEXTENCODING_UTF8 : SvxHtmlOptions::GetTextEncoding());
bCopyLocalFileToINet = officecfg::Office::Common::Filter::HTML::Export::LocalGraphic::get();

if (rFilterOptions == u"SkipImages")
{
Expand All @@ -228,7 +228,7 @@ ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const OUString& rBaseURL, ScDocume

for ( sal_uInt16 j=0; j < SC_HTML_FONTSIZES; j++ )
{
sal_uInt16 nSize = rHtmlOptions.GetFontSize( j );
sal_uInt16 nSize = SvxHtmlOptions::GetFontSize( j );
// remember in Twips, like our SvxFontHeightItem
if ( nSize )
nFontSize[j] = nSize * 20;
Expand Down
11 changes: 8 additions & 3 deletions sc/source/filter/html/htmlpars.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <numeric>
#include <utility>
#include <officecfg/Office/Common.hxx>

using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
Expand Down Expand Up @@ -186,9 +187,13 @@ ScHTMLParser::ScHTMLParser( EditEngine* pEditEngine, ScDocument* pDoc ) :
ScEEParser( pEditEngine ),
mpDoc( pDoc )
{
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
for( sal_uInt16 nIndex = 0; nIndex < SC_HTML_FONTSIZES; ++nIndex )
maFontHeights[ nIndex ] = rHtmlOptions.GetFontSize( nIndex ) * 20;
maFontHeights[0] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_1::get();
maFontHeights[1] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_2::get();
maFontHeights[2] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_3::get();
maFontHeights[3] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_4::get();
maFontHeights[4] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_5::get();
maFontHeights[5] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_6::get();
maFontHeights[6] = officecfg::Office::Common::Filter::HTML::Import::FontSize::Size_7::get();
}

ScHTMLParser::~ScHTMLParser()
Expand Down
4 changes: 2 additions & 2 deletions sc/source/filter/rtf/eeimpars.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <unotools/charclass.hxx>
#include <comphelper/string.hxx>
#include <osl/diagnose.h>
#include <officecfg/Office/Common.hxx>

#include <eeimport.hxx>
#include <global.hxx>
Expand Down Expand Up @@ -137,8 +138,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
if (pFormatter->GetLanguage() == LANGUAGE_SYSTEM)
{
// Automatic language option selected. Check for the global 'use US English' option.
SvxHtmlOptions aOpt;
bNumbersEnglishUS = aOpt.IsNumbersEnglishUS();
bNumbersEnglishUS = officecfg::Office::Common::Filter::HTML::Import::NumbersEnglishUS::get();
}
ScDocumentPool* pDocPool = mpDoc->GetPool();
ScRangeName* pRangeNames = mpDoc->GetRangeName();
Expand Down
Loading

0 comments on commit da9bba7

Please sign in to comment.