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

Generated by: LCOV version 1.10