summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2017-03-16 18:09:20 +0100
committerMichael Stahl <mstahl@redhat.com>2017-04-18 16:24:37 +0200
commite2d3e936ab03274696f235c9d74e247380070f6f (patch)
tree2737c6251ab44f4b5c772429b7d42a3414d9fb89
parentf3ab7e1403f60ad4f9137e68241e68aa06b2fb1e (diff)
tdf#95992 "Edit" > "Compare Document..." opens dialog that is...
misnamed "Insert" Issue is that the caption of the dialog is handled by generic code, which was not designed with comparison in mind. This fix extends the captions that can be used by such generic codes, without modifying the underlaying architecture. Letting callers directly provide caption text might be more versatile, though. The fix is extended to: * Writer Merge functionality * Calc Compare/Merge functionalities which use the same dialog (and thus were also displaying "Insert"). Change-Id: I452b37bf7d0024924c87316cd47572c09b373b65 Reviewed-on: https://gerrit.libreoffice.org/35285 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--include/sfx2/docinsert.hxx9
-rw-r--r--include/sfx2/filedlghelper.hxx6
-rw-r--r--sc/source/ui/docshell/docsh4.cxx5
-rw-r--r--sfx2/inc/filedlghelper.hrc2
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx17
-rw-r--r--sfx2/source/dialog/filedlghelper.src10
-rw-r--r--sfx2/source/doc/docinsert.cxx32
-rw-r--r--starmath/source/view.cxx2
-rw-r--r--sw/source/uibase/inc/uivwimp.hxx6
-rw-r--r--sw/source/uibase/uiview/uivwimp.cxx21
-rw-r--r--sw/source/uibase/uiview/view2.cxx3
-rw-r--r--sw/source/uibase/utlui/glbltree.cxx2
12 files changed, 98 insertions, 17 deletions
diff --git a/include/sfx2/docinsert.hxx b/include/sfx2/docinsert.hxx
index 4f47a79bd896..13f210de5b7f 100644
--- a/include/sfx2/docinsert.hxx
+++ b/include/sfx2/docinsert.hxx
@@ -53,8 +53,13 @@ private:
DECL_LINK(DialogClosedHdl, sfx2::FileDialogHelper*, void);
public:
- DocumentInserter(const OUString& rFactory,
- bool const bEnableMultiSelection = false);
+ enum class Mode {
+ Insert,
+ InsertMulti,
+ Compare,
+ Merge
+ };
+ DocumentInserter(const OUString& rFactory, const Mode mode = Mode::Insert);
~DocumentInserter();
void StartExecuteModal( const Link<sfx2::FileDialogHelper*,void>& _rDialogClosedLink );
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index 28159ec0cb45..f2f8ed6356d3 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -67,10 +67,12 @@ enum class FileDialogFlags {
MultiSelection = 0x08,
Graphic = 0x10, // register graphic formats
/// Sign existing PDF.
- SignPDF = 0x20
+ SignPDF = 0x20,
+ InsertCompare = 0x40, /// Special insertion ("Compare" caption)
+ InsertMerge = 0x80, /// Special insertion ("Merge" caption)
};
namespace o3tl {
- template<> struct typed_flags<FileDialogFlags> : is_typed_flags<FileDialogFlags, 0x3f> {};
+ template<> struct typed_flags<FileDialogFlags> : is_typed_flags<FileDialogFlags, 0xFF> {};
}
#define FILEDIALOG_FILTER_ALL "*.*"
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 5e986635b820..135034c784e7 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -722,13 +722,16 @@ void ScDocShell::Execute( SfxRequest& rReq )
}
else
{
+ const sfx2::DocumentInserter::Mode mode { nSlot==SID_DOCUMENT_COMPARE
+ ? sfx2::DocumentInserter::Mode::Compare
+ : sfx2::DocumentInserter::Mode::Merge};
// start file dialog asynchronous
pImpl->bIgnoreLostRedliningWarning = true;
delete pImpl->pRequest;
pImpl->pRequest = new SfxRequest( rReq );
delete pImpl->pDocInserter;
pImpl->pDocInserter = new ::sfx2::DocumentInserter(
- ScDocShell::Factory().GetFactoryName(), false );
+ ScDocShell::Factory().GetFactoryName(), mode );
pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) );
return ;
}
diff --git a/sfx2/inc/filedlghelper.hrc b/sfx2/inc/filedlghelper.hrc
index e63c9955b282..86cf4d56eecd 100644
--- a/sfx2/inc/filedlghelper.hrc
+++ b/sfx2/inc/filedlghelper.hrc
@@ -23,6 +23,8 @@
#include <sfx2/sfx.hrc>
#define STR_PB_SAVEACOPY (RID_SFX_EXPLORER_START + 65)
+#define STR_PB_COMPAREDOC (RID_SFX_EXPLORER_START + 66)
+#define STR_PB_MERGEDOC (RID_SFX_EXPLORER_START + 67)
#endif
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 75f6c16ca182..5782802cf201 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -887,7 +887,9 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
mbHasPreview = false;
mbShowPreview = false;
mbDeleteMatcher = false;
- mbInsert = bool(nFlags & FileDialogFlags::Insert);
+ mbInsert = bool(nFlags & (FileDialogFlags::Insert|
+ FileDialogFlags::InsertCompare|
+ FileDialogFlags::InsertMerge));
mbExport = bool(nFlags & FileDialogFlags::Export);
mbIsSaveDlg = false;
mbPwdCheckBoxState = false;
@@ -1106,7 +1108,18 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
// the "insert file" dialog needs another title
if ( mbInsert )
{
- mxFileDlg->setTitle( SfxResId( STR_SFX_EXPLORERFILE_INSERT ).toString() );
+ if ( nFlags & FileDialogFlags::InsertCompare )
+ {
+ mxFileDlg->setTitle( SfxResId( STR_PB_COMPAREDOC ).toString() );
+ }
+ else if ( nFlags & FileDialogFlags::InsertMerge )
+ {
+ mxFileDlg->setTitle( SfxResId( STR_PB_MERGEDOC ).toString() );
+ }
+ else
+ {
+ mxFileDlg->setTitle( SfxResId( STR_SFX_EXPLORERFILE_INSERT ).toString() );
+ }
uno::Reference < XFilePickerControlAccess > xExtDlg( mxFileDlg, UNO_QUERY );
if ( xExtDlg.is() )
{
diff --git a/sfx2/source/dialog/filedlghelper.src b/sfx2/source/dialog/filedlghelper.src
index a8bb9888600b..1e777e20353a 100644
--- a/sfx2/source/dialog/filedlghelper.src
+++ b/sfx2/source/dialog/filedlghelper.src
@@ -50,6 +50,16 @@ String STR_PB_SAVEACOPY
Text [ en-US ] = "Save a Copy" ;
};
+String STR_PB_COMPAREDOC
+{
+ Text [ en-US ] = "Compare to" ;
+};
+
+String STR_PB_MERGEDOC
+{
+ Text [ en-US ] = "Merge with" ;
+};
+
//******************************************************************** EOF
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx
index 6288d5ce765c..29cd9ee68808 100644
--- a/sfx2/source/doc/docinsert.cxx
+++ b/sfx2/source/doc/docinsert.cxx
@@ -46,15 +46,39 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno;
+namespace
+{
+
+FileDialogFlags lcl_map_mode_to_flags(const sfx2::DocumentInserter::Mode mode)
+{
+ FileDialogFlags f {FileDialogFlags::NONE};
+ switch (mode)
+ {
+ case sfx2::DocumentInserter::Mode::Insert:
+ f = FileDialogFlags::Insert;
+ break;
+ case sfx2::DocumentInserter::Mode::InsertMulti:
+ f = FileDialogFlags::Insert|FileDialogFlags::MultiSelection;
+ break;
+ case sfx2::DocumentInserter::Mode::Compare:
+ f = FileDialogFlags::InsertCompare;
+ break;
+ case sfx2::DocumentInserter::Mode::Merge:
+ f = FileDialogFlags::InsertMerge;
+ break;
+ }
+ return f;
+}
+
+}
+
namespace sfx2 {
DocumentInserter::DocumentInserter(
- const OUString& rFactory, bool const bEnableMultiSelection) :
+ const OUString& rFactory, const Mode mode) :
m_sDocFactory ( rFactory )
- , m_nDlgFlags ( (bEnableMultiSelection)
- ? (FileDialogFlags::Insert|FileDialogFlags::MultiSelection)
- : FileDialogFlags::Insert )
+ , m_nDlgFlags ( lcl_map_mode_to_flags(mode) )
, m_nError ( ERRCODE_NONE )
, m_pFileDlg ( nullptr )
, m_pItemSet ( nullptr )
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 50a1a5f7b616..82c1082e38ea 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -1597,7 +1597,7 @@ void SmViewShell::Execute(SfxRequest& rReq)
{
mpImpl->pRequest.reset(new SfxRequest( rReq ));
mpImpl->pDocInserter.reset(new ::sfx2::DocumentInserter(
- GetDoc()->GetFactory().GetFactoryName(), false ));
+ GetDoc()->GetFactory().GetFactoryName()));
mpImpl->pDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) );
break;
}
diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx
index 68c3707be574..411e95e2e228 100644
--- a/sw/source/uibase/inc/uivwimp.hxx
+++ b/sw/source/uibase/inc/uivwimp.hxx
@@ -156,7 +156,11 @@ public:
return m_bEditingPositionSet;
}
- void StartDocumentInserter( const OUString& rFactory, const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl );
+ void StartDocumentInserter(
+ const OUString& rFactory,
+ const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl,
+ const sal_uInt16 nSlotId
+ );
SfxMedium* CreateMedium();
void InitRequest( const SfxRequest& rRequest );
diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index b1ff6e0794c6..6c7288e5521d 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -230,10 +230,27 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable)
rTransferable.m_refCount--;
}
-void SwView_Impl::StartDocumentInserter( const OUString& rFactory, const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl )
+void SwView_Impl::StartDocumentInserter(
+ const OUString& rFactory,
+ const Link<sfx2::FileDialogHelper*,void>& rEndDialogHdl,
+ const sal_uInt16 nSlotId
+)
{
+ sfx2::DocumentInserter::Mode mode {sfx2::DocumentInserter::Mode::Insert};
+ switch( nSlotId )
+ {
+ case SID_DOCUMENT_MERGE:
+ mode = sfx2::DocumentInserter::Mode::Merge;
+ break;
+ case SID_DOCUMENT_COMPARE:
+ mode = sfx2::DocumentInserter::Mode::Compare;
+ break;
+ default:
+ break;
+ }
+
delete m_pDocInserter;
- m_pDocInserter = new ::sfx2::DocumentInserter( rFactory );
+ m_pDocInserter = new ::sfx2::DocumentInserter( rFactory, mode );
m_pDocInserter->StartExecuteModal( rEndDialogHdl );
}
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index bfcad89a6729..63dd947d3da3 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -2116,7 +2116,8 @@ long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUS
{
m_pViewImpl->StartDocumentInserter(
pDocSh->GetFactory().GetFactoryName(),
- LINK( this, SwView, DialogClosedHdl )
+ LINK( this, SwView, DialogClosedHdl ),
+ nSlotId
);
return -1;
}
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index 74402e468e7f..0cbeb28bba74 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -706,7 +706,7 @@ void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const OUString*
if ( !pFileName )
{
delete pDocInserter;
- pDocInserter = new ::sfx2::DocumentInserter( "swriter", true );
+ pDocInserter = new ::sfx2::DocumentInserter( "swriter", sfx2::DocumentInserter::Mode::InsertMulti );
pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) );
}
else if ( !pFileName->isEmpty() )