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

Generated by: LCOV version 1.10