[Libreoffice-commits] core.git: Branch 'feature/refactor-god-objects' - 845 commits - accessibility/inc accessibility/source avmedia/Library_avmedia.mk avmedia/Library_avmediaogl.mk avmedia/source basctl/source basctl/uiconfig basegfx/source basic/source binaryurp/source bin/distro-install-desktop-integration bin/distro-install-file-lists bridges/Library_cpp_uno.mk bridges/source canvas/source chart2/CppunitTest_chart2_export.mk chart2/CppunitTest_chart2_import.mk chart2/inc chart2/Library_chartcontroller.mk chart2/opengl chart2/Package_opengl.mk chart2/qa chart2/source chart2/uiconfig chart2/UIConfig_chart2.mk codemaker/source comphelper/source compilerplugins/clang config.guess config_host/config_features.h.in config_host.mk.in configmgr/source config.sub configure.ac connectivity/inc connectivity/source cppcanvas/CppunitTest_cppcanvas_emfplus.mk cppcanvas/CppunitTest_cppcanvas_test.mk cppcanvas/source cppuhelper/source cui/AllLangResTarget_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk dba ccess/inc dbaccess/source dbaccess/uiconfig dbaccess/UIConfig_dbaccess.mk desktop/inc desktop/Library_libreoffice.mk desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/source desktop/uiconfig desktop/UIConfig_deployment.mk download.lst drawinglayer/source editeng/source embeddedobj/source extensions/AllLangResTarget_bib.mk extensions/AllLangResTarget_scn.mk extensions/inc extensions/Library_npsoplugin.mk extensions/Module_extensions.mk extensions/source extensions/uiconfig extensions/UIConfig_sbibliography.mk extensions/UIConfig_scanner.mk external/collada2gltf external/icu external/libgltf external/libmwaw external/libodfgen external/librevenge external/libwps external/lpsolve external/rhino extras/source filter/CppunitTest_filter_pict_test.mk filter/qa filter/source filter/uiconfig forms/source formula/inc formula/Module_formula.mk formula/source formula/uiconfig formula/UIConfig_formula.mk fpicker/source fpicker/uiconfig framework/inc framework/source helpcompiler/in c helpcompiler/source helpcontent2 hwpfilter/source i18nlangtag/source i18npool/source idlc/inc idlc/source idl/source include/avmedia include/basebmp include/basegfx include/basic include/canvas include/codemaker include/com include/comphelper include/connectivity include/dbaccess include/editeng include/filter include/formula include/jvmaccess include/LibreOfficeKit include/oox include/rtl include/sal include/sfx2 include/sot include/svl include/svtools include/svx include/test include/tools include/unotest include/unotools include/vcl include/xmloff include/xmlreader instsetoo_native/inc_openoffice jvmaccess/source jvmfwk/source l10ntools/inc l10ntools/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Makefile libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source libreofficekit/StaticLibrary_libreofficekit.mk lingucomponent/source linguistic/source lotuswordpro/source Makefile.in odk/examples od k/Package_examples.mk odk/source offapi/com offapi/UnoApi_offapi.mk officecfg/CustomTarget_registry.mk officecfg/registry oovbaapi/ooo oox/inc oox/source package/source postprocess/CppunitTest_services.mk postprocess/Module_postprocess.mk postprocess/qa qadevOOo/runner qadevOOo/tests readlicense_oo/docs readlicense_oo/license registry/source reportdesign/inc reportdesign/source RepositoryExternal.mk Repository.mk RepositoryModule_host.mk rsc/inc rsc/source sal/osl sal/qa sax/source sc/inc scp2/AutoInstall.mk scp2/source sc/qa scripting/source scripting/workben sc/source sc/uiconfig sc/workben sd/AllLangResTarget_sd.mk sdext/source sd/inc sd/Library_sd.mk sd/qa sd/source sd/uiconfig sd/UIConfig_simpress.mk sd/workben sfx2/qa sfx2/source sfx2/uiconfig shell/Module_shell.mk shell/source slideshow/source smoketest/Executable_libtest.mk smoketest/libtest.cxx solenv/bin solenv/gbuild soltools/cpp soltools/mkdepend sot/source starmath/inc starmath/source starmath/uiconfig stoc/source store /source svgio/source svl/CppunitTest_svl_itempool.mk svl/CppunitTest_svl_items.mk svl/CppunitTest_svl_qa_cppunit.mk svl/Module_svl.mk svl/qa svl/source svtools/source svtools/uiconfig svx/inc svx/Library_svx.mk svx/source svx/uiconfig svx/UIConfig_svx.mk sw/CppunitTest_sw_tox.mk sw/CppunitTest_sw_uiwriter.mk sw/inc sw/Library_sw.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop test/Library_subsequenttest.mk test/Library_test.mk test/source toolkit/Library_tk.mk toolkit/source tools/source ucb/source udkapi/com UnoControls/inc UnoControls/source unodevtools/source unotest/source unotools/source unusedcode.easy uui/AllLangResTarget_uui.mk uui/source uui/uiconfig uui/UIConfig_uui.mk vcl/Executable_xid_fullscreen_on_all_monitors.mk vcl/generic vcl/headless vcl/inc vcl/Library_vcl.mk vcl/osx vcl/qa vcl/quartz vcl/source vcl/uiconfig vcl/unx wizards/com writerfilter/CustomTarget_source.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/source x mloff/inc xmloff/source xmlreader/source xmlscript/source xmlsecurity/source xmlsecurity/uiconfig
Valentin Kettner
vakevk+libreoffice at gmail.com
Thu Jun 26 14:43:26 PDT 2014
Rebased ref, commits from common ancestor:
commit 8633228275333c11a531764bc503fe3ecdc72435
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date: Wed Jun 25 21:38:33 2014 +0200
Fixed a stray closing } after rebasing to master.
Change-Id: I9a278f6626fc4377199ec7612092641fb2d1e36d
diff --git a/sw/source/core/doc/DocumentChartDataProviderManager.cxx b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
index 7e8717e..40ae086 100644
--- a/sw/source/core/doc/DocumentChartDataProviderManager.cxx
+++ b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
@@ -52,7 +52,6 @@ SwChartDataProvider * DocumentChartDataProviderManager::GetChartDataProvider( bo
}
return maChartDataProviderImplRef.get();
}
-}
void DocumentChartDataProviderManager::CreateChartInternalDataProviders( const SwTable *pTable )
{
commit 0d8458f9faa1498f9e45f280ffcdc377a21fdfd6
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date: Wed Jun 25 13:54:25 2014 +0200
Refactored IDocumentListsAccess out of SwDoc.
In the new class DocumentListsManager.
The method listfunc::CreateUniqueListId was also moved there.
Added a new method deleteListsByDefaultListStyle to the Interface,
which is needed for SwDoc::DelNumRule.
Change-Id: I75ea554a57d9402d2fcfeaedf9fbe50fbae2b020
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 79691a4..855c17f 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -191,6 +191,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/DocumentTimerManager \
sw/source/core/doc/DocumentLinksAdministrationManager \
sw/source/core/doc/DocumentListItemsManager \
+ sw/source/core/doc/DocumentListsManager \
sw/source/core/doc/extinput \
sw/source/core/doc/fmtcol \
sw/source/core/doc/ftnidx \
diff --git a/sw/inc/IDocumentListsAccess.hxx b/sw/inc/IDocumentListsAccess.hxx
index 590ec8c..f53cfa8 100644
--- a/sw/inc/IDocumentListsAccess.hxx
+++ b/sw/inc/IDocumentListsAccess.hxx
@@ -37,6 +37,7 @@ class IDocumentListsAccess
virtual SwList* createListForListStyle( const OUString& rListStyleName ) = 0;
virtual SwList* getListForListStyle( const OUString& rListStyleName ) const = 0;
virtual void deleteListForListStyle( const OUString& rListStyleName ) = 0;
+ virtual void deleteListsByDefaultListStyle( const OUString& rListStyleName ) = 0;
// #i91400#
virtual void trackChangeOfListStyleName( const OUString& rListStyleName,
const OUString& rNewListStyleName ) = 0;
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index baa18c5..5d53f7a 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -31,10 +31,6 @@
#include <IDocumentState.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <IDocumentOutlineNodes.hxx>
-
-#include <IDocumentListsAccess.hxx>
-class SwList;
-
#include <IDocumentExternalData.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XStorage.hpp>
@@ -187,6 +183,7 @@ class SwPrintData;
class SwRenderData;
class SwPageFrm;
class SwViewOption;
+class SwList;
class IDocumentUndoRedo;
class IDocumentSettingAccess;
class IDocumentDeviceAccess;
@@ -195,6 +192,7 @@ class IDocumentChartDataProviderAccess;
class IDocumentTimerAccess;
class IDocumentLinksAdministration;
class IDocumentListItems;
+class IDocumentListsAccess;
class _SetGetExpFlds;
namespace sw { namespace mark {
@@ -211,6 +209,7 @@ namespace sw {
class DocumentTimerManager;
class DocumentLinksAdministrationManager;
class DocumentListItemsManager;
+ class DocumentListsManager;
}
namespace com { namespace sun { namespace star {
@@ -257,7 +256,6 @@ class SW_DLLPUBLIC SwDoc :
public IDocumentState,
public IDocumentLayoutAccess,
public IDocumentOutlineNodes,
- public IDocumentListsAccess,
public IDocumentExternalData
{
@@ -292,6 +290,7 @@ class SW_DLLPUBLIC SwDoc :
const ::boost::scoped_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
const ::boost::scoped_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
const ::boost::scoped_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
+ const ::boost::scoped_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager;
// Pointer
SwFrmFmt *mpDfltFrmFmt; //< Default formats.
@@ -341,12 +340,6 @@ class SW_DLLPUBLIC SwDoc :
// Hash map to find numrules by name
mutable boost::unordered_map<OUString, SwNumRule *, OUStringHash> maNumRuleMap;
- typedef boost::unordered_map<OUString, SwList*, OUStringHash> tHashMapForLists;
- // container to hold the lists of the text document
- tHashMapForLists maLists;
- // relation between list style and its default list
- tHashMapForLists maListStyleLists;
-
SwRedlineTbl *mpRedlineTbl; //< List of all Ranged Redlines.
SwExtraRedlineTbl *mpExtraRedlineTbl; //< List of all Extra Redlines.
OUString *mpAutoFmtRedlnComment; //< Comment for Redlines inserted via AutoFormat.
@@ -780,15 +773,8 @@ public:
virtual void getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOutlineNodeList ) const SAL_OVERRIDE;
// IDocumentListsAccess
- virtual SwList* createList( const OUString& rListId,
- const OUString& rDefaultListStyleName ) SAL_OVERRIDE;
- virtual void deleteList( const OUString& rListId ) SAL_OVERRIDE;
- virtual SwList* getListByName( const OUString& rListId ) const SAL_OVERRIDE;
- virtual SwList* createListForListStyle( const OUString& rListStyleName ) SAL_OVERRIDE;
- virtual SwList* getListForListStyle( const OUString& rListStyleName ) const SAL_OVERRIDE;
- virtual void deleteListForListStyle( const OUString& rListStyleName ) SAL_OVERRIDE;
- virtual void trackChangeOfListStyleName( const OUString& rListStyleName,
- const OUString& rNewListStyleName ) SAL_OVERRIDE;
+ IDocumentListsAccess const & getIDocumentListsAccess() const;
+ IDocumentListsAccess & getIDocumentListsAccess();
// IDocumentExternalData
virtual void setExternalData(::sw::tExternalDataType eType,
diff --git a/sw/inc/listfunc.hxx b/sw/inc/listfunc.hxx
deleted file mode 100644
index 4057e193..0000000
--- a/sw/inc/listfunc.hxx
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- 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_INC_LISTFUNC_HXX
-#define INCLUDED_SW_INC_LISTFUNC_HXX
-
-class SwDoc;
-
-namespace listfunc
-{
- const OUString CreateUniqueListId( const SwDoc& rDoc );
-}
-
-#endif // INCLUDED_SW_INC_LISTFUNC_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 6d2eef2..6eee57d 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -21,6 +21,7 @@
#include <charfmt.hxx>
#include <cmdid.h>
#include <doc.hxx>
+#include <IDocumentListsAccess.hxx>
#include <editeng/colritem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/lineitem.hxx>
@@ -339,9 +340,9 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const
const OUString& sListId =
dynamic_cast<const SfxStringItem*>(pItem)->GetValue();
if ( !sListId.isEmpty() &&
- !pDstDoc->getListByName( sListId ) )
+ !pDstDoc->getIDocumentListsAccess().getListByName( sListId ) )
{
- const SwList* pList = pSrcDoc->getListByName( sListId );
+ const SwList* pList = pSrcDoc->getIDocumentListsAccess().getListByName( sListId );
// copy list style, if needed
const OUString sDefaultListStyleName =
pList->GetDefaultListStyleName();
@@ -371,10 +372,10 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const
// check again, if list exist, because <SwDoc::MakeNumRule(..)>
// could have also created it.
if ( pNewListIdItem == 0 &&
- !pDstDoc->getListByName( sListId ) )
+ !pDstDoc->getIDocumentListsAccess().getListByName( sListId ) )
{
// copy list
- pDstDoc->createList( sListId, sDefaultListStyleName );
+ pDstDoc->getIDocumentListsAccess().createList( sListId, sDefaultListStyleName );
}
}
}
diff --git a/sw/source/core/doc/DocumentListsManager.cxx b/sw/source/core/doc/DocumentListsManager.cxx
new file mode 100644
index 0000000..1e0a02f
--- /dev/null
+++ b/sw/source/core/doc/DocumentListsManager.cxx
@@ -0,0 +1,243 @@
+/* -*- 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 .
+ */
+#include <DocumentListsManager.hxx>
+#include <doc.hxx>
+#include <list.hxx>
+#include <numrule.hxx>
+#include <rtl/random.h>
+#include <vector>
+
+
+namespace sw
+{
+
+DocumentListsManager::DocumentListsManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ), maLists(), maListStyleLists()
+{
+}
+
+SwList* DocumentListsManager::createList( const OUString& rListId,
+ const OUString& sDefaultListStyleName )
+{
+ OUString sListId = rListId;
+ if ( sListId.isEmpty() )
+ {
+ sListId = CreateUniqueListId();
+ }
+
+ if ( getListByName( sListId ) )
+ {
+ OSL_FAIL( "<DocumentListsManager::createList(..)> - provided list id already used. Serious defect -> please inform OD." );
+ return 0;
+ }
+
+ SwNumRule* pDefaultNumRuleForNewList = m_rSwdoc.FindNumRulePtr( sDefaultListStyleName );
+ if ( !pDefaultNumRuleForNewList )
+ {
+ OSL_FAIL( "<DocumentListsManager::createList(..)> - for provided default list style name no list style is found. Serious defect -> please inform OD." );
+ return 0;
+ }
+
+ SwList* pNewList = new SwList( sListId, *pDefaultNumRuleForNewList, m_rSwdoc.GetNodes() );
+ maLists[sListId] = pNewList;
+
+ return pNewList;
+}
+
+void DocumentListsManager::deleteList( const OUString& sListId )
+{
+ SwList* pList = getListByName( sListId );
+ if ( pList )
+ {
+ maLists.erase( sListId );
+ delete pList;
+ }
+}
+
+SwList* DocumentListsManager::getListByName( const OUString& sListId ) const
+{
+ SwList* pList = 0;
+
+ boost::unordered_map< OUString, SwList*, OUStringHash >::const_iterator
+ aListIter = maLists.find( sListId );
+ if ( aListIter != maLists.end() )
+ {
+ pList = (*aListIter).second;
+ }
+
+ return pList;
+}
+
+SwList* DocumentListsManager::createListForListStyle( const OUString& sListStyleName )
+{
+ if ( sListStyleName.isEmpty() )
+ {
+ OSL_FAIL( "<DocumentListsManager::createListForListStyle(..)> - no list style name provided. Serious defect -> please inform OD." );
+ return 0;
+ }
+
+ if ( getListForListStyle( sListStyleName ) )
+ {
+ OSL_FAIL( "<DocumentListsManager::createListForListStyle(..)> - a list for the provided list style name already exists. Serious defect -> please inform OD." );
+ return 0;
+ }
+
+ SwNumRule* pNumRule = m_rSwdoc.FindNumRulePtr( sListStyleName );
+ if ( !pNumRule )
+ {
+ OSL_FAIL( "<DocumentListsManager::createListForListStyle(..)> - for provided list style name no list style is found. Serious defect -> please inform OD." );
+ return 0;
+ }
+
+ OUString sListId( pNumRule->GetDefaultListId() ); // can be empty String
+ if ( getListByName( sListId ) )
+ {
+ sListId = OUString();
+ }
+ SwList* pNewList = createList( sListId, sListStyleName );
+ maListStyleLists[sListStyleName] = pNewList;
+ pNumRule->SetDefaultListId( pNewList->GetListId() );
+
+ return pNewList;
+}
+
+SwList* DocumentListsManager::getListForListStyle( const OUString& sListStyleName ) const
+{
+ SwList* pList = 0;
+
+ boost::unordered_map< OUString, SwList*, OUStringHash >::const_iterator
+ aListIter = maListStyleLists.find( sListStyleName );
+ if ( aListIter != maListStyleLists.end() )
+ {
+ pList = (*aListIter).second;
+ }
+
+ return pList;
+}
+
+void DocumentListsManager::deleteListForListStyle( const OUString& sListStyleName )
+{
+ OUString sListId;
+ {
+ SwList* pList = getListForListStyle( sListStyleName );
+ OSL_ENSURE( pList,
+ "<DocumentListsManager::deleteListForListStyle(..)> - misusage of method: no list found for given list style name" );
+ if ( pList )
+ {
+ sListId = pList->GetListId();
+ }
+ }
+ if ( !sListId.isEmpty() )
+ {
+ maListStyleLists.erase( sListStyleName );
+ deleteList( sListId );
+ }
+}
+
+void DocumentListsManager::deleteListsByDefaultListStyle( const OUString& rListStyleName )
+{
+ std::vector< SwList* > aListsForDeletion;
+ tHashMapForLists::iterator aListIter = maLists.begin();
+ while ( aListIter != maLists.end() )
+ {
+ SwList* pList = (*aListIter).second;
+ if ( pList->GetDefaultListStyleName() == rListStyleName )
+ {
+ aListsForDeletion.push_back( pList );
+ }
+ ++aListIter;
+ }
+ while ( !aListsForDeletion.empty() )
+ {
+ SwList* pList = aListsForDeletion.back();
+ aListsForDeletion.pop_back();
+ deleteList( pList->GetListId() );
+ }
+}
+
+void DocumentListsManager::trackChangeOfListStyleName( const OUString& sListStyleName,
+ const OUString& sNewListStyleName )
+{
+ SwList* pList = getListForListStyle( sListStyleName );
+ OSL_ENSURE( pList,
+ "<DocumentListsManager::changeOfListStyleName(..)> - misusage of method: no list found for given list style name" );
+
+ if ( pList != 0 )
+ {
+ maListStyleLists.erase( sListStyleName );
+ maListStyleLists[sNewListStyleName] = pList;
+ }
+}
+
+
+
+
+DocumentListsManager::~DocumentListsManager()
+{
+ for ( boost::unordered_map< OUString, SwList*, OUStringHash >::iterator
+ aListIter = maLists.begin();
+ aListIter != maLists.end();
+ ++aListIter )
+ {
+ delete (*aListIter).second;
+ }
+ maLists.clear();
+
+ maListStyleLists.clear();
+}
+
+
+const OUString DocumentListsManager::MakeListIdUnique( const OUString& aSuggestedUniqueListId )
+{
+ long nHitCount = 0;
+ OUString aTmpStr = aSuggestedUniqueListId;
+ while ( getListByName( aTmpStr ) )
+ {
+ ++nHitCount;
+ aTmpStr = aSuggestedUniqueListId;
+ aTmpStr += OUString::number( nHitCount );
+ }
+
+ return aTmpStr;
+}
+
+const OUString DocumentListsManager::CreateUniqueListId()
+{
+ static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
+ if (bHack)
+ {
+ static sal_Int64 nIdCounter = SAL_CONST_INT64(7000000000);
+ return MakeListIdUnique( OUString( "list" + OUString::number(nIdCounter++) ) );
+ }
+ else
+ {
+ // #i92478#
+ OUString aNewListId( "list" );
+ // #o12311627#
+ static rtlRandomPool s_RandomPool( rtl_random_createPool() );
+ sal_Int64 n;
+ rtl_random_getBytes( s_RandomPool, &n, sizeof(n) );
+ aNewListId += OUString::number( (n < 0 ? -n : n) );
+
+ return MakeListIdUnique( aNewListId );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 0b9692d..9ff3443 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -25,6 +25,7 @@
#include <DocumentChartDataProviderManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
#include <DocumentListItemsManager.hxx>
+#include <DocumentListsManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
@@ -319,6 +320,17 @@ IDocumentListItems & SwDoc::getIDocumentListItems()
return *m_pDocumentListItemsManager;
}
+//IDocumentListsAccess
+IDocumentListsAccess const & SwDoc::getIDocumentListsAccess() const
+{
+ return *m_pDocumentListsManager;
+}
+
+IDocumentListsAccess & SwDoc::getIDocumentListsAccess()
+{
+ return *m_pDocumentListsManager;
+}
+
/* Implementations the next Interface here */
/*
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index ef8d4c2..4cfd187 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -94,6 +94,7 @@
#include <DocumentTimerManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
#include <DocumentListItemsManager.hxx>
+#include <DocumentListsManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -102,7 +103,6 @@
#include <pausethreadstarting.hxx>
#include <numrule.hxx>
#include <list.hxx>
-#include <listfunc.hxx>
#include <sfx2/Metadatable.hxx>
#include <fmtmeta.hxx>
@@ -201,6 +201,7 @@ SwDoc::SwDoc()
m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ),
m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ),
m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
+ m_pDocumentListsManager( new ::sw::DocumentListsManager( *this ) ),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -231,8 +232,6 @@ SwDoc::SwDoc()
mpURLStateChgd( 0 ),
mpNumberFormatter( 0 ),
mpNumRuleTbl( new SwNumRuleTbl ),
- maLists(),
- maListStyleLists(),
mpRedlineTbl( new SwRedlineTbl ),
mpExtraRedlineTbl ( new SwExtraRedlineTbl ),
mpAutoFmtRedlnComment( 0 ),
@@ -598,18 +597,6 @@ SwDoc::~SwDoc()
delete mpDfltGrfFmtColl;
delete mpNumRuleTbl;
- {
- for ( boost::unordered_map< OUString, SwList*, OUStringHash >::iterator
- aListIter = maLists.begin();
- aListIter != maLists.end();
- ++aListIter )
- {
- delete (*aListIter).second;
- }
- maLists.clear();
- }
- maListStyleLists.clear();
-
disposeXForms(); // #i113606#, dispose the XForms objects
delete mpNumberFormatter;
@@ -725,18 +712,6 @@ void SwDoc::ClearDoc()
BOOST_FOREACH( SwNumRule* pNumRule, *mpNumRuleTbl )
delete pNumRule;
mpNumRuleTbl->clear();
- // #i114725#,#i115828#
- {
- for ( boost::unordered_map< OUString, SwList*, OUStringHash >::iterator
- aListIter = maLists.begin();
- aListIter != maLists.end();
- ++aListIter )
- {
- delete (*aListIter).second;
- }
- maLists.clear();
- }
- maListStyleLists.clear();
// creation of new outline numbering rule
mpOutlineRule = new SwNumRule( SwNumRule::GetOutlineRuleName(),
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 35944bd..e582dae 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -25,6 +25,7 @@
#include <ftnidx.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentListsAccess.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
#include <doctxm.hxx>
@@ -48,7 +49,6 @@
#include <SwStyleNameMapper.hxx>
#include <SwNodeNum.hxx>
#include <list.hxx>
-#include <listfunc.hxx>
#include <switerator.hxx>
#include <comphelper/string.hxx>
@@ -105,7 +105,7 @@ void SwDoc::SetOutlineNumRule( const SwNumRule& rRule )
}
mpOutlineRule->SetRuleType( OUTLINE_RULE );
- mpOutlineRule->SetName(SwNumRule::GetOutlineRuleName(), *this);
+ mpOutlineRule->SetName(SwNumRule::GetOutlineRuleName(), getIDocumentListsAccess());
// assure that the outline numbering rule is an automatic rule
mpOutlineRule->SetAutoRule( true );
@@ -874,7 +874,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam,
else
{
// create new list and apply its list id
- const SwList* pNewList = createList( OUString(), pNewOrChangedNumRule->GetName() );
+ const SwList* pNewList = getIDocumentListsAccess().createList( OUString(), pNewOrChangedNumRule->GetName() );
OSL_ENSURE( pNewList,
"<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." );
sListId = pNewList->GetListId();
@@ -1027,28 +1027,8 @@ bool SwDoc::DelNumRule( const OUString& rName, bool bBroadcast )
BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PSEUDO,
SFX_STYLESHEET_ERASED);
- deleteListForListStyle( rName );
- {
- // delete further list, which have the deleted list style as default list style
- std::vector< SwList* > aListsForDeletion;
- tHashMapForLists::iterator aListIter = maLists.begin();
- while ( aListIter != maLists.end() )
- {
- SwList* pList = (*aListIter).second;
- if ( pList->GetDefaultListStyleName() == rName )
- {
- aListsForDeletion.push_back( pList );
- }
-
- ++aListIter;
- }
- while ( !aListsForDeletion.empty() )
- {
- SwList* pList = aListsForDeletion.back();
- aListsForDeletion.pop_back();
- deleteList( pList->GetListId() );
- }
- }
+ getIDocumentListsAccess().deleteListForListStyle( rName );
+ getIDocumentListsAccess().deleteListsByDefaultListStyle( rName );
// #i34097# DeleteAndDestroy deletes rName if
// rName is directly taken from the numrule.
const OUString aTmpName( rName );
@@ -1100,7 +1080,7 @@ bool SwDoc::RenameNumRule(const OUString & rOldName, const OUString & rNewName,
SwNumRule::tTxtNodeList aTxtNodeList;
pNumRule->GetTxtNodeList( aTxtNodeList );
- pNumRule->SetName( rNewName, *this );
+ pNumRule->SetName( rNewName, getIDocumentListsAccess() );
SwNumRuleItem aItem(rNewName);
@@ -1251,7 +1231,7 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM)
if ( aListStyleData.pReplaceNumRule == 0 )
{
aListStyleData.pReplaceNumRule = new SwNumRule(*pRule);
- aListStyleData.pReplaceNumRule->SetName( GetUniqueNumRuleName(), *this );
+ aListStyleData.pReplaceNumRule->SetName( GetUniqueNumRuleName(), getIDocumentListsAccess() );
aListStyleData.bCreateNewList = true;
}
@@ -2152,7 +2132,7 @@ void SwDoc::AddNumRule(SwNumRule * pRule)
maNumRuleMap[pRule->GetName()] = pRule;
pRule->SetNumRuleMap(&maNumRuleMap);
- createListForListStyle( pRule->GetName() );
+ getIDocumentListsAccess().createListForListStyle( pRule->GetName() );
}
sal_uInt16 SwDoc::MakeNumRule( const OUString &rName,
@@ -2165,7 +2145,7 @@ sal_uInt16 SwDoc::MakeNumRule( const OUString &rName,
{
pNew = new SwNumRule( *pCpy );
- pNew->SetName( GetUniqueNumRuleName( &rName ), *this );
+ pNew->SetName( GetUniqueNumRuleName( &rName ), getIDocumentListsAccess() );
if( pNew->GetName() != rName )
{
@@ -2296,7 +2276,7 @@ void SwDoc::MarkListLevel( const OUString& sListId,
const int nListLevel,
const bool bValue )
{
- SwList* pList = getListByName( sListId );
+ SwList* pList = getIDocumentListsAccess().getListByName( sListId );
if ( pList )
{
@@ -2365,177 +2345,5 @@ void SwDoc::getOutlineNodes( IDocumentOutlineNodes::tSortedOutlineNodeList& orOu
}
}
-// implementation of interface IDocumentListsAccess
-SwList* SwDoc::createList( const OUString& rListId,
- const OUString& sDefaultListStyleName )
-{
- OUString sListId = rListId;
- if ( sListId.isEmpty() )
- {
- sListId = listfunc::CreateUniqueListId( *this );
- }
-
- if ( getListByName( sListId ) )
- {
- OSL_FAIL( "<SwDoc::createList(..)> - provided list id already used. Serious defect -> please inform OD." );
- return 0;
- }
-
- SwNumRule* pDefaultNumRuleForNewList = FindNumRulePtr( sDefaultListStyleName );
- if ( !pDefaultNumRuleForNewList )
- {
- OSL_FAIL( "<SwDoc::createList(..)> - for provided default list style name no list style is found. Serious defect -> please inform OD." );
- return 0;
- }
-
- SwList* pNewList = new SwList( sListId, *pDefaultNumRuleForNewList, GetNodes() );
- maLists[sListId] = pNewList;
-
- return pNewList;
-}
-
-void SwDoc::deleteList( const OUString& sListId )
-{
- SwList* pList = getListByName( sListId );
- if ( pList )
- {
- maLists.erase( sListId );
- delete pList;
- }
-}
-
-SwList* SwDoc::getListByName( const OUString& sListId ) const
-{
- SwList* pList = 0;
-
- boost::unordered_map< OUString, SwList*, OUStringHash >::const_iterator
- aListIter = maLists.find( sListId );
- if ( aListIter != maLists.end() )
- {
- pList = (*aListIter).second;
- }
-
- return pList;
-}
-
-SwList* SwDoc::createListForListStyle( const OUString& sListStyleName )
-{
- if ( sListStyleName.isEmpty() )
- {
- OSL_FAIL( "<SwDoc::createListForListStyle(..)> - no list style name provided. Serious defect -> please inform OD." );
- return 0;
- }
-
- if ( getListForListStyle( sListStyleName ) )
- {
- OSL_FAIL( "<SwDoc::createListForListStyle(..)> - a list for the provided list style name already exists. Serious defect -> please inform OD." );
- return 0;
- }
-
- SwNumRule* pNumRule = FindNumRulePtr( sListStyleName );
- if ( !pNumRule )
- {
- OSL_FAIL( "<SwDoc::createListForListStyle(..)> - for provided list style name no list style is found. Serious defect -> please inform OD." );
- return 0;
- }
-
- OUString sListId( pNumRule->GetDefaultListId() ); // can be empty String
- if ( getListByName( sListId ) )
- {
- sListId = OUString();
- }
- SwList* pNewList = createList( sListId, sListStyleName );
- maListStyleLists[sListStyleName] = pNewList;
- pNumRule->SetDefaultListId( pNewList->GetListId() );
-
- return pNewList;
-}
-
-SwList* SwDoc::getListForListStyle( const OUString& sListStyleName ) const
-{
- SwList* pList = 0;
-
- boost::unordered_map< OUString, SwList*, OUStringHash >::const_iterator
- aListIter = maListStyleLists.find( sListStyleName );
- if ( aListIter != maListStyleLists.end() )
- {
- pList = (*aListIter).second;
- }
-
- return pList;
-}
-
-void SwDoc::deleteListForListStyle( const OUString& sListStyleName )
-{
- OUString sListId;
- {
- SwList* pList = getListForListStyle( sListStyleName );
- OSL_ENSURE( pList,
- "<SwDoc::deleteListForListStyle(..)> - misusage of method: no list found for given list style name" );
- if ( pList )
- {
- sListId = pList->GetListId();
- }
- }
- if ( !sListId.isEmpty() )
- {
- maListStyleLists.erase( sListStyleName );
- deleteList( sListId );
- }
-}
-
-void SwDoc::trackChangeOfListStyleName( const OUString& sListStyleName,
- const OUString& sNewListStyleName )
-{
- SwList* pList = getListForListStyle( sListStyleName );
- OSL_ENSURE( pList,
- "<SwDoc::changeOfListStyleName(..)> - misusage of method: no list found for given list style name" );
-
- if ( pList != 0 )
- {
- maListStyleLists.erase( sListStyleName );
- maListStyleLists[sNewListStyleName] = pList;
- }
-}
-
-namespace listfunc
-{
- const OUString MakeListIdUnique( const SwDoc& rDoc,
- const OUString& aSuggestedUniqueListId )
- {
- long nHitCount = 0;
- OUString aTmpStr = aSuggestedUniqueListId;
- while ( rDoc.getListByName( aTmpStr ) )
- {
- ++nHitCount;
- aTmpStr = aSuggestedUniqueListId;
- aTmpStr += OUString::number( nHitCount );
- }
-
- return aTmpStr;
- }
- const OUString CreateUniqueListId( const SwDoc& rDoc )
- {
- static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
-
- if (bHack)
- {
- static sal_Int64 nIdCounter = SAL_CONST_INT64(7000000000);
- return MakeListIdUnique( rDoc, OUString( "list" + OUString::number(nIdCounter++) ) );
- }
- else
- {
- // #i92478#
- OUString aNewListId( "list" );
- // #o12311627#
- static rtlRandomPool s_RandomPool( rtl_random_createPool() );
- sal_Int64 n;
- rtl_random_getBytes( s_RandomPool, &n, sizeof(n) );
- aNewListId += OUString::number( (n < 0 ? -n : n) );
-
- return MakeListIdUnique( rDoc, aNewListId );
- }
- }
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 66c156f..3645ca4 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -881,7 +881,7 @@ void SwNumRule::SetInvalidRule(bool bFlag)
{
const SwTxtNode* pTxtNode = *aIter;
// #i111681# - applying patch from cmc
- SwList* pList = pTxtNode->GetDoc()->getListByName( pTxtNode->GetListId() );
+ SwList* pList = pTxtNode->GetDoc()->getIDocumentListsAccess().getListByName( pTxtNode->GetListId() );
OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue --> please inform OD.");
if ( pList )
{
@@ -995,7 +995,7 @@ void SwNumRule::Validate()
for ( aIter = maTxtNodeList.begin(); aIter != maTxtNodeList.end(); ++aIter )
{
const SwTxtNode* pTxtNode = *aIter;
- aLists.insert( pTxtNode->GetDoc()->getListByName( pTxtNode->GetListId() ) );
+ aLists.insert( pTxtNode->GetDoc()->getIDocumentListsAccess().getListByName( pTxtNode->GetListId() ) );
}
std::for_each( aLists.begin(), aLists.end(),
std::mem_fun( &SwList::ValidateListTree ) );
diff --git a/sw/source/core/inc/DocumentListsManager.hxx b/sw/source/core/inc/DocumentListsManager.hxx
new file mode 100644
index 0000000..6d01d04
--- /dev/null
+++ b/sw/source/core/inc/DocumentListsManager.hxx
@@ -0,0 +1,73 @@
+/* -*- 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_DOCUMENTLISTSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTSMANAGER_HXX
+
+#include <IDocumentListsAccess.hxx>
+#include <boost/utility.hpp>
+#include <boost/unordered_map.hpp>
+
+class SwList;
+class SwDoc;
+
+namespace sw
+{
+
+
+class DocumentListsManager : public IDocumentListsAccess,
+ public ::boost::noncopyable
+{
+ public:
+
+ DocumentListsManager( SwDoc& i_rSwdoc );
+
+ SwList* createList( const OUString& rListId,
+ const OUString& rDefaultListStyleName ) SAL_OVERRIDE;
+ void deleteList( const OUString& rListId ) SAL_OVERRIDE;
+ SwList* getListByName( const OUString& rListId ) const SAL_OVERRIDE;
+
+ SwList* createListForListStyle( const OUString& rListStyleName ) SAL_OVERRIDE;
+ SwList* getListForListStyle( const OUString& rListStyleName ) const SAL_OVERRIDE;
+ void deleteListForListStyle( const OUString& rListStyleName ) SAL_OVERRIDE;
+ void deleteListsByDefaultListStyle( const OUString& rListStyleName ) SAL_OVERRIDE;
+ // #i91400#
+ void trackChangeOfListStyleName( const OUString& rListStyleName,
+ const OUString& rNewListStyleName ) SAL_OVERRIDE;
+ ~DocumentListsManager();
+
+ private:
+
+ SwDoc& m_rSwdoc;
+
+ typedef boost::unordered_map<OUString, SwList*, OUStringHash> tHashMapForLists;
+ // container to hold the lists of the text document
+ tHashMapForLists maLists;
+ // relation between list style and its default list
+ tHashMapForLists maListStyleLists;
+
+ const OUString CreateUniqueListId();
+ const OUString MakeListIdUnique( const OUString& aSuggestedUniqueListId );
+};
+
+}
+
+#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTSMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 01f9e9a..b31e661 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -52,6 +52,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentListsAccess.hxx>
#include <docary.hxx>
#include <pam.hxx>
#include <fldbas.hxx>
@@ -2522,7 +2523,7 @@ bool SwTxtNode::HasMarkedLabel() const
if ( IsInList() )
{
bResult =
- GetDoc()->getListByName( GetListId() )->IsListLevelMarked( GetActualListLevel() );
+ GetDoc()->getIDocumentListsAccess().getListByName( GetListId() )->IsListLevelMarked( GetActualListLevel() );
}
return bResult;
@@ -3985,14 +3986,14 @@ void SwTxtNode::AddToList()
const OUString sListId = GetListId();
if (!sListId.isEmpty())
{
- SwList* pList = GetDoc()->getListByName( sListId );
+ SwList* pList = GetDoc()->getIDocumentListsAccess().getListByName( sListId );
if ( pList == 0 )
{
// Create corresponding list.
SwNumRule* pNumRule = GetNumRule();
if ( pNumRule )
{
- pList = GetDoc()->createList( sListId, GetNumRule()->GetName() );
+ pList = GetDoc()->getIDocumentListsAccess().createList( sListId, GetNumRule()->GetName() );
}
}
OSL_ENSURE( pList != 0,
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index ec4332c..81654e3 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -59,6 +59,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDeviceAccess.hxx>
+#include <IDocumentListsAccess.hxx>
#include "swstyle.h"
#include "frmfmt.hxx"
#include "charfmt.hxx"
@@ -1063,7 +1064,7 @@ sal_uInt16 SwDocShell::UpdateStyle(const OUString &rName, sal_uInt16 nFamily, Sw
SwNumRule aRule( *pCurRule );
// #i91400#
aRule.SetName( pStyle->GetNumRule()->GetName(),
- *(pCurrWrtShell->GetDoc()) );
+ pCurrWrtShell->GetDoc()->getIDocumentListsAccess() );
pCurrWrtShell->ChgNumRuleFmts( aRule );
}
}
@@ -1206,7 +1207,7 @@ sal_uInt16 SwDocShell::MakeByExample( const OUString &rName, sal_uInt16 nFamily,
OUString sOrigRule( aRule.GetName() );
// #i91400#
aRule.SetName( pStyle->GetNumRule()->GetName(),
- *(pCurrWrtShell->GetDoc()) );
+ pCurrWrtShell->GetDoc()->getIDocumentListsAccess() );
pCurrWrtShell->ChgNumRuleFmts( aRule );
pCurrWrtShell->ReplaceNumRule( sOrigRule, aRule.GetName() );
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 1ca2960..cc609998 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -968,7 +968,7 @@ bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
else
{
// #i91400#
- ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
+ ((SwNumRule*)pNumRule)->SetName( rStr, rDoc.getIDocumentListsAccess() );
rDoc.SetModified();
bChg = true;
@@ -1870,7 +1870,7 @@ void SwDocStyleSheet::Create()
if( aName.isEmpty() )
{
// #i91400#
- pRule->SetName( aName, rDoc );
+ pRule->SetName( aName, rDoc.getIDocumentListsAccess() );
}
pNumRule = pRule;
}
commit 41525e894f90fd2568f09b83f7a35a85a63b018c
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date: Mon Jun 23 14:56:59 2014 +0200
Refactored IDocumentListItems out of SwDoc.
Into the new class DocumentListItemsManager.
Change-Id: Ic86200280caa1b6e2c940bb12149235223ed0cd2
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 9374bc5..79691a4 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -190,6 +190,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/DocumentChartDataProviderManager \
sw/source/core/doc/DocumentTimerManager \
sw/source/core/doc/DocumentLinksAdministrationManager \
+ sw/source/core/doc/DocumentListItemsManager \
sw/source/core/doc/extinput \
sw/source/core/doc/fmtcol \
sw/source/core/doc/ftnidx \
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 315ac3a..baa18c5 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -31,7 +31,6 @@
#include <IDocumentState.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <IDocumentOutlineNodes.hxx>
-#include <IDocumentListItems.hxx>
#include <IDocumentListsAccess.hxx>
class SwList;
@@ -195,6 +194,7 @@ class IDocumentDrawModelAccess;
class IDocumentChartDataProviderAccess;
class IDocumentTimerAccess;
class IDocumentLinksAdministration;
+class IDocumentListItems;
class _SetGetExpFlds;
namespace sw { namespace mark {
@@ -210,6 +210,7 @@ namespace sw {
class DocumentChartDataProviderManager;
class DocumentTimerManager;
class DocumentLinksAdministrationManager;
+ class DocumentListItemsManager;
}
namespace com { namespace sun { namespace star {
@@ -255,7 +256,6 @@ class SW_DLLPUBLIC SwDoc :
public IDocumentStatistics,
public IDocumentState,
public IDocumentLayoutAccess,
- public IDocumentListItems,
public IDocumentOutlineNodes,
public IDocumentListsAccess,
public IDocumentExternalData
@@ -291,6 +291,7 @@ class SW_DLLPUBLIC SwDoc :
::boost::scoped_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess;
const ::boost::scoped_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
const ::boost::scoped_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
+ const ::boost::scoped_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
// Pointer
SwFrmFmt *mpDfltFrmFmt; //< Default formats.
@@ -368,17 +369,8 @@ class SW_DLLPUBLIC SwDoc :
rtl::Reference<SvxForbiddenCharactersTable> mxForbiddenCharsTable;
com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents;
com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> m_xTemplateToProjectCache;
-public:
- struct lessThanNodeNum
- {
- bool operator()( const SwNodeNum* pNodeNumOne,
- const SwNodeNum* pNodeNumTwo ) const;
- };
- typedef ::std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList;
private:
- tImplSortedNodeNumList* mpListItemsList;
-
::std::auto_ptr< ::sfx2::IXmlIdRegistry > m_pXmlIdRegistry;
// other
@@ -774,13 +766,8 @@ public:
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess();
// IDocumentListItems
- virtual void addListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
- virtual void removeListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
- virtual OUString getListItemText( const SwNodeNum& rNodeNum,
- const bool bWithNumber = true,
- const bool bWithSpacesForLevel = false ) const SAL_OVERRIDE;
- virtual void getListItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
- virtual void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
+ IDocumentListItems const & getIDocumentListItems() const;
+ IDocumentListItems & getIDocumentListItems();
// IDocumentOutlineNodes
virtual sal_Int32 getOutlineNodesCount() const SAL_OVERRIDE;
diff --git a/sw/source/core/doc/DocumentListItemsManager.cxx b/sw/source/core/doc/DocumentListItemsManager.cxx
new file mode 100644
index 0000000..5844fd2
--- /dev/null
+++ b/sw/source/core/doc/DocumentListItemsManager.cxx
@@ -0,0 +1,121 @@
+/* -*- 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 .
+ */
+
+#include <DocumentListItemsManager.hxx>
+#include <SwNodeNum.hxx>
+#include <ndtxt.hxx>
+
+
+namespace sw
+{
+
+DocumentListItemsManager::DocumentListItemsManager() : mpListItemsList( new tImplSortedNodeNumList() ) // #i83479#
+{
+}
+
+bool DocumentListItemsManager::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
+ const SwNodeNum* pNodeNumTwo ) const
+{
+ return pNodeNumOne->LessThan( *pNodeNumTwo );
+}
+
+void DocumentListItemsManager::addListItem( const SwNodeNum& rNodeNum )
+{
+ if ( mpListItemsList == 0 )
+ {
+ return;
+ }
+
+ const bool bAlreadyInserted(
+ mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
+ OSL_ENSURE( !bAlreadyInserted,
+ "<DocumentListItemsManager::addListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
+ if ( !bAlreadyInserted )
+ {
+ mpListItemsList->insert( &rNodeNum );
+ }
+}
+
+void DocumentListItemsManager::removeListItem( const SwNodeNum& rNodeNum )
+{
+ if ( mpListItemsList == 0 )
+ {
+ return;
+ }
+
+ const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
+ if ( nDeleted > 1 )
+ {
+ OSL_FAIL( "<DocumentListItemsManager::removeListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
+ }
+}
+
+OUString DocumentListItemsManager::getListItemText( const SwNodeNum& rNodeNum,
+ const bool bWithNumber,
+ const bool bWithSpacesForLevel ) const
+{
+ return rNodeNum.GetTxtNode()
+ ? rNodeNum.GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
+ bWithNumber, bWithSpacesForLevel )
+ : OUString();
+}
+
+void DocumentListItemsManager::getListItems( tSortedNodeNumList& orNodeNumList ) const
+{
+ orNodeNumList.clear();
+ orNodeNumList.reserve( mpListItemsList->size() );
+
+ tImplSortedNodeNumList::iterator aIter;
+ tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
+ for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
+ {
+ orNodeNumList.push_back( (*aIter) );
+ }
+}
+
+void DocumentListItemsManager::getNumItems( tSortedNodeNumList& orNodeNumList ) const
+{
+ orNodeNumList.clear();
+ orNodeNumList.reserve( mpListItemsList->size() );
+
+ tImplSortedNodeNumList::iterator aIter;
+ tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
+ for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
+ {
+ const SwNodeNum* pNodeNum = (*aIter);
+ if ( pNodeNum->IsCounted() &&
+ pNodeNum->GetTxtNode() && pNodeNum->GetTxtNode()->HasNumber() )
+ {
+ orNodeNumList.push_back( pNodeNum );
+ }
+ }
+}
+
+DocumentListItemsManager::~DocumentListItemsManager()
+{
+// #i83479#
+delete mpListItemsList;
+mpListItemsList = 0;
+}
+
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index e565831..0b9692d 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -24,6 +24,7 @@
#include <DocumentDeviceManager.hxx>
#include <DocumentChartDataProviderManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
+#include <DocumentListItemsManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
@@ -306,6 +307,17 @@ IDocumentLinksAdministration & SwDoc::getIDocumentLinksAdministration()
return *m_pDocumentLinksAdministrationManager;
}
+//IDocumentListItems
+IDocumentListItems const & SwDoc::getIDocumentListItems() const
+{
+ return *m_pDocumentListItemsManager;
+}
+
+//IDocumentListItems
+IDocumentListItems & SwDoc::getIDocumentListItems()
+{
+ return *m_pDocumentListItemsManager;
+}
/* Implementations the next Interface here */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index d2ff828..ef8d4c2 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -93,6 +93,7 @@
#include <DocumentChartDataProviderManager.hxx>
#include <DocumentTimerManager.hxx>
#include <DocumentLinksAdministrationManager.hxx>
+#include <DocumentListItemsManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -199,6 +200,7 @@ SwDoc::SwDoc()
m_pDeviceAccess( new ::sw::DocumentDeviceManager( *this ) ),
m_pDocumentTimerManager( new ::sw::DocumentTimerManager( *this ) ),
m_pDocumentLinksAdministrationManager( new ::sw::DocumentLinksAdministrationManager( *this ) ),
+ m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -242,7 +244,6 @@ SwDoc::SwDoc()
mpLayoutCache( 0 ),
mpUnoCallBack(new SwModify(0)),
mpGrammarContact(createGrammarContact()),
- mpListItemsList( new tImplSortedNodeNumList() ), // #i83479#
m_pXmlIdRegistry(),
mnAutoFmtRedlnCommentNo( 0 ),
meRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
@@ -418,10 +419,6 @@ SwDoc::~SwDoc()
mpDocShell->SetUndoManager(0);
}
- // #i83479#
- delete mpListItemsList;
- mpListItemsList = 0;
-
delete mpGrammarContact;
mpGrammarContact = 0;
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index bf7b4f2..35944bd 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -2325,85 +2325,6 @@ bool SwDoc::IsFirstOfNumRuleAtPos( const SwPosition & rPos )
return bResult;
}
-// implementation for interface <IDocumentListItems>
-bool SwDoc::lessThanNodeNum::operator()( const SwNodeNum* pNodeNumOne,
- const SwNodeNum* pNodeNumTwo ) const
-{
- return pNodeNumOne->LessThan( *pNodeNumTwo );
-}
-
-void SwDoc::addListItem( const SwNodeNum& rNodeNum )
-{
- if ( mpListItemsList == 0 )
- {
- return;
- }
-
- const bool bAlreadyInserted(
- mpListItemsList->find( &rNodeNum ) != mpListItemsList->end() );
- OSL_ENSURE( !bAlreadyInserted,
- "<SwDoc::InsertListItem(..)> - <SwNodeNum> instance already registered as numbered item!" );
- if ( !bAlreadyInserted )
- {
- mpListItemsList->insert( &rNodeNum );
- }
-}
-
-void SwDoc::removeListItem( const SwNodeNum& rNodeNum )
-{
- if ( mpListItemsList == 0 )
- {
- return;
- }
-
- const tImplSortedNodeNumList::size_type nDeleted = mpListItemsList->erase( &rNodeNum );
- if ( nDeleted > 1 )
- {
- OSL_FAIL( "<SwDoc::RemoveListItem(..)> - <SwNodeNum> was registered more than once as numbered item!" );
- }
-}
-
-OUString SwDoc::getListItemText( const SwNodeNum& rNodeNum,
- const bool bWithNumber,
- const bool bWithSpacesForLevel ) const
-{
- return rNodeNum.GetTxtNode()
- ? rNodeNum.GetTxtNode()->GetExpandTxt( 0, -1, bWithNumber,
- bWithNumber, bWithSpacesForLevel )
- : OUString();
-}
-
-void SwDoc::getListItems( tSortedNodeNumList& orNodeNumList ) const
-{
- orNodeNumList.clear();
- orNodeNumList.reserve( mpListItemsList->size() );
-
- tImplSortedNodeNumList::iterator aIter;
- tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
- for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
- {
- orNodeNumList.push_back( (*aIter) );
- }
-}
-
-void SwDoc::getNumItems( tSortedNodeNumList& orNodeNumList ) const
-{
- orNodeNumList.clear();
- orNodeNumList.reserve( mpListItemsList->size() );
-
- tImplSortedNodeNumList::iterator aIter;
- tImplSortedNodeNumList::iterator aEndIter = mpListItemsList->end();
- for ( aIter = mpListItemsList->begin(); aIter != aEndIter; ++aIter )
- {
- const SwNodeNum* pNodeNum = (*aIter);
- if ( pNodeNum->IsCounted() &&
- pNodeNum->GetTxtNode() && pNodeNum->GetTxtNode()->HasNumber() )
- {
- orNodeNumList.push_back( pNodeNum );
- }
- }
-}
-
// implementation for interface <IDocumentOutlineNodes>
sal_Int32 SwDoc::getOutlineNodesCount() const
{
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 0af3c7c..0800d5e 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1927,7 +1927,7 @@ IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return
const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); }
IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); }
IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return GetDoc(); }
-IDocumentListItems& SwNode::getIDocumentListItems() { return *GetDoc(); } // #i83479#
+IDocumentListItems& SwNode::getIDocumentListItems() { return GetDoc()->getIDocumentListItems(); } // #i83479#
const IDocumentMarkAccess* SwNode::getIDocumentMarkAccess() const { return GetDoc()->getIDocumentMarkAccess(); }
IStyleAccess& SwNode::getIDocumentStyleAccess() { return GetDoc()->GetIStyleAccess(); }
diff --git a/sw/source/core/inc/DocumentListItemsManager.hxx b/sw/source/core/inc/DocumentListItemsManager.hxx
new file mode 100644
index 0000000..c292967
--- /dev/null
+++ b/sw/source/core/inc/DocumentListItemsManager.hxx
@@ -0,0 +1,69 @@
+/* -*- 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_DOCUMENTLISTITEMSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX
+
+#include <IDocumentListItems.hxx>
+#include <boost/utility.hpp>
+#include <set>
+
+namespace sw
+{
+
+class DocumentListItemsManager : public IDocumentListItems,
+ public ::boost::noncopyable
+{
+public:
+
+ DocumentListItemsManager();
+
+ void addListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
+ void removeListItem( const SwNodeNum& rNodeNum ) SAL_OVERRIDE;
+
+ OUString getListItemText( const SwNodeNum& rNodeNum,
+ const bool bWithNumber = true,
+ const bool bWithSpacesForLevel = false ) const SAL_OVERRIDE;
+
+ void getListItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
+
+ void getNumItems( IDocumentListItems::tSortedNodeNumList& orNodeNumList ) const SAL_OVERRIDE;
+
+ virtual ~DocumentListItemsManager();
+
+
+ //Non Interface
+ struct lessThanNodeNum
+ {
+ bool operator()( const SwNodeNum* pNodeNumOne,
+ const SwNodeNum* pNodeNumTwo ) const;
+ };
+
+ typedef ::std::set< const SwNodeNum*, lessThanNodeNum > tImplSortedNodeNumList;
+
+private:
+
+ tImplSortedNodeNumList* mpListItemsList;
+};
+
+}
+
+ #endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTLISTITEMSMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index cc80298..b17ae5e 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2540,7 +2540,7 @@ IDocumentUndoRedo const& SwViewShell::GetIDocumentUndoRedo() const
// --> OD 2007-11-14 #i83479#
const IDocumentListItems* SwViewShell::getIDocumentListItemsAccess() const
{
- return mpDoc;
+ return &mpDoc->getIDocumentListItems();
}
const IDocumentOutlineNodes* SwViewShell::getIDocumentOutlineNodesAccess() const
commit 5eb4dd9c934bb0cb95a0bb1f8a51e2bc77f81e8a
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date: Sun Jun 15 20:54:04 2014 +0200
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
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 68080e5..9374bc5 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 a0b3ee6..8d4f4c7 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 1ba457c..315ac3a 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 5bd6dc9..6452bdf 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 7dc30f9..11ffcae 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
similarity index 52%
rename from sw/source/core/doc/docdde.cxx
rename to sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index f321b05..bcd3464 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 ca9eca1..e565831 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>
@@ -284,6 +285,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 */
@@ -2034,90 +2056,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 818fef1..d2ff828 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>
@@ -197,6 +198,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 ) ),
@@ -223,7 +225,6 @@ SwDoc::SwDoc()
mpFtnIdxs( new SwFtnIdxs ),
mpDocStat( new SwDocStat ),
mpDocShell( 0 ),
- mpLinkMgr( new sfx2::LinkManager( 0 ) ),
mpACEWord( 0 ),
mpURLStateChgd( 0 ),
mpNumberFormatter( 0 ),
@@ -256,7 +257,6 @@ SwDoc::SwDoc()
mbNewDoc(false),
mbNewFldLst(true),
mbCopyIsMove(false),
- mbVisibleLinks(true),
mbInReading(false),
mbInXMLImport(false),
mbUpdateTOX(false),
@@ -269,7 +269,6 @@ SwDoc::SwDoc()
mbInsOnlyTxtGlssry(false),
mbContains_MSVBasic(false),
mbReadlineChecked(false),
- mbLinksUpdated( false ), //#i38810#
mbClipBoard( false ),
mbColumnSelection( false ),
mbIsPrepareSelAll(false),
@@ -465,13 +464,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
@@ -586,7 +585,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.
@@ -647,7 +646,7 @@ void SwDoc::SetDocShell( SwDocShell* pDSh )
mpDocShell->SetUndoManager(& GetUndoManager());
}
- mpLinkMgr->SetPersist( mpDocShell );
+ getIDocumentLinksAdministration().GetLinkManager().SetPersist( mpDocShell );
if( GetDocumentDrawModelManager().GetDrawModel() )
{
((SwDrawDocument*)GetDocumentDrawModelManager().GetDrawModel())->SetObjectShell( mpDocShell );
@@ -663,14 +662,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()
@@ -843,50 +842,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 d5e9924..18c6d87 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 b004366..bb66c21 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>
@@ -737,7 +738,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();
@@ -1282,7 +1283,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
@@ -1359,18 +1360,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() );
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list