summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2006-07-13 15:55:13 +0000
committerOliver Bolte <obo@openoffice.org>2006-07-13 15:55:13 +0000
commitcb2ff15dde9aa8f3369e4d21f2d4f397e1ded8c0 (patch)
tree723e49c9bc7d4034ce331e7b5eab0f86a5418c8d /fpicker
parentfcafc5a07d6e958c489a33bb4876de3d697ee881 (diff)
INTEGRATION: CWS jsc7 (1.8.8); FILE MERGED
2006/06/27 08:29:36 jsc 1.8.8.2: RESYNC: (1.8-1.9); FILE MERGED 2006/04/27 15:48:47 jsc 1.8.8.1: #i64810# insert new helper function appendDefaultExtension, takes care of any kind of valid filter extensions - used for automatic filename extension
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/iodlg.cxx68
1 files changed, 41 insertions, 27 deletions
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index a3ce2cf62f38..31cb371c8187 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: iodlg.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: hr $ $Date: 2006-06-20 00:12:46 $
+ * last change: $Author: obo $ $Date: 2006-07-13 16:55:13 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -1297,31 +1297,10 @@ IMPL_STATIC_LINK( SvtFileDialog, OpenHdl_Impl, void*, pVoid )
) // (in SvtFileDialog::GetPathList) be taken as file to save to
) // (#114818# - 2004-03-17 - fs@openoffice.org)
{
- // und diese nicht eh schon dran haengt
- String aExt = String(RTL_CONSTASCII_USTRINGPARAM("*."));
- INetURLObject aTemp( aFileName );
- aExt += String(aTemp.GetExtension().toAsciiLowerCase());
- const String& rType = pThis->_pImp->GetCurFilter()->GetType();
- String aType = rType;
- aType.ToLowerAscii();
-
- if ( ! aType.EqualsAscii(FILEDIALOG_FILTER_ALL) )
- {
- USHORT nWildCard = aType.GetTokenCount( FILEDIALOG_DEF_EXTSEP );
- USHORT nIndex, nPos = 0;
-
- for ( nIndex = 0; nIndex < nWildCard; nIndex++ )
- {
- if ( aExt == aType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ) )
- break;
- }
-
- if ( nIndex >= nWildCard )
- {
- aFileName += '.';
- aFileName += pThis->GetDefaultExt();
- }
- }
+ // check extension and append the default extension if necessary
+ appendDefaultExtension(aFileName,
+ pThis->GetDefaultExt(),
+ pThis->_pImp->GetCurFilter()->GetType());
}
BOOL bOpenFolder = ( FILEDLG_TYPE_PATHDLG == pThis->_pImp->_eDlgType ) &&
@@ -3413,6 +3392,41 @@ sal_Bool SvtFileDialog::ContentGetTitle( const rtl::OUString& rURL, String& rTit
return m_aContent.isValid();
}
+void SvtFileDialog::appendDefaultExtension(String& _rFileName,
+ const String& _rFilterDefaultExtension,
+ const String& _rFilterExtensions)
+{
+ String aTemp(_rFileName);
+ aTemp.ToLowerAscii();
+ String aType(_rFilterExtensions);
+ aType.ToLowerAscii();
+
+ if ( ! aType.EqualsAscii(FILEDIALOG_FILTER_ALL) )
+ {
+ USHORT nWildCard = aType.GetTokenCount( FILEDIALOG_DEF_EXTSEP );
+ USHORT nIndex, nPos = 0;
+
+ for ( nIndex = 0; nIndex < nWildCard; nIndex++ )
+ {
+ String aExt(aType.GetToken( 0, FILEDIALOG_DEF_EXTSEP, nPos ));
+ // take care of a leading *
+ USHORT nExtOffset = (aExt.GetBuffer()[0] == '*' ? 1 : 0);
+ sal_Unicode* pExt = aExt.GetBufferAccess() + nExtOffset;
+ xub_StrLen nExtLen = aExt.Len() - nExtOffset;
+ xub_StrLen nOffset = aTemp.Len() - nExtLen;
+ // minimize search by starting at last possible index
+ if ( aTemp.Search(pExt, nOffset) == nOffset )
+ break;
+ }
+
+ if ( nIndex >= nWildCard )
+ {
+ _rFileName += '.';
+ _rFileName += _rFilterDefaultExtension;
+ }
+ }
+}
+
// -----------------------------------------------------------------------
// QueryFolderNameDialog -------------------------------------------------------