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

EPUB export: add uno command to trigger the filter

This is quite similar to PDF, except that by default the File menu
doesn't advertise this command. Possible to add it via Tools ->
Customize -> Menus -> Search -> EPUB.

(Reasoning for having a dedicated UNO command for EPUB is an increasing
amount of users look at EPUB as the new PDF, given how non-reflowable
PDF is hard to read on mobile devices, while EPUB is primarily
reflowable.)

Change-Id: Ib80f784a630a192f5b6ffbbfc60cb565fda7ed37
üst 321c2d44
......@@ -125,6 +125,7 @@
#define SID_EXPORTDOC (SID_SFX_START + 829)
#define SID_EXPORTDOCASPDF (SID_SFX_START + 1673)
#define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674)
#define SID_EXPORTDOCASEPUB (SID_SFX_START + 1677)
#define SID_UPDATEDOCMODE (SID_SFX_START + 1668)
#define SID_CHECKOUT (SID_SFX_START + 512)
#define SID_CANCELCHECKOUT (SID_SFX_START + 513)
......
......@@ -4855,6 +4855,20 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ExportToEPUB" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">EPUB</value>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string">
<value xml:lang="en-US">~Export as EPUB...</value>
</prop>
<prop oor:name="TooltipLabel" oor:type="xs:string">
<value xml:lang="en-US">Export as EPUB</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
<node oor:name=".uno:ConfigureDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Customize...</value>
......
......@@ -234,6 +234,11 @@ shell SfxObjectShell
ExecMethod = ExecFile_Impl ;
StateMethod = GetState_Impl ;
]
SID_EXPORTDOCASEPUB
[
ExecMethod = ExecFile_Impl ;
StateMethod = GetState_Impl ;
]
SID_SIGNATURE
[
ExecMethod = ExecFile_Impl;
......
......@@ -4778,6 +4778,22 @@ SfxVoidItem ExportDirectToPDF SID_DIRECTEXPORTDOCASPDF
GroupId = SfxGroupId::Document;
]
SfxVoidItem ExportToEPUB SID_EXPORTDOCASEPUB
(SfxStringItem URL SID_FILE_NAME, SfxStringItem FilterName SID_FILTER_NAME)
[
AutoUpdate = FALSE,
FastCall = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = TRUE,
RecordAbsolute = FALSE,
RecordPerSet;
AccelConfig = TRUE,
MenuConfig = TRUE,
ToolBoxConfig = TRUE,
GroupId = SfxGroupId::Document;
]
SfxImageItem ImageOrientation SID_IMAGE_ORIENTATION
......
......@@ -168,8 +168,9 @@ static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC ||
nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF ||
nSlotId == SID_DIRECTEXPORTDOCASPDF || nSlotId == SID_SAVEACOPY ||
nSlotId == SID_SAVETO || nSlotId == SID_SAVEACOPY ||
nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
nSlotId == SID_EXPORTDOCASEPUB ||
nSlotId == SID_SAVEACOPYITEM);
}
......@@ -1330,6 +1331,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC ||
nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ||
nSlotId == SID_EXPORTDOCASEPUB ||
nSlotId == SID_SAVEACOPY )
{
const SfxPoolItem *pItem=nullptr;
......
......@@ -113,6 +113,7 @@
#define SAVE_REQUESTED 16
#define SAVEAS_REQUESTED 32
#define SAVEACOPY_REQUESTED 64
#define EPUBEXPORT_REQUESTED 128
#define SAVEASREMOTE_REQUESTED -1
// possible statuses of save operation
......@@ -130,7 +131,7 @@ using namespace css::system;
namespace {
sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode )
sal_uInt16 getSlotIDFromMode( sal_Int16 nStoreMode )
{
// This is a temporary hardcoded solution must be removed when
// dialogs do not need parameters in SidSet representation any more
......@@ -140,6 +141,8 @@ sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode )
nResult = SID_EXPORTDOC;
else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED ) )
nResult = SID_EXPORTDOCASPDF;
else if ( nStoreMode == ( EXPORT_REQUESTED | EPUBEXPORT_REQUESTED ) )
nResult = SID_EXPORTDOCASEPUB;
else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED | PDFDIRECTEXPORT_REQUESTED ) )
nResult = SID_DIRECTEXPORTDOCASPDF;
else if ( nStoreMode == SAVEAS_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | WIDEEXPORT_REQUESTED ) )
......@@ -154,15 +157,17 @@ sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode )
}
sal_Int8 getStoreModeFromSlotName( const OUString& aSlotName )
sal_Int16 getStoreModeFromSlotName( const OUString& aSlotName )
{
sal_Int8 nResult = 0;
sal_Int16 nResult = 0;
if ( aSlotName == "ExportTo" )
nResult = EXPORT_REQUESTED;
else if ( aSlotName == "ExportToPDF" )
nResult = EXPORT_REQUESTED | PDFEXPORT_REQUESTED;
else if ( aSlotName == "ExportDirectToPDF" )
nResult = EXPORT_REQUESTED | PDFEXPORT_REQUESTED | PDFDIRECTEXPORT_REQUESTED;
else if ( aSlotName == "ExportToEPUB" )
nResult = EXPORT_REQUESTED | EPUBEXPORT_REQUESTED;
else if ( aSlotName == "Save" )
nResult = SAVE_REQUESTED;
else if ( aSlotName == "SaveAs" )
......@@ -179,14 +184,14 @@ sal_Int8 getStoreModeFromSlotName( const OUString& aSlotName )
}
SfxFilterFlags getMustFlags( sal_Int8 nStoreMode )
SfxFilterFlags getMustFlags( sal_Int16 nStoreMode )
{
return ( SfxFilterFlags::EXPORT
| ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SfxFilterFlags::NONE : SfxFilterFlags::IMPORT ) );
}
SfxFilterFlags getDontFlags( sal_Int8 nStoreMode )
SfxFilterFlags getDontFlags( sal_Int16 nStoreMode )
{
return ( SfxFilterFlags::INTERNAL
| SfxFilterFlags::NOTINFILEDLG
......@@ -299,7 +304,7 @@ public:
OUString GetDocServiceName();
uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilterCheckFlags( SfxFilterFlags nMust, SfxFilterFlags nDont );
uno::Sequence< beans::PropertyValue > GetDocServiceAnyFilter( SfxFilterFlags nMust, SfxFilterFlags nDont );
uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl( sal_Int8 nStoreMode );
uno::Sequence< beans::PropertyValue > GetPreselectedFilter_Impl( sal_Int16 nStoreMode );
uno::Sequence< beans::PropertyValue > GetDocServiceDefaultFilter();
bool ExecuteFilterDialog_Impl( const OUString& aFilterName );
......@@ -311,7 +316,7 @@ public:
bool CheckFilterOptionsDialogExistence();
bool OutputFileDialog( sal_Int8 nStoreMode,
bool OutputFileDialog( sal_Int16 nStoreMode,
const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
bool bSetStandardName,
OUString& aSuggestedName,
......@@ -521,7 +526,7 @@ uno::Sequence< beans::PropertyValue > ModelData_Impl::GetDocServiceAnyFilter( Sf
}
uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl( sal_Int8 nStoreMode )
uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl( sal_Int16 nStoreMode )
{
if ( nStoreMode == SAVEASREMOTE_REQUESTED )
nStoreMode = SAVEAS_REQUESTED;
......@@ -542,6 +547,17 @@ uno::Sequence< beans::PropertyValue > ModelData_Impl::GetPreselectedFilter_Impl(
aFilterProps = ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
}
else if ( ( nStoreMode != SAVEASREMOTE_REQUESTED ) && ( nStoreMode & EPUBEXPORT_REQUESTED ) )
{
// Preselect EPUB filter for export.
uno::Sequence<beans::NamedValue> aSearchRequest
{
{ "Type", css::uno::makeAny(OUString("writer_EPUB_Document")) },
{ "DocumentService", css::uno::makeAny(GetDocServiceName()) }
};
aFilterProps = ::comphelper::MimeConfigurationHelper::SearchForFilter( m_pOwner->GetFilterQuery(), aSearchRequest, nMust, nDont );
}
else
{
aFilterProps = GetDocServiceDefaultFilterCheckFlags( nMust, nDont );
......@@ -781,7 +797,7 @@ bool ModelData_Impl::CheckFilterOptionsDialogExistence()
}
bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
const ::comphelper::SequenceAsHashMap& aPreselectedFilterPropsHM,
bool bSetStandardName,
OUString& aSuggestedName,
......@@ -825,7 +841,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
if( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) )
{
if ( nStoreMode & PDFEXPORT_REQUESTED )
if ( (nStoreMode & PDFEXPORT_REQUESTED) || (nStoreMode & EPUBEXPORT_REQUESTED) )
aDialogMode = css::ui::dialogs::TemplateDescription::
FILESAVE_AUTOEXTENSION;
else
......@@ -858,6 +874,13 @@ bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode,
pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, "pdf", rStandardDir, rBlackList, pWin ));
pFileDlg->SetCurrentFilter( aFilterUIName );
}
else if ((nStoreMode & EPUBEXPORT_REQUESTED) && !aPreselectedFilterPropsHM.empty())
{
// This is an EPUB export, the filter options has been shown already.
const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, "epub", rStandardDir, rBlackList, pWin));
pFileDlg->SetCurrentFilter(aFilterUIName);
}
else
{
// This is the normal dialog
......@@ -1286,7 +1309,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
// parse the slot name
bool bRemote = false;
sal_Int8 nStoreMode = getStoreModeFromSlotName( aSlotName );
sal_Int16 nStoreMode = getStoreModeFromSlotName( aSlotName );
if ( nStoreMode == SAVEASREMOTE_REQUESTED )
{
......@@ -1424,9 +1447,11 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
const OUString sFilterDataString(aFilterDataString);
const OUString sFilterFlagsString("FilterFlags");
if ( ( nStoreMode & EXPORT_REQUESTED ) && ( nStoreMode & PDFEXPORT_REQUESTED ) && !( nStoreMode & PDFDIRECTEXPORT_REQUESTED ) )
bool bPDFOptions = (nStoreMode & PDFEXPORT_REQUESTED) && !(nStoreMode & PDFDIRECTEXPORT_REQUESTED);
bool bEPUBOptions = (nStoreMode & EPUBEXPORT_REQUESTED);
if ( ( nStoreMode & EXPORT_REQUESTED ) && (bPDFOptions || bEPUBOptions) )
{
// this is PDF export, the filter options dialog should be shown before the export
// this is PDF or EPUB export, the filter options dialog should be shown before the export
aModelData.GetMediaDescr()[sFilterNameString] <<= aFilterName;
if ( aModelData.GetMediaDescr().find( sFilterFlagsString ) == aModelData.GetMediaDescr().end()
&& aModelData.GetMediaDescr().find( sFilterOptionsString ) == aModelData.GetMediaDescr().end()
......@@ -1564,7 +1589,7 @@ bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& xMo
aModelData.GetMediaDescr().find( OUString("FilterFlags") );
bool bFilterFlagsSet = ( aIter != aModelData.GetMediaDescr().end() );
if( !( nStoreMode & PDFEXPORT_REQUESTED ) && !bFilterFlagsSet
if( !( nStoreMode & PDFEXPORT_REQUESTED ) && !( nStoreMode & EPUBEXPORT_REQUESTED ) && !bFilterFlagsSet
&& ( ( nStoreMode & EXPORT_REQUESTED ) || bUseFilterOptions ) )
{
// execute filter options dialog
......
......@@ -499,6 +499,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
case SID_DIRECTEXPORTDOCASPDF:
bIsPDFExport = true;
SAL_FALLTHROUGH;
case SID_EXPORTDOCASEPUB:
case SID_EXPORTDOC:
case SID_SAVEASDOC:
case SID_SAVEASREMOTE:
......@@ -977,6 +978,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_EXPORTDOCASPDF:
case SID_DIRECTEXPORTDOCASPDF:
case SID_EXPORTDOCASEPUB:
{
break;
}
......
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