[Libreoffice-commits] core.git: sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri May 15 03:23:12 PDT 2015
sw/source/uibase/dbui/dbmgr.cxx | 178 ++++++++++++++++++++--------------------
1 file changed, 89 insertions(+), 89 deletions(-)
New commits:
commit f5c6a14de565c34b581e99508f5ce0454134f7f1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 15 12:20:18 2015 +0200
SwDBManager::LoadAndRegisterDataSource: fix indentation
Change-Id: I62645c02c556cb52d53e76c93ae17b41dfd43820
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 3f81f2e..abb06f5b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2515,104 +2515,104 @@ SwDBManager::DBConnURITypes SwDBManager::GetDBunoURI(const OUString &rURI, Any &
OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const Any &aURLAny, const uno::Reference< beans::XPropertySet > *pSettings,
const OUString &rURI, const OUString *pPrefix, const OUString *pDestDir)
{
- INetURLObject aURL( rURI );
- OUString sExt( aURL.GetExtension() );
- Any aTableFilterAny;
- Any aSuppressVersionsAny;
- Any aInfoAny;
- bool bStore = true;
- OUString sFind;
- Sequence<OUString> aFilters(1);
-
- switch (type) {
- case DBCONN_UNKNOWN:
- case DBCONN_CALC:
- break;
- case DBCONN_ODB:
- bStore = false;
- break;
- case DBCONN_FLAT:
- case DBCONN_DBASE:
- //set the filter to the file name without extension
- aFilters[0] = aURL.getBase();
- aTableFilterAny <<= aFilters;
- break;
- case DBCONN_MSJET:
- case DBCONN_MSACE:
- aSuppressVersionsAny <<= makeAny(true);
- break;
- }
-
- try
- {
- Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
- Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
+ INetURLObject aURL( rURI );
+ OUString sExt( aURL.GetExtension() );
+ Any aTableFilterAny;
+ Any aSuppressVersionsAny;
+ Any aInfoAny;
+ bool bStore = true;
+ OUString sFind;
+ Sequence<OUString> aFilters(1);
- OUString sNewName = INetURLObject::decode( aURL.getName(),
- INetURLObject::DECODE_UNAMBIGUOUS,
- RTL_TEXTENCODING_UTF8 );
- sal_Int32 nExtLen = aURL.GetExtension().getLength();
- sNewName = sNewName.replaceAt( sNewName.getLength() - nExtLen - 1, nExtLen + 1, "" );
- if (pPrefix)
- sNewName = *pPrefix + sNewName;
+ switch (type) {
+ case DBCONN_UNKNOWN:
+ case DBCONN_CALC:
+ break;
+ case DBCONN_ODB:
+ bStore = false;
+ break;
+ case DBCONN_FLAT:
+ case DBCONN_DBASE:
+ //set the filter to the file name without extension
+ aFilters[0] = aURL.getBase();
+ aTableFilterAny <<= aFilters;
+ break;
+ case DBCONN_MSJET:
+ case DBCONN_MSACE:
+ aSuppressVersionsAny <<= makeAny(true);
+ break;
+ }
- //find a unique name if sNewName already exists
+ try
+ {
+ Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+ Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
+
+ OUString sNewName = INetURLObject::decode( aURL.getName(),
+ INetURLObject::DECODE_UNAMBIGUOUS,
+ RTL_TEXTENCODING_UTF8 );
+ sal_Int32 nExtLen = aURL.GetExtension().getLength();
+ sNewName = sNewName.replaceAt( sNewName.getLength() - nExtLen - 1, nExtLen + 1, "" );
+ if (pPrefix)
+ sNewName = *pPrefix + sNewName;
+
+ //find a unique name if sNewName already exists
+ sFind = sNewName;
+ sal_Int32 nIndex = 0;
+ while(xDBContext->hasByName(sFind))
+ {
sFind = sNewName;
- sal_Int32 nIndex = 0;
- while(xDBContext->hasByName(sFind))
- {
- sFind = sNewName;
- sFind += OUString::number(++nIndex);
- }
+ sFind += OUString::number(++nIndex);
+ }
- Reference<XInterface> xNewInstance;
- if(!bStore)
+ Reference<XInterface> xNewInstance;
+ if(!bStore)
+ {
+ //odb-file
+ Any aDataSource = xDBContext->getByName(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ aDataSource >>= xNewInstance;
+ }
+ else
+ {
+ xNewInstance = xDBContext->createInstance();
+ Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
+
+ if(aURLAny.hasValue())
+ xDataProperties->setPropertyValue("URL", aURLAny);
+ if(aTableFilterAny.hasValue())
+ xDataProperties->setPropertyValue("TableFilter", aTableFilterAny);
+ if(aSuppressVersionsAny.hasValue())
+ xDataProperties->setPropertyValue("SuppressVersionColumns", aSuppressVersionsAny);
+ if(aInfoAny.hasValue())
+ xDataProperties->setPropertyValue("Info", aInfoAny);
+
+ if( DBCONN_FLAT == type && pSettings )
{
- //odb-file
- Any aDataSource = xDBContext->getByName(aURL.GetMainURL(INetURLObject::NO_DECODE));
- aDataSource >>= xNewInstance;
+ uno::Any aSettings = xDataProperties->getPropertyValue( "Settings" );
+ uno::Reference < beans::XPropertySet > xDSSettings;
+ aSettings >>= xDSSettings;
+ ::comphelper::copyProperties( *pSettings, xDSSettings );
+ xDSSettings->setPropertyValue( "Extension", uno::makeAny( sExt ));
}
- else
- {
- xNewInstance = xDBContext->createInstance();
- Reference<XPropertySet> xDataProperties(xNewInstance, UNO_QUERY);
-
- if(aURLAny.hasValue())
- xDataProperties->setPropertyValue("URL", aURLAny);
- if(aTableFilterAny.hasValue())
- xDataProperties->setPropertyValue("TableFilter", aTableFilterAny);
- if(aSuppressVersionsAny.hasValue())
- xDataProperties->setPropertyValue("SuppressVersionColumns", aSuppressVersionsAny);
- if(aInfoAny.hasValue())
- xDataProperties->setPropertyValue("Info", aInfoAny);
-
- if( DBCONN_FLAT == type && pSettings )
- {
- uno::Any aSettings = xDataProperties->getPropertyValue( "Settings" );
- uno::Reference < beans::XPropertySet > xDSSettings;
- aSettings >>= xDSSettings;
- ::comphelper::copyProperties( *pSettings, xDSSettings );
- xDSSettings->setPropertyValue( "Extension", uno::makeAny( sExt ));
- }
- Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
- Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
- OUString sOutputExt = ".odb";
- OUString sTmpName;
- {
- OUString sHomePath(SvtPathOptions().GetWorkPath());
- utl::TempFile aTempFile(sNewName, true, &sOutputExt, pDestDir ? pDestDir : &sHomePath);
- aTempFile.EnableKillingFile(true);
- sTmpName = aTempFile.GetURL();
- }
- xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
+ Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
+ Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW);
+ OUString sOutputExt = ".odb";
+ OUString sTmpName;
+ {
+ OUString sHomePath(SvtPathOptions().GetWorkPath());
+ utl::TempFile aTempFile(sNewName, true, &sOutputExt, pDestDir ? pDestDir : &sHomePath);
+ aTempFile.EnableKillingFile(true);
+ sTmpName = aTempFile.GetURL();
}
- xDBContext->registerObject( sFind, xNewInstance );
- }
- catch(const Exception&)
- {
- sFind.clear();
+ xStore->storeAsURL(sTmpName, Sequence< PropertyValue >());
}
+ xDBContext->registerObject( sFind, xNewInstance );
+ }
+ catch(const Exception&)
+ {
+ sFind.clear();
+ }
return sFind;
}
More information about the Libreoffice-commits
mailing list