Files
libreoffice/svtools/source/control/inettbc.cxx

1380 lines
46 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
2012-11-15 17:28:16 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifdef UNX
#include <pwd.h>
#include <sys/types.h>
#endif
#include <svtools/inettbc.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
2010-08-27 13:46:58 +02:00
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
#include <com/sun/star/ucb/UniversalContentBroker.hpp>
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
#include <com/sun/star/ucb/XCommandProcessor2.hpp>
#include <com/sun/star/ucb/XProgressHandler.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp>
#include <com/sun/star/ucb/SortedDynamicResultSetFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <rtl/instance.hxx>
#include <salhelper/thread.hxx>
#include <osl/mutex.hxx>
#include <vcl/builder.hxx>
#include <vcl/svapp.hxx>
#include <vcl/toolbox.hxx>
#include <unotools/historyoptions.hxx>
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
#include <svl/itemset.hxx>
#include <svl/urihelper.hxx>
#include <unotools/pathoptions.hxx>
#include <ucbhelper/commandenvironment.hxx>
#include <ucbhelper/content.hxx>
#include <unotools/localfilehelper.hxx>
#include <unotools/ucbhelper.hxx>
#include <svtools/asynclink.hxx>
#include <svl/urlfilter.hxx>
#include <vector>
#include <algorithm>
using namespace ::ucbhelper;
using namespace ::utl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::uno;
class SvtURLBox_Impl
{
public:
std::vector<OUString> aURLs;
std::vector<OUString> aCompletions;
std::vector<WildCard> m_aFilters;
static bool TildeParsing( OUString& aText, OUString& aBaseUrl );
inline SvtURLBox_Impl( )
{
FilterMatch::createWildCardFilterList(OUString(),m_aFilters);
}
};
class SvtMatchContext_Impl: public salhelper::Thread
{
static ::osl::Mutex* pDirMutex;
std::vector<OUString> aPickList;
std::vector<OUString> aCompletions;
std::vector<OUString> aURLs;
svtools::AsynchronLink aLink;
OUString aBaseURL;
OUString aText;
SvtURLBox* pBox;
bool bOnlyDirectories;
bool bNoSelection;
osl::Mutex mutex_;
bool stopped_;
css::uno::Reference< css::ucb::XCommandProcessor > processor_;
sal_Int32 commandId_;
DECL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void* );
virtual ~SvtMatchContext_Impl();
virtual void execute() SAL_OVERRIDE;
void doExecute();
void Insert( const OUString& rCompletion, const OUString& rURL, bool bForce = false);
void ReadFolder( const OUString& rURL, const OUString& rMatch, bool bSmart );
void FillPicklist(std::vector<OUString>& rPickList);
public:
SvtMatchContext_Impl( SvtURLBox* pBoxP, const OUString& rText );
void Stop();
};
namespace
{
struct theSvtMatchContextMutex
: public rtl::Static< ::osl::Mutex, theSvtMatchContextMutex > {};
}
SvtMatchContext_Impl::SvtMatchContext_Impl(
SvtURLBox* pBoxP, const OUString& rText )
: Thread( "SvtMatchContext_Impl" )
, aLink( STATIC_LINK( this, SvtMatchContext_Impl, Select_Impl ) )
, aBaseURL( pBoxP->aBaseURL )
, aText( rText )
, pBox( pBoxP )
, bOnlyDirectories( pBoxP->bOnlyDirectories )
, bNoSelection( pBoxP->bNoSelection )
, stopped_(false)
, commandId_(0)
{
aLink.CreateMutex();
FillPicklist( aPickList );
}
SvtMatchContext_Impl::~SvtMatchContext_Impl()
{
aLink.ClearPendingCall();
}
void SvtMatchContext_Impl::FillPicklist(std::vector<OUString>& rPickList)
{
// Einlesung der Historypickliste
Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST );
sal_uInt32 nCount = seqPicklist.getLength();
for( sal_uInt32 nItem=0; nItem < nCount; nItem++ )
{
Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
OUString sTitle;
INetURLObject aURL;
sal_uInt32 nPropertyCount = seqPropertySet.getLength();
for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
{
if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE )
{
seqPropertySet[nProperty].Value >>= sTitle;
aURL.SetURL( sTitle );
2012-01-11 20:46:25 -05:00
rPickList.insert(rPickList.begin() + nItem, aURL.GetMainURL(INetURLObject::DECODE_WITH_CHARSET));
break;
}
}
}
}
void SvtMatchContext_Impl::Stop()
{
css::uno::Reference< css::ucb::XCommandProcessor > proc;
sal_Int32 id(0);
{
osl::MutexGuard g(mutex_);
if (!stopped_) {
stopped_ = true;
proc = processor_;
id = commandId_;
}
}
if (proc.is()) {
proc->abort(id);
}
terminate();
}
void SvtMatchContext_Impl::execute( )
{
doExecute();
aLink.Call( this );
}
// This method is called via AsynchronLink, so it has the SolarMutex and
// calling solar code ( VCL ... ) is safe. It is called when the thread is
// terminated ( finished work or stopped ). Cancelling the thread via
// Cancellable does not discard the information gained so far, it
// inserts all collected completions into the listbox.
IMPL_STATIC_LINK( SvtMatchContext_Impl, Select_Impl, void*, )
{
// avoid recursion through cancel button
{
osl::MutexGuard g(pThis->mutex_);
if (pThis->stopped_) {
// Completion was stopped, no display:
return 0;
}
}
SvtURLBox* pBox = pThis->pBox;
pBox->bAutoCompleteMode = true;
// did we filter completions which otherwise would have been valid?
// (to be filled below)
bool bValidCompletionsFiltered = false;
// insert all completed strings into the listbox
pBox->Clear();
for(std::vector<OUString>::iterator i = pThis->aCompletions.begin(); i != pThis->aCompletions.end(); ++i)
{
OUString sCompletion(*i);
// convert the file into an URL
OUString sURL( sCompletion );
::utl::LocalFileHelper::ConvertPhysicalNameToURL( sCompletion, sURL );
// note: if this doesn't work, we're not interested in: we're checking the
// untouched sCompletion then
if ( !sURL.isEmpty() && !sURL.endsWith("/") )
{
OUString sUpperURL( sURL.toAsciiUpperCase() );
::std::vector< WildCard >::const_iterator aMatchingFilter =
::std::find_if(
pBox->pImp->m_aFilters.begin(),
pBox->pImp->m_aFilters.end(),
FilterMatch( sUpperURL )
);
if ( aMatchingFilter == pBox->pImp->m_aFilters.end() )
{ // this URL is not allowed
bValidCompletionsFiltered = true;
continue;
}
}
pBox->InsertEntry( sCompletion );
}
2012-01-11 20:46:25 -05:00
if( !pThis->bNoSelection && !pThis->aCompletions.empty() && !bValidCompletionsFiltered )
{
// select the first one
OUString aTmp( pBox->GetEntry(0) );
pBox->SetText( aTmp );
pBox->SetSelection( Selection( pThis->aText.getLength(), aTmp.getLength() ) );
}
// transfer string lists to listbox and forget them
2012-01-11 20:46:25 -05:00
pBox->pImp->aURLs = pThis->aURLs;
pBox->pImp->aCompletions = pThis->aCompletions;
pThis->aURLs.clear();
pThis->aCompletions.clear();
// force listbox to resize ( it may be open )
pBox->Resize();
// the box has this control as a member so we have to set that member
// to zero before deleting ourself.
pBox->pCtx.clear();
return 0;
}
void SvtMatchContext_Impl::Insert( const OUString& rCompletion,
const OUString& rURL,
bool bForce )
{
if( !bForce )
{
// avoid doubles
if(find(aCompletions.begin(), aCompletions.end(), OUString(rCompletion)) != aCompletions.end())
2012-01-11 20:46:25 -05:00
return;
}
2012-01-11 20:46:25 -05:00
aCompletions.push_back(rCompletion);
aURLs.push_back(rURL);
}
void SvtMatchContext_Impl::ReadFolder( const OUString& rURL,
const OUString& rMatch,
bool bSmart )
{
// check folder to scan
if( !UCBContentHelper::IsFolder( rURL ) )
return;
bool bPureHomePath = false;
#ifdef UNX
bPureHomePath = aText.startsWith( "~" ) && aText.indexOf( '/' ) == -1;
#endif
bool bExectMatch = bPureHomePath
|| aText == "."
|| aText.endsWith("/.")
|| aText.endsWith("/..");
// for pure home paths ( ~username ) the '.' at the end of rMatch
// means that it poits to root catalog
// this is done only for file contents since home paths parsing is useful only for them
if ( bPureHomePath && rMatch == "file:///." )
{
// a home that refers to /
OUString aNewText( aText );
aNewText += "/";
Insert( aNewText, rURL, true );
return;
}
// string to match with
INetURLObject aMatchObj( rMatch );
OUString aMatchName;
if ( rURL != aMatchObj.GetMainURL( INetURLObject::NO_DECODE ) )
{
aMatchName = aMatchObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
// matching is always done case insensitive, but completion will be case sensitive and case preserving
aMatchName = aMatchName.toAsciiLowerCase();
// if the matchstring ends with a slash, we must search for this also
if ( rMatch.endsWith("/") )
aMatchName += "/";
}
sal_Int32 nMatchLen = aMatchName.getLength();
INetURLObject aFolderObj( rURL );
DBG_ASSERT( aFolderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
try
{
Content aCnt( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ),
new ::ucbhelper::CommandEnvironment( uno::Reference< XInteractionHandler >(),
uno::Reference< XProgressHandler >() ),
comphelper::getProcessComponentContext() );
uno::Reference< XResultSet > xResultSet;
Sequence< OUString > aProps(2);
OUString* pProps = aProps.getArray();
pProps[0] = "Title";
pProps[1] = "IsFolder";
try
{
uno::Reference< XDynamicResultSet > xDynResultSet;
ResultSetInclude eInclude = INCLUDE_FOLDERS_AND_DOCUMENTS;
if ( bOnlyDirectories )
2010-08-27 13:46:58 +02:00
eInclude = INCLUDE_FOLDERS_ONLY;
xDynResultSet = aCnt.createDynamicCursor( aProps, eInclude );
uno::Reference < XAnyCompareFactory > xCompare;
uno::Reference < XSortedDynamicResultSetFactory > xSRSFac =
SortedDynamicResultSetFactory::create( ::comphelper::getProcessComponentContext() );
Sequence< NumberedSortingInfo > aSortInfo( 2 );
NumberedSortingInfo* pInfo = aSortInfo.getArray();
pInfo[ 0 ].ColumnIndex = 2;
pInfo[ 0 ].Ascending = false;
pInfo[ 1 ].ColumnIndex = 1;
pInfo[ 1 ].Ascending = true;
uno::Reference< XDynamicResultSet > xDynamicResultSet;
xDynamicResultSet =
xSRSFac->createSortedDynamicResultSet( xDynResultSet, aSortInfo, xCompare );
if ( xDynamicResultSet.is() )
{
xResultSet = xDynamicResultSet->getStaticResultSet();
}
}
catch( ::com::sun::star::uno::Exception& ) {}
if ( xResultSet.is() )
{
uno::Reference< XRow > xRow( xResultSet, UNO_QUERY );
uno::Reference< XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
try
{
while ( schedule() && xResultSet->next() )
{
OUString aURL = xContentAccess->queryContentIdentifierString();
OUString aTitle = xRow->getString(1);
bool bIsFolder = xRow->getBoolean(2);
// matching is always done case insensitive, but completion will be case sensitive and case preserving
aTitle = aTitle.toAsciiLowerCase();
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
if (
!nMatchLen ||
(bExectMatch && aMatchName == aTitle) ||
(!bExectMatch && aMatchName.compareTo(aTitle, nMatchLen) == 0)
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
)
{
// all names fit if matchstring is empty
INetURLObject aObj( aURL );
sal_Unicode aDelimiter = '/';
if ( bSmart )
// when parsing is done "smart", the delimiter must be "guessed"
aObj.getFSysPath( (INetURLObject::FSysStyle)(INetURLObject::FSYS_DETECT & ~INetURLObject::FSYS_VOS), &aDelimiter );
if ( bIsFolder )
aObj.setFinalSlash();
// get the last name of the URL
OUString aMatch = aObj.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
OUString aInput( aText );
if ( nMatchLen )
{
if (aText.endsWith(".") || bPureHomePath)
{
// if a "special folder" URL was typed, don't touch the user input
aMatch = aMatch.copy( nMatchLen );
}
else
{
// make the user input case preserving
DBG_ASSERT( aInput.getLength() >= nMatchLen, "Suspicious Matching!" );
aInput = aInput.copy( 0, aInput.getLength() - nMatchLen );
}
}
aInput += aMatch;
// folders should get a final slash automatically
if ( bIsFolder )
aInput += OUString(aDelimiter);
Insert( aInput, aObj.GetMainURL( INetURLObject::NO_DECODE ), true );
}
}
}
catch( ::com::sun::star::uno::Exception& )
{
}
}
}
catch( ::com::sun::star::uno::Exception& )
{
}
}
OUString SvtURLBox::ParseSmart( const OUString& _aText, const OUString& _aBaseURL, const OUString& aWorkDir )
{
OUString aMatch;
OUString aText = _aText;
OUString aBaseURL = _aBaseURL;
// parse ~ for Unix systems
// does nothing for Windows
if( !SvtURLBox_Impl::TildeParsing( aText, aBaseURL ) )
return OUString();
if( !aBaseURL.isEmpty() )
{
INetProtocol eBaseProt = INetURLObject::CompareProtocolScheme( aBaseURL );
// if a base URL is set the string may be parsed relative
if( aText.startsWith( "/" ) )
{
// text starting with slashes means absolute file URLs
OUString aTemp = INetURLObject::GetScheme( eBaseProt );
// file URL must be correctly encoded!
OUString aTextURL = INetURLObject::encode( aText, INetURLObject::PART_FPATH,
'%', INetURLObject::ENCODE_ALL );
aTemp += aTextURL;
INetURLObject aTmp( aTemp );
if ( !aTmp.HasError() && aTmp.GetProtocol() != INET_PROT_NOT_VALID )
aMatch = aTmp.GetMainURL( INetURLObject::NO_DECODE );
}
else
{
OUString aSmart( aText );
INetURLObject aObj( aBaseURL );
// HRO: I suppose this hack should only be done for Windows !!!???
#ifdef WNT
// HRO: INetURLObject::smatRel2Abs does not recognize '\\' as a relative path
// but in case of "\\\\" INetURLObject is right - this is an absolute path !
if( aText.startsWith("\\") && (aText.getLength() < 2 || aText[ 1 ] != '\\') )
{
// cut to first segment
OUString aTmp = INetURLObject::GetScheme( eBaseProt );
aTmp += "/";
aTmp += aObj.getName( 0, true, INetURLObject::DECODE_WITH_CHARSET );
aObj.SetURL( aTmp );
aSmart = aSmart.copy(1);
}
#endif
// base URL must be a directory !
aObj.setFinalSlash();
// take base URL and append current input
bool bWasAbsolute = false;
#ifdef UNX
INetURLObject::FSysStyle eStyle = static_cast< INetURLObject::FSysStyle >( INetURLObject::FSYS_VOS | INetURLObject::FSYS_UNX | INetURLObject::FSYS_DOS );
// encode file URL correctly
aSmart = INetURLObject::encode( aSmart, INetURLObject::PART_FPATH, '%', INetURLObject::ENCODE_ALL );
INetURLObject aTmp( aObj.smartRel2Abs(
aSmart, bWasAbsolute, false, INetURLObject::WAS_ENCODED, RTL_TEXTENCODING_UTF8, false, eStyle ) );
#else
INetURLObject aTmp( aObj.smartRel2Abs( aSmart, bWasAbsolute ) );
#endif
if ( aText.endsWith(".") )
// INetURLObject appends a final slash for the directories "." and "..", this is a bug!
// Remove it as a workaround
aTmp.removeFinalSlash();
if ( !aTmp.HasError() && aTmp.GetProtocol() != INET_PROT_NOT_VALID )
aMatch = aTmp.GetMainURL( INetURLObject::NO_DECODE );
}
}
else
{
OUString aTmpMatch;
::utl::LocalFileHelper::ConvertSystemPathToURL( aText, aWorkDir, aTmpMatch );
aMatch = aTmpMatch;
}
return aMatch;
}
void SvtMatchContext_Impl::doExecute()
{
::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
{
// have we been stopped while we were waiting for the mutex?
osl::MutexGuard g(mutex_);
if (stopped_) {
return;
}
}
// Reset match lists
2012-01-11 20:46:25 -05:00
aCompletions.clear();
aURLs.clear();
// check for input
sal_uInt16 nTextLen = aText.getLength();
if ( !nTextLen )
return;
if( aText.indexOf( '*' ) != -1 || aText.indexOf( '?' ) != -1 )
// no autocompletion for wildcards
return;
OUString aMatch;
OUString aWorkDir( SvtPathOptions().GetWorkPath() );
INetProtocol eProt = INetURLObject::CompareProtocolScheme( aText );
INetProtocol eBaseProt = INetURLObject::CompareProtocolScheme( aBaseURL );
if ( aBaseURL.isEmpty() )
eBaseProt = INetURLObject::CompareProtocolScheme( aWorkDir );
INetProtocol eSmartProt = pBox->GetSmartProtocol();
// if the user input is a valid URL, go on with it
// otherwise it could be parsed smart with a predefined smart protocol
// ( or if this is not set with the protocol of a predefined base URL )
CWS-TOOLING: integrate CWS vcl101 2009-04-30 16:05:34 +0200 pl r271420 : #i95591# need a poll timer so XtTimers work properly 2009-04-30 11:25:52 +0200 hdu r271406 : #i100929# avoid unneeded colormap reallocation 2009-04-30 11:21:16 +0200 hdu r271405 : #i100929# use improved SetDrawable() also for salframe updates 2009-04-30 11:12:41 +0200 hdu r271404 : i100929# invalidate cached renderpic also for changed vdev 2009-04-29 14:31:40 +0200 hdu r271375 : i100929# use cached renderpic also for alpha-rect/bitmap drawing 2009-04-29 14:16:51 +0200 hdu r271370 : i100929# notify only GtkSalFrame's valid X11SalFrames 2009-04-29 13:58:10 +0200 hdu r271369 : i100929# notify GtkSalFrame's X11SalGraphics that their drawables will become obsolete 2009-04-29 13:53:48 +0200 hdu r271367 : #i100929# release cached renderpic whenever the corresponding drawable changes 2009-04-28 11:56:07 +0200 pl r271317 : fix a snafu 2009-04-27 16:52:29 +0200 hdu r271293 : #i100000# WAE fix for debug=true compilation 2009-04-27 12:38:11 +0200 hdu r271260 : #i101367# disable vdev mapmode when measuring pixel size 2009-04-27 12:28:37 +0200 hdu r271259 : #i101367# speedup svclcanvas::CanvasBitmapHelper::getSize() 2009-04-23 15:11:25 +0200 hdu r271175 : #i91685# ignore trailing space in last cell 2009-04-23 12:55:14 +0200 pl r271156 : #i101032# check for empty bitmap 2009-04-23 11:04:50 +0200 pl r271144 : #101184# add a paranoia check 2009-04-21 19:12:25 +0200 pl r271055 : #i101184# add: recognize added/removed monitors in xinerama configuration for gtk plugin (thanks cmc) 2009-04-21 17:04:44 +0200 pl r271046 : #i101089# remove unused method (thanks cmc) 2009-04-21 16:41:38 +0200 hdu r271042 : #i99842# set text decoration color 2009-04-20 22:57:37 +0200 pl r271015 : #i101063# fix warnings 2009-04-20 22:55:39 +0200 pl r271014 : #i101063# fix warnings 2009-04-20 11:35:24 +0200 hdu r270968 : #i1001102# remove dependency to psprint module 2009-04-20 11:31:08 +0200 hdu r270967 : #i100929# keep cached render Picture in X11SalGraphics removes 2009-04-20 11:24:57 +0200 hdu r270966 : #i100929# cache render Picture in X11SalGraphics 2009-04-18 14:53:22 +0200 hdu r270959 : CWS-TOOLING: rebase CWS vcl101 to trunk@270723 (milestone: DEV300:m46) 2009-04-17 12:00:50 +0200 hdu r270934 : #i100951# b2d-polygon clipping handles bezier-segments nowadays => performance opt possible 2009-04-17 11:50:49 +0200 hdu r270933 : #i100922# count b2d-polypoly-points to avoid priority-queue reallocations 2009-04-17 11:07:03 +0200 hdu r270930 : #i101145# match dpi-sanity check with gnome-UI (thanks Caolan!) 2009-04-17 10:44:41 +0200 hdu r270929 : #i100603# dingbats-encoded PDF-builtin fonts are symbol fonts too 2009-04-17 10:36:10 +0200 hdu r270928 : #i101145# check sanity of resolution reported by Xft-dpi (thanks CMC!) 2009-04-08 13:53:35 +0200 hdu r270644 : #i100951# avoid expensive calls to basegfx::tools::clipPolygonOnRange() if possible 2009-04-08 13:19:26 +0200 hdu r270637 : #i100922# prevent needless stl::priority_queue reallacations by reserving 2009-04-08 11:14:30 +0200 hdu r270627 : #i100929# use X11SalGraphics::GetXRenderPicture() also for text drawing 2009-04-08 10:00:42 +0200 hdu r270620 : #i100929# add and use X11SalGraphics::GetXRenderPicture() for polygon drawing 2009-04-06 15:52:47 +0200 hdu r270563 : #i100885# add and use AquaSalGraphics::copyResolution() to speed up virdev creation 2009-04-02 14:39:06 +0200 pl r270408 : #i95873# do not set LD_LIBRARY_PATH for external apps 2009-03-31 18:43:19 +0200 pl r270292 : #i99783# transparency of closer image changed to mask in the meantime 2009-03-27 15:42:37 +0100 hdu r270158 : #i100591# fix binary search in dingbats encoding converter 2009-03-27 13:06:34 +0100 hdu r270151 : #i100603# only PDF builtin text fonts use WinAnsiEncoding 2009-03-27 12:05:35 +0100 hdu r270147 : #i100603# use correct encoding for all PDF builtin fonts 2009-03-27 09:04:07 +0100 hdu r270133 : #i100603# use proper encoding for PDF builtin symbol fonts 2009-03-26 17:19:38 +0100 hdu r270090 : #i100591# support RTL_TEXTENCODING_ADOBE_DINGBATS encoding 2009-03-25 09:02:18 +0100 hdu r269995 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading SAGE and extra USER32 symbols 2009-03-25 08:55:49 +0100 hdu r269994 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading LUNA symbols 2009-03-24 16:15:54 +0100 hdu r269965 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading vclplugin symbols 2009-03-24 16:10:29 +0100 hdu r269963 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading USP symbols 2009-03-24 15:54:30 +0100 hdu r269962 : #i100521# prefer osl_getAsciiFunctionSymbol() when dynloading xrender symbols 2009-03-24 10:46:55 +0100 hdu r269920 : #i100506# fix WAE build breakers on unxsols4 for debug=true 2009-03-23 16:36:43 +0100 hdu r269884 : #159477# fix crash for PDFs with big zlib-chunks 2009-03-20 17:36:56 +0100 pl r269821 : #i96568# add recent files to mac quickstarter 2009-03-20 14:39:41 +0100 pl r269809 : #i35482# no HC mode detection, automatically done in independent part 2009-03-19 20:01:37 +0100 pl r269768 : #i95591# do not reuse UnxPloginComm because of connection loss problems 2009-03-19 18:08:23 +0100 pl r269765 : #i95588# change default visibility that was ignored everywhere but unix anyway
2009-06-03 15:45:09 +00:00
if( eProt == INET_PROT_NOT_VALID || eProt == eSmartProt || (eSmartProt == INET_PROT_NOT_VALID && eProt == eBaseProt) )
{
// not stopped yet ?
if( schedule() )
{
if ( eProt == INET_PROT_NOT_VALID )
aMatch = SvtURLBox::ParseSmart( aText, aBaseURL, aWorkDir );
else
aMatch = aText;
if ( !aMatch.isEmpty() )
{
INetURLObject aURLObject( aMatch );
OUString aMainURL( aURLObject.GetMainURL( INetURLObject::NO_DECODE ) );
// Disable autocompletion for anything but the (local) file
// system (for which access is hopefully fast), as the logic of
// how SvtMatchContext_Impl is used requires this code to run to
// completion before further user input is processed, and even
// SvtMatchContext_Impl::Stop does not guarantee a speedy
// return:
if ( !aMainURL.isEmpty()
&& aURLObject.GetProtocol() == INET_PROT_FILE )
{
// if text input is a directory, it must be part of the match list! Until then it is scanned
bool folder = false;
if (aURLObject.hasFinalSlash()) {
try {
css::uno::Reference< css::uno::XComponentContext >
ctx(comphelper::getProcessComponentContext());
css::uno::Reference<
css::ucb::XUniversalContentBroker > ucb(
css::ucb::UniversalContentBroker::create(
ctx));
css::uno::Sequence< css::beans::Property > prop(1);
prop[0].Name = "IsFolder";
prop[0].Handle = -1;
prop[0].Type = cppu::UnoType< bool >::get();
css::uno::Any res;
css::uno::Reference< css::ucb::XCommandProcessor >
proc(
ucb->queryContent(
ucb->createContentIdentifier(aMainURL)),
css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::ucb::XCommandProcessor2 >
proc2(proc, css::uno::UNO_QUERY);
sal_Int32 id = proc->createCommandIdentifier();
try {
{
osl::MutexGuard g(mutex_);
processor_ = proc;
commandId_ = id;
}
res = proc->execute(
css::ucb::Command(
"getPropertyValues", -1,
css::uno::makeAny(prop)),
id,
css::uno::Reference<
css::ucb::XCommandEnvironment >());
} catch (...) {
if (proc2.is()) {
try {
proc2->releaseCommandIdentifier(id);
} catch (css::uno::RuntimeException & e) {
SAL_WARN(
"svtools.control",
"ignoring UNO RuntimeException "
<< e.Message);
}
}
throw;
}
if (proc2.is()) {
proc2->releaseCommandIdentifier(id);
}
{
osl::MutexGuard g(mutex_);
processor_.clear();
// At least the neon-based WebDAV UCP does not
// properly support aborting commands, so return
// anyway now if an abort request had been
// ignored and the command execution only
// returned "successfully" after some timeout:
if (stopped_) {
return;
}
}
css::uno::Reference< css::sdbc::XRow > row(
res, css::uno::UNO_QUERY_THROW);
folder = row->getBoolean(1) && !row->wasNull();
} catch (css::uno::Exception & e) {
SAL_WARN(
"svtools.control",
"ignoring UNO Exception " << typeid(*&e).name()
<< ": " << e.Message);
return;
}
}
if ( folder )
2010-08-27 13:46:58 +02:00
Insert( aText, aMatch );
else
// otherwise the parent folder will be taken
aURLObject.removeSegment();
// scan directory and insert all matches
ReadFolder( aURLObject.GetMainURL( INetURLObject::NO_DECODE ), aMatch, eProt == INET_PROT_NOT_VALID );
}
}
}
}
if ( bOnlyDirectories )
// don't scan history picklist if only directories are allowed, picklist contains only files
return;
bool bFull = false;
INetURLObject aCurObj;
OUString aEmpty, aCurString, aCurMainURL;
INetURLObject aObj;
aObj.SetSmartProtocol( eSmartProt == INET_PROT_NOT_VALID ? INET_PROT_HTTP : eSmartProt );
for( ;; )
{
for(std::vector<OUString>::iterator i = aPickList.begin(); schedule() && i != aPickList.end(); ++i)
{
2012-01-11 20:46:25 -05:00
aCurObj.SetURL(*i);
aCurObj.SetSmartURL( aCurObj.GetURLNoPass());
aCurMainURL = aCurObj.GetMainURL( INetURLObject::NO_DECODE );
if( eProt != INET_PROT_NOT_VALID && aCurObj.GetProtocol() != eProt )
continue;
if( eSmartProt != INET_PROT_NOT_VALID && aCurObj.GetProtocol() != eSmartProt )
continue;
switch( aCurObj.GetProtocol() )
{
case INET_PROT_HTTP:
case INET_PROT_HTTPS:
case INET_PROT_FTP:
{
if( eProt == INET_PROT_NOT_VALID && !bFull )
{
aObj.SetSmartURL( aText );
if( aObj.GetURLPath().getLength() > 1 )
continue;
}
aCurString = aCurMainURL;
if( eProt == INET_PROT_NOT_VALID )
{
// try if text matches the scheme
OUString aScheme( INetURLObject::GetScheme( aCurObj.GetProtocol() ) );
if ( aScheme.startsWithIgnoreAsciiCase( aText ) && aText.getLength() < aScheme.getLength() )
{
if( bFull )
aMatch = aCurObj.GetMainURL( INetURLObject::NO_DECODE );
else
{
aCurObj.SetMark( aEmpty );
aCurObj.SetParam( aEmpty );
aCurObj.SetURLPath( aEmpty );
aMatch = aCurObj.GetMainURL( INetURLObject::NO_DECODE );
}
Insert( aMatch, aMatch );
}
// now try smart matching
aCurString = aCurString.copy( aScheme.getLength() );
}
if( aCurString.startsWithIgnoreAsciiCase( aText ) )
{
if( bFull )
aMatch = aCurObj.GetMainURL( INetURLObject::NO_DECODE );
else
{
aCurObj.SetMark( aEmpty );
aCurObj.SetParam( aEmpty );
aCurObj.SetURLPath( aEmpty );
aMatch = aCurObj.GetMainURL( INetURLObject::NO_DECODE );
}
OUString aURL( aMatch );
if( eProt == INET_PROT_NOT_VALID )
aMatch = aMatch.copy( INetURLObject::GetScheme( aCurObj.GetProtocol() ).getLength() );
if( aText.getLength() < aMatch.getLength() )
Insert( aMatch, aURL );
continue;
}
break;
}
default:
{
if( bFull )
continue;
if( aCurMainURL.startsWith(aText) )
{
if( aText.getLength() < aCurMainURL.getLength() )
Insert( aCurMainURL, aCurMainURL );
continue;
}
break;
}
}
}
if( !bFull )
bFull = true;
else
break;
}
return;
}
void SvtURLBox::TryAutoComplete()
{
if( Application::AnyInput( VCL_INPUT_KEYBOARD ) ) return;
OUString aCurText = GetText();
Selection aSelection( GetSelection() );
if( aSelection.Max() != aCurText.getLength() )
return;
sal_uInt16 nLen = (sal_uInt16)aSelection.Min();
aCurText = aCurText.copy( 0, nLen );
if( !aCurText.isEmpty() && bIsAutoCompleteEnabled )
{
if ( pCtx.is() )
{
pCtx->Stop();
pCtx->join();
pCtx.clear();
}
pCtx = new SvtMatchContext_Impl( this, aCurText );
pCtx->launch();
}
}
SvtURLBox::SvtURLBox( vcl::Window* pParent, INetProtocol eSmart, bool bSetDefaultHelpID )
: ComboBox( pParent , WB_DROPDOWN | WB_AUTOSIZE | WB_AUTOHSCROLL ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( false ),
bOnlyDirectories( false ),
bCtrlClick( false ),
bHistoryDisabled( false ),
bNoSelection( false ),
bIsAutoCompleteEnabled( true )
{
Init(bSetDefaultHelpID);
if ( GetDesktopRectPixel().GetWidth() > 800 )
SetSizePixel( Size( 300, 240 ) );
else
SetSizePixel( Size( 225, 240 ) );
}
SvtURLBox::SvtURLBox( vcl::Window* pParent, WinBits _nStyle, INetProtocol eSmart,
bool bSetDefaultHelpID )
: ComboBox( pParent, _nStyle ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( false ),
bOnlyDirectories( false ),
bCtrlClick( false ),
bHistoryDisabled( false ),
bNoSelection( false ),
bIsAutoCompleteEnabled( true )
{
Init(bSetDefaultHelpID);
}
extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeSvtURLBox(vcl::Window *pParent, VclBuilder::stringmap &)
{
WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP|
WB_DROPDOWN|WB_AUTOSIZE|WB_AUTOHSCROLL;
SvtURLBox* pListBox = new SvtURLBox(pParent, nWinBits, INET_PROT_NOT_VALID, false);
pListBox->EnableAutoSize(true);
return pListBox;
}
SvtURLBox::SvtURLBox( vcl::Window* pParent, const ResId& _rResId, INetProtocol eSmart,
bool bSetDefaultHelpID )
: ComboBox( pParent , _rResId ),
eSmartProtocol( eSmart ),
bAutoCompleteMode( false ),
bOnlyDirectories( false ),
bCtrlClick( false ),
bHistoryDisabled( false ),
bNoSelection( false ),
bIsAutoCompleteEnabled( true )
{
Init(bSetDefaultHelpID);
}
void SvtURLBox::Init(bool bSetDefaultHelpID)
{
pImp = new SvtURLBox_Impl();
2010-11-16 15:00:14 +01:00
if (bSetDefaultHelpID && GetHelpId().isEmpty())
SetHelpId( ".uno:OpenURL" );
EnableAutocomplete( false );
SetText( OUString() );
GetSubEdit()->autocompleteSignal.connect( boost::bind( &SvtURLBox::AutoCompleteHandler, this, _1 ) );
UpdatePicklistForSmartProtocol_Impl();
EnableAutoSize(GetStyle() & WB_AUTOSIZE);
}
SvtURLBox::~SvtURLBox()
{
if( pCtx.is() )
{
pCtx->Stop();
pCtx->join();
}
delete pImp;
}
void SvtURLBox::UpdatePickList( )
{
if( pCtx.is() )
{
pCtx->Stop();
pCtx->join();
pCtx.clear();
}
OUString sText = GetText();
if ( !sText.isEmpty() && bIsAutoCompleteEnabled )
{
pCtx = new SvtMatchContext_Impl( this, sText );
pCtx->launch();
}
}
void SvtURLBox::SetSmartProtocol( INetProtocol eProt )
{
if ( eSmartProtocol != eProt )
{
eSmartProtocol = eProt;
UpdatePicklistForSmartProtocol_Impl();
}
}
void SvtURLBox::UpdatePicklistForSmartProtocol_Impl()
{
Clear();
if ( !bHistoryDisabled )
{
// read history pick list
Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST );
sal_uInt32 nCount = seqPicklist.getLength();
INetURLObject aCurObj;
for( sal_uInt32 nItem=0; nItem < nCount; nItem++ )
{
Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
OUString sURL;
sal_uInt32 nPropertyCount = seqPropertySet.getLength();
for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
{
if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL )
{
seqPropertySet[nProperty].Value >>= sURL;
aCurObj.SetURL( sURL );
if ( !sURL.isEmpty() && ( eSmartProtocol != INET_PROT_NOT_VALID ) )
{
if( aCurObj.GetProtocol() != eSmartProtocol )
break;
}
OUString aURL( aCurObj.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
if ( !aURL.isEmpty() )
{
bool bFound = aURL.endsWith("/");
if ( !bFound )
{
OUString aUpperURL( aURL );
aUpperURL = aUpperURL.toAsciiUpperCase();
bFound
= (::std::find_if(
pImp->m_aFilters.begin(),
pImp->m_aFilters.end(),
FilterMatch( aUpperURL ) )
!= pImp->m_aFilters.end());
}
if ( bFound )
{
OUString aFile;
if (::utl::LocalFileHelper::ConvertURLToSystemPath(aURL,aFile))
InsertEntry(aFile);
else
InsertEntry(aURL);
}
}
break;
}
}
}
}
}
bool SvtURLBox::ProcessKey( const vcl::KeyCode& rKey )
{
// every key input stops the current matching thread
if( pCtx.is() )
{
pCtx->Stop();
pCtx->join();
pCtx.clear();
}
vcl::KeyCode aCode( rKey.GetCode() );
if ( aCode == KEY_RETURN && !GetText().isEmpty() )
{
// wait for completion of matching thread
::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
if ( bAutoCompleteMode )
{
// reset picklist
bAutoCompleteMode = false;
Selection aSelection( GetSelection() );
SetSelection( Selection( aSelection.Min(), aSelection.Min() ) );
if ( bOnlyDirectories )
Clear();
else
UpdatePicklistForSmartProtocol_Impl();
Resize();
}
bCtrlClick = rKey.IsMod1();
bool bHandled = false;
if ( GetOpenHdl().IsSet() )
{
bHandled = true;
GetOpenHdl().Call(this);
}
else if ( GetSelectHdl().IsSet() )
{
bHandled = true;
GetSelectHdl().Call(this);
}
bCtrlClick = false;
ClearModifyFlag();
return bHandled;
}
else if ( aCode == KEY_RETURN && GetText().isEmpty() && GetOpenHdl().IsSet() )
{
// for file dialog
bAutoCompleteMode = false;
GetOpenHdl().Call(this);
return true;
}
else if( aCode == KEY_ESCAPE )
{
Selection aSelection( GetSelection() );
if ( bAutoCompleteMode || aSelection.Min() != aSelection.Max() )
{
SetSelection( Selection( aSelection.Min(), aSelection.Min() ) );
if ( bOnlyDirectories )
Clear();
else
UpdatePicklistForSmartProtocol_Impl();
Resize();
}
else
{
return false;
}
bAutoCompleteMode = false;
return true;
}
else
{
return false;
}
}
void SvtURLBox::Modify()
{
ComboBox::Modify();
}
bool SvtURLBox::PreNotify( NotifyEvent& rNEvt )
{
if( rNEvt.GetWindow() == GetSubEdit() && rNEvt.GetType() == EVENT_KEYINPUT )
{
const KeyEvent& rEvent = *rNEvt.GetKeyEvent();
const vcl::KeyCode& rKey = rEvent.GetKeyCode();
vcl::KeyCode aCode( rKey.GetCode() );
if( ProcessKey( rKey ) )
{
return true;
}
else if( ( aCode == KEY_UP || aCode == KEY_DOWN ) && !rKey.IsMod2() )
{
Selection aSelection( GetSelection() );
sal_uInt16 nLen = (sal_uInt16)aSelection.Min();
GetSubEdit()->KeyInput( rEvent );
SetSelection( Selection( nLen, GetText().getLength() ) );
return true;
}
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
if ( MatchesPlaceHolder( GetText() ) )
{
// set the selection so a key stroke will overwrite
// the placeholder rather than edit it
SetSelection( Selection( 0, GetText().getLength() ) );
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
}
}
return ComboBox::PreNotify( rNEvt );
}
void SvtURLBox::AutoCompleteHandler( Edit* )
{
if ( GetSubEdit()->GetAutocompleteAction() == AUTOCOMPLETE_KEYINPUT )
TryAutoComplete();
}
bool SvtURLBox::Notify( NotifyEvent &rEvt )
{
if ( EVENT_GETFOCUS == rEvt.GetType() )
{
#ifndef UNX
// pb: don't select automatically on unix #93251#
SetSelection( Selection( 0, GetText().getLength() ) );
#endif
}
else if ( EVENT_LOSEFOCUS == rEvt.GetType() )
{
if( GetText().isEmpty() )
ClearModifyFlag();
if ( pCtx.is() )
{
pCtx->Stop();
pCtx->join();
pCtx.clear();
}
}
return ComboBox::Notify( rEvt );
}
void SvtURLBox::Select()
{
ComboBox::Select();
ClearModifyFlag();
}
void SvtURLBox::SetOnlyDirectories( bool bDir )
{
bOnlyDirectories = bDir;
if ( bOnlyDirectories )
Clear();
}
void SvtURLBox::SetNoURLSelection( bool bSet )
{
bNoSelection = bSet;
}
OUString SvtURLBox::GetURL()
{
// wait for end of autocompletion
::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
OUString aText( GetText() );
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
if ( MatchesPlaceHolder( aText ) )
return aPlaceHolder;
2012-01-11 20:46:25 -05:00
// try to get the right case preserving URL from the list of URLs
for(std::vector<OUString>::iterator i = pImp->aCompletions.begin(), j = pImp->aURLs.begin(); i != pImp->aCompletions.end() && j != pImp->aURLs.end(); ++i, ++j)
{
2012-01-11 20:46:25 -05:00
if((*i).equals(aText))
return *j;
}
#ifdef WNT
// erase trailing spaces on Windows since thay are invalid on this OS and
// most of the time they are inserted by accident via copy / paste
aText = comphelper::string::stripEnd(aText, ' ');
if ( aText.isEmpty() )
return aText;
// #i9739#
#endif
INetURLObject aObj( aText );
if( aText.indexOf( '*' ) != -1 || aText.indexOf( '?' ) != -1 )
{
// no autocompletion for wildcards
INetURLObject aTempObj;
if ( eSmartProtocol != INET_PROT_NOT_VALID )
aTempObj.SetSmartProtocol( eSmartProtocol );
if ( aTempObj.SetSmartURL( aText ) )
return aTempObj.GetMainURL( INetURLObject::NO_DECODE );
else
return aText;
}
if ( aObj.GetProtocol() == INET_PROT_NOT_VALID )
{
OUString aName = ParseSmart( aText, aBaseURL, SvtPathOptions().GetWorkPath() );
aObj.SetURL(aName);
OUString aURL( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
if ( aURL.isEmpty() )
// aText itself is invalid, and even together with aBaseURL, it could not
// made valid -> no chance
return aText;
bool bSlash = aObj.hasFinalSlash();
{
const OUString aPropName("CasePreservingURL");
OUString aFileURL;
Any aAny = UCBContentHelper::GetProperty(aURL, aPropName);
bool success = (aAny >>= aFileURL);
OUString aTitle;
if(success)
aTitle = INetURLObject(aFileURL).getName(
INetURLObject::LAST_SEGMENT,
true,
INetURLObject::DECODE_WITH_CHARSET );
else
success =
2011-11-28 10:09:57 +01:00
UCBContentHelper::GetTitle(aURL,&aTitle);
if( success && aTitle != "/" && aTitle != "." )
{
aObj.SetName( aTitle );
if ( bSlash )
aObj.setFinalSlash();
}
}
}
return aObj.GetMainURL( INetURLObject::NO_DECODE );
}
void SvtURLBox::DisableHistory()
{
bHistoryDisabled = true;
UpdatePicklistForSmartProtocol_Impl();
}
void SvtURLBox::SetBaseURL( const OUString& rURL )
{
::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() );
// Reset match lists
2012-01-11 20:46:25 -05:00
pImp->aCompletions.clear();
pImp->aURLs.clear();
aBaseURL = rURL;
}
/** Parse leading ~ for Unix systems,
does nothing for Windows
*/
bool SvtURLBox_Impl::TildeParsing(
OUString&
#ifdef UNX
aText
#endif
, OUString&
#ifdef UNX
aBaseURL
#endif
)
{
#ifdef UNX
if( aText.startsWith( "~" ) )
{
OUString aParseTilde;
bool bTrailingSlash = true; // use trailing slash
if( aText.getLength() == 1 || aText[ 1 ] == '/' )
{
// covers "~" or "~/..." cases
const char* aHomeLocation = getenv( "HOME" );
if( !aHomeLocation )
aHomeLocation = "";
aParseTilde = OUString::createFromAscii(aHomeLocation);
// in case the whole path is just "~" then there should
// be no trailing slash at the end
if( aText.getLength() == 1 )
bTrailingSlash = false;
}
else
{
// covers "~username" and "~username/..." cases
sal_Int32 nNameEnd = aText.indexOf( '/' );
OUString aUserName = aText.copy( 1, ( nNameEnd != -1 ) ? nNameEnd : ( aText.getLength() - 1 ) );
struct passwd* pPasswd = NULL;
#ifdef SOLARIS
Sequence< sal_Int8 > sBuf( 1024 );
struct passwd aTmp;
sal_Int32 nRes = getpwnam_r( OUStringToOString( aUserName, RTL_TEXTENCODING_ASCII_US ).getStr(),
&aTmp,
(char*)sBuf.getArray(),
1024,
&pPasswd );
if( !nRes && pPasswd )
aParseTilde = OUString::createFromAscii(pPasswd->pw_dir);
else
return false; // no such user
#else
pPasswd = getpwnam( OUStringToOString( aUserName, RTL_TEXTENCODING_ASCII_US ).getStr() );
2010-08-27 13:46:58 +02:00
if( pPasswd )
aParseTilde = OUString::createFromAscii(pPasswd->pw_dir);
else
return false; // no such user
#endif
// in case the path is "~username" then there should
// be no trailing slash at the end
if( nNameEnd == -1 )
bTrailingSlash = false;
}
if( !bTrailingSlash )
{
if( aParseTilde.isEmpty() || aParseTilde == "/" )
{
// "/" path should be converted to "/."
aParseTilde = "/.";
}
else
{
// "blabla/" path should be converted to "blabla"
aParseTilde = comphelper::string::stripEnd(aParseTilde, '/');
}
}
else
{
if( !aParseTilde.endsWith("/") )
aParseTilde += "/";
if( aText.getLength() > 2 )
aParseTilde += aText.copy( 2 );
}
aText = aParseTilde;
aBaseURL = ""; // tilde provide absolute path
}
#endif
return true;
}
void SvtURLBox::SetFilter(const OUString& _sFilter)
{
pImp->m_aFilters.clear();
FilterMatch::createWildCardFilterList(_sFilter,pImp->m_aFilters);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */