LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/unoidl - UnoDocumentSettings.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 311 594 52.4 %
Date: 2012-12-27 Functions: 18 34 52.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <vector>
      22             : #include <com/sun/star/embed/XStorage.hpp>
      23             : #include <com/sun/star/embed/ElementModes.hpp>
      24             : #include <com/sun/star/embed/XTransactedObject.hpp>
      25             : #include <com/sun/star/lang/XServiceInfo.hpp>
      26             : #include <com/sun/star/beans/XPropertySet.hpp>
      27             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      28             : #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
      29             : #include <cppuhelper/implbase3.hxx>
      30             : #include <comphelper/propertysethelper.hxx>
      31             : #include <comphelper/propertysetinfo.hxx>
      32             : #include <tools/urlobj.hxx>
      33             : #include <svx/xtable.hxx>
      34             : #include <osl/diagnose.h>
      35             : #include <osl/mutex.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : 
      38             : #include "drawdoc.hxx"
      39             : #include "DrawDocShell.hxx"
      40             : #include "unomodel.hxx"
      41             : 
      42             : #include "optsitem.hxx"
      43             : #include <sfx2/printer.hxx>
      44             : #include "sdattr.hxx"
      45             : #include "../inc/ViewShell.hxx"
      46             : #include "../inc/FrameView.hxx"
      47             : #include "Outliner.hxx"
      48             : #include <xmloff/settingsstore.hxx>
      49             : #include <editeng/editstat.hxx>
      50             : #include <svx/unoapi.hxx>
      51             : 
      52             : #define MAP_LEN(x) x, sizeof(x)-1
      53             : 
      54             : using namespace ::comphelper;
      55             : using namespace ::osl;
      56             : using ::rtl::OUString;
      57             : using namespace ::cppu;
      58             : using namespace ::com::sun::star;
      59             : using namespace ::com::sun::star::uno;
      60             : using namespace ::com::sun::star::util;
      61             : using namespace ::com::sun::star::container;
      62             : using namespace ::com::sun::star::drawing;
      63             : using namespace ::com::sun::star::lang;
      64             : using namespace ::com::sun::star::document;
      65             : using namespace ::com::sun::star::frame;
      66             : using namespace ::com::sun::star::beans;
      67             : using namespace ::com::sun::star::i18n;
      68             : 
      69             : namespace sd
      70             : {
      71             :     class DocumentSettings : public WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >,
      72             :                              public comphelper::PropertySetHelper,
      73             :                              public DocumentSettingsSerializer
      74             :     {
      75             :     public:
      76             :         DocumentSettings( SdXImpressDocument* pModel );
      77             :         virtual ~DocumentSettings() throw();
      78             : 
      79             :         // XInterface
      80             :         virtual Any SAL_CALL queryInterface( const Type& aType ) throw (RuntimeException);
      81             :         virtual void SAL_CALL acquire(  ) throw ();
      82             :         virtual void SAL_CALL release(  ) throw ();
      83             : 
      84             :         // XPropertySet
      85             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
      86             :         virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      87             :         virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      88             :         virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      89             :         virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      90             :         virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      91             :         virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      92             : 
      93             :         // XMultiPropertySet
      94             :         virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      95             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException);
      96             :         virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
      97             :         virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
      98             :         virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
      99             : 
     100             :         // XServiceInfo
     101             :         virtual OUString SAL_CALL getImplementationName(  ) throw(RuntimeException);
     102             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
     103             :         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(RuntimeException);
     104             : 
     105             :         // DocumentSettingsSerializer cf. xmloff
     106             :         virtual uno::Sequence<beans::PropertyValue>
     107             :                 filterStreamsFromStorage(const uno::Reference< embed::XStorage > &xStorage,
     108             :                                          const uno::Sequence<beans::PropertyValue>& aConfigProps );
     109             :         virtual uno::Sequence<beans::PropertyValue>
     110             :                 filterStreamsToStorage(const uno::Reference< embed::XStorage > &xStorage,
     111             :                                        const uno::Sequence<beans::PropertyValue>& aConfigProps );
     112             : 
     113             :     protected:
     114             :         virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
     115             :         virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
     116             : 
     117             :     private:
     118             :         bool LoadList( XPropertyListType t, const rtl::OUString &rPath,
     119             :                        const uno::Reference< embed::XStorage > &xStorage );
     120             :         void AssignURL( XPropertyListType t, const Any* pValue, bool *pOk, bool *pChanged );
     121             :         void ExtractURL( XPropertyListType t, Any* pValue );
     122             :         Reference< XModel >     mxModel;
     123             :         SdXImpressDocument*     mpModel;
     124             :     };
     125             : 
     126           4 :     Reference< XInterface > SAL_CALL DocumentSettings_createInstance( SdXImpressDocument* pModel )
     127             :         throw( Exception )
     128             :     {
     129             :         DBG_ASSERT( pModel, "I need a model for the DocumentSettings!" );
     130           4 :         return (XWeak*)new DocumentSettings( pModel );
     131             :     }
     132             : 
     133             : enum SdDocumentSettingsPropertyHandles
     134             : {
     135             :     HANDLE_PRINTDRAWING, HANDLE_PRINTNOTES, HANDLE_PRINTHANDOUT, HANDLE_PRINTOUTLINE, HANDLE_MEASUREUNIT, HANDLE_SCALE_NUM,
     136             :     HANDLE_SCALE_DOM, HANDLE_TABSTOP, HANDLE_PRINTPAGENAME, HANDLE_PRINTDATE, HANDLE_PRINTTIME,
     137             :     HANDLE_PRINTHIDENPAGES, HANDLE_PRINTFITPAGE, HANDLE_PRINTTILEPAGE, HANDLE_PRINTBOOKLET, HANDLE_PRINTBOOKLETFRONT,
     138             :     HANDLE_PRINTBOOKLETBACK, HANDLE_PRINTQUALITY, HANDLE_COLORTABLEURL, HANDLE_DASHTABLEURL, HANDLE_LINEENDTABLEURL, HANDLE_HATCHTABLEURL,
     139             :     HANDLE_GRADIENTTABLEURL, HANDLE_BITMAPTABLEURL, HANDLE_FORBIDDENCHARS, HANDLE_APPLYUSERDATA, HANDLE_PAGENUMFMT,
     140             :     HANDLE_PRINTERNAME, HANDLE_PRINTERJOB, HANDLE_PARAGRAPHSUMMATION, HANDLE_CHARCOMPRESS, HANDLE_ASIANPUNCT, HANDLE_UPDATEFROMTEMPLATE,
     141             :     HANDLE_PRINTER_INDEPENDENT_LAYOUT
     142             :     // #i33095#
     143             :     ,HANDLE_LOAD_READONLY, HANDLE_SAVE_VERSION
     144             :     ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL
     145             : };
     146             : 
     147             : #define MID_PRINTER 1
     148             : 
     149           4 :     PropertySetInfo* createSettingsInfoImpl( sal_Bool bIsDraw )
     150             :     {
     151             :         static PropertyMapEntry aImpressSettingsInfoMap[] =
     152             :         {
     153           2 :             { MAP_LEN("IsPrintDrawing"),        HANDLE_PRINTDRAWING,        &::getBooleanCppuType(),                0,  MID_PRINTER },
     154           2 :             { MAP_LEN("IsPrintNotes"),          HANDLE_PRINTNOTES,          &::getBooleanCppuType(),                0,  MID_PRINTER },
     155           2 :             { MAP_LEN("IsPrintHandout"),        HANDLE_PRINTHANDOUT,        &::getBooleanCppuType(),                0,  MID_PRINTER },
     156           2 :             { MAP_LEN("IsPrintOutline"),        HANDLE_PRINTOUTLINE,        &::getBooleanCppuType(),                0,  MID_PRINTER },
     157           2 :             { MAP_LEN("SlidesPerHandout"),      HANDLE_SLIDESPERHANDOUT,    &::getCppuType((const sal_Int16*)0),    0,  MID_PRINTER },
     158           2 :             { MAP_LEN("HandoutsHorizontal"),    HANDLE_HANDOUTHORIZONTAL,   &::getBooleanCppuType(),                0,  MID_PRINTER },
     159             :             { NULL, 0, 0, NULL, 0, 0 }
     160          16 :         };
     161             : 
     162             :         static PropertyMapEntry aDrawSettingsInfoMap[] =
     163             :         {
     164           2 :             { MAP_LEN("MeasureUnit"),           HANDLE_MEASUREUNIT,         &::getCppuType((const sal_Int16*)0),    0,  0 },
     165           2 :             { MAP_LEN("ScaleNumerator"),        HANDLE_SCALE_NUM,           &::getCppuType((const sal_Int32*)0),    0,  0 },
     166           2 :             { MAP_LEN("ScaleDenominator"),      HANDLE_SCALE_DOM,           &::getCppuType((const sal_Int32*)0),    0,  0 },
     167             :             { NULL, 0, 0, NULL, 0, 0 }
     168          10 :         };
     169             : 
     170             :         static PropertyMapEntry aCommonSettingsInfoMap[] =
     171             :         {
     172           2 :             { MAP_LEN("DefaultTabStop"),        HANDLE_TABSTOP,             &::getCppuType((const sal_Int32*)0),    0,  0 },
     173           2 :             { MAP_LEN("PrinterName"),           HANDLE_PRINTERNAME,         &::getCppuType((const OUString*)0),     0,  0 },
     174           2 :             { MAP_LEN("PrinterSetup"),          HANDLE_PRINTERJOB,          &::getCppuType((const uno::Sequence < sal_Int8 > *)0),  0, MID_PRINTER },
     175             : 
     176           2 :             { MAP_LEN("IsPrintPageName"),       HANDLE_PRINTPAGENAME,       &::getBooleanCppuType(),                0,  MID_PRINTER },
     177           2 :             { MAP_LEN("IsPrintDate"),           HANDLE_PRINTDATE,           &::getBooleanCppuType(),                0,  MID_PRINTER },
     178           2 :             { MAP_LEN("IsPrintTime"),           HANDLE_PRINTTIME,           &::getBooleanCppuType(),                0,  MID_PRINTER },
     179           2 :             { MAP_LEN("IsPrintHiddenPages"),    HANDLE_PRINTHIDENPAGES,     &::getBooleanCppuType(),                0,  MID_PRINTER },
     180           2 :             { MAP_LEN("IsPrintFitPage"),        HANDLE_PRINTFITPAGE,        &::getBooleanCppuType(),                0,  MID_PRINTER },
     181           2 :             { MAP_LEN("IsPrintTilePage"),       HANDLE_PRINTTILEPAGE,       &::getBooleanCppuType(),                0,  MID_PRINTER },
     182           2 :             { MAP_LEN("IsPrintBooklet"),        HANDLE_PRINTBOOKLET,        &::getBooleanCppuType(),                0,  MID_PRINTER },
     183           2 :             { MAP_LEN("IsPrintBookletFront"),   HANDLE_PRINTBOOKLETFRONT,   &::getBooleanCppuType(),                0,  MID_PRINTER },
     184           2 :             { MAP_LEN("IsPrintBookletBack"),    HANDLE_PRINTBOOKLETBACK,    &::getBooleanCppuType(),                0,  MID_PRINTER },
     185           2 :             { MAP_LEN("PrintQuality"),          HANDLE_PRINTQUALITY,        &::getCppuType((const sal_Int32*)0),    0,  MID_PRINTER },
     186           2 :             { MAP_LEN("ColorTableURL"),         HANDLE_COLORTABLEURL,       &::getCppuType((const OUString*)0),     0,  0 },
     187           2 :             { MAP_LEN("DashTableURL"),          HANDLE_DASHTABLEURL,        &::getCppuType((const OUString*)0),     0,  0 },
     188           2 :             { MAP_LEN("LineEndTableURL"),       HANDLE_LINEENDTABLEURL,     &::getCppuType((const OUString*)0),     0,  0 },
     189           2 :             { MAP_LEN("HatchTableURL"),         HANDLE_HATCHTABLEURL,       &::getCppuType((const OUString*)0),     0,  0 },
     190           2 :             { MAP_LEN("GradientTableURL"),      HANDLE_GRADIENTTABLEURL,    &::getCppuType((const OUString*)0),     0,  0 },
     191           2 :             { MAP_LEN("BitmapTableURL"),        HANDLE_BITMAPTABLEURL,      &::getCppuType((const OUString*)0),     0,  0 },
     192             : 
     193           2 :             { MAP_LEN("ForbiddenCharacters"),   HANDLE_FORBIDDENCHARS,      &::getCppuType((const Reference< XForbiddenCharacters >*)0),    0, 0 },
     194           2 :             { MAP_LEN("ApplyUserData"),         HANDLE_APPLYUSERDATA,       &::getBooleanCppuType(),                0,  0 },
     195             : 
     196           2 :             { MAP_LEN("PageNumberFormat"),      HANDLE_PAGENUMFMT,          &::getCppuType((const sal_Int32*)0),    0,  0 },
     197           2 :             { MAP_LEN("ParagraphSummation"),    HANDLE_PARAGRAPHSUMMATION,  &::getBooleanCppuType(),                0,  0 },
     198           2 :             { MAP_LEN("CharacterCompressionType"),HANDLE_CHARCOMPRESS,      &::getCppuType((sal_Int16*)0),          0,  0 },
     199           2 :             { MAP_LEN("IsKernAsianPunctuation"),HANDLE_ASIANPUNCT,          &::getBooleanCppuType(),                0,  0 },
     200           2 :             { MAP_LEN("UpdateFromTemplate"),    HANDLE_UPDATEFROMTEMPLATE,  &::getBooleanCppuType(),                0,  0 },
     201           2 :             { MAP_LEN("PrinterIndependentLayout"),HANDLE_PRINTER_INDEPENDENT_LAYOUT,&::getCppuType((const sal_Int16*)0), 0,  0 },
     202             :             // --> #i33095#
     203           2 :             { MAP_LEN("LoadReadonly"),          HANDLE_LOAD_READONLY,       &::getBooleanCppuType(),                0,  0 },
     204           2 :             { MAP_LEN("SaveVersionOnClose"),    HANDLE_SAVE_VERSION,        &::getBooleanCppuType(),                0,  0 },
     205             :             { NULL, 0, 0, NULL, 0, 0 }
     206          62 :         };
     207             : 
     208           4 :         PropertySetInfo* pInfo = new PropertySetInfo( aCommonSettingsInfoMap );
     209           4 :         pInfo->add( bIsDraw ? aDrawSettingsInfoMap : aImpressSettingsInfoMap );
     210             : 
     211           4 :         return pInfo;
     212             :     }
     213             : }
     214             : 
     215             : using namespace ::sd;
     216             : 
     217           4 : DocumentSettings::DocumentSettings( SdXImpressDocument* pModel )
     218           4 : :   PropertySetHelper( createSettingsInfoImpl( !pModel->IsImpressDocument() ) ),
     219             :     mxModel( pModel ),
     220           8 :     mpModel( pModel )
     221             : {
     222           4 : }
     223             : 
     224           8 : DocumentSettings::~DocumentSettings() throw()
     225             : {
     226           8 : }
     227             : 
     228          12 : bool DocumentSettings::LoadList( XPropertyListType t, const rtl::OUString &rInPath,
     229             :                                  const uno::Reference< embed::XStorage > &xStorage )
     230             : {
     231          12 :     SdDrawDocument* pDoc = mpModel->GetDoc();
     232             : 
     233          12 :     sal_Int32 nSlash = rInPath.lastIndexOf('/');
     234          12 :     rtl::OUString aPath, aName;
     235          12 :     if (nSlash < -1)
     236           0 :         aName = rInPath;
     237             :     else {
     238          12 :         aName = rInPath.copy( nSlash + 1 );
     239          12 :         aPath = rInPath.copy( 0, nSlash );
     240             :     }
     241             : 
     242             :     XPropertyListRef pList = XPropertyList::CreatePropertyList(
     243          12 :         t, aPath, (XOutdevItemPool*)&pDoc->GetPool() );
     244          12 :     pList->SetName( aName );
     245             : 
     246          12 :     if( pList->LoadFrom( xStorage, rInPath ) )
     247             :     {
     248           0 :         pDoc->SetPropertyList( pList );
     249           0 :         return true;
     250             :     }
     251             : 
     252          12 :     return false;
     253             : }
     254             : 
     255           0 : void DocumentSettings::AssignURL( XPropertyListType t, const Any* pValue,
     256             :                                   bool *pOk, bool *pChanged )
     257             : {
     258           0 :     OUString aURL;
     259           0 :     if( !(bool)( *pValue >>= aURL ) )
     260           0 :         return;
     261             : 
     262           0 :     if( LoadList( t, aURL, uno::Reference< embed::XStorage >() ) )
     263           0 :         *pOk = *pChanged = true;
     264             : }
     265             : 
     266             : static struct {
     267             :     const char *pName;
     268             :     XPropertyListType t;
     269             : } aURLPropertyNames[] = {
     270             :     { "ColorTableURL", XCOLOR_LIST },
     271             :     { "DashTableURL", XDASH_LIST },
     272             :     { "LineEndTableURL", XLINE_END_LIST },
     273             :     { "HatchTableURL", XHATCH_LIST },
     274             :     { "GradientTableURL", XGRADIENT_LIST },
     275             :     { "BitmapTableURL", XBITMAP_LIST }
     276             : };
     277             : 
     278          67 : static XPropertyListType getTypeOfName( const rtl::OUString &aName )
     279             : {
     280         427 :     for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
     281         372 :         if( aName.equalsAscii( aURLPropertyNames[i].pName ) )
     282          12 :             return aURLPropertyNames[i].t;
     283             :     }
     284          55 :     return (XPropertyListType) -1;
     285             : }
     286             : 
     287           0 : static rtl::OUString getNameOfType( XPropertyListType t )
     288             : {
     289           0 :     for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
     290           0 :         if( t == aURLPropertyNames[i].t )
     291             :             return rtl::OUString( aURLPropertyNames[i].pName,
     292           0 :                                   strlen( aURLPropertyNames[i].pName ) - 3,
     293           0 :                                   RTL_TEXTENCODING_UTF8 );
     294             :     }
     295           0 :     return rtl::OUString();
     296             : }
     297             : 
     298             : uno::Sequence<beans::PropertyValue>
     299           2 :         DocumentSettings::filterStreamsFromStorage(
     300             :                 const uno::Reference< embed::XStorage > &xStorage,
     301             :                 const uno::Sequence<beans::PropertyValue>& aConfigProps )
     302             : {
     303           2 :     uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
     304           2 :     int nRet = 0;
     305          69 :     for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
     306             :     {
     307          67 :         XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
     308          67 :         if (t < 0)
     309          55 :             aRet[nRet++] = aConfigProps[i];
     310             :         else
     311             :         {
     312          12 :             rtl::OUString aURL;
     313          12 :             aConfigProps[i].Value >>= aURL;
     314          12 :             LoadList( t, aURL, xStorage );
     315             :         }
     316             :     }
     317           2 :     aRet.realloc( nRet );
     318           2 :     return aRet;
     319             : }
     320             : 
     321             : uno::Sequence<beans::PropertyValue>
     322           0 :         DocumentSettings::filterStreamsToStorage(
     323             :                 const uno::Reference< embed::XStorage > &xStorage,
     324             :                 const uno::Sequence<beans::PropertyValue>& aConfigProps )
     325             : {
     326           0 :     uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
     327             : 
     328           0 :     bool bHasEmbed = false;
     329           0 :     SdDrawDocument* pDoc = mpModel->GetDoc();
     330           0 :     for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
     331             :     {
     332           0 :         XPropertyListRef pList = pDoc->GetPropertyList( (XPropertyListType) i );
     333           0 :         if( ( bHasEmbed = pList.is() && pList->IsEmbedInDocument() ) )
     334             :             break;
     335           0 :     }
     336           0 :     if( !bHasEmbed )
     337           0 :         return aConfigProps;
     338             : 
     339             :     try {
     340             :         // create Settings/ sub storage.
     341           0 :         uno::Reference< embed::XStorage > xSubStorage;
     342           0 :         xSubStorage = xStorage->openStorageElement( "Settings" ,
     343           0 :             embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
     344           0 :         if( !xSubStorage.is() )
     345           0 :             return aRet;
     346             : 
     347             :         // now populate it
     348           0 :         for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
     349             :         {
     350           0 :             XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
     351           0 :             aRet[i] = aConfigProps[i];
     352           0 :             if (t >= 0) {
     353           0 :                 XPropertyListRef pList = pDoc->GetPropertyList( t );
     354           0 :                 if( !pList.is() || !pList->IsEmbedInDocument() )
     355           0 :                     continue; // no change ...
     356             :                 else
     357             :                 {
     358             :                     // Such specific path construction is grim.
     359           0 :                     rtl::OUString aValue;
     360           0 :                     aRet[i].Value >>= aValue;
     361             : 
     362           0 :                     rtl::OUStringBuffer aName( getNameOfType( t ) );
     363           0 :                     rtl::OUString aResult;
     364           0 :                     if( pList->SaveTo( xSubStorage, aName.makeStringAndClear(), &aResult ) )
     365             :                     {
     366           0 :                         rtl::OUString aRealPath( "Settings/" );
     367           0 :                         aRealPath += aResult;
     368           0 :                         aRet[i].Value <<= aRealPath;
     369           0 :                     }
     370           0 :                 }
     371             :             }
     372             :         }
     373             : 
     374             :         // surprisingly difficult to make it really exist
     375           0 :         uno::Reference< embed::XTransactedObject > xTrans( xSubStorage, UNO_QUERY );
     376           0 :         if( xTrans.is() )
     377           0 :             xTrans->commit();
     378           0 :         uno::Reference< lang::XComponent > xComp( xSubStorage, UNO_QUERY );
     379           0 :         if( xComp.is() )
     380           0 :             xSubStorage->dispose();
     381           0 :     } catch (const uno::Exception &e) {
     382             :         (void)e;
     383             : //        fprintf (stderr, "saving etc. exception '%s'\n",
     384             : //                 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
     385             :     }
     386             : 
     387           0 :     return aRet;
     388             : }
     389             : 
     390          52 : void DocumentSettings::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
     391             : {
     392          52 :     ::SolarMutexGuard aGuard;
     393             : 
     394          52 :     SdDrawDocument* pDoc = mpModel->GetDoc();
     395          52 :     ::sd::DrawDocShell* pDocSh = mpModel->GetDocShell();
     396          52 :     if( NULL == pDoc || NULL == pDocSh )
     397           0 :         throw UnknownPropertyException();
     398             : 
     399          52 :     sal_Bool bValue = sal_False;
     400          52 :     bool bOk, bChanged = false, bOptionsChanged = false;
     401             : 
     402          52 :     SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
     403             : 
     404          52 :     SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
     405          52 :     if( pPrinter )
     406             :     {
     407           5 :         SdOptionsPrintItem* pPrinterOptions = NULL;
     408           5 :         if(pPrinter->GetOptions().GetItemState( ATTR_OPTIONS_PRINT, sal_False, (const SfxPoolItem**) &pPrinterOptions) == SFX_ITEM_SET)
     409           0 :             aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
     410             :     }
     411             :     else
     412             :     {
     413          47 :         aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
     414             :     }
     415          52 :     SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
     416             : 
     417         104 :     for( ; *ppEntries; ppEntries++, pValues++ )
     418             :     {
     419          52 :         bOk = false;
     420             : 
     421          52 :         switch( (*ppEntries)->mnHandle )
     422             :         {
     423             :             case HANDLE_COLORTABLEURL:
     424           0 :                 AssignURL( XCOLOR_LIST, pValues, &bOk, &bChanged );
     425           0 :                 break;
     426             : 
     427             :             case HANDLE_DASHTABLEURL:
     428           0 :                 AssignURL( XDASH_LIST, pValues, &bOk, &bChanged );
     429           0 :                 break;
     430             : 
     431             :             case HANDLE_LINEENDTABLEURL:
     432           0 :                 AssignURL( XLINE_END_LIST, pValues, &bOk, &bChanged );
     433           0 :                 break;
     434             : 
     435             :             case HANDLE_HATCHTABLEURL:
     436           0 :                 AssignURL( XHATCH_LIST, pValues, &bOk, &bChanged );
     437           0 :                 break;
     438             : 
     439             :             case HANDLE_GRADIENTTABLEURL:
     440           0 :                 AssignURL( XGRADIENT_LIST, pValues, &bOk, &bChanged );
     441           0 :                 break;
     442             : 
     443             :             case HANDLE_BITMAPTABLEURL:
     444           0 :                 AssignURL( XBITMAP_LIST, pValues, &bOk, &bChanged );
     445           0 :                 break;
     446             : 
     447             :             case HANDLE_FORBIDDENCHARS:
     448           2 :                 bOk = true;
     449           2 :                 break;
     450             : 
     451             :             case HANDLE_APPLYUSERDATA:
     452             :                 {
     453           2 :                     sal_Bool bApplyUserData = sal_False;
     454           2 :                     if( *pValues >>= bApplyUserData )
     455             :                     {
     456           2 :                         bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
     457           2 :                         pDocSh->SetUseUserData( bApplyUserData );
     458           2 :                         bOk = true;
     459             :                     }
     460             :                 }
     461           2 :                 break;
     462             :             case HANDLE_PRINTDRAWING:
     463           1 :                 if( *pValues >>= bValue )
     464             :                 {
     465           1 :                     if( aPrintOpts.IsDraw() != bValue )
     466             :                     {
     467           0 :                         aPrintOpts.SetDraw( bValue );
     468           0 :                         bOptionsChanged = true;
     469             :                     }
     470             : 
     471           1 :                     bOk = true;
     472             :                 }
     473           1 :                 break;
     474             :             case HANDLE_PRINTNOTES:
     475           1 :                 if( *pValues >>= bValue )
     476             :                 {
     477           1 :                     if( aPrintOpts.IsNotes() != bValue )
     478             :                     {
     479           0 :                         aPrintOpts.SetNotes( bValue );
     480           0 :                         bOptionsChanged = true;
     481             :                     }
     482             : 
     483           1 :                     bOk = true;
     484             :                 }
     485           1 :                 break;
     486             :             case HANDLE_PRINTHANDOUT:
     487           1 :                 if( *pValues >>= bValue )
     488             :                 {
     489           1 :                     if( aPrintOpts.IsHandout() != bValue)
     490             :                     {
     491           0 :                         aPrintOpts.SetHandout( bValue );
     492           0 :                         bOptionsChanged = true;
     493             :                     }
     494             : 
     495           1 :                     bOk = true;
     496             :                 }
     497           1 :                 break;
     498             :             case HANDLE_PRINTOUTLINE:
     499           1 :                 if( *pValues >>= bValue )
     500             :                 {
     501           1 :                     if( aPrintOpts.IsOutline() != bValue)
     502             :                     {
     503           0 :                         aPrintOpts.SetOutline( bValue );
     504           0 :                         bOptionsChanged = true;
     505             :                     }
     506           1 :                     bOk = true;
     507             :                 }
     508           1 :                 break;
     509             :             case HANDLE_SLIDESPERHANDOUT:
     510             :                 {
     511           1 :                     sal_Int16 nValue = 0;
     512           1 :                     if( (*pValues >>= nValue) && (nValue >= 1) && (nValue <= 9) )
     513             :                     {
     514           1 :                         if( static_cast<sal_Int16>( aPrintOpts.GetHandoutPages() ) != nValue )
     515             :                         {
     516           0 :                             aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
     517           0 :                             bOptionsChanged = true;
     518             :                         }
     519           1 :                         bOk = true;
     520             :                     }
     521             :                 }
     522           1 :                 break;
     523             :             case HANDLE_HANDOUTHORIZONTAL:
     524           1 :                 if( *pValues >>= bValue )
     525             :                 {
     526           1 :                     if( aPrintOpts.IsHandoutHorizontal() != bValue )
     527             :                     {
     528           0 :                         aPrintOpts.SetHandoutHorizontal( bValue );
     529           0 :                         bOptionsChanged = true;
     530             :                     }
     531           1 :                     bOk = true;
     532             :                 }
     533           1 :                 break;
     534             : 
     535             :             case HANDLE_PRINTPAGENAME:
     536           2 :                 if( *pValues >>= bValue )
     537             :                 {
     538           2 :                     if( aPrintOpts.IsPagename() != bValue)
     539             :                     {
     540           0 :                         aPrintOpts.SetPagename( bValue );
     541           0 :                         bOptionsChanged = true;
     542             :                     }
     543           2 :                     bOk = true;
     544             :                 }
     545           2 :                 break;
     546             :             case HANDLE_PRINTDATE:
     547           2 :                 if( *pValues >>= bValue )
     548             :                 {
     549           2 :                     if( aPrintOpts.IsDate() != bValue)
     550             :                     {
     551           0 :                         aPrintOpts.SetDate( bValue );
     552           0 :                         bOptionsChanged = true;
     553             :                     }
     554           2 :                     bOk = true;
     555             :                 }
     556           2 :                 break;
     557             :             case HANDLE_PRINTTIME:
     558           2 :                 if( *pValues >>= bValue )
     559             :                 {
     560           2 :                     if( aPrintOpts.IsDate() != bValue)
     561             :                     {
     562           0 :                         aPrintOpts.SetTime( bValue );
     563           0 :                         bOptionsChanged = true;
     564             :                     }
     565           2 :                     bOk = true;
     566             :                 }
     567           2 :                 break;
     568             :             case HANDLE_PRINTHIDENPAGES:
     569           2 :                 if( *pValues >>= bValue )
     570             :                 {
     571           2 :                     if( aPrintOpts.IsHiddenPages() != bValue)
     572             :                     {
     573           0 :                         aPrintOpts.SetHiddenPages( bValue );
     574           0 :                         bOptionsChanged = true;
     575             :                     }
     576           2 :                     bOk = true;
     577             :                 }
     578           2 :                 break;
     579             :             case HANDLE_PRINTFITPAGE:
     580           2 :                 if( *pValues >>= bValue )
     581             :                 {
     582           2 :                     if( aPrintOpts.IsPagesize() != bValue)
     583             :                     {
     584           0 :                         aPrintOpts.SetPagesize( bValue );
     585           0 :                         bOptionsChanged = true;
     586             :                     }
     587           2 :                     bOk = true;
     588             :                 }
     589           2 :                 break;
     590             :             case HANDLE_PRINTTILEPAGE:
     591           2 :                 if( *pValues >>= bValue )
     592             :                 {
     593           2 :                     if( aPrintOpts.IsPagetile() != bValue)
     594             :                     {
     595           0 :                         aPrintOpts.SetPagetile( bValue );
     596           0 :                         bOptionsChanged = true;
     597             :                     }
     598           2 :                     bOk = true;
     599             :                 }
     600           2 :                 break;
     601             :             case HANDLE_PRINTBOOKLET:
     602           2 :                 if( *pValues >>= bValue )
     603             :                 {
     604           2 :                     if( aPrintOpts.IsBooklet() != bValue)
     605             :                     {
     606           0 :                         aPrintOpts.SetBooklet( bValue );
     607           0 :                         bOptionsChanged = true;
     608             :                     }
     609           2 :                     bOk = true;
     610             :                 }
     611           2 :                 break;
     612             :             case HANDLE_PRINTBOOKLETFRONT:
     613           2 :                 if( *pValues >>= bValue )
     614             :                 {
     615           2 :                     if( aPrintOpts.IsFrontPage() != bValue)
     616             :                     {
     617           0 :                         aPrintOpts.SetFrontPage( bValue );
     618           0 :                         bOptionsChanged = true;
     619             :                     }
     620           2 :                     bOk = true;
     621             :                 }
     622           2 :                 break;
     623             :             case HANDLE_PRINTBOOKLETBACK:
     624           2 :                 if( *pValues >>= bValue )
     625             :                 {
     626           2 :                     if( aPrintOpts.IsBackPage() != bValue)
     627             :                     {
     628           0 :                         aPrintOpts.SetBackPage( bValue );
     629           0 :                         bOptionsChanged = true;
     630             :                     }
     631           2 :                     bOk = true;
     632             :                 }
     633           2 :                 break;
     634             :             case HANDLE_PRINTQUALITY:
     635             :                 {
     636           2 :                     sal_Int32 nValue = 0;
     637           2 :                     if( *pValues >>= nValue )
     638             :                     {
     639           2 :                         if( aPrintOpts.GetOutputQuality() != nValue)
     640             :                         {
     641           0 :                             aPrintOpts.SetOutputQuality( (sal_uInt16)nValue );
     642           0 :                             bOptionsChanged = true;
     643             :                         }
     644           2 :                         bOk = true;
     645             :                     }
     646             :                 }
     647           2 :                 break;
     648             :             case HANDLE_MEASUREUNIT:
     649             :                 {
     650           0 :                     sal_Int16 nValue = 0;
     651           0 :                     if( *pValues >>= nValue )
     652             :                     {
     653             :                         short nFieldUnit;
     654           0 :                         if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
     655             :                         {
     656           0 :                             pDoc->SetUIUnit((FieldUnit)nFieldUnit );
     657           0 :                             bOk = true;
     658             :                         }
     659             :                     }
     660             :                 }
     661           0 :                 break;
     662             :             case HANDLE_SCALE_NUM:
     663             :                 {
     664           0 :                     sal_Int32 nValue = 0;
     665           0 :                     if( *pValues >>= nValue )
     666             :                     {
     667           0 :                         Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
     668           0 :                         pDoc->SetUIScale( aFract );
     669           0 :                         bOk = true;
     670           0 :                         bChanged = true;
     671             :                     }
     672             :                 }
     673           0 :                 break;
     674             :             case HANDLE_SCALE_DOM:
     675             :                 {
     676           0 :                     sal_Int32 nValue = 0;
     677           0 :                     if( *pValues >>= nValue )
     678             :                     {
     679           0 :                         Fraction aFract( pDoc->GetUIScale().GetNumerator(), nValue );
     680           0 :                         pDoc->SetUIScale( aFract );
     681           0 :                         bOk = true;
     682           0 :                         bChanged = true;
     683             :                     }
     684             :                 }
     685           0 :                 break;
     686             : 
     687             :             case HANDLE_TABSTOP:
     688             :                 {
     689           2 :                     sal_Int32 nValue = 0;
     690           2 :                     if( (*pValues >>= nValue) && (nValue >= 0) )
     691             :                     {
     692           2 :                         pDoc->SetDefaultTabulator((sal_uInt16)nValue);
     693           2 :                         bOk = true;
     694           2 :                         bChanged = true;
     695             :                     }
     696             :                 }
     697           2 :                 break;
     698             :             case HANDLE_PAGENUMFMT:
     699             :                 {
     700           2 :                     sal_Int32 nValue = 0;
     701           2 :                     if( (*pValues >>= nValue ) && (nValue >= SVX_CHARS_UPPER_LETTER ) && (nValue <= SVX_PAGEDESC) )
     702             :                     {
     703           2 :                         pDoc->SetPageNumType((SvxNumType)nValue);
     704           2 :                         bOk = true;
     705           2 :                         bChanged = true;
     706             :                     }
     707             :                 }
     708           2 :                 break;
     709             :             case HANDLE_PRINTERNAME:
     710             :                 {
     711           2 :                     OUString aPrinterName;
     712           2 :                     if( *pValues >>= aPrinterName )
     713             :                     {
     714           2 :                         bOk = true;
     715           2 :                         if( !aPrinterName.isEmpty() && pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
     716             :                         {
     717           0 :                             SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_True );
     718           0 :                             if (pTempPrinter)
     719             :                             {
     720           0 :                                 SfxPrinter *pNewPrinter = new SfxPrinter( pTempPrinter->GetOptions().Clone(), aPrinterName );
     721           0 :                                 pDocSh->SetPrinter( pNewPrinter );
     722             :                             }
     723             :                         }
     724           2 :                     }
     725             :                 }
     726           2 :                 break;
     727             :             case HANDLE_PRINTERJOB:
     728             :                 {
     729           2 :                     Sequence < sal_Int8 > aSequence;
     730           2 :                     if ( *pValues >>= aSequence )
     731             :                     {
     732           2 :                         bOk = true;
     733           2 :                         sal_uInt32 nSize = aSequence.getLength();
     734           2 :                         if( nSize )
     735             :                         {
     736           2 :                             SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
     737           2 :                             aStream.Seek ( STREAM_SEEK_TO_BEGIN );
     738             :                             SfxItemSet* pItemSet;
     739             : 
     740           2 :                             if( pPrinter )
     741             :                             {
     742           0 :                                 pItemSet = pPrinter->GetOptions().Clone();
     743             :                             }
     744             :                             else
     745             :                             {
     746             :                                 pItemSet = new SfxItemSet(pDoc->GetPool(),
     747             :                                             SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
     748             :                                             SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
     749             :                                             ATTR_OPTIONS_PRINT,         ATTR_OPTIONS_PRINT,
     750           2 :                                             0 );
     751             :                             }
     752             : 
     753           2 :                             pPrinter = SfxPrinter::Create ( aStream, pItemSet );
     754             : 
     755           2 :                             MapMode aMM (pPrinter->GetMapMode());
     756           2 :                             aMM.SetMapUnit(MAP_100TH_MM);
     757           2 :                             pPrinter->SetMapMode(aMM);
     758             : 
     759           2 :                             pDocSh->SetPrinter( pPrinter );
     760             : 
     761           2 :                             pPrinter = NULL;
     762             :                         }
     763           2 :                     }
     764             :                 }
     765           2 :                 break;
     766             : 
     767             :             case HANDLE_PARAGRAPHSUMMATION :
     768             :             {
     769           2 :                 sal_Bool bIsSummationOfParagraphs = sal_False;
     770           2 :                 if ( *pValues >>= bIsSummationOfParagraphs )
     771             :                 {
     772           2 :                     bOk = true;
     773           2 :                     bChanged = true;
     774           2 :                     if ( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     775             :                     {
     776           2 :                         sal_uInt32 nSum = bIsSummationOfParagraphs ? EE_CNTRL_ULSPACESUMMATION : 0;
     777             :                         sal_uInt32 nCntrl;
     778             : 
     779           2 :                         pDoc->SetSummationOfParagraphs( bIsSummationOfParagraphs );
     780           2 :                         SdDrawDocument* pDocument = pDocSh->GetDoc();
     781           2 :                         SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     782           2 :                         nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     783           2 :                         rOutl.SetControlWord( nCntrl | nSum );
     784           2 :                         ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     785           2 :                         if( pOutl )
     786             :                         {
     787           0 :                             nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     788           0 :                             pOutl->SetControlWord( nCntrl | nSum );
     789             :                         }
     790           2 :                         pOutl = pDocument->GetInternalOutliner( sal_False );
     791           2 :                         if( pOutl )
     792             :                         {
     793           2 :                             nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     794           2 :                             pOutl->SetControlWord( nCntrl | nSum );
     795             :                         }
     796             :                     }
     797             :                 }
     798             :             }
     799           2 :             break;
     800             : 
     801             :             case HANDLE_CHARCOMPRESS:
     802             :             {
     803           2 :                 sal_Int16 nCharCompressType = 0;
     804           2 :                 if( *pValues >>= nCharCompressType )
     805             :                 {
     806           2 :                     bOk = true;
     807             : 
     808           2 :                     pDoc->SetCharCompressType( (sal_uInt16)nCharCompressType );
     809           2 :                     SdDrawDocument* pDocument = pDocSh->GetDoc();
     810           2 :                     SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     811           2 :                     rOutl.SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     812           2 :                     ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     813           2 :                     if( pOutl )
     814             :                     {
     815           0 :                         pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     816             :                     }
     817           2 :                     pOutl = pDocument->GetInternalOutliner( sal_False );
     818           2 :                     if( pOutl )
     819             :                     {
     820           2 :                         pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     821             :                     }
     822             :                 }
     823             :                 break;
     824             : 
     825             :             }
     826             :             case HANDLE_ASIANPUNCT:
     827             :             {
     828           2 :                 sal_Bool bAsianPunct = sal_False;
     829           2 :                 if( *pValues >>= bAsianPunct )
     830             :                 {
     831           2 :                     bOk = true;
     832             : 
     833           2 :                     pDoc->SetKernAsianPunctuation( bAsianPunct );
     834           2 :                     SdDrawDocument* pDocument = pDocSh->GetDoc();
     835           2 :                     SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     836           2 :                     rOutl.SetKernAsianPunctuation( bAsianPunct );
     837           2 :                     ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     838           2 :                     if( pOutl )
     839             :                     {
     840           0 :                         pOutl->SetKernAsianPunctuation( bAsianPunct );
     841             :                     }
     842           2 :                     pOutl = pDocument->GetInternalOutliner( sal_False );
     843           2 :                     if( pOutl )
     844             :                     {
     845           2 :                         pOutl->SetKernAsianPunctuation( bAsianPunct );
     846             :                     }
     847             :                 }
     848             :                 break;
     849             : 
     850             :             }
     851             :             case HANDLE_UPDATEFROMTEMPLATE:
     852             :             {
     853           2 :                 sal_Bool value = sal_False;
     854           2 :                 if( *pValues >>= value )
     855             :                 {
     856           2 :                     bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
     857           2 :                     pDocSh->SetQueryLoadTemplate( value );
     858           2 :                     bOk = true;
     859             :                 }
     860             :             }
     861           2 :             break;
     862             : 
     863             :             case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
     864             :             {
     865             :                 // Just propagate the new printer independent layout mode to
     866             :                 // the document and determine it really differs from the old
     867             :                 // one.
     868             :                 sal_Int16 nOldValue =
     869           2 :                     (sal_Int16)pDoc->GetPrinterIndependentLayout ();
     870           2 :                 sal_Int16 nValue = 0;
     871           2 :                 if (*pValues >>= nValue)
     872             :                 {
     873           2 :                     pDoc->SetPrinterIndependentLayout (nValue);
     874           2 :                     bChanged = (nValue != nOldValue);
     875           2 :                     bOk = true;
     876             :                 }
     877             :             }
     878           2 :             break;
     879             : 
     880             :             // --> #i33095#
     881             :             case HANDLE_LOAD_READONLY:
     882             :             {
     883           2 :                 sal_Bool bNewValue = sal_False;
     884           2 :                 if ( *pValues >>= bNewValue )
     885             :                 {
     886           2 :                     bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
     887           2 :                     pDocSh->SetLoadReadonly( bNewValue );
     888           2 :                     bOk = true;
     889             :                 }
     890             :             }
     891           2 :             break;
     892             : 
     893             :             case HANDLE_SAVE_VERSION:
     894             :             {
     895           2 :                 sal_Bool bNewValue = sal_False;
     896           2 :                 if ( *pValues >>= bNewValue )
     897             :                 {
     898           2 :                     bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
     899           2 :                     pDocSh->SetSaveVersionOnClose( bNewValue );
     900           2 :                     bOk = true;
     901             :                 }
     902             :             }
     903           2 :             break;
     904             : 
     905             :             default:
     906           0 :                 throw UnknownPropertyException();
     907             :         }
     908             : 
     909          52 :         if( !bOk )
     910           0 :             throw IllegalArgumentException();
     911             :     }
     912             : 
     913          52 :     if( bOptionsChanged )
     914             :     {
     915           0 :         if( !pPrinter )
     916           0 :             pPrinter = pDocSh->GetPrinter( sal_True );
     917           0 :         SfxItemSet aNewOptions( pPrinter->GetOptions() );
     918           0 :         aNewOptions.Put( aOptionsPrintItem );
     919           0 :         pPrinter->SetOptions( aNewOptions );
     920             :     }
     921             : 
     922          52 :     if( bChanged || bOptionsChanged )
     923           8 :         mpModel->SetModified( sal_True );
     924          52 : }
     925             : 
     926           0 : void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
     927             : {
     928           0 :     XPropertyListRef pList = mpModel->GetDoc()->GetPropertyList( t );
     929           0 :     if( !pList.is() )
     930           0 :         return;
     931             : 
     932           0 :     INetURLObject aPathURL( pList->GetPath() );
     933           0 :     aPathURL.insertName( pList->GetName() );
     934           0 :     aPathURL.setExtension( pList->GetDefaultExt() );
     935           0 :     OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
     936           0 :     *pValue <<= aPath;
     937             : }
     938             : 
     939           2 : void DocumentSettings::_getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValue ) throw(UnknownPropertyException, WrappedTargetException )
     940             : {
     941           2 :     ::SolarMutexGuard aGuard;
     942             : 
     943           2 :     SdDrawDocument* pDoc = mpModel->GetDoc();
     944           2 :     ::sd::DrawDocShell* pDocSh = mpModel->GetDocShell();
     945           2 :     if( NULL == pDoc || NULL == pDocSh )
     946           0 :         throw UnknownPropertyException();
     947             : 
     948           2 :     SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
     949             : 
     950           2 :     SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
     951           2 :     if( pPrinter )
     952             :     {
     953           0 :         SdOptionsPrintItem* pPrinterOptions = NULL;
     954           0 :         if(pPrinter->GetOptions().GetItemState( ATTR_OPTIONS_PRINT, sal_False, (const SfxPoolItem**) &pPrinterOptions) == SFX_ITEM_SET)
     955           0 :             aOptionsPrintItem.GetOptionsPrint() = pPrinterOptions->GetOptionsPrint();
     956             :     }
     957             :     else
     958             :     {
     959           2 :         aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
     960             :     }
     961           2 :     SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
     962             : 
     963           4 :     for( ; *ppEntries; ppEntries++, pValue++ )
     964             :     {
     965           2 :         switch( (*ppEntries)->mnHandle )
     966             :         {
     967             :             case HANDLE_COLORTABLEURL:
     968           0 :                 ExtractURL( XCOLOR_LIST, pValue );
     969           0 :                 break;
     970             :             case HANDLE_DASHTABLEURL:
     971           0 :                 ExtractURL( XDASH_LIST, pValue );
     972           0 :                 break;
     973             :             case HANDLE_LINEENDTABLEURL:
     974           0 :                 ExtractURL( XLINE_END_LIST, pValue );
     975           0 :                 break;
     976             :             case HANDLE_HATCHTABLEURL:
     977           0 :                 ExtractURL( XHATCH_LIST, pValue );
     978           0 :                 break;
     979             :             case HANDLE_GRADIENTTABLEURL:
     980           0 :                 ExtractURL( XGRADIENT_LIST, pValue );
     981           0 :                 break;
     982             :             case HANDLE_BITMAPTABLEURL:
     983           0 :                 ExtractURL( XBITMAP_LIST, pValue );
     984           0 :                 break;
     985             :             case HANDLE_FORBIDDENCHARS:
     986           2 :                 *pValue <<= mpModel->getForbiddenCharsTable();
     987           2 :                 break;
     988             :             case HANDLE_APPLYUSERDATA:
     989           0 :                 *pValue <<= pDocSh->IsUseUserData();
     990           0 :                 break;
     991             :             case HANDLE_PRINTDRAWING:
     992           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsDraw();
     993           0 :                 break;
     994             :             case HANDLE_PRINTNOTES:
     995           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsNotes();
     996           0 :                 break;
     997             :             case HANDLE_PRINTHANDOUT:
     998           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHandout();
     999           0 :                 break;
    1000             :             case HANDLE_PRINTOUTLINE:
    1001           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsOutline();
    1002           0 :                 break;
    1003             :             case HANDLE_SLIDESPERHANDOUT:
    1004           0 :                 *pValue <<= (sal_Int16)aPrintOpts.GetHandoutPages();
    1005           0 :                 break;
    1006             :             case HANDLE_HANDOUTHORIZONTAL:
    1007           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHandoutHorizontal();
    1008           0 :                 break;
    1009             :             case HANDLE_PRINTPAGENAME:
    1010           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagename();
    1011           0 :                 break;
    1012             :             case HANDLE_PRINTDATE:
    1013           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsDate();
    1014           0 :                 break;
    1015             :             case HANDLE_PRINTTIME:
    1016           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsTime();
    1017           0 :                 break;
    1018             :             case HANDLE_PRINTHIDENPAGES:
    1019           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHiddenPages();
    1020           0 :                 break;
    1021             :             case HANDLE_PRINTFITPAGE:
    1022           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagesize();
    1023           0 :                 break;
    1024             :             case HANDLE_PRINTTILEPAGE:
    1025           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagetile();
    1026           0 :                 break;
    1027             :             case HANDLE_PRINTBOOKLET:
    1028           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsBooklet();
    1029           0 :                 break;
    1030             :             case HANDLE_PRINTBOOKLETFRONT:
    1031           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsFrontPage();
    1032           0 :                 break;
    1033             :             case HANDLE_PRINTBOOKLETBACK:
    1034           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsBackPage();
    1035           0 :                 break;
    1036             :             case HANDLE_PRINTQUALITY:
    1037           0 :                 *pValue <<= (sal_Int32)aPrintOpts.GetOutputQuality();
    1038           0 :                 break;
    1039             :             case HANDLE_MEASUREUNIT:
    1040             :                 {
    1041             :                     short nMeasure;
    1042           0 :                     SvxFieldUnitToMeasureUnit( (const short)pDoc->GetUIUnit(), nMeasure );
    1043           0 :                     *pValue <<= (sal_Int16)nMeasure;
    1044             :                 }
    1045           0 :                 break;
    1046             :             case HANDLE_SCALE_NUM:
    1047           0 :                 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetNumerator();
    1048           0 :                 break;
    1049             :             case HANDLE_SCALE_DOM:
    1050           0 :                 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetDenominator();
    1051           0 :                 break;
    1052             :             case HANDLE_TABSTOP:
    1053           0 :                 *pValue <<= (sal_Int32)pDoc->GetDefaultTabulator();
    1054           0 :                 break;
    1055             :             case HANDLE_PAGENUMFMT:
    1056           0 :                 *pValue <<= (sal_Int32)pDoc->GetPageNumType();
    1057           0 :                 break;
    1058             :             case HANDLE_PRINTERNAME:
    1059             :                 {
    1060           0 :                     SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
    1061           0 :                     *pValue <<= pTempPrinter ? OUString ( pTempPrinter->GetName()) : OUString();
    1062             :                 }
    1063           0 :                 break;
    1064             :             case HANDLE_PRINTERJOB:
    1065             :                 {
    1066           0 :                     SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
    1067           0 :                     if (pTempPrinter)
    1068             :                     {
    1069           0 :                         SvMemoryStream aStream;
    1070           0 :                         pTempPrinter->Store( aStream );
    1071           0 :                         aStream.Seek ( STREAM_SEEK_TO_END );
    1072           0 :                         sal_uInt32 nSize = aStream.Tell();
    1073           0 :                         aStream.Seek ( STREAM_SEEK_TO_BEGIN );
    1074           0 :                         Sequence < sal_Int8 > aSequence ( nSize );
    1075           0 :                         memcpy ( aSequence.getArray(), aStream.GetData(), nSize );
    1076           0 :                         *pValue <<= aSequence;
    1077             :                     }
    1078             :                     else
    1079             :                     {
    1080           0 :                         Sequence < sal_Int8 > aSequence;
    1081           0 :                         *pValue <<= aSequence;
    1082             :                     }
    1083             :                 }
    1084           0 :                 break;
    1085             : 
    1086             :             case HANDLE_PARAGRAPHSUMMATION :
    1087             :             {
    1088           0 :                 sal_Bool bIsSummationOfParagraphs = pDoc->IsSummationOfParagraphs();
    1089           0 :                 *pValue <<= bIsSummationOfParagraphs;
    1090             :             }
    1091           0 :             break;
    1092             : 
    1093             :             case HANDLE_CHARCOMPRESS:
    1094             :             {
    1095           0 :                 *pValue <<= (sal_Int16)pDoc->GetCharCompressType();
    1096           0 :                 break;
    1097             :             }
    1098             : 
    1099             :             case HANDLE_ASIANPUNCT:
    1100             :             {
    1101           0 :                 *pValue <<= (sal_Bool)pDoc->IsKernAsianPunctuation();
    1102           0 :                 break;
    1103             :             }
    1104             : 
    1105             :             case HANDLE_UPDATEFROMTEMPLATE:
    1106             :             {
    1107           0 :                 *pValue <<= pDocSh->IsQueryLoadTemplate();
    1108             :             }
    1109           0 :             break;
    1110             : 
    1111             :             case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
    1112             :             {
    1113             :                 sal_Int16 nPrinterIndependentLayout =
    1114           0 :                     (sal_Int16)pDoc->GetPrinterIndependentLayout();
    1115           0 :                 *pValue <<= nPrinterIndependentLayout;
    1116             :             }
    1117           0 :             break;
    1118             : 
    1119             :             // --> #i33095#
    1120             :             case HANDLE_LOAD_READONLY:
    1121             :             {
    1122           0 :                 *pValue <<= pDocSh->IsLoadReadonly();
    1123             :             }
    1124           0 :             break;
    1125             : 
    1126             :             case HANDLE_SAVE_VERSION:
    1127             :             {
    1128           0 :                 *pValue <<= pDocSh->IsSaveVersionOnClose();
    1129             :             }
    1130           0 :             break;
    1131             : 
    1132             :             default:
    1133           0 :                 throw UnknownPropertyException();
    1134             :         }
    1135           2 :     }
    1136           2 : }
    1137             : 
    1138             : // XInterface
    1139           4 : Any SAL_CALL DocumentSettings::queryInterface( const Type& aType ) throw (RuntimeException)
    1140             : {
    1141           4 :     return WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::queryInterface( aType );
    1142             : }
    1143             : 
    1144           8 : void SAL_CALL DocumentSettings::acquire(  ) throw ()
    1145             : {
    1146           8 :     WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::acquire();
    1147           8 : }
    1148             : 
    1149           8 : void SAL_CALL DocumentSettings::release(  ) throw ()
    1150             : {
    1151           8 :     WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::release();
    1152           8 : }
    1153             : 
    1154             : 
    1155             : // XPropertySet
    1156           4 : Reference< XPropertySetInfo > SAL_CALL DocumentSettings::getPropertySetInfo(  ) throw(RuntimeException)
    1157             : {
    1158           4 :     return PropertySetHelper::getPropertySetInfo();
    1159             : }
    1160             : 
    1161          52 : void SAL_CALL DocumentSettings::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1162             : {
    1163          52 :     PropertySetHelper::setPropertyValue( aPropertyName, aValue );
    1164          52 : }
    1165             : 
    1166           2 : Any SAL_CALL DocumentSettings::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1167             : {
    1168           2 :     return PropertySetHelper::getPropertyValue( PropertyName );
    1169             : }
    1170             : 
    1171           0 : void SAL_CALL DocumentSettings::addPropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& xListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1172             : {
    1173           0 :     PropertySetHelper::addPropertyChangeListener( aPropertyName, xListener );
    1174           0 : }
    1175             : 
    1176           0 : void SAL_CALL DocumentSettings::removePropertyChangeListener( const OUString& aPropertyName, const Reference< XPropertyChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1177             : {
    1178           0 :     PropertySetHelper::removePropertyChangeListener( aPropertyName, aListener );
    1179           0 : }
    1180             : 
    1181           0 : void SAL_CALL DocumentSettings::addVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1182             : {
    1183           0 :     PropertySetHelper::addVetoableChangeListener( PropertyName, aListener );
    1184           0 : }
    1185             : 
    1186           0 : void SAL_CALL DocumentSettings::removeVetoableChangeListener( const OUString& PropertyName, const Reference< XVetoableChangeListener >& aListener ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1187             : {
    1188           0 :     PropertySetHelper::removeVetoableChangeListener( PropertyName, aListener );
    1189           0 : }
    1190             : 
    1191             : // XMultiPropertySet
    1192           0 : void SAL_CALL DocumentSettings::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw(PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1193             : {
    1194           0 :     PropertySetHelper::setPropertyValues( aPropertyNames, aValues );
    1195           0 : }
    1196             : 
    1197           0 : Sequence< Any > SAL_CALL DocumentSettings::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw(RuntimeException)
    1198             : {
    1199           0 :     return PropertySetHelper::getPropertyValues( aPropertyNames );
    1200             : }
    1201             : 
    1202           0 : void SAL_CALL DocumentSettings::addPropertiesChangeListener( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
    1203             : {
    1204           0 :     PropertySetHelper::addPropertiesChangeListener( aPropertyNames, xListener );
    1205           0 : }
    1206             : 
    1207           0 : void SAL_CALL DocumentSettings::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
    1208             : {
    1209           0 :     PropertySetHelper::removePropertiesChangeListener( xListener );
    1210           0 : }
    1211             : 
    1212           0 : void SAL_CALL DocumentSettings::firePropertiesChangeEvent( const Sequence< OUString >& aPropertyNames, const Reference< XPropertiesChangeListener >& xListener ) throw(RuntimeException)
    1213             : {
    1214           0 :     PropertySetHelper::firePropertiesChangeEvent( aPropertyNames, xListener );
    1215           0 : }
    1216             : 
    1217             : // XServiceInfo
    1218           0 : OUString SAL_CALL DocumentSettings::getImplementationName(  )
    1219             :     throw(RuntimeException)
    1220             : {
    1221           0 :     return OUString( "com.sun.star.comp.Draw.DocumentSettings" );
    1222             : }
    1223             : 
    1224           0 : sal_Bool SAL_CALL DocumentSettings::supportsService( const OUString& ServiceName )
    1225             :     throw(RuntimeException)
    1226             : {
    1227           0 :     const Sequence< OUString > aSeq( getSupportedServiceNames() );
    1228           0 :     sal_Int32 nCount = aSeq.getLength();
    1229           0 :     const OUString* pServices = aSeq.getConstArray();
    1230           0 :     while( nCount-- )
    1231             :     {
    1232           0 :         if( *pServices++ == ServiceName )
    1233           0 :             return sal_True;
    1234             :     }
    1235             : 
    1236           0 :     return sal_True;
    1237             : }
    1238             : 
    1239           0 : Sequence< OUString > SAL_CALL DocumentSettings::getSupportedServiceNames(  )
    1240             :     throw(RuntimeException)
    1241             : {
    1242           0 :     Sequence< OUString > aSeq( 2 );
    1243           0 :     aSeq[0] = "com.sun.star.document.Settings" ;
    1244           0 :     if( mpModel->IsImpressDocument() )
    1245             :     {
    1246           0 :         aSeq[1] = "com.sun.star.presentation.DocumentSettings" ;
    1247             :     }
    1248             :     else
    1249             :     {
    1250           0 :         aSeq[1] = "com.sun.star.drawing.DocumentSettings" ;
    1251             :     }
    1252             : 
    1253           0 :     return aSeq;
    1254           9 : }
    1255             : 
    1256             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10