summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2003-11-04 13:30:21 +0000
committerMikhail Voitenko <mav@openoffice.org>2003-11-04 13:30:21 +0000
commitc37f4bb94a119e4031796c097a35c1217e221e6c (patch)
tree286a47c0866e78782812c9d3cffabb3188c2ec3b
parentc606cf901739b73ddd9ec45a57f3d9c95f305f99 (diff)
#112739# add breakLink method
-rw-r--r--embeddedobj/source/commonembedding/miscobj.cxx6
-rw-r--r--embeddedobj/source/commonembedding/persistence.cxx127
-rw-r--r--embeddedobj/source/inc/commonembobj.hxx14
-rw-r--r--embeddedobj/test/Container1/EmbedContApp.java11
4 files changed, 112 insertions, 46 deletions
diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index 36540d7f5681..0dd1a2321b3a 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -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 ) );
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index 55985fe6652d..24bbea1f3e19 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -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;
}
//------------------------------------------------------
@@ -962,6 +937,88 @@ void SAL_CALL OCommonEmbeddedObject::reload(
}
//------------------------------------------------------
+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,
uno::RuntimeException )
@@ -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 )
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 12cc35a5c6e2..c0046f60e039 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -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);
diff --git a/embeddedobj/test/Container1/EmbedContApp.java b/embeddedobj/test/Container1/EmbedContApp.java
index d6fd81c2e55c..e8e1084dc987 100644
--- a/embeddedobj/test/Container1/EmbedContApp.java
+++ b/embeddedobj/test/Container1/EmbedContApp.java
@@ -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 );
}