LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - UnoDocumentSettings.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 600 0.0 %
Date: 2014-04-14 Functions: 0 37 0.0 %
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           0 :     Reference< XInterface > SAL_CALL DocumentSettings_createInstance( SdXImpressDocument* pModel )
     126             :         throw( Exception )
     127             :     {
     128             :         DBG_ASSERT( pModel, "I need a model for the DocumentSettings!" );
     129           0 :         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           0 :     PropertySetInfo * createSettingsInfoImpl( sal_Bool bIsDraw )
     149             :     {
     150             :         static PropertyMapEntry const aImpressSettingsInfoMap[] =
     151             :         {
     152           0 :             { OUString("IsPrintDrawing"),        HANDLE_PRINTDRAWING,        ::getBooleanCppuType(),                0,  MID_PRINTER },
     153           0 :             { OUString("IsPrintNotes"),          HANDLE_PRINTNOTES,          ::getBooleanCppuType(),                0,  MID_PRINTER },
     154           0 :             { OUString("IsPrintHandout"),        HANDLE_PRINTHANDOUT,        ::getBooleanCppuType(),                0,  MID_PRINTER },
     155           0 :             { OUString("IsPrintOutline"),        HANDLE_PRINTOUTLINE,        ::getBooleanCppuType(),                0,  MID_PRINTER },
     156           0 :             { OUString("SlidesPerHandout"),      HANDLE_SLIDESPERHANDOUT,    ::getCppuType((const sal_Int16*)0),    0,  MID_PRINTER },
     157           0 :             { OUString("HandoutsHorizontal"),    HANDLE_HANDOUTHORIZONTAL,   ::getBooleanCppuType(),                0,  MID_PRINTER },
     158             :             { OUString(), 0, css::uno::Type(), 0, 0 }
     159           0 :         };
     160             : 
     161             :         static PropertyMapEntry const aDrawSettingsInfoMap[] =
     162             :         {
     163           0 :             { OUString("MeasureUnit"),           HANDLE_MEASUREUNIT,         ::getCppuType((const sal_Int16*)0),    0,  0 },
     164           0 :             { OUString("ScaleNumerator"),        HANDLE_SCALE_NUM,           ::getCppuType((const sal_Int32*)0),    0,  0 },
     165           0 :             { OUString("ScaleDenominator"),      HANDLE_SCALE_DOM,           ::getCppuType((const sal_Int32*)0),    0,  0 },
     166             :             { OUString(), 0, css::uno::Type(), 0, 0 }
     167           0 :         };
     168             : 
     169             :         static PropertyMapEntry const aCommonSettingsInfoMap[] =
     170             :         {
     171           0 :             { OUString("DefaultTabStop"),        HANDLE_TABSTOP,             ::getCppuType((const sal_Int32*)0),    0,  0 },
     172           0 :             { OUString("PrinterName"),           HANDLE_PRINTERNAME,         ::getCppuType((const OUString*)0),     0,  0 },
     173           0 :             { OUString("PrinterSetup"),          HANDLE_PRINTERJOB,          ::getCppuType((const uno::Sequence < sal_Int8 > *)0),  0, MID_PRINTER },
     174             : 
     175           0 :             { OUString("IsPrintPageName"),       HANDLE_PRINTPAGENAME,       ::getBooleanCppuType(),                0,  MID_PRINTER },
     176           0 :             { OUString("IsPrintDate"),           HANDLE_PRINTDATE,           ::getBooleanCppuType(),                0,  MID_PRINTER },
     177           0 :             { OUString("IsPrintTime"),           HANDLE_PRINTTIME,           ::getBooleanCppuType(),                0,  MID_PRINTER },
     178           0 :             { OUString("IsPrintHiddenPages"),    HANDLE_PRINTHIDENPAGES,     ::getBooleanCppuType(),                0,  MID_PRINTER },
     179           0 :             { OUString("IsPrintFitPage"),        HANDLE_PRINTFITPAGE,        ::getBooleanCppuType(),                0,  MID_PRINTER },
     180           0 :             { OUString("IsPrintTilePage"),       HANDLE_PRINTTILEPAGE,       ::getBooleanCppuType(),                0,  MID_PRINTER },
     181           0 :             { OUString("IsPrintBooklet"),        HANDLE_PRINTBOOKLET,        ::getBooleanCppuType(),                0,  MID_PRINTER },
     182           0 :             { OUString("IsPrintBookletFront"),   HANDLE_PRINTBOOKLETFRONT,   ::getBooleanCppuType(),                0,  MID_PRINTER },
     183           0 :             { OUString("IsPrintBookletBack"),    HANDLE_PRINTBOOKLETBACK,    ::getBooleanCppuType(),                0,  MID_PRINTER },
     184           0 :             { OUString("PrintQuality"),          HANDLE_PRINTQUALITY,        ::getCppuType((const sal_Int32*)0),    0,  MID_PRINTER },
     185           0 :             { OUString("ColorTableURL"),         HANDLE_COLORTABLEURL,       ::getCppuType((const OUString*)0),     0,  0 },
     186           0 :             { OUString("DashTableURL"),          HANDLE_DASHTABLEURL,        ::getCppuType((const OUString*)0),     0,  0 },
     187           0 :             { OUString("LineEndTableURL"),       HANDLE_LINEENDTABLEURL,     ::getCppuType((const OUString*)0),     0,  0 },
     188           0 :             { OUString("HatchTableURL"),         HANDLE_HATCHTABLEURL,       ::getCppuType((const OUString*)0),     0,  0 },
     189           0 :             { OUString("GradientTableURL"),      HANDLE_GRADIENTTABLEURL,    ::getCppuType((const OUString*)0),     0,  0 },
     190           0 :             { OUString("BitmapTableURL"),        HANDLE_BITMAPTABLEURL,      ::getCppuType((const OUString*)0),     0,  0 },
     191             : 
     192           0 :             { OUString("ForbiddenCharacters"),   HANDLE_FORBIDDENCHARS,      ::getCppuType((const Reference< XForbiddenCharacters >*)0),    0, 0 },
     193           0 :             { OUString("ApplyUserData"),         HANDLE_APPLYUSERDATA,       ::getBooleanCppuType(),                0,  0 },
     194             : 
     195           0 :             { OUString("PageNumberFormat"),      HANDLE_PAGENUMFMT,          ::getCppuType((const sal_Int32*)0),    0,  0 },
     196           0 :             { OUString("ParagraphSummation"),    HANDLE_PARAGRAPHSUMMATION,  ::getBooleanCppuType(),                0,  0 },
     197           0 :             { OUString("CharacterCompressionType"),HANDLE_CHARCOMPRESS,      ::getCppuType((sal_Int16*)0),          0,  0 },
     198           0 :             { OUString("IsKernAsianPunctuation"),HANDLE_ASIANPUNCT,          ::getBooleanCppuType(),                0,  0 },
     199           0 :             { OUString("UpdateFromTemplate"),    HANDLE_UPDATEFROMTEMPLATE,  ::getBooleanCppuType(),                0,  0 },
     200           0 :             { OUString("PrinterIndependentLayout"),HANDLE_PRINTER_INDEPENDENT_LAYOUT,::getCppuType((const sal_Int16*)0), 0,  0 },
     201             :             // --> #i33095#
     202           0 :             { OUString("LoadReadonly"),          HANDLE_LOAD_READONLY,       ::getBooleanCppuType(),                0,  0 },
     203           0 :             { OUString("SaveVersionOnClose"),    HANDLE_SAVE_VERSION,        ::getBooleanCppuType(),                0,  0 },
     204           0 :             { OUString("EmbedFonts"),            HANDLE_EMBED_FONTS,         ::getBooleanCppuType(),                0,  0 },
     205             :             { OUString(), 0, css::uno::Type(), 0, 0 }
     206           0 :         };
     207             : 
     208           0 :         PropertySetInfo* pInfo = new PropertySetInfo( aCommonSettingsInfoMap );
     209           0 :         pInfo->add( bIsDraw ? aDrawSettingsInfoMap : aImpressSettingsInfoMap );
     210             : 
     211           0 :         return pInfo;
     212             :     }
     213             : }
     214             : 
     215             : using namespace ::sd;
     216             : 
     217           0 : DocumentSettings::DocumentSettings( SdXImpressDocument* pModel )
     218           0 : :   PropertySetHelper( createSettingsInfoImpl( !pModel->IsImpressDocument() ) ),
     219           0 :     mxModel( pModel )
     220             : {
     221           0 : }
     222             : 
     223           0 : DocumentSettings::~DocumentSettings() throw()
     224             : {
     225           0 : }
     226             : 
     227           0 : bool DocumentSettings::LoadList( XPropertyListType t, const OUString &rInPath,
     228             :                                  const OUString &rReferer,
     229             :                                  const uno::Reference< embed::XStorage > &xStorage )
     230             : {
     231           0 :     SdDrawDocument* pDoc = mxModel->GetDoc();
     232             : 
     233           0 :     sal_Int32 nSlash = rInPath.lastIndexOf('/');
     234           0 :     OUString aPath, aName;
     235           0 :     if (nSlash < -1)
     236           0 :         aName = rInPath;
     237             :     else {
     238           0 :         aName = rInPath.copy( nSlash + 1 );
     239           0 :         aPath = rInPath.copy( 0, nSlash );
     240             :     }
     241             : 
     242             :     XPropertyListRef pList = XPropertyList::CreatePropertyList(
     243           0 :         t, aPath, rReferer );
     244           0 :     pList->SetName( aName );
     245             : 
     246           0 :     if( pList->LoadFrom( xStorage, rInPath, rReferer ) )
     247             :     {
     248           0 :         pDoc->SetPropertyList( pList );
     249           0 :         return true;
     250             :     }
     251             : 
     252           0 :     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           0 : static XPropertyListType getTypeOfName( const OUString &aName )
     279             : {
     280           0 :     for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ ) {
     281           0 :         if( aName.equalsAscii( aURLPropertyNames[i].pName ) )
     282           0 :             return aURLPropertyNames[i].t;
     283             :     }
     284           0 :     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           0 :         DocumentSettings::filterStreamsFromStorage(
     300             :                 OUString const & referer,
     301             :                 const uno::Reference< embed::XStorage > &xStorage,
     302             :                 const uno::Sequence<beans::PropertyValue>& aConfigProps )
     303             : {
     304           0 :     uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
     305           0 :     int nRet = 0;
     306           0 :     for( sal_Int32 i = 0; i < aConfigProps.getLength(); i++ )
     307             :     {
     308           0 :         XPropertyListType t = getTypeOfName( aConfigProps[i].Name );
     309           0 :         if (t < 0)
     310           0 :             aRet[nRet++] = aConfigProps[i];
     311             :         else
     312             :         {
     313           0 :             OUString aURL;
     314           0 :             aConfigProps[i].Value >>= aURL;
     315           0 :             LoadList( t, aURL, referer, xStorage );
     316             :         }
     317             :     }
     318           0 :     aRet.realloc( nRet );
     319           0 :     return aRet;
     320             : }
     321             : 
     322             : uno::Sequence<beans::PropertyValue>
     323           0 :         DocumentSettings::filterStreamsToStorage(
     324             :                 const uno::Reference< embed::XStorage > &xStorage,
     325             :                 const uno::Sequence<beans::PropertyValue>& aConfigProps )
     326             : {
     327           0 :     uno::Sequence<beans::PropertyValue> aRet( aConfigProps.getLength() );
     328             : 
     329           0 :     bool bHasEmbed = false;
     330           0 :     SdDrawDocument* pDoc = mxModel->GetDoc();
     331           0 :     for( size_t i = 0; i < SAL_N_ELEMENTS( aURLPropertyNames ); i++ )
     332             :     {
     333           0 :         XPropertyListRef pList = pDoc->GetPropertyList( (XPropertyListType) i );
     334           0 :         if( ( bHasEmbed = pList.is() && pList->IsEmbedInDocument() ) )
     335           0 :             break;
     336           0 :     }
     337           0 :     if( !bHasEmbed )
     338           0 :         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           0 : DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
     393             :         const Any* pValues)
     394             : throw (UnknownPropertyException, PropertyVetoException,
     395             :     IllegalArgumentException, WrappedTargetException, RuntimeException)
     396             : {
     397           0 :     ::SolarMutexGuard aGuard;
     398             : 
     399           0 :     SdDrawDocument* pDoc = mxModel->GetDoc();
     400           0 :     ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
     401           0 :     if( NULL == pDoc || NULL == pDocSh )
     402             :     {
     403             :         throw RuntimeException("Document or Shell missing",
     404           0 :                 static_cast<OWeakObject *>(this));
     405             :     }
     406             : 
     407           0 :     sal_Bool bValue = sal_False;
     408           0 :     bool bOk, bChanged = false, bOptionsChanged = false;
     409             : 
     410           0 :     SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
     411             : 
     412           0 :     SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
     413           0 :     if( pPrinter )
     414             :     {
     415           0 :         SdOptionsPrintItem* pPrinterOptions = NULL;
     416           0 :         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           0 :         aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
     422             :     }
     423           0 :     SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
     424             : 
     425           0 :     for( ; *ppEntries; ppEntries++, pValues++ )
     426             :     {
     427           0 :         bOk = false;
     428             : 
     429           0 :         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           0 :                 bOk = true;
     457           0 :                 break;
     458             : 
     459             :             case HANDLE_APPLYUSERDATA:
     460             :                 {
     461           0 :                     bool bApplyUserData = false;
     462           0 :                     if( *pValues >>= bApplyUserData )
     463             :                     {
     464           0 :                         bChanged = ( bApplyUserData != pDocSh->IsUseUserData() );
     465           0 :                         pDocSh->SetUseUserData( bApplyUserData );
     466           0 :                         bOk = true;
     467             :                     }
     468             :                 }
     469           0 :                 break;
     470             :             case HANDLE_PRINTDRAWING:
     471           0 :                 if( *pValues >>= bValue )
     472             :                 {
     473           0 :                     if( aPrintOpts.IsDraw() != bValue )
     474             :                     {
     475           0 :                         aPrintOpts.SetDraw( bValue );
     476           0 :                         bOptionsChanged = true;
     477             :                     }
     478             : 
     479           0 :                     bOk = true;
     480             :                 }
     481           0 :                 break;
     482             :             case HANDLE_PRINTNOTES:
     483           0 :                 if( *pValues >>= bValue )
     484             :                 {
     485           0 :                     if( aPrintOpts.IsNotes() != bValue )
     486             :                     {
     487           0 :                         aPrintOpts.SetNotes( bValue );
     488           0 :                         bOptionsChanged = true;
     489             :                     }
     490             : 
     491           0 :                     bOk = true;
     492             :                 }
     493           0 :                 break;
     494             :             case HANDLE_PRINTHANDOUT:
     495           0 :                 if( *pValues >>= bValue )
     496             :                 {
     497           0 :                     if( aPrintOpts.IsHandout() != bValue)
     498             :                     {
     499           0 :                         aPrintOpts.SetHandout( bValue );
     500           0 :                         bOptionsChanged = true;
     501             :                     }
     502             : 
     503           0 :                     bOk = true;
     504             :                 }
     505           0 :                 break;
     506             :             case HANDLE_PRINTOUTLINE:
     507           0 :                 if( *pValues >>= bValue )
     508             :                 {
     509           0 :                     if( aPrintOpts.IsOutline() != bValue)
     510             :                     {
     511           0 :                         aPrintOpts.SetOutline( bValue );
     512           0 :                         bOptionsChanged = true;
     513             :                     }
     514           0 :                     bOk = true;
     515             :                 }
     516           0 :                 break;
     517             :             case HANDLE_SLIDESPERHANDOUT:
     518             :                 {
     519           0 :                     sal_Int16 nValue = 0;
     520           0 :                     if( (*pValues >>= nValue) && (nValue >= 1) && (nValue <= 9) )
     521             :                     {
     522           0 :                         if( static_cast<sal_Int16>( aPrintOpts.GetHandoutPages() ) != nValue )
     523             :                         {
     524           0 :                             aPrintOpts.SetHandoutPages( static_cast< sal_uInt16 >( nValue ) );
     525           0 :                             bOptionsChanged = true;
     526             :                         }
     527           0 :                         bOk = true;
     528             :                     }
     529             :                 }
     530           0 :                 break;
     531             :             case HANDLE_HANDOUTHORIZONTAL:
     532           0 :                 if( *pValues >>= bValue )
     533             :                 {
     534           0 :                     if( aPrintOpts.IsHandoutHorizontal() != bValue )
     535             :                     {
     536           0 :                         aPrintOpts.SetHandoutHorizontal( bValue );
     537           0 :                         bOptionsChanged = true;
     538             :                     }
     539           0 :                     bOk = true;
     540             :                 }
     541           0 :                 break;
     542             : 
     543             :             case HANDLE_PRINTPAGENAME:
     544           0 :                 if( *pValues >>= bValue )
     545             :                 {
     546           0 :                     if( aPrintOpts.IsPagename() != bValue)
     547             :                     {
     548           0 :                         aPrintOpts.SetPagename( bValue );
     549           0 :                         bOptionsChanged = true;
     550             :                     }
     551           0 :                     bOk = true;
     552             :                 }
     553           0 :                 break;
     554             :             case HANDLE_PRINTDATE:
     555           0 :                 if( *pValues >>= bValue )
     556             :                 {
     557           0 :                     if( aPrintOpts.IsDate() != bValue)
     558             :                     {
     559           0 :                         aPrintOpts.SetDate( bValue );
     560           0 :                         bOptionsChanged = true;
     561             :                     }
     562           0 :                     bOk = true;
     563             :                 }
     564           0 :                 break;
     565             :             case HANDLE_PRINTTIME:
     566           0 :                 if( *pValues >>= bValue )
     567             :                 {
     568           0 :                     if( aPrintOpts.IsDate() != bValue)
     569             :                     {
     570           0 :                         aPrintOpts.SetTime( bValue );
     571           0 :                         bOptionsChanged = true;
     572             :                     }
     573           0 :                     bOk = true;
     574             :                 }
     575           0 :                 break;
     576             :             case HANDLE_PRINTHIDENPAGES:
     577           0 :                 if( *pValues >>= bValue )
     578             :                 {
     579           0 :                     if( aPrintOpts.IsHiddenPages() != bValue)
     580             :                     {
     581           0 :                         aPrintOpts.SetHiddenPages( bValue );
     582           0 :                         bOptionsChanged = true;
     583             :                     }
     584           0 :                     bOk = true;
     585             :                 }
     586           0 :                 break;
     587             :             case HANDLE_PRINTFITPAGE:
     588           0 :                 if( *pValues >>= bValue )
     589             :                 {
     590           0 :                     if( aPrintOpts.IsPagesize() != bValue)
     591             :                     {
     592           0 :                         aPrintOpts.SetPagesize( bValue );
     593           0 :                         bOptionsChanged = true;
     594             :                     }
     595           0 :                     bOk = true;
     596             :                 }
     597           0 :                 break;
     598             :             case HANDLE_PRINTTILEPAGE:
     599           0 :                 if( *pValues >>= bValue )
     600             :                 {
     601           0 :                     if( aPrintOpts.IsPagetile() != bValue)
     602             :                     {
     603           0 :                         aPrintOpts.SetPagetile( bValue );
     604           0 :                         bOptionsChanged = true;
     605             :                     }
     606           0 :                     bOk = true;
     607             :                 }
     608           0 :                 break;
     609             :             case HANDLE_PRINTBOOKLET:
     610           0 :                 if( *pValues >>= bValue )
     611             :                 {
     612           0 :                     if( aPrintOpts.IsBooklet() != bValue)
     613             :                     {
     614           0 :                         aPrintOpts.SetBooklet( bValue );
     615           0 :                         bOptionsChanged = true;
     616             :                     }
     617           0 :                     bOk = true;
     618             :                 }
     619           0 :                 break;
     620             :             case HANDLE_PRINTBOOKLETFRONT:
     621           0 :                 if( *pValues >>= bValue )
     622             :                 {
     623           0 :                     if( aPrintOpts.IsFrontPage() != bValue)
     624             :                     {
     625           0 :                         aPrintOpts.SetFrontPage( bValue );
     626           0 :                         bOptionsChanged = true;
     627             :                     }
     628           0 :                     bOk = true;
     629             :                 }
     630           0 :                 break;
     631             :             case HANDLE_PRINTBOOKLETBACK:
     632           0 :                 if( *pValues >>= bValue )
     633             :                 {
     634           0 :                     if( aPrintOpts.IsBackPage() != bValue)
     635             :                     {
     636           0 :                         aPrintOpts.SetBackPage( bValue );
     637           0 :                         bOptionsChanged = true;
     638             :                     }
     639           0 :                     bOk = true;
     640             :                 }
     641           0 :                 break;
     642             :             case HANDLE_PRINTQUALITY:
     643             :                 {
     644           0 :                     sal_Int32 nValue = 0;
     645           0 :                     if( *pValues >>= nValue )
     646             :                     {
     647           0 :                         if( aPrintOpts.GetOutputQuality() != nValue)
     648             :                         {
     649           0 :                             aPrintOpts.SetOutputQuality( (sal_uInt16)nValue );
     650           0 :                             bOptionsChanged = true;
     651             :                         }
     652           0 :                         bOk = true;
     653             :                     }
     654             :                 }
     655           0 :                 break;
     656             :             case HANDLE_MEASUREUNIT:
     657             :                 {
     658           0 :                     sal_Int16 nValue = 0;
     659           0 :                     if( *pValues >>= nValue )
     660             :                     {
     661             :                         short nFieldUnit;
     662           0 :                         if( SvxMeasureUnitToFieldUnit( nValue, nFieldUnit ) )
     663             :                         {
     664           0 :                             pDoc->SetUIUnit((FieldUnit)nFieldUnit );
     665           0 :                             bOk = true;
     666             :                         }
     667             :                     }
     668             :                 }
     669           0 :                 break;
     670             :             case HANDLE_SCALE_NUM:
     671             :                 {
     672           0 :                     sal_Int32 nValue = 0;
     673           0 :                     if( *pValues >>= nValue )
     674             :                     {
     675           0 :                         Fraction aFract( nValue, pDoc->GetUIScale().GetDenominator() );
     676           0 :                         pDoc->SetUIScale( aFract );
     677           0 :                         bOk = true;
     678           0 :                         bChanged = true;
     679             :                     }
     680             :                 }
     681           0 :                 break;
     682             :             case HANDLE_SCALE_DOM:
     683             :                 {
     684           0 :                     sal_Int32 nValue = 0;
     685           0 :                     if( *pValues >>= nValue )
     686             :                     {
     687           0 :                         Fraction aFract( pDoc->GetUIScale().GetNumerator(), nValue );
     688           0 :                         pDoc->SetUIScale( aFract );
     689           0 :                         bOk = true;
     690           0 :                         bChanged = true;
     691             :                     }
     692             :                 }
     693           0 :                 break;
     694             : 
     695             :             case HANDLE_TABSTOP:
     696             :                 {
     697           0 :                     sal_Int32 nValue = 0;
     698           0 :                     if( (*pValues >>= nValue) && (nValue >= 0) )
     699             :                     {
     700           0 :                         pDoc->SetDefaultTabulator((sal_uInt16)nValue);
     701           0 :                         bOk = true;
     702           0 :                         bChanged = true;
     703             :                     }
     704             :                 }
     705           0 :                 break;
     706             :             case HANDLE_PAGENUMFMT:
     707             :                 {
     708           0 :                     sal_Int32 nValue = 0;
     709           0 :                     if( (*pValues >>= nValue ) && (nValue >= SVX_CHARS_UPPER_LETTER ) && (nValue <= SVX_PAGEDESC) )
     710             :                     {
     711           0 :                         pDoc->SetPageNumType((SvxNumType)nValue);
     712           0 :                         bOk = true;
     713           0 :                         bChanged = true;
     714             :                     }
     715             :                 }
     716           0 :                 break;
     717             :             case HANDLE_PRINTERNAME:
     718             :                 {
     719           0 :                     OUString aPrinterName;
     720           0 :                     if( *pValues >>= aPrinterName )
     721             :                     {
     722           0 :                         bOk = true;
     723           0 :                         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           0 :                     }
     733             :                 }
     734           0 :                 break;
     735             :             case HANDLE_PRINTERJOB:
     736             :                 {
     737           0 :                     Sequence < sal_Int8 > aSequence;
     738           0 :                     if ( *pValues >>= aSequence )
     739             :                     {
     740           0 :                         bOk = true;
     741           0 :                         sal_uInt32 nSize = aSequence.getLength();
     742           0 :                         if( nSize )
     743             :                         {
     744           0 :                             SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
     745           0 :                             aStream.Seek ( STREAM_SEEK_TO_BEGIN );
     746             :                             SfxItemSet* pItemSet;
     747             : 
     748           0 :                             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           0 :                                             0 );
     759             :                             }
     760             : 
     761           0 :                             pPrinter = SfxPrinter::Create ( aStream, pItemSet );
     762             : 
     763           0 :                             MapMode aMM (pPrinter->GetMapMode());
     764           0 :                             aMM.SetMapUnit(MAP_100TH_MM);
     765           0 :                             pPrinter->SetMapMode(aMM);
     766             : 
     767           0 :                             pDocSh->SetPrinter( pPrinter );
     768             : 
     769           0 :                             pPrinter = NULL;
     770             :                         }
     771           0 :                     }
     772             :                 }
     773           0 :                 break;
     774             : 
     775             :             case HANDLE_PARAGRAPHSUMMATION :
     776             :             {
     777           0 :                 sal_Bool bIsSummationOfParagraphs = sal_False;
     778           0 :                 if ( *pValues >>= bIsSummationOfParagraphs )
     779             :                 {
     780           0 :                     bOk = true;
     781           0 :                     bChanged = true;
     782           0 :                     if ( pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     783             :                     {
     784           0 :                         sal_uInt32 nSum = bIsSummationOfParagraphs ? EE_CNTRL_ULSPACESUMMATION : 0;
     785             :                         sal_uInt32 nCntrl;
     786             : 
     787           0 :                         pDoc->SetSummationOfParagraphs( bIsSummationOfParagraphs );
     788           0 :                         SdDrawDocument* pDocument = pDocSh->GetDoc();
     789           0 :                         SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     790           0 :                         nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     791           0 :                         rOutl.SetControlWord( nCntrl | nSum );
     792           0 :                         ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     793           0 :                         if( pOutl )
     794             :                         {
     795           0 :                             nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     796           0 :                             pOutl->SetControlWord( nCntrl | nSum );
     797             :                         }
     798           0 :                         pOutl = pDocument->GetInternalOutliner( sal_False );
     799           0 :                         if( pOutl )
     800             :                         {
     801           0 :                             nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
     802           0 :                             pOutl->SetControlWord( nCntrl | nSum );
     803             :                         }
     804             :                     }
     805             :                 }
     806             :             }
     807           0 :             break;
     808             : 
     809             :             case HANDLE_CHARCOMPRESS:
     810             :             {
     811           0 :                 sal_Int16 nCharCompressType = 0;
     812           0 :                 if( *pValues >>= nCharCompressType )
     813             :                 {
     814           0 :                     bOk = true;
     815             : 
     816           0 :                     pDoc->SetCharCompressType( (sal_uInt16)nCharCompressType );
     817           0 :                     SdDrawDocument* pDocument = pDocSh->GetDoc();
     818           0 :                     SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     819           0 :                     rOutl.SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     820           0 :                     ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     821           0 :                     if( pOutl )
     822             :                     {
     823           0 :                         pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     824             :                     }
     825           0 :                     pOutl = pDocument->GetInternalOutliner( sal_False );
     826           0 :                     if( pOutl )
     827             :                     {
     828           0 :                         pOutl->SetAsianCompressionMode( (sal_uInt16)nCharCompressType );
     829             :                     }
     830             :                 }
     831           0 :                 break;
     832             : 
     833             :             }
     834             :             case HANDLE_ASIANPUNCT:
     835             :             {
     836           0 :                 sal_Bool bAsianPunct = sal_False;
     837           0 :                 if( *pValues >>= bAsianPunct )
     838             :                 {
     839           0 :                     bOk = true;
     840             : 
     841           0 :                     pDoc->SetKernAsianPunctuation( bAsianPunct );
     842           0 :                     SdDrawDocument* pDocument = pDocSh->GetDoc();
     843           0 :                     SdrOutliner& rOutl = pDocument->GetDrawOutliner();
     844           0 :                     rOutl.SetKernAsianPunctuation( bAsianPunct );
     845           0 :                     ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
     846           0 :                     if( pOutl )
     847             :                     {
     848           0 :                         pOutl->SetKernAsianPunctuation( bAsianPunct );
     849             :                     }
     850           0 :                     pOutl = pDocument->GetInternalOutliner( sal_False );
     851           0 :                     if( pOutl )
     852             :                     {
     853           0 :                         pOutl->SetKernAsianPunctuation( bAsianPunct );
     854             :                     }
     855             :                 }
     856           0 :                 break;
     857             : 
     858             :             }
     859             :             case HANDLE_UPDATEFROMTEMPLATE:
     860             :             {
     861           0 :                 bool value = false;
     862           0 :                 if( *pValues >>= value )
     863             :                 {
     864           0 :                     bChanged = ( value != pDocSh->IsQueryLoadTemplate() );
     865           0 :                     pDocSh->SetQueryLoadTemplate( value );
     866           0 :                     bOk = true;
     867             :                 }
     868             :             }
     869           0 :             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           0 :                     (sal_Int16)pDoc->GetPrinterIndependentLayout ();
     878           0 :                 sal_Int16 nValue = 0;
     879           0 :                 if (*pValues >>= nValue)
     880             :                 {
     881           0 :                     pDoc->SetPrinterIndependentLayout (nValue);
     882           0 :                     bChanged = (nValue != nOldValue);
     883           0 :                     bOk = true;
     884             :                 }
     885             :             }
     886           0 :             break;
     887             : 
     888             :             // --> #i33095#
     889             :             case HANDLE_LOAD_READONLY:
     890             :             {
     891           0 :                 bool bNewValue = false;
     892           0 :                 if ( *pValues >>= bNewValue )
     893             :                 {
     894           0 :                     bChanged = ( pDocSh->IsLoadReadonly() != bNewValue );
     895           0 :                     pDocSh->SetLoadReadonly( bNewValue );
     896           0 :                     bOk = true;
     897             :                 }
     898             :             }
     899           0 :             break;
     900             : 
     901             :             case HANDLE_SAVE_VERSION:
     902             :             {
     903           0 :                 bool bNewValue = false;
     904           0 :                 if ( *pValues >>= bNewValue )
     905             :                 {
     906           0 :                     bChanged = ( pDocSh->IsSaveVersionOnClose() != bNewValue );
     907           0 :                     pDocSh->SetSaveVersionOnClose( bNewValue );
     908           0 :                     bOk = true;
     909             :                 }
     910             :             }
     911           0 :             break;
     912             : 
     913             :             case HANDLE_EMBED_FONTS:
     914             :             {
     915           0 :                 bool bNewValue = false;
     916           0 :                 if ( *pValues >>= bNewValue )
     917             :                 {
     918           0 :                     bChanged = ( pDoc->IsUsingEmbededFonts() != bNewValue );
     919           0 :                     pDoc->SetIsUsingEmbededFonts( bNewValue );
     920           0 :                     bOk = true;
     921             :                 }
     922             :             }
     923           0 :             break;
     924             : 
     925             :             default:
     926           0 :                 throw UnknownPropertyException();
     927             :         }
     928             : 
     929           0 :         if( !bOk )
     930           0 :             throw IllegalArgumentException();
     931             :     }
     932             : 
     933           0 :     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           0 :     if( bChanged || bOptionsChanged )
     943           0 :         mxModel->SetModified( sal_True );
     944           0 : }
     945             : 
     946           0 : void DocumentSettings::ExtractURL( XPropertyListType t, Any* pValue )
     947             : {
     948           0 :     XPropertyListRef pList = mxModel->GetDoc()->GetPropertyList( t );
     949           0 :     if( !pList.is() )
     950           0 :         return;
     951             : 
     952           0 :     INetURLObject aPathURL( pList->GetPath() );
     953           0 :     aPathURL.insertName( pList->GetName() );
     954           0 :     aPathURL.setExtension( pList->GetDefaultExt() );
     955           0 :     OUString aPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
     956           0 :     *pValue <<= aPath;
     957             : }
     958             : 
     959             : void
     960           0 : DocumentSettings::_getPropertyValues(
     961             :         const PropertyMapEntry** ppEntries, Any* pValue)
     962             : throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
     963             : {
     964           0 :     ::SolarMutexGuard aGuard;
     965             : 
     966           0 :     SdDrawDocument* pDoc = mxModel->GetDoc();
     967           0 :     ::sd::DrawDocShell* pDocSh = mxModel->GetDocShell();
     968           0 :     if( NULL == pDoc || NULL == pDocSh )
     969             :     {
     970             :         throw RuntimeException("Document or Shell missing",
     971           0 :                 static_cast<OWeakObject *>(this));
     972             :     }
     973             : 
     974           0 :     SdOptionsPrintItem aOptionsPrintItem( ATTR_OPTIONS_PRINT );
     975             : 
     976           0 :     SfxPrinter* pPrinter = pDocSh->GetPrinter( sal_False );
     977           0 :     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           0 :         aOptionsPrintItem.SetOptions( SD_MOD()->GetSdOptions(pDoc->GetDocumentType()) );
     986             :     }
     987           0 :     SdOptionsPrint& aPrintOpts = aOptionsPrintItem.GetOptionsPrint();
     988             : 
     989           0 :     for( ; *ppEntries; ppEntries++, pValue++ )
     990             :     {
     991           0 :         switch( (*ppEntries)->mnHandle )
     992             :         {
     993             :             case HANDLE_COLORTABLEURL:
     994           0 :                 ExtractURL( XCOLOR_LIST, pValue );
     995           0 :                 break;
     996             :             case HANDLE_DASHTABLEURL:
     997           0 :                 ExtractURL( XDASH_LIST, pValue );
     998           0 :                 break;
     999             :             case HANDLE_LINEENDTABLEURL:
    1000           0 :                 ExtractURL( XLINE_END_LIST, pValue );
    1001           0 :                 break;
    1002             :             case HANDLE_HATCHTABLEURL:
    1003           0 :                 ExtractURL( XHATCH_LIST, pValue );
    1004           0 :                 break;
    1005             :             case HANDLE_GRADIENTTABLEURL:
    1006           0 :                 ExtractURL( XGRADIENT_LIST, pValue );
    1007           0 :                 break;
    1008             :             case HANDLE_BITMAPTABLEURL:
    1009           0 :                 ExtractURL( XBITMAP_LIST, pValue );
    1010           0 :                 break;
    1011             :             case HANDLE_FORBIDDENCHARS:
    1012           0 :                 *pValue <<= mxModel->getForbiddenCharsTable();
    1013           0 :                 break;
    1014             :             case HANDLE_APPLYUSERDATA:
    1015           0 :                 *pValue <<= pDocSh->IsUseUserData();
    1016           0 :                 break;
    1017             :             case HANDLE_PRINTDRAWING:
    1018           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsDraw();
    1019           0 :                 break;
    1020             :             case HANDLE_PRINTNOTES:
    1021           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsNotes();
    1022           0 :                 break;
    1023             :             case HANDLE_PRINTHANDOUT:
    1024           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHandout();
    1025           0 :                 break;
    1026             :             case HANDLE_PRINTOUTLINE:
    1027           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsOutline();
    1028           0 :                 break;
    1029             :             case HANDLE_SLIDESPERHANDOUT:
    1030           0 :                 *pValue <<= (sal_Int16)aPrintOpts.GetHandoutPages();
    1031           0 :                 break;
    1032             :             case HANDLE_HANDOUTHORIZONTAL:
    1033           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHandoutHorizontal();
    1034           0 :                 break;
    1035             :             case HANDLE_PRINTPAGENAME:
    1036           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagename();
    1037           0 :                 break;
    1038             :             case HANDLE_PRINTDATE:
    1039           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsDate();
    1040           0 :                 break;
    1041             :             case HANDLE_PRINTTIME:
    1042           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsTime();
    1043           0 :                 break;
    1044             :             case HANDLE_PRINTHIDENPAGES:
    1045           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsHiddenPages();
    1046           0 :                 break;
    1047             :             case HANDLE_PRINTFITPAGE:
    1048           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagesize();
    1049           0 :                 break;
    1050             :             case HANDLE_PRINTTILEPAGE:
    1051           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsPagetile();
    1052           0 :                 break;
    1053             :             case HANDLE_PRINTBOOKLET:
    1054           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsBooklet();
    1055           0 :                 break;
    1056             :             case HANDLE_PRINTBOOKLETFRONT:
    1057           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsFrontPage();
    1058           0 :                 break;
    1059             :             case HANDLE_PRINTBOOKLETBACK:
    1060           0 :                 *pValue <<= (sal_Bool)aPrintOpts.IsBackPage();
    1061           0 :                 break;
    1062             :             case HANDLE_PRINTQUALITY:
    1063           0 :                 *pValue <<= (sal_Int32)aPrintOpts.GetOutputQuality();
    1064           0 :                 break;
    1065             :             case HANDLE_MEASUREUNIT:
    1066             :                 {
    1067             :                     short nMeasure;
    1068           0 :                     SvxFieldUnitToMeasureUnit( (const short)pDoc->GetUIUnit(), nMeasure );
    1069           0 :                     *pValue <<= (sal_Int16)nMeasure;
    1070             :                 }
    1071           0 :                 break;
    1072             :             case HANDLE_SCALE_NUM:
    1073           0 :                 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetNumerator();
    1074           0 :                 break;
    1075             :             case HANDLE_SCALE_DOM:
    1076           0 :                 *pValue <<= (sal_Int32)pDoc->GetUIScale().GetDenominator();
    1077           0 :                 break;
    1078             :             case HANDLE_TABSTOP:
    1079           0 :                 *pValue <<= (sal_Int32)pDoc->GetDefaultTabulator();
    1080           0 :                 break;
    1081             :             case HANDLE_PAGENUMFMT:
    1082           0 :                 *pValue <<= (sal_Int32)pDoc->GetPageNumType();
    1083           0 :                 break;
    1084             :             case HANDLE_PRINTERNAME:
    1085             :                 {
    1086           0 :                     SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
    1087           0 :                     *pValue <<= pTempPrinter ? OUString ( pTempPrinter->GetName()) : OUString();
    1088             :                 }
    1089           0 :                 break;
    1090             :             case HANDLE_PRINTERJOB:
    1091             :                 {
    1092           0 :                     SfxPrinter *pTempPrinter = pDocSh->GetPrinter( sal_False );
    1093           0 :                     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           0 :                         Sequence < sal_Int8 > aSequence;
    1107           0 :                         *pValue <<= aSequence;
    1108             :                     }
    1109             :                 }
    1110           0 :                 break;
    1111             : 
    1112             :             case HANDLE_PARAGRAPHSUMMATION :
    1113             :             {
    1114           0 :                 sal_Bool bIsSummationOfParagraphs = pDoc->IsSummationOfParagraphs();
    1115           0 :                 *pValue <<= bIsSummationOfParagraphs;
    1116             :             }
    1117           0 :             break;
    1118             : 
    1119             :             case HANDLE_CHARCOMPRESS:
    1120             :             {
    1121           0 :                 *pValue <<= (sal_Int16)pDoc->GetCharCompressType();
    1122           0 :                 break;
    1123             :             }
    1124             : 
    1125             :             case HANDLE_ASIANPUNCT:
    1126             :             {
    1127           0 :                 *pValue <<= (sal_Bool)pDoc->IsKernAsianPunctuation();
    1128           0 :                 break;
    1129             :             }
    1130             : 
    1131             :             case HANDLE_UPDATEFROMTEMPLATE:
    1132             :             {
    1133           0 :                 *pValue <<= pDocSh->IsQueryLoadTemplate();
    1134             :             }
    1135           0 :             break;
    1136             : 
    1137             :             case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
    1138             :             {
    1139             :                 sal_Int16 nPrinterIndependentLayout =
    1140           0 :                     (sal_Int16)pDoc->GetPrinterIndependentLayout();
    1141           0 :                 *pValue <<= nPrinterIndependentLayout;
    1142             :             }
    1143           0 :             break;
    1144             : 
    1145             :             // --> #i33095#
    1146             :             case HANDLE_LOAD_READONLY:
    1147             :             {
    1148           0 :                 *pValue <<= pDocSh->IsLoadReadonly();
    1149             :             }
    1150           0 :             break;
    1151             : 
    1152             :             case HANDLE_SAVE_VERSION:
    1153             :             {
    1154           0 :                 *pValue <<= pDocSh->IsSaveVersionOnClose();
    1155             :             }
    1156           0 :             break;
    1157             : 
    1158             :             case HANDLE_EMBED_FONTS:
    1159             :             {
    1160           0 :                 *pValue <<= pDoc->IsUsingEmbededFonts();
    1161             :             }
    1162           0 :             break;
    1163             : 
    1164             :             default:
    1165           0 :                 throw UnknownPropertyException();
    1166             :         }
    1167           0 :     }
    1168           0 : }
    1169             : 
    1170             : // XInterface
    1171           0 : Any SAL_CALL DocumentSettings::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
    1172             : {
    1173           0 :     return WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::queryInterface( aType );
    1174             : }
    1175             : 
    1176           0 : void SAL_CALL DocumentSettings::acquire(  ) throw ()
    1177             : {
    1178           0 :     WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::acquire();
    1179           0 : }
    1180             : 
    1181           0 : void SAL_CALL DocumentSettings::release(  ) throw ()
    1182             : {
    1183           0 :     WeakImplHelper3< XPropertySet, XMultiPropertySet, XServiceInfo >::release();
    1184           0 : }
    1185             : 
    1186             : 
    1187             : // XPropertySet
    1188           0 : Reference< XPropertySetInfo > SAL_CALL DocumentSettings::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
    1189             : {
    1190           0 :     return PropertySetHelper::getPropertySetInfo();
    1191             : }
    1192             : 
    1193           0 : void SAL_CALL DocumentSettings::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
    1194             : {
    1195           0 :     PropertySetHelper::setPropertyValue( aPropertyName, aValue );
    1196           0 : }
    1197             : 
    1198           0 : Any SAL_CALL DocumentSettings::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
    1199             : {
    1200           0 :     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           0 : }
    1278             : 
    1279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10