/* -*- 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 .
*/
using css::uno::Reference; using css::uno::UNO_QUERY; using css::uno::UNO_QUERY_THROW; using css::uno::UNO_SET_THROW; using css::uno::Exception; using css::uno::Sequence; using css::uno::XComponentContext; using css::embed::XStorage; using css::frame::XController; using css::sdb::application::XDatabaseDocumentUI; using css::lang::XComponent; using css::io::XStream; using css::io::TextInputStream; using css::io::XTextInputStream2; using css::util::XModifiable;
// create a sub storage for recovery data if ( i_rTargetStorage->hasByName( sRecoveryDataSubStorageName ) )
i_rTargetStorage->removeElement( sRecoveryDataSubStorageName );
Reference< XStorage > xRecoveryStorage = i_rTargetStorage->openStorageElement( sRecoveryDataSubStorageName, ElementModes::READWRITE );
// store recovery data for open sub components of the given controller(s) if ( !i_rControllers.empty() )
{
ENSURE_OR_THROW( i_rControllers.size() == 1, "can't handle more than one controller"); // At the moment, there can be only one view to a database document. If we ever allow for more than this, // then we need a concept for sub documents opened from different controllers (i.e. two document views, // and the user opens the very same form in both views). And depending on this, we need a concept for // how those are saved to the recovery file.
// recover all sub components as indicated by the map for (autoconst& elemMapCompDescs : aMapCompDescs)
{ const SubComponentType eComponentType = elemMapCompDescs.first;
// the storage for all components of the current type
Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement(
SubComponentRecovery::getComponentsStorageName( eComponentType ), ElementModes::READ ), UNO_SET_THROW );
// loop through all components of this type for (autoconst& elem : elemMapCompDescs.second)
{ const OUString sComponentName(elem.second.sName); if ( !xComponentsStor->hasByName(elem.first) )
{
SAL_WARN( "dbaccess", "DatabaseDocumentRecovery::recoverSubDocuments: inconsistent recovery storage: storage '" <<
elem.first << "' not found in '" <<
SubComponentRecovery::getComponentsStorageName( eComponentType ) << "', but required per map file!" ); continue;
}
// the controller needs to have a connection to be able to open sub components if ( !xDocumentUI->isConnected() )
xDocumentUI->connect();
// at the moment, we only store, during session save, sub components which are modified. So, set this // recovered sub component to "modified", too.
lcl_markModified( xSubComponent );
}
xComponentsStor->dispose();
}
xRecoveryStorage->dispose();
// now that we successfully recovered, removed the "recovery" sub storage try
{
i_rDocumentStorage->removeElement( sRecoveryDataSubStorageName );
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.