LCOV - code coverage report
Current view: top level - sd/source/ui/app - sdmod2.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 89 373 23.9 %
Date: 2014-11-03 Functions: 5 8 62.5 %
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             : #include <editeng/eeitem.hxx>
      21             : #include <editeng/flditem.hxx>
      22             : #include <sfx2/printer.hxx>
      23             : #include <svl/inethist.hxx>
      24             : #include <svl/poolitem.hxx>
      25             : #include <svl/flagitem.hxx>
      26             : #include <unotools/useroptions.hxx>
      27             : #include <sfx2/bindings.hxx>
      28             : #include <vcl/msgbox.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <sfx2/docfile.hxx>
      31             : #include <sfx2/request.hxx>
      32             : 
      33             : #include <editeng/measfld.hxx>
      34             : #include <editeng/editstat.hxx>
      35             : #include <editeng/editeng.hxx>
      36             : 
      37             : #include <svx/dialogs.hrc>
      38             : #include <svx/svdotext.hxx>
      39             : #include <svx/svdpagv.hxx>
      40             : #include <svx/svdopage.hxx>
      41             : 
      42             : #include <sfx2/sfxdlg.hxx>
      43             : 
      44             : #include <svx/sdr/contact/displayinfo.hxx>
      45             : 
      46             : #include "sdmod.hxx"
      47             : #include "app.hrc"
      48             : #include "glob.hrc"
      49             : #include "strings.hrc"
      50             : #include "res_bmp.hrc"
      51             : #include "ViewShell.hxx"
      52             : #include "FrameView.hxx"
      53             : #include "sdattr.hxx"
      54             : #include "optsitem.hxx"
      55             : #include "DrawDocShell.hxx"
      56             : #include "drawdoc.hxx"
      57             : #include "Outliner.hxx"
      58             : #include "sdresid.hxx"
      59             : #include "pres.hxx"
      60             : #include "DrawViewShell.hxx"
      61             : #include "OutlineViewShell.hxx"
      62             : #include "OutlineView.hxx"
      63             : #include "ViewShellBase.hxx"
      64             : #include "sdpage.hxx"
      65             : #include "sdxfer.hxx"
      66             : #include "sdabstdlg.hxx"
      67             : #include <svl/intitem.hxx>
      68             : 
      69             : /** retrieves the page that is currently painted. This will only be the master page
      70             :     if the current drawn view only shows the master page*/
      71        9241 : static SdPage* GetCurrentPage( sd::ViewShell* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
      72             : {
      73        9241 :     if( !pInfo )
      74           0 :         return 0;
      75             : 
      76        9241 :     bMasterView = false;
      77        9241 :     SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
      78        9241 :     SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
      79             : 
      80             :     // special case, someone already set the current page on the EditFieldInfo
      81             :     // This is used from the svx::UnoGraphicsExporter f.e.
      82        9241 :     if( pPage )
      83             :     {
      84           0 :         bMasterView = false;
      85           0 :         return pPage;
      86             :     }
      87             : 
      88             :     // first try to check if we are inside the outline view
      89        9241 :     sd::OutlineView* pSdView = NULL;
      90        9241 :     if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
      91           0 :         pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
      92             : 
      93        9241 :     if (pSdView != NULL && (pOutliner ==  &pSdView->GetOutliner()))
      94             :     {
      95             :         // outline mode
      96           0 :         int nPgNum = 0;
      97           0 :         Outliner& rOutl = pSdView->GetOutliner();
      98           0 :         long nPos = pInfo->GetPara();
      99           0 :         sal_Int32 nParaPos = 0;
     100             : 
     101           0 :         for( Paragraph* pPara = rOutl.GetParagraph( 0 ); pPara && nPos >= 0; pPara = rOutl.GetParagraph( ++nParaPos ), nPos-- )
     102             :         {
     103           0 :             if( rOutl.HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
     104           0 :                 nPgNum++;
     105             :         }
     106             : 
     107           0 :         pPage = pViewSh->GetDoc()->GetSdPage( (sal_uInt16)nPgNum, PK_STANDARD );
     108             :     }
     109             :     else
     110             :     {
     111             :         // draw mode, slide mode and preview. Get the processed page from the outliner
     112        9241 :         if(pOutliner)
     113             :         {
     114        9241 :             pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
     115             :         }
     116             : 
     117             :         // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
     118             :         // is no longer needed. I debugged and checked all usages of PageNumber decompositions
     119             :         // which all use the new possibility of setting the visualized page at the SdrOutliner.
     120             : 
     121             :         // if all else failed, geht the current page from the object that is
     122             :         // currently formated from the document
     123        9241 :         if(!pPage)
     124             :         {
     125        9090 :             const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
     126             : 
     127        9090 :             if( pTextObj )
     128             :             {
     129         968 :                 pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
     130             :             }
     131             :         }
     132             : 
     133        9241 :         if(pPage)
     134             :         {
     135        1119 :             bMasterView = pPage && pPage->IsMasterPage();
     136             :         }
     137             :     }
     138             : 
     139        9241 :     return pPage;
     140             : }
     141             : 
     142             : /**
     143             :  * Link for CalcFieldValue of Outliners
     144             :  */
     145       18602 : IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
     146             : {
     147        9301 :     if (pInfo)
     148             :     {
     149        9301 :         const SvxFieldData* pField = pInfo->GetField().GetField();
     150        9301 :         ::sd::DrawDocShell*     pDocShell = NULL;
     151        9301 :         SdDrawDocument* pDoc = 0;
     152             : 
     153        9301 :         SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
     154        9301 :         if( pSdrOutliner )
     155             :         {
     156        9301 :             const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
     157             : 
     158        9301 :             if( pTextObj )
     159        9299 :                 pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
     160             : 
     161        9301 :             if( pDoc )
     162        9299 :                 pDocShell = pDoc->GetDocSh();
     163             :         }
     164             : 
     165        9301 :         if( !pDocShell )
     166           2 :             pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
     167             : 
     168        9301 :         const SvxDateField* pDateField = 0;
     169        9301 :         const SvxExtTimeField* pExtTimeField = 0;
     170        9301 :         const SvxExtFileField* pExtFileField = 0;
     171        9301 :         const SvxAuthorField* pAuthorField = 0;
     172        9301 :         const SvxURLField* pURLField = 0;
     173             : 
     174        9301 :         if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
     175             :         {
     176          60 :             LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
     177          60 :             pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
     178             :         }
     179        9241 :         else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
     180             :         {
     181           0 :             LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
     182           0 :             pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
     183             :         }
     184        9241 :         else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
     185             :         {
     186           0 :             if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
     187             :             {
     188           0 :                 OUString aName;
     189           0 :                 if( pDocShell->HasName() )
     190           0 :                     aName = pDocShell->GetMedium()->GetName();
     191             :                 else
     192           0 :                     aName = pDocShell->GetName();
     193             : 
     194           0 :                 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
     195             :             }
     196           0 :             pInfo->SetRepresentation( pExtFileField->GetFormatted() );
     197             : 
     198             :         }
     199        9241 :         else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0  )
     200             :         {
     201           0 :             if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
     202             :             {
     203           0 :                 SvtUserOptions aUserOptions;
     204             :                 SvxAuthorField aAuthorField(
     205             :                         aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
     206           0 :                         pAuthorField->GetType(), pAuthorField->GetFormat() );
     207             : 
     208           0 :                 *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
     209             :             }
     210           0 :             pInfo->SetRepresentation( pAuthorField->GetFormatted() );
     211             : 
     212             :         }
     213        9241 :         else if( dynamic_cast< const SvxPageField*  >(pField) )
     214             :         {
     215        2695 :             OUString aRepresentation(" ");
     216             : 
     217        2695 :             ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
     218        2695 :             if(pViewSh == NULL)
     219             :             {
     220        2428 :                 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
     221        2428 :                 if(pBase)
     222           0 :                     pViewSh = pBase->GetMainViewShell().get();
     223             :             }
     224        2695 :             if( !pDoc && pViewSh )
     225           0 :                 pDoc = pViewSh->GetDoc();
     226             : 
     227             :             bool bMasterView;
     228        2695 :             SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
     229             : 
     230        2695 :             if( pPage && pDoc && !bMasterView )
     231             :             {
     232             :                 int nPgNum;
     233             : 
     234           1 :                 if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
     235             :                 {
     236           0 :                     nPgNum = pViewSh->GetPrintedHandoutPageNum();
     237             :                 }
     238             :                 else
     239             :                 {
     240           1 :                     nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
     241             :                 }
     242           1 :                 aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
     243             :             }
     244             :             else
     245        2694 :                 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBER).toString();
     246             : 
     247        2695 :             pInfo->SetRepresentation( aRepresentation );
     248             :         }
     249             : 
     250        6546 :         else if( dynamic_cast< const SvxPageTitleField*  >(pField) )
     251             :         {
     252           0 :             OUString aRepresentation(" ");
     253             : 
     254           0 :             ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
     255           0 :             if(pViewSh == NULL)
     256             :             {
     257           0 :                 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
     258           0 :                 if(pBase)
     259           0 :                     pViewSh = pBase->GetMainViewShell().get();
     260             :             }
     261           0 :             if( !pDoc && pViewSh )
     262           0 :                 pDoc = pViewSh->GetDoc();
     263             : 
     264             :             bool bMasterView;
     265           0 :             SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
     266             : 
     267           0 :             if( pPage && pDoc && !bMasterView )
     268             :             {
     269           0 :                 aRepresentation = pPage->GetName();
     270             :             }
     271             : 
     272           0 :             pInfo->SetRepresentation( aRepresentation );
     273             :         }
     274        6546 :         else if( dynamic_cast< const SvxPagesField*  >(pField) )
     275             :         {
     276           0 :             OUString aRepresentation(" ");
     277             : 
     278           0 :             ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
     279           0 :             if(pViewSh == NULL)
     280             :             {
     281           0 :                 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
     282           0 :                 if(pBase)
     283           0 :                     pViewSh = pBase->GetMainViewShell().get();
     284             :             }
     285           0 :             if( !pDoc && pViewSh )
     286           0 :                 pDoc = pViewSh->GetDoc();
     287             : 
     288             :             bool bMasterView;
     289           0 :             SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
     290             : 
     291           0 :             sal_uInt16 nPageCount = 0;
     292             : 
     293           0 :             if( !bMasterView )
     294             :             {
     295           0 :                 if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
     296             :                 {
     297           0 :                     nPageCount = pViewSh->GetPrintedHandoutPageCount();
     298             :                 }
     299           0 :                 else if( pDoc )
     300             :                 {
     301           0 :                     nPageCount = (sal_uInt16)pDoc->GetActiveSdPageCount();
     302             :                 }
     303             :             }
     304             : 
     305           0 :             if( nPageCount > 0 )
     306           0 :                 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
     307             :             else
     308           0 :                 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNT).toString();
     309             : 
     310           0 :             pInfo->SetRepresentation( aRepresentation );
     311             :         }
     312        6546 :         else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
     313             :         {
     314           0 :             switch ( pURLField->GetFormat() )
     315             :             {
     316             :                 case SVXURLFORMAT_APPDEFAULT: //!!! adjustable at App???
     317             :                 case SVXURLFORMAT_REPR:
     318           0 :                     pInfo->SetRepresentation( pURLField->GetRepresentation() );
     319           0 :                     break;
     320             : 
     321             :                 case SVXURLFORMAT_URL:
     322           0 :                     pInfo->SetRepresentation( pURLField->GetURL() );
     323           0 :                     break;
     324             :             }
     325             : 
     326           0 :             OUString aURL = pURLField->GetURL();
     327             : 
     328           0 :             svtools::ColorConfig aConfig;
     329             :             svtools::ColorConfigEntry eEntry =
     330           0 :                 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
     331           0 :             pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
     332             :         }
     333        6546 :         else if ( dynamic_cast< const SdrMeasureField* >(pField))
     334             :         {
     335           0 :             pInfo->ClearFldColor();
     336             :         }
     337             :         else
     338             :         {
     339        6546 :             OUString aRepresentation;
     340             : 
     341        6546 :             bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
     342        6546 :             bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
     343        6546 :             bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
     344             : 
     345        6546 :             if( bHeaderField || bFooterField || bDateTimeField )
     346             :             {
     347        6546 :                 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
     348        6546 :                 bool bMasterView = false;
     349        6546 :                 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
     350             : 
     351        6546 :                 if( (pPage == NULL) || bMasterView )
     352             :                 {
     353       12792 :                     if( bHeaderField )
     354        1430 :                         aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADER).toString();
     355        4966 :                     else if (bFooterField )
     356        2488 :                         aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTER).toString();
     357        2478 :                     else if (bDateTimeField )
     358        2478 :                         aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIME).toString();
     359             :                 }
     360             :                 else
     361             :                 {
     362         150 :                     const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
     363             : 
     364         150 :                     if( bHeaderField )
     365             :                     {
     366           2 :                         aRepresentation = rSettings.maHeaderText;
     367             :                     }
     368         148 :                     else if( bFooterField )
     369             :                     {
     370          74 :                         aRepresentation = rSettings.maFooterText;
     371             :                     }
     372          74 :                     else if( bDateTimeField )
     373             :                     {
     374          74 :                         if( rSettings.mbDateTimeIsFixed )
     375             :                         {
     376          74 :                             aRepresentation = rSettings.maDateTimeText;
     377             :                         }
     378             :                         else
     379             :                         {
     380           0 :                             Date aDate( Date::SYSTEM );
     381           0 :                             tools::Time aTime( tools::Time::SYSTEM );
     382           0 :                             LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
     383           0 :                             aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
     384             :                         }
     385             :                     }
     386             :                 }
     387             :             }
     388             :             else
     389             :             {
     390             :                 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
     391             :             }
     392             : 
     393        6546 :             if( aRepresentation.isEmpty() )                // TODO: Edit engine doesn't handle empty fields?
     394         150 :                 aRepresentation = " ";
     395        6546 :             pInfo->SetRepresentation( aRepresentation );
     396             :         }
     397             :     }
     398             : 
     399        9301 :     return(0);
     400             : }
     401             : 
     402             : /**
     403             :  * virtual methods for option dialog
     404             :  */
     405           0 : SfxItemSet*  SdModule::CreateItemSet( sal_uInt16 nSlot )
     406             : {
     407           0 :     ::sd::FrameView* pFrameView = NULL;
     408           0 :     ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
     409           0 :     SdDrawDocument* pDoc = NULL;
     410             : 
     411             :     // Here we set the DocType of the option dialog (not document!)
     412           0 :     DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
     413           0 :     if( nSlot == SID_SD_GRAPHIC_OPTIONS )
     414           0 :         eDocType = DOCUMENT_TYPE_DRAW;
     415             : 
     416           0 :     if (pDocSh)
     417             :     {
     418           0 :         pDoc = pDocSh->GetDoc();
     419             : 
     420             :         // If the option dialog is identical to the document type,
     421             :         // we can pass the FrameView too:
     422           0 :         if( pDoc && eDocType == pDoc->GetDocumentType() )
     423           0 :             pFrameView = pDocSh->GetFrameView();
     424             : 
     425           0 :         ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
     426           0 :         if (pViewShell != NULL)
     427           0 :             pViewShell->WriteFrameViewData();
     428             :     }
     429             : 
     430           0 :     SdOptions* pOptions = GetSdOptions(eDocType);
     431             : 
     432             :     // Pool has by default MapUnit Twips (Awgh!)
     433           0 :     SfxItemPool& rPool = GetPool();
     434           0 :     rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
     435             : 
     436             :     SfxItemSet*  pRet = new SfxItemSet( rPool,
     437             :                         SID_ATTR_METRIC, SID_ATTR_METRIC,
     438             :                         SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
     439             : 
     440             :                         ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
     441             :                         ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
     442             :                         ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
     443             : 
     444             :                         ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
     445             : 
     446             :                         ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
     447             : 
     448             :                         ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
     449             : 
     450             :                         SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
     451           0 :                         0 );
     452             : 
     453             :     // TP_OPTIONS_LAYOUT:
     454           0 :     pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
     455             : 
     456           0 :     sal_uInt16 nDefTab = 0;
     457           0 :     if( pFrameView)
     458           0 :         nDefTab = pDoc->GetDefaultTabulator();
     459             :     else
     460           0 :         nDefTab = pOptions->GetDefTab();
     461           0 :     pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
     462             : 
     463           0 :     FieldUnit nMetric = (FieldUnit)0xffff;
     464           0 :     if( pFrameView)
     465           0 :         nMetric = pDoc->GetUIUnit();
     466             :     else
     467           0 :         nMetric = (FieldUnit)pOptions->GetMetric();
     468             : 
     469           0 :     if( nMetric == (FieldUnit)0xffff )
     470           0 :         nMetric = GetFieldUnit();
     471             : 
     472           0 :     pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
     473             : 
     474             :     // TP_OPTIONS_CONTENTS:
     475           0 :     pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
     476             : 
     477             :     // TP_OPTIONS_MISC:
     478           0 :     SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
     479           0 :     if ( pFrameView )
     480             :     {
     481           0 :         aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
     482           0 :         aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
     483           0 :             (sal_uInt16)pDoc->GetPrinterIndependentLayout());
     484             :     }
     485           0 :     pRet->Put( aSdOptionsMiscItem );
     486             : 
     487             :     // TP_OPTIONS_SNAP:
     488           0 :     pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
     489             : 
     490             :     // TP_SCALE:
     491           0 :     sal_uInt32 nW = 10L;
     492           0 :     sal_uInt32 nH = 10L;
     493             :     sal_Int32  nX;
     494             :     sal_Int32  nY;
     495           0 :     if( pDocSh )
     496             :     {
     497           0 :         SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
     498           0 :         Size aSize(pPage->GetSize());
     499           0 :         nW = aSize.Width();
     500           0 :         nH = aSize.Height();
     501             :     }
     502             : 
     503           0 :     if(pFrameView)
     504             :     {
     505           0 :         const Fraction& rFraction =  pDoc->GetUIScale();
     506           0 :         nX=rFraction.GetNumerator();
     507           0 :         nY=rFraction.GetDenominator();
     508             :     }
     509             :     else
     510             :     {
     511             :         // Get options from configuration file
     512           0 :         pOptions->GetScale( nX, nY );
     513             :     }
     514             : 
     515           0 :     pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
     516           0 :     pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
     517           0 :     pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
     518           0 :     pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
     519             : 
     520             :     // TP_OPTIONS_PRINT:
     521           0 :     pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
     522             : 
     523             :     // RID_SVXPAGE_GRID:
     524           0 :     pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
     525             : 
     526           0 :     return pRet;
     527             : }
     528           0 : void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
     529             : {
     530           0 :     const SfxPoolItem*  pItem = NULL;
     531           0 :     bool bNewDefTab = false;
     532           0 :     bool bNewPrintOptions = false;
     533           0 :     bool bMiscOptions = false;
     534             : 
     535           0 :     ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
     536           0 :     SdDrawDocument* pDoc = NULL;
     537             :     // Here we set the DocType of the option dialog (not document!)
     538           0 :     DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
     539           0 :     if( nSlot == SID_SD_GRAPHIC_OPTIONS )
     540           0 :         eDocType = DOCUMENT_TYPE_DRAW;
     541             : 
     542           0 :     ::sd::ViewShell* pViewShell = NULL;
     543             : 
     544           0 :     if (pDocSh)
     545             :     {
     546           0 :         pDoc = pDocSh->GetDoc();
     547             : 
     548           0 :         pViewShell = pDocSh->GetViewShell();
     549           0 :         if (pViewShell != NULL)
     550           0 :             pViewShell->WriteFrameViewData();
     551             :     }
     552           0 :     SdOptions* pOptions = GetSdOptions(eDocType);
     553             :     // Grid
     554           0 :     if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
     555           0 :                             false, (const SfxPoolItem**) &pItem ))
     556             :     {
     557           0 :         const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
     558           0 :         pGridItem->SetOptions( pOptions );
     559             :     }
     560             : 
     561             :     // Layout
     562           0 :     const SdOptionsLayoutItem* pLayoutItem = NULL;
     563           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
     564           0 :                             false, (const SfxPoolItem**) &pLayoutItem ))
     565             :     {
     566           0 :         pLayoutItem->SetOptions( pOptions );
     567             :     }
     568             : 
     569             :     // Metric
     570           0 :     if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_METRIC, false, &pItem ) )
     571             :     {
     572           0 :         if( pDoc && eDocType == pDoc->GetDocumentType() )
     573           0 :             PutItem( *pItem );
     574           0 :         pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
     575             :     }
     576           0 :     sal_uInt16 nDefTab = pOptions->GetDefTab();
     577             :     // Default-Tabulator
     578           0 :     if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, false, &pItem ) )
     579             :     {
     580           0 :         nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
     581           0 :         pOptions->SetDefTab( nDefTab );
     582             : 
     583           0 :         bNewDefTab = true;
     584             :     }
     585             : 
     586             :     // Scale
     587           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, false, &pItem ) )
     588             :     {
     589           0 :         sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
     590           0 :         if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, false, &pItem ) )
     591             :         {
     592           0 :             sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
     593           0 :             pOptions->SetScale( nX, nY );
     594             : 
     595             :             // Apply to document only if doc type match
     596           0 :             if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
     597             :             {
     598           0 :                 pDoc->SetUIScale( Fraction( nX, nY ) );
     599           0 :                 if( pViewShell )
     600           0 :                     pViewShell->SetRuler( pViewShell->HasRuler() );
     601             :             }
     602             :         }
     603             :     }
     604             : 
     605             :     // Contents
     606           0 :     const SdOptionsContentsItem* pContentsItem = NULL;
     607           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
     608           0 :                             false, (const SfxPoolItem**) &pContentsItem ))
     609             :     {
     610           0 :         pContentsItem->SetOptions( pOptions );
     611             :     }
     612             : 
     613             :     // Misc
     614           0 :     const SdOptionsMiscItem* pMiscItem = NULL;
     615           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
     616           0 :                             false, (const SfxPoolItem**) &pMiscItem ))
     617             :     {
     618           0 :         pMiscItem->SetOptions( pOptions );
     619           0 :         bMiscOptions = true;
     620             :     }
     621             : 
     622             :     // Snap
     623           0 :     const SdOptionsSnapItem* pSnapItem = NULL;
     624           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
     625           0 :                             false, (const SfxPoolItem**) &pSnapItem ))
     626             :     {
     627           0 :         pSnapItem->SetOptions( pOptions );
     628             :     }
     629             : 
     630           0 :     SfxItemSet aPrintSet( GetPool(),
     631             :                     SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
     632             :                     SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
     633             :                     ATTR_OPTIONS_PRINT,         ATTR_OPTIONS_PRINT,
     634           0 :                     0 );
     635             : 
     636             :     // Print
     637           0 :     const SdOptionsPrintItem* pPrintItem = NULL;
     638           0 :     if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
     639           0 :                             false, (const SfxPoolItem**) &pPrintItem ))
     640             :     {
     641           0 :         pPrintItem->SetOptions( pOptions );
     642             : 
     643             :         // set PrintOptionsSet
     644           0 :         SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
     645           0 :         SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
     646           0 :         sal_uInt16      nFlags = 0;
     647             : 
     648           0 :         nFlags =  (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
     649           0 :                 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
     650           0 :         aFlagItem.SetValue( nFlags );
     651             : 
     652           0 :         aPrintSet.Put( aPrintItem );
     653           0 :         aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
     654           0 :         aPrintSet.Put( aFlagItem );
     655             : 
     656           0 :         bNewPrintOptions = true;
     657             :     }
     658             : 
     659             :     // Only if also the document type matches...
     660           0 :     if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
     661             :     {
     662           0 :         if( bNewPrintOptions )
     663             :         {
     664           0 :             pDocSh->GetPrinter(true)->SetOptions( aPrintSet );
     665             :         }
     666             : 
     667             :         // set DefTab at Model
     668           0 :         if( bNewDefTab )
     669             :         {
     670           0 :             SdDrawDocument* pDocument = pDocSh->GetDoc();
     671           0 :             pDocument->SetDefaultTabulator( nDefTab );
     672             : 
     673           0 :             ::sd::Outliner* pOutl = pDocument->GetOutliner( false );
     674           0 :             if( pOutl )
     675           0 :                 pOutl->SetDefTab( nDefTab );
     676             : 
     677           0 :             ::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( false );
     678           0 :             if( pInternalOutl )
     679           0 :                 pInternalOutl->SetDefTab( nDefTab );
     680             :         }
     681           0 :         if ( bMiscOptions )
     682             :         {
     683           0 :             pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
     684           0 :             sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
     685             :             sal_uInt32 nCntrl;
     686             : 
     687           0 :             SdDrawDocument* pDocument = pDocSh->GetDoc();
     688           0 :             SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     689           0 :             nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     690           0 :             rOutl.SetControlWord( nCntrl | nSum );
     691           0 :             ::sd::Outliner* pOutl = pDocument->GetOutliner( false );
     692           0 :             if( pOutl )
     693             :             {
     694           0 :                 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     695           0 :                 pOutl->SetControlWord( nCntrl | nSum );
     696             :             }
     697           0 :             pOutl = pDocument->GetInternalOutliner( false );
     698           0 :             if( pOutl )
     699             :             {
     700           0 :                 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     701           0 :                 pOutl->SetControlWord( nCntrl | nSum );
     702             :             }
     703             : 
     704             :             // Set printer independent layout mode.
     705           0 :             if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
     706           0 :                 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
     707             :         }
     708             :     }
     709             : 
     710           0 :     pOptions->StoreConfig();
     711             : 
     712             :     // Only if also the document type matches...
     713           0 :     if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
     714             :     {
     715           0 :         FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
     716           0 :         pDoc->SetUIUnit(eUIUnit);
     717             : 
     718           0 :         if (pViewShell)
     719             :         {
     720             :             // make sure no one is in text edit mode, cause there
     721             :             // are some pointers remembered else (!)
     722           0 :             if(pViewShell->GetView())
     723           0 :                 pViewShell->GetView()->SdrEndTextEdit();
     724             : 
     725           0 :             ::sd::FrameView* pFrame = pViewShell->GetFrameView();
     726           0 :             pFrame->Update(pOptions);
     727           0 :             pViewShell->ReadFrameViewData(pFrame);
     728           0 :             pViewShell->SetUIUnit(eUIUnit);
     729           0 :             pViewShell->SetDefTabHRuler( nDefTab );
     730             :         }
     731             :     }
     732             : 
     733           0 :     if( pViewShell && pViewShell->GetViewFrame() )
     734           0 :         pViewShell->GetViewFrame()->GetBindings().InvalidateAll( true );
     735           0 : }
     736             : 
     737           0 : SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet )
     738             : {
     739           0 :     SfxTabPage* pRet = NULL;
     740           0 :     SfxAllItemSet aSet(*(rSet.GetPool()));
     741           0 :     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     742           0 :     if( pFact )
     743             :     {
     744           0 :         switch(nId)
     745             :         {
     746             :             case SID_SD_TP_CONTENTS:
     747             :             case SID_SI_TP_CONTENTS:
     748           0 :             {   ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
     749           0 :                 if( fnCreatePage )
     750           0 :                     pRet = (*fnCreatePage)( pParent, &rSet );
     751             :             }
     752           0 :             break;
     753             :             case SID_SD_TP_SNAP:
     754             :             case SID_SI_TP_SNAP:
     755           0 :             {   ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
     756           0 :                 if( fnCreatePage )
     757           0 :                     pRet = (*fnCreatePage)( pParent, &rSet );
     758             :             }
     759           0 :             break;
     760             :             case SID_SD_TP_PRINT:
     761             :             case SID_SI_TP_PRINT:
     762             :             {
     763           0 :                 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
     764           0 :                 if( fnCreatePage )
     765             :                 {
     766           0 :                     pRet = (*fnCreatePage)( pParent, &rSet );
     767           0 :                     if(SID_SD_TP_PRINT == nId)
     768           0 :                         aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
     769           0 :                     pRet->PageCreated(aSet);
     770             :                 }
     771             :             }
     772           0 :             break;
     773             :             case SID_SI_TP_MISC:
     774             :             case SID_SD_TP_MISC:
     775             :             {
     776           0 :                 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
     777           0 :                 if( fnCreatePage )
     778             :                 {
     779           0 :                     pRet = (*fnCreatePage)( pParent, &rSet );
     780           0 :                     if(SID_SD_TP_MISC == nId)
     781           0 :                         aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
     782             :                     else
     783           0 :                         aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
     784           0 :                     pRet->PageCreated(aSet);
     785             :                 }
     786             :             }
     787           0 :             break;
     788             :             case RID_SVXPAGE_TEXTANIMATION :
     789             :             {
     790           0 :                 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
     791           0 :                 if ( pSfxFact )
     792             :                 {
     793           0 :                     ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
     794           0 :                     if ( fnCreatePage )
     795           0 :                         pRet = (*fnCreatePage)( pParent, &rSet );
     796             :                 }
     797             :             }
     798           0 :             break;
     799             :         }
     800             :         DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
     801             :     }
     802             : 
     803           0 :     return pRet;
     804         114 : }
     805             : 
     806             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10