Kaydet (Commit) c37f4bb9 authored tarafından Mikhail Voitenko's avatar Mikhail Voitenko

#112739# add breakLink method

üst c606cf90
......@@ -2,9 +2,9 @@
*
* $RCSfile: miscobj.cxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mav $ $Date: 2003-10-27 12:57:29 $
* last change: $Author: mav $ $Date: 2003-11-04 14:30:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -236,6 +236,7 @@ uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType
static_cast< embed::XEmbeddedObject* >( this ),
static_cast< embed::XVisualObject* >( this ),
static_cast< embed::XEmbedPersist* >( this ),
static_cast< embed::XLinkageSupport* >( this ),
static_cast< embed::XClassifiedObject* >( this ),
static_cast< embed::XComponentSupplier* >( this ),
static_cast< document::XEventBroadcaster* >( this ) );
......@@ -277,6 +278,7 @@ uno::Sequence< uno::Type > SAL_CALL OCommonEmbeddedObject::getTypes()
::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ),
::getCppuType( (const uno::Reference< embed::XVisualObject >*)NULL ),
::getCppuType( (const uno::Reference< embed::XEmbedPersist >*)NULL ),
::getCppuType( (const uno::Reference< embed::XLinkageSupport >*)NULL ),
::getCppuType( (const uno::Reference< embed::XClassifiedObject >*)NULL ),
::getCppuType( (const uno::Reference< embed::XComponentSupplier >*)NULL ),
::getCppuType( (const uno::Reference< document::XEventBroadcaster >*)NULL ) );
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: persistence.cxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mav $ $Date: 2003-10-27 12:57:29 $
* last change: $Author: mav $ $Date: 2003-11-04 14:30:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -499,7 +499,7 @@ uno::Reference< frame::XModel > OCommonEmbeddedObject::CreateTempDocFromLink_Imp
}
//------------------------------------------------------
void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
sal_Bool SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
const uno::Reference< embed::XStorage >& xStorage,
const ::rtl::OUString& sEntName,
sal_Int32 nEntryConnectionMode,
......@@ -593,36 +593,9 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
if ( nEntryConnectionMode == embed::EntryInitModes::ENTRY_NO_INIT )
{
// the document just already changed its storage to store to
// the links to OOo documents will ignore this call and return false
if ( m_bIsLink )
{
// for linked object it means that it becomes embedded object
// the document must switch it's persistence also
// the document is a new embedded object so it must be marked as modified
uno::Reference< frame::XModel > xDocument = CreateTempDocFromLink_Impl();
uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetDocument(), uno::UNO_QUERY );
if ( !xModif.is() )
throw uno::RuntimeException();
try
{
xModif->setModified( sal_True );
}
catch( uno::Exception& )
{}
m_pDocHolder->SetDocument( xDocument, m_bReadOnly );
OSL_ENSURE( m_pDocHolder->GetDocument().is(), "If document cant be created, an exception must be thrown!\n" );
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
m_nObjectState = embed::EmbedStates::EMBED_RUNNING;
else if ( m_nObjectState == embed::EmbedStates::EMBED_ACTIVE )
m_pDocHolder->Show();
m_bIsLink = sal_False;
m_aLinkFilterName = ::rtl::OUString();
m_aLinkURL = ::rtl::OUString();
}
return sal_False;
}
else if ( nEntryConnectionMode == embed::EntryInitModes::ENTRY_TRUNCATE_INIT )
{
......@@ -648,6 +621,8 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
3 );
}
return sal_True;
}
//------------------------------------------------------
......@@ -961,6 +936,88 @@ void SAL_CALL OCommonEmbeddedObject::reload(
// use meaningfull part of lArguments
}
//------------------------------------------------------
void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XStorage >& xStorage,
const ::rtl::OUString& sEntName )
throw ( lang::IllegalArgumentException,
embed::WrongStateException,
io::IOException,
uno::Exception,
uno::RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
if ( !xStorage.is() )
throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "No parent storage is provided!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
1 );
if ( !sEntName.getLength() )
throw lang::IllegalArgumentException( ::rtl::OUString::createFromAscii( "Empty element name is provided!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ),
2 );
if ( !m_bIsLink || m_nObjectState == -1 )
{
// it must be a linked initialized object
throw embed::WrongStateException(
::rtl::OUString::createFromAscii( "The object is not a valid linked object!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
}
if ( m_bWaitSaveCompleted )
throw embed::WrongStateException(
::rtl::OUString::createFromAscii( "The object waits for saveCompleted() call!\n" ),
uno::Reference< uno::XInterface >( reinterpret_cast< ::cppu::OWeakObject* >(this) ) );
uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY );
if ( !xNameAccess.is() )
throw uno::RuntimeException(); //TODO
// detect entry existence
sal_Bool bElExists = xNameAccess->hasByName( sEntName );
m_bReadOnly = sal_False;
sal_Int32 nStorageMode = embed::ElementModes::ELEMENT_READWRITE;
m_xObjectStorage = xStorage->openStorageElement( sEntName, nStorageMode );
m_xParentStorage = xStorage;
m_aEntryName = sEntName;
// the object should be based on the storage ??? TODO
if ( bElExists && !xStorage->isStorageElement( sEntName ) )
throw io::IOException(); // TODO access denied
// for linked object it means that it becomes embedded object
// the document must switch it's persistence also
// the document is a new embedded object so it must be marked as modified
uno::Reference< frame::XModel > xDocument = CreateTempDocFromLink_Impl();
uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetDocument(), uno::UNO_QUERY );
if ( !xModif.is() )
throw uno::RuntimeException();
try
{
xModif->setModified( sal_True );
}
catch( uno::Exception& )
{}
m_pDocHolder->SetDocument( xDocument, m_bReadOnly );
OSL_ENSURE( m_pDocHolder->GetDocument().is(), "If document cant be created, an exception must be thrown!\n" );
if ( m_nObjectState == embed::EmbedStates::EMBED_LOADED )
m_nObjectState = embed::EmbedStates::EMBED_RUNNING;
else if ( m_nObjectState == embed::EmbedStates::EMBED_ACTIVE )
m_pDocHolder->Show();
m_bIsLink = sal_False;
m_aLinkFilterName = ::rtl::OUString();
m_aLinkURL = ::rtl::OUString();
}
//------------------------------------------------------
sal_Bool SAL_CALL OCommonEmbeddedObject::isLink()
throw ( embed::WrongStateException,
......@@ -980,9 +1037,9 @@ sal_Bool SAL_CALL OCommonEmbeddedObject::isLink()
//------------------------------------------------------
::rtl::OUString SAL_CALL OCommonEmbeddedObject::getLinkURL()
throw ( ::com::sun::star::embed::WrongStateException,
::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException)
throw ( embed::WrongStateException,
uno::Exception,
uno::RuntimeException )
{
::osl::MutexGuard aGuard( m_aMutex );
if ( m_bDisposed )
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: commonembobj.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mav $ $Date: 2003-10-27 13:00:38 $
* last change: $Author: mav $ $Date: 2003-11-04 14:30:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -326,7 +326,7 @@ public:
// XEmbedPersist
virtual void SAL_CALL setPersistentEntry(
virtual sal_Bool SAL_CALL setPersistentEntry(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
const ::rtl::OUString& sEntName,
sal_Int32 nEntryConnectionMode,
......@@ -387,6 +387,14 @@ public:
// XLinkageSupport
virtual void SAL_CALL breakLink( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
const ::rtl::OUString& sEntName )
throw ( ::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::embed::WrongStateException,
::com::sun::star::io::IOException,
::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException );
virtual sal_Bool SAL_CALL isLink()
throw ( ::com::sun::star::embed::WrongStateException,
::com::sun::star::uno::RuntimeException);
......
......@@ -617,18 +617,17 @@ public class EmbedContApp extends Applet implements MouseListener, XEmbeddedClie
if ( xNameAccess != null && xNameAccess.hasByName( "LinkName" ) )
m_xStorage.removeElement( "LinkName" );
XEmbedPersist xPersist = (XEmbedPersist)UnoRuntime.queryInterface( XEmbedPersist.class,
m_xEmbedObj );
if ( xPersist != null )
XLinkageSupport xLinkage = (XLinkageSupport)UnoRuntime.queryInterface( XLinkageSupport.class,
m_xEmbedObj );
if ( xLinkage != null )
{
PropertyValue[] pEmp = new PropertyValue[0];
xPersist.setPersistentEntry( m_xStorage, "EmbedSub", EntryInitModes.ENTRY_NO_INIT, pEmp );
xLinkage.breakLink( m_xStorage, "EmbedSub" );
m_bLinkObj = false;
m_aLinkURI = null;
}
else
JOptionPane.showMessageDialog( m_aFrame,
"No XEmbedPersist in ConvertLink... !",
"No XLinkageSupport in ConvertLink... !",
"Error:",
JOptionPane.ERROR_MESSAGE );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment