diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-23 08:29:44 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-23 10:28:38 +0100 |
commit | 3982ce50f9845189373dac48d52d6070f6366a4f (patch) | |
tree | 34f8d5de5ad265095857e207006bcda273f26d85 | |
parent | 249107f62cbe4b4e145bd6e62bfb9960dc0cdb60 (diff) |
svt: All files are compiled with enabled exception handling.
So, merge these files.
Change-Id: Icc8e221a40c70dc24a9fb048e06cf4fe7635fd02
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/source/control/filectrl.cxx | 54 | ||||
-rw-r--r-- | svtools/source/control/filectrl2.cxx | 75 |
3 files changed, 53 insertions, 77 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 915c5b87bd59..47628080b2c3 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -111,7 +111,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/control/ctrlbox \ svtools/source/control/ctrltool \ svtools/source/control/filectrl \ - svtools/source/control/filectrl2 \ svtools/source/control/fileurlbox \ svtools/source/control/fmtfield \ svtools/source/control/headbar \ diff --git a/svtools/source/control/filectrl.cxx b/svtools/source/control/filectrl.cxx index f605f8a8ab59..8b9aedc851ae 100644 --- a/svtools/source/control/filectrl.cxx +++ b/svtools/source/control/filectrl.cxx @@ -17,10 +17,21 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <svtools/svtresid.hxx> #include <svtools/filectrl.hxx> + +#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <comphelper/processfactory.hxx> +#include <osl/file.h> +#include <svtools/svtresid.hxx> +#include <tools/urlobj.hxx> +#include <vcl/stdtext.hxx> #include <filectrl.hrc> +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::ui; + // ======================================================================= FileControl::FileControl( Window* pParent, WinBits nStyle, FileControlMode nFlags ) : @@ -197,4 +208,45 @@ void FileControl::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize GetEdit().SetStyle( nOldEditStyle ); } +void FileControl::ImplBrowseFile( ) +{ + try + { + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); + Reference < dialogs::XFilePicker3 > xFilePicker = dialogs::FilePicker::createWithMode( xContext, dialogs::TemplateDescription::FILEOPEN_SIMPLE ); + // transform the system notation text into a file URL + OUString sSystemNotation = GetText(), sFileURL; + oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData ); + if ( nError == osl_File_E_INVAL ) + sFileURL = GetText(); // #97709# Maybe URL is already a file URL... + + //#90430# Check if URL is really a file URL + OUString aTmp; + if ( osl_getSystemPathFromFileURL( sFileURL.pData, &aTmp.pData ) == osl_File_E_None ) + { + // initially set this directory + xFilePicker->setDisplayDirectory( sFileURL ); + } + + if ( xFilePicker->execute() ) + { + Sequence < OUString > aPathSeq = xFilePicker->getFiles(); + + if ( aPathSeq.getLength() ) + { + OUString aNewText = aPathSeq[0]; + INetURLObject aObj( aNewText ); + if ( aObj.GetProtocol() == INET_PROT_FILE ) + aNewText = aObj.PathToFileName(); + SetText( aNewText ); + maEdit.GetModifyHdl().Call( &maEdit ); + } + } + } + catch( const Exception& ) + { + OSL_FAIL( "FileControl::ImplBrowseFile: caught an exception while executing the file picker!" ); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/filectrl2.cxx b/svtools/source/control/filectrl2.cxx deleted file mode 100644 index 01a21625aeb3..000000000000 --- a/svtools/source/control/filectrl2.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - - -// this file contains code from filectrl.cxx which needs to be compiled with enabled exception hanling -#include <svtools/filectrl.hxx> -#include <com/sun/star/ui/dialogs/FilePicker.hpp> -#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> -#include <comphelper/processfactory.hxx> -#include <tools/urlobj.hxx> -#include <osl/file.h> -#include <vcl/stdtext.hxx> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::ui; - -void FileControl::ImplBrowseFile( ) -{ - try - { - Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); - Reference < dialogs::XFilePicker3 > xFilePicker = dialogs::FilePicker::createWithMode( xContext, dialogs::TemplateDescription::FILEOPEN_SIMPLE ); - // transform the system notation text into a file URL - OUString sSystemNotation = GetText(), sFileURL; - oslFileError nError = osl_getFileURLFromSystemPath( sSystemNotation.pData, &sFileURL.pData ); - if ( nError == osl_File_E_INVAL ) - sFileURL = GetText(); // #97709# Maybe URL is already a file URL... - - //#90430# Check if URL is really a file URL - OUString aTmp; - if ( osl_getSystemPathFromFileURL( sFileURL.pData, &aTmp.pData ) == osl_File_E_None ) - { - // initially set this directory - xFilePicker->setDisplayDirectory( sFileURL ); - } - - if ( xFilePicker->execute() ) - { - Sequence < OUString > aPathSeq = xFilePicker->getFiles(); - - if ( aPathSeq.getLength() ) - { - OUString aNewText = aPathSeq[0]; - INetURLObject aObj( aNewText ); - if ( aObj.GetProtocol() == INET_PROT_FILE ) - aNewText = aObj.PathToFileName(); - SetText( aNewText ); - maEdit.GetModifyHdl().Call( &maEdit ); - } - } - } - catch( const Exception& ) - { - OSL_FAIL( "FileControl::ImplBrowseFile: caught an exception while executing the file picker!" ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |