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

Generated by: LCOV version 1.10