summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-14 12:55:05 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-14 12:55:05 +0100
commit16dacff35f047b4acb5ea594ed01e9ce76fc525e (patch)
tree885e3cfc3753249559a84d55bedafd667b25202b /sfx2/source
parent3df3758bd64435d207ccc1aff7d9aba4466a3095 (diff)
autorecovery: replace some SfxFrameItem occurences by SfxUnoFrameItem
As a consequence, replace some occurences of SfxFrame with XFrame. This allows getting rid of yet some more Sfx code in the (SFX) doc loader. Also, it prevents premature creations of SfxFrame instances during loading, since now the frame is really created when it is needed only.
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/appl/appopen.cxx48
-rw-r--r--sfx2/source/appl/appserv.cxx15
-rw-r--r--sfx2/source/appl/appuno.cxx22
-rw-r--r--sfx2/source/control/unoctitm.cxx2
-rw-r--r--sfx2/source/doc/objmisc.cxx8
-rw-r--r--sfx2/source/view/frame.cxx47
-rw-r--r--sfx2/source/view/frmload.cxx49
-rw-r--r--sfx2/source/view/viewfrm.cxx20
8 files changed, 113 insertions, 98 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index f0d5e2322ba6..7874f05890fb 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -1120,12 +1120,22 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
return;
}
- SFX_REQUEST_ARG(rReq, pFrmItem, SfxFrameItem, SID_DOCFRAME, FALSE);
- SfxFrame *pFrame = NULL;
- if ( pFrmItem )
- pFrame = pFrmItem->GetFrame();
- else if ( SfxViewFrame::Current() )
- pFrame = SfxViewFrame::Current()->GetFrame();
+ SfxFrame* pTargetFrame = NULL;
+ Reference< XFrame > xTargetFrame;
+
+ SFX_REQUEST_ARG(rReq, pFrameItem, SfxFrameItem, SID_DOCFRAME, FALSE);
+ if ( pFrameItem )
+ pTargetFrame = pFrameItem->GetFrame();
+
+ if ( !pTargetFrame )
+ {
+ SFX_REQUEST_ARG(rReq, pUnoFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE);
+ if ( pUnoFrameItem )
+ xTargetFrame = pUnoFrameItem->GetFrame();
+ }
+
+ if ( !pTargetFrame && !xTargetFrame.is() && SfxViewFrame::Current() )
+ pTargetFrame = SfxViewFrame::Current()->GetFrame();
// check if caller has set a callback
SFX_REQUEST_ARG(rReq, pLinkItem, SfxLinkItem, SID_DONELINK, FALSE );
@@ -1202,18 +1212,24 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
// {
// if a frame is given, it must be used for the starting point of the targetting mechanism
// this code is also used if asynchronous loading is possible, because loadComponent always is synchron
- Reference < XFrame > xFrame;
- if ( pFrame )
- xFrame = pFrame->GetFrameInterface();
- else
- xFrame = Reference < XFrame >( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY );
+ if ( !xTargetFrame.is() )
+ {
+ if ( pTargetFrame )
+ {
+ xTargetFrame = pTargetFrame->GetFrameInterface();
+ }
+ else
+ {
+ xTargetFrame.set( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY );
+ }
+ }
// make URL ready
SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_FILE_NAME, FALSE );
aFileName = pURLItem->GetValue();
if( aFileName.Len() && aFileName.GetChar(0) == '#' ) // Mark without URL
{
- SfxViewFrame *pView = pFrame ? pFrame->GetCurrentViewFrame() : 0;
+ SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : 0;
if ( !pView )
pView = SfxViewFrame::Current();
pView->GetViewShell()->JumpToMark( aFileName.Copy(1) );
@@ -1231,13 +1247,13 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
// if loading must be done synchron, we must wait for completion to get a return value
// find frame by myself; I must konw the exact frame to get the controller for the return value from it
//if( aTarget.getLength() )
- // xFrame = xFrame->findFrame( aTarget, FrameSearchFlag::ALL );
+ // xTargetFrame = xTargetFrame->findFrame( aTarget, FrameSearchFlag::ALL );
Reference < XComponent > xComp;
try
{
- xComp = ::comphelper::SynchronousDispatch::dispatch( xFrame, aFileName, aTarget, 0, aArgs );
-// Reference < XComponentLoader > xLoader( xFrame, UNO_QUERY );
+ xComp = ::comphelper::SynchronousDispatch::dispatch( xTargetFrame, aFileName, aTarget, 0, aArgs );
+// Reference < XComponentLoader > xLoader( xTargetFrame, UNO_QUERY );
// xComp = xLoader->loadComponentFromURL( aFileName, aTarget, 0, aArgs );
}
catch(const RuntimeException&)
@@ -1262,7 +1278,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY );
xTrans->parseStrict( aURL );
- Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY );
+ Reference < XDispatchProvider > xProv( xTargetFrame, UNO_QUERY );
Reference < XDispatch > xDisp = xProv.is() ? xProv->queryDispatch( aURL, aTarget, FrameSearchFlag::ALL ) : Reference < XDispatch >();;
RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, "PERFORMANCE - SfxApplication::OpenDocExec_Impl" );
if ( xDisp.is() )
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 02cb82963930..e40d2dea29ba 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -266,9 +266,9 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
Reference< XFrame > xFrame;
const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- SFX_ITEMSET_ARG( pIntSet, pFrame, SfxUnoAnyItem, SID_FILLFRAME, FALSE );
- if (pFrame)
- pFrame->GetValue() >>= xFrame;
+ SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE );
+ if ( pFrameItem )
+ xFrame = pFrameItem->GetFrame();
SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog(
RID_SVXDLG_CUSTOMIZE,
@@ -895,7 +895,10 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
const SfxPoolItem* pItem = NULL;
Reference < XFrame > xFrame;
if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
- ( (SfxUnoAnyItem*)pItem )->GetValue() >>= xFrame;
+ {
+ OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
+ xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
+ }
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if ( pFact )
{
@@ -1063,9 +1066,9 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
Reference< XFrame > xFrame;
const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, FALSE );
+ SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE );
if ( pFrameItem )
- pFrameItem->GetValue() >>= xFrame;
+ xFrame = pFrameItem->GetFrame();
if ( !xFrame.is() )
{
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 4d2a1f234ba6..8ca5c85c7174 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -470,7 +470,11 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque
const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n];
String aName = rProp.Name;
if ( aName == sFrame )
- rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) );
+ {
+ Reference< XFrame > xFrame;
+ OSL_VERIFY( rProp.Value >>= xFrame );
+ rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
+ }
else
if ( aName == sHidden )
{
@@ -562,11 +566,11 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque
}
else if ( aName == sFrame )
{
- Reference< XFrame > xVal;
- sal_Bool bOK = (rProp.Value >>= xVal);
+ Reference< XFrame > xFrame;
+ sal_Bool bOK = (rProp.Value >>= xFrame);
DBG_ASSERT( bOK, "invalid type for Frame" );
if (bOK)
- rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) );
+ rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) );
}
else if ( aName == sAsTemplate )
{
@@ -1380,7 +1384,15 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta
if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
{
pValue[nActProp].Name = sFrame;
- pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() );
+ if ( pItem->ISA( SfxUsrAnyItem ) )
+ {
+ OSL_ENSURE( false, "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" );
+ pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue();
+ }
+ else if ( pItem->ISA( SfxUnoFrameItem ) )
+ pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame();
+ else
+ OSL_ENSURE( false, "TransformItems: invalid item type for SID_FILLFRAME!" );
}
if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET )
{
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 190cc47dc2f6..de274b2adf47 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -759,7 +759,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util
}
SfxAllItemSet aInternalSet( SFX_APP()->GetPool() );
if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem !
- aInternalSet.Put( SfxUnoAnyItem( SID_FILLFRAME, css::uno::makeAny(xFrameRef) ) );
+ aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) );
sal_Bool bSuccess = sal_False;
sal_Bool bFailure = sal_False;
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index ce0de006829c..9bf2264cc446 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -2137,13 +2137,11 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium )
{
Window* pWindow = 0;
SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet();
- SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoAnyItem, SID_FILLFRAME, FALSE );
+ SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE );
if ( pUnoItem )
{
- uno::Reference < frame::XFrame > xFrame;
- pUnoItem->GetValue() >>= xFrame;
- if ( xFrame.is() )
- pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
+ uno::Reference < frame::XFrame > xFrame( pUnoItem->GetFrame() );
+ pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
}
if ( !pWindow )
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index 44df30b6fd70..6558af8b0fe6 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -103,6 +103,7 @@ using namespace ::com::sun::star::container;
TYPEINIT1(SfxFrame, SfxListener);
TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem);
TYPEINIT1(SfxUsrAnyItem, SfxPoolItem);
+TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem);
SvCompatWeakHdl* SfxFrame::GetHdl()
{
@@ -640,11 +641,6 @@ int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const
return sal_False;
}
-String SfxUsrAnyItem::GetValueText() const
-{
- return String();
-}
-
SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const
{
return new SfxUsrAnyItem( Which(), aValue );
@@ -662,6 +658,39 @@ sal_Bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*n
return sal_True;
}
+SfxUnoFrameItem::SfxUnoFrameItem()
+ : SfxPoolItem()
+ , m_xFrame()
+{
+}
+
+SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame )
+ : SfxPoolItem( nWhichId )
+ , m_xFrame( i_rFrame )
+{
+}
+
+int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
+{
+ return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
+}
+
+SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
+{
+ return new SfxUnoFrameItem( Which(), m_xFrame );
+}
+
+sal_Bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ rVal <<= m_xFrame;
+ return sal_True;
+}
+
+sal_Bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ return ( rVal >>= m_xFrame );
+}
+
SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur )
: pFrame( &rFrame )
, bRecursive( bRecur )
@@ -959,10 +988,10 @@ SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
return NULL;
}
-const SfxPoolItem* SfxFrame::LoadDocumentSynchron( SfxItemSet& aSet )
+const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame )
{
- aSet.Put( SfxFrameItem( SID_DOCFRAME, this ) );
- aSet.ClearItem( SID_TARGETNAME );
- return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, aSet );
+ i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) );
+ i_rSet.ClearItem( SID_TARGETNAME );
+ return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet );
}
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index 6eba855290f4..956cef506201 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -256,44 +256,11 @@ namespace
}
// --------------------------------------------------------------------------------------------------------------------
-SfxFrame* SfxFrameLoader_Impl::impl_getOrCreateEmptySfxFrame( const Reference< XFrame >& i_rFrame ) const
-{
- for ( SfxFrame* pFrame = SfxFrame::GetFirst();
- pFrame;
- pFrame = SfxFrame::GetNext( *pFrame )
- )
- {
- if ( pFrame->GetFrameInterface() == i_rFrame )
- {
- if ( ( pFrame->GetCurrentViewFrame() != NULL )
- || ( pFrame->GetCurrentDocument() != NULL )
- )
- // an empty SfxFrame was requested, so we can't use this instance.
- // Note that it is perfectly letgitimate that during loading into an XFrame which already contains
- // a document, there exist two SfxFrame instances bound to this XFrame - the old one, which will be
- // destroyed later, and the new one, which we're going to create
- continue;
-
- return pFrame;
- }
- }
-
- SfxFrame* pFrame = SfxFrame::Create( i_rFrame );
- ENSURE_OR_THROW( pFrame, "could not create an SfxFrame" );
- return pFrame;
-}
-
-// --------------------------------------------------------------------------------------------------------------------
sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlotID, const Reference< XFrame >& i_rxFrame )
{
- SfxFrame* pTargetFrame = impl_getOrCreateEmptySfxFrame( i_rxFrame );
- SfxFrameWeak wFrame = pTargetFrame;
-
SfxRequest aRequest( _nSlotID, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() );
- aRequest.AppendItem( SfxFrameItem ( SID_DOCFRAME, pTargetFrame ) );
-
- sal_Bool bSuccess = lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) );
- return impl_cleanUp( bSuccess, wFrame );
+ aRequest.AppendItem( SfxUnoFrameItem( SID_FILLFRAME, i_rxFrame ) );
+ return lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) );
}
// --------------------------------------------------------------------------------------------------------------------
@@ -380,18 +347,6 @@ SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< X
}
// --------------------------------------------------------------------------------------------------------------------
-sal_Bool SfxFrameLoader_Impl::impl_cleanUp( const sal_Bool i_bSuccess, const SfxFrameWeak& i_wFrame ) const
-{
- if ( !i_bSuccess && i_wFrame && !i_wFrame->GetCurrentDocument() )
- {
- i_wFrame->SetFrameInterface_Impl( NULL );
- i_wFrame->DoClose();
- }
-
- return i_bSuccess;
-}
-
-// --------------------------------------------------------------------------------------------------------------------
bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedValueCollection& io_rDescriptor ) const
{
const ::rtl::OUString sTemplateRegioName = io_rDescriptor.getOrDefault( "TemplateRegionName", ::rtl::OUString() );
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 7193a3a8fb81..6b1d06ce4508 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -2112,20 +2112,22 @@ SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const USHORT i
//--------------------------------------------------------------------
-SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrame* i_pTargetFrame, const USHORT i_nViewId )
+SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rTargetFrame, const USHORT i_nViewId )
{
- Reference< XFrame > xFrame;
- if ( i_pTargetFrame )
- xFrame = i_pTargetFrame->GetFrameInterface();
-
- return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, xFrame, i_nViewId, false );
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, i_nViewId, false );
}
//--------------------------------------------------------------------
SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const USHORT i_nViewId )
{
- return LoadDocumentIntoFrame( i_rDoc, i_pFrameItem ? i_pFrameItem->GetFrame() : NULL, i_nViewId );
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : NULL, i_nViewId, false );
+}
+
+//--------------------------------------------------------------------
+SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxUnoFrameItem* i_pFrameItem, const USHORT i_nViewId )
+{
+ return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem ? i_pFrameItem->GetFrame() : NULL, i_nViewId, false );
}
//--------------------------------------------------------------------
@@ -2386,9 +2388,9 @@ void SfxViewFrame::ExecView_Impl
Reference < XFrame > xFrame;
// the frame (optional arg. TODO: this is currently not supported in the slot definition ...)
- SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, sal_False );
+ SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
if ( pFrameItem )
- pFrameItem->GetValue() >>= xFrame;
+ xFrame = pFrameItem->GetFrame();
LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false );