Kaydet (Commit) 913fbc82 authored tarafından Miklos Vajna's avatar Miklos Vajna

EPUB export: add UI to request fixed layout

Sets the EPUBLayoutMethod filter data key at UNO level.

Change-Id: Ia07029bd83fec02e98cb6a3cc2bfea2ab742d769
Reviewed-on: https://gerrit.libreoffice.org/45644Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst ab7bdd1f
......@@ -97,6 +97,22 @@ class EPUBExportTest(UITestCase):
mediaDir = [i.Value for i in filterData if i.Name == "RVNGMediaDir"][0]
self.assertEqual("file:///foo/bar", mediaDir)
def testFixedLayout(self):
def handleDialog(dialog):
# Select the second entry to request fixed, not reflowable layout.
dialog.getChild("layoutlb").executeAction("SELECT", mkPropertyValues({"POS": "1"}))
dialog.getChild("ok").executeAction("CLICK", tuple())
uiComponent = self.ui_test._xContext.ServiceManager.createInstanceWithContext("com.sun.star.comp.Writer.EPUBExportUIComponent", self.ui_test._xContext)
self.ui_test.execute_blocking_action(action=uiComponent.execute, dialog_handler=handleDialog)
propertyValues = uiComponent.getPropertyValues()
filterData = [i.Value for i in propertyValues if i.Name == "FilterData"][0]
# The EPUBLayoutMethod key was missing, EPUBExportDialog::OKClickHdl() did not set it.
layout = [i.Value for i in filterData if i.Name == "EPUBLayoutMethod"][0]
# 1 stands for libepubgen::EPUB_LAYOUT_METHOD_FIXED.
self.assertEqual(1, layout)
def testMeta(self):
def handleDialog(dialog):
dialog.getChild("identifier").executeAction("TYPE", mkPropertyValues({"TEXT": "baddcafe-e394-4cd6-9b83-7172794612e5"}))
......
......@@ -90,12 +90,26 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH
if (it->second >>= nSplitMethod)
// No conversion, 1:1 mapping between libepubgen::EPUBSplitMethod
// and entry positions.
m_pVersion->SelectEntryPos(nSplitMethod);
m_pSplit->SelectEntryPos(nSplitMethod);
}
else
m_pSplit->SelectEntryPos(EPUBExportFilter::GetDefaultSplitMethod());
m_pSplit->SetSelectHdl(LINK(this, EPUBExportDialog, SplitSelectHdl));
get(m_pLayout, "layoutlb");
it = rFilterData.find("EPUBLayoutMethod");
if (it != rFilterData.end())
{
sal_Int32 nLayoutMethod = 0;
if (it->second >>= nLayoutMethod)
// No conversion, 1:1 mapping between libepubgen::EPUBLayoutMethod
// and entry positions.
m_pLayout->SelectEntryPos(nLayoutMethod);
}
else
m_pLayout->SelectEntryPos(EPUBExportFilter::GetDefaultLayoutMethod());
m_pLayout->SetSelectHdl(LINK(this, EPUBExportDialog, LayoutSelectHdl));
get(m_pCoverPath, "coverpath");
get(m_pCoverButton, "coverbutton");
......@@ -128,6 +142,13 @@ IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, ListBox &, void)
mrFilterData["EPUBSplitMethod"] <<= m_pSplit->GetSelectedEntryPos();
}
IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, ListBox &, void)
{
// No conversion, 1:1 mapping between entry positions and
// libepubgen::EPUBLayoutMethod.
mrFilterData["EPUBLayoutMethod"] <<= m_pLayout->GetSelectedEntryPos();
}
IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void)
{
SvxOpenGraphicDialog aDlg("Import", this);
......@@ -187,6 +208,7 @@ void EPUBExportDialog::dispose()
m_pDate.clear();
m_pMediaDir.clear();
m_pMediaButton.clear();
m_pLayout.clear();
ModalDialog::dispose();
}
......
......@@ -30,6 +30,7 @@ public:
private:
DECL_LINK(VersionSelectHdl, ListBox &, void);
DECL_LINK(SplitSelectHdl, ListBox &, void);
DECL_LINK(LayoutSelectHdl, ListBox &, void);
DECL_LINK(CoverClickHdl, Button *, void);
DECL_LINK(MediaClickHdl, Button *, void);
DECL_LINK(OKClickHdl, Button *, void);
......@@ -38,6 +39,7 @@ private:
comphelper::SequenceAsHashMap &mrFilterData;
VclPtr<ListBox> m_pVersion;
VclPtr<ListBox> m_pSplit;
VclPtr<ListBox> m_pLayout;
VclPtr<Edit> m_pCoverPath;
VclPtr<PushButton> m_pCoverButton;
VclPtr<Edit> m_pMediaDir;
......
......@@ -206,6 +206,59 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment6">
<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="box10">
<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="layoutft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|layoutft">Layout method:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">layoutlb</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="layoutlb">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
<items>
<item translatable="yes" context="exportepub|layoutreflowable">Reflowable</item>
<item translatable="yes" context="exportepub|layoutfixed">Fixed</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">3</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
......@@ -276,7 +329,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
......@@ -349,7 +402,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment