[Libreoffice-commits] .: Branch 'feature/fpicker-rework' - 4 commits - cui/source .gitignore sfx2/inc sfx2/source vcl/AllLangResTarget_vcl.mk vcl/inc vcl/source vcl/unx
Michael Meeks
michael at kemper.freedesktop.org
Fri Nov 4 15:32:54 PDT 2011
.gitignore | 17 ++
cui/source/options/optgdlg.cxx | 25 +---
sfx2/inc/sfx2/filedlghelper.hxx | 1
sfx2/source/dialog/filedlghelper.cxx | 10 -
vcl/AllLangResTarget_vcl.mk | 1
vcl/inc/salinst.hxx | 2
vcl/inc/svids.hrc | 19 +++
vcl/inc/unx/gtk/gtkinst.hxx | 2
vcl/inc/vcl/svapp.hxx | 4
vcl/source/app/svapp.cxx | 6 +
vcl/source/src/fpicker.src | 92 ++++++++++++++++
vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 78 +++++++------
vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx | 1
vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx | 15 --
vcl/unx/gtk/fpicker/SalGtkPicker.cxx | 8 -
vcl/unx/gtk/fpicker/resourceprovider.cxx | 165 ++++++-----------------------
16 files changed, 238 insertions(+), 208 deletions(-)
New commits:
commit 5e5ef2f7578808250c0dcf180de4b8ef95bb0c8e
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Nov 4 22:32:52 2011 +0000
gtk3: port file-picker, using more standard combobox APIs etc.
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index 7ffcb69..fb88175 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -59,8 +59,6 @@
#include "gtk/fpicker/resourceprovider.hxx"
#include "gtk/fpicker/SalGtkFilePicker.hxx"
-#if !GTK_CHECK_VERSION(3,0,0)
-
//------------------------------------------------------------------------
// namespace directives
//------------------------------------------------------------------------
@@ -211,7 +209,14 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
m_pAligns[i] = gtk_alignment_new(0, 0, 0, 1);
- m_pLists[i] = gtk_combo_box_new_text();
+ m_pListStores[i] = gtk_list_store_new (1, G_TYPE_STRING);
+ m_pLists[i] = gtk_combo_box_new_with_model(GTK_TREE_MODEL(m_pListStores[i]));
+ g_object_unref (m_pListStores[i]); // owned by the widget.
+ GtkCellRenderer *pCell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start(
+ GTK_CELL_LAYOUT(m_pLists[i]), pCell, TRUE);
+ gtk_cell_layout_set_attributes(
+ GTK_CELL_LAYOUT (m_pLists[i]), pCell, "text", 0, NULL);
m_pListLabels[i] = gtk_label_new( "" );
@@ -497,8 +502,16 @@ dialog_remove_buttons( GtkDialog *pDialog )
{
g_return_if_fail( GTK_IS_DIALOG( pDialog ) );
+ GtkWidget *pActionArea;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ pActionArea = gtk_dialog_get_action_area( pDialog );
+#else
+ pActionArea = pDialog->action_area;
+#endif
+
GList *pChildren =
- gtk_container_get_children( GTK_CONTAINER( pDialog->action_area ) );
+ gtk_container_get_children( GTK_CONTAINER( pActionArea ) );
for( GList *p = pChildren; p; p = p->next )
gtk_widget_destroy( GTK_WIDGET( p->data ) );
@@ -1136,14 +1149,20 @@ GtkWidget *SalGtkFilePicker::getWidget( sal_Int16 nControlId, GType *pType )
//------------------------------------------------------------------------------------
// XFilePickerControlAccess functions
//------------------------------------------------------------------------------------
-namespace
+static void HackWidthToFirst(GtkComboBox *pWidget)
{
- void HackWidthToFirst(GtkComboBox *pWidget)
- {
- GtkRequisition requisition;
- gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
- gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
- }
+ GtkRequisition requisition;
+ gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
+ gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
+}
+
+static void ComboBoxAppendText(GtkComboBox *pCombo, const rtl::OUString &rStr)
+{
+ GtkTreeIter aIter;
+ GtkListStore *pStore = GTK_LIST_STORE(gtk_combo_box_get_model(pCombo));
+ rtl::OString aStr = rtl::OUStringToOString(rStr, RTL_TEXTENCODING_UTF8);
+ gtk_list_store_append(pStore, &aIter);
+ gtk_list_store_set(pStore, &aIter, 0, aStr.getStr(), -1);
}
void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction, const uno::Any& rValue)
@@ -1154,7 +1173,7 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
{
OUString sItem;
rValue >>= sItem;
- gtk_combo_box_append_text(pWidget, rtl::OUStringToOString(sItem, RTL_TEXTENCODING_UTF8).getStr());
+ ComboBoxAppendText(pWidget, sItem);
if (!bVersionWidthUnset)
{
HackWidthToFirst(pWidget);
@@ -1169,8 +1188,7 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
sal_Int32 nItemCount = aStringList.getLength();
for (sal_Int32 i = 0; i < nItemCount; ++i)
{
- gtk_combo_box_append_text(pWidget,
- rtl::OUStringToOString(aStringList[i], RTL_TEXTENCODING_UTF8).getStr());
+ ComboBoxAppendText(pWidget,aStringList[i]);
if (!bVersionWidthUnset)
{
HackWidthToFirst(pWidget);
@@ -1183,22 +1201,20 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
{
sal_Int32 nPos=0;
rValue >>= nPos;
- gtk_combo_box_remove_text(pWidget, nPos);
+
+ GtkTreeIter aIter;
+ GtkListStore *pStore = GTK_LIST_STORE(
+ gtk_combo_box_get_model(GTK_COMBO_BOX(pWidget)));
+ if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pStore), &aIter, NULL, nPos))
+ gtk_list_store_remove(pStore, &aIter);
}
break;
case ControlActions::DELETE_ITEMS:
{
gtk_combo_box_set_active(pWidget, -1);
- gint nItems = 0;
- do
- {
- nItems =
- gtk_tree_model_iter_n_children(
- gtk_combo_box_get_model(pWidget), NULL);
- for (gint nI = 0; nI < nItems; ++nI)
- gtk_combo_box_remove_text(pWidget, nI);
- }
- while (nItems);
+ GtkListStore *pStore = GTK_LIST_STORE(
+ gtk_combo_box_get_model(GTK_COMBO_BOX(pWidget)));
+ gtk_list_store_clear(pStore);
}
break;
case ControlActions::SET_SELECT_ITEM:
@@ -1587,7 +1603,7 @@ sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( u
}
// also emit the signal
- g_signal_emit_by_name( GTK_OBJECT( m_pDialog ), "update-preview" );
+ g_signal_emit_by_name( G_OBJECT( m_pDialog ), "update-preview" );
mbPreviewState = bShowState;
}
@@ -2018,23 +2034,15 @@ SalGtkFilePicker::~SalGtkFilePicker()
gtk_widget_destroy( m_pVBox );
}
-#endif
-
using namespace ::com::sun::star;
uno::Reference< ui::dialogs::XFilePicker2 >
GtkInstance::createFilePicker( const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext > &xMSF )
{
-#if GTK_CHECK_VERSION(3,0,0)
- fprintf( stderr, "Create dummy gtk file picker\n" );
- (void)xMSF;
- return uno::Reference< ui::dialogs::XFilePicker2 >();
-#else
fprintf( stderr, "Create gtk file picker\n" );
return uno::Reference< ui::dialogs::XFilePicker2 >(
new SalGtkFilePicker( xMSF ) );
-#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
index aadff65..8d39e42 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
@@ -280,6 +280,7 @@ class SalGtkFilePicker :
GtkWidget *m_pHBoxs[ LIST_LAST ];
GtkWidget *m_pAligns[ LIST_LAST ];
GtkWidget *m_pLists[ LIST_LAST ];
+ GtkListStore *m_pListStores[ LIST_LAST ];
GtkWidget *m_pListLabels[ LIST_LAST ];
bool mbListVisibility[ LIST_LAST ];
bool mbButtonVisibility[ BUTTON_LAST ];
diff --git a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
index 07b6bb2..f4e2476 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
@@ -50,19 +50,12 @@
#include <string.h>
-
-//------------------------------------------------------------------------
-// namespace directives
-//------------------------------------------------------------------------
-
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
-#if !GTK_CHECK_VERSION(3,0,0)
-
//-----------------------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------------------
@@ -133,8 +126,6 @@ void SAL_CALL SalGtkFolderPicker::setDescription( const rtl::OUString& rDescript
::rtl::OString aDescription = OUStringToOString( rDescription, RTL_TEXTENCODING_UTF8 );
}
-
-
//-----------------------------------------------------------------------------------------
// XExecutableDialog functions
//-----------------------------------------------------------------------------------------
@@ -186,7 +177,6 @@ sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException )
return retVal;
}
-
//------------------------------------------------------------------------------------
// XCancellable
//------------------------------------------------------------------------------------
@@ -199,19 +189,13 @@ void SAL_CALL SalGtkFolderPicker::cancel() throw( uno::RuntimeException )
// TODO m_pImpl->cancel();
}
-#endif
uno::Reference< ui::dialogs::XFolderPicker >
GtkInstance::createFolderPicker( const uno::Reference< uno::XComponentContext > &xMSF )
{
fprintf( stderr, "Create gtk folder picker\n" );
-#if GTK_CHECK_VERSION(3,0,0)
- (void)xMSF;
- return uno::Reference< ui::dialogs::XFolderPicker >();
-#else
return uno::Reference< ui::dialogs::XFolderPicker >(
new SalGtkFolderPicker( xMSF ) );
-#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
index 0520f2a..7146b99 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
@@ -66,8 +66,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
-#if !GTK_CHECK_VERSION(3,0,0)
-
rtl::OUString SalGtkPicker::uritounicode(const gchar* pIn)
{
if (!pIn)
@@ -92,7 +90,7 @@ rtl::OUString SalGtkPicker::uritounicode(const gchar* pIn)
}
else
{
- OUString aNewURL = Reference<uri::XExternalUriReferenceTranslator>(Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext), UNO_QUERY_THROW)->translateToInternal(sURL);
+ OUString aNewURL = uno::Reference<uri::XExternalUriReferenceTranslator>(uno::Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext), UNO_QUERY_THROW)->translateToInternal(sURL);
if( aNewURL.getLength() )
sURL = aNewURL;
}
@@ -108,7 +106,7 @@ rtl::OString SalGtkPicker::unicodetouri(const rtl::OUString &rURL)
INetURLObject aURL(rURL);
if (INET_PROT_FILE == aURL.GetProtocol())
{
- OUString aNewURL = Reference<uri::XExternalUriReferenceTranslator>(Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext ), UNO_QUERY_THROW)->translateToExternal( rURL );
+ OUString aNewURL = uno::Reference<uri::XExternalUriReferenceTranslator>(uno::Reference<XMultiComponentFactory>(comphelper::getProcessServiceFactory(), UNO_QUERY_THROW)->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uri.ExternalUriReferenceTranslator")), m_xContext ), UNO_QUERY_THROW)->translateToExternal( rURL );
if( aNewURL.getLength() )
{
@@ -290,6 +288,4 @@ uno::Reference< uno::XInterface > SalGtkPicker::createInstance( const rtl::OUStr
return m_xContext->getServiceManager()->createInstanceWithContext( rName, m_xContext );
}
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 417396edb7d5c867803d9093a6068f0850482492
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Nov 4 21:49:28 2011 +0000
move required resources down from fpicker & svtools into vcl
diff --git a/vcl/AllLangResTarget_vcl.mk b/vcl/AllLangResTarget_vcl.mk
index b84b9aa..7534c26 100644
--- a/vcl/AllLangResTarget_vcl.mk
+++ b/vcl/AllLangResTarget_vcl.mk
@@ -49,6 +49,7 @@ $(eval $(call gb_SrsTarget_add_files,vcl/source/src,\
vcl/source/src/print.src \
vcl/source/src/stdtext.src \
vcl/source/src/units.src \
+ vcl/source/src/fpicker.src \
))
diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc
index bc76c70..dc16ab1 100644
--- a/vcl/inc/svids.hrc
+++ b/vcl/inc/svids.hrc
@@ -195,6 +195,25 @@
#define SV_STDTEXT_ALLFILETYPES 10207
#define SV_STDTEXT_LAST SV_STDTEXT_ALLFILETYPES
+#define STR_FPICKER_AUTO_EXTENSION 10300
+#define STR_FPICKER_PASSWORD 10301
+#define STR_FPICKER_FILTER_OPTIONS 10302
+#define STR_FPICKER_READONLY 10303
+#define STR_FPICKER_INSERT_AS_LINK 10304
+#define STR_FPICKER_SHOW_PREVIEW 10305
+#define STR_FPICKER_PLAY 10306
+#define STR_FPICKER_VERSION 10307
+#define STR_FPICKER_TEMPLATES 10308
+#define STR_FPICKER_IMAGE_TEMPLATE 10309
+#define STR_FPICKER_SELECTION 10310
+#define STR_FPICKER_FOLDER_DEFAULT_TITLE 10311
+#define STR_FPICKER_FOLDER_DEFAULT_DESCRIPTION 10312
+#define STR_FPICKER_ALREADYEXISTOVERWRITE 10313
+#define STR_FPICKER_ALLFORMATS 10314
+#define STR_FPICKER_OPEN 10315
+#define STR_FPICKER_SAVE 10316
+#define STR_FPICKER_TYPE 10317
+
#define SV_ACCESSERROR_FIRST SV_ACCESSERROR_WRONG_VERSION
#define SV_ACCESSERROR_WRONG_VERSION 10500
#define SV_ACCESSERROR_BRIDGE_MSG 10501
diff --git a/vcl/source/src/fpicker.src b/vcl/source/src/fpicker.src
new file mode 100644
index 0000000..ce66044
--- /dev/null
+++ b/vcl/source/src/fpicker.src
@@ -0,0 +1,92 @@
+#include <svids.hrc>
+
+String STR_FPICKER_AUTO_EXTENSION
+{
+ Text [ en-US ] = "~Automatic file name extension" ;
+};
+
+String STR_FPICKER_PASSWORD
+{
+ Text [ en-US ] = "Save with pass~word" ;
+};
+
+String STR_FPICKER_FILTER_OPTIONS
+{
+ Text [ en-US ] = "~Edit filter settings";
+};
+
+String STR_FPICKER_READONLY
+{
+ Text [ en-US ] = "~Read-only" ;
+};
+
+String STR_FPICKER_INSERT_AS_LINK
+{
+ Text [ en-US ] = "~Link" ;
+};
+
+String STR_FPICKER_SHOW_PREVIEW
+{
+ Text [ en-US ] = "Pr~eview" ;
+};
+
+String STR_FPICKER_PLAY
+{
+ Text [ en-US ] = "~Play" ;
+};
+
+String STR_FPICKER_VERSION
+{
+ Text [ en-US ] = "~Version:";
+};
+
+String STR_FPICKER_TEMPLATES
+{
+ Text [ en-US ] = "S~tyles:" ;
+};
+
+String STR_FPICKER_IMAGE_TEMPLATE
+{
+ Text [ en-US ] = "Style:";
+};
+
+String STR_FPICKER_SELECTION
+{
+ Text [ en-US ] = "~Selection" ;
+};
+
+String STR_FPICKER_FOLDER_DEFAULT_TITLE
+{
+ Text [ en-US ] = "Select Path" ;
+};
+
+String STR_FPICKER_FOLDER_DEFAULT_DESCRIPTION
+{
+ Text [ en-US ] = "Please select a folder.";
+};
+
+String STR_FPICKER_ALREADYEXISTOVERWRITE
+{
+ Text [ en-US ] = "A file named \"$filename$\" already exists.\n\nDo you want to replace it?" ;
+};
+
+String STR_FPICKER_ALLFORMATS
+{
+ Text [ en-US ] = "All Formats" ;
+};
+
+String STR_FPICKER_OPEN
+{
+ Text [ en-US ] = "Open" ;
+};
+
+String STR_FPICKER_SAVE
+{
+ Text [ en-US ] = "Save" ;
+};
+
+String STR_FPICKER_TYPE
+{
+ Text [ en-US ] = "File ~type" ;
+};
+
diff --git a/vcl/unx/gtk/fpicker/resourceprovider.cxx b/vcl/unx/gtk/fpicker/resourceprovider.cxx
index 70a3e68..5d19d78 100644
--- a/vcl/unx/gtk/fpicker/resourceprovider.cxx
+++ b/vcl/unx/gtk/fpicker/resourceprovider.cxx
@@ -26,199 +26,104 @@
*
************************************************************************/
-//------------------------------------------------------------------------
-// includes
-//------------------------------------------------------------------------
#include <osl/diagnose.h>
-#include <rtl/ustrbuf.hxx>
#include "resourceprovider.hxx"
-#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <tools/resmgr.hxx>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
-#include <svtools/svtools.hrc>
-#include <svtools/filedlg2.hrc>
+#include "svids.hrc"
+#include "svdata.hxx"
-//------------------------------------------------------------
-// namespace directives
-//------------------------------------------------------------
-
-using rtl::OUString;
using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
-static const char* RES_NAME = "fps_office";
-static const char* OTHER_RES_NAME = "svt";
-
-//------------------------------------------------------------
-// we have to translate control ids to resource ids
-//------------------------------------------------------------
-
-struct _Entry
+//---------------------------------------
+// translate control ids to resource ids
+//---------------------------------------
+static const struct
{
sal_Int32 ctrlId;
sal_Int16 resId;
+} CtrlIdToResIdTable[] = {
+ { CHECKBOX_AUTOEXTENSION, STR_FPICKER_AUTO_EXTENSION },
+ { CHECKBOX_PASSWORD, STR_FPICKER_PASSWORD },
+ { CHECKBOX_FILTEROPTIONS, STR_FPICKER_FILTER_OPTIONS },
+ { CHECKBOX_READONLY, STR_FPICKER_READONLY },
+ { CHECKBOX_LINK, STR_FPICKER_INSERT_AS_LINK },
+ { CHECKBOX_PREVIEW, STR_FPICKER_SHOW_PREVIEW },
+ { PUSHBUTTON_PLAY, STR_FPICKER_PLAY },
+ { LISTBOX_VERSION_LABEL, STR_FPICKER_VERSION },
+ { LISTBOX_TEMPLATE_LABEL, STR_FPICKER_TEMPLATES },
+ { LISTBOX_IMAGE_TEMPLATE_LABEL, STR_FPICKER_IMAGE_TEMPLATE },
+ { CHECKBOX_SELECTION, STR_FPICKER_SELECTION },
+ { FOLDERPICKER_TITLE, STR_FPICKER_FOLDER_DEFAULT_TITLE },
+ { FOLDER_PICKER_DEF_DESCRIPTION, STR_FPICKER_FOLDER_DEFAULT_DESCRIPTION },
+ { FILE_PICKER_OVERWRITE, STR_FPICKER_ALREADYEXISTOVERWRITE },
+ { FILE_PICKER_ALLFORMATS, STR_FPICKER_ALLFORMATS },
+ { FILE_PICKER_TITLE_OPEN, STR_FPICKER_OPEN },
+ { FILE_PICKER_TITLE_SAVE, STR_FPICKER_SAVE },
+ { FILE_PICKER_FILE_TYPE, STR_FPICKER_TYPE }
};
-_Entry CtrlIdToResIdTable[] = {
- { CHECKBOX_AUTOEXTENSION, STR_SVT_FILEPICKER_AUTO_EXTENSION },
- { CHECKBOX_PASSWORD, STR_SVT_FILEPICKER_PASSWORD },
- { CHECKBOX_FILTEROPTIONS, STR_SVT_FILEPICKER_FILTER_OPTIONS },
- { CHECKBOX_READONLY, STR_SVT_FILEPICKER_READONLY },
- { CHECKBOX_LINK, STR_SVT_FILEPICKER_INSERT_AS_LINK },
- { CHECKBOX_PREVIEW, STR_SVT_FILEPICKER_SHOW_PREVIEW },
- { PUSHBUTTON_PLAY, STR_SVT_FILEPICKER_PLAY },
- { LISTBOX_VERSION_LABEL, STR_SVT_FILEPICKER_VERSION },
- { LISTBOX_TEMPLATE_LABEL, STR_SVT_FILEPICKER_TEMPLATES },
- { LISTBOX_IMAGE_TEMPLATE_LABEL, STR_SVT_FILEPICKER_IMAGE_TEMPLATE },
- { CHECKBOX_SELECTION, STR_SVT_FILEPICKER_SELECTION },
- { FOLDERPICKER_TITLE, STR_SVT_FOLDERPICKER_DEFAULT_TITLE },
- { FOLDER_PICKER_DEF_DESCRIPTION, STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION },
- { FILE_PICKER_OVERWRITE, STR_SVT_ALREADYEXISTOVERWRITE },
- { FILE_PICKER_ALLFORMATS, STR_SVT_ALLFORMATS }
-};
-
-_Entry OtherCtrlIdToResIdTable[] = {
- { FILE_PICKER_TITLE_OPEN, STR_FILEDLG_OPEN },
- { FILE_PICKER_TITLE_SAVE, STR_FILEDLG_SAVE },
- { FILE_PICKER_FILE_TYPE, STR_FILEDLG_TYPE },
-};
-
-
-const sal_Int32 SIZE_TABLE = SAL_N_ELEMENTS( CtrlIdToResIdTable );
-const sal_Int32 OTHER_SIZE_TABLE = SAL_N_ELEMENTS( OtherCtrlIdToResIdTable );
-
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
-sal_Int16 CtrlIdToResId( sal_Int32 aControlId )
+static sal_Int16 CtrlIdToResId( sal_Int32 aControlId )
{
- sal_Int16 aResId = -1;
-
- for ( sal_Int32 i = 0; i < SIZE_TABLE; i++ )
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( CtrlIdToResIdTable ); i++ )
{
if ( CtrlIdToResIdTable[i].ctrlId == aControlId )
- {
- aResId = CtrlIdToResIdTable[i].resId;
- break;
- }
+ return CtrlIdToResIdTable[i].resId;
}
-
- return aResId;
+ return -1;
}
-sal_Int16 OtherCtrlIdToResId( sal_Int32 aControlId )
-{
- sal_Int16 aResId = -1;
-
- for ( sal_Int32 i = 0; i < OTHER_SIZE_TABLE; i++ )
- {
- if ( OtherCtrlIdToResIdTable[i].ctrlId == aControlId )
- {
- aResId = OtherCtrlIdToResIdTable[i].resId;
- break;
- }
- }
-
- return aResId;
-}
-
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
class CResourceProvider_Impl
{
public:
-
- //-------------------------------------
- //
- //-------------------------------------
-
CResourceProvider_Impl( )
{
- m_ResMgr = ResMgr::CreateResMgr( RES_NAME );
- m_OtherResMgr = ResMgr::CreateResMgr( OTHER_RES_NAME );
+ m_ResMgr = ImplGetResMgr();
}
- //-------------------------------------
- //
- //-------------------------------------
-
~CResourceProvider_Impl( )
{
delete m_ResMgr;
- delete m_OtherResMgr;
}
- //-------------------------------------
- //
- //-------------------------------------
-
- OUString getResString( sal_Int16 aId )
+ rtl::OUString getResString( sal_Int16 aId )
{
- String aResString;
- OUString aResOUString;
+ OSL_ASSERT( m_ResMgr );
+ String aResString;
try
{
- OSL_ASSERT( m_ResMgr && m_OtherResMgr );
-
// translate the control id to a resource id
sal_Int16 aResId = CtrlIdToResId( aId );
if ( aResId > -1 )
aResString = String( ResId( aResId, *m_ResMgr ) );
- else
- {
- aResId = OtherCtrlIdToResId( aId );
- if ( aResId > -1 )
- aResString = String( ResId( aResId, *m_OtherResMgr ) );
- }
- if ( aResId > -1 )
- aResOUString = OUString( aResString );
}
catch(...)
{
}
- return aResOUString;
+ return rtl::OUString( aResString );
}
public:
ResMgr* m_ResMgr;
- ResMgr* m_OtherResMgr;
};
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
CResourceProvider::CResourceProvider( ) :
m_pImpl( new CResourceProvider_Impl() )
{
}
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
CResourceProvider::~CResourceProvider( )
{
delete m_pImpl;
}
-//------------------------------------------------------------
-//
-//------------------------------------------------------------
-
-OUString CResourceProvider::getResString( sal_Int32 aId )
+rtl::OUString CResourceProvider::getResString( sal_Int32 aId )
{
return m_pImpl->getResString( aId ).replace('~', '_');
}
commit def692d3ad2788f9632a51d2b908bb3c3ffce4c9
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Nov 4 21:10:42 2011 +0000
hush more kinds of file types
diff --git a/.gitignore b/.gitignore
index e102c36..a97b2d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# backup and temporary files
*~
.*.sw[op]
+\#*
# python generated file
*.pyc
@@ -58,6 +59,14 @@
/bin/repo-list
/src.downloaded
/ooo.lst
+/intltool-extract.in
+/intltool-merge.in
+/intltool-update.in
+/NEWS
+/TODO
+/README
+/AUTHORS
+/MAINTAINERS
# misc
/file-lists
@@ -76,6 +85,7 @@
/tags
/docs
/autogen.save
+TAGS
/*/*.exe
@@ -106,5 +116,10 @@ test/user-template/user/psprint/pspfontcache
# libxslt debug memdump
.memdump
-#LibreOffice lock files
+# LibreOffice lock files
.~lock.*#
+
+# Everyone loves patching
+*.patch
+*.orig
+*.rej
commit 74479c90a4408385836b06747a441d984ec1b62c
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Nov 4 21:04:18 2011 +0000
gtk: cleanup to make the vcl file-picker interface work.
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index e08dcc7..72355b7 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -124,20 +124,11 @@ int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
namespace
{
- ::rtl::OUString impl_SystemFileOpenServiceName()
+ static ::rtl::OUString impl_SystemFileOpenServiceName()
{
- const ::rtl::OUString &rDesktopEnvironment =
- Application::GetDesktopEnvironment();
+ const ::rtl::OUString &rDesktopEnvironment = Application::GetDesktopEnvironment();
- if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) )
- {
- #ifdef ENABLE_GTK
- return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.GtkFilePicker") );
- #else
- return rtl::OUString();
- #endif
- }
- else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
+ if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
{
#ifdef ENABLE_KDE4
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.KDE4FilePicker") );
@@ -162,10 +153,14 @@ namespace
#endif
}
- sal_Bool lcl_HasSystemFilePicker()
+ static bool lcl_HasSystemFilePicker()
{
+ if( Application::hasNativeFileSelection() )
+ return true;
+
+ // Otherwise fall-back on querying services
+ bool bRet = false;
Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- sal_Bool bRet = sal_False;
Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
Reference< XSet > xSet( xFactory, UNO_QUERY );
@@ -178,7 +173,7 @@ namespace
::rtl::OUString aFileService = impl_SystemFileOpenServiceName();
Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
if ( xEnum.is() && xEnum->hasMoreElements() )
- bRet = sal_True;
+ bRet = true;
}
catch (const IllegalArgumentException&)
{
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx
index 291897d..2157590 100644
--- a/sfx2/inc/sfx2/filedlghelper.hxx
+++ b/sfx2/inc/sfx2/filedlghelper.hxx
@@ -99,7 +99,6 @@ class Window;
#define FILE_OPEN_SERVICE_NAME "com.sun.star.ui.dialogs.FilePicker"
#define FOLDER_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.FolderPicker"
-#define FILE_OPEN_SERVICE_NAME_SYSTEM "com.sun.star.ui.dialogs.SystemFilePicker"
#define FILE_OPEN_SERVICE_NAME_OOO "com.sun.star.ui.dialogs.OfficeFilePicker"
//-----------------------------------------------------------------------------
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 35b2f62..aac467d 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -841,21 +841,21 @@ ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const
}
// ------------------------------------------------------------------------
-sal_Bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker >& _rxFP )
+static bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker >& _rxFP )
{
try
{
uno::Reference< XServiceInfo > xSI( _rxFP, UNO_QUERY );
- if ( xSI.is() && xSI->supportsService( DEFINE_CONST_OUSTRING( "com.sun.star.ui.dialogs.SystemFilePicker" ) ) )
- return sal_True;
+ if ( !xSI.is() )
+ return true;
+ return xSI->supportsService( DEFINE_CONST_OUSTRING( "com.sun.star.ui.dialogs.SystemFilePicker" ) );
}
catch( const Exception& )
{
}
- return sal_False;
+ return false;
}
-
// ------------------------------------------------------------------------
// ----------- FileDialogHelper_Impl ---------------------------
// ------------------------------------------------------------------------
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index e503fb4..67affdb 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -170,6 +170,8 @@ public:
virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDropTarget();
virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType) = 0;
+ virtual bool hasNativeFileSelection() const { return false; }
+
virtual com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 >
createFilePicker( const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext >& )
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 55a1879..8b937a3 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -109,6 +109,8 @@ public:
virtual GenPspGraphics *CreatePrintGraphics();
+ virtual bool hasNativeFileSelection() const { return true; }
+
virtual com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 >
createFilePicker( const com::sun::star::uno::Reference<
com::sun::star::uno::XComponentContext >& );
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index 951f817..07782df 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -373,6 +373,10 @@ public:
*/
static void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
+ /** Do we have a native / system file selector available ?
+ */
+ static bool hasNativeFileSelection();
+
/** Create a platform specific file picker, if one is available,
otherwise return an empty reference
*/
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index e144851..e23192c 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1895,6 +1895,12 @@ void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
{
}
+bool Application::hasNativeFileSelection()
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ return pSVData->mpDefInst->hasNativeFileSelection();
+}
+
Reference< ui::dialogs::XFilePicker2 >
Application::createFilePicker( const Reference< uno::XComponentContext >& xSM )
{
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index b7caa0a..7ffcb69 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -972,7 +972,7 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException )
UNO_QUERY_THROW );
uno::Reference< frame::XDesktop > xDesktop(
- createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.Toolkit")) ),
+ createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
UNO_QUERY_THROW );
RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop);
diff --git a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
index 923a7fe..07b6bb2 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFolderPicker.cxx
@@ -206,6 +206,7 @@ GtkInstance::createFolderPicker( const uno::Reference< uno::XComponentContext >
{
fprintf( stderr, "Create gtk folder picker\n" );
#if GTK_CHECK_VERSION(3,0,0)
+ (void)xMSF;
return uno::Reference< ui::dialogs::XFolderPicker >();
#else
return uno::Reference< ui::dialogs::XFolderPicker >(
More information about the Libreoffice-commits
mailing list