incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1182539 - in /incubator/ooo/trunk/main: fpicker/source/office/ fpicker/source/unx/gnome/ svtools/inc/svtools/
Date Wed, 12 Oct 2011 19:23:38 GMT
Author: pfg
Date: Wed Oct 12 19:23:38 2011
New Revision: 1182539

URL: http://svn.apache.org/viewvc?rev=1182539&view=rev
Log:
i113141 - fpicker: gtk Save As dialog should show all appropriate formats by default

Modified:
    incubator/ooo/trunk/main/fpicker/source/office/iodlg.src
    incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
    incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.hxx
    incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.cxx
    incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.hxx
    incubator/ooo/trunk/main/svtools/inc/svtools/svtools.hrc

Modified: incubator/ooo/trunk/main/fpicker/source/office/iodlg.src
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/fpicker/source/office/iodlg.src?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/fpicker/source/office/iodlg.src (original)
+++ incubator/ooo/trunk/main/fpicker/source/office/iodlg.src Wed Oct 12 19:23:38 2011
@@ -333,5 +333,10 @@ String STR_SVT_NOREMOVABLEDEVICE
     Text [ en-US ] = "No removable storage device detected.\nMake sure it is plugged in properly
and try again." ;
 };
 
+String STR_SVT_ALLFORMATS
+{
+	Text [ en-US ] = "All Formats" ;
+};
+
 //******************************************************************** EOF
 

Modified: incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx (original)
+++ incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx Wed Oct 12 19:23:38
2011
@@ -52,6 +52,7 @@
 
 #include <iostream>
 #include <algorithm>
+#include <set>
 #include "resourceprovider.hxx"
 #ifndef _SV_RC_H
 #include <tools/rc.hxx>
@@ -148,6 +149,7 @@ SalGtkFilePicker::SalGtkFilePicker( cons
     mbPreviewState( sal_False ),
     mHID_Preview( 0 ),
 	m_pPreview( NULL ),
+    m_pPseudoFilter( NULL ),
 	m_PreviewImageWidth( 256 ),
     m_PreviewImageHeight( 256 )
 {
@@ -657,7 +659,7 @@ void SalGtkFilePicker::ensureFilterList(
 		m_pFilterList = new FilterList;
 
 		// set the first filter to the current filter
-		if( ( !m_aCurrentFilter ) || ( !m_aCurrentFilter.getLength() ) )
+		if ( !m_aCurrentFilter.getLength() )
 			m_aCurrentFilter = _rInitialCurrentFilter;
 	}
 }
@@ -680,7 +682,6 @@ void SAL_CALL SalGtkFilePicker::appendFi
 
 	// append the filter
 	m_pFilterList->insert( m_pFilterList->end(), FilterEntry( aTitle, aFilter ) );
-	// implAddFilter( aTitle, aFilter );
 }
 
 //-----------------------------------------------------------------------------------------
@@ -747,7 +748,10 @@ void SalGtkFilePicker::UpdateFilterfromU
     }
     else if( GtkFileFilter *filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_pDialog)))
     {
-        updateCurrentFilterFromName(gtk_file_filter_get_name( filter ));
+		if (m_pPseudoFilter != filter)
+        	updateCurrentFilterFromName(gtk_file_filter_get_name( filter ));
+		else
+        	updateCurrentFilterFromName(OUStringToOString( m_aInitialFilter, RTL_TEXTENCODING_UTF8
).getStr());
     }
 }
 
@@ -924,9 +928,15 @@ uno::Sequence<rtl::OUString> SAL_CALL Sa
                     }
                 }
 
-			    const gchar* filtername = 
-				    gtk_file_filter_get_name( gtk_file_chooser_get_filter( GTK_FILE_CHOOSER( m_pDialog
) ) );
-                sFilterName = OUString( filtername, strlen( filtername ), RTL_TEXTENCODING_UTF8
);
+				GtkFileFilter *filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_pDialog));
+        		if (m_pPseudoFilter != filter)
+				{
+			    	const gchar* filtername = 
+				    	gtk_file_filter_get_name( filter );
+                	sFilterName = OUString( filtername, strlen( filtername ), RTL_TEXTENCODING_UTF8
);
+				}
+				else
+					sFilterName = m_aInitialFilter;
             }
 
 			OSL_TRACE( "2: current filter is %s\n", 
@@ -1891,7 +1901,7 @@ case_insensitive_filter (const GtkFileFi
 }
 }
 
