tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / connectivity / source / drivers / hsqldb / StorageFileAccess.cxx
blobbb07d6673fb1b09f3242f1da254b5f15647755de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 #include <com/sun/star/embed/XStorage.hpp>
25 #include <com/sun/star/lang/IllegalArgumentException.hpp>
26 #include <hsqldb/HStorageMap.hxx>
27 #include <comphelper/diagnose_ex.hxx>
29 using namespace ::com::sun::star::container;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::embed;
32 using namespace ::com::sun::star::io;
33 using namespace ::com::sun::star::lang;
34 using namespace ::connectivity::hsqldb;
37 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
38 * Method: isStreamElement
39 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
41 extern "C" SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
42 (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
44 TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
45 auto storage = aStoragePair.mapStorage();
46 if ( !storage )
47 return JNI_FALSE;
49 try
51 OUString sName = StorageContainer::jstring2ustring(env,name);
52 try
54 OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
55 if ( storage->isStreamElement(sOldName) )
57 try
59 storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url));
61 catch(const Exception&)
66 catch(const NoSuchElementException&)
69 catch(const IllegalArgumentException&)
72 return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url));
74 catch(const NoSuchElementException&)
77 catch(const Exception&)
79 TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "forwarding");
80 if (env->ExceptionCheck())
81 env->ExceptionClear();
83 return JNI_FALSE;
88 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
89 * Method: removeElement
90 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
92 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
93 (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
95 #ifdef HSQLDB_DBG
97 OUString sKey = StorageContainer::jstring2ustring(env,key);
98 OUString sName = StorageContainer::jstring2ustring(env,name);
100 #endif
101 TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
102 auto storage = aStoragePair.mapStorage();
103 if ( !storage.is() )
104 return;
108 storage->removeElement(StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,name),aStoragePair.url));
110 catch(const NoSuchElementException&)
112 if (env->ExceptionCheck())
113 env->ExceptionClear();
115 catch(const Exception& e)
117 TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "");
118 StorageContainer::throwJavaException(e,env);
124 * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
125 * Method: renameElement
126 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
128 extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
129 (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring oldname, jstring newname)
131 #ifdef HSQLDB_DBG
133 OUString sKey = StorageContainer::jstring2ustring(env,key);
134 OUString sNewName = StorageContainer::jstring2ustring(env,newname);
135 OUString sOldName = StorageContainer::jstring2ustring(env,oldname);
137 #endif
138 TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
139 auto storage = aStoragePair.mapStorage();
140 if ( !storage.is() )
141 return;
145 storage->renameElement(
146 StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,oldname),aStoragePair.url),
147 StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.url)
149 #ifdef HSQLDB_DBG
151 OUString sNewName = StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second);
152 OSL_ENSURE(aStoragePair.first.first->isStreamElement(sNewName),"Stream could not be renamed");
154 #endif
156 catch(const NoSuchElementException&)
159 catch(const Exception& e)
161 TOOLS_WARN_EXCEPTION( "connectivity.hsqldb", "Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement");
162 StorageContainer::throwJavaException(e,env);
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */