[Libreoffice-commits] core.git: 2 commits - sw/inc sw/Library_sw.mk sw/source
Valentin Kettner
vakevk+libreoffice at gmail.com
Tue Apr 22 05:40:07 PDT 2014
sw/Library_sw.mk | 2
sw/inc/doc.hxx | 96 +---
sw/source/core/doc/DocumentDeviceManager.cxx | 360 ++++++++++++++++++
sw/source/core/doc/DocumentSettingManager.cxx | 504 +++++++++++++++++++++++++
sw/source/core/doc/doc.cxx | 509 +-------------------------
sw/source/core/doc/docdesc.cxx | 65 ---
sw/source/core/doc/docnew.cxx | 156 +------
sw/source/core/docnode/node.cxx | 2
sw/source/core/inc/DocumentDeviceManager.hxx | 83 ++++
sw/source/core/inc/DocumentSettingManager.hxx | 120 ++++++
sw/source/core/uibase/app/docshini.cxx | 2
sw/source/core/view/viewsh.cxx | 4
12 files changed, 1156 insertions(+), 747 deletions(-)
New commits:
commit 185c270e66d03d1f77beb8a8996393d023e818e7
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date: Fri Apr 11 02:34:05 2014 +0200
Split out the IDocumentDeviceAccess interface of SwDoc.
The interface implementation is now in the class DocumentDeviceManager and
SwDoc has a member variable of that class to which the Interface's
method calls get forwarded.
The following methods were also moved because they are only used by this
interface:
CreateVirtualDevice_, CreatePrinter_ and PrtDataChanged.
Change-Id: I0b0de6540f0c8635ce560381fb924a3d9cd50c0e
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 5e74b79..62b864f 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -185,6 +185,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/docsort \
sw/source/core/doc/docstat \
sw/source/core/doc/doctxm \
+ sw/source/core/doc/DocumentDeviceManager \
sw/source/core/doc/docxforms \
sw/source/core/doc/DocumentSettingManager \
sw/source/core/doc/extinput \
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ce2cc6e..22a3739 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -22,8 +22,9 @@
// SwDoc interfaces
#include <IInterface.hxx>
#include <IDocumentSettingAccess.hxx>
-#include <IDocumentDeviceAccess.hxx>
#include <IDocumentMarkAccess.hxx>
+#include <IDocumentDeviceAccess.hxx> //from this class's persective this isnt even necessary anymore but I encountered at least
+ //one different class that relies on this being included here. What to do?
#include <IDocumentRedlineAccess.hxx>
#include <IDocumentLinksAdministration.hxx>
#include <IDocumentFieldsAccess.hxx>
@@ -209,6 +210,7 @@ namespace sw {
class UndoManager;
class IShellCursorSupplier;
class DocumentSettingManager;
+ class DocumentDeviceManager;
}
namespace com { namespace sun { namespace star {
@@ -247,7 +249,6 @@ void StartGrammarChecking( SwDoc &rDoc );
class SW_DLLPUBLIC SwDoc :
public IInterface,
public IDocumentSettingAccess,
- public IDocumentDeviceAccess,
public IDocumentRedlineAccess,
public IDocumentLinksAdministration,
public IDocumentFieldsAccess,
@@ -271,6 +272,7 @@ class SW_DLLPUBLIC SwDoc :
// private Member
::boost::scoped_ptr<SwNodes> m_pNodes; //< document content (Nodes Array)
+ ::boost::scoped_ptr< ::sw::DocumentDeviceManager > m_DeviceAccess;
SwAttrPool* mpAttrPool; //< the attribute pool
SwPageDescs maPageDescs; //< PageDescriptors
Link maOle2Link; //< OLE 2.0-notification
@@ -320,10 +322,6 @@ class SW_DLLPUBLIC SwDoc :
SwDBMgr *mpDBMgr; /**< Pointer to the DBMgr for
evaluation of DB-fields. */
- VirtualDevice *mpVirDev; //< can be used for formatting
- SfxPrinter *mpPrt; //< can be used for formatting
- SwPrintData *mpPrtData; //< Print configuration
-
SwDoc *mpGlossaryDoc; //< Pointer to glossary-document.
SwNumRule *mpOutlineRule;
@@ -574,12 +572,6 @@ private:
const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt );
SwFmt* FindFmtByName( const SwFmtsBase& rFmtArr, const OUString& rName ) const;
- VirtualDevice& CreateVirtualDevice_() const;
- SfxPrinter& CreatePrinter_() const;
- void PrtDataChanged(); /**< Printer or JobSetup altered.
- Care has to be taken of the necessary
- invalidations and notifications. */
-
// gcc: aFtnInfo::CopyCtor is private, therefore we too have to protect ourselves.
SwDoc( const SwDoc &);
@@ -685,16 +677,18 @@ public:
virtual void setRsidRoot( sal_uInt32 nVal );
// IDocumentDeviceAccess
- virtual SfxPrinter* getPrinter(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
- virtual void setPrinter(/*[in]*/ SfxPrinter* pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged ) SAL_OVERRIDE;
- virtual VirtualDevice* getVirtualDevice(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
- virtual void setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool bCallVirDevDataChanged ) SAL_OVERRIDE;
- virtual OutputDevice* getReferenceDevice(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
- virtual void setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes ) SAL_OVERRIDE;
- virtual const JobSetup* getJobsetup() const SAL_OVERRIDE;
- virtual void setJobsetup(/*[in]*/ const JobSetup& rJobSetup ) SAL_OVERRIDE;
- virtual const SwPrintData & getPrintData() const SAL_OVERRIDE;
- virtual void setPrintData(/*[in]*/ const SwPrintData& rPrtData) SAL_OVERRIDE;
+ const IDocumentDeviceAccess* getIDocumentDeviceAccessConst() const;
+ IDocumentDeviceAccess* getIDocumentDeviceAccess();
+ virtual SfxPrinter* getPrinter(/*[in]*/ bool bCreate ) const;
+ virtual void setPrinter(/*[in]*/ SfxPrinter* pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged );
+ virtual VirtualDevice* getVirtualDevice(/*[in]*/ bool bCreate ) const;
+ virtual void setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool bCallVirDevDataChanged );
+ virtual OutputDevice* getReferenceDevice(/*[in]*/ bool bCreate ) const;
+ virtual void setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes );
+ virtual const JobSetup* getJobsetup() const;
+ virtual void setJobsetup(/*[in]*/ const JobSetup& rJobSetup );
+ virtual const SwPrintData & getPrintData() const;
+ virtual void setPrintData(/*[in]*/ const SwPrintData& rPrtData);
// IDocumentMarkAccess
IDocumentMarkAccess* getIDocumentMarkAccess();
diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx
new file mode 100644
index 0000000..5b5890a
--- /dev/null
+++ b/sw/source/core/doc/DocumentDeviceManager.cxx
@@ -0,0 +1,360 @@
+/* -*- 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 <DocumentDeviceManager.hxx>
+
+#include <IDocumentDeviceAccess.hxx>
+#include <doc.hxx>
+#include <sfx2/printer.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/jobset.hxx>
+#include <printdata.hxx>
+#include <vcl/mapmod.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svdmodel.hxx>
+#include <cmdid.h>
+#include <wdocsh.hxx>
+#include <prtopt.hxx>
+#include <viewsh.hxx>
+#include <rootfrm.hxx>
+#include <viewopt.hxx>
+#include <swwait.hxx>
+#include <fntcache.hxx>
+
+
+class SwDocShell;
+class SwWait;
+
+
+namespace sw {
+
+DocumentDeviceManager::DocumentDeviceManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ), mpPrt(0), mpVirDev(0), mpPrtData(0) {}
+
+SfxPrinter* DocumentDeviceManager::getPrinter(/*[in]*/ bool bCreate ) const
+{
+ SfxPrinter* pRet = 0;
+ if ( !bCreate || mpPrt )
+ pRet = mpPrt;
+ else
+ pRet = &CreatePrinter_();
+
+ return pRet;
+}
+
+void DocumentDeviceManager::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
+{
+ if ( pP != mpPrt )
+ {
+ if ( bDeleteOld )
+ delete mpPrt;
+ mpPrt = pP;
+
+ // our printer should always use TWIP. Don't rely on this being set in SwViewShell::InitPrt, there
+ // are situations where this isn't called.
+ // #i108712# / 2010-02-26 / frank.schoenheit at sun.com
+ if ( mpPrt )
+ {
+ MapMode aMapMode( mpPrt->GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ mpPrt->SetMapMode( aMapMode );
+ }
+
+ if ( m_rSwdoc.GetDrawModel() && !m_rSwdoc.get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
+ m_rSwdoc.GetDrawModel()->SetRefDevice( mpPrt );
+ }
+
+ if ( bCallPrtDataChanged &&
+ // #i41075# Do not call PrtDataChanged() if we do not
+ // use the printer for formatting:
+ !m_rSwdoc.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
+ PrtDataChanged();
+}
+
+VirtualDevice* DocumentDeviceManager::getVirtualDevice(/*[in]*/ bool bCreate ) const
+{
+ VirtualDevice* pRet = 0;
+ if ( !bCreate || mpVirDev )
+ pRet = mpVirDev;
+ else
+ pRet = &CreateVirtualDevice_();
+
+ return pRet;
+}
+
+void DocumentDeviceManager::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
+{
+ if ( mpVirDev != pVd )
+ {
+ if ( bDeleteOld )
+ delete mpVirDev;
+ mpVirDev = pVd;
+
+ if ( m_rSwdoc.GetDrawModel() && m_rSwdoc.get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
+ m_rSwdoc.GetDrawModel()->SetRefDevice( mpVirDev );
+ }
+}
+
+OutputDevice* DocumentDeviceManager::getReferenceDevice(/*[in]*/ bool bCreate ) const
+{
+ OutputDevice* pRet = 0;
+ if ( !m_rSwdoc.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
+ {
+ pRet = getPrinter( bCreate );
+
+ if ( bCreate && !mpPrt->IsValid() )
+ {
+ pRet = getVirtualDevice( true );
+ }
+ }
+ else
+ {
+ pRet = getVirtualDevice( bCreate );
+ }
+
+ return pRet;
+}
+
+void DocumentDeviceManager::setReferenceDeviceType(/*[in]*/ bool bNewVirtual, /*[in]*/ bool bNewHiRes )
+{
+ if ( m_rSwdoc.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual ||
+ m_rSwdoc.get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes )
+ {
+ if ( bNewVirtual )
+ {
+ VirtualDevice* pMyVirDev = getVirtualDevice( true );
+ if ( !bNewHiRes )
+ pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
+ else
+ pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
+
+ if( m_rSwdoc.GetDrawModel() )
+ m_rSwdoc.GetDrawModel()->SetRefDevice( pMyVirDev );
+ }
+ else
+ {
+ // #i41075#
+ // We have to take care that a printer exists before calling
+ // PrtDataChanged() in order to prevent that PrtDataChanged()
+ // triggers this funny situation:
+ // getReferenceDevice()->getPrinter()->CreatePrinter_()
+ // ->setPrinter()-> PrtDataChanged()
+ SfxPrinter* pPrinter = getPrinter( true );
+ if( m_rSwdoc.GetDrawModel() )
+ m_rSwdoc.GetDrawModel()->SetRefDevice( pPrinter );
+ }
+
+ m_rSwdoc.set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );
+ m_rSwdoc.set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
+ PrtDataChanged();
+ m_rSwdoc.SetModified();
+ }
+}
+
+const JobSetup* DocumentDeviceManager::getJobsetup() const
+{
+ return mpPrt ? &mpPrt->GetJobSetup() : 0;
+}
+
+void DocumentDeviceManager::setJobsetup(/*[in]*/ const JobSetup &rJobSetup )
+{
+ bool bCheckPageDescs = 0 == mpPrt;
+ bool bDataChanged = false;
+
+ if ( mpPrt )
+ {
+ if ( mpPrt->GetName() == rJobSetup.GetPrinterName() )
+ {
+ if ( mpPrt->GetJobSetup() != rJobSetup )
+ {
+ mpPrt->SetJobSetup( rJobSetup );
+ bDataChanged = true;
+ }
+ }
+ else
+ delete mpPrt, mpPrt = 0;
+ }
+
+ if( !mpPrt )
+ {
+ //The ItemSet is deleted by Sfx!
+ SfxItemSet *pSet = new SfxItemSet( m_rSwdoc.GetAttrPool(),
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0 );
+ SfxPrinter *p = new SfxPrinter( pSet, rJobSetup );
+ if ( bCheckPageDescs )
+ setPrinter( p, true, true );
+ else
+ {
+ mpPrt = p;
+ bDataChanged = true;
+ }
+ }
+ if ( bDataChanged && !m_rSwdoc.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
+ PrtDataChanged();
+}
+
+const SwPrintData & DocumentDeviceManager::getPrintData() const
+{
+ if(!mpPrtData)
+ {
+ DocumentDeviceManager * pThis = const_cast< DocumentDeviceManager * >(this);
+ pThis->mpPrtData = new SwPrintData;
+
+ // SwPrintData should be initialized from the configuration,
+ // the respective config item is implemented by SwPrintOptions which
+ // is also derived from SwPrintData
+ const SwDocShell *pDocSh = m_rSwdoc.GetDocShell();
+ OSL_ENSURE( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" );
+ bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh);
+ SwPrintOptions aPrintOptions( bWeb );
+ *pThis->mpPrtData = aPrintOptions;
+ }
+ return *mpPrtData;
+}
+
+void DocumentDeviceManager::setPrintData(/*[in]*/ const SwPrintData& rPrtData )
+{
+ if(!mpPrtData)
+ mpPrtData = new SwPrintData;
+ *mpPrtData = rPrtData;
+}
+
+DocumentDeviceManager::~DocumentDeviceManager()
+{
+ delete mpPrtData;
+ delete mpVirDev;
+ DELETEZ( mpPrt );
+}
+
+VirtualDevice& DocumentDeviceManager::CreateVirtualDevice_() const
+{
+#ifdef IOS
+ VirtualDevice* pNewVir = new VirtualDevice( 8 );
+#else
+ VirtualDevice* pNewVir = new VirtualDevice( 1 );
+#endif
+
+ pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
+
+ // #i60945# External leading compatibility for unix systems.
+ if ( m_rSwdoc.get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) )
+ pNewVir->Compat_ZeroExtleadBug();
+
+ MapMode aMapMode( pNewVir->GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ pNewVir->SetMapMode( aMapMode );
+
+ const_cast<DocumentDeviceManager*>(this)->setVirtualDevice( pNewVir, true, true );
+ return *mpVirDev;
+}
+
+SfxPrinter& DocumentDeviceManager::CreatePrinter_() const
+{
+ OSL_ENSURE( ! mpPrt, "Do not call CreatePrinter_(), call getPrinter() instead" );
+
+#if OSL_DEBUG_LEVEL > 1
+ OSL_TRACE( "Printer will be created!" );
+#endif
+
+ // We create a default SfxPrinter.
+ // The ItemSet is deleted by Sfx!
+ SfxItemSet *pSet = new SfxItemSet( m_rSwdoc.GetAttrPool(),
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0 );
+
+ SfxPrinter* pNewPrt = new SfxPrinter( pSet );
+ const_cast<DocumentDeviceManager*>(this)->setPrinter( pNewPrt, true, true );
+ return *mpPrt;
+}
+
+void DocumentDeviceManager::PrtDataChanged()
+{
+// If you change this, also modify InJobSetup in Sw3io if appropriate.
+
+ // #i41075#
+ OSL_ENSURE( m_rSwdoc.get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ||
+ 0 != getPrinter( false ), "PrtDataChanged will be called recursively!" );
+ SwRootFrm* pTmpRoot = m_rSwdoc.GetCurrentLayout();
+ boost::scoped_ptr<SwWait> pWait;
+ bool bEndAction = false;
+
+ if( m_rSwdoc.GetDocShell() )
+ m_rSwdoc.GetDocShell()->UpdateFontList();
+
+ bool bDraw = true;
+ if ( pTmpRoot )
+ {
+ SwViewShell *pSh = m_rSwdoc.GetCurrentViewShell();
+ if( pSh &&
+ (!pSh->GetViewOptions()->getBrowseMode() ||
+ pSh->GetViewOptions()->IsPrtFormat()) )
+ {
+ if ( m_rSwdoc.GetDocShell() )
+ pWait.reset(new SwWait( *m_rSwdoc.GetDocShell(), true ));
+
+ pTmpRoot->StartAllAction();
+ bEndAction = true;
+
+ bDraw = false;
+ if( m_rSwdoc.GetDrawModel() )
+ {
+ m_rSwdoc.GetDrawModel()->SetAddExtLeading( m_rSwdoc.get(IDocumentSettingAccess::ADD_EXT_LEADING) );
+ m_rSwdoc.GetDrawModel()->SetRefDevice( getReferenceDevice( false ) );
+ }
+
+ pFntCache->Flush();
+
+ std::set<SwRootFrm*> aAllLayouts = m_rSwdoc.GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
+
+ do
+ {
+ pSh->InitPrt( getPrinter(false) );
+ pSh = (SwViewShell*)pSh->GetNext();
+ }
+ while ( pSh != m_rSwdoc.GetCurrentViewShell() );
+ }
+ }
+ if ( bDraw && m_rSwdoc.GetDrawModel() )
+ {
+ const bool bTmpAddExtLeading = m_rSwdoc.get(IDocumentSettingAccess::ADD_EXT_LEADING);
+ if ( bTmpAddExtLeading != m_rSwdoc.GetDrawModel()->IsAddExtLeading() )
+ m_rSwdoc.GetDrawModel()->SetAddExtLeading( bTmpAddExtLeading );
+
+ OutputDevice* pOutDev = getReferenceDevice( false );
+ if ( pOutDev != m_rSwdoc.GetDrawModel()->GetRefDevice() )
+ m_rSwdoc.GetDrawModel()->SetRefDevice( pOutDev );
+ }
+
+ m_rSwdoc.PrtOLENotify( sal_True );
+
+ if ( bEndAction )
+ pTmpRoot->EndAllAction();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index a479d26..623a546 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -108,6 +108,7 @@
#include <txtfrm.hxx>
#include <attrhint.hxx>
#include <view.hxx>
+#include <DocumentDeviceManager.hxx>
#include <wdocsh.hxx>
#include <prtopt.hxx>
@@ -242,199 +243,68 @@ void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
m_pDocumentSettingManager->setCharacterCompressionType(n);
}
-/* IDocumentDeviceAccess */
-SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const
+// IDocumentDeviceAccess
+const IDocumentDeviceAccess* SwDoc::getIDocumentDeviceAccessConst() const
{
- SfxPrinter* pRet = 0;
- if ( !bCreate || mpPrt )
- pRet = mpPrt;
- else
- pRet = &CreatePrinter_();
-
- return pRet;
+ return m_DeviceAccess.get();
}
-void SwDoc::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
+IDocumentDeviceAccess* SwDoc::getIDocumentDeviceAccess()
{
- if ( pP != mpPrt )
- {
- if ( bDeleteOld )
- delete mpPrt;
- mpPrt = pP;
-
- // our printer should always use TWIP. Don't rely on this being set in SwViewShell::InitPrt, there
- // are situations where this isn't called.
- // #i108712# / 2010-02-26 / frank.schoenheit at sun.com
- if ( mpPrt )
- {
- MapMode aMapMode( mpPrt->GetMapMode() );
- aMapMode.SetMapUnit( MAP_TWIP );
- mpPrt->SetMapMode( aMapMode );
- }
+ return m_DeviceAccess.get();
+}
- if ( mpDrawModel && !get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
- mpDrawModel->SetRefDevice( mpPrt );
- }
+SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const
+{
+ return getIDocumentDeviceAccessConst()->getPrinter( bCreate );
+}
- if ( bCallPrtDataChanged &&
- // #i41075# Do not call PrtDataChanged() if we do not
- // use the printer for formatting:
- !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
- PrtDataChanged();
+void SwDoc::setPrinter(/*[in]*/ SfxPrinter* pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
+{
+ getIDocumentDeviceAccess()->setPrinter( pP, bDeleteOld, bCallPrtDataChanged );
}
VirtualDevice* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate ) const
{
- VirtualDevice* pRet = 0;
- if ( !bCreate || mpVirDev )
- pRet = mpVirDev;
- else
- pRet = &CreateVirtualDevice_();
-
- return pRet;
+ return getIDocumentDeviceAccessConst()->getVirtualDevice( bCreate );
}
-void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
+void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool bCallVirDevDataChanged )
{
- if ( mpVirDev != pVd )
- {
- if ( bDeleteOld )
- delete mpVirDev;
- mpVirDev = pVd;
-
- if ( mpDrawModel && get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
- mpDrawModel->SetRefDevice( mpVirDev );
- }
+ getIDocumentDeviceAccess()->setVirtualDevice( pVd, bDeleteOld, bCallVirDevDataChanged );
}
OutputDevice* SwDoc::getReferenceDevice(/*[in]*/ bool bCreate ) const
{
- OutputDevice* pRet = 0;
- if ( !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
- {
- pRet = getPrinter( bCreate );
-
- if ( bCreate && !mpPrt->IsValid() )
- {
- pRet = getVirtualDevice( true );
- }
- }
- else
- {
- pRet = getVirtualDevice( bCreate );
- }
-
- return pRet;
+ return getIDocumentDeviceAccessConst()->getReferenceDevice( bCreate );
}
void SwDoc::setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes )
{
- if ( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual ||
- get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes )
- {
- if ( bNewVirtual )
- {
- VirtualDevice* pMyVirDev = getVirtualDevice( true );
- if ( !bNewHiRes )
- pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
- else
- pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
-
- if( mpDrawModel )
- mpDrawModel->SetRefDevice( pMyVirDev );
- }
- else
- {
- // #i41075#
- // We have to take care that a printer exists before calling
- // PrtDataChanged() in order to prevent that PrtDataChanged()
- // triggers this funny situation:
- // getReferenceDevice()->getPrinter()->CreatePrinter_()
- // ->setPrinter()-> PrtDataChanged()
- SfxPrinter* pPrinter = getPrinter( true );
- if( mpDrawModel )
- mpDrawModel->SetRefDevice( pPrinter );
- }
-
- set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );
- set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
- PrtDataChanged();
- SetModified();
- }
+ getIDocumentDeviceAccess()->setReferenceDeviceType( bNewVirtual, bNewHiRes );
}
const JobSetup* SwDoc::getJobsetup() const
{
- return mpPrt ? &mpPrt->GetJobSetup() : 0;
+ return getIDocumentDeviceAccessConst()->getJobsetup();
}
-void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup )
+void SwDoc::setJobsetup(/*[in]*/ const JobSetup& rJobSetup )
{
- bool bCheckPageDescs = 0 == mpPrt;
- bool bDataChanged = false;
-
- if ( mpPrt )
- {
- if ( mpPrt->GetName() == rJobSetup.GetPrinterName() )
- {
- if ( mpPrt->GetJobSetup() != rJobSetup )
- {
- mpPrt->SetJobSetup( rJobSetup );
- bDataChanged = true;
- }
- }
- else
- delete mpPrt, mpPrt = 0;
- }
-
- if( !mpPrt )
- {
- //The ItemSet is deleted by Sfx!
- SfxItemSet *pSet = new SfxItemSet( GetAttrPool(),
- FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
- SID_HTML_MODE, SID_HTML_MODE,
- SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
- SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
- 0 );
- SfxPrinter *p = new SfxPrinter( pSet, rJobSetup );
- if ( bCheckPageDescs )
- setPrinter( p, true, true );
- else
- {
- mpPrt = p;
- bDataChanged = true;
- }
- }
- if ( bDataChanged && !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
- PrtDataChanged();
+ getIDocumentDeviceAccess()->setJobsetup( rJobSetup );
}
const SwPrintData & SwDoc::getPrintData() const
{
- if(!mpPrtData)
- {
- SwDoc * pThis = const_cast< SwDoc * >(this);
- pThis->mpPrtData = new SwPrintData;
-
- // SwPrintData should be initialized from the configuration,
- // the respective config item is implemented by SwPrintOptions which
- // is also derived from SwPrintData
- const SwDocShell *pDocSh = GetDocShell();
- OSL_ENSURE( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" );
- bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh);
- SwPrintOptions aPrintOptions( bWeb );
- *pThis->mpPrtData = aPrintOptions;
- }
- return *mpPrtData;
+ return getIDocumentDeviceAccessConst()->getPrintData();
}
-void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData )
+void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData)
{
- if(!mpPrtData)
- mpPrtData = new SwPrintData;
- *mpPrtData = rPrtData;
+ getIDocumentDeviceAccess()->setPrintData( rPrtData );
}
+
/* Implementations the next Interface here */
/*
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index bb3063f..5879372 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -648,71 +648,6 @@ SwPageDesc* SwDoc::FindPageDescByName( const OUString& rName, sal_uInt16* pPos )
return pRet;
}
-void SwDoc::PrtDataChanged()
-{
-// If you change this, also modify InJobSetup in Sw3io if appropriate.
-
- // #i41075#
- OSL_ENSURE( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ||
- 0 != getPrinter( false ), "PrtDataChanged will be called recursively!" );
- SwRootFrm* pTmpRoot = GetCurrentLayout();
- boost::scoped_ptr<SwWait> pWait;
- bool bEndAction = false;
-
- if( GetDocShell() )
- GetDocShell()->UpdateFontList();
-
- bool bDraw = true;
- if ( pTmpRoot )
- {
- SwViewShell *pSh = GetCurrentViewShell();
- if( pSh &&
- (!pSh->GetViewOptions()->getBrowseMode() ||
- pSh->GetViewOptions()->IsPrtFormat()) )
- {
- if ( GetDocShell() )
- pWait.reset(new SwWait( *GetDocShell(), true ));
-
- pTmpRoot->StartAllAction();
- bEndAction = true;
-
- bDraw = false;
- if( mpDrawModel )
- {
- mpDrawModel->SetAddExtLeading( get(IDocumentSettingAccess::ADD_EXT_LEADING) );
- mpDrawModel->SetRefDevice( getReferenceDevice( false ) );
- }
-
- pFntCache->Flush();
-
- std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
- std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
-
- do
- {
- pSh->InitPrt( mpPrt );
- pSh = (SwViewShell*)pSh->GetNext();
- }
- while ( pSh != GetCurrentViewShell() );
- }
- }
- if ( bDraw && mpDrawModel )
- {
- const bool bTmpAddExtLeading = get(IDocumentSettingAccess::ADD_EXT_LEADING);
- if ( bTmpAddExtLeading != mpDrawModel->IsAddExtLeading() )
- mpDrawModel->SetAddExtLeading( bTmpAddExtLeading );
-
- OutputDevice* pOutDev = getReferenceDevice( false );
- if ( pOutDev != mpDrawModel->GetRefDevice() )
- mpDrawModel->SetRefDevice( pOutDev );
- }
-
- PrtOLENotify( sal_True );
-
- if ( bEndAction )
- pTmpRoot->EndAllAction();
-}
-
// We collect the GlobalNames of the servers at runtime, who don't want to be notified
// about printer changes. Thereby saving loading a lot of objects (luckily all foreign
// objects are mapped to one ID).
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index c18438e..712ffa3 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -88,6 +88,7 @@
#include <tblsel.hxx>
#include <MarkManager.hxx>
#include <UndoManager.hxx>
+#include <DocumentDeviceManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -182,8 +183,8 @@ static void lcl_DelFmtIndices( SwFmt* pFmt )
* exported methods
*/
SwDoc::SwDoc()
- : m_pNodes( new SwNodes(this) )
- ,
+ : m_pNodes( new SwNodes(this) ),
+ m_DeviceAccess( new ::sw::DocumentDeviceManager( *this ) ),
mpAttrPool(new SwAttrPool(this)),
mpMarkManager(new ::sw::mark::MarkManager(*this)),
m_pMetaFieldManager(new ::sw::MetaFieldManager()),
@@ -209,9 +210,6 @@ SwDoc::SwDoc()
mpDrawModel( 0 ),
mpUpdtFlds( new SwDocUpdtFld( this ) ),
mpFldTypes( new SwFldTypes() ),
- mpVirDev( 0 ),
- mpPrt( 0 ),
- mpPrtData( 0 ),
mpGlossaryDoc( 0 ),
mpOutlineRule( 0 ),
mpFtnInfo( new SwFtnInfo ),
@@ -577,6 +575,11 @@ SwDoc::~SwDoc()
DeleteAndDestroy(*mpGrfFmtCollTbl, 1, mpGrfFmtCollTbl->size());
delete mpGrfFmtCollTbl;
+ // Without explicitly freeing the DocumentDeviceManager
+ // and relying on the implicit freeing there would be a crash
+ // due to it happening after SwAttrPool is freed.
+ m_DeviceAccess.reset();
+
/*
* DefaultFormats and DefaultFormatCollections (FmtColl)
* are at position 0 of their respective arrays.
@@ -586,7 +589,6 @@ SwDoc::~SwDoc()
mpFrmFmtTbl->erase( mpFrmFmtTbl->begin() );
mpCharFmtTbl->erase( mpCharFmtTbl->begin() );
- DELETEZ( mpPrt );
#if HAVE_FEATURE_DBCONNECTIVITY
DELETEZ( mpDBMgr );
#endif
@@ -632,7 +634,6 @@ SwDoc::~SwDoc()
disposeXForms(); // #i113606#, dispose the XForms objects
- delete mpPrtData;
delete mpNumberFormatter;
delete mpFtnInfo;
delete mpEndNoteInfo;
@@ -646,51 +647,10 @@ SwDoc::~SwDoc()
delete mpDfltCharFmt;
delete mpDfltFrmFmt;
delete mpLayoutCache;
- delete mpVirDev;
SfxItemPool::Free(mpAttrPool);
}
-VirtualDevice& SwDoc::CreateVirtualDevice_() const
-{
- VirtualDevice* pNewVir = new VirtualDevice( 1 );
-
- pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
-
- // #i60945# External leading compatibility for unix systems.
- if ( get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) )
- pNewVir->Compat_ZeroExtleadBug();
-
- MapMode aMapMode( pNewVir->GetMapMode() );
- aMapMode.SetMapUnit( MAP_TWIP );
- pNewVir->SetMapMode( aMapMode );
-
- const_cast<SwDoc*>(this)->setVirtualDevice( pNewVir, true, true );
- return *mpVirDev;
-}
-
-SfxPrinter& SwDoc::CreatePrinter_() const
-{
- OSL_ENSURE( ! mpPrt, "Do not call CreatePrinter_(), call getPrinter() instead" );
-
-#if OSL_DEBUG_LEVEL > 1
- OSL_TRACE( "Printer will be created!" );
-#endif
-
- // We create a default SfxPrinter.
- // The ItemSet is deleted by Sfx!
- SfxItemSet *pSet = new SfxItemSet( ((SwDoc*)this)->GetAttrPool(),
- FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
- SID_HTML_MODE, SID_HTML_MODE,
- SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
- SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
- 0 );
-
- SfxPrinter* pNewPrt = new SfxPrinter( pSet );
- const_cast<SwDoc*>(this)->setPrinter( pNewPrt, true, true );
- return *mpPrt;
-}
-
void SwDoc::SetDocShell( SwDocShell* pDSh )
{
if( mpDocShell != pDSh )
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 125cc2b..b20053c 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1915,7 +1915,7 @@ SwOLENodes* SwCntntNode::CreateOLENodesArray( const SwFmtColl& rColl, bool bOnly
* Document Interface Access
*/
const IDocumentSettingAccess* SwNode::getIDocumentSettingAccess() const { return GetDoc(); }
-const IDocumentDeviceAccess* SwNode::getIDocumentDeviceAccess() const { return GetDoc(); }
+const IDocumentDeviceAccess* SwNode::getIDocumentDeviceAccess() const { return GetDoc()->getIDocumentDeviceAccessConst(); }
const IDocumentRedlineAccess* SwNode::getIDocumentRedlineAccess() const { return GetDoc(); }
const IDocumentStylePoolAccess* SwNode::getIDocumentStylePoolAccess() const { return GetDoc(); }
const IDocumentLineNumberAccess* SwNode::getIDocumentLineNumberAccess() const { return GetDoc(); }
diff --git a/sw/source/core/inc/DocumentDeviceManager.hxx b/sw/source/core/inc/DocumentDeviceManager.hxx
new file mode 100644
index 0000000..5681a98
--- /dev/null
+++ b/sw/source/core/inc/DocumentDeviceManager.hxx
@@ -0,0 +1,83 @@
+/* -*- 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_DOCUMENTDEVICEMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTDEVICEMANAGER_HXX
+
+#include <IDocumentDeviceAccess.hxx>
+#include <boost/utility.hpp>
+#include <sal/types.h>
+
+
+class SwDoc;
+class SfxPrinter;
+class VirtualDevice;
+class OutputDevice;
+class JobSetup;
+class SwPrintData;
+
+namespace sw {
+
+class DocumentDeviceManager : public IDocumentDeviceAccess,
+ public ::boost::noncopyable
+{
+
+public:
+
+ DocumentDeviceManager( SwDoc& i_rSwdoc );
+
+ SfxPrinter* getPrinter(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
+
+ void setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged ) SAL_OVERRIDE;
+
+ VirtualDevice* getVirtualDevice(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
+
+ void setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool ) SAL_OVERRIDE;
+
+ OutputDevice* getReferenceDevice(/*[in]*/ bool bCreate ) const SAL_OVERRIDE;
+
+ void setReferenceDeviceType(/*[in]*/ bool bNewVirtual, /*[in]*/ bool bNewHiRes ) SAL_OVERRIDE;
+
+ const JobSetup* getJobsetup() const SAL_OVERRIDE;
+
+ void setJobsetup(/*[in]*/ const JobSetup &rJobSetup ) SAL_OVERRIDE;
+
+ const SwPrintData & getPrintData() const SAL_OVERRIDE;
+
+ void setPrintData(/*[in]*/ const SwPrintData& rPrtData ) SAL_OVERRIDE;
+
+ virtual ~DocumentDeviceManager() SAL_OVERRIDE;
+
+private:
+
+ VirtualDevice& CreateVirtualDevice_() const;
+ SfxPrinter& CreatePrinter_() const;
+ void PrtDataChanged(); /**< Printer or JobSetup altered.
+ Care has to be taken of the necessary
+ invalidations and notifications. */
+
+ SwDoc& m_rSwdoc;
+ SfxPrinter* mpPrt;
+ VirtualDevice* mpVirDev;
+ SwPrintData* mpPrtData;
+};
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/uibase/app/docshini.cxx b/sw/source/core/uibase/app/docshini.cxx
index 8ea9c1e..0bd8560 100644
--- a/sw/source/core/uibase/app/docshini.cxx
+++ b/sw/source/core/uibase/app/docshini.cxx
@@ -678,7 +678,7 @@ void SwDocShell::SubInitNew()
/*
* Document Interface Access
*/
-IDocumentDeviceAccess* SwDocShell::getIDocumentDeviceAccess() { return pDoc; }
+IDocumentDeviceAccess* SwDocShell::getIDocumentDeviceAccess() { return pDoc->getIDocumentDeviceAccess(); }
const IDocumentSettingAccess* SwDocShell::getIDocumentSettingAccess() const { return pDoc; }
IDocumentChartDataProviderAccess* SwDocShell::getIDocumentChartDataProviderAccess() { return pDoc; }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index af543fd..5edacae 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2502,8 +2502,8 @@ SwPostItMgr* SwViewShell::GetPostItMgr()
*/
const IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() const { return mpDoc; }
IDocumentSettingAccess* SwViewShell::getIDocumentSettingAccess() { return mpDoc; }
-const IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() const { return mpDoc; }
-IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() { return mpDoc; }
+const IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() const { return mpDoc->getIDocumentDeviceAccessConst(); }
+IDocumentDeviceAccess* SwViewShell::getIDocumentDeviceAccess() { return mpDoc->getIDocumentDeviceAccess(); }
const IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() const { return mpDoc->getIDocumentMarkAccess(); }
IDocumentMarkAccess* SwViewShell::getIDocumentMarkAccess() { return mpDoc->getIDocumentMarkAccess(); }
const IDocumentDrawModelAccess* SwViewShell::getIDocumentDrawModelAccess() const { return mpDoc; }
commit e2a349c19dd1f8e00ae677c26900938d11f13938
Author: anuragkanungo <anuragkanungo at gmail.com>
Date: Sat Apr 5 14:29:54 2014 +0530
Refactor IDocumentSettingAccess Interface of SwDoc
Change-Id: I4a7ec73d3bdf9888e50d071b593798b74780b80c
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 0bdee22..5e74b79 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -186,6 +186,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/docstat \
sw/source/core/doc/doctxm \
sw/source/core/doc/docxforms \
+ sw/source/core/doc/DocumentSettingManager \
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 cfff535..ce2cc6e 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -208,6 +208,7 @@ namespace sw {
class MetaFieldManager;
class UndoManager;
class IShellCursorSupplier;
+ class DocumentSettingManager;
}
namespace com { namespace sun { namespace star {
@@ -290,6 +291,7 @@ class SW_DLLPUBLIC SwDoc :
const ::boost::scoped_ptr< ::sw::mark::MarkManager> mpMarkManager;
const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager;
const ::boost::scoped_ptr< ::sw::UndoManager > m_pUndoManager;
+ const ::boost::scoped_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager;
// Pointer
SwFrmFmt *mpDfltFrmFmt; //< Default formats.
@@ -400,10 +402,7 @@ private:
sal_uInt16 mnAutoFmtRedlnCommentNo; /**< SeqNo for conjoining of AutoFmt-Redlines.
by the UI. Managed by SwAutoFmt! */
- sal_uInt16 mnLinkUpdMode; //< UpdateMode for links.
- SwFldUpdateFlags meFldUpdMode;//< Automatically Update Mode for fields/charts.
RedlineMode_t meRedlineMode; //< Current Redline Mode.
- SwCharCompressType meChrCmprType;//< for ASIAN: compress punctuation/kana
sal_uInt32 mnRsid; //< current session ID of the document
sal_uInt32 mnRsidRoot; //< session ID when the document was created
@@ -441,11 +440,7 @@ private:
bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary.
bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX.
bool mbInLoadAsynchron : 1; //< TRUE: Document is in the process of being loaded asynchronously.
- bool mbHTMLMode : 1; //< TRUE: Document is in HTMLMode.
bool mbInCallModified : 1; //< TRUE: in Set/Reset-Modified link.
- bool mbIsGlobalDoc : 1; //< TRUE: It's a global document.
- bool mbGlblDocSaveLinks : 1; //< TRUE: Save sections linked in global document.
- bool mbIsLabelDoc : 1; //< TRUE: It's a label document.
bool mbIsAutoFmtRedline : 1; //< TRUE: Redlines are recorded by Autoformat.
bool mbOLEPrtNotifyPending : 1; /**< TRUE: Printer has changed. At creation of
::com::sun::star::sdbcx::View
@@ -454,8 +449,6 @@ private:
bool mbIsRedlineMove : 1; //< True: Redlines are moved into to / out of the section.
bool mbInsOnlyTxtGlssry : 1; //< True: insert 'only text' glossary into doc
bool mbContains_MSVBasic : 1; //< True: MS-VBasic exist is in our storage
- bool mbPurgeOLE : 1; //< sal_True: Purge OLE-Objects
- bool mbKernAsianPunctuation : 1; //< sal_True: kerning also for ASIAN punctuation
bool mbReadlineChecked : 1; //< sal_True: if the query was already shown
bool mbLinksUpdated : 1; /**< #i38810#
flag indicating, that the links have been updated. */
@@ -532,53 +525,8 @@ private:
// label is followed by a tab character.
// mbTabAtLeftIndentForParagraphsInList def = sal_False, hidden
- bool mbParaSpaceMax : 1;
- bool mbParaSpaceMaxAtPages : 1;
- bool mbTabCompat : 1;
- bool mbUseVirtualDevice : 1;
- bool mbAddFlyOffsets : 1;
- bool mbAddExternalLeading : 1;
- bool mbUseHiResolutionVirtualDevice : 1;
- bool mbOldLineSpacing : 1; // #i11859#
- bool mbAddParaSpacingToTableCells : 1;
- bool mbUseFormerObjectPos : 1; // #i11860#
- bool mbUseFormerTextWrapping : 1;
- bool mbConsiderWrapOnObjPos : 1; // #i28701#
- // sal_True: object positioning algorithm has consider the wrapping style of // the floating screen objects as given by its attribute 'WrapInfluenceOnObjPos'
- // floating screen objects as given by its
- // attribute 'WrapInfluenceOnObjPos'.
- bool mbMathBaselineAlignment : 1; // TL 2010-10-29 #i972#
- bool mbStylesNoDefault : 1;
- bool mbFloattableNomargins : 1; //< If paragraph margins next to a floating table should be ignored.
- bool mEmbedFonts : 1; //< Whether to embed fonts used by the document when saving.
- bool mEmbedSystemFonts : 1; //< Whether to embed also system fonts.
-
// non-ui-compatibility flags:
- bool mbOldNumbering : 1;
- bool mbIgnoreFirstLineIndentInNumbering : 1; // #i47448#
- bool mbDoNotJustifyLinesWithManualBreak : 1; // #i49277#
- bool mbDoNotResetParaAttrsForNumFont : 1; // #i53199#
- bool mbTableRowKeep : 1;
- bool mbIgnoreTabsAndBlanksForLineCalculation : 1; // #i3952#
- bool mbDoNotCaptureDrawObjsOnPage : 1; // #i62875#
- bool mbOutlineLevelYieldsOutlineRule : 1;
- bool mbClipAsCharacterAnchoredWriterFlyFrames : 1;
- bool mbUnixForceZeroExtLeading : 1; // #i60945#
bool mbOldPrinterMetrics : 1;
- bool mbTabRelativeToIndent : 1; // #i24363# tab stops relative to indent
- bool mbProtectForm : 1;
- bool mbInvertBorderSpacing : 1;
- bool mbCollapseEmptyCellPara : 1;
- bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above
- bool mbSmallCapsPercentage66;
- bool mbTabOverflow;
- bool mbUnbreakableNumberings;
- bool mbClippedPictures;
- bool mbBackgroundParaOverDrawings;
- bool mbTabOverMargin;
- bool mbSurroundTextWrapSmall;
-
- bool mbLastBrowseMode : 1;
sal_uInt32 mn32DummyCompatabilityOptions1;
sal_uInt32 mn32DummyCompatabilityOptions2;
@@ -2080,6 +2028,8 @@ public:
::sw::MetaFieldManager & GetMetaFieldManager();
::sw::UndoManager & GetUndoManager();
::sw::UndoManager const& GetUndoManager() const;
+ ::sw::DocumentSettingManager & GetDocumentSettingManager();
+ ::sw::DocumentSettingManager const& GetDocumentSettingManager() const;
SfxObjectShell* CreateCopy(bool bCallInitNew) const;
/**
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
new file mode 100644
index 0000000..599df11
--- /dev/null
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -0,0 +1,504 @@
+/* -*- 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 <DocumentSettingManager.hxx>
+#include <doc.hxx>
+#include <comphelper/processfactory.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <svx/svdmodel.hxx>
+#include <unotools/compatibility.hxx>
+#include <swmodule.hxx>
+#include <linkenum.hxx>
+#include <rootfrm.hxx>
+#include <breakit.hxx>
+#include <docary.hxx>
+#include <SwUndoFmt.hxx>
+
+/* IDocumentSettingAccess */
+
+sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
+ :m_rDoc(rDoc)
+ ,
+ mnLinkUpdMode( GLOBALSETTING ),
+ meFldUpdMode( AUTOUPD_GLOBALSETTING ),
+ meChrCmprType( CHARCOMPRESS_NONE ),
+ mbHTMLMode(false),
+ mbIsGlobalDoc(false),
+ mbGlblDocSaveLinks(false),
+ mbIsLabelDoc(false),
+ mbPurgeOLE(true),
+ mbKernAsianPunctuation(false),
+
+ // COMPATIBILITY FLAGS START
+
+ mbAddFlyOffsets(false),
+ mbUseHiResolutionVirtualDevice(true),
+ mbMathBaselineAlignment(false), // default for *old* documents is 'off'
+ mbStylesNoDefault(false),
+ mbFloattableNomargins(false),
+ mEmbedFonts(false),
+ mEmbedSystemFonts(false),
+ mbOldNumbering(false),
+ mbIgnoreFirstLineIndentInNumbering(false),
+ mbDoNotResetParaAttrsForNumFont(false),
+ mbTableRowKeep(false),
+ mbIgnoreTabsAndBlanksForLineCalculation(false),
+ mbDoNotCaptureDrawObjsOnPage(false),
+ mbOutlineLevelYieldsOutlineRule(false),
+ mbClipAsCharacterAnchoredWriterFlyFrames(false),
+ mbUnixForceZeroExtLeading(false),
+ mbTabRelativeToIndent(true),
+ mbProtectForm(false), // i#78591#
+ mbInvertBorderSpacing (false),
+ mbCollapseEmptyCellPara(true),
+ mbTabAtLeftIndentForParagraphsInList(false), //#i89181#
+ mbSmallCapsPercentage66(false),
+ mbTabOverflow(true),
+ mbUnbreakableNumberings(false),
+ mbClippedPictures(false),
+ mbBackgroundParaOverDrawings(false),
+ mbTabOverMargin(false),
+ mbSurroundTextWrapSmall(false),
+ mbLastBrowseMode( false )
+
+ // COMPATIBILITY FLAGS END
+{
+ // COMPATIBILITY FLAGS START
+
+ // Note: Any non-hidden compatibility flag should obtain its default
+ // by asking SvtCompatibilityOptions, see below.
+
+ const SvtCompatibilityOptions aOptions;
+ mbParaSpaceMax = aOptions.IsAddSpacing();
+ mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages();
+ mbTabCompat = !aOptions.IsUseOurTabStops();
+ mbUseVirtualDevice = !aOptions.IsUsePrtDevice();
+ mbAddExternalLeading = !aOptions.IsNoExtLeading();
+ mbOldLineSpacing = aOptions.IsUseLineSpacing();
+ mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing();
+ mbUseFormerObjectPos = aOptions.IsUseObjectPositioning();
+ mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping();
+ mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle();
+
+ mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace();
+
+ // COMPATIBILITY FLAGS END
+
+}
+
+
+sw::DocumentSettingManager::~DocumentSettingManager()
+{
+}
+
+/* IDocumentSettingAccess */
+bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
+{
+ switch (id)
+ {
+ // COMPATIBILITY FLAGS START
+ case PARA_SPACE_MAX: return mbParaSpaceMax; //(n8Dummy1 & DUMMY_PARASPACEMAX);
+ case PARA_SPACE_MAX_AT_PAGES: return mbParaSpaceMaxAtPages; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES);
+ case TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT);
+ case ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
+ case ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
+ case USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
+ case USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
+ case OLD_NUMBERING: return mbOldNumbering;
+ case OLD_LINE_SPACING: return mbOldLineSpacing;
+ case ADD_PARA_SPACING_TO_TABLE_CELLS: return mbAddParaSpacingToTableCells;
+ case USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos;
+ case USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping;
+ case CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos;
+ case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak;
+ case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering;
+ case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: return mbOutlineLevelYieldsOutlineRule;
+ case TABLE_ROW_KEEP: return mbTableRowKeep;
+ case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation;
+ case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage;
+ // #i68949#
+ case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames;
+ case UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading;
+ case TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent;
+ case PROTECT_FORM: return mbProtectForm;
+ // #i89181#
+ case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
+ case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
+ case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
+ case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66;
+ case TAB_OVERFLOW: return mbTabOverflow;
+ case UNBREAKABLE_NUMBERINGS: return mbUnbreakableNumberings;
+ case CLIPPED_PICTURES: return mbClippedPictures;
+ case BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings;
+ case TAB_OVER_MARGIN: return mbTabOverMargin;
+ case SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall;
+
+ case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the SwViewShell has to be asked!
+ case HTML_MODE: return mbHTMLMode;
+ case GLOBAL_DOCUMENT: return mbIsGlobalDoc;
+ case GLOBAL_DOCUMENT_SAVE_LINKS: return mbGlblDocSaveLinks;
+ case LABEL_DOCUMENT: return mbIsLabelDoc;
+ case PURGE_OLE: return mbPurgeOLE;
+ case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation;
+ case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
+ case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
+ case STYLES_NODEFAULT: return mbStylesNoDefault;
+ case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
+ case EMBED_FONTS: return mEmbedFonts;
+ case EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
+ default:
+ OSL_FAIL("Invalid setting id");
+ }
+ return false;
+}
+
+void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
+{
+ switch (id)
+ {
+ // COMPATIBILITY FLAGS START
+ case PARA_SPACE_MAX:
+ mbParaSpaceMax = value;
+ break;
+ case PARA_SPACE_MAX_AT_PAGES:
+ mbParaSpaceMaxAtPages = value;
+ break;
+ case TAB_COMPAT:
+ mbTabCompat = value;
+ break;
+ case ADD_FLY_OFFSETS:
+ mbAddFlyOffsets = value;
+ break;
+ case ADD_EXT_LEADING:
+ mbAddExternalLeading = value;
+ break;
+ case USE_VIRTUAL_DEVICE:
+ mbUseVirtualDevice = value;
+ break;
+ case USE_HIRES_VIRTUAL_DEVICE:
+ mbUseHiResolutionVirtualDevice = value;
+ break;
+ case OLD_NUMBERING:
+ if (mbOldNumbering != value)
+ {
+ mbOldNumbering = value;
+
+ const SwNumRuleTbl& rNmTbl = m_rDoc.GetNumRuleTbl();
+ for( sal_uInt16 n = 0; n < rNmTbl.size(); ++n )
+ rNmTbl[n]->SetInvalidRule(sal_True);
+
+ m_rDoc.UpdateNumRule();
+
+ SwNumRule *pOutlineRule = m_rDoc.GetOutlineNumRule();
+ if (pOutlineRule)
+ {
+ pOutlineRule->Validate();
+ // counting of phantoms depends on <IsOldNumbering()>
+ pOutlineRule->SetCountPhantoms( !mbOldNumbering );
+ }
+ }
+ break;
+ case OLD_LINE_SPACING:
+ mbOldLineSpacing = value;
+ break;
+ case ADD_PARA_SPACING_TO_TABLE_CELLS:
+ mbAddParaSpacingToTableCells = value;
+ break;
+ case USE_FORMER_OBJECT_POS:
+ mbUseFormerObjectPos = value;
+ break;
+ case USE_FORMER_TEXT_WRAPPING:
+ mbUseFormerTextWrapping = value;
+ break;
+ case CONSIDER_WRAP_ON_OBJECT_POSITION:
+ mbConsiderWrapOnObjPos = value;
+ break;
+ case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
+ mbDoNotJustifyLinesWithManualBreak = value;
+ break;
+ case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
+ mbIgnoreFirstLineIndentInNumbering = value;
+ break;
+
+ case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE:
+ mbOutlineLevelYieldsOutlineRule = value;
+ break;
+
+ case TABLE_ROW_KEEP:
+ mbTableRowKeep = value;
+ break;
+
+ case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
+ mbIgnoreTabsAndBlanksForLineCalculation = value;
+ break;
+
+ case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
+ mbDoNotCaptureDrawObjsOnPage = value;
+ break;
+
+ // #i68949#
+ case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME:
+ mbClipAsCharacterAnchoredWriterFlyFrames = value;
+ break;
+
+ case UNIX_FORCE_ZERO_EXT_LEADING:
+ mbUnixForceZeroExtLeading = value;
+ break;
+
+ case PROTECT_FORM:
+ mbProtectForm = value;
+ break;
+
+ case TABS_RELATIVE_TO_INDENT:
+ mbTabRelativeToIndent = value;
+ break;
+ // #i89181#
+ case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
+ mbTabAtLeftIndentForParagraphsInList = value;
+ break;
+
+ case INVERT_BORDER_SPACING:
+ mbInvertBorderSpacing = value;
+ break;
+
+ case COLLAPSE_EMPTY_CELL_PARA:
+ mbCollapseEmptyCellPara = value;
+ break;
+
+ case SMALL_CAPS_PERCENTAGE_66:
+ mbSmallCapsPercentage66 = value;
+ break;
+
+ case TAB_OVERFLOW:
+ mbTabOverflow = value;
+ break;
+
+ case UNBREAKABLE_NUMBERINGS:
+ mbUnbreakableNumberings = value;
+ break;
+
+ case CLIPPED_PICTURES:
+ mbClippedPictures = value;
+ break;
+
+ case BACKGROUND_PARA_OVER_DRAWINGS:
+ mbBackgroundParaOverDrawings = value;
+ break;
+
+ case TAB_OVER_MARGIN:
+ mbTabOverMargin = value;
+ break;
+
+ case SURROUND_TEXT_WRAP_SMALL:
+ mbSurroundTextWrapSmall = value;
+ break;
+
+ // COMPATIBILITY FLAGS END
+
+ case BROWSE_MODE: //can be used temporary (load/save) when no SwViewShell is available
+ mbLastBrowseMode = value;
+ break;
+
+ case HTML_MODE:
+ mbHTMLMode = value;
+ break;
+
+ case GLOBAL_DOCUMENT:
+ mbIsGlobalDoc = value;
+ break;
+
+ case GLOBAL_DOCUMENT_SAVE_LINKS:
+ mbGlblDocSaveLinks = value;
+ break;
+
+ case LABEL_DOCUMENT:
+ mbIsLabelDoc = value;
+ break;
+
+ case PURGE_OLE:
+ mbPurgeOLE = value;
+ break;
+
+ case KERN_ASIAN_PUNCTUATION:
+ mbKernAsianPunctuation = value;
+ break;
+
+ case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
+ mbDoNotResetParaAttrsForNumFont = value;
+ break;
+ case MATH_BASELINE_ALIGNMENT:
+ mbMathBaselineAlignment = value;
+ break;
+ case STYLES_NODEFAULT:
+ mbStylesNoDefault = value;
+ break;
+ case FLOATTABLE_NOMARGINS:
+ mbFloattableNomargins = value;
+ break;
+ case EMBED_FONTS:
+ mEmbedFonts = value;
+ break;
+ case EMBED_SYSTEM_FONTS:
+ mEmbedSystemFonts = value;
+ break;
+ default:
+ OSL_FAIL("Invalid setting id");
+ }
+}
+
+const i18n::ForbiddenCharacters*
+ sw::DocumentSettingManager::getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const
+{
+ const i18n::ForbiddenCharacters* pRet = 0;
+ if( mxForbiddenCharsTable.is() )
+ pRet = mxForbiddenCharsTable->GetForbiddenCharacters( nLang, false );
+ if( bLocaleData && !pRet && g_pBreakIt )
+ pRet = &g_pBreakIt->GetForbidden( (LanguageType)nLang );
+ return pRet;
+}
+
+void sw::DocumentSettingManager::setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang,
+ /*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rFChars )
+{
+ if( !mxForbiddenCharsTable.is() )
+ {
+ mxForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
+ }
+ mxForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars );
+
+ SdrModel *pDrawModel = m_rDoc.GetDrawModel();
+ if( pDrawModel )
+ {
+ pDrawModel->SetForbiddenCharsTable( mxForbiddenCharsTable );
+ if( !m_rDoc.IsInReading() )
+ pDrawModel->ReformatAllTextObjects();
+ }
+
+ SwRootFrm* pTmpRoot = m_rDoc.GetCurrentLayout();
+ if( pTmpRoot && !m_rDoc.IsInReading() )
+ {
+ pTmpRoot->StartAllAction();
+ std::set<SwRootFrm*> aAllLayouts = m_rDoc.GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
+ pTmpRoot->EndAllAction();
+ }
+ m_rDoc.SetModified();
+}
+
+rtl::Reference<SvxForbiddenCharactersTable>& sw::DocumentSettingManager::getForbiddenCharacterTable()
+{
+ if( !mxForbiddenCharsTable.is() )
+ {
+ mxForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
+ }
+ return mxForbiddenCharsTable;
+}
+
+const rtl::Reference<SvxForbiddenCharactersTable>& sw::DocumentSettingManager::getForbiddenCharacterTable() const
+{
+ return mxForbiddenCharsTable;
+}
+
+sal_uInt16 sw::DocumentSettingManager::getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const
+{
+ sal_uInt16 nRet = mnLinkUpdMode;
+ if( bGlobalSettings && GLOBALSETTING == nRet )
+ nRet = SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE));
+ return nRet;
+}
+
+void sw::DocumentSettingManager::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode )
+{
+ mnLinkUpdMode = eMode;
+}
+
+SwFldUpdateFlags sw::DocumentSettingManager::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const
+{
+ SwFldUpdateFlags eRet = meFldUpdMode;
+ if( bGlobalSettings && AUTOUPD_GLOBALSETTING == eRet )
+ eRet = SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE));
+ return eRet;
+}
+
+void sw::DocumentSettingManager::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode )
+{
+ meFldUpdMode = eMode;
+}
+
+SwCharCompressType sw::DocumentSettingManager::getCharacterCompressionType() const
+{
+ return meChrCmprType;
+}
+
+void sw::DocumentSettingManager::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
+{
+ if( meChrCmprType != n )
+ {
+ meChrCmprType = n;
+
+ SdrModel *pDrawModel = m_rDoc.GetDrawModel();
+ if( pDrawModel )
+ {
+ pDrawModel->SetCharCompressType( static_cast<sal_uInt16>(n) );
+ if( !m_rDoc.IsInReading() )
+ pDrawModel->ReformatAllTextObjects();
+ }
+
+ SwRootFrm* pTmpRoot = m_rDoc.GetCurrentLayout();
+ if( pTmpRoot && !m_rDoc.IsInReading() )
+ {
+ pTmpRoot->StartAllAction();
+ std::set<SwRootFrm*> aAllLayouts = m_rDoc.GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
+ pTmpRoot->EndAllAction();
+ }
+ m_rDoc.SetModified();
+ }
+}
+
+
+void sw::DocumentSettingManager::ReplaceCompatabilityOptions(const DocumentSettingManager& rSource)
+{
+ mbParaSpaceMax = rSource.mbParaSpaceMax;
+ mbParaSpaceMaxAtPages = rSource.mbParaSpaceMaxAtPages;
+ mbTabCompat = rSource.mbTabCompat;
+ mbUseVirtualDevice = rSource.mbUseVirtualDevice;
+ mbAddExternalLeading = rSource.mbAddExternalLeading;
+ mbOldLineSpacing = rSource.mbOldLineSpacing;
+ mbAddParaSpacingToTableCells = rSource.mbAddParaSpacingToTableCells;
+ mbUseFormerObjectPos = rSource.mbUseFormerObjectPos;
+ mbUseFormerTextWrapping = rSource.mbUseFormerTextWrapping;
+ mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos;
+ mbAddFlyOffsets = rSource.mbAddFlyOffsets;
+ mbOldNumbering = rSource.mbOldNumbering;
+ mbUseHiResolutionVirtualDevice = rSource.mbUseHiResolutionVirtualDevice;
+ mbIgnoreFirstLineIndentInNumbering = rSource.mbIgnoreFirstLineIndentInNumbering;
+ mbDoNotJustifyLinesWithManualBreak = rSource.mbDoNotJustifyLinesWithManualBreak;
+ mbDoNotResetParaAttrsForNumFont = rSource.mbDoNotResetParaAttrsForNumFont;
+ mbOutlineLevelYieldsOutlineRule = rSource.mbOutlineLevelYieldsOutlineRule;
+ mbTableRowKeep = rSource.mbTableRowKeep;
+ mbIgnoreTabsAndBlanksForLineCalculation = rSource.mbIgnoreTabsAndBlanksForLineCalculation;
+ mbDoNotCaptureDrawObjsOnPage = rSource.mbDoNotCaptureDrawObjsOnPage;
+ mbClipAsCharacterAnchoredWriterFlyFrames = rSource.mbClipAsCharacterAnchoredWriterFlyFrames;
+ mbUnixForceZeroExtLeading = rSource.mbUnixForceZeroExtLeading;
+ mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
+ mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 8b3d925..a479d26 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -18,6 +18,7 @@
*/
#include <doc.hxx>
+#include <DocumentSettingManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
@@ -33,7 +34,6 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
-#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <tools/urlobj.hxx>
#include <tools/poly.hxx>
@@ -48,7 +48,6 @@
#include <editeng/charsetcoloritem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <sfx2/linkmgr.hxx>
-#include <editeng/forbiddencharacterstable.hxx>
#include <svx/svdmodel.hxx>
#include <editeng/pbinitem.hxx>
#include <unotools/charclass.hxx>
@@ -67,7 +66,6 @@
#include <txtinet.hxx>
#include <txtrfmrk.hxx>
#include <frmatr.hxx>
-#include <linkenum.hxx>
#include <pagefrm.hxx>
#include <rootfrm.hxx>
#include <swtable.hxx>
@@ -79,7 +77,6 @@
#include <UndoSplitMove.hxx>
#include <UndoTable.hxx>
#include <pagedesc.hxx>
-#include <breakit.hxx>
#include <ndole.hxx>
#include <ndgrf.hxx>
#include <rolbck.hxx>
@@ -101,7 +98,6 @@
#include <statstr.hrc>
#include <comcore.hrc>
#include <SwUndoTOXChange.hxx>
-#include <SwUndoFmt.hxx>
#include <unocrsr.hxx>
#include <docsh.hxx>
#include <viewopt.hxx>
@@ -154,319 +150,44 @@ sal_Int32 SwDoc::getReferenceCount() const
/* IDocumentSettingAccess */
bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
{
- switch (id)
- {
- // COMPATIBILITY FLAGS START
- case PARA_SPACE_MAX: return mbParaSpaceMax; //(n8Dummy1 & DUMMY_PARASPACEMAX);
- case PARA_SPACE_MAX_AT_PAGES: return mbParaSpaceMaxAtPages; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES);
- case TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT);
- case ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
- case ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
- case USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
- case USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
- case OLD_NUMBERING: return mbOldNumbering;
- case OLD_LINE_SPACING: return mbOldLineSpacing;
- case ADD_PARA_SPACING_TO_TABLE_CELLS: return mbAddParaSpacingToTableCells;
- case USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos;
- case USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping;
- case CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos;
- case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak;
- case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering;
- case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: return mbOutlineLevelYieldsOutlineRule;
- case TABLE_ROW_KEEP: return mbTableRowKeep;
- case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation;
- case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage;
- // #i68949#
- case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames;
- case UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading;
- case TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent;
- case PROTECT_FORM: return mbProtectForm;
- // #i89181#
- case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
- case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
- case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
- case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66;
- case TAB_OVERFLOW: return mbTabOverflow;
- case UNBREAKABLE_NUMBERINGS: return mbUnbreakableNumberings;
- case CLIPPED_PICTURES: return mbClippedPictures;
- case BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings;
- case TAB_OVER_MARGIN: return mbTabOverMargin;
- case SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall;
-
- case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the SwViewShell has to be asked!
- case HTML_MODE: return mbHTMLMode;
- case GLOBAL_DOCUMENT: return mbIsGlobalDoc;
- case GLOBAL_DOCUMENT_SAVE_LINKS: return mbGlblDocSaveLinks;
- case LABEL_DOCUMENT: return mbIsLabelDoc;
- case PURGE_OLE: return mbPurgeOLE;
- case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation;
- case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
- case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
- case STYLES_NODEFAULT: return mbStylesNoDefault;
- case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
- case EMBED_FONTS: return mEmbedFonts;
- case EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
- default:
- OSL_FAIL("Invalid setting id");
- }
- return false;
+ return m_pDocumentSettingManager->get(id);
}
void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
{
- switch (id)
- {
- // COMPATIBILITY FLAGS START
- case PARA_SPACE_MAX:
- mbParaSpaceMax = value;
- break;
- case PARA_SPACE_MAX_AT_PAGES:
- mbParaSpaceMaxAtPages = value;
- break;
- case TAB_COMPAT:
- mbTabCompat = value;
- break;
- case ADD_FLY_OFFSETS:
- mbAddFlyOffsets = value;
- break;
- case ADD_EXT_LEADING:
- mbAddExternalLeading = value;
- break;
- case USE_VIRTUAL_DEVICE:
- mbUseVirtualDevice = value;
- break;
- case USE_HIRES_VIRTUAL_DEVICE:
- mbUseHiResolutionVirtualDevice = value;
- break;
- case OLD_NUMBERING:
- if (mbOldNumbering != value)
- {
- mbOldNumbering = value;
-
- const SwNumRuleTbl& rNmTbl = GetNumRuleTbl();
- for( sal_uInt16 n = 0; n < rNmTbl.size(); ++n )
- rNmTbl[n]->SetInvalidRule(sal_True);
-
- UpdateNumRule();
-
- if (mpOutlineRule)
- {
- mpOutlineRule->Validate();
- // counting of phantoms depends on <IsOldNumbering()>
- mpOutlineRule->SetCountPhantoms( !mbOldNumbering );
- }
- }
- break;
- case OLD_LINE_SPACING:
- mbOldLineSpacing = value;
- break;
- case ADD_PARA_SPACING_TO_TABLE_CELLS:
- mbAddParaSpacingToTableCells = value;
- break;
- case USE_FORMER_OBJECT_POS:
- mbUseFormerObjectPos = value;
- break;
- case USE_FORMER_TEXT_WRAPPING:
- mbUseFormerTextWrapping = value;
- break;
- case CONSIDER_WRAP_ON_OBJECT_POSITION:
- mbConsiderWrapOnObjPos = value;
- break;
- case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
- mbDoNotJustifyLinesWithManualBreak = value;
- break;
- case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
- mbIgnoreFirstLineIndentInNumbering = value;
- break;
-
- case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE:
- mbOutlineLevelYieldsOutlineRule = value;
- break;
-
- case TABLE_ROW_KEEP:
- mbTableRowKeep = value;
- break;
-
- case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
- mbIgnoreTabsAndBlanksForLineCalculation = value;
- break;
-
- case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
- mbDoNotCaptureDrawObjsOnPage = value;
- break;
-
- // #i68949#
- case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME:
- mbClipAsCharacterAnchoredWriterFlyFrames = value;
- break;
-
- case UNIX_FORCE_ZERO_EXT_LEADING:
- mbUnixForceZeroExtLeading = value;
- break;
-
- case PROTECT_FORM:
- mbProtectForm = value;
- break;
-
- case TABS_RELATIVE_TO_INDENT:
- mbTabRelativeToIndent = value;
- break;
- // #i89181#
- case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
- mbTabAtLeftIndentForParagraphsInList = value;
- break;
-
- case INVERT_BORDER_SPACING:
- mbInvertBorderSpacing = value;
- break;
-
- case COLLAPSE_EMPTY_CELL_PARA:
- mbCollapseEmptyCellPara = value;
- break;
-
- case SMALL_CAPS_PERCENTAGE_66:
- mbSmallCapsPercentage66 = value;
- break;
-
- case TAB_OVERFLOW:
- mbTabOverflow = value;
- break;
-
- case UNBREAKABLE_NUMBERINGS:
- mbUnbreakableNumberings = value;
- break;
-
- case CLIPPED_PICTURES:
- mbClippedPictures = value;
- break;
-
- case BACKGROUND_PARA_OVER_DRAWINGS:
- mbBackgroundParaOverDrawings = value;
- break;
-
- case TAB_OVER_MARGIN:
- mbTabOverMargin = value;
- break;
-
- case SURROUND_TEXT_WRAP_SMALL:
- mbSurroundTextWrapSmall = value;
- break;
-
- // COMPATIBILITY FLAGS END
-
- case BROWSE_MODE: //can be used temporary (load/save) when no SwViewShell is available
- mbLastBrowseMode = value;
- break;
-
- case HTML_MODE:
- mbHTMLMode = value;
- break;
-
- case GLOBAL_DOCUMENT:
- mbIsGlobalDoc = value;
- break;
-
- case GLOBAL_DOCUMENT_SAVE_LINKS:
- mbGlblDocSaveLinks = value;
- break;
-
- case LABEL_DOCUMENT:
- mbIsLabelDoc = value;
- break;
-
- case PURGE_OLE:
- mbPurgeOLE = value;
- break;
-
- case KERN_ASIAN_PUNCTUATION:
- mbKernAsianPunctuation = value;
- break;
-
- case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
- mbDoNotResetParaAttrsForNumFont = value;
- break;
- case MATH_BASELINE_ALIGNMENT:
- mbMathBaselineAlignment = value;
- break;
- case STYLES_NODEFAULT:
- mbStylesNoDefault = value;
- break;
- case FLOATTABLE_NOMARGINS:
- mbFloattableNomargins = value;
- break;
- case EMBED_FONTS:
- mEmbedFonts = value;
- break;
- case EMBED_SYSTEM_FONTS:
- mEmbedSystemFonts = value;
- break;
- default:
- OSL_FAIL("Invalid setting id");
- }
+ m_pDocumentSettingManager->set(id,value);
}
const i18n::ForbiddenCharacters*
SwDoc::getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const
{
- const i18n::ForbiddenCharacters* pRet = 0;
- if( mxForbiddenCharsTable.is() )
- pRet = mxForbiddenCharsTable->GetForbiddenCharacters( nLang, false );
- if( bLocaleData && !pRet && g_pBreakIt )
- pRet = &g_pBreakIt->GetForbidden( (LanguageType)nLang );
- return pRet;
+ return m_pDocumentSettingManager->getForbiddenCharacters(nLang,bLocaleData);
}
void SwDoc::setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang,
/*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rFChars )
{
- if( !mxForbiddenCharsTable.is() )
- {
- mxForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
- }
- mxForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars );
- if( mpDrawModel )
- {
- mpDrawModel->SetForbiddenCharsTable( mxForbiddenCharsTable );
- if( !mbInReading )
- mpDrawModel->ReformatAllTextObjects();
- }
-
- SwRootFrm* pTmpRoot = GetCurrentLayout();
- if( pTmpRoot && !mbInReading )
- {
- pTmpRoot->StartAllAction();
- std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
- std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
- pTmpRoot->EndAllAction();
- }
- SetModified();
+ m_pDocumentSettingManager->setForbiddenCharacters(nLang,rFChars);
}
rtl::Reference<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable()
{
- if( !mxForbiddenCharsTable.is() )
- {
- mxForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
- }
- return mxForbiddenCharsTable;
+ return m_pDocumentSettingManager->getForbiddenCharacterTable();
}
const rtl::Reference<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable() const
{
- return mxForbiddenCharsTable;
+ return m_pDocumentSettingManager->getForbiddenCharacterTable();
}
sal_uInt16 SwDoc::getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const
{
- sal_uInt16 nRet = mnLinkUpdMode;
- if( bGlobalSettings && GLOBALSETTING == nRet )
- nRet = SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE));
- return nRet;
+ return m_pDocumentSettingManager->getLinkUpdateMode(bGlobalSettings);
}
void SwDoc::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode )
{
- mnLinkUpdMode = eMode;
+ m_pDocumentSettingManager->setLinkUpdateMode(eMode);
}
sal_uInt32 SwDoc::getRsid() const
@@ -503,44 +224,22 @@ void SwDoc::setRsidRoot( sal_uInt32 nVal )
SwFldUpdateFlags SwDoc::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const
{
- SwFldUpdateFlags eRet = meFldUpdMode;
- if( bGlobalSettings && AUTOUPD_GLOBALSETTING == eRet )
- eRet = SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE));
- return eRet;
+ return m_pDocumentSettingManager->getFieldUpdateFlags(bGlobalSettings);
}
void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode )
{
- meFldUpdMode = eMode;
+ m_pDocumentSettingManager->setFieldUpdateFlags(eMode);
}
SwCharCompressType SwDoc::getCharacterCompressionType() const
{
- return meChrCmprType;
+ return m_pDocumentSettingManager->getCharacterCompressionType();
}
void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
{
- if( meChrCmprType != n )
- {
- meChrCmprType = n;
- if( mpDrawModel )
- {
- mpDrawModel->SetCharCompressType( static_cast<sal_uInt16>(n) );
- if( !mbInReading )
- mpDrawModel->ReformatAllTextObjects();
- }
-
- SwRootFrm* pTmpRoot = GetCurrentLayout();
- if( pTmpRoot && !mbInReading )
- {
- pTmpRoot->StartAllAction();
- std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
- std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
- pTmpRoot->EndAllAction();
- }
- SetModified();
- }
+ m_pDocumentSettingManager->setCharacterCompressionType(n);
}
/* IDocumentDeviceAccess */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 66eb19c58..c18438e 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -20,6 +20,7 @@
#include <config_features.h>
#include <doc.hxx>
+#include <DocumentSettingManager.hxx>
#include <dcontact.hxx>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
@@ -42,7 +43,6 @@
#include <sfx2/linkmgr.hxx>
#include <editeng/forbiddencharacterstable.hxx>
#include <svl/zforlist.hxx>
-#include <unotools/compatibility.hxx>
#include <unotools/lingucfg.hxx>
#include <svx/svdpage.hxx>
#include <paratr.hxx>
@@ -189,6 +189,7 @@ SwDoc::SwDoc()
m_pMetaFieldManager(new ::sw::MetaFieldManager()),
m_pUndoManager(new ::sw::UndoManager(
boost::shared_ptr<SwNodes>(new SwNodes(this)), *this, *this, *this)),
+ m_pDocumentSettingManager(new ::sw::DocumentSettingManager(*this)),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -242,10 +243,7 @@ SwDoc::SwDoc()
mpListItemsList( new tImplSortedNodeNumList() ), // #i83479#
m_pXmlIdRegistry(),
mnAutoFmtRedlnCommentNo( 0 ),
- mnLinkUpdMode( GLOBALSETTING ),
- meFldUpdMode( AUTOUPD_GLOBALSETTING ),
meRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
- meChrCmprType( CHARCOMPRESS_NONE ),
mReferenceCount(0),
mIdleBlockCount(0),
mnLockExpFld( 0 ),
@@ -263,19 +261,13 @@ SwDoc::SwDoc()
mbInXMLImport(false),
mbUpdateTOX(false),
mbInLoadAsynchron(false),
- mbHTMLMode(false),
mbInCallModified(false),
- mbIsGlobalDoc(false),
- mbGlblDocSaveLinks(false),
- mbIsLabelDoc(false),
mbIsAutoFmtRedline(false),
mbOLEPrtNotifyPending(false),
mbAllOLENotify(false),
mbIsRedlineMove(false),
mbInsOnlyTxtGlssry(false),
mbContains_MSVBasic(false),
- mbPurgeOLE(true),
- mbKernAsianPunctuation(false),
mbReadlineChecked(false),
mbLinksUpdated( false ), //#i38810#
mbClipBoard( false ),
@@ -288,36 +280,7 @@ SwDoc::SwDoc()
// COMPATIBILITY FLAGS START
- mbAddFlyOffsets(false),
- mbUseHiResolutionVirtualDevice(true),
- mbMathBaselineAlignment(false), // default for *old* documents is 'off'
- mbStylesNoDefault(false),
- mbFloattableNomargins(false),
- mEmbedFonts(false),
- mEmbedSystemFonts(false),
- mbOldNumbering(false),
- mbIgnoreFirstLineIndentInNumbering(false),
- mbDoNotResetParaAttrsForNumFont(false),
- mbTableRowKeep(false),
- mbIgnoreTabsAndBlanksForLineCalculation(false),
- mbDoNotCaptureDrawObjsOnPage(false),
- mbOutlineLevelYieldsOutlineRule(false),
- mbClipAsCharacterAnchoredWriterFlyFrames(false),
- mbUnixForceZeroExtLeading(false),
mbOldPrinterMetrics(false),
- mbTabRelativeToIndent(true),
- mbProtectForm(false), // i#78591#
- mbInvertBorderSpacing (false),
- mbCollapseEmptyCellPara(true),
- mbTabAtLeftIndentForParagraphsInList(false), //#i89181#
- mbSmallCapsPercentage66(false),
- mbTabOverflow(true),
- mbUnbreakableNumberings(false),
- mbClippedPictures(false),
- mbBackgroundParaOverDrawings(false),
- mbTabOverMargin(false),
- mbSurroundTextWrapSmall(false),
- mbLastBrowseMode( false ),
mn32DummyCompatabilityOptions1(0),
mn32DummyCompatabilityOptions2(0),
@@ -327,27 +290,6 @@ SwDoc::SwDoc()
mbReadOnly(false),
meDocType(DOCTYPE_NATIVE)
{
- // COMPATIBILITY FLAGS START
-
- // Note: Any non-hidden compatibility flag should obtain its default
- // by asking SvtCompatibilityOptions, see below.
-
- const SvtCompatibilityOptions aOptions;
- mbParaSpaceMax = aOptions.IsAddSpacing();
- mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages();
- mbTabCompat = !aOptions.IsUseOurTabStops();
- mbUseVirtualDevice = !aOptions.IsUsePrtDevice();
- mbAddExternalLeading = !aOptions.IsNoExtLeading();
- mbOldLineSpacing = aOptions.IsUseLineSpacing();
- mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing();
- mbUseFormerObjectPos = aOptions.IsUseObjectPositioning();
- mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping();
- mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle();
-
- mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace();
-
- // COMPATIBILITY FLAGS END
-
/*
* DefaultFormats and DefaultFormatCollections (FmtColl)
* are inserted at position 0 at the respective array.
@@ -1035,6 +977,18 @@ SwDoc::GetUndoManager() const
return *m_pUndoManager;
}
+::sw::DocumentSettingManager &
+SwDoc::GetDocumentSettingManager()
+{
+ return *m_pDocumentSettingManager;
+}
+
+::sw::DocumentSettingManager const&
+SwDoc::GetDocumentSettingManager() const
+{
+ return *m_pDocumentSettingManager;
+}
+
IDocumentUndoRedo &
SwDoc::GetIDocumentUndoRedo()
{
@@ -1105,31 +1059,9 @@ void SwDoc::ReplaceCompatabilityOptions(const SwDoc& rSource)
{
mn32DummyCompatabilityOptions1 = rSource.mn32DummyCompatabilityOptions1;
mn32DummyCompatabilityOptions2 = rSource.mn32DummyCompatabilityOptions2;
- mbParaSpaceMax = rSource.mbParaSpaceMax;
- mbParaSpaceMaxAtPages = rSource.mbParaSpaceMaxAtPages;
- mbTabCompat = rSource.mbTabCompat;
- mbUseVirtualDevice = rSource.mbUseVirtualDevice;
- mbAddExternalLeading = rSource.mbAddExternalLeading;
- mbOldLineSpacing = rSource.mbOldLineSpacing;
- mbAddParaSpacingToTableCells = rSource.mbAddParaSpacingToTableCells;
- mbUseFormerObjectPos = rSource.mbUseFormerObjectPos;
- mbUseFormerTextWrapping = rSource.mbUseFormerTextWrapping;
- mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos;
- mbAddFlyOffsets = rSource.mbAddFlyOffsets;
- mbOldNumbering = rSource.mbOldNumbering;
- mbUseHiResolutionVirtualDevice = rSource.mbUseHiResolutionVirtualDevice;
- mbIgnoreFirstLineIndentInNumbering = rSource.mbIgnoreFirstLineIndentInNumbering;
- mbDoNotJustifyLinesWithManualBreak = rSource.mbDoNotJustifyLinesWithManualBreak;
- mbDoNotResetParaAttrsForNumFont = rSource.mbDoNotResetParaAttrsForNumFont;
- mbOutlineLevelYieldsOutlineRule = rSource.mbOutlineLevelYieldsOutlineRule;
- mbTableRowKeep = rSource.mbTableRowKeep;
- mbIgnoreTabsAndBlanksForLineCalculation = rSource.mbIgnoreTabsAndBlanksForLineCalculation;
- mbDoNotCaptureDrawObjsOnPage = rSource.mbDoNotCaptureDrawObjsOnPage;
- mbClipAsCharacterAnchoredWriterFlyFrames = rSource.mbClipAsCharacterAnchoredWriterFlyFrames;
- mbUnixForceZeroExtLeading = rSource.mbUnixForceZeroExtLeading;
mbOldPrinterMetrics = rSource.mbOldPrinterMetrics;
- mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
- mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
+
+ m_pDocumentSettingManager->ReplaceCompatabilityOptions(rSource.GetDocumentSettingManager());
}
SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
new file mode 100644
index 0000000..10a2a5a
--- /dev/null
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -0,0 +1,120 @@
+/* -*- 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_DOCSETTING_HXX
+#define INCLUDED_SW_INC_DOCSETTING_HXX
+
+#include <IDocumentSettingAccess.hxx>
+class SwDoc;
+
+namespace sw {
+class DocumentSettingManager :
+ public IDocumentSettingAccess
+{
+ rtl::Reference<SvxForbiddenCharactersTable> mxForbiddenCharsTable;
+ SwDoc &m_rDoc;
+
+ sal_uInt16 mnLinkUpdMode; //< UpdateMode for links.
+
+ SwFldUpdateFlags meFldUpdMode;//< Automatically Update Mode for fields/charts.
+ SwCharCompressType meChrCmprType;//< for ASIAN: compress punctuation/kana
+
+ bool mbHTMLMode : 1; //< TRUE: Document is in HTMLMode.
+ bool mbIsGlobalDoc : 1; //< TRUE: It's a global document.
+ bool mbGlblDocSaveLinks : 1; //< TRUE: Save sections linked in global document.
+ bool mbIsLabelDoc : 1; //< TRUE: It's a label document.
+ bool mbPurgeOLE : 1; //< sal_True: Purge OLE-Objects
+ bool mbKernAsianPunctuation : 1; //< sal_True: kerning also for ASIAN punctuation
+
+ bool mbParaSpaceMax : 1;
+ bool mbParaSpaceMaxAtPages : 1;
+ bool mbTabCompat : 1;
+ bool mbUseVirtualDevice : 1;
+ bool mbAddFlyOffsets : 1;
+ bool mbAddExternalLeading : 1;
+ bool mbUseHiResolutionVirtualDevice : 1;
+ bool mbOldLineSpacing : 1; // #i11859#
+ bool mbAddParaSpacingToTableCells : 1;
+ bool mbUseFormerObjectPos : 1; // #i11860#
+ bool mbUseFormerTextWrapping : 1;
+ bool mbConsiderWrapOnObjPos : 1; // #i28701#
+ // sal_True: object positioning algorithm has consider the wrapping style of // the floating screen objects as given by its attribute 'WrapInfluenceOnObjPos'
+ // floating screen objects as given by its
+ // attribute 'WrapInfluenceOnObjPos'.
+ bool mbMathBaselineAlignment : 1; // TL 2010-10-29 #i972#
+ bool mbStylesNoDefault : 1;
+ bool mbFloattableNomargins : 1; //< If paragraph margins next to a floating table should be ignored.
+ bool mEmbedFonts : 1; //< Whether to embed fonts used by the document when saving.
+ bool mEmbedSystemFonts : 1; //< Whether to embed also system fonts.
+
+ // non-ui-compatibility flags:
+ bool mbOldNumbering : 1;
+ bool mbIgnoreFirstLineIndentInNumbering : 1; // #i47448#
+ bool mbDoNotJustifyLinesWithManualBreak : 1; // #i49277#
+ bool mbDoNotResetParaAttrsForNumFont : 1; // #i53199#
+ bool mbTableRowKeep : 1;
+ bool mbIgnoreTabsAndBlanksForLineCalculation : 1; // #i3952#
+ bool mbDoNotCaptureDrawObjsOnPage : 1; // #i62875#
+ bool mbOutlineLevelYieldsOutlineRule : 1;
+ bool mbClipAsCharacterAnchoredWriterFlyFrames : 1;
+ bool mbUnixForceZeroExtLeading : 1; // #i60945#
+ bool mbTabRelativeToIndent : 1; // #i24363# tab stops relative to indent
+ bool mbProtectForm : 1;
+ bool mbInvertBorderSpacing : 1;
+ bool mbCollapseEmptyCellPara : 1;
+ bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above
+ bool mbSmallCapsPercentage66;
+ bool mbTabOverflow;
+ bool mbUnbreakableNumberings;
+ bool mbClippedPictures;
+ bool mbBackgroundParaOverDrawings;
+ bool mbTabOverMargin;
+ bool mbSurroundTextWrapSmall;
+
+ bool mbLastBrowseMode : 1;
+
+public:
+
+ DocumentSettingManager(SwDoc &rDoc);
+ ~DocumentSettingManager();
+
+ // IDocumentSettingAccess
+ virtual bool get(/*[in]*/ DocumentSettingId id) const;
+ virtual void set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value);
+ virtual const com::sun::star::i18n::ForbiddenCharacters* getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const;
+ virtual void setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rForbiddenCharacters );
+ virtual rtl::Reference<SvxForbiddenCharactersTable>& getForbiddenCharacterTable();
+ virtual const rtl::Reference<SvxForbiddenCharactersTable>& getForbiddenCharacterTable() const;
+ virtual sal_uInt16 getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const;
+ virtual void setLinkUpdateMode( /*[in]*/ sal_uInt16 nMode );
+ virtual SwFldUpdateFlags getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const;
+ virtual void setFieldUpdateFlags( /*[in]*/ SwFldUpdateFlags eMode );
+ virtual SwCharCompressType getCharacterCompressionType() const;
+ virtual void setCharacterCompressionType( /*[in]*/SwCharCompressType nType );
+
+
+// Replace all compatability options with those from rSource.
+ void ReplaceCompatabilityOptions(const DocumentSettingManager& rSource);
+
+};
+
+}
+
+#endif //_DOCSETTING_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list