1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SVX_DATABASELOCATIONINPUT_HXX 21 #define INCLUDED_SVX_DATABASELOCATIONINPUT_HXX 22 23 #include <svx/svxdllapi.h> 24 #include <rtl/ustring.hxx> 25 26 #include <memory> 27 28 class PushButton; 29 30 class URLBox; 31 namespace weld { class Button; class Window; } 32 namespace com::sun::star::uno { class XComponentContext; } 33 namespace com::sun::star::uno { template <typename > class Reference; } 34 35 namespace svx 36 { 37 //= DatabaseLocationInputController 38 class DatabaseLocationInputController_Impl; 39 /** helper class to control controls needed to input a database location 40 41 If you allow, in your dialog, to save a database document, then you usually 42 have an URLBox for inputting the actual location, and a push button 43 to browse for a location. 44 45 This helper class controls such two UI elements. 46 */ 47 class SAL_WARN_UNUSED SVX_DLLPUBLIC DatabaseLocationInputController 48 { 49 public: 50 DatabaseLocationInputController( 51 const css::uno::Reference<css::uno::XComponentContext>& _rContext, 52 URLBox& _rLocationInput, 53 weld::Button& _rBrowseButton, 54 weld::Window& _rDialog 55 ); 56 ~DatabaseLocationInputController(); 57 58 /** sets the given URL at the input control, after translating it into a system path 59 */ 60 void setURL( const OUString& _rURL ); 61 62 /** returns the current database location, in form of a URL (not a system path) 63 */ 64 OUString getURL() const; 65 66 /** prepares committing the database location entered in the input field 67 68 Effectively, this method checks whether the file in the location already 69 exists, and if so, it asks the user whether to overwrite it. 70 71 If the method is called multiple times, this check only happens when the location 72 changed since the last call. 73 */ 74 bool prepareCommit(); 75 76 private: 77 ::std::unique_ptr< DatabaseLocationInputController_Impl > 78 m_pImpl; 79 }; 80 } 81 82 #endif // INCLUDED_SVX_DATABASELOCATIONINPUT_HXX 83 84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 85