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

Generated by: LCOV version 1.10