LCOV - code coverage report
Current view: top level - libreoffice/svx/source/svdraw - svdmodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 560 1103 50.8 %
Date: 2012-12-27 Functions: 77 120 64.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <svx/svdmodel.hxx>
      22             : 
      23             : #include <math.h>
      24             : 
      25             : #include <osl/endian.h>
      26             : #include <rtl/logfile.hxx>
      27             : #include <rtl/strbuf.hxx>
      28             : 
      29             : #include <com/sun/star/lang/XComponent.hpp>
      30             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
      31             : #include <com/sun/star/embed/ElementModes.hpp>
      32             : 
      33             : #include <unotools/ucbstreamhelper.hxx>
      34             : 
      35             : #include <tools/string.hxx>
      36             : #include <svl/whiter.hxx>
      37             : #include <svx/xit.hxx>
      38             : #include <svx/xbtmpit.hxx>
      39             : #include <svx/xlndsit.hxx>
      40             : #include <svx/xlnedit.hxx>
      41             : #include <svx/xflgrit.hxx>
      42             : #include <svx/xflftrit.hxx>
      43             : #include <svx/xflhtit.hxx>
      44             : #include <svx/xlnstit.hxx>
      45             : 
      46             : #include "svx/svditext.hxx"
      47             : #include <editeng/editeng.hxx>   // for EditEngine::CreatePool()
      48             : 
      49             : #include <svx/xtable.hxx>
      50             : 
      51             : #include "svx/svditer.hxx"
      52             : #include <svx/svdtrans.hxx>
      53             : #include <svx/svdpage.hxx>
      54             : #include <svx/svdlayer.hxx>
      55             : #include <svx/svdundo.hxx>
      56             : #include <svx/svdpool.hxx>
      57             : #include <svx/svdobj.hxx>
      58             : #include <svx/svdotext.hxx>  // for ReformatAllTextObjects and CalcFieldValue
      59             : #include <svx/svdetc.hxx>
      60             : #include <svx/svdoutl.hxx>
      61             : #include <svx/svdoole2.hxx>
      62             : #include "svx/svdglob.hxx"  // StringCache
      63             : #include "svx/svdstr.hrc"   // object's name
      64             : #include "svdoutlinercache.hxx"
      65             : 
      66             : #include "svx/xflclit.hxx"
      67             : #include "svx/xflhtit.hxx"
      68             : #include "svx/xlnclit.hxx"
      69             : 
      70             : #include "officecfg/Office/Common.hxx"
      71             : #include "editeng/fontitem.hxx"
      72             : #include <editeng/colritem.hxx>
      73             : #include <editeng/fhgtitem.hxx>
      74             : #include <svl/style.hxx>
      75             : #include <editeng/numitem.hxx>
      76             : #include <editeng/bulitem.hxx>
      77             : #include <editeng/outlobj.hxx>
      78             : #include "editeng/forbiddencharacterstable.hxx"
      79             : #include <svl/zforlist.hxx>
      80             : #include <comphelper/servicehelper.hxx>
      81             : #include <comphelper/storagehelper.hxx>
      82             : 
      83             : #include <tools/tenccvt.hxx>
      84             : #include <unotools/syslocale.hxx>
      85             : 
      86             : #include <vcl/svapp.hxx>
      87             : #include <svx/sdr/properties/properties.hxx>
      88             : #include <editeng/eeitem.hxx>
      89             : #include <svl/itemset.hxx>
      90             : 
      91             : using namespace ::com::sun::star;
      92             : using namespace ::com::sun::star::uno;
      93             : using namespace ::com::sun::star::lang;
      94             : 
      95             : ////////////////////////////////////////////////////////////////////////////////////////////////////
      96             : 
      97             : struct SdrModelImpl
      98             : {
      99             :     SfxUndoManager* mpUndoManager;
     100             :     SdrUndoFactory* mpUndoFactory;
     101             :     bool mbAllowShapePropertyChangeListener;
     102             : };
     103             : 
     104             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     105             : 
     106             : DBG_NAME(SdrModel)
     107         123 : TYPEINIT1(SdrModel,SfxBroadcaster);
     108         361 : void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper,
     109             :     bool bUseExtColorTable, bool bLoadRefCounts)
     110             : {
     111         361 :     mpImpl = new SdrModelImpl;
     112         361 :     mpImpl->mpUndoManager=0;
     113         361 :     mpImpl->mpUndoFactory=0;
     114         361 :     mpImpl->mbAllowShapePropertyChangeListener = false;
     115         361 :     mbInDestruction = false;
     116         361 :     aObjUnit=SdrEngineDefaults::GetMapFraction();
     117         361 :     eObjUnit=SdrEngineDefaults::GetMapUnit();
     118         361 :     eUIUnit=FUNIT_MM;
     119         361 :     aUIScale=Fraction(1,1);
     120         361 :     nUIUnitKomma=0;
     121         361 :     bUIOnlyKomma=sal_False;
     122         361 :     pLayerAdmin=NULL;
     123         361 :     pItemPool=pPool;
     124         361 :     bMyPool=sal_False;
     125         361 :     m_pEmbeddedHelper=_pEmbeddedHelper;
     126         361 :     pDrawOutliner=NULL;
     127         361 :     pHitTestOutliner=NULL;
     128         361 :     pRefOutDev=NULL;
     129         361 :     nProgressAkt=0;
     130         361 :     nProgressMax=0;
     131         361 :     nProgressOfs=0;
     132         361 :     pDefaultStyleSheet=NULL;
     133         361 :     pLinkManager=NULL;
     134         361 :     pUndoStack=NULL;
     135         361 :     pRedoStack=NULL;
     136         361 :     nMaxUndoCount=16;
     137         361 :     pAktUndoGroup=NULL;
     138         361 :     nUndoLevel=0;
     139         361 :     mbUndoEnabled=true;
     140         361 :     nProgressPercent=0;
     141         361 :     nLoadVersion=0;
     142         361 :     bExtColorTable=sal_False;
     143         361 :     mbChanged = sal_False;
     144         361 :     bInfoChanged=sal_False;
     145         361 :     bPagNumsDirty=sal_False;
     146         361 :     bMPgNumsDirty=sal_False;
     147         361 :     bPageNotValid=sal_False;
     148         361 :     bSavePortable=sal_False;
     149         361 :     bSaveCompressed=sal_False;
     150         361 :     bSaveNative=sal_False;
     151         361 :     bSwapGraphics=sal_False;
     152         361 :     nSwapGraphicsMode=SDR_SWAPGRAPHICSMODE_DEFAULT;
     153         361 :     bSaveOLEPreview=sal_False;
     154         361 :     bPasteResize=sal_False;
     155         361 :     bNoBitmapCaching=sal_False;
     156         361 :     bReadOnly=sal_False;
     157         361 :     nStreamCompressMode=COMPRESSMODE_NONE;
     158         361 :     nStreamNumberFormat=NUMBERFORMAT_INT_BIGENDIAN;
     159         361 :     nDefaultTabulator=0;
     160         361 :     mpNumberFormatter = NULL;
     161         361 :     bTransparentTextFrames=sal_False;
     162         361 :     bStarDrawPreviewMode = sal_False;
     163         361 :     nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND;
     164         361 :     mpForbiddenCharactersTable = NULL;
     165         361 :     mbModelLocked = false;
     166         361 :     mpOutlinerCache = NULL;
     167         361 :     mbKernAsianPunctuation = sal_False;
     168         361 :     mbAddExtLeading = sal_False;
     169         361 :     mnHandoutPageCount = 0;
     170             : 
     171             :     mnCharCompressType =
     172             :         officecfg::Office::Common::AsianLayout::CompressCharacterDistance::
     173         361 :         get();
     174             : 
     175             : #ifdef OSL_LITENDIAN
     176         361 :     nStreamNumberFormat=NUMBERFORMAT_INT_LITTLEENDIAN;
     177             : #endif
     178         361 :     bExtColorTable=bUseExtColorTable;
     179             : 
     180         361 :     if ( pPool == NULL )
     181             :     {
     182          99 :         pItemPool=new SdrItemPool(0L, bLoadRefCounts);
     183             :         // Outliner doesn't have its own Pool, so use the EditEngine's
     184          99 :         SfxItemPool* pOutlPool=EditEngine::CreatePool( bLoadRefCounts );
     185             :         // OutlinerPool as SecondaryPool of SdrPool
     186          99 :         pItemPool->SetSecondaryPool(pOutlPool);
     187             :         // remember that I created both pools myself
     188          99 :         bMyPool=sal_True;
     189             :     }
     190         361 :     pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
     191             : 
     192             : // using static SdrEngineDefaults only if default SvxFontHeight item is not available
     193         361 :     const SfxPoolItem* pPoolItem = pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT );
     194         361 :     if ( pPoolItem )
     195         262 :         nDefTextHgt = ((SvxFontHeightItem*)pPoolItem)->GetHeight();
     196             :     else
     197          99 :         nDefTextHgt = SdrEngineDefaults::GetFontHeight();
     198             : 
     199         361 :     pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_False ) );
     200             : 
     201         361 :     SetTextDefaults();
     202         361 :     pLayerAdmin=new SdrLayerAdmin;
     203         361 :     pLayerAdmin->SetModel(this);
     204         361 :     ImpSetUIUnit();
     205             : 
     206             :     // can't create DrawOutliner OnDemand, because I can't get the Pool,
     207             :     // then (only from 302 onwards!)
     208         361 :     pDrawOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
     209         361 :     ImpSetOutlinerDefaults(pDrawOutliner, sal_True);
     210             : 
     211         361 :     pHitTestOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
     212         361 :     ImpSetOutlinerDefaults(pHitTestOutliner, sal_True);
     213             : 
     214         361 :     ImpCreateTables();
     215         361 : }
     216             : 
     217           0 : SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
     218             :     aReadDate( DateTime::EMPTY ),
     219             :     maMaPag(),
     220           0 :     maPages()
     221             : {
     222             : #ifdef TIMELOG
     223             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
     224             : #endif
     225             : 
     226             :     DBG_CTOR(SdrModel,NULL);
     227           0 :     ImpCtor(pPool, pPers, false, (bool)bLoadRefCounts);
     228           0 : }
     229             : 
     230          61 : SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
     231             :     aReadDate( DateTime::EMPTY ),
     232             :     maMaPag(),
     233             :     maPages(),
     234          61 :     aTablePath(rPath)
     235             : {
     236             : #ifdef TIMELOG
     237             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
     238             : #endif
     239             : 
     240             :     DBG_CTOR(SdrModel,NULL);
     241          61 :     ImpCtor(pPool, pPers, false, (bool)bLoadRefCounts);
     242          61 : }
     243             : 
     244           0 : SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable, sal_Bool bLoadRefCounts):
     245             :     aReadDate( DateTime::EMPTY ),
     246             :     maMaPag(),
     247           0 :     maPages()
     248             : {
     249             : #ifdef TIMELOG
     250             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
     251             : #endif
     252             : 
     253             :     DBG_CTOR(SdrModel,NULL);
     254           0 :     ImpCtor(pPool,pPers,bUseExtColorTable, (bool)bLoadRefCounts);
     255           0 : }
     256             : 
     257         300 : SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable, sal_Bool bLoadRefCounts):
     258             :     aReadDate( DateTime::EMPTY ),
     259             :     maMaPag(),
     260             :     maPages(),
     261         300 :     aTablePath(rPath)
     262             : {
     263             : #ifdef TIMELOG
     264             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
     265             : #endif
     266             : 
     267             :     DBG_CTOR(SdrModel,NULL);
     268         300 :     ImpCtor(pPool,pPers,bUseExtColorTable, (bool)bLoadRefCounts);
     269         300 : }
     270             : 
     271           0 : SdrModel::SdrModel(const SdrModel& /*rSrcModel*/):
     272             :     SfxBroadcaster(),
     273             :     tools::WeakBase< SdrModel >(),
     274             :     aReadDate( DateTime::EMPTY ),
     275             :     maMaPag(),
     276           0 :     maPages()
     277             : {
     278             : #ifdef TIMELOG
     279             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
     280             : #endif
     281             : 
     282             :     // not yet implemented
     283             :     OSL_FAIL("SdrModel::CopyCtor() is not yet implemented.");
     284           0 : }
     285             : 
     286        1620 : SdrModel::~SdrModel()
     287             : {
     288             : #ifdef TIMELOG
     289             :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::~SdrModel(...)" );
     290             : #endif
     291             : 
     292             :     DBG_DTOR(SdrModel,NULL);
     293             : 
     294         180 :     mbInDestruction = true;
     295             : 
     296         180 :     Broadcast(SdrHint(HINT_MODELCLEARED));
     297             : 
     298         180 :     delete mpOutlinerCache;
     299             : 
     300         180 :     ClearUndoBuffer();
     301             : #ifdef DBG_UTIL
     302             :     if(pAktUndoGroup)
     303             :     {
     304             :         rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
     305             :             "In the Dtor of the SdrModel there is an open Undo left: \""));
     306             :         aStr.append(rtl::OUStringToOString(pAktUndoGroup->GetComment(), osl_getThreadTextEncoding()))
     307             :             .append('\"');
     308             :         OSL_FAIL(aStr.getStr());
     309             :     }
     310             : #endif
     311         180 :     if (pAktUndoGroup!=NULL)
     312           0 :         delete pAktUndoGroup;
     313             : 
     314         180 :     ClearModel(sal_True);
     315             : 
     316         180 :     delete pLayerAdmin;
     317             : 
     318             :     // Delete DrawOutliner only after deleting ItemPool, because ItemPool
     319             :     // references Items of the DrawOutliner!
     320         180 :     delete pHitTestOutliner;
     321         180 :     delete pDrawOutliner;
     322             : 
     323             :     // delete StyleSheetPool, derived classes should not do this since
     324             :     // the DrawingEngine may need it in its destructor
     325         180 :     if( mxStyleSheetPool.is() )
     326             :     {
     327          18 :         Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
     328          18 :         if( xComponent.is() ) try
     329             :         {
     330          18 :             xComponent->dispose();
     331             :         }
     332           0 :         catch( RuntimeException& )
     333             :         {
     334             :         }
     335          18 :         mxStyleSheetPool.clear();
     336             :     }
     337             : 
     338         180 :     if (bMyPool)
     339             :     {
     340             :         // delete Pools if they're mine
     341          92 :         SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool();
     342          92 :         SfxItemPool::Free(pItemPool);
     343             :         // OutlinerPool has to be deleted after deleting ItemPool, because
     344             :         // ItemPool contains SetItems that themselves reference Items from OutlinerPool.
     345          92 :         SfxItemPool::Free(pOutlPool);
     346             :     }
     347             : 
     348         180 :     if( mpForbiddenCharactersTable )
     349         108 :         mpForbiddenCharactersTable->release();
     350             : 
     351         180 :     if(mpNumberFormatter)
     352           0 :         delete mpNumberFormatter;
     353             : 
     354         180 :     delete mpImpl->mpUndoFactory;
     355         180 :     delete mpImpl;
     356        1440 : }
     357             : 
     358          48 : bool SdrModel::IsInDestruction() const
     359             : {
     360          48 :     return mbInDestruction;
     361             : }
     362             : 
     363             : // not yet implemented
     364           0 : void SdrModel::operator=(const SdrModel&)
     365             : {
     366             :     OSL_FAIL("SdrModel::operator=() is not yet implemented.");
     367           0 : }
     368             : 
     369           0 : bool SdrModel::operator==(const SdrModel&) const
     370             : {
     371             :     OSL_FAIL("SdrModel::operator==() is not yet implemented");
     372           0 :     return sal_False;
     373             : }
     374             : 
     375         318 : void SdrModel::SetSwapGraphics( bool bSwap )
     376             : {
     377         318 :     bSwapGraphics = bSwap;
     378         318 : }
     379             : 
     380           0 : bool SdrModel::IsReadOnly() const
     381             : {
     382           0 :     return bReadOnly;
     383             : }
     384             : 
     385           0 : void SdrModel::SetReadOnly(bool bYes)
     386             : {
     387           0 :     bReadOnly=bYes;
     388           0 : }
     389             : 
     390             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     391             : 
     392         139 : void SdrModel::SetMaxUndoActionCount(sal_uIntPtr nAnz)
     393             : {
     394         139 :     if (nAnz<1) nAnz=1;
     395         139 :     nMaxUndoCount=nAnz;
     396         139 :     if (pUndoStack!=NULL) {
     397           0 :         while (pUndoStack->size()>nMaxUndoCount) {
     398           0 :             delete pUndoStack->back();
     399           0 :             pUndoStack->pop_back();
     400             :         }
     401             :     }
     402         139 : }
     403             : 
     404         319 : void SdrModel::ClearUndoBuffer()
     405             : {
     406         319 :     if (pUndoStack!=NULL) {
     407         123 :         while (!pUndoStack->empty()) {
     408          41 :             delete pUndoStack->back();
     409          41 :             pUndoStack->pop_back();
     410             :         }
     411          41 :         delete pUndoStack;
     412          41 :         pUndoStack=NULL;
     413             :     }
     414         319 :     if (pRedoStack!=NULL) {
     415           0 :         while (!pRedoStack->empty()) {
     416           0 :             delete pRedoStack->back();
     417           0 :             pRedoStack->pop_back();
     418             :         }
     419           0 :         delete pRedoStack;
     420           0 :         pRedoStack=NULL;
     421             :     }
     422         319 : }
     423             : 
     424           0 : bool SdrModel::HasUndoActions() const
     425             : {
     426           0 :     return pUndoStack && !pUndoStack->empty();
     427             : }
     428             : 
     429           0 : bool SdrModel::HasRedoActions() const
     430             : {
     431           0 :     return pRedoStack && !pRedoStack->empty();
     432             : }
     433             : 
     434           0 : bool SdrModel::Undo()
     435             : {
     436           0 :     bool bRet = false;
     437           0 :     if( mpImpl->mpUndoManager )
     438             :     {
     439             :         OSL_FAIL("svx::SdrModel::Undo(), method not supported with application undo manager!");
     440             :     }
     441             :     else
     442             :     {
     443           0 :         SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL;
     444           0 :         if(pDo!=NULL)
     445             :         {
     446           0 :             const bool bWasUndoEnabled = mbUndoEnabled;
     447           0 :             mbUndoEnabled = false;
     448           0 :             pDo->Undo();
     449           0 :             if(pRedoStack==NULL)
     450           0 :                 pRedoStack=new std::deque<SfxUndoAction*>;
     451           0 :             SfxUndoAction* p = pUndoStack->front();
     452           0 :             pUndoStack->pop_front();
     453           0 :             pRedoStack->push_front(p);
     454           0 :             mbUndoEnabled = bWasUndoEnabled;
     455             :         }
     456             :     }
     457           0 :     return bRet;
     458             : }
     459             : 
     460           0 : bool SdrModel::Redo()
     461             : {
     462           0 :     bool bRet = false;
     463           0 :     if( mpImpl->mpUndoManager )
     464             :     {
     465             :         OSL_FAIL("svx::SdrModel::Redo(), method not supported with application undo manager!");
     466             :     }
     467             :     else
     468             :     {
     469           0 :         SfxUndoAction* pDo = HasRedoActions() ? pRedoStack->front() : NULL;
     470           0 :         if(pDo!=NULL)
     471             :         {
     472           0 :             const bool bWasUndoEnabled = mbUndoEnabled;
     473           0 :             mbUndoEnabled = false;
     474           0 :             pDo->Redo();
     475           0 :             if(pUndoStack==NULL)
     476           0 :                 pUndoStack=new std::deque<SfxUndoAction*>;
     477           0 :             SfxUndoAction* p = pRedoStack->front();
     478           0 :             pRedoStack->pop_front();
     479           0 :             pUndoStack->push_front(p);
     480           0 :             mbUndoEnabled = bWasUndoEnabled;
     481             :         }
     482             :     }
     483           0 :     return bRet;
     484             : }
     485             : 
     486           0 : bool SdrModel::Repeat(SfxRepeatTarget& rView)
     487             : {
     488           0 :     bool bRet = false;
     489           0 :     if( mpImpl->mpUndoManager )
     490             :     {
     491             :         OSL_FAIL("svx::SdrModel::Redo(), method not supported with application undo manager!");
     492             :     }
     493             :     else
     494             :     {
     495           0 :         SfxUndoAction* pDo = HasUndoActions() ? pUndoStack->front() : NULL;
     496           0 :         if(pDo!=NULL)
     497             :         {
     498           0 :             if(pDo->CanRepeat(rView))
     499             :             {
     500           0 :                 pDo->Repeat(rView);
     501           0 :                 bRet = true;
     502             :             }
     503             :         }
     504             :     }
     505           0 :     return bRet;
     506             : }
     507             : 
     508          41 : void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo)
     509             : {
     510             :     DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
     511          41 :     if( IsUndoEnabled() )
     512             :     {
     513          41 :         if (aUndoLink.IsSet())
     514             :         {
     515           0 :             aUndoLink.Call(pUndo);
     516             :         }
     517             :         else
     518             :         {
     519          41 :             if (pUndoStack==NULL)
     520          41 :                 pUndoStack=new std::deque<SfxUndoAction*>;
     521          41 :             pUndoStack->push_front(pUndo);
     522          82 :             while (pUndoStack->size()>nMaxUndoCount)
     523             :             {
     524           0 :                 delete pUndoStack->back();
     525           0 :                 pUndoStack->pop_back();
     526             :             }
     527          41 :             if (pRedoStack!=NULL)
     528           0 :                 pRedoStack->clear();
     529             :         }
     530             :     }
     531             :     else
     532             :     {
     533           0 :         delete pUndo;
     534             :     }
     535          41 : }
     536             : 
     537          41 : void SdrModel::BegUndo()
     538             : {
     539          41 :     if( mpImpl->mpUndoManager )
     540             :     {
     541           0 :         const String aEmpty;
     542           0 :         mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty);
     543           0 :         nUndoLevel++;
     544             :     }
     545          41 :     else if( IsUndoEnabled() )
     546             :     {
     547          41 :         if(pAktUndoGroup==NULL)
     548             :         {
     549          41 :             pAktUndoGroup = new SdrUndoGroup(*this);
     550          41 :             nUndoLevel=1;
     551             :         }
     552             :         else
     553             :         {
     554           0 :             nUndoLevel++;
     555             :         }
     556             :     }
     557          41 : }
     558             : 
     559          64 : void SdrModel::BegUndo(const XubString& rComment)
     560             : {
     561          64 :     if( mpImpl->mpUndoManager )
     562             :     {
     563          23 :         const String aEmpty;
     564          23 :         mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty );
     565          23 :         nUndoLevel++;
     566             :     }
     567          41 :     else if( IsUndoEnabled() )
     568             :     {
     569          41 :         BegUndo();
     570          41 :         if (nUndoLevel==1)
     571             :         {
     572          41 :             pAktUndoGroup->SetComment(rComment);
     573             :         }
     574             :     }
     575          64 : }
     576             : 
     577           0 : void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, SdrRepeatFunc eFunc)
     578             : {
     579           0 :     if( mpImpl->mpUndoManager )
     580             :     {
     581           0 :         String aComment(rComment);
     582           0 :         if( aComment.Len() && rObjDescr.Len() )
     583             :         {
     584           0 :             String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1"));
     585           0 :             aComment.SearchAndReplace(aSearchString, rObjDescr);
     586             :         }
     587           0 :         const String aEmpty;
     588           0 :         mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty );
     589           0 :         nUndoLevel++;
     590             :     }
     591           0 :     else if( IsUndoEnabled() )
     592             :     {
     593           0 :         BegUndo();
     594           0 :         if (nUndoLevel==1)
     595             :         {
     596           0 :             pAktUndoGroup->SetComment(rComment);
     597           0 :             pAktUndoGroup->SetObjDescription(rObjDescr);
     598           0 :             pAktUndoGroup->SetRepeatFunction(eFunc);
     599             :         }
     600             :     }
     601           0 : }
     602             : 
     603          64 : void SdrModel::EndUndo()
     604             : {
     605             :     DBG_ASSERT(nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!");
     606          64 :     if( mpImpl->mpUndoManager )
     607             :     {
     608          23 :         if( nUndoLevel )
     609             :         {
     610          23 :             nUndoLevel--;
     611          23 :             mpImpl->mpUndoManager->LeaveListAction();
     612             :         }
     613             :     }
     614             :     else
     615             :     {
     616          41 :         if(pAktUndoGroup!=NULL && IsUndoEnabled())
     617             :         {
     618          41 :             nUndoLevel--;
     619          41 :             if(nUndoLevel==0)
     620             :             {
     621          41 :                 if(pAktUndoGroup->GetActionCount()!=0)
     622             :                 {
     623          41 :                     SdrUndoAction* pUndo=pAktUndoGroup;
     624          41 :                     pAktUndoGroup=NULL;
     625          41 :                     ImpPostUndoAction(pUndo);
     626             :                 }
     627             :                 else
     628             :                 {
     629             :                     // was empty
     630           0 :                     delete pAktUndoGroup;
     631           0 :                     pAktUndoGroup=NULL;
     632             :                 }
     633             :             }
     634             :         }
     635             :     }
     636          64 : }
     637             : 
     638           0 : void SdrModel::SetUndoComment(const XubString& rComment)
     639             : {
     640             :     DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is already 0!");
     641             : 
     642           0 :     if( mpImpl->mpUndoManager )
     643             :     {
     644             :         OSL_FAIL("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
     645             :     }
     646           0 :     else if( IsUndoEnabled() )
     647             :     {
     648           0 :         if(nUndoLevel==1)
     649             :         {
     650           0 :             pAktUndoGroup->SetComment(rComment);
     651             :         }
     652             :     }
     653           0 : }
     654             : 
     655           0 : void SdrModel::SetUndoComment(const XubString& rComment, const XubString& rObjDescr)
     656             : {
     657             :     DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is already 0!");
     658           0 :     if( mpImpl->mpUndoManager )
     659             :     {
     660             :         OSL_FAIL("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
     661             :     }
     662             :     else
     663             :     {
     664           0 :         if (nUndoLevel==1)
     665             :         {
     666           0 :             pAktUndoGroup->SetComment(rComment);
     667           0 :             pAktUndoGroup->SetObjDescription(rObjDescr);
     668             :         }
     669             :     }
     670           0 : }
     671             : 
     672          64 : void SdrModel::AddUndo(SdrUndoAction* pUndo)
     673             : {
     674          64 :     if( mpImpl->mpUndoManager )
     675             :     {
     676          23 :         mpImpl->mpUndoManager->AddUndoAction( pUndo );
     677             :     }
     678          41 :     else if( !IsUndoEnabled() )
     679             :     {
     680           0 :         delete pUndo;
     681             :     }
     682             :     else
     683             :     {
     684          41 :         if (pAktUndoGroup!=NULL)
     685             :         {
     686          41 :             pAktUndoGroup->AddAction(pUndo);
     687             :         }
     688             :         else
     689             :         {
     690           0 :             ImpPostUndoAction(pUndo);
     691             :         }
     692             :     }
     693          64 : }
     694             : 
     695        5086 : void SdrModel::EnableUndo( bool bEnable )
     696             : {
     697        5086 :     if( mpImpl->mpUndoManager )
     698             :     {
     699          14 :         mpImpl->mpUndoManager->EnableUndo( bEnable );
     700             :     }
     701             :     else
     702             :     {
     703        5072 :         mbUndoEnabled = bEnable;
     704             :     }
     705        5086 : }
     706             : 
     707        1981 : bool SdrModel::IsUndoEnabled() const
     708             : {
     709        1981 :     if( mpImpl->mpUndoManager )
     710             :     {
     711          62 :         return mpImpl->mpUndoManager->IsUndoEnabled();
     712             :     }
     713             :     else
     714             :     {
     715        1919 :         return mbUndoEnabled;
     716             :     }
     717             : }
     718             : 
     719         361 : void SdrModel::ImpCreateTables()
     720             : {
     721        2527 :     for( int i = 0; i < XPROPERTY_LIST_COUNT; i++ )
     722             :     {
     723        2166 :         if( !bExtColorTable || i != XCOLOR_LIST )
     724             :             maProperties[i] = XPropertyList::CreatePropertyList (
     725        1866 :                 (XPropertyListType) i, aTablePath, (XOutdevItemPool*)pItemPool );
     726             :     }
     727         361 : }
     728             : 
     729         352 : void SdrModel::ClearModel(sal_Bool bCalledFromDestructor)
     730             : {
     731         352 :     if(bCalledFromDestructor)
     732             :     {
     733         352 :         mbInDestruction = true;
     734             :     }
     735             : 
     736             :     sal_Int32 i;
     737             :     // delete all drawing pages
     738         352 :     sal_Int32 nAnz=GetPageCount();
     739         680 :     for (i=nAnz-1; i>=0; i--)
     740             :     {
     741         328 :         DeletePage( (sal_uInt16)i );
     742             :     }
     743         352 :     maPages.clear();
     744         352 :     PageListChanged();
     745             : 
     746             :     // delete all Masterpages
     747         352 :     nAnz=GetMasterPageCount();
     748         379 :     for(i=nAnz-1; i>=0; i--)
     749             :     {
     750          27 :         DeleteMasterPage( (sal_uInt16)i );
     751             :     }
     752         352 :     maMaPag.clear();
     753         352 :     MasterPageListChanged();
     754             : 
     755         352 :     pLayerAdmin->ClearLayer();
     756         352 : }
     757             : 
     758           0 : SdrModel* SdrModel::AllocModel() const
     759             : {
     760           0 :     SdrModel* pModel=new SdrModel;
     761           0 :     pModel->SetScaleUnit(eObjUnit,aObjUnit);
     762           0 :     return pModel;
     763             : }
     764             : 
     765           0 : SdrPage* SdrModel::AllocPage(bool bMasterPage)
     766             : {
     767           0 :     return new SdrPage(*this,bMasterPage);
     768             : }
     769             : 
     770         361 : void SdrModel::SetTextDefaults() const
     771             : {
     772         361 :     SetTextDefaults( pItemPool, nDefTextHgt );
     773         361 : }
     774             : 
     775         381 : void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, sal_uIntPtr nDefTextHgt )
     776             : {
     777             :     // set application-language specific dynamic pool language defaults
     778         381 :     SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ;
     779         381 :     SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK);
     780         381 :     SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL);
     781         381 :     sal_uInt16 nLanguage(Application::GetSettings().GetLanguageTag().getLanguageType());
     782             : 
     783             :     // get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default
     784         381 :     Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
     785         381 :     aSvxFontItem.SetFamily(aFont.GetFamily());
     786         381 :     aSvxFontItem.SetFamilyName(aFont.GetName());
     787         381 :     aSvxFontItem.SetStyleName(String());
     788         381 :     aSvxFontItem.SetPitch( aFont.GetPitch());
     789         381 :     aSvxFontItem.SetCharSet( aFont.GetCharSet() );
     790         381 :     pItemPool->SetPoolDefaultItem(aSvxFontItem);
     791             : 
     792             :     // get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default
     793         381 :     Font aFontCJK(OutputDevice::GetDefaultFont(DEFAULTFONT_CJK_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
     794         381 :     aSvxFontItemCJK.SetFamily( aFontCJK.GetFamily());
     795         381 :     aSvxFontItemCJK.SetFamilyName(aFontCJK.GetName());
     796         381 :     aSvxFontItemCJK.SetStyleName(String());
     797         381 :     aSvxFontItemCJK.SetPitch( aFontCJK.GetPitch());
     798         381 :     aSvxFontItemCJK.SetCharSet( aFontCJK.GetCharSet());
     799         381 :     pItemPool->SetPoolDefaultItem(aSvxFontItemCJK);
     800             : 
     801             :     // get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default
     802         381 :     Font aFontCTL(OutputDevice::GetDefaultFont(DEFAULTFONT_CTL_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
     803         381 :     aSvxFontItemCTL.SetFamily(aFontCTL.GetFamily());
     804         381 :     aSvxFontItemCTL.SetFamilyName(aFontCTL.GetName());
     805         381 :     aSvxFontItemCTL.SetStyleName(String());
     806         381 :     aSvxFontItemCTL.SetPitch( aFontCTL.GetPitch() );
     807         381 :     aSvxFontItemCTL.SetCharSet( aFontCTL.GetCharSet());
     808         381 :     pItemPool->SetPoolDefaultItem(aSvxFontItemCTL);
     809             : 
     810             :     // set dynamic FontHeight defaults
     811         381 :     pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) );
     812         381 :     pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
     813         381 :     pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
     814             : 
     815             :     // set FontColor defaults
     816         381 :     pItemPool->SetPoolDefaultItem( SvxColorItem(SdrEngineDefaults::GetFontColor(), EE_CHAR_COLOR) );
     817         381 : }
     818             : 
     819       26054 : SdrOutliner& SdrModel::GetDrawOutliner(const SdrTextObj* pObj) const
     820             : {
     821       26054 :     pDrawOutliner->SetTextObj(pObj);
     822       26054 :     return *pDrawOutliner;
     823             : }
     824             : 
     825           0 : const SdrTextObj* SdrModel::GetFormattingTextObj() const
     826             : {
     827           0 :     if (pDrawOutliner!=NULL) {
     828           0 :         return pDrawOutliner->GetTextObj();
     829             :     }
     830           0 :     return NULL;
     831             : }
     832             : 
     833        3164 : void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, sal_Bool bInit )
     834             : {
     835             :     /**************************************************************************
     836             :     * Initialization of the Outliners for drawing text and HitTest
     837             :     **************************************************************************/
     838        3164 :     if( bInit )
     839             :     {
     840         722 :         pOutliner->EraseVirtualDevice();
     841         722 :         pOutliner->SetUpdateMode(sal_False);
     842         722 :         pOutliner->SetEditTextObjectPool(pItemPool);
     843         722 :         pOutliner->SetDefTab(nDefaultTabulator);
     844             :     }
     845             : 
     846        3164 :     pOutliner->SetRefDevice(GetRefDevice());
     847        3164 :     pOutliner->SetForbiddenCharsTable(GetForbiddenCharsTable());
     848        3164 :     pOutliner->SetAsianCompressionMode( mnCharCompressType );
     849        3164 :     pOutliner->SetKernAsianPunctuation( IsKernAsianPunctuation() );
     850        3164 :     pOutliner->SetAddExtLeading( IsAddExtLeading() );
     851             : 
     852        3164 :     if ( !GetRefDevice() )
     853             :     {
     854        2336 :         MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit);
     855        2336 :         pOutliner->SetRefMapMode(aMapMode);
     856             :     }
     857        3164 : }
     858             : 
     859         375 : void SdrModel::SetRefDevice(OutputDevice* pDev)
     860             : {
     861         375 :     pRefOutDev=pDev;
     862         375 :     ImpSetOutlinerDefaults( pDrawOutliner );
     863         375 :     ImpSetOutlinerDefaults( pHitTestOutliner );
     864         375 :     RefDeviceChanged();
     865         375 : }
     866             : 
     867         760 : void SdrModel::ImpReformatAllTextObjects()
     868             : {
     869         760 :     if( isLocked() )
     870         770 :         return;
     871             : 
     872         750 :     sal_uInt16 nAnz=GetMasterPageCount();
     873             :     sal_uInt16 nNum;
     874         750 :     for (nNum=0; nNum<nAnz; nNum++) {
     875           0 :         GetMasterPage(nNum)->ReformatAllTextObjects();
     876             :     }
     877         750 :     nAnz=GetPageCount();
     878        1142 :     for (nNum=0; nNum<nAnz; nNum++) {
     879         392 :         GetPage(nNum)->ReformatAllTextObjects();
     880             :     }
     881             : }
     882             : 
     883             : /*  steps over all available pages and sends notify messages to
     884             :     all edge objects that are connected to other objects so that
     885             :     they may reposition themselves
     886             : */
     887          73 : void SdrModel::ImpReformatAllEdgeObjects()
     888             : {
     889          73 :     if( isLocked() )
     890         146 :         return;
     891             : 
     892           0 :     sal_uInt16 nAnz=GetMasterPageCount();
     893             :     sal_uInt16 nNum;
     894           0 :     for (nNum=0; nNum<nAnz; nNum++)
     895             :     {
     896           0 :         GetMasterPage(nNum)->ReformatAllEdgeObjects();
     897             :     }
     898           0 :     nAnz=GetPageCount();
     899           0 :     for (nNum=0; nNum<nAnz; nNum++)
     900             :     {
     901           0 :         GetPage(nNum)->ReformatAllEdgeObjects();
     902             :     }
     903             : }
     904             : 
     905           0 : uno::Reference<embed::XStorage> SdrModel::GetDocumentStorage() const
     906             : {
     907             :     uno::Reference<document::XStorageBasedDocument> const xSBD(
     908           0 :             const_cast<SdrModel*>(this)->getUnoModel(), uno::UNO_QUERY);
     909           0 :     if (!xSBD.is())
     910             :     {
     911             :         SAL_WARN("svx", "no UNO model");
     912           0 :         return 0;
     913             :     }
     914           0 :     return xSBD->getDocumentStorage();
     915             : }
     916             : 
     917             : uno::Reference<io::XInputStream>
     918           0 : SdrModel::GetDocumentStream( ::rtl::OUString const& rURL,
     919             :                 ::comphelper::LifecycleProxy & rProxy) const
     920             : {
     921           0 :     uno::Reference<embed::XStorage> const xStorage(GetDocumentStorage());
     922           0 :     if (!xStorage.is())
     923             :     {
     924             :         SAL_WARN("svx", "no storage?");
     925           0 :         return 0;
     926             :     }
     927             :     try {
     928             :         uno::Reference<io::XStream> const xStream(
     929             :             ::comphelper::OStorageHelper::GetStreamAtPackageURL(
     930           0 :                 xStorage, rURL, embed::ElementModes::READ, rProxy));
     931           0 :         return (xStream.is()) ? xStream->getInputStream() : 0;
     932             :     }
     933           0 :     catch (container::NoSuchElementException const&)
     934             :     {
     935             :         SAL_INFO("svx", "not found");
     936             :     }
     937           0 :     catch (uno::Exception const& e)
     938             :     {
     939             :         SAL_WARN("svx", "exception: '" << e.Message << "'");
     940             :     }
     941           0 :     return 0;
     942             : }
     943             : 
     944             : // convert template attributes from the string into "hard" attributes
     945           0 : void SdrModel::BurnInStyleSheetAttributes()
     946             : {
     947           0 :     sal_uInt16 nAnz=GetMasterPageCount();
     948             :     sal_uInt16 nNum;
     949           0 :     for (nNum=0; nNum<nAnz; nNum++) {
     950           0 :         GetMasterPage(nNum)->BurnInStyleSheetAttributes();
     951             :     }
     952           0 :     nAnz=GetPageCount();
     953           0 :     for (nNum=0; nNum<nAnz; nNum++) {
     954           0 :         GetPage(nNum)->BurnInStyleSheetAttributes();
     955             :     }
     956           0 : }
     957             : 
     958         375 : void SdrModel::RefDeviceChanged()
     959             : {
     960         375 :     Broadcast(SdrHint(HINT_REFDEVICECHG));
     961         375 :     ImpReformatAllTextObjects();
     962         375 : }
     963             : 
     964          61 : void SdrModel::SetDefaultFontHeight(sal_uIntPtr nVal)
     965             : {
     966          61 :     if (nVal!=nDefTextHgt) {
     967          41 :         nDefTextHgt=nVal;
     968          41 :         Broadcast(SdrHint(HINT_DEFFONTHGTCHG));
     969          41 :         ImpReformatAllTextObjects();
     970             :     }
     971          61 : }
     972             : 
     973          60 : void SdrModel::SetDefaultTabulator(sal_uInt16 nVal)
     974             : {
     975          60 :     if (nDefaultTabulator!=nVal) {
     976          59 :         nDefaultTabulator=nVal;
     977          59 :         Outliner& rOutliner=GetDrawOutliner();
     978          59 :         rOutliner.SetDefTab(nVal);
     979          59 :         Broadcast(SdrHint(HINT_DEFAULTTABCHG));
     980          59 :         ImpReformatAllTextObjects();
     981             :     }
     982          60 : }
     983             : 
     984         643 : void SdrModel::ImpSetUIUnit()
     985             : {
     986         643 :     if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator())
     987             :     {
     988           0 :         aUIScale = Fraction(1,1);
     989             :     }
     990             : 
     991             :     // set start values
     992         643 :     nUIUnitKomma = 0;
     993         643 :     sal_Int64 nMul(1);
     994         643 :     sal_Int64 nDiv(1);
     995             : 
     996             :     // normalize on meters resp. inch
     997         643 :     switch (eObjUnit)
     998             :     {
     999         381 :         case MAP_100TH_MM   : nUIUnitKomma+=5; break;
    1000           0 :         case MAP_10TH_MM    : nUIUnitKomma+=4; break;
    1001           0 :         case MAP_MM         : nUIUnitKomma+=3; break;
    1002           0 :         case MAP_CM         : nUIUnitKomma+=2; break;
    1003           0 :         case MAP_1000TH_INCH: nUIUnitKomma+=3; break;
    1004           0 :         case MAP_100TH_INCH : nUIUnitKomma+=2; break;
    1005           0 :         case MAP_10TH_INCH  : nUIUnitKomma+=1; break;
    1006           0 :         case MAP_INCH       : nUIUnitKomma+=0; break;
    1007           0 :         case MAP_POINT      : nDiv=72;     break;          // 1Pt   = 1/72"
    1008         262 :         case MAP_TWIP       : nDiv=144; nUIUnitKomma++; break; // 1Twip = 1/1440"
    1009           0 :         case MAP_PIXEL      : break;
    1010           0 :         case MAP_SYSFONT    : break;
    1011           0 :         case MAP_APPFONT    : break;
    1012           0 :         case MAP_RELATIVE   : break;
    1013           0 :         default: break;
    1014             :     } // switch
    1015             : 
    1016             :     // 1 mile    =  8 furlong = 63.360" = 1.609.344,0mm
    1017             :     // 1 furlong = 10 chains  =  7.920" =   201.168,0mm
    1018             :     // 1 chain   =  4 poles   =    792" =    20.116,8mm
    1019             :     // 1 pole    =  5 1/2 yd  =    198" =     5.029,2mm
    1020             :     // 1 yd      =  3 ft      =     36" =       914,4mm
    1021             :     // 1 ft      = 12 "       =      1" =       304,8mm
    1022         643 :     switch (eUIUnit)
    1023             :     {
    1024           0 :         case FUNIT_NONE   : break;
    1025             :         // metric
    1026           0 :         case FUNIT_100TH_MM: nUIUnitKomma-=5; break;
    1027         623 :         case FUNIT_MM     : nUIUnitKomma-=3; break;
    1028           0 :         case FUNIT_CM     : nUIUnitKomma-=2; break;
    1029           0 :         case FUNIT_M      : nUIUnitKomma+=0; break;
    1030           0 :         case FUNIT_KM     : nUIUnitKomma+=3; break;
    1031             :         // Inch
    1032           0 :         case FUNIT_TWIP   : nMul=144; nUIUnitKomma--;  break;  // 1Twip = 1/1440"
    1033           0 :         case FUNIT_POINT  : nMul=72;     break;            // 1Pt   = 1/72"
    1034           0 :         case FUNIT_PICA   : nMul=6;      break;            // 1Pica = 1/6"
    1035          20 :         case FUNIT_INCH   : break;                         // 1"    = 1"
    1036           0 :         case FUNIT_FOOT   : nDiv*=12;    break;            // 1Ft   = 12"
    1037           0 :         case FUNIT_MILE   : nDiv*=6336; nUIUnitKomma++; break; // 1mile = 63360"
    1038             :         // other
    1039           0 :         case FUNIT_CUSTOM : break;
    1040           0 :         case FUNIT_PERCENT: nUIUnitKomma+=2; break;
    1041             :         // TODO: Add code to handle the following if needed (added to remove warning)
    1042           0 :         case FUNIT_CHAR   : break;
    1043           0 :         case FUNIT_LINE   : break;
    1044             :     } // switch
    1045             : 
    1046             :     // check if mapping is from metric to inch and adapt
    1047         643 :     const bool bMapInch(IsInch(eObjUnit));
    1048         643 :     const bool bUIMetr(IsMetric(eUIUnit));
    1049             : 
    1050         643 :     if (bMapInch && bUIMetr)
    1051             :     {
    1052         262 :         nUIUnitKomma += 4;
    1053         262 :         nMul *= 254;
    1054             :     }
    1055             : 
    1056             :     // check if mapping is from inch to metric and adapt
    1057         643 :     const bool bMapMetr(IsMetric(eObjUnit));
    1058         643 :     const bool bUIInch(IsInch(eUIUnit));
    1059             : 
    1060         643 :     if (bMapMetr && bUIInch)
    1061             :     {
    1062          20 :         nUIUnitKomma -= 4;
    1063          20 :         nDiv *= 254;
    1064             :     }
    1065             : 
    1066             :     // use temporary fraction for reduction (fallback to 32bit here),
    1067             :     // may need to be changed in the future, too
    1068         643 :     if(1 != nMul || 1 != nDiv)
    1069             :     {
    1070         282 :         const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv));
    1071         282 :         nMul = aTemp.GetNumerator();
    1072         282 :         nDiv = aTemp.GetDenominator();
    1073             :     }
    1074             : 
    1075             :     // #i89872# take Unit of Measurement into account
    1076         643 :     if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator())
    1077             :     {
    1078             :         // divide by UIScale
    1079           0 :         nMul *= aUIScale.GetDenominator();
    1080           0 :         nDiv *= aUIScale.GetNumerator();
    1081             :     }
    1082             : 
    1083             :     // shorten trailing zeros for dividend
    1084        1286 :     while(0 == (nMul % 10))
    1085             :     {
    1086           0 :         nUIUnitKomma--;
    1087           0 :         nMul /= 10;
    1088             :     }
    1089             : 
    1090             :     // shorten trailing zeros for divisor
    1091        1286 :     while(0 == (nDiv % 10))
    1092             :     {
    1093           0 :         nUIUnitKomma++;
    1094           0 :         nDiv /= 10;
    1095             :     }
    1096             : 
    1097             :     // end preparations, set member values
    1098         643 :     aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
    1099         643 :     bUIOnlyKomma = (nMul == nDiv);
    1100         643 :     TakeUnitStr(eUIUnit, aUIUnitStr);
    1101         643 : }
    1102             : 
    1103           0 : void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
    1104             : {
    1105           0 :     if (eObjUnit!=eMap || aObjUnit!=rFrac) {
    1106           0 :         eObjUnit=eMap;
    1107           0 :         aObjUnit=rFrac;
    1108           0 :         pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
    1109           0 :         ImpSetUIUnit();
    1110           0 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1111           0 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1112           0 :         ImpReformatAllTextObjects();
    1113             :     }
    1114           0 : }
    1115             : 
    1116         361 : void SdrModel::SetScaleUnit(MapUnit eMap)
    1117             : {
    1118         361 :     if (eObjUnit!=eMap) {
    1119         262 :         eObjUnit=eMap;
    1120         262 :         pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
    1121         262 :         ImpSetUIUnit();
    1122         262 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1123         262 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1124         262 :         ImpReformatAllTextObjects();
    1125             :     }
    1126         361 : }
    1127             : 
    1128          61 : void SdrModel::SetScaleFraction(const Fraction& rFrac)
    1129             : {
    1130          61 :     if (aObjUnit!=rFrac) {
    1131           0 :         aObjUnit=rFrac;
    1132           0 :         ImpSetUIUnit();
    1133           0 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1134           0 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1135           0 :         ImpReformatAllTextObjects();
    1136             :     }
    1137          61 : }
    1138             : 
    1139           0 : void SdrModel::SetUIUnit(FieldUnit eUnit)
    1140             : {
    1141           0 :     if (eUIUnit!=eUnit) {
    1142           0 :         eUIUnit=eUnit;
    1143           0 :         ImpSetUIUnit();
    1144           0 :         ImpReformatAllTextObjects();
    1145             :     }
    1146           0 : }
    1147             : 
    1148           0 : void SdrModel::SetUIScale(const Fraction& rScale)
    1149             : {
    1150           0 :     if (aUIScale!=rScale) {
    1151           0 :         aUIScale=rScale;
    1152           0 :         ImpSetUIUnit();
    1153           0 :         ImpReformatAllTextObjects();
    1154             :     }
    1155           0 : }
    1156             : 
    1157          20 : void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
    1158             : {
    1159          20 :     if (eUIUnit!=eUnit || aUIScale!=rScale) {
    1160          20 :         eUIUnit=eUnit;
    1161          20 :         aUIScale=rScale;
    1162          20 :         ImpSetUIUnit();
    1163          20 :         ImpReformatAllTextObjects();
    1164             :     }
    1165          20 : }
    1166             : 
    1167         643 : void SdrModel::TakeUnitStr(FieldUnit eUnit, XubString& rStr)
    1168             : {
    1169         643 :     switch(eUnit)
    1170             :     {
    1171             :         default:
    1172             :         case FUNIT_NONE   :
    1173             :         case FUNIT_CUSTOM :
    1174             :         {
    1175           0 :             rStr = String();
    1176           0 :             break;
    1177             :         }
    1178             :         case FUNIT_100TH_MM:
    1179             :         {
    1180           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("/100mm"));
    1181           0 :             break;
    1182             :         }
    1183             :         case FUNIT_MM     :
    1184             :         {
    1185         623 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("mm"));
    1186         623 :             break;
    1187             :         }
    1188             :         case FUNIT_CM     :
    1189             :         {
    1190           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("cm"));
    1191           0 :             break;
    1192             :         }
    1193             :         case FUNIT_M      :
    1194             :         {
    1195           0 :             rStr = String();
    1196           0 :             rStr += sal_Unicode('m');
    1197           0 :             break;
    1198             :         }
    1199             :         case FUNIT_KM     :
    1200             :         {
    1201           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("km"));
    1202           0 :             break;
    1203             :         }
    1204             :         case FUNIT_TWIP   :
    1205             :         {
    1206           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("twip"));
    1207           0 :             break;
    1208             :         }
    1209             :         case FUNIT_POINT  :
    1210             :         {
    1211           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("pt"));
    1212           0 :             break;
    1213             :         }
    1214             :         case FUNIT_PICA   :
    1215             :         {
    1216           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("pica"));
    1217           0 :             break;
    1218             :         }
    1219             :         case FUNIT_INCH   :
    1220             :         {
    1221          20 :             rStr = String();
    1222          20 :             rStr += sal_Unicode('"');
    1223          20 :             break;
    1224             :         }
    1225             :         case FUNIT_FOOT   :
    1226             :         {
    1227           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("ft"));
    1228           0 :             break;
    1229             :         }
    1230             :         case FUNIT_MILE   :
    1231             :         {
    1232           0 :             rStr = UniString(RTL_CONSTASCII_USTRINGPARAM("mile(s)"));
    1233           0 :             break;
    1234             :         }
    1235             :         case FUNIT_PERCENT:
    1236             :         {
    1237           0 :             rStr = String();
    1238           0 :             rStr += sal_Unicode('%');
    1239           0 :             break;
    1240             :         }
    1241             :     }
    1242         643 : }
    1243             : 
    1244           0 : void SdrModel::TakeMetricStr(long nVal, rtl::OUString& rStr, bool bNoUnitChars, sal_Int32 nNumDigits) const
    1245             : {
    1246             :     // #i22167#
    1247             :     // change to double precision usage to not lose decimal places
    1248           0 :     const bool bNegative(nVal < 0L);
    1249           0 :     SvtSysLocale aSysLoc;
    1250           0 :     const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData());
    1251           0 :     double fLocalValue(double(nVal) * double(aUIUnitFact));
    1252             : 
    1253           0 :     if(bNegative)
    1254             :     {
    1255           0 :         fLocalValue = -fLocalValue;
    1256             :     }
    1257             : 
    1258           0 :     if( -1 == nNumDigits )
    1259             :     {
    1260           0 :         nNumDigits = rLoc.getNumDigits();
    1261             :     }
    1262             : 
    1263           0 :     sal_Int32 nKomma(nUIUnitKomma);
    1264             : 
    1265           0 :     if(nKomma > nNumDigits)
    1266             :     {
    1267           0 :         const sal_Int32 nDiff(nKomma - nNumDigits);
    1268           0 :         const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
    1269             : 
    1270           0 :         fLocalValue /= fFactor;
    1271           0 :         nKomma = nNumDigits;
    1272             :     }
    1273           0 :     else if(nKomma < nNumDigits)
    1274             :     {
    1275           0 :         const sal_Int32 nDiff(nNumDigits - nKomma);
    1276           0 :         const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
    1277             : 
    1278           0 :         fLocalValue *= fFactor;
    1279           0 :         nKomma = nNumDigits;
    1280             :     }
    1281             : 
    1282           0 :     rtl::OUStringBuffer aBuf;
    1283           0 :     aBuf.append(static_cast<sal_Int32>(fLocalValue + 0.5));
    1284             : 
    1285           0 :     if(nKomma < 0)
    1286             :     {
    1287             :         // negative nKomma (decimal point) means: add zeros
    1288           0 :         sal_Int32 nAnz(-nKomma);
    1289             : 
    1290           0 :         for(sal_Int32 i=0; i<nAnz; i++)
    1291           0 :             aBuf.append(sal_Unicode('0'));
    1292             : 
    1293           0 :         nKomma = 0;
    1294             :     }
    1295             : 
    1296             :     // the second condition needs to be <= since inside this loop
    1297             :     // also the leading zero is inserted.
    1298           0 :     if (nKomma > 0 && aBuf.getLength() <= nKomma)
    1299             :     {
    1300             :         // if necessary, add zeros before the decimal point
    1301           0 :         sal_Int32 nAnz = nKomma - aBuf.getLength();
    1302             : 
    1303           0 :         if(nAnz >= 0 && rLoc.isNumLeadingZero())
    1304           0 :             nAnz++;
    1305             : 
    1306           0 :         for(sal_Int32 i=0; i<nAnz; i++)
    1307           0 :             aBuf.insert(0, sal_Unicode('0'));
    1308             :     }
    1309             : 
    1310           0 :     sal_Unicode cDec( rLoc.getNumDecimalSep()[0] );
    1311             : 
    1312             :     // insert KommaChar (decimal point character)
    1313           0 :     sal_Int32 nVorKomma = aBuf.getLength() - nKomma;
    1314             : 
    1315           0 :     if(nKomma > 0)
    1316           0 :         aBuf.insert(nVorKomma, cDec);
    1317             : 
    1318           0 :     if(!rLoc.isNumTrailingZeros())
    1319             :     {
    1320             :         // Remove all trailing zeros.
    1321           0 :         while (aBuf.getLength() && aBuf[aBuf.getLength()-1] == sal_Unicode('0'))
    1322           0 :             aBuf.remove(aBuf.getLength()-1, 1);
    1323             : 
    1324             :         // Remove decimal if it's the last character.
    1325           0 :         if (aBuf.getLength() && aBuf[aBuf.getLength()-1] == cDec)
    1326           0 :             aBuf.remove(aBuf.getLength()-1, 1);
    1327             :     }
    1328             : 
    1329             :     // if necessary, add separators before every third digit
    1330           0 :     if( nVorKomma > 3 )
    1331             :     {
    1332           0 :         String aThoSep( rLoc.getNumThousandSep() );
    1333           0 :         if ( aThoSep.Len() > 0 )
    1334             :         {
    1335           0 :             sal_Unicode cTho( aThoSep.GetChar(0) );
    1336           0 :             sal_Int32 i(nVorKomma - 3);
    1337             : 
    1338           0 :             while(i > 0)
    1339             :             {
    1340           0 :                 aBuf.insert(i, cTho);
    1341           0 :                 i -= 3;
    1342             :             }
    1343           0 :         }
    1344             :     }
    1345             : 
    1346           0 :     if (!aBuf.getLength())
    1347           0 :         aBuf.append(sal_Unicode('0'));
    1348             : 
    1349           0 :     if(bNegative)
    1350             :     {
    1351           0 :         aBuf.insert(0, sal_Unicode('-'));
    1352             :     }
    1353             : 
    1354           0 :     if(!bNoUnitChars)
    1355           0 :         aBuf.append(aUIUnitStr);
    1356             : 
    1357           0 :     rStr = aBuf.makeStringAndClear();
    1358           0 : }
    1359             : 
    1360           0 : void SdrModel::TakeWinkStr(long nWink, rtl::OUString& rStr, bool bNoDegChar) const
    1361             : {
    1362           0 :     bool bNeg = nWink < 0;
    1363             : 
    1364           0 :     if(bNeg)
    1365           0 :         nWink = -nWink;
    1366             : 
    1367           0 :     rtl::OUStringBuffer aBuf;
    1368           0 :     aBuf.append(static_cast<sal_Int32>(nWink));
    1369             : 
    1370           0 :     SvtSysLocale aSysLoc;
    1371           0 :     const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
    1372           0 :     sal_Int32 nAnz = 2;
    1373             : 
    1374           0 :     if(rLoc.isNumLeadingZero())
    1375           0 :         nAnz++;
    1376             : 
    1377           0 :     while(aBuf.getLength() < nAnz)
    1378           0 :         aBuf.insert(0, sal_Unicode('0'));
    1379             : 
    1380           0 :     aBuf.insert(aBuf.getLength()-2, rLoc.getNumDecimalSep()[0]);
    1381             : 
    1382           0 :     if(bNeg)
    1383           0 :         aBuf.insert(0, sal_Unicode('-'));
    1384             : 
    1385           0 :     if(!bNoDegChar)
    1386           0 :         aBuf.append(DEGREE_CHAR);
    1387             : 
    1388           0 :     rStr = aBuf.makeStringAndClear();
    1389           0 : }
    1390             : 
    1391           0 : void SdrModel::TakePercentStr(const Fraction& rVal, XubString& rStr, bool bNoPercentChar) const
    1392             : {
    1393           0 :     sal_Int32 nMul(rVal.GetNumerator());
    1394           0 :     sal_Int32 nDiv(rVal.GetDenominator());
    1395           0 :     sal_Bool bNeg(nMul < 0);
    1396             : 
    1397           0 :     if(nDiv < 0)
    1398           0 :         bNeg = !bNeg;
    1399             : 
    1400           0 :     if(nMul < 0)
    1401           0 :         nMul = -nMul;
    1402             : 
    1403           0 :     if(nDiv < 0)
    1404           0 :         nDiv = -nDiv;
    1405             : 
    1406           0 :     nMul *= 100;
    1407           0 :     nMul += nDiv/2;
    1408           0 :     nMul /= nDiv;
    1409             : 
    1410           0 :     rStr = UniString::CreateFromInt32(nMul);
    1411             : 
    1412           0 :     if(bNeg)
    1413           0 :         rStr.Insert(sal_Unicode('-'), 0);
    1414             : 
    1415           0 :     if(!bNoPercentChar)
    1416           0 :         rStr += sal_Unicode('%');
    1417           0 : }
    1418             : 
    1419      102403 : void SdrModel::SetChanged(sal_Bool bFlg)
    1420             : {
    1421      102403 :     mbChanged = bFlg;
    1422      102403 : }
    1423             : 
    1424           0 : void SdrModel::RecalcPageNums(bool bMaster)
    1425             : {
    1426           0 :     if(bMaster)
    1427             :     {
    1428           0 :         sal_uInt16 nAnz=sal_uInt16(maMaPag.size());
    1429             :         sal_uInt16 i;
    1430           0 :         for (i=0; i<nAnz; i++) {
    1431           0 :             SdrPage* pPg=maMaPag[i];
    1432           0 :             pPg->SetPageNum(i);
    1433             :         }
    1434           0 :         bMPgNumsDirty=sal_False;
    1435             :     }
    1436             :     else
    1437             :     {
    1438           0 :         sal_uInt16 nAnz=sal_uInt16(maPages.size());
    1439             :         sal_uInt16 i;
    1440           0 :         for (i=0; i<nAnz; i++) {
    1441           0 :             SdrPage* pPg=maPages[i];
    1442           0 :             pPg->SetPageNum(i);
    1443             :         }
    1444           0 :         bPagNumsDirty=sal_False;
    1445             :     }
    1446           0 : }
    1447             : 
    1448         520 : void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
    1449             : {
    1450         520 :     sal_uInt16 nAnz=GetPageCount();
    1451         520 :     if (nPos>nAnz) nPos=nAnz;
    1452         520 :     maPages.insert(maPages.begin()+nPos,pPage);
    1453         520 :     PageListChanged();
    1454         520 :     pPage->SetInserted(sal_True);
    1455         520 :     pPage->SetPageNum(nPos);
    1456         520 :     pPage->SetModel(this);
    1457         520 :     if (nPos<nAnz) bPagNumsDirty=sal_True;
    1458         520 :     SetChanged();
    1459         520 :     SdrHint aHint(HINT_PAGEORDERCHG);
    1460         520 :     aHint.SetPage(pPage);
    1461         520 :     Broadcast(aHint);
    1462         520 : }
    1463             : 
    1464         332 : void SdrModel::DeletePage(sal_uInt16 nPgNum)
    1465             : {
    1466         332 :     SdrPage* pPg=RemovePage(nPgNum);
    1467         332 :     delete pPg;
    1468         332 : }
    1469             : 
    1470         332 : SdrPage* SdrModel::RemovePage(sal_uInt16 nPgNum)
    1471             : {
    1472         332 :     SdrPage* pPg=maPages[nPgNum];
    1473         332 :     maPages.erase(maPages.begin()+nPgNum);
    1474         332 :     PageListChanged();
    1475         332 :     if (pPg!=NULL) {
    1476         332 :         pPg->SetInserted(sal_False);
    1477             :     }
    1478         332 :     bPagNumsDirty=sal_True;
    1479         332 :     SetChanged();
    1480         332 :     SdrHint aHint(HINT_PAGEORDERCHG);
    1481         332 :     aHint.SetPage(pPg);
    1482         332 :     Broadcast(aHint);
    1483         332 :     return pPg;
    1484             : }
    1485             : 
    1486           1 : void SdrModel::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
    1487             : {
    1488           1 :     SdrPage* pPg=maPages[nPgNum];
    1489           1 :     maPages.erase(maPages.begin()+nPgNum);
    1490           1 :     PageListChanged();
    1491           1 :     if (pPg!=NULL) {
    1492           1 :         pPg->SetInserted(sal_False);
    1493           1 :         InsertPage(pPg,nNewPos);
    1494             :     }
    1495           1 : }
    1496             : 
    1497          34 : void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
    1498             : {
    1499          34 :     sal_uInt16 nAnz=GetMasterPageCount();
    1500          34 :     if (nPos>nAnz) nPos=nAnz;
    1501          34 :     maMaPag.insert(maMaPag.begin()+nPos,pPage);
    1502          34 :     MasterPageListChanged();
    1503          34 :     pPage->SetInserted(sal_True);
    1504          34 :     pPage->SetPageNum(nPos);
    1505          34 :     pPage->SetModel(this);
    1506          34 :     if (nPos<nAnz) {
    1507           0 :         bMPgNumsDirty=sal_True;
    1508             :     }
    1509          34 :     SetChanged();
    1510          34 :     SdrHint aHint(HINT_PAGEORDERCHG);
    1511          34 :     aHint.SetPage(pPage);
    1512          34 :     Broadcast(aHint);
    1513          34 : }
    1514             : 
    1515          28 : void SdrModel::DeleteMasterPage(sal_uInt16 nPgNum)
    1516             : {
    1517          28 :     SdrPage* pPg=RemoveMasterPage(nPgNum);
    1518          28 :     if (pPg!=NULL) delete pPg;
    1519          28 : }
    1520             : 
    1521          28 : SdrPage* SdrModel::RemoveMasterPage(sal_uInt16 nPgNum)
    1522             : {
    1523          28 :     SdrPage* pRetPg=maMaPag[nPgNum];
    1524          28 :     maMaPag.erase(maMaPag.begin()+nPgNum);
    1525          28 :     MasterPageListChanged();
    1526             : 
    1527          28 :     if(pRetPg)
    1528             :     {
    1529             :         // Now delete the links from the normal drawing pages to the deleted master page.
    1530          28 :         sal_uInt16 nPageAnz(GetPageCount());
    1531             : 
    1532          28 :         for(sal_uInt16 np(0); np < nPageAnz; np++)
    1533             :         {
    1534           0 :             GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg);
    1535             :         }
    1536             : 
    1537          28 :         pRetPg->SetInserted(sal_False);
    1538             :     }
    1539             : 
    1540          28 :     bMPgNumsDirty=sal_True;
    1541          28 :     SetChanged();
    1542          28 :     SdrHint aHint(HINT_PAGEORDERCHG);
    1543          28 :     aHint.SetPage(pRetPg);
    1544          28 :     Broadcast(aHint);
    1545          28 :     return pRetPg;
    1546             : }
    1547             : 
    1548           0 : void SdrModel::MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos)
    1549             : {
    1550           0 :     SdrPage* pPg=maMaPag[nPgNum];
    1551           0 :     maMaPag.erase(maMaPag.begin()+nPgNum);
    1552           0 :     MasterPageListChanged();
    1553           0 :     if (pPg!=NULL) {
    1554           0 :         pPg->SetInserted(sal_False);
    1555           0 :         maMaPag.insert(maMaPag.begin()+nNewPos,pPg);
    1556           0 :         MasterPageListChanged();
    1557             :     }
    1558           0 :     bMPgNumsDirty=sal_True;
    1559           0 :     SetChanged();
    1560           0 :     SdrHint aHint(HINT_PAGEORDERCHG);
    1561           0 :     aHint.SetPage(pPg);
    1562           0 :     Broadcast(aHint);
    1563           0 : }
    1564             : 
    1565             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1566             : 
    1567           0 : void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
    1568             :                          sal_uInt16 nDestPos,
    1569             :                          bool bUndo, bool bMoveNoCopy)
    1570             : {
    1571           0 :     if( bUndo && !IsUndoEnabled() )
    1572           0 :         bUndo = false;
    1573             : 
    1574           0 :     if( bUndo )
    1575           0 :         BegUndo(ImpGetResStr(STR_UndoMergeModel));
    1576             : 
    1577           0 :     sal_uInt16 nPageAnz=GetPageCount();
    1578           0 :     sal_uInt16 nMaxPage=nPageAnz;
    1579             : 
    1580           0 :     if (nMaxPage!=0)
    1581           0 :         nMaxPage--;
    1582           0 :     if (nFirstPageNum>nMaxPage)
    1583           0 :         nFirstPageNum=nMaxPage;
    1584           0 :     if (nLastPageNum>nMaxPage)
    1585           0 :         nLastPageNum =nMaxPage;
    1586           0 :     bool bReverse=nLastPageNum<nFirstPageNum;
    1587           0 :     if (nDestPos>nPageAnz)
    1588           0 :         nDestPos=nPageAnz;
    1589             : 
    1590             :     // at first, save the pointers of the affected pages in an array
    1591           0 :     sal_uInt16 nPageNum=nFirstPageNum;
    1592           0 :     sal_uInt16 nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
    1593           0 :     SdrPage** pPagePtrs=new SdrPage*[nCopyAnz];
    1594             :     sal_uInt16 nCopyNum;
    1595           0 :     for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
    1596             :     {
    1597           0 :         pPagePtrs[nCopyNum]=GetPage(nPageNum);
    1598           0 :         if (bReverse)
    1599           0 :             nPageNum--;
    1600             :         else
    1601           0 :             nPageNum++;
    1602             :     }
    1603             : 
    1604             :     // now copy the pages
    1605           0 :     sal_uInt16 nDestNum=nDestPos;
    1606           0 :     for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
    1607             :     {
    1608           0 :         SdrPage* pPg=pPagePtrs[nCopyNum];
    1609           0 :         sal_uInt16 nPageNum2=pPg->GetPageNum();
    1610           0 :         if (!bMoveNoCopy)
    1611             :         {
    1612           0 :             const SdrPage* pPg1=GetPage(nPageNum2);
    1613           0 :             pPg=pPg1->Clone();
    1614           0 :             InsertPage(pPg,nDestNum);
    1615           0 :             if (bUndo)
    1616           0 :                 AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
    1617           0 :             nDestNum++;
    1618             :         }
    1619             :         else
    1620             :         {
    1621             :             // TODO: Move is untested!
    1622           0 :             if (nDestNum>nPageNum2)
    1623           0 :                 nDestNum--;
    1624             : 
    1625           0 :             if(bUndo)
    1626           0 :                 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum));
    1627             : 
    1628           0 :             pPg=RemovePage(nPageNum2);
    1629           0 :             InsertPage(pPg,nDestNum);
    1630           0 :             nDestNum++;
    1631             :         }
    1632             : 
    1633           0 :         if(bReverse)
    1634           0 :             nPageNum2--;
    1635             :         else
    1636           0 :             nPageNum2++;
    1637             :     }
    1638             : 
    1639           0 :     delete[] pPagePtrs;
    1640           0 :     if(bUndo)
    1641           0 :         EndUndo();
    1642           0 : }
    1643             : 
    1644           0 : void SdrModel::Merge(SdrModel& rSourceModel,
    1645             :                      sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
    1646             :                      sal_uInt16 nDestPos,
    1647             :                      bool bMergeMasterPages, bool bAllMasterPages,
    1648             :                      bool bUndo, bool bTreadSourceAsConst)
    1649             : {
    1650           0 :     if (&rSourceModel==this)
    1651             :     {
    1652           0 :         CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst);
    1653           0 :         return;
    1654             :     }
    1655             : 
    1656           0 :     if( bUndo && !IsUndoEnabled() )
    1657           0 :         bUndo = false;
    1658             : 
    1659           0 :     if (bUndo)
    1660           0 :         BegUndo(ImpGetResStr(STR_UndoMergeModel));
    1661             : 
    1662           0 :     sal_uInt16 nSrcPageAnz=rSourceModel.GetPageCount();
    1663           0 :     sal_uInt16 nSrcMasterPageAnz=rSourceModel.GetMasterPageCount();
    1664           0 :     sal_uInt16 nDstMasterPageAnz=GetMasterPageCount();
    1665           0 :     bool bInsPages=(nFirstPageNum<nSrcPageAnz || nLastPageNum<nSrcPageAnz);
    1666           0 :     sal_uInt16 nMaxSrcPage=nSrcPageAnz; if (nMaxSrcPage!=0) nMaxSrcPage--;
    1667           0 :     if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage;
    1668           0 :     if (nLastPageNum>nMaxSrcPage)  nLastPageNum =nMaxSrcPage;
    1669           0 :     bool bReverse=nLastPageNum<nFirstPageNum;
    1670             : 
    1671           0 :     sal_uInt16*   pMasterMap=NULL;
    1672           0 :     bool* pMasterNeed=NULL;
    1673           0 :     sal_uInt16    nMasterNeed=0;
    1674           0 :     if (bMergeMasterPages && nSrcMasterPageAnz!=0) {
    1675             :         // determine which MasterPages from rSrcModel we need
    1676           0 :         pMasterMap=new sal_uInt16[nSrcMasterPageAnz];
    1677           0 :         pMasterNeed=new bool[nSrcMasterPageAnz];
    1678           0 :         memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(sal_uInt16));
    1679           0 :         if (bAllMasterPages) {
    1680           0 :             memset(pMasterNeed, true, nSrcMasterPageAnz * sizeof(bool));
    1681             :         } else {
    1682           0 :             memset(pMasterNeed, false, nSrcMasterPageAnz * sizeof(bool));
    1683           0 :             sal_uInt16 nAnf= bReverse ? nLastPageNum : nFirstPageNum;
    1684           0 :             sal_uInt16 nEnd= bReverse ? nFirstPageNum : nLastPageNum;
    1685           0 :             for (sal_uInt16 i=nAnf; i<=nEnd; i++) {
    1686           0 :                 const SdrPage* pPg=rSourceModel.GetPage(i);
    1687           0 :                 if(pPg->TRG_HasMasterPage())
    1688             :                 {
    1689           0 :                     SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
    1690           0 :                     sal_uInt16 nMPgNum(rMasterPage.GetPageNum());
    1691             : 
    1692           0 :                     if(nMPgNum < nSrcMasterPageAnz)
    1693             :                     {
    1694           0 :                         pMasterNeed[nMPgNum] = true;
    1695             :                     }
    1696             :                 }
    1697             :             }
    1698             :         }
    1699             :         // now determine the Mapping of the MasterPages
    1700           0 :         sal_uInt16 nAktMaPagNum=nDstMasterPageAnz;
    1701           0 :         for (sal_uInt16 i=0; i<nSrcMasterPageAnz; i++) {
    1702           0 :             if (pMasterNeed[i]) {
    1703           0 :                 pMasterMap[i]=nAktMaPagNum;
    1704           0 :                 nAktMaPagNum++;
    1705           0 :                 nMasterNeed++;
    1706             :             }
    1707             :         }
    1708             :     }
    1709             : 
    1710             :     // get the MasterPages
    1711           0 :     if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) {
    1712           0 :         for (sal_uInt16 i=nSrcMasterPageAnz; i>0;) {
    1713           0 :             i--;
    1714           0 :             if (pMasterNeed[i]) {
    1715           0 :                 SdrPage* pPg=NULL;
    1716           0 :                 if (bTreadSourceAsConst) {
    1717           0 :                     const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
    1718           0 :                     pPg=pPg1->Clone();
    1719             :                 } else {
    1720           0 :                     pPg=rSourceModel.RemoveMasterPage(i);
    1721             :                 }
    1722           0 :                 if (pPg!=NULL) {
    1723             :                     // Now append all of them to the end of the DstModel.
    1724             :                     // Don't use InsertMasterPage(), because everything is
    1725             :                     // inconsistent until all are in.
    1726           0 :                     maMaPag.insert(maMaPag.begin()+nDstMasterPageAnz, pPg);
    1727           0 :                     MasterPageListChanged();
    1728           0 :                     pPg->SetInserted(sal_True);
    1729           0 :                     pPg->SetModel(this);
    1730           0 :                     bMPgNumsDirty=sal_True;
    1731           0 :                     if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
    1732             :                 } else {
    1733             :                     OSL_FAIL("SdrModel::Merge(): MasterPage not found in SourceModel.");
    1734             :                 }
    1735             :             }
    1736             :         }
    1737             :     }
    1738             : 
    1739             :     // get the drawing pages
    1740           0 :     if (bInsPages) {
    1741           0 :         sal_uInt16 nSourcePos=nFirstPageNum;
    1742           0 :         sal_uInt16 nMergeCount=sal_uInt16(Abs((long)((long)nFirstPageNum-nLastPageNum))+1);
    1743           0 :         if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
    1744           0 :         while (nMergeCount>0) {
    1745           0 :             SdrPage* pPg=NULL;
    1746           0 :             if (bTreadSourceAsConst) {
    1747           0 :                 const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
    1748           0 :                 pPg=pPg1->Clone();
    1749             :             } else {
    1750           0 :                 pPg=rSourceModel.RemovePage(nSourcePos);
    1751             :             }
    1752           0 :             if (pPg!=NULL) {
    1753           0 :                 InsertPage(pPg,nDestPos);
    1754           0 :                 if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
    1755             : 
    1756           0 :                 if(pPg->TRG_HasMasterPage())
    1757             :                 {
    1758           0 :                     SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
    1759           0 :                     sal_uInt16 nMaPgNum(rMasterPage.GetPageNum());
    1760             : 
    1761           0 :                     if (bMergeMasterPages)
    1762             :                     {
    1763           0 :                         sal_uInt16 nNeuNum(0xFFFF);
    1764             : 
    1765           0 :                         if(pMasterMap)
    1766             :                         {
    1767           0 :                             nNeuNum = pMasterMap[nMaPgNum];
    1768             :                         }
    1769             : 
    1770           0 :                         if(nNeuNum != 0xFFFF)
    1771             :                         {
    1772           0 :                             if(bUndo)
    1773             :                             {
    1774           0 :                                 AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg));
    1775             :                             }
    1776             : 
    1777           0 :                             pPg->TRG_SetMasterPage(*GetMasterPage(nNeuNum));
    1778             :                         }
    1779             :                         DBG_ASSERT(nNeuNum!=0xFFFF,"SdrModel::Merge(): Something is crooked with the mapping of the MasterPages.");
    1780             :                     } else {
    1781           0 :                         if (nMaPgNum>=nDstMasterPageAnz) {
    1782             :                             // This is outside of the original area of the MasterPage of the DstModel.
    1783           0 :                             pPg->TRG_ClearMasterPage();
    1784             :                         }
    1785             :                     }
    1786             :                 }
    1787             : 
    1788             :             } else {
    1789             :                 OSL_FAIL("SdrModel::Merge(): Drawing page not found in SourceModel.");
    1790             :             }
    1791           0 :             nDestPos++;
    1792           0 :             if (bReverse) nSourcePos--;
    1793           0 :             else if (bTreadSourceAsConst) nSourcePos++;
    1794           0 :             nMergeCount--;
    1795             :         }
    1796             :     }
    1797             : 
    1798           0 :     delete [] pMasterMap;
    1799           0 :     delete [] pMasterNeed;
    1800             : 
    1801           0 :     bMPgNumsDirty=sal_True;
    1802           0 :     bPagNumsDirty=sal_True;
    1803             : 
    1804           0 :     SetChanged();
    1805             :     // TODO: Missing: merging and mapping of layers
    1806             :     // at the objects as well as at the MasterPageDescriptors
    1807           0 :     if (bUndo) EndUndo();
    1808             : }
    1809             : 
    1810           0 : void SdrModel::SetStarDrawPreviewMode(sal_Bool bPreview)
    1811             : {
    1812           0 :     if (!bPreview && bStarDrawPreviewMode && GetPageCount())
    1813             :     {
    1814             :         // Resetting is not allowed, because the Model might not be loaded completely
    1815             :         DBG_ASSERT(sal_False,"SdrModel::SetStarDrawPreviewMode(): Resetting not allowed, because Model might not be complete.");
    1816             :     }
    1817             :     else
    1818             :     {
    1819           0 :         bStarDrawPreviewMode = bPreview;
    1820             :     }
    1821           0 : }
    1822             : 
    1823         479 : uno::Reference< uno::XInterface > SdrModel::getUnoModel()
    1824             : {
    1825         479 :     if( !mxUnoModel.is() )
    1826          55 :         mxUnoModel = createUnoModel();
    1827             : 
    1828         479 :     return mxUnoModel;
    1829             : }
    1830             : 
    1831           0 : void SdrModel::setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel )
    1832             : {
    1833           0 :     mxUnoModel = xModel;
    1834           0 : }
    1835             : 
    1836           0 : uno::Reference< uno::XInterface > SdrModel::createUnoModel()
    1837             : {
    1838             :     OSL_FAIL( "SdrModel::createUnoModel() - base implementation should not be called!" );
    1839           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt;
    1840           0 :     return xInt;
    1841             : }
    1842             : 
    1843         164 : void SdrModel::setLock( bool bLock )
    1844             : {
    1845         164 :     if( mbModelLocked != bLock )
    1846             :     {
    1847         147 :         if( sal_False == bLock )
    1848             :         {
    1849          73 :             ImpReformatAllEdgeObjects();
    1850             :         }
    1851         147 :         mbModelLocked = bLock;
    1852             :     }
    1853         164 : }
    1854             : 
    1855             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1856             : 
    1857         460 : void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel )
    1858             : {
    1859         460 :     if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) )
    1860             :     {
    1861         460 :         if( pNewModel == NULL )
    1862           0 :             pNewModel = this;
    1863             : 
    1864         460 :         SfxWhichIter aWhichIter(*pSourceSet);
    1865         460 :         sal_uInt16 nWhich(aWhichIter.FirstWhich());
    1866             :         const SfxPoolItem *pPoolItem;
    1867             : 
    1868       65202 :         while(nWhich)
    1869             :         {
    1870       64282 :             if(SFX_ITEM_SET == pSourceSet->GetItemState(nWhich, sal_False, &pPoolItem))
    1871             :             {
    1872        4505 :                 const SfxPoolItem* pItem = pPoolItem;
    1873             : 
    1874        4505 :                 switch( nWhich )
    1875             :                 {
    1876             :                 case XATTR_FILLBITMAP:
    1877           0 :                     pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pNewModel );
    1878           0 :                     break;
    1879             :                 case XATTR_LINEDASH:
    1880           0 :                     pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pNewModel );
    1881           0 :                     break;
    1882             :                 case XATTR_LINESTART:
    1883           3 :                     pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pNewModel );
    1884           3 :                     break;
    1885             :                 case XATTR_LINEEND:
    1886           7 :                     pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pNewModel );
    1887           7 :                     break;
    1888             :                 case XATTR_FILLGRADIENT:
    1889           1 :                     pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pNewModel );
    1890           1 :                     break;
    1891             :                 case XATTR_FILLFLOATTRANSPARENCE:
    1892             :                     // allow all kinds of XFillFloatTransparenceItem to be set
    1893           0 :                     pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pNewModel );
    1894           0 :                     break;
    1895             :                 case XATTR_FILLHATCH:
    1896           0 :                     pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pNewModel );
    1897           0 :                     break;
    1898             :                 }
    1899             : 
    1900             :                 // set item
    1901        4505 :                 if( pItem )
    1902             :                 {
    1903        4505 :                     pDestSet->Put(*pItem);
    1904             : 
    1905             :                     // delete item if it was a generated one
    1906        4505 :                     if( pItem != pPoolItem)
    1907           2 :                         delete (SfxPoolItem*)pItem;
    1908             :                 }
    1909             :             }
    1910       64282 :             nWhich = aWhichIter.NextWhich();
    1911         460 :         }
    1912             :     }
    1913         460 : }
    1914             : 
    1915             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    1916             : 
    1917         322 : void SdrModel::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
    1918             : {
    1919         322 :     if( mpForbiddenCharactersTable )
    1920           0 :         mpForbiddenCharactersTable->release();
    1921             : 
    1922         322 :     mpForbiddenCharactersTable = xForbiddenChars.get();
    1923             : 
    1924         322 :     if( mpForbiddenCharactersTable )
    1925         284 :         mpForbiddenCharactersTable->acquire();
    1926             : 
    1927         322 :     ImpSetOutlinerDefaults( pDrawOutliner );
    1928         322 :     ImpSetOutlinerDefaults( pHitTestOutliner );
    1929         322 : }
    1930             : 
    1931        6391 : rtl::Reference<SvxForbiddenCharactersTable> SdrModel::GetForbiddenCharsTable() const
    1932             : {
    1933        6391 :     return mpForbiddenCharactersTable;
    1934             : }
    1935             : 
    1936         302 : void SdrModel::SetCharCompressType( sal_uInt16 nType )
    1937             : {
    1938         302 :     if( nType != mnCharCompressType )
    1939             :     {
    1940           1 :         mnCharCompressType = nType;
    1941           1 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1942           1 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1943             :     }
    1944         302 : }
    1945             : 
    1946          40 : void SdrModel::SetKernAsianPunctuation( sal_Bool bEnabled )
    1947             : {
    1948          40 :     if( mbKernAsianPunctuation != (bool) bEnabled )
    1949             :     {
    1950           0 :         mbKernAsianPunctuation = bEnabled;
    1951           0 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1952           0 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1953             :     }
    1954          40 : }
    1955             : 
    1956         262 : void SdrModel::SetAddExtLeading( sal_Bool bEnabled )
    1957             : {
    1958         262 :     if( mbAddExtLeading != (bool) bEnabled )
    1959             :     {
    1960         261 :         mbAddExtLeading = bEnabled;
    1961         261 :         ImpSetOutlinerDefaults( pDrawOutliner );
    1962         261 :         ImpSetOutlinerDefaults( pHitTestOutliner );
    1963             :     }
    1964         262 : }
    1965             : 
    1966           3 : void SdrModel::ReformatAllTextObjects()
    1967             : {
    1968           3 :     ImpReformatAllTextObjects();
    1969           3 : }
    1970             : 
    1971        1134 : SdrOutliner* SdrModel::createOutliner( sal_uInt16 nOutlinerMode )
    1972             : {
    1973        1134 :     if( NULL == mpOutlinerCache )
    1974          72 :         mpOutlinerCache = new SdrOutlinerCache(this);
    1975             : 
    1976        1134 :     return mpOutlinerCache->createOutliner( nOutlinerMode );
    1977             : }
    1978             : 
    1979        1134 : void SdrModel::disposeOutliner( SdrOutliner* pOutliner )
    1980             : {
    1981        1134 :     if( mpOutlinerCache )
    1982             :     {
    1983        1134 :         mpOutlinerCache->disposeOutliner( pOutliner );
    1984             :     }
    1985             :     else
    1986             :     {
    1987           0 :         delete pOutliner;
    1988             :     }
    1989        1134 : }
    1990             : 
    1991           0 : SvxNumType SdrModel::GetPageNumType() const
    1992             : {
    1993           0 :     return SVX_ARABIC;
    1994             : }
    1995             : 
    1996         236 : const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
    1997             : {
    1998             :     DBG_ASSERT(nPgNum < maPages.size(), "SdrModel::GetPage: Access out of range (!)");
    1999         236 :     return maPages[nPgNum];
    2000             : }
    2001             : 
    2002        2948 : SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum)
    2003             : {
    2004             :     DBG_ASSERT(nPgNum < maPages.size(), "SdrModel::GetPage: Access out of range (!)");
    2005        2948 :     return maPages[nPgNum];
    2006             : }
    2007             : 
    2008        2552 : sal_uInt16 SdrModel::GetPageCount() const
    2009             : {
    2010        2552 :     return sal_uInt16(maPages.size());
    2011             : }
    2012             : 
    2013         989 : void SdrModel::PageListChanged()
    2014             : {
    2015         989 : }
    2016             : 
    2017          50 : const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
    2018             : {
    2019             :     DBG_ASSERT(nPgNum < maMaPag.size(), "SdrModel::GetMasterPage: Access out of range (!)");
    2020          50 :     return maMaPag[nPgNum];
    2021             : }
    2022             : 
    2023         187 : SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum)
    2024             : {
    2025             :     DBG_ASSERT(nPgNum < maMaPag.size(), "SdrModel::GetMasterPage: Access out of range (!)");
    2026         187 :     return maMaPag[nPgNum];
    2027             : }
    2028             : 
    2029        1282 : sal_uInt16 SdrModel::GetMasterPageCount() const
    2030             : {
    2031        1282 :     return sal_uInt16(maMaPag.size());
    2032             : }
    2033             : 
    2034         334 : void SdrModel::MasterPageListChanged()
    2035             : {
    2036         334 : }
    2037             : 
    2038          34 : void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager )
    2039             : {
    2040          34 :     mpImpl->mpUndoManager = pUndoManager;
    2041          34 : }
    2042             : 
    2043           0 : SfxUndoManager* SdrModel::GetSdrUndoManager() const
    2044             : {
    2045           0 :     return mpImpl->mpUndoManager;
    2046             : }
    2047             : 
    2048          64 : SdrUndoFactory& SdrModel::GetSdrUndoFactory() const
    2049             : {
    2050          64 :     if( !mpImpl->mpUndoFactory )
    2051          41 :         mpImpl->mpUndoFactory = new SdrUndoFactory;
    2052          64 :     return *mpImpl->mpUndoFactory;
    2053             : }
    2054             : 
    2055          18 : void SdrModel::SetSdrUndoFactory( SdrUndoFactory* pUndoFactory )
    2056             : {
    2057          18 :     if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) )
    2058             :     {
    2059          18 :         delete mpImpl->mpUndoFactory;
    2060          18 :         mpImpl->mpUndoFactory = pUndoFactory;
    2061             :     }
    2062          18 : }
    2063             : 
    2064             : /* added for the reporting engine, but does not work
    2065             :    correctly, so only enable it for this model */
    2066           0 : void SdrModel::SetAllowShapePropertyChangeListener( bool bAllow )
    2067             : {
    2068           0 :     if( mpImpl )
    2069             :     {
    2070           0 :         mpImpl->mbAllowShapePropertyChangeListener = bAllow;
    2071             :     }
    2072           0 : }
    2073             : 
    2074             : namespace
    2075             : {
    2076             :     class theSdrModelUnoTunnelImplementationId : public rtl::Static< UnoTunnelIdInit, theSdrModelUnoTunnelImplementationId > {};
    2077             : }
    2078             : 
    2079          12 : const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImplementationId()
    2080             : {
    2081          12 :     return theSdrModelUnoTunnelImplementationId::get().getSeq();
    2082             : }
    2083             : 
    2084         288 : void SdrModel::SetDrawingLayerPoolDefaults()
    2085             : {
    2086         288 :     const String aNullStr;
    2087         288 :     const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE);
    2088         288 :     const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING);
    2089         288 :     const XHatch aNullHatch(aNullLineCol);
    2090             : 
    2091         288 :     pItemPool->SetPoolDefaultItem( XFillColorItem(aNullStr,aNullFillCol) );
    2092         288 :     pItemPool->SetPoolDefaultItem( XFillHatchItem(pItemPool,aNullHatch) );
    2093         288 :     pItemPool->SetPoolDefaultItem( XLineColorItem(aNullStr,aNullLineCol) );
    2094         288 : }
    2095             : 
    2096             : ////////////////////////////////////////////////////////////////////////////////////////////////////
    2097             : 
    2098     1235412 : TYPEINIT1(SdrHint,SfxHint);
    2099             : 
    2100        3819 : SdrHint::SdrHint(SdrHintKind eNewHint)
    2101             : :   mpPage(0L),
    2102             :     mpObj(0L),
    2103             :     mpObjList(0L),
    2104        3819 :     meHint(eNewHint)
    2105             : {
    2106        3819 : }
    2107             : 
    2108        6552 : SdrHint::SdrHint(const SdrObject& rNewObj)
    2109        6552 : :   mpPage(rNewObj.GetPage()),
    2110             :     mpObj(&rNewObj),
    2111        6552 :     mpObjList(rNewObj.GetObjList()),
    2112       19656 :     meHint(HINT_OBJCHG)
    2113             : {
    2114        6552 :     maRectangle = rNewObj.GetLastBoundRect();
    2115        6552 : }
    2116             : 
    2117        1163 : void SdrHint::SetPage(const SdrPage* pNewPage)
    2118             : {
    2119        1163 :     mpPage = pNewPage;
    2120        1163 : }
    2121             : 
    2122           0 : void SdrHint::SetObject(const SdrObject* pNewObj)
    2123             : {
    2124           0 :     mpObj = pNewObj;
    2125           0 : }
    2126             : 
    2127        4510 : void SdrHint::SetKind(SdrHintKind eNewKind)
    2128             : {
    2129        4510 :     meHint = eNewKind;
    2130        4510 : }
    2131             : 
    2132         597 : const SdrPage* SdrHint::GetPage() const
    2133             : {
    2134         597 :     return mpPage;
    2135             : }
    2136             : 
    2137       14200 : const SdrObject* SdrHint::GetObject() const
    2138             : {
    2139       14200 :     return mpObj;
    2140             : }
    2141             : 
    2142      296270 : SdrHintKind SdrHint::GetKind() const
    2143             : {
    2144      296270 :     return meHint;
    2145             : }
    2146             : 
    2147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10