diff options
author | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-06-15 20:54:04 +0200 |
---|---|---|
committer | Valentin Kettner <vakevk+libreoffice@gmail.com> | 2014-07-15 15:44:03 +0200 |
commit | 54ca3a6efa89eb2222abf0a51597074be25ce322 (patch) | |
tree | 1bedc9ab1816d9282fba35b2d9c9be007b1f89b1 /sw | |
parent | a27e8f6c8dd81d1fa1a34a88890bcd944682146d (diff) |
Refactored IDocumentLinksAdministration out of SwDoc.
To the new class DocumentLinksAdministrationManager.
Additional to the Interface methods SwDoc::SelectServerObj was also moved
and sw/source/core/doc/docdde.cxx was deleted as it became empty.
Also fixed OUString usage in IDocumentLinksAdministration.hxx .
Change-Id: I1f2bf0881a7d4add9c657b6441851ae14ad8d161
Diffstat (limited to 'sw')
26 files changed, 460 insertions, 305 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index d96a0660e184..bb04a34e13c9 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -166,7 +166,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/doc/docchart \ sw/source/core/doc/doccomp \ sw/source/core/doc/doccorr \ - sw/source/core/doc/docdde \ sw/source/core/doc/docdesc \ sw/source/core/doc/docdraw \ sw/source/core/doc/docedt \ @@ -190,6 +189,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/doc/DocumentDrawModelManager \ sw/source/core/doc/DocumentChartDataProviderManager \ sw/source/core/doc/DocumentTimerManager \ + sw/source/core/doc/DocumentLinksAdministrationManager \ sw/source/core/doc/extinput \ sw/source/core/doc/fmtcol \ sw/source/core/doc/ftnidx \ diff --git a/sw/inc/IDocumentLinksAdministration.hxx b/sw/inc/IDocumentLinksAdministration.hxx index a0b3ee6851d0..8d4f4c74d47f 100644 --- a/sw/inc/IDocumentLinksAdministration.hxx +++ b/sw/inc/IDocumentLinksAdministration.hxx @@ -24,6 +24,9 @@ namespace com { namespace sun { namespace star { namespace uno { class Any; } } } } namespace sfx2 { class SvLinkSource; class LinkManager; } +namespace rtl { class OUString; } +using rtl::OUString; + /** Document links administration interface */ diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ef6fc5fb7cc6..b8671fbb4a00 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -23,7 +23,6 @@ #include <IInterface.hxx> #include <IDocumentMarkAccess.hxx> #include <IDocumentRedlineAccess.hxx> -#include <IDocumentLinksAdministration.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentContentOperations.hxx> #include <IDocumentStylePoolAccess.hxx> @@ -190,6 +189,12 @@ class SwRenderData; class SwPageFrm; class SwViewOption; class IDocumentUndoRedo; +class IDocumentSettingAccess; +class IDocumentDeviceAccess; +class IDocumentDrawModelAccess; +class IDocumentChartDataProviderAccess; +class IDocumentTimerAccess; +class IDocumentLinksAdministration; class _SetGetExpFlds; namespace sw { namespace mark { @@ -204,6 +209,7 @@ namespace sw { class DocumentDrawModelManager; class DocumentChartDataProviderManager; class DocumentTimerManager; + class DocumentLinksAdministrationManager; } namespace com { namespace sun { namespace star { @@ -242,7 +248,6 @@ void StartGrammarChecking( SwDoc &rDoc ); class SW_DLLPUBLIC SwDoc : public IInterface, public IDocumentRedlineAccess, - public IDocumentLinksAdministration, public IDocumentFieldsAccess, public IDocumentContentOperations, public IDocumentStylePoolAccess, @@ -285,6 +290,7 @@ class SW_DLLPUBLIC SwDoc : const ::boost::scoped_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager; ::boost::scoped_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess; const ::boost::scoped_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager; + const ::boost::scoped_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager; // Pointer SwFrmFmt *mpDfltFrmFmt; //< Default formats. @@ -324,8 +330,6 @@ class SW_DLLPUBLIC SwDoc : SwDocShell *mpDocShell; //< Ptr to SfxDocShell of Doc. SfxObjectShellLock mxTmpDocShell; //< A temporary shell that is used to copy OLE-Nodes - sfx2::LinkManager *mpLinkMgr; //< List of linked stuff (graphics/DDE/OLE). - SwAutoCorrExceptWord *mpACEWord; /**< For the automated takeover of auto-corrected words that are "re-corrected". */ SwURLStateChanged *mpURLStateChgd; //< SfxClient for changes in INetHistory @@ -405,7 +409,6 @@ private: bool mbNewDoc : 1; //< TRUE: new Doc. bool mbNewFldLst : 1; //< TRUE: Rebuild field-list. bool mbCopyIsMove : 1; //< TRUE: Copy is a hidden Move. - bool mbVisibleLinks : 1; //< TRUE: Links are inserted visibly. bool mbInReading : 1; //< TRUE: Document is in the process of being read. bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary. bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX. @@ -420,8 +423,6 @@ private: bool mbInsOnlyTxtGlssry : 1; //< True: insert 'only text' glossary into doc bool mbContains_MSVBasic : 1; //< True: MS-VBasic exist is in our storage bool mbReadlineChecked : 1; //< sal_True: if the query was already shown - bool mbLinksUpdated : 1; /**< #i38810# - flag indicating, that the links have been updated. */ bool mbClipBoard : 1; //< TRUE: this document represents the clipboard bool mbColumnSelection : 1; /**< TRUE: this content has bee created by a column selection (clipboard docs only) */ @@ -610,17 +611,11 @@ public: IDocumentUndoRedo const& GetIDocumentUndoRedo() const; // IDocumentLinksAdministration - virtual bool IsVisibleLinks() const SAL_OVERRIDE; - virtual void SetVisibleLinks(bool bFlag) SAL_OVERRIDE; - virtual sfx2::LinkManager& GetLinkManager() SAL_OVERRIDE; - virtual const sfx2::LinkManager& GetLinkManager() const SAL_OVERRIDE; - virtual void UpdateLinks(bool bUI) SAL_OVERRIDE; - virtual bool GetData(const OUString& rItem, const OUString& rMimeType, ::com::sun::star::uno::Any& rValue) const SAL_OVERRIDE; - virtual bool SetData(const OUString& rItem, const OUString& rMimeType, const ::com::sun::star::uno::Any& rValue) SAL_OVERRIDE; - virtual ::sfx2::SvLinkSource* CreateLinkSource(const OUString& rItem) SAL_OVERRIDE; - virtual bool EmbedAllLinks() SAL_OVERRIDE; - virtual void SetLinksUpdated(const bool bNewLinksUpdated) SAL_OVERRIDE; - virtual bool LinksUpdated() const SAL_OVERRIDE; + IDocumentLinksAdministration const & getIDocumentLinksAdministration() const; + IDocumentLinksAdministration & getIDocumentLinksAdministration(); + + ::sw::DocumentLinksAdministrationManager const & GetDocumentLinksAdministrationManager() const; + ::sw::DocumentLinksAdministrationManager & GetDocumentLinksAdministrationManager(); // IDocumentFieldsAccess virtual const SwFldTypes *GetFldTypes() const SAL_OVERRIDE; diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 5bd6dc9b404d..6452bdf849ba 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -20,6 +20,7 @@ #include <bookmrk.hxx> #include <IDocumentMarkAccess.hxx> #include <IDocumentUndoRedo.hxx> +#include <IDocumentLinksAdministration.hxx> #include <doc.hxx> #include <ndtxt.hxx> #include <pam.hxx> @@ -229,7 +230,7 @@ namespace sw { namespace mark void DdeBookmark::DeregisterFromDoc(SwDoc* const pDoc) { if(m_aRefObj.Is()) - pDoc->GetLinkManager().RemoveServer(m_aRefObj); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer(m_aRefObj); } DdeBookmark::~DdeBookmark() diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx index 2a8b56c53a9d..495fb39cd1f1 100644 --- a/sw/source/core/doc/DocumentDrawModelManager.cxx +++ b/sw/source/core/doc/DocumentDrawModelManager.cxx @@ -23,6 +23,7 @@ #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDeviceAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <docsh.hxx> #include <swtypes.hxx> #include <swhints.hxx> @@ -140,7 +141,7 @@ void DocumentDrawModelManager::InitDrawModel() // Set the LinkManager in the model so that linked graphics can be inserted. // The WinWord import needs it too. - mpDrawModel->SetLinkManager( & m_rSwdoc.GetLinkManager() ); + mpDrawModel->SetLinkManager( & m_rSwdoc.getIDocumentLinksAdministration().GetLinkManager() ); mpDrawModel->SetAddExtLeading( m_rSwdoc.getIDocumentSettingAccess().get(IDocumentSettingAccess::ADD_EXT_LEADING) ); OutputDevice* pRefDev = m_rSwdoc.getIDocumentDeviceAccess().getReferenceDevice( false ); diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx index 7d884413bb91..892727bc391f 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx @@ -17,36 +17,77 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <stdlib.h> +#include <DocumentLinksAdministrationManager.hxx> -#include <vcl/svapp.hxx> -#include <tools/urlobj.hxx> - -#include <sfx2/linkmgr.hxx> -#include <unotools/charclass.hxx> -#include <fmtcntnt.hxx> #include <doc.hxx> -#include <swserv.hxx> -#include <IMark.hxx> +#include <DocumentSettingManager.hxx> +#include <IDocumentUndoRedo.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/linkmgr.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/frame.hxx> +#include <linkenum.hxx> +#include <com/sun/star/document/UpdateDocMode.hpp> +#include <swtypes.hxx> +#include <viewsh.hxx> +#include <docsh.hxx> #include <bookmrk.hxx> +#include <swserv.hxx> +#include <swbaslnk.hxx> #include <section.hxx> +#include <docary.hxx> +#include <frmfmt.hxx> +#include <fmtcntnt.hxx> #include <swtable.hxx> -#include <node.hxx> #include <ndtxt.hxx> -#include <pam.hxx> -#include <docary.hxx> -#include <MarkManager.hxx> +#include <tools/urlobj.hxx> +#include <unotools/charclass.hxx> +//#include <rtl/string.h> #include <boost/foreach.hpp> + using namespace ::com::sun::star; +//Helper functions for this file namespace { + struct _FindItem + { + const OUString m_Item; + SwTableNode* pTblNd; + SwSectionNode* pSectNd; + + _FindItem(const OUString& rS) + : m_Item(rS), pTblNd(0), pSectNd(0) + {} + }; + + ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr ) + { + for( sal_uInt16 n = 0; n < rLinks.size(); ++n ) + { + ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]); + if( pLnk && + ( OBJECT_CLIENT_GRF == pLnk->GetObjType() || + OBJECT_CLIENT_FILE == pLnk->GetObjType() ) && + pLnk->ISA( SwBaseLink ) ) + { + ::sfx2::SvBaseLinkRef xLink = pLnk; + + OUString sFName; + rLnkMgr.GetDisplayNames( xLink, 0, &sFName, 0, 0 ); + + INetURLObject aURL( sFName ); + if( INET_PROT_FILE == aURL.GetProtocol() || + INET_PROT_CID == aURL.GetProtocol() ) + return pLnk; + } + } + return 0; + } + - static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark( - const IDocumentMarkAccess& rMarkAccess, - const OUString& rName, - const bool bCaseSensitive ) + ::sw::mark::DdeBookmark* lcl_FindDdeBookmark( const IDocumentMarkAccess& rMarkAccess, const OUString& rName, const bool bCaseSensitive ) { //Iterating over all bookmarks, checking DdeBookmarks const OUString sNameLc = bCaseSensitive ? rName : GetAppCharClass().lowercase(rName); @@ -70,86 +111,152 @@ namespace } return NULL; } -} -struct _FindItem -{ - const OUString m_Item; - SwTableNode* pTblNd; - SwSectionNode* pSectNd; - _FindItem(const OUString& rS) - : m_Item(rS), pTblNd(0), pSectNd(0) - {} -}; + bool lcl_FindSection( const SwSectionFmt* pSectFmt, _FindItem * const pItem, bool bCaseSensitive ) + { + SwSection* pSect = pSectFmt->GetSection(); + if( pSect ) + { + OUString sNm( (bCaseSensitive) + ? pSect->GetSectionName() + : GetAppCharClass().lowercase( pSect->GetSectionName() )); + OUString sCompare( (bCaseSensitive) + ? pItem->m_Item + : GetAppCharClass().lowercase( pItem->m_Item ) ); + if( sNm == sCompare ) + { + // found, so get the data + const SwNodeIndex* pIdx; + if( 0 != (pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && + &pSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() ) + { + // a table in the normal NodesArr + pItem->pSectNd = pIdx->GetNode().GetSectionNode(); + return false; + } + // If the name is already correct, but not the rest then we don't have them. + // The names are always unique. + } + } + return true; + } -static bool lcl_FindSection( const SwSectionFmt* pSectFmt, _FindItem * const pItem, bool bCaseSensitive ) -{ - SwSection* pSect = pSectFmt->GetSection(); - if( pSect ) + bool lcl_FindTable( const SwFrmFmt* pTableFmt, _FindItem * const pItem ) { - OUString sNm( (bCaseSensitive) - ? pSect->GetSectionName() - : GetAppCharClass().lowercase( pSect->GetSectionName() )); - OUString sCompare( (bCaseSensitive) - ? pItem->m_Item - : GetAppCharClass().lowercase( pItem->m_Item ) ); - if( sNm == sCompare ) + OUString sNm( GetAppCharClass().lowercase( pTableFmt->GetName() )); + if ( sNm == pItem->m_Item ) { - // found, so get the data - const SwNodeIndex* pIdx; - if( 0 != (pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && - &pSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() ) + SwTable* pTmpTbl; + SwTableBox* pFBox; + if( 0 != ( pTmpTbl = SwTable::FindTable( pTableFmt ) ) && + 0 != ( pFBox = pTmpTbl->GetTabSortBoxes()[0] ) && + pFBox->GetSttNd() && + &pTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) { // a table in the normal NodesArr - pItem->pSectNd = pIdx->GetNode().GetSectionNode(); + pItem->pTblNd = (SwTableNode*) + pFBox->GetSttNd()->FindTableNode(); return false; } // If the name is already correct, but not the rest then we don't have them. // The names are always unique. } + return true; } - return true; + } -static bool lcl_FindTable( const SwFrmFmt* pTableFmt, _FindItem * const pItem ) + +namespace sw { - OUString sNm( GetAppCharClass().lowercase( pTableFmt->GetName() )); - if ( sNm == pItem->m_Item ) - { - SwTable* pTmpTbl; - SwTableBox* pFBox; - if( 0 != ( pTmpTbl = SwTable::FindTable( pTableFmt ) ) && - 0 != ( pFBox = pTmpTbl->GetTabSortBoxes()[0] ) && - pFBox->GetSttNd() && - &pTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) + +DocumentLinksAdministrationManager::DocumentLinksAdministrationManager( SwDoc& i_rSwdoc ) : mbVisibleLinks(true), + mbLinksUpdated( false ), //#i38810# + mpLinkMgr( new sfx2::LinkManager( 0 ) ), + m_rSwdoc( i_rSwdoc ) +{ +} + +bool DocumentLinksAdministrationManager::IsVisibleLinks() const +{ + return mbVisibleLinks; +} + +void DocumentLinksAdministrationManager::SetVisibleLinks(bool bFlag) +{ + mbVisibleLinks = bFlag; +} + +sfx2::LinkManager& DocumentLinksAdministrationManager::GetLinkManager() +{ + return *mpLinkMgr; +} + +const sfx2::LinkManager& DocumentLinksAdministrationManager::GetLinkManager() const +{ + return *mpLinkMgr; +} + +// #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks() +// to new SwDoc::UpdateLinks(): +void DocumentLinksAdministrationManager::UpdateLinks( bool bUI ) +{ + SfxObjectCreateMode eMode; + sal_uInt16 nLinkMode = m_rSwdoc.GetDocumentSettingManager().getLinkUpdateMode( true ); + if ( m_rSwdoc.GetDocShell()) { + sal_uInt16 nUpdateDocMode = m_rSwdoc.GetDocShell()->GetUpdateDocMode(); + if( (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) && + !GetLinkManager().GetLinks().empty() && + SFX_CREATE_MODE_INTERNAL != + ( eMode = m_rSwdoc.GetDocShell()->GetCreateMode()) && + SFX_CREATE_MODE_ORGANIZER != eMode && + SFX_CREATE_MODE_PREVIEW != eMode && + !m_rSwdoc.GetDocShell()->IsPreview() ) { - // a table in the normal NodesArr - pItem->pTblNd = (SwTableNode*) - pFBox->GetSttNd()->FindTableNode(); - return false; + SwViewShell* pVSh = 0; + bool bAskUpdate = nLinkMode == MANUAL; + bool bUpdate = true; + switch(nUpdateDocMode) + { + case document::UpdateDocMode::NO_UPDATE: bUpdate = false;break; + case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break; + case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break; + } + if( bUpdate && (bUI || !bAskUpdate) ) + { + SfxMedium* pMedium = m_rSwdoc.GetDocShell()->GetMedium(); + SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0; + Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0; + if( m_rSwdoc.GetCurrentViewShell() && !m_rSwdoc.GetEditShell( &pVSh ) && !pVSh ) + { + SwViewShell aVSh( m_rSwdoc, 0, 0 ); + + SET_CURR_SHELL( &aVSh ); + GetLinkManager().UpdateAllLinks( bAskUpdate , true, false, pDlgParent ); + } + else + GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent ); + } } - // If the name is already correct, but not the rest then we don't have them. - // The names are always unique. } - return true; } -bool SwDoc::GetData( const OUString& rItem, const OUString& rMimeType, +bool DocumentLinksAdministrationManager::GetData( const OUString& rItem, const OUString& rMimeType, uno::Any & rValue ) const { // search for bookmarks and sections case sensitive at first. If nothing is found then try again case insensitive bool bCaseSensitive = true; while( true ) { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*mpMarkManager, rItem, bCaseSensitive); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*m_rSwdoc.getIDocumentMarkAccess(), rItem, bCaseSensitive); if(pBkmk) return SwServerObject(*pBkmk).GetData(rValue, rMimeType); // Do we already have the Item? OUString sItem( bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - BOOST_FOREACH( const SwSectionFmt* pFmt, *mpSectionFmtTbl ) + BOOST_FOREACH( const SwSectionFmt* pFmt, m_rSwdoc.GetSections() ) { if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) break; @@ -165,7 +272,7 @@ bool SwDoc::GetData( const OUString& rItem, const OUString& rMimeType, } _FindItem aPara( GetAppCharClass().lowercase( rItem )); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + BOOST_FOREACH( const SwFrmFmt* pFmt, *m_rSwdoc.GetTblFrmFmts() ) { if (!(lcl_FindTable(pFmt, &aPara))) break; @@ -178,21 +285,21 @@ bool SwDoc::GetData( const OUString& rItem, const OUString& rMimeType, return false; } -bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, +bool DocumentLinksAdministrationManager::SetData( const OUString& rItem, const OUString& rMimeType, const uno::Any & rValue ) { // search for bookmarks and sections case sensitive at first. If nothing is found then try again case insensitive bool bCaseSensitive = true; while( true ) { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*mpMarkManager, rItem, bCaseSensitive); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*m_rSwdoc.getIDocumentMarkAccess(), rItem, bCaseSensitive); if(pBkmk) return SwServerObject(*pBkmk).SetData(rMimeType, rValue); // Do we already have the Item? OUString sItem( bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - BOOST_FOREACH( const SwSectionFmt* pFmt, *mpSectionFmtTbl ) + BOOST_FOREACH( const SwSectionFmt* pFmt, m_rSwdoc.GetSections() ) { if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) break; @@ -209,7 +316,7 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, OUString sItem(GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + BOOST_FOREACH( const SwFrmFmt* pFmt, *m_rSwdoc.GetTblFrmFmts() ) { if (!(lcl_FindTable(pFmt, &aPara))) break; @@ -222,7 +329,7 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, return false; } -::sfx2::SvLinkSource* SwDoc::CreateLinkSource(const OUString& rItem) +::sfx2::SvLinkSource* DocumentLinksAdministrationManager::CreateLinkSource(const OUString& rItem) { SwServerObject* pObj = NULL; @@ -231,7 +338,7 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, while( true ) { // bookmarks - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*mpMarkManager, rItem, bCaseSensitive); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*m_rSwdoc.getIDocumentMarkAccess(), rItem, bCaseSensitive); if(pBkmk && pBkmk->IsExpanded() && (0 == (pObj = pBkmk->GetRefObject()))) { @@ -245,7 +352,7 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, _FindItem aPara(bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); // sections - BOOST_FOREACH( const SwSectionFmt* pFmt, *mpSectionFmtTbl ) + BOOST_FOREACH( const SwSectionFmt* pFmt, m_rSwdoc.GetSections() ) { if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) break; @@ -268,7 +375,7 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, _FindItem aPara( GetAppCharClass().lowercase(rItem) ); // tables - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + BOOST_FOREACH( const SwFrmFmt* pFmt, *m_rSwdoc.GetTblFrmFmts() ) { if (!(lcl_FindTable(pFmt, &aPara))) break; @@ -284,8 +391,52 @@ bool SwDoc::SetData( const OUString& rItem, const OUString& rMimeType, return pObj; } -bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, - SwNodeRange*& rpRange ) const +/// embedded all local links (Areas/Graphics) +bool DocumentLinksAdministrationManager::EmbedAllLinks() +{ + bool bRet = false; + sfx2::LinkManager& rLnkMgr = GetLinkManager(); + const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks(); + if( !rLinks.empty() ) + { + ::sw::UndoGuard const undoGuard(m_rSwdoc.GetIDocumentUndoRedo()); + + ::sfx2::SvBaseLink* pLnk = 0; + while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) ) + { + ::sfx2::SvBaseLinkRef xLink = pLnk; + // Tell the link that it's being destroyed! + xLink->Closed(); + + // if one forgot to remove itself + if( xLink.Is() ) + rLnkMgr.Remove( xLink ); + + bRet = true; + } + + m_rSwdoc.GetIDocumentUndoRedo().DelAllUndoObj(); + m_rSwdoc.SetModified(); + } + return bRet; +} + +void DocumentLinksAdministrationManager::SetLinksUpdated(const bool bNewLinksUpdated) +{ + mbLinksUpdated = bNewLinksUpdated; +} + +bool DocumentLinksAdministrationManager::LinksUpdated() const +{ + return mbLinksUpdated; +} + +DocumentLinksAdministrationManager::~DocumentLinksAdministrationManager() +{ + DELETEZ( mpLinkMgr ); +} + +bool DocumentLinksAdministrationManager::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, SwNodeRange*& rpRange ) const { // Do we actually have the Item? rpPam = 0; @@ -313,7 +464,7 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, if( sCmp == "table" ) { sName = rCC.lowercase( sName ); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + BOOST_FOREACH( const SwFrmFmt* pFmt, *m_rSwdoc.GetTblFrmFmts() ) { if (!(lcl_FindTable(pFmt, &aPara))) break; @@ -329,7 +480,7 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, { SwNodeIndex* pIdx; SwNode* pNd; - const SwFlyFrmFmt* pFlyFmt = FindFlyByName( sName ); + const SwFlyFrmFmt* pFlyFmt = m_rSwdoc.FindFlyByName( sName ); if( pFlyFmt && 0 != ( pIdx = (SwNodeIndex*)pFlyFmt->GetCntnt().GetCntntIdx() ) && !( pNd = &pIdx->GetNode())->IsNoTxtNode() ) @@ -345,13 +496,13 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, } else if( sCmp == "outline" ) { - SwPosition aPos( SwNodeIndex( (SwNodes&)GetNodes() )); - if( GotoOutline( aPos, sName )) + SwPosition aPos( SwNodeIndex( (SwNodes&)m_rSwdoc.GetNodes() )); + if( m_rSwdoc.GotoOutline( aPos, sName )) { SwNode* pNd = &aPos.nNode.GetNode(); const int nLvl = pNd->GetTxtNode()->GetAttrOutlineLevel()-1; - const SwOutlineNodes& rOutlNds = GetNodes().GetOutLineNds(); + const SwOutlineNodes& rOutlNds = m_rSwdoc.GetNodes().GetOutLineNds(); sal_uInt16 nTmpPos; rOutlNds.Seek_Entry( pNd, &nTmpPos ); rpRange = new SwNodeRange( aPos.nNode, 0, aPos.nNode ); @@ -367,7 +518,7 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, if( nTmpPos < rOutlNds.size() ) rpRange->aEnd = *rOutlNds[ nTmpPos ]; else - rpRange->aEnd = GetNodes().GetEndOfContent(); + rpRange->aEnd = m_rSwdoc.GetNodes().GetEndOfContent(); return true; } } @@ -380,7 +531,7 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, bool bCaseSensitive = true; while( true ) { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*mpMarkManager, sItem, bCaseSensitive); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*m_rSwdoc.getIDocumentMarkAccess(), sItem, bCaseSensitive); if(pBkmk) { if(pBkmk->IsExpanded()) @@ -392,9 +543,9 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, _FindItem aPara( bCaseSensitive ? sItem : rCC.lowercase( sItem ) ); - if( !mpSectionFmtTbl->empty() ) + if( !m_rSwdoc.GetSections().empty() ) { - BOOST_FOREACH( const SwSectionFmt* pFmt, *mpSectionFmtTbl ) + BOOST_FOREACH( const SwSectionFmt* pFmt, m_rSwdoc.GetSections() ) { if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) break; @@ -414,4 +565,9 @@ bool SwDoc::SelectServerObj( const OUString& rStr, SwPaM*& rpPam, return false; } + + +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 0e4cc29920fb..6966696c88be 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -23,6 +23,7 @@ #include <DocumentTimerManager.hxx> #include <DocumentDeviceManager.hxx> #include <DocumentChartDataProviderManager.hxx> +#include <DocumentLinksAdministrationManager.hxx> #include <UndoManager.hxx> #include <hintids.hxx> #include <tools/shl.hxx> @@ -281,6 +282,27 @@ IDocumentTimerAccess & SwDoc::getIDocumentTimerAccess() return *m_pDocumentTimerManager; } +// IDocumentLinksAdministration +IDocumentLinksAdministration const & SwDoc::getIDocumentLinksAdministration() const +{ + return *m_pDocumentLinksAdministrationManager; +} + +IDocumentLinksAdministration & SwDoc::getIDocumentLinksAdministration() +{ + return *m_pDocumentLinksAdministrationManager; +} + +::sw::DocumentLinksAdministrationManager const & SwDoc::GetDocumentLinksAdministrationManager() const +{ + return *m_pDocumentLinksAdministrationManager; +} + +::sw::DocumentLinksAdministrationManager & SwDoc::GetDocumentLinksAdministrationManager() +{ + return *m_pDocumentLinksAdministrationManager; +} + /* Implementations the next Interface here */ @@ -2031,90 +2053,6 @@ bool SwDoc::ConvertFieldsToText() } -bool SwDoc::IsVisibleLinks() const -{ - return mbVisibleLinks; -} - -void SwDoc::SetVisibleLinks(bool bFlag) -{ - mbVisibleLinks = bFlag; -} - -sfx2::LinkManager& SwDoc::GetLinkManager() -{ - return *mpLinkMgr; -} - -const sfx2::LinkManager& SwDoc::GetLinkManager() const -{ - return *mpLinkMgr; -} - -void SwDoc::SetLinksUpdated(const bool bNewLinksUpdated) -{ - mbLinksUpdated = bNewLinksUpdated; -} - -bool SwDoc::LinksUpdated() const -{ - return mbLinksUpdated; -} - -static ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr ) -{ - for( sal_uInt16 n = 0; n < rLinks.size(); ++n ) - { - ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]); - if( pLnk && - ( OBJECT_CLIENT_GRF == pLnk->GetObjType() || - OBJECT_CLIENT_FILE == pLnk->GetObjType() ) && - pLnk->ISA( SwBaseLink ) ) - { - ::sfx2::SvBaseLinkRef xLink = pLnk; - - OUString sFName; - rLnkMgr.GetDisplayNames( xLink, 0, &sFName, 0, 0 ); - - INetURLObject aURL( sFName ); - if( INET_PROT_FILE == aURL.GetProtocol() || - INET_PROT_CID == aURL.GetProtocol() ) - return pLnk; - } - } - return 0; -} - -/// embedded all local links (Areas/Graphics) -bool SwDoc::EmbedAllLinks() -{ - bool bRet = false; - sfx2::LinkManager& rLnkMgr = GetLinkManager(); - const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks(); - if( !rLinks.empty() ) - { - ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); - - ::sfx2::SvBaseLink* pLnk = 0; - while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) ) - { - ::sfx2::SvBaseLinkRef xLink = pLnk; - // Tell the link that it's being destroyed! - xLink->Closed(); - - // if one forgot to remove itself - if( xLink.Is() ) - rLnkMgr.Remove( xLink ); - - bRet = true; - } - - GetIDocumentUndoRedo().DelAllUndoObj(); - SetModified(); - } - return bRet; -} - bool SwDoc::IsInsTblFormatNum() const { return SW_MOD()->IsInsTblFormatNum(GetDocumentSettingManager().get(IDocumentSettingAccess::HTML_MODE)); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 72f6560193c3..a6344a0b177c 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -92,6 +92,7 @@ #include <DocumentDrawModelManager.hxx> #include <DocumentChartDataProviderManager.hxx> #include <DocumentTimerManager.hxx> +#include <DocumentLinksAdministrationManager.hxx> #include <unochart.hxx> #include <fldbas.hxx> @@ -200,6 +201,7 @@ SwDoc::SwDoc() m_pDocumentChartDataProviderManager( new sw::DocumentChartDataProviderManager( *this ) ), m_pDeviceAccess( new ::sw::DocumentDeviceManager( *this ) ), m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ), + m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ), mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ), mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ), @@ -226,7 +228,6 @@ SwDoc::SwDoc() mpFtnIdxs( new SwFtnIdxs ), mpDocStat( new SwDocStat ), mpDocShell( 0 ), - mpLinkMgr( new sfx2::LinkManager( 0 ) ), mpACEWord( 0 ), mpURLStateChgd( 0 ), mpNumberFormatter( 0 ), @@ -259,7 +260,6 @@ SwDoc::SwDoc() mbNewDoc(false), mbNewFldLst(true), mbCopyIsMove(false), - mbVisibleLinks(true), mbInReading(false), mbInXMLImport(false), mbUpdateTOX(false), @@ -272,7 +272,6 @@ SwDoc::SwDoc() mbInsOnlyTxtGlssry(false), mbContains_MSVBasic(false), mbReadlineChecked(false), - mbLinksUpdated( false ), //#i38810# mbClipBoard( false ), mbColumnSelection( false ), mbIsPrepareSelAll(false), @@ -483,13 +482,13 @@ SwDoc::~SwDoc() // Release the BaseLinks { - ::sfx2::SvLinkSources aTemp(mpLinkMgr->GetServers()); + ::sfx2::SvLinkSources aTemp(getIDocumentLinksAdministration().GetLinkManager().GetServers()); for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it ) (*it)->Closed(); - if( !mpLinkMgr->GetLinks().empty() ) - mpLinkMgr->Remove( 0, mpLinkMgr->GetLinks().size() ); + if( !getIDocumentLinksAdministration().GetLinkManager().GetLinks().empty() ) + getIDocumentLinksAdministration().GetLinkManager().Remove( 0, getIDocumentLinksAdministration().GetLinkManager().GetLinks().size() ); } // The ChapterNumbers/Numbers need to be deleted before the styles @@ -604,7 +603,7 @@ SwDoc::~SwDoc() GetDocumentDrawModelManager().ReleaseDrawModel(); // Destroy DrawModel before the LinkManager, because it's always set // in the DrawModel. - DELETEZ( mpLinkMgr ); + //The LinkManager gets destroyed automatically with m_pLinksAdministrationManager // Clear the Tables before deleting the defaults, or we crash due to // dependencies on defaults. @@ -665,7 +664,7 @@ void SwDoc::SetDocShell( SwDocShell* pDSh ) mpDocShell->SetUndoManager(& GetUndoManager()); } - mpLinkMgr->SetPersist( mpDocShell ); + getIDocumentLinksAdministration().GetLinkManager().SetPersist( mpDocShell ); // set DocShell pointer also on DrawModel InitDrawModelAndDocShell(mpDocShell, GetDocumentDrawModelManager().GetDrawModel()); @@ -680,14 +679,14 @@ uno::Reference < embed::XStorage > SwDoc::GetDocStorage() { if( mpDocShell ) return mpDocShell->GetStorage(); - if( mpLinkMgr->GetPersist() ) - return mpLinkMgr->GetPersist()->GetStorage(); + if( getIDocumentLinksAdministration().GetLinkManager().GetPersist() ) + return getIDocumentLinksAdministration().GetLinkManager().GetPersist()->GetStorage(); return NULL; } SfxObjectShell* SwDoc::GetPersist() const { - return mpDocShell ? mpDocShell : mpLinkMgr->GetPersist(); + return mpDocShell ? mpDocShell : getIDocumentLinksAdministration().GetLinkManager().GetPersist(); } void SwDoc::ClearDoc() @@ -860,50 +859,6 @@ IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode ) return pDoc->getGrammarContact(); } -// #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks() -// to new SwDoc::UpdateLinks(): -void SwDoc::UpdateLinks( bool bUI ) -{ - SfxObjectCreateMode eMode; - sal_uInt16 nLinkMode = GetDocumentSettingManager().getLinkUpdateMode( true ); - if ( GetDocShell()) { - sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode(); - if( (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) && - !GetLinkManager().GetLinks().empty() && - SFX_CREATE_MODE_INTERNAL != - ( eMode = GetDocShell()->GetCreateMode()) && - SFX_CREATE_MODE_ORGANIZER != eMode && - SFX_CREATE_MODE_PREVIEW != eMode && - !GetDocShell()->IsPreview() ) - { - SwViewShell* pVSh = 0; - bool bAskUpdate = nLinkMode == MANUAL; - bool bUpdate = true; - switch(nUpdateDocMode) - { - case document::UpdateDocMode::NO_UPDATE: bUpdate = false;break; - case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break; - case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break; - } - if( bUpdate && (bUI || !bAskUpdate) ) - { - SfxMedium* pMedium = GetDocShell()->GetMedium(); - SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0; - Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0; - if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh ) - { - SwViewShell aVSh( *this, 0, 0 ); - - SET_CURR_SHELL( &aVSh ); - GetLinkManager().UpdateAllLinks( bAskUpdate , true, false, pDlgParent ); - } - else - GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent ); - } - } - } -} - ::sfx2::IXmlIdRegistry& SwDoc::GetXmlIdRegistry() { diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx index d5e992482bfc..18c6d8790805 100644 --- a/sw/source/core/doc/swserv.cxx +++ b/sw/source/core/doc/swserv.cxx @@ -21,6 +21,7 @@ #include <sfx2/linkmgr.hxx> #include <com/sun/star/uno/Sequence.h> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <swtypes.hxx> #include <swserv.hxx> #include <swbaslnk.hxx> @@ -226,7 +227,7 @@ bool SwServerObject::IsLinkInServer( const SwBaseLink* pChkLnk ) const if( nSttNd && nEndNd ) { // Get LinkManager - const ::sfx2::SvBaseLinks& rLnks = pNds->GetDoc()->GetLinkManager().GetLinks(); + const ::sfx2::SvBaseLinks& rLnks = pNds->GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks(); // To avoid recursions: convert ServerType! SwServerObject::ServerModes eSave = eType; @@ -303,7 +304,7 @@ SwDataChanged::~SwDataChanged() // JP 09.04.96: Only if the Layout is available (thus during input) if( pDoc->GetCurrentViewShell() ) { - const ::sfx2::SvLinkSources& rServers = pDoc->GetLinkManager().GetServers(); + const ::sfx2::SvLinkSources& rServers = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetServers(); ::sfx2::SvLinkSources aTemp(rServers); for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it ) @@ -323,7 +324,7 @@ SwDataChanged::~SwDataChanged() if( !refObj->HasDataLinks() ) { // Then remove from the list - pDoc->GetLinkManager().RemoveServer( *it ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( *it ); } } } diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 970a7aac6a2a..18aa82a2a8ae 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -28,6 +28,7 @@ #include <fmtclds.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> +#include <IDocumentLinksAdministration.hxx> #include <rootfrm.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -738,7 +739,7 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, else if( !pSection->IsLinkType() && pSection->IsConnected() ) { pSection->Disconnect(); - GetLinkManager().Remove( &pSection->GetBaseLink() ); + getIDocumentLinksAdministration().GetLinkManager().Remove( &pSection->GetBaseLink() ); } SetModified(); @@ -1283,7 +1284,7 @@ SwSectionNode* SwSectionNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) c && pDoc->GetIDocumentUndoRedo().IsUndoNodes(rNds)) { pNewSect->SetRefObject( m_pSection->GetObject() ); - pDoc->GetLinkManager().InsertServer( pNewSect->GetObject() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().InsertServer( pNewSect->GetObject() ); } // METADATA: copy xml:id; must be done after insertion of node @@ -1360,18 +1361,17 @@ void SwSectionNode::NodesArrChgd() m_pSection->CreateLink( pDoc->GetCurrentViewShell() ? CREATE_CONNECT : CREATE_NONE ); if (m_pSection->IsServer()) - pDoc->GetLinkManager().InsertServer( m_pSection->GetObject() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().InsertServer( m_pSection->GetObject() ); } else { if (CONTENT_SECTION != m_pSection->GetType() && m_pSection->IsConnected()) { - pDoc->GetLinkManager().Remove( &m_pSection->GetBaseLink() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( &m_pSection->GetBaseLink() ); } - if (m_pSection->IsServer()) - pDoc->GetLinkManager().RemoveServer( m_pSection->GetObject() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( m_pSection->GetObject() ); } } } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 37242a7cf126..e3d2fa811fb7 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -61,6 +61,7 @@ #include <istyleaccess.hxx> #include <IDocumentListItems.hxx> #include <DocumentSettingManager.hxx> +#include <IDocumentLinksAdministration.hxx> #include <switerator.hxx> #include "ndole.hxx" @@ -1927,8 +1928,8 @@ const IDocumentLineNumberAccess* SwNode::getIDocumentLineNumberAccess() const { const IDocumentDrawModelAccess* SwNode::getIDocumentDrawModelAccess() const { return & GetDoc()->getIDocumentDrawModelAccess(); } const IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() const { return GetDoc(); } IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() { return GetDoc(); } -const IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() const { return GetDoc(); } -IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return GetDoc(); } +const IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() const { return &GetDoc()->getIDocumentLinksAdministration(); } +IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return &GetDoc()->getIDocumentLinksAdministration(); } const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); } IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); } IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return GetDoc(); } diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 32737f65eefc..6b0515aff286 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -33,6 +33,7 @@ #include <fmtpdsc.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> +#include <DocumentLinksAdministrationManager.hxx> #include <node.hxx> #include <pam.hxx> #include <frmtool.hxx> @@ -239,12 +240,12 @@ SwSection::~SwSection() if (CONTENT_SECTION != m_Data.GetType()) { - pDoc->GetLinkManager().Remove( m_RefLink ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( m_RefLink ); } if (m_RefObj.Is()) { - pDoc->GetLinkManager().RemoveServer( &m_RefObj ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( &m_RefObj ); } // If the Section is the last Client in the Format we can delete it @@ -593,7 +594,7 @@ void SwSection::SetLinkFileName(const OUString& rNew, OUString const*const pPass void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd ) { const SwNode* pNd; - const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks(); + const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for( sal_uInt16 n = rLnks.size(); n; ) { ::sfx2::SvBaseLink* pBLnk = &(*rLnks[ --n ]); @@ -1094,7 +1095,7 @@ static void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd ) return; } const ::sfx2::SvBaseLink* pOwnLink( &(rSectNd.GetSection().GetBaseLink() ) ); - const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks(); + const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for ( sal_uInt16 n = rLnks.size(); n > 0; ) { SwIntrnlSectRefLink* pSectLnk = dynamic_cast<SwIntrnlSectRefLink*>(&(*rLnks[ --n ])); @@ -1127,7 +1128,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) uno::Any aValue; aValue <<= sName; // Arbitrary name - const ::sfx2::SvBaseLinks& rLnks = pDoc->GetLinkManager().GetLinks(); + const ::sfx2::SvBaseLinks& rLnks = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for( sal_uInt16 n = rLnks.size(); n; ) { ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]); @@ -1139,7 +1140,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) { // It's in the Section, so update. But only if it's not in the same File! OUString sFName; - pDoc->GetLinkManager().GetDisplayNames( pBLink, 0, &sFName, 0, 0 ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().GetDisplayNames( pBLink, 0, &sFName, 0, 0 ); if( sFName != sName ) { pBLink->DataChanged( sMimeType, aValue ); @@ -1180,13 +1181,13 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) pDoc->SetModified(); // set additional flag that links have been updated, in order to check this // during load. - pDoc->SetLinksUpdated( true ); + pDoc->getIDocumentLinksAdministration().SetLinksUpdated( true ); // Always switch off Undo bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); pDoc->GetIDocumentUndoRedo().DoUndo(false); - bool bWasVisibleLinks = pDoc->IsVisibleLinks(); - pDoc->SetVisibleLinks( false ); + bool bWasVisibleLinks = pDoc->getIDocumentLinksAdministration().IsVisibleLinks(); + pDoc->getIDocumentLinksAdministration().SetVisibleLinks( false ); SwPaM* pPam; SwViewShell* pVSh = 0; @@ -1241,7 +1242,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) break; OUString sFilter; OUString sRange; - pDoc->GetLinkManager().GetDisplayNames( this, 0, &sFileName, + pDoc->getIDocumentLinksAdministration().GetLinkManager().GetDisplayNames( this, 0, &sFileName, &sRange, &sFilter ); RedlineMode_t eOldRedlineMode = nsRedlineMode_t::REDLINE_NONE; @@ -1292,7 +1293,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) if( pSrcDoc == pDoc ) { tools::SvRef<SwServerObject> refObj( (SwServerObject*) - pDoc->CreateLinkSource( sRange )); + pDoc->getIDocumentLinksAdministration().CreateLinkSource( sRange )); if( refObj.Is() ) { bRecursion = refObj->IsLinkInServer( this ) || @@ -1304,7 +1305,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) SwPaM* pCpyPam = 0; if( !bRecursion && - pSrcDoc->SelectServerObj( sRange, pCpyPam, pCpyRg ) + pSrcDoc->GetDocumentLinksAdministrationManager().SelectServerObj( sRange, pCpyPam, pCpyRg ) && pCpyPam ) { if( pSrcDoc != pDoc || @@ -1330,7 +1331,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) if ( pSrcDoc != pDoc && rSection.IsProtectFlag() ) { - pSrcDoc->GetLinkManager().UpdateAllLinks( false, true, false, 0 ); + pSrcDoc->getIDocumentLinksAdministration().GetLinkManager().UpdateAllLinks( false, true, false, 0 ); } if( pCpyRg ) @@ -1414,7 +1415,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) // remove all undo actions and turn undo on again pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); pDoc->GetIDocumentUndoRedo().DoUndo(bWasUndo); - pDoc->SetVisibleLinks( bWasVisibleLinks ); + pDoc->getIDocumentLinksAdministration().SetVisibleLinks( bWasVisibleLinks ); pDoc->UnlockExpFlds(); if( !pDoc->IsExpFldsLocked() ) @@ -1491,7 +1492,7 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) } else { - pFmt->GetDoc()->GetLinkManager().Remove( m_RefLink ); + pFmt->GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( m_RefLink ); } SwIntrnlSectRefLink *const pLnk = @@ -1499,13 +1500,13 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) const OUString sCmd(SwSectionData::CollapseWhiteSpaces(m_Data.GetLinkFileName())); pLnk->SetUpdateMode( nUpdateType ); - pLnk->SetVisible( pFmt->GetDoc()->IsVisibleLinks() ); + pLnk->SetVisible( pFmt->GetDoc()->getIDocumentLinksAdministration().IsVisibleLinks() ); switch (m_Data.GetType()) { case DDE_LINK_SECTION: pLnk->SetLinkSourceName( sCmd ); - pFmt->GetDoc()->GetLinkManager().InsertDDELink( pLnk ); + pFmt->GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertDDELink( pLnk ); break; case FILE_LINK_SECTION: { @@ -1514,7 +1515,7 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) const OUString sFile(sCmd.getToken( 0, sfx2::cTokenSeparator, nIndex )); const OUString sFltr(sCmd.getToken( 0, sfx2::cTokenSeparator, nIndex )); const OUString sRange(sCmd.getToken( 0, sfx2::cTokenSeparator, nIndex )); - pFmt->GetDoc()->GetLinkManager().InsertFileLink( *pLnk, + pFmt->GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *pLnk, static_cast<sal_uInt16>(m_Data.GetType()), sFile, ( !sFltr.isEmpty() ? &sFltr : 0 ), @@ -1556,7 +1557,7 @@ void SwSection::BreakLink() OSL_ENSURE(pFormat, "SwSection::BreakLink: no format?"); if (pFormat) { - pFormat->GetDoc()->GetLinkManager().Remove( m_RefLink ); + pFormat->GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( m_RefLink ); } m_RefLink.Clear(); } diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index d5b4d0989ecb..220c6a4f43f8 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -35,6 +35,7 @@ #include <frmatr.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <pam.hxx> #include <editsh.hxx> #include <swtable.hxx> @@ -228,7 +229,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem ) // Notify all who are listening at the same link bInNotifyLinks = true; - const ::sfx2::SvBaseLinks& rLnks = pDoc->GetLinkManager().GetLinks(); + const ::sfx2::SvBaseLinks& rLnks = pDoc->getIDocumentLinksAdministration().GetLinkManager().GetLinks(); for( sal_uInt16 n = rLnks.size(); n; ) { ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]); diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 2746b725290c..93dbf5c5168c 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -32,6 +32,7 @@ #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <docary.hxx> #include <editsh.hxx> #include <frame.hxx> @@ -585,7 +586,7 @@ OUString SwEditShell::Calculate() sfx2::LinkManager& SwEditShell::GetLinkManager() { - return mpDoc->GetLinkManager(); + return mpDoc->getIDocumentLinksAdministration().GetLinkManager(); } void *SwEditShell::GetIMapInventor() const diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx index d0fd69dbe32f..e120a1cfd203 100644 --- a/sw/source/core/fields/ddefld.cxx +++ b/sw/source/core/fields/ddefld.cxx @@ -20,6 +20,7 @@ #include <osl/thread.h> #include <sfx2/linkmgr.hxx> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <editsh.hxx> #include <ndtxt.hxx> #include <fmtfld.hxx> @@ -240,7 +241,7 @@ SwDDEFieldType::SwDDEFieldType(const OUString& rName, SwDDEFieldType::~SwDDEFieldType() { if( pDoc && !pDoc->IsInDtor() ) - pDoc->GetLinkManager().Remove( refLink ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); refLink->Disconnect(); } @@ -283,14 +284,14 @@ void SwDDEFieldType::SetDoc( SwDoc* pNewDoc ) if( pDoc && refLink.Is() ) { OSL_ENSURE( !nRefCnt, "How do we get the references?" ); - pDoc->GetLinkManager().Remove( refLink ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); } pDoc = pNewDoc; if( pDoc && nRefCnt ) { - refLink->SetVisible( pDoc->IsVisibleLinks() ); - pDoc->GetLinkManager().InsertDDELink( refLink ); + refLink->SetVisible( pDoc->getIDocumentLinksAdministration().IsVisibleLinks() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().InsertDDELink( refLink ); } } @@ -298,15 +299,15 @@ void SwDDEFieldType::_RefCntChgd() { if( nRefCnt ) { - refLink->SetVisible( pDoc->IsVisibleLinks() ); - pDoc->GetLinkManager().InsertDDELink( refLink ); + refLink->SetVisible( pDoc->getIDocumentLinksAdministration().IsVisibleLinks() ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().InsertDDELink( refLink ); if( pDoc->GetCurrentViewShell() ) UpdateNow(); } else { Disconnect(); - pDoc->GetLinkManager().Remove( refLink ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); } } diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index a818742f0cd3..5781e9eb20ab 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -34,6 +34,7 @@ #include <fmturl.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <frmatr.hxx> #include <grfatr.hxx> #include <swtypes.hxx> @@ -186,7 +187,7 @@ bool SwGrfNode::ReRead( } else // no name anymore, so remove link { - GetDoc()->GetLinkManager().Remove( refLink ); + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); refLink.Clear(); } @@ -322,7 +323,7 @@ SwGrfNode::~SwGrfNode() if( refLink.Is() ) { OSL_ENSURE( !bInSwapIn, "DTOR: I am still in SwapIn" ); - pDoc->GetLinkManager().Remove( refLink ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); refLink->Disconnect(); } else @@ -668,7 +669,7 @@ bool SwGrfNode::SavePersistentData() if( refLink.Is() ) { OSL_ENSURE( !bInSwapIn, "SavePersistentData: I am still in SwapIn" ); - GetDoc()->GetLinkManager().Remove( refLink ); + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( refLink ); return true; } @@ -1089,7 +1090,7 @@ void DelAllGrfCacheEntries( SwDoc* pDoc ) if( pDoc ) { // delete all Graphic-Links with this name from cache - const sfx2::LinkManager& rLnkMgr = pDoc->GetLinkManager(); + const sfx2::LinkManager& rLnkMgr = pDoc->getIDocumentLinksAdministration().GetLinkManager(); const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks(); SwGrfNode* pGrfNd; OUString sFileNm; diff --git a/sw/source/core/inc/DocumentLinksAdministrationManager.hxx b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx new file mode 100644 index 000000000000..27ce04ef32bb --- /dev/null +++ b/sw/source/core/inc/DocumentLinksAdministrationManager.hxx @@ -0,0 +1,82 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLINKSADMINISTRATIONMANAGER_HXX +#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLINKSADMINISTRATIONMANAGER_HXX + +#include <IDocumentLinksAdministration.hxx> +#include <boost/utility.hpp> + + +namespace sfx2 { class LinkManager; } +class SwDoc; +class SwPaM; +class SwNodeRange; + +namespace sw +{ + +class DocumentLinksAdministrationManager : public IDocumentLinksAdministration, + public ::boost::noncopyable +{ +public: + + DocumentLinksAdministrationManager( SwDoc& i_rSwdoc ); + + bool IsVisibleLinks() const SAL_OVERRIDE; + + void SetVisibleLinks(bool bFlag) SAL_OVERRIDE; + + sfx2::LinkManager& GetLinkManager() SAL_OVERRIDE; + + const sfx2::LinkManager& GetLinkManager() const SAL_OVERRIDE; + + void UpdateLinks(bool bUI) SAL_OVERRIDE; + + bool GetData(const OUString& rItem, const OUString& rMimeType, ::com::sun::star::uno::Any& rValue) const SAL_OVERRIDE; + + bool SetData(const OUString& rItem, const OUString& rMimeType, const ::com::sun::star::uno::Any& rValue) SAL_OVERRIDE; + + ::sfx2::SvLinkSource* CreateLinkSource(const OUString& rItem) SAL_OVERRIDE; + + bool EmbedAllLinks() SAL_OVERRIDE; + + void SetLinksUpdated(const bool bNewLinksUpdated) SAL_OVERRIDE; + + bool LinksUpdated() const SAL_OVERRIDE; + + //Non-Interface method + bool SelectServerObj( const OUString& rStr, SwPaM*& rpPam, SwNodeRange*& rpRange ) const; + + virtual ~DocumentLinksAdministrationManager(); + +private: + + bool mbVisibleLinks; //< TRUE: Links are inserted visibly. + bool mbLinksUpdated; //< #i38810# flag indicating, that the links have been updated. + sfx2::LinkManager *mpLinkMgr; //< List of linked stuff (graphics/DDE/OLE). + + SwDoc& m_rSwdoc; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 7c47e26d7887..872ef569e9fd 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -48,6 +48,7 @@ #include <frmatr.hxx> #include <ndole.hxx> #include <DocumentSettingManager.hxx> +#include <IDocumentLinksAdministration.hxx> #include <comphelper/classids.hxx> #include <vcl/graph.hxx> @@ -516,7 +517,7 @@ bool SwOLENode::UpdateLinkURL_Impl() if ( mpObjectLink ) { OUString aNewLinkURL; - GetDoc()->GetLinkManager().GetDisplayNames( mpObjectLink, 0, &aNewLinkURL, 0, 0 ); + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().GetDisplayNames( mpObjectLink, 0, &aNewLinkURL, 0, 0 ); if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) ) { if ( !aOLEObj.xOLERef.is() ) @@ -586,7 +587,7 @@ void SwOLENode::DisconnectFileLink_Impl() { if ( mpObjectLink ) { - GetDoc()->GetLinkManager().Remove( mpObjectLink ); + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( mpObjectLink ); mpObjectLink = NULL; } } @@ -606,7 +607,7 @@ void SwOLENode::CheckFileLink_Impl() // this is a file link so the model link manager should handle it mpObjectLink = new SwEmbedObjectLink( this ); maLinkURL = aLinkURL; - GetDoc()->GetLinkManager().InsertFileLink( *mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL ); + GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL ); mpObjectLink->Connect(); } } diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index fdc5f3e328c7..36c5a4e9bb3e 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -34,6 +34,7 @@ #include <fmtfld.hxx> #include <frmatr.hxx> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <docary.hxx> #include <frame.hxx> #include <swtable.hxx> @@ -279,7 +280,7 @@ SwTable::~SwTable() { SwDoc* pDoc = GetFrmFmt()->GetDoc(); if( !pDoc->IsInDtor() ) // then remove from the list - pDoc->GetLinkManager().RemoveServer( &refObj ); + pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( &refObj ); refObj->Closed(); } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index 2b9e19fd463a..0fb81476809d 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -22,6 +22,7 @@ #include <sfx2/linkmgr.hxx> #include <fmtcntnt.hxx> #include <doc.hxx> +#include <IDocumentLinksAdministration.hxx> #include <docary.hxx> #include <swundo.hxx> #include <pam.hxx> @@ -476,7 +477,7 @@ void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext) else if( CONTENT_SECTION == rNdSect.GetType() && rNdSect.IsConnected() ) { rNdSect.Disconnect(); - rDoc.GetLinkManager().Remove( &rNdSect.GetBaseLink() ); + rDoc.getIDocumentLinksAdministration().GetLinkManager().Remove( &rNdSect.GetBaseLink() ); } } } diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index a5eb5e414c90..6505ccf525c9 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -39,6 +39,7 @@ #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDeviceAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <pam.hxx> #include <editsh.hxx> #include <undobj.hxx> @@ -357,7 +358,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) // #i42634# Moved common code of SwReader::Read() and // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks(): // ATM still with Update - pDoc->UpdateLinks( true ); + pDoc->getIDocumentLinksAdministration().UpdateLinks( true ); // not insert: set the redline mode read from settings.xml eOld = static_cast<RedlineMode_t>( @@ -375,7 +376,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) // have to be modified. During update of links the OLE link at the document // isn't set. Thus, the document's modified state has to be set again after // the OLE link is restored - see above <pDoc->SetOle2Link( aOLELink )>. - if ( pDoc->LinksUpdated() ) + if ( pDoc->getIDocumentLinksAdministration().LinksUpdated() ) { pDoc->SetModified(); } @@ -888,7 +889,7 @@ sal_uLong SwWriter::Write( WriterRef& rxWriter, const OUString* pRealFileName ) { rDoc.ResetModified(); // #i38810# - reset also flag, that indicates updated links - rDoc.SetLinksUpdated( false ); + rDoc.getIDocumentLinksAdministration().SetLinksUpdated( false ); } } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index f8226b12664c..ea77049645e1 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -79,6 +79,7 @@ #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <mdiexp.hxx> @@ -426,7 +427,7 @@ SwHTMLParser::~SwHTMLParser() sal_uInt16 nLinkMode = pDoc->getIDocumentSettingAccess().getLinkUpdateMode( true ); if( nLinkMode != NEVER && bAsync && SFX_CREATE_MODE_INTERNAL!=pDoc->GetDocShell()->GetCreateMode() ) - pDoc->GetLinkManager().UpdateAllLinks( nLinkMode == MANUAL, + pDoc->getIDocumentLinksAdministration().GetLinkManager().UpdateAllLinks( nLinkMode == MANUAL, true, false ); if ( pDoc->GetDocShell()->IsLoading() ) diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index b2998a10e7cb..145c78722a35 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -70,6 +70,7 @@ #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <IDocumentDeviceAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <docstat.hxx> @@ -1038,7 +1039,7 @@ void SwDocShell::GetState(SfxItemSet& rSet) { //check if linked content or possibly hidden content is available //mpDoc->UpdateFlds( NULL, false ); - sfx2::LinkManager& rLnkMgr = mpDoc->GetLinkManager(); + sfx2::LinkManager& rLnkMgr = mpDoc->getIDocumentLinksAdministration().GetLinkManager(); const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks(); bool bRet = false; if( !rLnks.empty() ) @@ -1103,7 +1104,11 @@ void SwDocShell::LoadingFinished() // enables the document modification again. // Thus, manuell modify the document, if its modified and its links are updated // before <FinishedLoading(..)> is called. +<<<<<<< HEAD const bool bHasDocToStayModified( mpDoc->IsModified() && mpDoc->LinksUpdated() ); +======= + const bool bHasDocToStayModified( pDoc->IsModified() && pDoc->getIDocumentLinksAdministration().LinksUpdated() ); +>>>>>>> Refactored IDocumentLinksAdministration out of SwDoc. FinishedLoading( SFX_LOADED_ALL ); SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this); @@ -1126,7 +1131,11 @@ void SwDocShell::CancelTransfers() { // Cancel all links from LinkManager aFinishedTimer.Stop(); +<<<<<<< HEAD mpDoc->GetLinkManager().CancelTransfers(); +======= + pDoc->getIDocumentLinksAdministration().GetLinkManager().CancelTransfers(); +>>>>>>> Refactored IDocumentLinksAdministration out of SwDoc. SfxObjectShell::CancelTransfers(); } @@ -1182,7 +1191,7 @@ void SwDocShell::CalcLayoutForOLEObjects() // read by the binary filter: void SwDocShell::UpdateLinks() { - GetDoc()->UpdateLinks(true); + GetDoc()->getIDocumentLinksAdministration().UpdateLinks(true); // #i50703# Update footnote numbers SwTxtFtn::SetUniqueSeqRefNo( *GetDoc() ); SwNodeIndex aTmp( GetDoc()->GetNodes() ); diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index ad0aed99cdc2..8780c4b7db75 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -76,6 +76,7 @@ #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentDeviceAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <pagedesc.hxx> #include <shellio.hxx> #include <pview.hxx> @@ -826,7 +827,7 @@ void SwDocShell::Execute(SfxRequest& rReq) if(mpWrtShell) mpWrtShell->StartAllAction(); mpDoc->UpdateFlds( NULL, false ); - mpDoc->EmbedAllLinks(); + mpDoc->getIDocumentLinksAdministration().EmbedAllLinks(); mpDoc->RemoveInvisibleContent(); if(mpWrtShell) mpWrtShell->EndAllAction(); @@ -1164,24 +1165,24 @@ void lcl_processCompatibleSfxHint( const uno::Reference< document::XVbaEventsHel bool SwDocShell::DdeGetData( const OUString& rItem, const OUString& rMimeType, uno::Any & rValue ) { - return mpDoc->GetData( rItem, rMimeType, rValue ); + return mpDoc->getIDocumentLinksAdministration().GetData( rItem, rMimeType, rValue ); } bool SwDocShell::DdeSetData( const OUString& rItem, const OUString& rMimeType, const uno::Any & rValue ) { - return mpDoc->SetData( rItem, rMimeType, rValue ); + return mpDoc->getIDocumentLinksAdministration().SetData( rItem, rMimeType, rValue ); } ::sfx2::SvLinkSource* SwDocShell::DdeCreateLinkSource( const OUString& rItem ) { - return mpDoc->CreateLinkSource( rItem ); + return mpDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem ); } void SwDocShell::ReconnectDdeLink(SfxObjectShell& rServer) { if ( mpDoc ) { - ::sfx2::LinkManager& rLinkManager = mpDoc->GetLinkManager(); + ::sfx2::LinkManager& rLinkManager = mpDoc->getIDocumentLinksAdministration().GetLinkManager(); rLinkManager.ReconnectDdeLink(rServer); } } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 0ed706fddfbf..50a35123a3ec 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -78,6 +78,7 @@ #include <dbmgr.hxx> #include <doc.hxx> #include <IDocumentSettingAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <swwait.hxx> #include <swunohelper.hxx> #include <dbui.hrc> @@ -2825,7 +2826,7 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwDoc* pWorkDoc = rWorkShell.GetDoc(); SwDBManager* pWorkDBManager = pWorkDoc->GetDBManager(); pWorkDoc->SetDBManager( this ); - pWorkDoc->EmbedAllLinks(); + pWorkDoc->getIDocumentLinksAdministration().EmbedAllLinks(); SwUndoId nLastUndoId(UNDO_EMPTY); if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId)) { diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 93c336fff758..4a036065ab8a 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -98,6 +98,7 @@ #include <IDocumentDeviceAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <IDocumentChartDataProviderAccess.hxx> +#include <IDocumentLinksAdministration.hxx> #include <editeng/forbiddencharacterstable.hxx> #include <svl/zforlist.hxx> #include <drawdoc.hxx> @@ -2238,7 +2239,7 @@ void SwXTextDocument::updateLinks( ) throw(RuntimeException, std::exception) if(!IsValid()) throw RuntimeException(); SwDoc* pDoc = pDocShell->GetDoc(); - sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager(); + sfx2::LinkManager& rLnkMan = pDoc->getIDocumentLinksAdministration().GetLinkManager(); if( !rLnkMan.GetLinks().empty() ) { UnoActionContext aAction(pDoc); |