-int SalGtkFilePicker::implAddFilter( const OUString& rFilter, const OUString& rType
)
+GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const OUString&
rType )
 {
     GdkThreadLock aLock;
 
@@ -1942,7 +1952,6 @@ int SalGtkFilePicker::implAddFilter( con
 
 	gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( m_pDialog ), filter );
 
-    int nAdded = 0;
     if (!bAllGlob)
     {
         GtkTreeIter iter;
@@ -1953,30 +1962,67 @@ int SalGtkFilePicker::implAddFilter( con
             2, aFilterName.getStr(),
             3, OUStringToOString(rType, RTL_TEXTENCODING_UTF8).getStr(),
             -1);
-        nAdded = 1;
     }
-    return nAdded;
+    return filter;
 }
 
-int SalGtkFilePicker::implAddFilterGroup( const OUString& /*_rFilter*/, const Sequence<
StringPair >& _rFilters )
+void SalGtkFilePicker::implAddFilterGroup( const OUString& /*_rFilter*/, const Sequence<
StringPair >& _rFilters )
 {
 	// Gtk+ has no filter group concept I think so ...
 	// implAddFilter( _rFilter, String() );
-    int nAdded = 0;
 	const StringPair* pSubFilters	= _rFilters.getConstArray();
 	const StringPair* pSubFiltersEnd = pSubFilters + _rFilters.getLength();
 	for( ; pSubFilters != pSubFiltersEnd; ++pSubFilters )
-		nAdded += implAddFilter( pSubFilters->First, pSubFilters->Second );
-    return nAdded;
+		implAddFilter( pSubFilters->First, pSubFilters->Second );
 }
 
 void SalGtkFilePicker::SetFilters()
 {
-	OSL_TRACE( "start setting filters\n");
-
     GdkThreadLock aLock;
 
-    int nAdded = 0;
+	if (!m_aInitialFilter.getLength())
+		m_aInitialFilter = m_aCurrentFilter;
+
+	rtl::OUString sPseudoFilter;
+    if( GTK_FILE_CHOOSER_ACTION_SAVE == gtk_file_chooser_get_action( GTK_FILE_CHOOSER( m_pDialog
) ) )
+    {
+		std::set<OUString> aAllFormats;
+		if( m_pFilterList && !m_pFilterList->empty() )
+		{
+			for	(	FilterList::iterator aListIter = m_pFilterList->begin();
+					aListIter != m_pFilterList->end();
+					++aListIter
+				)
+			{
+				if( aListIter->hasSubFilters() )
+				{	// it's a filter group
+					UnoFilterList aSubFilters;
+					aListIter->getSubFilters( aSubFilters );
+					const StringPair* pSubFilters   = aSubFilters.getConstArray();
+					const StringPair* pSubFiltersEnd = pSubFilters + aSubFilters.getLength();
+					for( ; pSubFilters != pSubFiltersEnd; ++pSubFilters )
+						aAllFormats.insert(pSubFilters->Second);
+				}
+				else
+					aAllFormats.insert(aListIter->getFilter());
+			}
+		}
+		if (aAllFormats.size() > 1)
+		{
+			rtl::OUString sAllFilter;
+			std::set<OUString>::const_iterator aEnd = aAllFormats.end();
+			for (std::set<OUString>::const_iterator aIter = aAllFormats.begin(); aIter != aEnd;
++aIter)
+			{
+				if (sAllFilter.getLength())
+					sAllFilter += OUString(sal_Unicode(';'));
+				sAllFilter += *aIter;
+			}
+			CResourceProvider aResProvider;
+			sPseudoFilter = aResProvider.getResString(FILE_PICKER_ALLFORMATS);
+			m_pPseudoFilter = implAddFilter( sPseudoFilter, sAllFilter );
+		}
+    }
+
 	if( m_pFilterList && !m_pFilterList->empty() )
 	{
 		for	(	FilterList::iterator aListIter = m_pFilterList->begin();
@@ -1990,30 +2036,27 @@ void SalGtkFilePicker::SetFilters()
 				UnoFilterList aSubFilters;
 				aListIter->getSubFilters( aSubFilters );
 
-				nAdded += implAddFilterGroup( aListIter->getTitle(), aSubFilters );
+				implAddFilterGroup( aListIter->getTitle(), aSubFilters );
 			}
 			else
 			{
 				// it's a single filter
 
-				nAdded += implAddFilter( aListIter->getTitle(), aListIter->getFilter() );
+				implAddFilter( aListIter->getTitle(), aListIter->getFilter() );
 			}
 		}
 	}
 
