EPUB export: add options dialog
It just exposes the two options available at libepubgen level already. Change-Id: I428919ffe495b6d7ec2773f542e2fea6733d0a1c Reviewed-on: https://gerrit.libreoffice.org/42241 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
158434ee87
commit
1f582e38dd
8 changed files with 383 additions and 3 deletions
|
@ -68,6 +68,7 @@ $(eval $(call gb_Library_use_externals,wpftwriter,\
|
|||
$(eval $(call gb_Library_add_exception_objects,wpftwriter,\
|
||||
writerperfect/source/writer/AbiWordImportFilter \
|
||||
writerperfect/source/writer/EBookImportFilter \
|
||||
writerperfect/source/writer/EPUBExportDialog \
|
||||
writerperfect/source/writer/EPUBExportFilter \
|
||||
writerperfect/source/writer/EPUBExportUIComponent \
|
||||
writerperfect/source/writer/EPUBPackage \
|
||||
|
|
|
@ -21,6 +21,7 @@ $(eval $(call gb_UIConfig_UIConfig,writerperfect))
|
|||
|
||||
$(eval $(call gb_UIConfig_add_uifiles,writerperfect,\
|
||||
writerperfect/uiconfig/ui/wpftencodingdialog \
|
||||
writerperfect/uiconfig/ui/exportepub \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
121
writerperfect/source/writer/EPUBExportDialog.cxx
Normal file
121
writerperfect/source/writer/EPUBExportDialog.cxx
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "EPUBExportDialog.hxx"
|
||||
|
||||
#include "EPUBExportFilter.hxx"
|
||||
|
||||
using namespace com::sun::star;
|
||||
|
||||
namespace
|
||||
{
|
||||
/// Converts version value to a listbox entry position.
|
||||
sal_Int32 VersionToPosition(sal_Int32 nVersion)
|
||||
{
|
||||
sal_Int32 nPosition = 0;
|
||||
|
||||
switch (nVersion)
|
||||
{
|
||||
case 30:
|
||||
nPosition = 0;
|
||||
break;
|
||||
case 20:
|
||||
nPosition = 1;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return nPosition;
|
||||
}
|
||||
|
||||
/// Converts listbox entry position to a version value.
|
||||
sal_Int32 PositionToVersion(sal_Int32 nPosition)
|
||||
{
|
||||
sal_Int32 nVersion = 0;
|
||||
|
||||
switch (nPosition)
|
||||
{
|
||||
case 0:
|
||||
nVersion = 30;
|
||||
break;
|
||||
case 1:
|
||||
nVersion = 20;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return nVersion;
|
||||
}
|
||||
}
|
||||
|
||||
namespace writerperfect
|
||||
{
|
||||
|
||||
EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData)
|
||||
: ModalDialog(pParent, "EpubDialog", "writerperfect/ui/exportepub.ui"),
|
||||
mrFilterData(rFilterData)
|
||||
{
|
||||
get(m_pVersion, "versionlb");
|
||||
assert(PositionToVersion(m_pVersion->GetSelectEntryPos()) == EPUBExportFilter::GetDefaultVersion());
|
||||
|
||||
auto it = rFilterData.find("EPUBVersion");
|
||||
if (it != rFilterData.end())
|
||||
{
|
||||
sal_Int32 nVersion = 0;
|
||||
if (it->second >>= nVersion)
|
||||
m_pVersion->SelectEntryPos(VersionToPosition(nVersion));
|
||||
}
|
||||
m_pVersion->SetSelectHdl(LINK(this, EPUBExportDialog, VersionSelectHdl));
|
||||
|
||||
get(m_pSplit, "splitlb");
|
||||
it = rFilterData.find("EPUBSplitMethod");
|
||||
if (it != rFilterData.end())
|
||||
{
|
||||
sal_Int32 nSplitMethod = 0;
|
||||
if (it->second >>= nSplitMethod)
|
||||
// No conversion, 1:1 mapping between libepubgen::EPUBSplitMethod
|
||||
// and entry positions.
|
||||
m_pVersion->SelectEntryPos(nSplitMethod);
|
||||
}
|
||||
else
|
||||
m_pSplit->SelectEntryPos(EPUBExportFilter::GetDefaultSplitMethod());
|
||||
m_pSplit->SetSelectHdl(LINK(this, EPUBExportDialog, SplitSelectHdl));
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, ListBox &, void)
|
||||
{
|
||||
mrFilterData["EPUBVersion"] <<= PositionToVersion(m_pVersion->GetSelectEntryPos());
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, ListBox &, void)
|
||||
{
|
||||
// No conversion, 1:1 mapping between entry positions and
|
||||
// libepubgen::EPUBSplitMethod.
|
||||
mrFilterData["EPUBSplitMethod"] <<= m_pSplit->GetSelectEntryPos();
|
||||
}
|
||||
|
||||
EPUBExportDialog::~EPUBExportDialog()
|
||||
{
|
||||
disposeOnce();
|
||||
}
|
||||
|
||||
void EPUBExportDialog::dispose()
|
||||
{
|
||||
m_pVersion.clear();
|
||||
m_pSplit.clear();
|
||||
ModalDialog::dispose();
|
||||
}
|
||||
|
||||
} // namespace writerperfect
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
41
writerperfect/source/writer/EPUBExportDialog.hxx
Normal file
41
writerperfect/source/writer/EPUBExportDialog.hxx
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTDIALOG_HXX
|
||||
#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTDIALOG_HXX
|
||||
|
||||
#include <comphelper/sequenceashashmap.hxx>
|
||||
#include <vcl/dialog.hxx>
|
||||
#include <vcl/lstbox.hxx>
|
||||
|
||||
namespace writerperfect
|
||||
{
|
||||
|
||||
/// EPUB export options dialog.
|
||||
class EPUBExportDialog : public ModalDialog
|
||||
{
|
||||
public:
|
||||
EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData);
|
||||
~EPUBExportDialog() override;
|
||||
void dispose() override;
|
||||
|
||||
private:
|
||||
DECL_LINK(VersionSelectHdl, ListBox &, void);
|
||||
DECL_LINK(SplitSelectHdl, ListBox &, void);
|
||||
|
||||
comphelper::SequenceAsHashMap &mrFilterData;
|
||||
VclPtr<ListBox> m_pVersion;
|
||||
VclPtr<ListBox> m_pSplit;
|
||||
};
|
||||
|
||||
} // namespace writerperfect
|
||||
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -33,10 +33,20 @@ EPUBExportFilter::EPUBExportFilter(const uno::Reference<uno::XComponentContext>
|
|||
{
|
||||
}
|
||||
|
||||
sal_Int32 EPUBExportFilter::GetDefaultVersion()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
sal_Int32 EPUBExportFilter::GetDefaultSplitMethod()
|
||||
{
|
||||
return libepubgen::EPUB_SPLIT_METHOD_HEADING;
|
||||
}
|
||||
|
||||
sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDescriptor)
|
||||
{
|
||||
sal_Int32 nVersion = 30;
|
||||
sal_Int32 nSplitMethod = libepubgen::EPUB_SPLIT_METHOD_HEADING;
|
||||
sal_Int32 nVersion = EPUBExportFilter::GetDefaultVersion();
|
||||
sal_Int32 nSplitMethod = EPUBExportFilter::GetDefaultSplitMethod();
|
||||
uno::Sequence<beans::PropertyValue> aFilterData;
|
||||
for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,11 @@ public:
|
|||
OUString SAL_CALL getImplementationName() override;
|
||||
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override;
|
||||
css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
|
||||
|
||||
/// Gives the default EPUB version.
|
||||
static sal_Int32 GetDefaultVersion();
|
||||
/// Gives the default split method.
|
||||
static sal_Int32 GetDefaultSplitMethod();
|
||||
};
|
||||
|
||||
} // namespace writerperfect
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/vclptr.hxx>
|
||||
|
||||
#include "EPUBExportDialog.hxx"
|
||||
|
||||
using namespace com::sun::star;
|
||||
|
||||
|
@ -70,7 +74,10 @@ void EPUBExportUIComponent::setTitle(const OUString &/*rTitle*/)
|
|||
|
||||
sal_Int16 EPUBExportUIComponent::execute()
|
||||
{
|
||||
ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData);
|
||||
if (pDialog->Execute() == RET_OK)
|
||||
return ui::dialogs::ExecutableDialogResults::OK;
|
||||
return ui::dialogs::ExecutableDialogResults::CANCEL;
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *SAL_CALL com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation(uno::XComponentContext *pCtx, uno::Sequence<uno::Any> const &)
|
||||
|
|
194
writerperfect/uiconfig/ui/exportepub.ui
Normal file
194
writerperfect/uiconfig/ui/exportepub.ui
Normal file
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface domain="sw">
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<object class="GtkDialog" id="EpubDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">6</property>
|
||||
<property name="title" translatable="yes" context="exportepub|EpubDialog">EPUB Export</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="ok">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="cancel">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="help">
|
||||
<property name="label">gtk-help</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
<property name="secondary">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="top_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="versionft">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="label" translatable="yes" context="exportepub|versionft">Version:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">versionlb</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="versionlb">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item translatable="yes" context="exportepub|epub3">EPUB 3.0</item>
|
||||
<item translatable="yes" context="exportepub|epub2">EPUB 2.0</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="top_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="splitft">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="label" translatable="yes" context="exportepub|splitft">Split method:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">versionlb</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="splitlb">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item translatable="yes" context="exportepub|splitpage">Page break</item>
|
||||
<item translatable="yes" context="exportepub|splitheading">Heading</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="0">ok</action-widget>
|
||||
<action-widget response="-6">cancel</action-widget>
|
||||
<action-widget response="-11">help</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
<property name="upper">9999</property>
|
||||
<property name="value">1</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
</interface>
|
Loading…
Reference in a new issue