LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/core - drawdoc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 209 382 54.7 %
Date: 2013-07-09 Functions: 24 32 75.0 %
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 "PageListWatcher.hxx"
      22             : #include <com/sun/star/text/WritingMode.hpp>
      23             : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      24             : #include <com/sun/star/i18n/ScriptType.hpp>
      25             : #include <editeng/forbiddencharacterstable.hxx>
      26             : 
      27             : #include <svx/svxids.hrc>
      28             : #include <svl/srchitem.hxx>
      29             : #include <editeng/eeitem.hxx>
      30             : #include <editeng/scriptspaceitem.hxx>
      31             : 
      32             : #include <unotools/useroptions.hxx>
      33             : 
      34             : #include <sfx2/printer.hxx>
      35             : #include <sfx2/app.hxx>
      36             : #include <sfx2/linkmgr.hxx>
      37             : #include <svx/dialogs.hrc>
      38             : #include "Outliner.hxx"
      39             : #include "sdmod.hxx"
      40             : #include <editeng/editstat.hxx>
      41             : #include <editeng/fontitem.hxx>
      42             : #include <svl/flagitem.hxx>
      43             : #include <svx/svdoattr.hxx>
      44             : #include <svx/svdotext.hxx>
      45             : #include <editeng/bulletitem.hxx>
      46             : #include <editeng/numitem.hxx>
      47             : #include <svx/svditer.hxx>
      48             : #include <editeng/unolingu.hxx>
      49             : #include <svl/itempool.hxx>
      50             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      51             : #include <svx/xtable.hxx>
      52             : #include <com/sun/star/linguistic2/XHyphenator.hpp>
      53             : #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
      54             : #include <com/sun/star/beans/XPropertySet.hpp>
      55             : #include <editeng/outlobj.hxx>
      56             : #include <unotools/saveopt.hxx>
      57             : #include <comphelper/extract.hxx>
      58             : #include <i18nlangtag/mslangid.hxx>
      59             : #include <i18nlangtag/languagetag.hxx>
      60             : #include <unotools/charclass.hxx>
      61             : #include <comphelper/processfactory.hxx>
      62             : #include <unotools/pathoptions.hxx>
      63             : #include <unotools/lingucfg.hxx>
      64             : #include <unotools/linguprops.hxx>
      65             : 
      66             : #include <editeng/outliner.hxx>
      67             : #include "drawdoc.hxx"
      68             : #include "sdpage.hxx"
      69             : #include "pglink.hxx"
      70             : #include "sdattr.hxx"
      71             : #include "glob.hrc"
      72             : #include "glob.hxx"
      73             : #include "stlpool.hxx"
      74             : #include "sdiocmpt.hxx"
      75             : #include "sdresid.hxx"
      76             : #include "cusshow.hxx"
      77             : #include "customshowlist.hxx"
      78             : #include "../ui/inc/DrawDocShell.hxx"
      79             : #include "../ui/inc/GraphicDocShell.hxx"
      80             : #include "../ui/inc/sdxfer.hxx"
      81             : #include "../ui/inc/ViewShell.hxx"
      82             : #include "../ui/inc/optsitem.hxx"
      83             : #include "../ui/inc/FrameView.hxx"
      84             : 
      85             : #include <tools/tenccvt.hxx>
      86             : 
      87             : using namespace ::sd;
      88             : using namespace ::com::sun::star;
      89             : using namespace ::com::sun::star::uno;
      90             : using namespace ::com::sun::star::lang;
      91             : using namespace ::com::sun::star::linguistic2;
      92             : 
      93             : //////////////////////////////////////////////////////////////////////////////
      94             : 
      95        1005 : TYPEINIT1( SdDrawDocument, FmFormModel );
      96             : 
      97             : SdDrawDocument* SdDrawDocument::pDocLockedInsertingLinks = NULL;
      98             : 
      99             : //////////////////////////////////////////////////////////////////////////////
     100             : 
     101          91 : PresentationSettings::PresentationSettings()
     102             : :   mbAll( true ),
     103             :     mbEndless( false ),
     104             :     mbCustomShow(false),
     105             :     mbManual( false ),
     106             :     mbMouseVisible( false ),
     107             :     mbMouseAsPen( false ),
     108             :     mbLockedPages( false ),
     109             :     mbAlwaysOnTop( false ),
     110             :     mbFullScreen( true ),
     111             :     mbAnimationAllowed( true ),
     112             :     mnPauseTimeout( 10 ),
     113             :     mbShowPauseLogo( false ),
     114          91 :     mbStartWithNavigator(false)
     115             : {
     116          91 : }
     117             : 
     118             : // ---------------------------------------------------------------------------
     119             : 
     120           0 : PresentationSettings::PresentationSettings( const PresentationSettings& r )
     121             : :   maPresPage( r.maPresPage ),
     122             :     mbAll( r.mbAll ),
     123             :     mbEndless( r.mbEndless ),
     124             :     mbCustomShow( r.mbCustomShow ),
     125             :     mbManual( r.mbManual ),
     126             :     mbMouseVisible( r.mbMouseVisible ),
     127             :     mbMouseAsPen( r.mbMouseAsPen ),
     128             :     mbLockedPages( r.mbLockedPages ),
     129             :     mbAlwaysOnTop( r.mbAlwaysOnTop ),
     130             :     mbFullScreen( r.mbFullScreen ),
     131             :     mbAnimationAllowed( r.mbAnimationAllowed ),
     132             :     mnPauseTimeout( r.mnPauseTimeout ),
     133             :     mbShowPauseLogo( r.mbShowPauseLogo ),
     134           0 :     mbStartWithNavigator( r.mbStartWithNavigator )
     135             : {
     136           0 : }
     137             : 
     138             : // ---------------------------------------------------------------------------
     139             : 
     140          91 : SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
     141         182 : : FmFormModel( SvtPathOptions().GetPalettePath(), NULL, pDrDocSh )
     142             : , mpOutliner(NULL)
     143             : , mpInternalOutliner(NULL)
     144             : , mpWorkStartupTimer(NULL)
     145             : , mpOnlineSpellingTimer(NULL)
     146             : , mpOnlineSpellingList(NULL)
     147             : , mpOnlineSearchItem(NULL)
     148             : , mpCustomShowList(NULL)
     149             : , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh))
     150             : , mpCreatingTransferable( NULL )
     151             : , mbHasOnlineSpellErrors(sal_False)
     152             : , mbInitialOnlineSpellingEnabled(sal_True)
     153             : , mbNewOrLoadCompleted(sal_False)
     154             : , mbStartWithPresentation( false )
     155             : , meLanguage( LANGUAGE_SYSTEM )
     156             : , meLanguageCJK( LANGUAGE_SYSTEM )
     157             : , meLanguageCTL( LANGUAGE_SYSTEM )
     158             : , mePageNumType(SVX_ARABIC)
     159             : , mbAllocDocSh(sal_False)
     160             : , meDocType(eType)
     161             : , mpCharClass(NULL)
     162             : , mpLocale(NULL)
     163             : , mpDrawPageListWatcher(0)
     164             : , mpMasterPageListWatcher(0)
     165         182 : , mbUseEmbedFonts(false)
     166             : {
     167         273 :     mpDrawPageListWatcher = ::std::auto_ptr<ImpDrawPageListWatcher>(
     168         182 :         new ImpDrawPageListWatcher(*this));
     169         273 :     mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
     170         182 :         new ImpMasterPageListWatcher(*this));
     171             : 
     172          91 :     SetObjectShell(pDrDocSh);       // for VCDrawModel
     173             : 
     174          91 :     if (mpDocSh)
     175             :     {
     176          89 :         SetSwapGraphics(sal_True);
     177             :     }
     178             : 
     179             :     // Set measuring unit (of the application) and scale (of SdMod)
     180             :     sal_Int32 nX, nY;
     181          91 :     SdOptions* pOptions = SD_MOD()->GetSdOptions(meDocType);
     182          91 :     pOptions->GetScale( nX, nY );
     183             : 
     184             :     // Allow UI scale only for draw documents.
     185          91 :     if( eType == DOCUMENT_TYPE_DRAW )
     186          52 :         SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( nX, nY ) );  // user-defined
     187             :     else
     188          39 :         SetUIUnit( (FieldUnit)pOptions->GetMetric(), Fraction( 1, 1 ) );    // default
     189             : 
     190          91 :     SetScaleUnit(MAP_100TH_MM);
     191          91 :     SetScaleFraction(Fraction(1, 1));
     192          91 :     SetDefaultFontHeight(847);     // 24p
     193             : 
     194          91 :     pItemPool->SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
     195          91 :     pItemPool->FreezeIdRanges();
     196          91 :     SetTextDefaults();
     197             : 
     198             :     // DrawingEngine has to know where it is...
     199          91 :     FmFormModel::SetStyleSheetPool( new SdStyleSheetPool( GetPool(), this ) );
     200             : 
     201             :     // Set StyleSheetPool for DrawOutliner, so text objects can be read correctly.
     202             :     // The link to the StyleRequest handler of the document is set later, in
     203             :     // NewOrLoadCompleted, because only then do all the templates exist.
     204          91 :     SdrOutliner& rOutliner = GetDrawOutliner();
     205          91 :     rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     206          91 :     SetCalcFieldValueHdl( &rOutliner );
     207             : 
     208             :     // set linguistic options
     209             :     {
     210          91 :         const SvtLinguConfig    aLinguConfig;
     211         182 :         SvtLinguOptions         aOptions;
     212          91 :         aLinguConfig.GetOptions( aOptions );
     213             : 
     214             :         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
     215          91 :             ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE );
     216             :         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
     217          91 :             ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK );
     218             :         SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
     219          91 :             ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL );
     220             : 
     221         182 :         mbOnlineSpell = aOptions.bIsSpellAuto;
     222             :     }
     223             : 
     224          91 :     LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
     225          91 :     LanguageTag aLanguageTag( eRealLanguage);
     226          91 :     mpLocale = new ::com::sun::star::lang::Locale( aLanguageTag.getLocale());
     227          91 :     mpCharClass = new CharClass( aLanguageTag );
     228             : 
     229             :     // If the current application language is a language that uses right-to-left text...
     230          91 :     LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
     231          91 :     if( MsLangId::isRightToLeft( eRealCTLLanguage ) )
     232             :     {
     233             :         // ... then we have to set this as a default
     234           0 :         SetDefaultWritingMode( ::com::sun::star::text::WritingMode_RL_TB );
     235             :     }
     236             : 
     237             :     // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text
     238          91 :     if (MsLangId::isKorean(eRealCTLLanguage) || (LANGUAGE_JAPANESE == eRealCTLLanguage))
     239             :     {
     240           0 :         GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) );
     241             :     }
     242             : 
     243             :     // Set DefTab and SpellOptions for the SD module
     244          91 :     sal_uInt16 nDefTab = pOptions->GetDefTab();
     245          91 :     SetDefaultTabulator( nDefTab );
     246             : 
     247             :     try
     248             :     {
     249          91 :         Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
     250          91 :         if ( xSpellChecker.is() )
     251          91 :             rOutliner.SetSpeller( xSpellChecker );
     252             : 
     253         182 :         Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
     254          91 :         if( xHyphenator.is() )
     255          91 :             rOutliner.SetHyphenator( xHyphenator );
     256             : 
     257         182 :         SetForbiddenCharsTable( new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() ) );
     258             :     }
     259           0 :     catch(...)
     260             :     {
     261             :         OSL_FAIL("Can't get SpellChecker");
     262             :     }
     263             : 
     264          91 :     rOutliner.SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
     265             : 
     266          91 :     if (mpDocSh)
     267             :     {
     268          89 :         SetLinkManager( new sfx2::LinkManager(mpDocSh) );
     269             :     }
     270             : 
     271          91 :     sal_uLong nCntrl = rOutliner.GetControlWord();
     272          91 :     nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
     273          91 :     nCntrl |= EE_CNTRL_URLSFXEXECUTE;
     274             : 
     275          91 :     if (mbOnlineSpell)
     276          91 :         nCntrl |= EE_CNTRL_ONLINESPELLING;
     277             :     else
     278           0 :         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     279             : 
     280          91 :     nCntrl &= ~ EE_CNTRL_ULSPACESUMMATION;
     281          91 :     if ( meDocType != DOCUMENT_TYPE_IMPRESS )
     282          52 :         SetSummationOfParagraphs( sal_False );
     283             :     else
     284             :     {
     285          39 :         SetSummationOfParagraphs( pOptions->IsSummationOfParagraphs() );
     286          39 :         if ( pOptions->IsSummationOfParagraphs() )
     287           0 :             nCntrl |= EE_CNTRL_ULSPACESUMMATION;
     288             :     }
     289          91 :     rOutliner.SetControlWord(nCntrl);
     290             : 
     291             :     // Initialize the printer independent layout mode
     292          91 :     SetPrinterIndependentLayout (pOptions->GetPrinterIndependentLayout());
     293             : 
     294             :     // Set the StyleSheetPool for HitTestOutliner.
     295             :     // The link to the StyleRequest handler of the document is set later, in
     296             :     // NewOrLoadCompleted, because only then do all the templates exist.
     297         182 :     SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() );
     298          91 :     pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() );
     299             : 
     300          91 :     SetCalcFieldValueHdl( pHitTestOutliner );
     301             : 
     302             :     try
     303             :     {
     304          91 :         Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
     305          91 :         if ( xSpellChecker.is() )
     306          91 :             pHitTestOutliner->SetSpeller( xSpellChecker );
     307             : 
     308         182 :         Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
     309          91 :         if( xHyphenator.is() )
     310         182 :             pHitTestOutliner->SetHyphenator( xHyphenator );
     311             :     }
     312           0 :     catch(...)
     313             :     {
     314             :         OSL_FAIL("Can't get SpellChecker");
     315             :     }
     316             : 
     317          91 :     pHitTestOutliner->SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
     318             : 
     319          91 :     sal_uLong nCntrl2 = pHitTestOutliner->GetControlWord();
     320          91 :     nCntrl2 |= EE_CNTRL_ALLOWBIGOBJS;
     321          91 :     nCntrl2 |= EE_CNTRL_URLSFXEXECUTE;
     322          91 :     nCntrl2 &= ~EE_CNTRL_ONLINESPELLING;
     323             : 
     324          91 :     nCntrl2 &= ~ EE_CNTRL_ULSPACESUMMATION;
     325          91 :     if ( pOptions->IsSummationOfParagraphs() )
     326           0 :         nCntrl2 |= EE_CNTRL_ULSPACESUMMATION;
     327             : 
     328          91 :     pHitTestOutliner->SetControlWord( nCntrl2 );
     329             : 
     330             :     /** Create layers
     331             :       *
     332             :       * We create the following default layers on all pages and master pages:
     333             :       *
     334             :       * STR_LAYOUT    : default layer for drawing objects
     335             :       *
     336             :       * STR_BCKGRND   : background of the master page
     337             :       *                 (currently unused within normal pages)
     338             :       *
     339             :       * STR_BCKGRNDOBJ: objects on the background of master pages
     340             :       *                 (currently unused within normal pages)
     341             :       *
     342             :       * STR_CONTROLS  : default layer for controls
     343             :       */
     344             : 
     345             :     {
     346          91 :         String aControlLayerName( SdResId(STR_LAYER_CONTROLS) );
     347             : 
     348          91 :         SdrLayerAdmin& rLayerAdmin = GetLayerAdmin();
     349          91 :         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_LAYOUT)) );
     350          91 :         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRND)) );
     351          91 :         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_BCKGRNDOBJ)) );
     352          91 :         rLayerAdmin.NewLayer( aControlLayerName );
     353          91 :         rLayerAdmin.NewLayer( String(SdResId(STR_LAYER_MEASURELINES)) );
     354             : 
     355          91 :         rLayerAdmin.SetControlLayerName(aControlLayerName);
     356          91 :     }
     357             : 
     358             : 
     359          91 : }
     360             : 
     361             : 
     362             : // Destructor
     363             : 
     364         264 : SdDrawDocument::~SdDrawDocument()
     365             : {
     366          88 :     Broadcast(SdrHint(HINT_MODELCLEARED));
     367             : 
     368          88 :     if (mpWorkStartupTimer)
     369             :     {
     370           0 :         if ( mpWorkStartupTimer->IsActive() )
     371           0 :             mpWorkStartupTimer->Stop();
     372             : 
     373           0 :         delete mpWorkStartupTimer;
     374           0 :         mpWorkStartupTimer = NULL;
     375             :     }
     376             : 
     377          88 :     StopOnlineSpelling();
     378          88 :     delete mpOnlineSearchItem;
     379          88 :     mpOnlineSearchItem = NULL;
     380             : 
     381          88 :     CloseBookmarkDoc();
     382          88 :     SetAllocDocSh(sal_False);
     383             : 
     384          88 :     ClearModel(sal_True);
     385             : 
     386          88 :     if (pLinkManager)
     387             :     {
     388             :         // Release BaseLinks
     389          86 :         if ( !pLinkManager->GetLinks().empty() )
     390             :         {
     391           0 :             pLinkManager->Remove( 0, pLinkManager->GetLinks().size() );
     392             :         }
     393             : 
     394          86 :         delete pLinkManager;
     395          86 :         pLinkManager = NULL;
     396             :     }
     397             : 
     398          88 :     std::vector<sd::FrameView*>::iterator pIter;
     399          97 :     for ( pIter = maFrameViewList.begin(); pIter != maFrameViewList.end(); ++pIter )
     400           9 :         delete *pIter;
     401             : 
     402          88 :     if (mpCustomShowList)
     403             :     {
     404           6 :         for (sal_uLong j = 0; j < mpCustomShowList->size(); j++)
     405             :         {
     406             :             // If necessary, delete CustomShows
     407           3 :             SdCustomShow* pCustomShow = (*mpCustomShowList)[j];
     408           3 :             delete pCustomShow;
     409             :         }
     410             : 
     411           3 :         delete mpCustomShowList;
     412           3 :         mpCustomShowList = NULL;
     413             :     }
     414             : 
     415          88 :     delete mpOutliner;
     416          88 :     mpOutliner = NULL;
     417             : 
     418          88 :     delete mpInternalOutliner;
     419          88 :     mpInternalOutliner = NULL;
     420             : 
     421          88 :     delete mpLocale;
     422          88 :     mpLocale = NULL;
     423             : 
     424          88 :     delete mpCharClass;
     425          88 :     mpCharClass = NULL;
     426         176 : }
     427             : 
     428             : 
     429             : // This method creates a new document (SdDrawDocument) and returns a pointer to
     430             : // said document. The drawing engine uses this method to put the document (or
     431             : // parts of it) into the clipboard/DragServer.
     432             : 
     433           0 : SdrModel* SdDrawDocument::AllocModel() const
     434             : {
     435           0 :     SdDrawDocument* pNewModel = NULL;
     436             : 
     437           0 :     if( mpCreatingTransferable )
     438             :     {
     439             :         // Document is created for drag & drop/clipboard. To be able to
     440             :         // do this, the document has to know a DocShell (SvPersist).
     441           0 :         SfxObjectShell*   pObj = NULL;
     442           0 :         ::sd::DrawDocShell*     pNewDocSh = NULL;
     443             : 
     444           0 :         if( meDocType == DOCUMENT_TYPE_IMPRESS )
     445             :             mpCreatingTransferable->SetDocShell( new ::sd::DrawDocShell(
     446           0 :                 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
     447             :         else
     448             :             mpCreatingTransferable->SetDocShell( new ::sd::GraphicDocShell(
     449           0 :                 SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType ) );
     450             : 
     451           0 :         pNewDocSh = static_cast< ::sd::DrawDocShell*>( pObj = mpCreatingTransferable->GetDocShell() );
     452           0 :         pNewDocSh->DoInitNew( NULL );
     453           0 :         pNewModel = pNewDocSh->GetDoc();
     454             : 
     455             :         // Only necessary for clipboard –
     456             :         // for drag & drop this is handled by DragServer
     457           0 :         SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) GetStyleSheetPool();
     458           0 :         SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) pNewModel->GetStyleSheetPool();
     459             : 
     460           0 :         pNewStylePool->CopyGraphicSheets(*pOldStylePool);
     461           0 :         pNewStylePool->CopyCellSheets(*pOldStylePool);
     462           0 :         pNewStylePool->CopyTableStyles(*pOldStylePool);
     463             : 
     464             : 
     465           0 :         for (sal_uInt16 i = 0; i < GetMasterSdPageCount(PK_STANDARD); i++)
     466             :         {
     467             :             // Move with all of the master page's layouts
     468           0 :             String aOldLayoutName(((SdDrawDocument*) this)->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName());
     469           0 :             aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
     470           0 :             SdStyleSheetVector aCreatedSheets;
     471           0 :             pNewStylePool->CopyLayoutSheets(aOldLayoutName, *pOldStylePool, aCreatedSheets );
     472           0 :         }
     473             : 
     474           0 :         pNewModel->NewOrLoadCompleted( DOC_LOADED );  // loaded from source document
     475             :     }
     476           0 :     else if( mbAllocDocSh )
     477             :     {
     478             :         // Create a DocShell which is then returned with GetAllocedDocSh()
     479           0 :         SdDrawDocument* pDoc = (SdDrawDocument*) this;
     480           0 :         pDoc->SetAllocDocSh(sal_False);
     481           0 :         pDoc->mxAllocedDocShRef = new ::sd::DrawDocShell(
     482           0 :             SFX_CREATE_MODE_EMBEDDED, sal_True, meDocType);
     483           0 :         pDoc->mxAllocedDocShRef->DoInitNew(NULL);
     484           0 :         pNewModel = pDoc->mxAllocedDocShRef->GetDoc();
     485             :     }
     486             :     else
     487             :     {
     488           0 :         pNewModel = new SdDrawDocument(meDocType, NULL);
     489             :     }
     490             : 
     491           0 :     return pNewModel;
     492             : }
     493             : 
     494             : // This method creates a new page (SdPage) and returns a pointer to said page.
     495             : // The drawing engine uses this method to create pages (whose types it does
     496             : // not know, as they are _derivatives_ of SdrPage) when loading.
     497             : 
     498         598 : SdrPage* SdDrawDocument::AllocPage(bool bMasterPage)
     499             : {
     500         598 :     return new SdPage(*this, NULL, bMasterPage);
     501             : }
     502             : 
     503             : // When the model has changed
     504       34532 : void SdDrawDocument::SetChanged(sal_Bool bFlag)
     505             : {
     506       34532 :     if (mpDocSh)
     507             :     {
     508       34512 :         if (mbNewOrLoadCompleted && mpDocSh->IsEnableSetModified())
     509             :         {
     510             :             // Pass on to base class
     511        4762 :             FmFormModel::SetChanged(bFlag);
     512             : 
     513             :             // Forward to ObjectShell
     514        4762 :             mpDocSh->SetModified(bFlag);
     515             :         }
     516             :     }
     517             :     else
     518             :     {
     519             :         // Pass on to base class
     520          20 :         FmFormModel::SetChanged(bFlag);
     521             :     }
     522       34532 : }
     523             : 
     524             : // The model changed, don't call anything else
     525        4934 : void SdDrawDocument::NbcSetChanged(sal_Bool bFlag)
     526             : {
     527             :     // forward to baseclass
     528        4934 :     FmFormModel::SetChanged(bFlag);
     529        4934 : }
     530             : 
     531             : // NewOrLoadCompleted is called when the document is loaded, or when it is clear
     532             : // it won't load any more.
     533             : 
     534          84 : void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode)
     535             : {
     536          84 :     if (eMode == NEW_DOC)
     537             :     {
     538             :         // New document:
     539             :         // create slideshow and default templates,
     540             :         // create pool for virtual controls
     541          84 :         CreateLayoutTemplates();
     542          84 :         CreateDefaultCellStyles();
     543             : 
     544          84 :         static_cast< SdStyleSheetPool* >( mxStyleSheetPool.get() )->CreatePseudosIfNecessary();
     545             :     }
     546           0 :     else if (eMode == DOC_LOADED)
     547             :     {
     548             :             // Document has finished loading
     549             : 
     550           0 :         CheckMasterPages();
     551             : 
     552           0 :         if ( GetMasterSdPageCount(PK_STANDARD) > 1 )
     553           0 :             RemoveUnnecessaryMasterPages( NULL, sal_True, sal_False );
     554             : 
     555           0 :         for ( sal_uInt16 i = 0; i < GetPageCount(); i++ )
     556             :         {
     557             :             // Check for correct layout names
     558           0 :             SdPage* pPage = (SdPage*) GetPage( i );
     559             : 
     560           0 :             if(pPage->TRG_HasMasterPage())
     561             :             {
     562           0 :                 SdPage& rMaster = (SdPage&)pPage->TRG_GetMasterPage();
     563             : 
     564           0 :                 if(rMaster.GetLayoutName() != pPage->GetLayoutName())
     565             :                 {
     566           0 :                     pPage->SetLayoutName(rMaster.GetLayoutName());
     567             :                 }
     568             :             }
     569             :         }
     570             : 
     571           0 :         for ( sal_uInt16 nPage = 0; nPage < GetMasterPageCount(); nPage++)
     572             :         {
     573             :             // LayoutName and PageName must be the same
     574           0 :             SdPage* pPage = (SdPage*) GetMasterPage( nPage );
     575             : 
     576           0 :             String aName( pPage->GetLayoutName() );
     577           0 :             aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ) );
     578             : 
     579           0 :             if( aName != pPage->GetName() )
     580           0 :                 pPage->SetName( aName );
     581           0 :         }
     582             : 
     583             :         // Create names of the default layers in the user's language
     584           0 :         RestoreLayerNames();
     585             : 
     586             :         // Create names of the styles in the user's language
     587           0 :         static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->UpdateStdNames();
     588             : 
     589             :         // Create any missing styles – e. g. formerly, there was no Subtitle style
     590           0 :         static_cast<SdStyleSheetPool*>(mxStyleSheetPool.get())->CreatePseudosIfNecessary();
     591             :     }
     592             : 
     593             :     // Set default style of Drawing Engine
     594          84 :     String aName( SdResId(STR_STANDARD_STYLESHEET_NAME));
     595          84 :     SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_GRAPHICS)));
     596             : 
     597             :     // #i119287# Set default StyleSheet for SdrGrafObj and SdrOle2Obj
     598          84 :     SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(static_cast<SfxStyleSheet*>(mxStyleSheetPool->Find(String( SdResId(STR_POOLSHEET_OBJNOLINENOFILL)), SD_STYLE_FAMILY_GRAPHICS)));
     599             : 
     600             :     // Initialize DrawOutliner and DocumentOutliner, but don't initialize the
     601             :     // global outliner, as it is not document specific like StyleSheetPool and
     602             :     // StyleRequestHandler are.
     603          84 :     ::Outliner& rDrawOutliner = GetDrawOutliner();
     604          84 :     rDrawOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     605          84 :     sal_uLong nCntrl = rDrawOutliner.GetControlWord();
     606          84 :     if (mbOnlineSpell)
     607          84 :         nCntrl |= EE_CNTRL_ONLINESPELLING;
     608             :     else
     609           0 :         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     610          84 :     rDrawOutliner.SetControlWord(nCntrl);
     611             : 
     612             :     // Initialize HitTestOutliner and DocumentOutliner, but don't initialize the
     613             :     // global outliner, as it is not document specific like StyleSheetPool and
     614             :     // StyleRequestHandler are.
     615          84 :     pHitTestOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     616             : 
     617          84 :     if(mpOutliner)
     618             :     {
     619           0 :         mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     620             :     }
     621          84 :     if(mpInternalOutliner)
     622             :     {
     623           1 :         mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     624             :     }
     625             : 
     626          84 :     if ( eMode == DOC_LOADED )
     627             :     {
     628             :         // Make presentation objects listeners of the appropriate styles
     629           0 :         SdStyleSheetPool* pSPool = (SdStyleSheetPool*) GetStyleSheetPool();
     630             :         sal_uInt16 nPage, nPageCount;
     631             : 
     632             :         // create missing layout style sheets for broken documents
     633             :         //         that where created with the 5.2
     634           0 :         nPageCount = GetMasterSdPageCount( PK_STANDARD );
     635           0 :         for (nPage = 0; nPage < nPageCount; nPage++)
     636             :         {
     637           0 :             SdPage* pPage = GetMasterSdPage(nPage, PK_STANDARD);
     638           0 :             pSPool->CreateLayoutStyleSheets( pPage->GetName(), sal_True );
     639             :         }
     640             : 
     641             :         // Default and notes pages:
     642           0 :         for (nPage = 0; nPage < GetPageCount(); nPage++)
     643             :         {
     644           0 :             SdPage* pPage = (SdPage*)GetPage(nPage);
     645           0 :             NewOrLoadCompleted( pPage, pSPool );
     646             :         }
     647             : 
     648             :         // Master pages:
     649           0 :         for (nPage = 0; nPage < GetMasterPageCount(); nPage++)
     650             :         {
     651           0 :             SdPage* pPage = (SdPage*)GetMasterPage(nPage);
     652             : 
     653           0 :             NewOrLoadCompleted( pPage, pSPool );
     654             :         }
     655             :     }
     656             : 
     657          84 :     mbNewOrLoadCompleted = sal_True;
     658             : 
     659             :     // Update all linked pages
     660          84 :     SdPage* pPage = NULL;
     661          84 :     sal_uInt16 nMaxSdPages = GetSdPageCount(PK_STANDARD);
     662             : 
     663          85 :     for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++)
     664             :     {
     665           1 :         pPage = (SdPage*) GetSdPage(nSdPage, PK_STANDARD);
     666             : 
     667           1 :         if (pPage && pPage->GetFileName().Len() && pPage->GetBookmarkName().Len())
     668             :         {
     669           0 :             pPage->SetModel(this);
     670             :         }
     671             :     }
     672             : 
     673          84 :     UpdateAllLinks();
     674             : 
     675          84 :     SetChanged( sal_False );
     676          84 : }
     677             : 
     678             : /** updates all links, only links in this document should by resolved */
     679          91 : void SdDrawDocument::UpdateAllLinks()
     680             : {
     681          91 :     if ( !pDocLockedInsertingLinks && pLinkManager && !pLinkManager->GetLinks().empty() )
     682             :     {
     683           0 :         pDocLockedInsertingLinks = this; // lock inserting links. only links in this document should by resolved
     684             : 
     685           0 :         pLinkManager->UpdateAllLinks();  // query box: update all links?
     686             : 
     687           0 :         if( pDocLockedInsertingLinks == this )
     688           0 :             pDocLockedInsertingLinks = NULL;  // unlock inserting links
     689             :     }
     690          91 : }
     691             : 
     692             : /** this loops over the presentation objectes of a page and repairs some new settings
     693             :     from old binary files and resets all default strings for empty presentation objects.
     694             : */
     695           0 : void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool )
     696             : {
     697           0 :     sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() );
     698           0 :     if(!rPresentationShapes.isEmpty())
     699             :     {
     700             :         // Create lists of title and outline styles
     701           0 :         String aName = pPage->GetLayoutName();
     702           0 :         aName.Erase( aName.SearchAscii( SD_LT_SEPARATOR ));
     703             : 
     704           0 :         std::vector<SfxStyleSheetBase*> aOutlineList;
     705           0 :         pSPool->CreateOutlineSheetList(aName,aOutlineList);
     706             : 
     707           0 :         SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)pSPool->GetTitleSheet(aName);
     708             : 
     709           0 :         SdrObject* pObj = 0;
     710           0 :         rPresentationShapes.seekShape(0);
     711             : 
     712             :         // Now look for title and outline text objects, then make those objects
     713             :         // listeners.
     714           0 :         while( (pObj = rPresentationShapes.getNextShape()) )
     715             :         {
     716           0 :             if (pObj->GetObjInventor() == SdrInventor)
     717             :             {
     718           0 :                 OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
     719           0 :                 sal_uInt16 nId = pObj->GetObjIdentifier();
     720             : 
     721           0 :                 if (nId == OBJ_TITLETEXT)
     722             :                 {
     723           0 :                     if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
     724           0 :                         pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
     725             : 
     726             :                     // sal_True: don't delete "hard" attributes when doing this.
     727           0 :                     if (pTitleSheet)
     728           0 :                         pObj->SetStyleSheet(pTitleSheet, sal_True);
     729             :                 }
     730           0 :                 else if (nId == OBJ_OUTLINETEXT)
     731             :                 {
     732           0 :                     if( pOPO && pOPO->GetOutlinerMode() == OUTLINERMODE_DONTKNOW )
     733           0 :                         pOPO->SetOutlinerMode( OUTLINERMODE_OUTLINEOBJECT );
     734             : 
     735           0 :                     std::vector<SfxStyleSheetBase*>::iterator iter;
     736           0 :                     for (iter = aOutlineList.begin(); iter != aOutlineList.end(); ++iter)
     737             :                     {
     738           0 :                         SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(*iter);
     739             : 
     740           0 :                         if (pSheet)
     741             :                         {
     742           0 :                             pObj->StartListening(*pSheet);
     743             : 
     744           0 :                             if( iter == aOutlineList.begin())
     745             :                                 // text frame listens to stylesheet of layer 1
     746           0 :                                 pObj->NbcSetStyleSheet(pSheet, sal_True);
     747             :                         }
     748             :                     }
     749             :                 }
     750             : 
     751           0 :                 if (pObj->ISA(SdrTextObj) && pObj->IsEmptyPresObj() && pPage)
     752             :                 {
     753           0 :                     PresObjKind ePresObjKind = pPage->GetPresObjKind(pObj);
     754           0 :                     String aString( pPage->GetPresObjText(ePresObjKind) );
     755             : 
     756           0 :                     if (aString.Len())
     757             :                     {
     758           0 :                         sd::Outliner* pInternalOutl = GetInternalOutliner(sal_True);
     759           0 :                         pPage->SetObjText( (SdrTextObj*) pObj, pInternalOutl, ePresObjKind, aString );
     760           0 :                         pObj->NbcSetStyleSheet( pPage->GetStyleSheetForPresObj( ePresObjKind ), sal_True );
     761           0 :                         pInternalOutl->Clear();
     762           0 :                     }
     763             :                 }
     764             :             }
     765           0 :         }
     766             :     }
     767           0 : }
     768             : 
     769             : // Local outliner that is used for outline mode. In this outliner, OutlinerViews
     770             : // may be inserted.
     771         117 : ::sd::Outliner* SdDrawDocument::GetOutliner(sal_Bool bCreateOutliner)
     772             : {
     773         117 :     if (!mpOutliner && bCreateOutliner)
     774             :     {
     775           0 :         mpOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
     776             : 
     777           0 :         if (mpDocSh)
     778           0 :             mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
     779             : 
     780           0 :         mpOutliner->SetDefTab( nDefaultTabulator );
     781           0 :         mpOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     782             :     }
     783             : 
     784         117 :     return(mpOutliner);
     785             : }
     786             : 
     787             : 
     788             : // Internal outliner that is used to create text objects. We don't insert any
     789             : // OutlinerViews into this outliner!
     790        1107 : ::sd::Outliner* SdDrawDocument::GetInternalOutliner(sal_Bool bCreateOutliner)
     791             : {
     792        1107 :     if ( !mpInternalOutliner && bCreateOutliner )
     793             :     {
     794          82 :         mpInternalOutliner = new ::sd::Outliner( this, OUTLINERMODE_TEXTOBJECT );
     795             : 
     796             :         // This outliner is only used to create special text objects. As no
     797             :         // information about portions is saved in this outliner, the update mode
     798             :         // can/should always remain sal_False.
     799          82 :         mpInternalOutliner->SetUpdateMode( sal_False );
     800          82 :         mpInternalOutliner->EnableUndo( sal_False );
     801             : 
     802          82 :         if (mpDocSh)
     803          82 :             mpInternalOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
     804             : 
     805          82 :         mpInternalOutliner->SetDefTab( nDefaultTabulator );
     806          82 :         mpInternalOutliner->SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool());
     807             :     }
     808             : 
     809             :     DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->GetUpdateMode() == sal_False ) , "InternalOutliner: UpdateMode = sal_True !" );
     810             :     DBG_ASSERT( !mpInternalOutliner || ( mpInternalOutliner->IsUndoEnabled() == sal_False ), "InternalOutliner: Undo = sal_True !" );
     811             : 
     812             :     // If you add stuff here, always clear it out.
     813             :     // Advantages:
     814             :     // a) no unnecessary Clear calls
     815             :     // b) no wasted memory
     816             :     DBG_ASSERT( !mpInternalOutliner || ( ( mpInternalOutliner->GetParagraphCount() == 1 ) && ( mpInternalOutliner->GetText( mpInternalOutliner->GetParagraph( 0 ) ).Len() == 0 ) ), "InternalOutliner: not empty!" );
     817             : 
     818        1107 :     return mpInternalOutliner;
     819             : }
     820             : 
     821             : // OnlineSpelling on/off
     822           0 : void SdDrawDocument::SetOnlineSpell(sal_Bool bIn)
     823             : {
     824           0 :     mbOnlineSpell = bIn;
     825           0 :     sal_uLong nCntrl = 0;
     826             : 
     827           0 :     if(mpOutliner)
     828             :     {
     829           0 :         nCntrl = mpOutliner->GetControlWord();
     830             : 
     831           0 :         if(mbOnlineSpell)
     832           0 :             nCntrl |= EE_CNTRL_ONLINESPELLING;
     833             :         else
     834           0 :             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     835             : 
     836           0 :         mpOutliner->SetControlWord(nCntrl);
     837             :     }
     838             : 
     839           0 :     if (mpInternalOutliner)
     840             :     {
     841           0 :         nCntrl = mpInternalOutliner->GetControlWord();
     842             : 
     843           0 :         if (mbOnlineSpell)
     844           0 :             nCntrl |= EE_CNTRL_ONLINESPELLING;
     845             :         else
     846           0 :             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     847             : 
     848           0 :         mpInternalOutliner->SetControlWord(nCntrl);
     849             :     }
     850             : 
     851           0 :     ::Outliner& rOutliner = GetDrawOutliner();
     852             : 
     853           0 :     nCntrl = rOutliner.GetControlWord();
     854             : 
     855           0 :     if (mbOnlineSpell)
     856           0 :         nCntrl |= EE_CNTRL_ONLINESPELLING;
     857             :     else
     858           0 :         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
     859             : 
     860           0 :     rOutliner.SetControlWord(nCntrl);
     861             : 
     862           0 :     if (mbOnlineSpell)
     863             :     {
     864           0 :         StartOnlineSpelling();
     865             :     }
     866             :     else
     867             :     {
     868           0 :         StopOnlineSpelling();
     869             :     }
     870           0 : }
     871             : 
     872             : 
     873             : // OnlineSpelling: highlighting on/off
     874          82 : uno::Reference< uno::XInterface > SdDrawDocument::createUnoModel()
     875             : {
     876          82 :     uno::Reference< uno::XInterface > xModel;
     877             : 
     878             :     try
     879             :     {
     880          82 :         if ( mpDocSh )
     881          82 :             xModel = mpDocSh->GetModel();
     882             :     }
     883           0 :     catch( uno::RuntimeException& )
     884             :     {
     885             :     }
     886             : 
     887          82 :     return xModel;
     888             : }
     889             : 
     890        1129 : SvxNumType SdDrawDocument::GetPageNumType() const
     891             : {
     892        1129 :     return mePageNumType;
     893             : }
     894             : 
     895             : 
     896             : 
     897             : 
     898          98 : void SdDrawDocument::SetPrinterIndependentLayout (sal_Int32 nMode)
     899             : {
     900          98 :     switch (nMode)
     901             :     {
     902             :         case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
     903             :         case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
     904             :             // Just store supported modes and inform the doc shell
     905          98 :             mnPrinterIndependentLayout = nMode;
     906             : 
     907             :             // Since it is possible that a SdDrawDocument is constructed without a
     908             :             // SdDrawDocShell the pointer member mpDocSh needs to be tested
     909             :             // before the call is executed. This is e. g. used for copy/paste.
     910          98 :             if(mpDocSh)
     911             :             {
     912          96 :                 mpDocSh->UpdateRefDevice ();
     913             :             }
     914             : 
     915          98 :             break;
     916             : 
     917             :         default:
     918             :             // Ignore unknown values
     919           0 :             break;
     920             :     }
     921          98 : }
     922             : 
     923         209 : sal_Int32 SdDrawDocument::GetPrinterIndependentLayout (void)
     924             : {
     925         209 :     return mnPrinterIndependentLayout;
     926             : }
     927             : 
     928           4 : bool SdDrawDocument::IsStartWithPresentation() const
     929             : {
     930           4 :     return mbStartWithPresentation;
     931             : }
     932             : 
     933           0 : void SdDrawDocument::SetStartWithPresentation( bool bStartWithPresentation )
     934             : {
     935           0 :     mbStartWithPresentation = bStartWithPresentation;
     936           0 : }
     937             : 
     938         757 : void SdDrawDocument::PageListChanged()
     939             : {
     940         757 :     mpDrawPageListWatcher->Invalidate();
     941         757 : }
     942             : 
     943         599 : void SdDrawDocument::MasterPageListChanged()
     944             : {
     945         599 :     mpMasterPageListWatcher->Invalidate();
     946         599 : }
     947             : 
     948         182 : void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner)
     949             : {
     950         182 :     pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
     951         182 : }
     952             : 
     953           0 : sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const OUString& rAuthor )
     954             : {
     955             :     // force current user to have first color
     956           0 :     if( maAnnotationAuthors.empty() )
     957             :     {
     958           0 :         SvtUserOptions aUserOptions;
     959           0 :         maAnnotationAuthors.push_back( aUserOptions.GetFullName() );
     960             :     }
     961             : 
     962           0 :     sal_uInt16 idx = 0;
     963           0 :     const std::vector< OUString >::const_iterator aEnd( maAnnotationAuthors.end());
     964           0 :     for( std::vector< OUString >::const_iterator iter( maAnnotationAuthors.begin() ); iter != aEnd; ++iter )
     965             :     {
     966           0 :         if( (*iter) == rAuthor )
     967             :         {
     968           0 :             break;
     969             :         }
     970           0 :         idx++;
     971             :     }
     972             : 
     973           0 :     if( idx == maAnnotationAuthors.size() )
     974             :     {
     975           0 :         maAnnotationAuthors.push_back( rAuthor );
     976             :     }
     977             : 
     978           0 :     return idx;
     979          33 : }
     980             : 
     981             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10