-    if (nAdded)
+    if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_pFilterStore), NULL)) //If m_pFilterStore
is not empty
         gtk_widget_show( m_pFilterExpander );
     else
         gtk_widget_hide( m_pFilterExpander );
 
 	// set the default filter
-	if( m_aCurrentFilter && (m_aCurrentFilter.getLength() > 0) )
-	{
-		OSL_TRACE( "Setting current filter to %s\n", 
-			OUStringToOString( m_aCurrentFilter, RTL_TEXTENCODING_UTF8 ).getStr() );
-
+	if (sPseudoFilter.getLength())
+		SetCurFilter( sPseudoFilter );
+	else if(m_aCurrentFilter.getLength())
 		SetCurFilter( m_aCurrentFilter );
-	}
 
 	OSL_TRACE( "end setting filters\n");
 }

Modified: incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.hxx?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.hxx (original)
+++ incubator/ooo/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.hxx Wed Oct 12 19:23:38
2011
@@ -314,11 +314,13 @@ class SalGtkFilePicker : 
         gulong mnHID_SelectionChange;
 
 		::rtl::OUString	m_aCurrentFilter;
+		::rtl::OUString	m_aInitialFilter;
 
         bool bVersionWidthUnset;
         sal_Bool mbPreviewState;
         gulong mHID_Preview;
         GtkWidget* m_pPreview;
+		GtkFileFilter* m_pPseudoFilter;
         sal_Int32 m_PreviewImageWidth;
         sal_Int32 m_PreviewImageHeight;
         
@@ -329,8 +331,8 @@ class SalGtkFilePicker : 
         void UpdateFilterfromUI();
 
         void implChangeType( GtkTreeSelection *selection );
-		int implAddFilter( const OUString& rFilter, const OUString& rType);
-		int implAddFilterGroup( const OUString& rFilter, 
+		GtkFileFilter * implAddFilter( const OUString& rFilter, const OUString& rType );
+		void implAddFilterGroup( const OUString& rFilter, 
 					 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair>&
_rFilters );
         void updateCurrentFilterFromName(const gchar* filtername);
         void unselect_type();

Modified: incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.cxx?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.cxx (original)
+++ incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.cxx Wed Oct 12 19:23:38
2011
@@ -82,7 +82,8 @@ _Entry CtrlIdToResIdTable[] = {
     { 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_OVERWRITE,                    STR_SVT_ALREADYEXISTOVERWRITE },
+    { FILE_PICKER_ALLFORMATS,                   STR_SVT_ALLFORMATS }
 };
 
 _Entry OtherCtrlIdToResIdTable[] = {

Modified: incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.hxx?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.hxx (original)
+++ incubator/ooo/trunk/main/fpicker/source/unx/gnome/resourceprovider.hxx Wed Oct 12 19:23:38
2011
@@ -45,6 +45,7 @@
 #define FILE_PICKER_TITLE_SAVE        503
 #define FILE_PICKER_FILE_TYPE         504
 #define FILE_PICKER_OVERWRITE         505
+#define FILE_PICKER_ALLFORMATS        506
 
 //------------------------------------------------------------------------
 // deklarations

Modified: incubator/ooo/trunk/main/svtools/inc/svtools/svtools.hrc
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/inc/svtools/svtools.hrc?rev=1182539&r1=1182538&r2=1182539&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/inc/svtools/svtools.hrc (original)
+++ incubator/ooo/trunk/main/svtools/inc/svtools/svtools.hrc Wed Oct 12 19:23:38 2011
@@ -66,6 +66,7 @@
 #define RID_FILEOPEN_INVALIDFOLDER		(RID_SVTOOLS_START + 34)
 #define RID_FILEOPEN_NOTEXISTENTFILE	(RID_SVTOOLS_START + 35)
 #define STR_SVT_NOREMOVABLEDEVICE       (RID_SVTOOLS_START + 36)
+#define STR_SVT_ALLFORMATS				(RID_SVTOOLS_START + 37)
 
 // doc template dialog
 #define DLG_DOCTEMPLATE					(RID_SVTOOLS_START+50)



Mime
View raw message