diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | f47a9d9db3d06927380bb79b04bb6d4721a92d2b (patch) | |
tree | 19d89fdf39c23688415f8884ec433f02fdce7672 /sd/source/ui/unoidl |
initial import
Diffstat (limited to 'sd/source/ui/unoidl')
-rw-r--r-- | sd/source/ui/unoidl/makefile.mk | 127 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unocpres.cxx | 484 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unocpres.hxx | 203 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unohelp.hxx | 93 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unokywds.cxx | 138 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unolayer.cxx | 655 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unolayer.hxx | 185 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 1280 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 965 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.hxx | 141 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 1762 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.hxx | 320 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopback.cxx | 353 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopback.hxx | 133 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unosrch.cxx | 934 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unovwcrs.cxx | 275 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unowcntr.cxx | 166 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unowcntr.hxx | 95 |
18 files changed, 8309 insertions, 0 deletions
diff --git a/sd/source/ui/unoidl/makefile.mk b/sd/source/ui/unoidl/makefile.mk new file mode 100644 index 000000000000..6b1642f30293 --- /dev/null +++ b/sd/source/ui/unoidl/makefile.mk @@ -0,0 +1,127 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + + +PRJ=..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=unoidl +ENABLE_EXCEPTIONS=TRUE +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : sdpre.mk +.INCLUDE : settings.mk +.INCLUDE : sd.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +CXXFILES = $(PRJ)$/util$/sd.cxx \ + unomodel.cxx \ + unopage.cxx \ + unoiview.cxx \ + unolayer.cxx \ + unopres.cxx \ + unocpres.cxx \ + unoobj.cxx \ + unosrch.cxx \ + unowcntr.cxx \ + unogsfm.cxx \ + unogstyl.cxx \ + unopsfm.cxx \ + unopstyl.cxx \ + unokywds.cxx \ + unostyls.cxx \ + unopback.cxx \ + unovwcrs.cxx + +.IF "$(COM)"=="GCC" +NOOPTFILES= $(SLO)$/unowcntr.obj +.ENDIF + +SLOFILES = \ + $(SLO)$/unomodel.obj \ + $(SLO)$/unopage.obj \ + $(SLO)$/unoiview.obj \ + $(SLO)$/unolayer.obj \ + $(SLO)$/unopres.obj \ + $(SLO)$/unocpres.obj \ + $(SLO)$/unoobj.obj \ + $(SLO)$/unosrch.obj \ + $(SLO)$/unowcntr.obj \ + $(SLO)$/unogsfm.obj \ + $(SLO)$/unogstyl.obj \ + $(SLO)$/unopsfm.obj \ + $(SLO)$/unopstyl.obj \ + $(SLO)$/unokywds.obj \ + $(SLO)$/unostyls.obj \ + $(SLO)$/unopback.obj \ + $(SLO)$/unovwcrs.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sd/source/ui/unoidl/unocpres.cxx b/sd/source/ui/unoidl/unocpres.cxx new file mode 100644 index 000000000000..70a12b272d3d --- /dev/null +++ b/sd/source/ui/unoidl/unocpres.cxx @@ -0,0 +1,484 @@ +/************************************************************************* + * + * $RCSfile: unocpres.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +#include <cppuhelper/extract.hxx> + +#include "unohelp.hxx" +#include "unomodel.hxx" +#include "drawdoc.hxx" +#include "unocpres.hxx" +#include "cusshow.hxx" +#include "unopage.hxx" + +using namespace ::rtl; +using namespace ::vos; +using namespace ::com::sun::star; + +SdXCustomPresentation::SdXCustomPresentation() throw() +: mpSdCustomShow(NULL), mpModel(NULL) +{ +} + +SdXCustomPresentation::SdXCustomPresentation( SdCustomShow* pShow, SdXImpressDocument* pMyModel) throw() +: mpSdCustomShow(pShow), mpModel(pMyModel) +{ +} + +SdXCustomPresentation::~SdXCustomPresentation() throw() +{ +} + +UNO3_GETIMPLEMENTATION_IMPL( SdXCustomPresentation ); + +// XServiceInfo +OUString SAL_CALL SdXCustomPresentation::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXCustomPresentation") ); +} + +sal_Bool SAL_CALL SdXCustomPresentation::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdXCustomPresentation::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CustomPresentation") ); + uno::Sequence< OUString > aSeq( &aSN, 1 ); + return aSeq; +} + +// XIndexContainer +void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::Any& Element ) + throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( Index < 0 || Index > mpSdCustomShow->Count() ) + throw lang::IndexOutOfBoundsException(); + + uno::Reference< drawing::XDrawPage > xPage; + if(!::cppu::extractInterface(xPage, Element )) + throw lang::IllegalArgumentException(); + + SdDrawPage* pPage = SdDrawPage::getImplementation( xPage ); + + if(pPage) + { + if( NULL == mpModel ) + mpModel = pPage->GetModel(); + + if( NULL != mpModel && NULL == mpSdCustomShow && mpModel->GetDoc() ) + mpSdCustomShow = new SdCustomShow( mpModel->GetDoc() ); + + mpSdCustomShow->Insert(pPage->GetSdrPage(), Index); + } + + if( mpModel ) + mpModel->SetModified(); +} + +void SAL_CALL SdXCustomPresentation::removeByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpSdCustomShow) + { + uno::Any aPage( getByIndex( Index ) ); + + uno::Reference< drawing::XDrawPage > xPage( *(uno::Reference< drawing::XDrawPage > *)aPage.getValue() ); + SvxDrawPage* pPage = SvxDrawPage::getImplementation( xPage ); + if(pPage) + mpSdCustomShow->Remove(pPage->GetSdrPage()); + } + + if( mpModel ) + mpModel->SetModified(); +} + +// XIndexReplace +void SAL_CALL SdXCustomPresentation::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) + throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + removeByIndex( Index ); + insertByIndex( Index, Element ); +} + +// XElementAccess +uno::Type SAL_CALL SdXCustomPresentation::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE( drawing::XDrawPage ); +} + +sal_Bool SAL_CALL SdXCustomPresentation::hasElements() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return getCount() > 0; +} + +// XIndexAccess +sal_Int32 SAL_CALL SdXCustomPresentation::getCount() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return mpSdCustomShow?mpSdCustomShow->Count():0; +} + +uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( Index < 0 || Index >= mpSdCustomShow->Count() ) + throw lang::IndexOutOfBoundsException(); + + uno::Any aAny; + if(mpSdCustomShow && mpModel ) + { + uno::Reference< drawing::XDrawPage > xRef( mpModel->CreateXDrawPage((SdPage*)mpSdCustomShow->GetObject(Index))); + + aAny <<= xRef; + } + + return aAny; +} + +// XNamed +OUString SAL_CALL SdXCustomPresentation::getName() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpSdCustomShow) + return mpSdCustomShow->GetName(); + + return OUString(); +} + +void SAL_CALL SdXCustomPresentation::setName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpSdCustomShow) + mpSdCustomShow->SetName( aName ); +} + +/*===========================================================================* + * class SdXCustomPresentationAccess : public XCustomPresentationAccess, * + * public UsrObject * + *===========================================================================*/ + +SdXCustomPresentationAccess::SdXCustomPresentationAccess(SdXImpressDocument& rMyModel) throw() +: mrModel(rMyModel) +{ +} + +SdXCustomPresentationAccess::~SdXCustomPresentationAccess() throw() +{ +} + +// XServiceInfo +OUString SAL_CALL SdXCustomPresentationAccess::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXCustomPresentationAccess") ); +} + +sal_Bool SAL_CALL SdXCustomPresentationAccess::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + const OUString aNS( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CustomPresentationAccess") ); + uno::Sequence< OUString > aSeq( &aNS, 1 ); + return aSeq; +} + +// XSingleServiceFactory +uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstance() + throw(uno::Exception, uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xRef( (::cppu::OWeakObject*)new SdXCustomPresentation() ); + return xRef; +} + +uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments ) + throw(uno::Exception, uno::RuntimeException) +{ + return createInstance(); +} + +// XNameContainer +void SAL_CALL SdXCustomPresentationAccess::insertByName( const OUString& aName, const uno::Any& aElement ) + throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + // get the documents custom show list + List* pList; + if(mrModel.GetDoc()) + pList = mrModel.GetDoc()->GetCustomShowList(sal_True); + + // no list, no cookies + if( NULL == pList) + throw uno::RuntimeException(); + + // do we have an container::XIndexContainer? + uno::Reference< container::XIndexContainer > xContainer; + ::cppu::extractInterface( xContainer, aElement); + SdXCustomPresentation* pXShow = SdXCustomPresentation::getImplementation(xContainer); + + if( NULL == pXShow ) + throw lang::IllegalArgumentException(); + + // get the internal custom show from the api wrapper + SdCustomShow* pShow = pXShow->GetSdCustomShow(); + if( NULL == pShow ) + { + pShow = new SdCustomShow( mrModel.GetDoc() ); + pXShow->SetSdCustomShow( pShow ); + } + else + { + if( NULL == pXShow->GetModel() || *pXShow->GetModel() != mrModel ) + throw lang::IllegalArgumentException(); + } + + // give it a name + pShow->SetName( aName); + + // check if this or another customshow with the same name already exists + for( SdCustomShow* pCompare = (SdCustomShow*)pList->First(); + pCompare; + pCompare = (SdCustomShow*)pList->Next() ) + { + if( pCompare == pShow || pCompare->GetName() == pShow->GetName() ) + break; + } + + if( CONTAINER_ENTRY_NOTFOUND != pList->GetPos( pShow ) ) + { + uno::Any aAny; + aAny <<= container::ElementExistException(); + + lang::WrappedTargetException aExp; + aExp.TargetException = aAny; + + throw aExp; + } + + pList->Insert(pShow); + + mrModel.SetModified(); +} + +void SAL_CALL SdXCustomPresentationAccess::removeByName( const OUString& Name ) + throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdCustomShow* pShow = getSdCustomShow(Name); + + List* pList = GetCustomShowList(); + if(pList && pShow) + delete (SdCustomShow*)pList->Remove( pShow ); + else + throw container::NoSuchElementException(); + + mrModel.SetModified(); +} + +// XNameReplace +void SAL_CALL SdXCustomPresentationAccess::replaceByName( const OUString& aName, const uno::Any& aElement ) + throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + removeByName( aName ); + insertByName( aName, aElement ); +} + +// XNameAccess +uno::Any SAL_CALL SdXCustomPresentationAccess::getByName( const OUString& aName ) + throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + SdCustomShow* pShow = getSdCustomShow(aName); + if(pShow) + { + uno::Reference< container::XIndexContainer > xRef( (container::XIndexContainer*)new SdXCustomPresentation(pShow, &mrModel) ); + aAny <<= xRef; + } + else + { + throw container::NoSuchElementException(); + } + + return aAny; +} + +uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getElementNames() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + List* pList = GetCustomShowList(); + const sal_uInt32 nCount = pList?pList->Count():0; + + uno::Sequence< OUString > aSequence( nCount ); + OUString* pStringList = aSequence.getArray(); + + sal_uInt32 nIdx = 0; + while( nIdx < nCount ) + { + const SdCustomShow* pShow = (const SdCustomShow*)pList->GetObject(nIdx); + pStringList[nIdx] = pShow->GetName(); + nIdx++; + } + + return aSequence; +} + + +sal_Bool SAL_CALL SdXCustomPresentationAccess::hasByName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return getSdCustomShow(aName) != NULL; +} + +// XElementAccess +uno::Type SAL_CALL SdXCustomPresentationAccess::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE( container::XIndexContainer ); +} + +sal_Bool SAL_CALL SdXCustomPresentationAccess::hasElements() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + List* pList = GetCustomShowList(); + return pList && pList->Count() > 0; +} + +SdCustomShow * SdXCustomPresentationAccess::getSdCustomShow( const OUString& Name ) const throw() +{ + sal_uInt32 nIdx = 0; + + List* pList = GetCustomShowList(); + const sal_uInt32 nCount = pList?pList->Count():0; + + const String aName( Name ); + + while( nIdx < nCount ) + { + SdCustomShow* pShow = (SdCustomShow*)pList->GetObject(nIdx); + if( pShow->GetName() == aName ) + return pShow; + nIdx++; + } + return NULL; +} + +sal_Int32 SdXCustomPresentationAccess::getSdCustomShowIdx( const OUString& Name ) const throw() +{ + sal_Int32 nIdx = 0; + + List* pList = GetCustomShowList(); + const sal_Int32 nCount = pList?pList->Count():0; + + const String aName( Name ); + + while( nIdx < nCount ) + { + SdCustomShow* pShow = (SdCustomShow*)pList->GetObject(nIdx); + if( pShow->GetName() == aName ) + return nIdx; + nIdx++; + } + return -1; +} + + diff --git a/sd/source/ui/unoidl/unocpres.hxx b/sd/source/ui/unoidl/unocpres.hxx new file mode 100644 index 000000000000..0dc382a1638e --- /dev/null +++ b/sd/source/ui/unoidl/unocpres.hxx @@ -0,0 +1,203 @@ +/************************************************************************* + * + * $RCSfile: unocpres.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SD_UNOCPRES_HXX +#define _SD_UNOCPRES_HXX + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ +#include <com/sun/star/container/XIndexContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +#include <cppuhelper/implbase4.hxx> +#include <unotools/servicehelper.hxx> + +/////////////////////////////////////////////////////////////////////////////// + +class SdXImpressDocument; +class SdView; +class SdDrawViewShell; +class SdCustomShow; + +class SdXCustomPresentation : public ::cppu::WeakImplHelper4< ::com::sun::star::container::XIndexContainer, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XUnoTunnel, + ::com::sun::star::lang::XServiceInfo > +{ +private: + SdCustomShow* mpSdCustomShow; + SdXImpressDocument* mpModel; + +public: + SdXCustomPresentation() throw(); + SdXCustomPresentation( SdCustomShow* mpSdCustomShow, SdXImpressDocument* pMyModel) throw(); + virtual ~SdXCustomPresentation() throw(); + + // internal + void Invalidate() { mpSdCustomShow = NULL; } + SdCustomShow* GetSdCustomShow() const throw() { return mpSdCustomShow; } + void SetSdCustomShow( SdCustomShow* pShow ) throw() { mpSdCustomShow = pShow; } + SdXImpressDocument* GetModel() const throw() { return mpModel; } + + // uno helper + UNO3_GETIMPLEMENTATION_DECL(SdXCustomPresentation) + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); +}; + +// -------------------------------------------------------------------------- + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif + +#include <cppuhelper/implbase3.hxx> + +#include "unomodel.hxx" +#include "drawdoc.hxx" + +class List; + +class SdXCustomPresentationAccess : public ::cppu::WeakImplHelper3< ::com::sun::star::container::XNameContainer, + ::com::sun::star::lang::XSingleServiceFactory, + ::com::sun::star::lang::XServiceInfo > +{ +private: + SdXImpressDocument& mrModel; + + // intern + inline List* GetCustomShowList() const throw(); + sal_Int32 getSdCustomShowIdx( const ::rtl::OUString& Name ) const throw(); + SdCustomShow * getSdCustomShow( const ::rtl::OUString& Name ) const throw(); + +public: + SdXCustomPresentationAccess(SdXImpressDocument& rMyModel) throw(); + ~SdXCustomPresentationAccess() throw(); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XSingleServiceFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); +}; + +inline List * SdXCustomPresentationAccess::GetCustomShowList() const throw() +{ + if(mrModel.GetDoc()) + return mrModel.GetDoc()->GetCustomShowList(sal_False); + else + return NULL; +}; + +#endif + + diff --git a/sd/source/ui/unoidl/unohelp.hxx b/sd/source/ui/unoidl/unohelp.hxx new file mode 100644 index 000000000000..66e3a97a165d --- /dev/null +++ b/sd/source/ui/unoidl/unohelp.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * $RCSfile: unohelp.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +namespace sd +{ +inline sal_Bool any2bool( const ::com::sun::star::uno::Any& rAny, sal_Bool& rBool ) +{ + if( rAny.getValueType() == ::getCppuBooleanType() ) + { + rBool = *(sal_Bool*)rAny.getValue(); + } + else + { + sal_Int32 nValue; + if(!(rAny >>= nValue)) + return sal_False; + rBool = nValue != 0; + } + + return sal_True; +} + +inline void bool2any( sal_Bool bBool, ::com::sun::star::uno::Any& rAny ) +{ + rAny.setValue( &bBool, ::getCppuBooleanType() ); +} + +} + +#define ITYPE( xint ) \ + ::getCppuType((const uno::Reference< xint >*)0) + +#define QUERYINT( xint ) \ + if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ + aAny <<= uno::Reference< xint >(this) diff --git a/sd/source/ui/unoidl/unokywds.cxx b/sd/source/ui/unoidl/unokywds.cxx new file mode 100644 index 000000000000..9659c197c729 --- /dev/null +++ b/sd/source/ui/unoidl/unokywds.cxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * $RCSfile: unokywds.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <unokywds.hxx> + +#define UNO_PREFIX "com.sun.star." + +// SdUnoStyleFamilies +char __FAR_DATA sUNO_SdUnoStyleFamilies[] = "SdUnoStyleFamilies"; +char __FAR_DATA sUNO_Graphic_Style_Family_Name[] = "graphics"; + +// SdUnoPseudoStyleFamily +char __FAR_DATA sUNO_SdUnoPseudoStyleFamily[] = "SdUnoPseudoStyleFamily"; +char __FAR_DATA sUNO_PseudoSheet_Title[] = "title"; +char __FAR_DATA sUNO_PseudoSheet_SubTitle[] = "subtitle"; +char __FAR_DATA sUNO_PseudoSheet_Background[] = "background"; +char __FAR_DATA sUNO_PseudoSheet_Background_Objects[] = "backgroundobjects"; +char __FAR_DATA sUNO_PseudoSheet_Notes[] = "notes"; +char __FAR_DATA sUNO_PseudoSheet_Outline1[] = "outline1"; +char __FAR_DATA sUNO_PseudoSheet_Outline2[] = "outline2"; +char __FAR_DATA sUNO_PseudoSheet_Outline3[] = "outline3"; +char __FAR_DATA sUNO_PseudoSheet_Outline4[] = "outline4"; +char __FAR_DATA sUNO_PseudoSheet_Outline5[] = "outline5"; +char __FAR_DATA sUNO_PseudoSheet_Outline6[] = "outline6"; +char __FAR_DATA sUNO_PseudoSheet_Outline7[] = "outline7"; +char __FAR_DATA sUNO_PseudoSheet_Outline8[] = "outline8"; +char __FAR_DATA sUNO_PseudoSheet_Outline9[] = "outline9"; + +// SdUnoPseudoStyle +char __FAR_DATA sUNO_SdUnoPseudoStyle[] = "SdUnoPseudoStyle"; + +// SdUnoGraphicStyleFamily +char __FAR_DATA sUNO_SdUnoGraphicStyleFamily[] = "SdUnoGraphicStyleFamily"; +char __FAR_DATA sUNO_StyleName_standard[] = "standard"; +char __FAR_DATA sUNO_StyleName_objwitharrow[] = "objectwitharrow"; +char __FAR_DATA sUNO_StyleName_objwithshadow[] = "objectwithshadow"; +char __FAR_DATA sUNO_StyleName_objwithoutfill[] = "objectwithoutfill"; +char __FAR_DATA sUNO_StyleName_text[] = "text"; +char __FAR_DATA sUNO_StyleName_textbody[] = "textbody"; +char __FAR_DATA sUNO_StyleName_textbodyjust[] = "textbodyjustfied"; +char __FAR_DATA sUNO_StyleName_textbodyindent[] = "textbodyindent"; +char __FAR_DATA sUNO_StyleName_title[] = "title"; +char __FAR_DATA sUNO_StyleName_title1[] = "title1"; +char __FAR_DATA sUNO_StyleName_title2[] = "title2"; +char __FAR_DATA sUNO_StyleName_headline[] = "headline"; +char __FAR_DATA sUNO_StyleName_headline1[] = "headline1"; +char __FAR_DATA sUNO_StyleName_headline2[] = "headline2"; +char __FAR_DATA sUNO_StyleName_measure[] = "measure"; + +// SdUnoGraphicStyle +char __FAR_DATA sUNO_SdUnoGraphicStyle[] = "SdUnoGraphicStyle"; + +// SdUnoPageBackground +char __FAR_DATA sUNO_SdUnoPageBackground[] = "SdUnoPageBackground"; + +// SdLayerManager +char __FAR_DATA sUNO_SdLayerManager[] = "SdUnoLayerManager"; + +// SdLayer +char __FAR_DATA sUNO_SdLayer[] = "SdUnoLayer"; + +// SdXShape +char __FAR_DATA sUNO_shape_style[] = "Style"; + +// services +char __FAR_DATA sUNO_Service_StyleFamily[] = UNO_PREFIX "style.StyleFamily"; +char __FAR_DATA sUNO_Service_StyleFamilies[] = UNO_PREFIX "style.StyleFamilies"; +char __FAR_DATA sUNO_Service_Style[] = UNO_PREFIX "style.Style"; +char __FAR_DATA sUNO_Service_AreaShapeDescriptor[] = UNO_PREFIX "drawing.AreaShapeDescriptor"; +char __FAR_DATA sUNO_Service_LineShapeDescriptor[] = UNO_PREFIX "drawing.LineShapeDescriptor"; +char __FAR_DATA sUNO_Service_ParagraphProperties[] = UNO_PREFIX "style.ParagraphProperties"; +char __FAR_DATA sUNO_Service_CharacterProperties[] = UNO_PREFIX "style.CharacterProperties"; +char __FAR_DATA sUNO_Service_Text[] = UNO_PREFIX "drawing.Text"; +char __FAR_DATA sUNO_Service_PageBackground[] = UNO_PREFIX "drawing.PageBackground"; +char __FAR_DATA sUNO_Service_DrawingLayer[] = UNO_PREFIX "drawing.Layer"; +char __FAR_DATA sUNO_Service_DrawingLayerManager[] = UNO_PREFIX "drawing.LayerManager"; + +// properties +char __FAR_DATA sUNO_Prop_Background[] = "Background"; + diff --git a/sd/source/ui/unoidl/unolayer.cxx b/sd/source/ui/unoidl/unolayer.cxx new file mode 100644 index 000000000000..bb3e511b3a9c --- /dev/null +++ b/sd/source/ui/unoidl/unolayer.cxx @@ -0,0 +1,655 @@ +/************************************************************************* + * + * $RCSfile: unolayer.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif + +#include <svx/svdpagv.hxx> +#include <svx/unoshape.hxx> +#include <svx/svdobj.hxx> + +// folgende fuer InsertSdPage() +#ifndef _SVDLAYER_HXX //autogen +#include <svx/svdlayer.hxx> +#endif + +#ifndef _SD_DOCSHELL_HXX +#include <docshell.hxx> +#endif +#ifndef _DRAWDOC_HXX +#include <drawdoc.hxx> +#endif +#ifndef _UNOMODEL_HXX +#include <unomodel.hxx> +#endif +#ifndef _UNOLAYER_HXX +#include <unolayer.hxx> +#endif + +#ifndef _SD_UNOPRNMS_HXX +#include "unoprnms.hxx" +#endif + +#include "unohelp.hxx" +#include "frmview.hxx" +#include "drviewsh.hxx" +#include "sdview.hxx" + +#include "viewshel.hxx" +#include "app.hrc" +#include "strings.hrc" +#include "sdresid.hxx" + +#include "unokywds.hxx" + +using namespace ::rtl; +using namespace ::vos; +using namespace ::com::sun::star; + +//============================================================================= +// class SdLayer +//============================================================================= + +#define WID_LAYER_LOCKED 1 +#define WID_LAYER_PRINTABLE 2 +#define WID_LAYER_VISIBLE 3 +#define WID_LAYER_NAME 4 + +const SfxItemPropertyMap* ImplGetSdLayerPropertyMap() +{ + static const SfxItemPropertyMap aSdLayerPropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_LAYER_LOCKED), WID_LAYER_LOCKED, &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_LAYER_PRINTABLE), WID_LAYER_PRINTABLE,&::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_LAYER_VISIBLE), WID_LAYER_VISIBLE, &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_LAYER_NAME), WID_LAYER_NAME, &::getCppuType((const OUString*)0), 0, 0 }, + { 0,0,0,0,0} + }; + + return aSdLayerPropertyMap_Impl; +} + +/** */ +SdLayer::SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw() +: aPropSet(ImplGetSdLayerPropertyMap()), + pLayerManager(pLayerManager_), pLayer(pSdrLayer_), + mxLayerManager(pLayerManager_) +{ +} + +/** */ +SdLayer::~SdLayer() throw() +{ +} + +// uno helper +UNO3_GETIMPLEMENTATION_IMPL( SdLayer ); + +// XServiceInfo +OUString SAL_CALL SdLayer::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( OUString::createFromAscii(sUNO_SdLayer) ); +} + +sal_Bool SAL_CALL SdLayer::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdLayer::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayer) ); + uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +// beans::XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL SdLayer::getPropertySetInfo( ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return aPropSet.getPropertySetInfo(); +} + +void SAL_CALL SdLayer::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(pLayer == NULL || pLayerManager == NULL) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(aPropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_LAYER_LOCKED: + { + sal_Bool bValue; + if(!sd::any2bool( aValue, bValue )) + throw lang::IllegalArgumentException(); + set( LOCKED, bValue ); + break; + } + case WID_LAYER_PRINTABLE: + { + sal_Bool bValue; + if(!sd::any2bool( aValue, bValue )) + throw lang::IllegalArgumentException(); + set( PRINTABLE, bValue ); + break; + } + case WID_LAYER_VISIBLE: + { + sal_Bool bValue; + if(!sd::any2bool( aValue, bValue )) + throw lang::IllegalArgumentException(); + set( VISIBLE, bValue ); + break; + } + case WID_LAYER_NAME: + { + OUString aName; + if(!(aValue >>= aName)) + throw lang::IllegalArgumentException(); + + pLayer->SetName(aName); + pLayerManager->UpdateLayerView(); + break; + } + default: + throw beans::UnknownPropertyException(); + break; + } + + if( pLayerManager->GetDocShell() ) + pLayerManager->GetDocShell()->SetModified(); +} + +uno::Any SAL_CALL SdLayer::getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(pLayer == NULL || pLayerManager == NULL) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(PropertyName); + + uno::Any aValue; + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_LAYER_LOCKED: + sd::bool2any( get( LOCKED ), aValue ); + break; + case WID_LAYER_PRINTABLE: + sd::bool2any( get( PRINTABLE ), aValue ); + break; + case WID_LAYER_VISIBLE: + sd::bool2any( get( VISIBLE ), aValue ); + break; + case WID_LAYER_NAME: + { + OUString aRet( pLayer->GetName() ); + aValue <<= aRet; + break; + } + default: + throw beans::UnknownPropertyException(); + break; + } + + return aValue; +} + +void SAL_CALL SdLayer::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdLayer::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdLayer::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdLayer::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} + +/** */ +sal_Bool SdLayer::get( LayerAttribute what ) throw() +{ + if(pLayer&&pLayerManager) + { + // Versuch 1. ist eine beliebige Seite geoeffnet? + SdView *pView = pLayerManager->GetView(); + SdrPageView* pSdrPageView = NULL; + if(pView) + pSdrPageView = pView->GetPageViewPvNum(0); + + if(pSdrPageView) + { + String aLayerName = pLayer->GetName(); + switch(what) + { + case VISIBLE: return pSdrPageView->IsLayerVisible(aLayerName); + case PRINTABLE: return pSdrPageView->IsLayerPrintable(aLayerName); + case LOCKED: return pSdrPageView->IsLayerLocked(aLayerName); + } + } + + // Versuch 2. Info von der FrameView besorgen + if(pLayerManager->GetDocShell()) + { + FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); + if(pFrameView) + switch(what) + { + case VISIBLE: return pFrameView->GetVisibleLayers().IsSet(pLayer->GetID()); + case PRINTABLE: return pFrameView->GetPrintableLayers().IsSet(pLayer->GetID()); + case LOCKED: return pFrameView->GetLockedLayers().IsSet(pLayer->GetID()); + } + } + + } + return sal_False; //TODO: uno::Exception? +} + +void SdLayer::set( LayerAttribute what, sal_Bool flag ) throw() +{ + if(pLayer&&pLayerManager) + { + // Versuch 1. ist eine beliebige Seite geoeffnet? + SdView *pView = pLayerManager->GetView(); + SdrPageView* pSdrPageView = NULL; + if(pView) + pSdrPageView = pView->GetPageViewPvNum(0); + + if(pSdrPageView) + { + String aLayerName(pLayer->GetName()); + switch(what) + { + case VISIBLE: pSdrPageView->SetLayerVisible(aLayerName,flag); + break; + case PRINTABLE: pSdrPageView->SetLayerPrintable(aLayerName,flag); + break; + case LOCKED: pSdrPageView->SetLayerLocked(aLayerName,flag); + break; + } + } + + // Versuch 2. Info von der FrameView besorgen + if(pLayerManager->GetDocShell()) + { + FrameView *pFrameView = pLayerManager->GetDocShell()->GetFrameView(); + + if(pFrameView) + { + SetOfByte aNewLayers; + switch(what) + { + case VISIBLE: aNewLayers = pFrameView->GetVisibleLayers(); + break; + case PRINTABLE: aNewLayers = pFrameView->GetPrintableLayers(); + break; + case LOCKED: aNewLayers = pFrameView->GetLockedLayers(); + break; + } + + aNewLayers.Set(pLayer->GetID(),flag); + + switch(what) + { + case VISIBLE: pFrameView->SetVisibleLayers(aNewLayers); + break; + case PRINTABLE: pFrameView->SetPrintableLayers(aNewLayers); + break; + case LOCKED: pFrameView->SetLockedLayers(aNewLayers); + break; + } + return; + } + } + } + //TODO: uno::Exception? +} + +//============================================================================= +// class SdLayerManager +//============================================================================= + +/** */ +SdLayerManager::SdLayerManager( SdXImpressDocument& rMyModel ) throw() +:rModel(rMyModel) +{ +} + +/** */ +SdLayerManager::~SdLayerManager() throw() +{ +} + +// uno helper +UNO3_GETIMPLEMENTATION_IMPL( SdLayerManager ); + +// XServiceInfo +OUString SAL_CALL SdLayerManager::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( OUString::createFromAscii(sUNO_SdLayerManager) ); +} + +sal_Bool SAL_CALL SdLayerManager::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdLayerManager::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + OUString aServiceName( OUString::createFromAscii(sUNO_Service_DrawingLayerManager) ); + uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +// XLayerManager +uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::insertNewByIndex( sal_Int32 nIndex ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XLayer > xLayer; + + if( rModel.pDoc ) + { + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); + sal_uInt16 nLayer = nLayerCnt - 2 + 1; + String aLayerName; + + // Ueberpruefung auf schon vorhandene Namen + while( aLayerName.Len()==0 || rLayerAdmin.GetLayer( aLayerName, sal_False) ) + { + aLayerName = String(SdResId(STR_LAYER)); + aLayerName += String::CreateFromInt32( (sal_Int32)nLayer ); + nLayer++; + } + + if(rModel.pDocShell) + { + SdViewShell* pViewSh = rModel.pDocShell->GetViewShell(); + if(pViewSh) + { + + SdrLayer* pNewLayer = pViewSh->GetView()->InsertNewLayer(aLayerName, nIndex ); + xLayer = new SdLayer( this, pNewLayer ); + + rModel.SetModified(); + } + } + } + return xLayer; +} + +void SAL_CALL SdLayerManager::remove( const uno::Reference< drawing::XLayer >& xLayer ) + throw(container::NoSuchElementException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdLayer* pSdLayer = SdLayer::getImplementation(xLayer); + + if(pSdLayer && GetView()) + { + const SdrLayer* pSdrLayer = pSdLayer->GetSdrLayer(); + GetView()->DeleteLayer( pSdrLayer->GetName() ); + + UpdateLayerView(); + } + + rModel.SetModified(); +} + +void SAL_CALL SdLayerManager::attachShapeToLayer( const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XLayer >& xLayer ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(rModel.pDoc==NULL) + return; + + SdLayer* pSdLayer = SdLayer::getImplementation(xLayer); + SdrLayer* pSdrLayer = pSdLayer?pSdLayer->GetSdrLayer():NULL; + if(pSdrLayer==NULL) + return; + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + SdrObject* pSdrObject = pShape?pShape->GetSdrObject():NULL; + + if(pSdrObject && pSdrLayer ) + pSdrObject->SetLayer(pSdrLayer->GetID()); + + rModel.SetModified(); +} + +uno::Reference< drawing::XLayer > SAL_CALL SdLayerManager::getLayerForShape( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XLayer > xLayer; + + if(rModel.pDoc) + { + SvxShape* pShape = SvxShape::getImplementation( xShape ); + SdrObject* pObj = pShape?pShape->GetSdrObject():NULL; + if(pObj) + { + SdrLayerID aId = pObj->GetLayer(); + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + xLayer = new SdLayer(this,rLayerAdmin.GetLayerPerID(aId)); + } + } + return xLayer; +} + +// XIndexAccess +sal_Int32 SAL_CALL SdLayerManager::getCount() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( rModel.pDoc ) + { + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + return rLayerAdmin.GetLayerCount(); + } + + return 0; +} + +uno::Any SAL_CALL SdLayerManager::getByIndex( sal_Int32 nLayer ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( nLayer >= getCount() || nLayer < 0 ) + throw lang::IndexOutOfBoundsException(); + + uno::Any aAny; + + if( rModel.pDoc ) + { + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + uno::Reference< drawing::XLayer > xLM = new SdLayer( (SdLayerManager*)this, rLayerAdmin.GetLayer(nLayer) ); + aAny <<= xLM; + } + return aAny; +} + + +// XNameAccess +uno::Any SAL_CALL SdLayerManager::getByName( const OUString& aName ) + throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XLayer > xLayer; + + uno::Any aAny; + + if( rModel.pDoc ) + { + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + SdrLayer* pLayer = rLayerAdmin.GetLayer( aName, FALSE ); + if( pLayer == NULL ) + throw container::NoSuchElementException(); + + xLayer = new SdLayer( (SdLayerManager*)this, pLayer ); + aAny <<= xLayer; + return aAny; + } + + throw container::NoSuchElementException(); + return aAny; +} + +uno::Sequence< OUString > SAL_CALL SdLayerManager::getElementNames() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + const sal_uInt16 nLayerCount = rLayerAdmin.GetLayerCount(); + + uno::Sequence< OUString > aSeq( nLayerCount ); + + OUString* pStrings = aSeq.getArray(); + SdrLayer* pLayer; + + for( sal_uInt16 nLayer = 0; nLayer < nLayerCount; nLayer++ ) + { + pLayer = rLayerAdmin.GetLayer( nLayer ); + if( pLayer ) + *pStrings++ = pLayer->GetName(); + } + + return aSeq; +} + +sal_Bool SAL_CALL SdLayerManager::hasByName( const OUString& aName ) throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdrLayerAdmin& rLayerAdmin = rModel.pDoc->GetLayerAdmin(); + + return NULL != rLayerAdmin.GetLayer( aName, FALSE ); +} + +// XElementAccess +uno::Type SAL_CALL SdLayerManager::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE( drawing::XLayer ); +} + +sal_Bool SAL_CALL SdLayerManager::hasElements() throw(uno::RuntimeException) +{ + return getCount() > 0; +} + +/** Falls an den Layern was geaendert wurde sorgt diese Methode dafuer, das + die Aenderungen auch in der sdbcx::View sichtbar gemacht werden */ +void SdLayerManager::UpdateLayerView( sal_Bool modify ) const throw() +{ + if(rModel.pDocShell) + { + SdDrawViewShell* pDrViewSh = + PTR_CAST(SdDrawViewShell, rModel.pDocShell->GetViewShell()); + + if(pDrViewSh) + { + sal_Bool bLayerMode = pDrViewSh->GetLayerMode(); + pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), !bLayerMode); + pDrViewSh->ChangeEditMode(pDrViewSh->GetEditMode(), bLayerMode); + } + + if(modify) + rModel.pDoc->SetChanged(sal_True); + } +} + +/** */ +SdView* SdLayerManager::GetView() const throw() +{ + if( rModel.pDocShell ) + { + SdViewShell* pViewSh = rModel.pDocShell->GetViewShell(); + if(pViewSh) + return pViewSh->GetView(); + } + return NULL; +} + + + diff --git a/sd/source/ui/unoidl/unolayer.hxx b/sd/source/ui/unoidl/unolayer.hxx new file mode 100644 index 000000000000..fbed752e7e00 --- /dev/null +++ b/sd/source/ui/unoidl/unolayer.hxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * $RCSfile: unolayer.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNOLAYER_HXX +#define _UNOLAYER_HXX + +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_XLAYER_HPP_ +#include <com/sun/star/drawing/XLayer.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_XLAYERMANAGER_HPP_ +#include <com/sun/star/drawing/XLayerManager.hpp> +#endif + +#include <cppuhelper/implbase3.hxx> +#include <unotools/servicehelper.hxx> + +#include <unomodel.hxx> + +class SdrLayer; +class SdView; +class SdLayerManager; +class SdXImpressDocument; + +enum LayerAttribute { VISIBLE, PRINTABLE, LOCKED }; + +/*********************************************************************** +* * +***********************************************************************/ +class SdLayer : public ::cppu::WeakImplHelper3< ::com::sun::star::drawing::XLayer, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XUnoTunnel> +{ +private: + SdLayerManager* pLayerManager; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayerManager > mxLayerManager; + + SdrLayer* pLayer; + SvxItemPropertySet aPropSet; + + sal_Bool get( LayerAttribute what ) throw(); + void set( LayerAttribute what, sal_Bool flag ) throw(); + +public: + SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw(); + virtual ~SdLayer() throw(); + + // intern + SdrLayer* GetSdrLayer() const throw() { return pLayer; } + + // uno helper + UNO3_GETIMPLEMENTATION_DECL( SdLayer ) + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::beans::XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); +}; + +/*********************************************************************** +* * +***********************************************************************/ + +#include <cppuhelper/implbase4.hxx> + +class SdLayerManager : public ::cppu::WeakImplHelper4< ::com::sun::star::drawing::XLayerManager, + ::com::sun::star::container::XNameAccess, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XUnoTunnel > +{ + friend class SdLayer; + +private: + SdXImpressDocument& rModel; + + SdView* GetView() const throw(); + SdDrawDocShell* GetDocShell() const throw() { return rModel.pDocShell; } + + void UpdateLayerView( sal_Bool modify = sal_True ) const throw(); + +public: + SdLayerManager( SdXImpressDocument& rMyModel ) throw(); + virtual ~SdLayerManager() throw(); + + // uno helper + UNO3_GETIMPLEMENTATION_DECL( SdLayerManager ) + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XLayerManager + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL attachShapeToLayer( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL getLayerForShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); +}; + +#endif + + diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx new file mode 100644 index 000000000000..b00f9ec0c17f --- /dev/null +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -0,0 +1,1280 @@ +/************************************************************************* + * + * $RCSfile: unomodel.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_ +#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif +#ifndef _COM_SUN_STAR_STYLE_XSTYLE_HPP_ +#include <com/sun/star/style/XStyle.hpp> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif + +#include <rtl/uuid.h> +#include <rtl/memory.h> + +#ifndef _UNOMODEL_HXX +#include <unomodel.hxx> +#endif + +#ifndef _SFXDISPATCH_HXX //autogen +#include <sfx2/dispatch.hxx> +#endif +#ifndef _SFX_BINDINGS_HXX +#include <sfx2/bindings.hxx> +#endif + +// folgende fuer InsertSdPage() +#ifndef _SVDLAYER_HXX //autogen +#include <svx/svdlayer.hxx> +#endif +#ifndef _SVDSOB_HXX //autogen +#include <svx/svdsob.hxx> +#endif +#ifndef _SVX_UNOAPI_HXX_ +#include <svx/unoapi.hxx> +#endif + +#ifndef _SVX_UNOFILL_HXX_ +#include <svx/unofill.hxx> +#endif + +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif + +#ifndef _UNO_LINGU_HXX +#include <svx/unolingu.hxx> +#endif + +#include <svx/unoshape.hxx> +#include <svx/unonrule.hxx> + +#include <docshell.hxx> +#include <drawdoc.hxx> +#include <glob.hrc> +#include <sdresid.hxx> +#include <sdpage.hxx> + +#include "unohelp.hxx" +#include <unolayer.hxx> +#include <unoprnms.hxx> +#include <unopage.hxx> +#include <unopres.hxx> +#include <unocpres.hxx> +#include <unoobj.hxx> +#include <unostyls.hxx> +#include <stlpool.hxx> +#include <unogstyl.hxx> + +#include "viewshel.hxx" +#include "app.hrc" + +using namespace ::osl; +using namespace ::rtl; +using namespace ::vos; +using namespace ::cppu; +using namespace ::com::sun::star; + +#define WID_MODEL_LANGUAGE 1 +#define WID_MODEL_TABSTOP 2 + +const SfxItemPropertyMap* ImplGetDrawModelPropertyMap() +{ + // Achtung: Der erste Parameter MUSS sortiert vorliegen !!! + const static SfxItemPropertyMap aDrawModelPropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_MODEL_LANGUAGE), WID_MODEL_LANGUAGE, &::getCppuType((const lang::Locale*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_MODEL_TABSTOP), WID_MODEL_TABSTOP, &::getCppuType((const sal_Int32*)0), 0, 0}, + { 0,0,0,0,0 } + }; + + return aDrawModelPropertyMap_Impl; +} + +// this ctor is used from the DocShell +SdXImpressDocument::SdXImpressDocument( SdDrawDocShell* pShell ) throw() +: SfxBaseModel( pShell ), + pDocShell( pShell ), + aPropSet( ImplGetDrawModelPropertyMap() ) +{ + if( pDocShell ) + { + pDoc = pDocShell->GetDoc(); + StartListening( *pDoc ); + } + else + { + DBG_ERROR("DocShell is invalid"); + } + + mbImpressDoc = pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS; +} + +/*********************************************************************** +* * +***********************************************************************/ +SdXImpressDocument::~SdXImpressDocument() throw() +{ + if( pDoc ) + EndListening( *pDoc ); +} + +// uno helper + + +/****************************************************************************** +* Erzeugt anhand der uebergebennen SdPage eine SdDrawPage. Wurde fuer diese * +* SdPage bereits eine SdDrawPage erzeugt, wird keine neue SdDrawPage erzeug. * +******************************************************************************/ +uno::Reference< drawing::XDrawPage > SdXImpressDocument::CreateXDrawPage( SdPage* pPage ) throw() +{ + DBG_ASSERT(pPage,"SdXImpressDocument::CreateXDrawPage( NULL? )"); + + uno::Reference< drawing::XDrawPage > xDrawPage; + + if(pPage) + { + xDrawPage = SvxDrawPage::GetPageForSdrPage(pPage); + + if(!xDrawPage.is()) + { + if(pPage->IsMasterPage()) + { + xDrawPage = (presentation::XPresentationPage*)new SdMasterPage( this, pPage ); + } + else + { + xDrawPage = (SvxDrawPage*)new SdDrawPage( this, pPage ); + } + } + } + + return xDrawPage; +} + +UNO3_GETIMPLEMENTATION_IMPL( SdXImpressDocument ); + +// XInterface +uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT(lang::XServiceInfo); + else QUERYINT(beans::XPropertySet); + else QUERYINT(lang::XMultiServiceFactory); + else QUERYINT(drawing::XDrawPageDuplicator); + else QUERYINT(drawing::XLayerSupplier); + else QUERYINT(drawing::XMasterPagesSupplier); + else QUERYINT(drawing::XDrawPagesSupplier); + else QUERYINT(document::XLinkTargetSupplier); + else QUERYINT(style::XStyleFamiliesSupplier); + else if( mbImpressDoc && rType == ITYPE(presentation::XPresentationSupplier) ) + aAny <<= uno::Reference< presentation::XPresentationSupplier >(this); + else if( mbImpressDoc && rType == ITYPE(presentation::XCustomPresentationSupplier) ) + aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this); + else + return SfxBaseModel::queryInterface( rType ); + + return aAny; +} + +void SAL_CALL SdXImpressDocument::acquire() throw(uno::RuntimeException) +{ + SfxBaseModel::acquire(); +} + +void SAL_CALL SdXImpressDocument::release() throw(uno::RuntimeException) +{ + SfxBaseModel::release(); +} + +// XTypeProvider +uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) throw(uno::RuntimeException) +{ + if( maTypeSequence.getLength() == 0 ) + { + const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() ); + const sal_Int32 nBaseTypes = aBaseTypes.getLength(); + const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); + + const sal_Int32 nOwnTypes = mbImpressDoc ? 11 : 9; // !DANGER! Keep this updated! + + maTypeSequence.realloc( nBaseTypes + nOwnTypes ); + uno::Type* pTypes = maTypeSequence.getArray(); + + *pTypes++ = ITYPE(beans::XPropertySet); + *pTypes++ = ITYPE(lang::XServiceInfo); + *pTypes++ = ITYPE(lang::XMultiServiceFactory); + *pTypes++ = ITYPE(drawing::XDrawPageDuplicator); + *pTypes++ = ITYPE(drawing::XLayerSupplier); + *pTypes++ = ITYPE(drawing::XMasterPagesSupplier); + *pTypes++ = ITYPE(drawing::XDrawPagesSupplier); + *pTypes++ = ITYPE(document::XLinkTargetSupplier); + *pTypes++ = ITYPE(style::XStyleFamiliesSupplier); + if( mbImpressDoc ) + { + *pTypes++ = ITYPE(presentation::XPresentationSupplier); + *pTypes++ = ITYPE(presentation::XCustomPresentationSupplier); + } + + for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) + *pTypes++ = *pBaseTypes++; + } + + return maTypeSequence; +} + +uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId( ) throw(uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +/*********************************************************************** +* * +***********************************************************************/ +void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); + + if( pSdrHint ) + { + if( pSdrHint->GetKind() == HINT_MODELCLEARED ) + { + pDoc = NULL; + pDocShell = NULL; + } + } + else + { + const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint ); + + // ist unser SdDrawDocument gerade gestorben? + if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING) + { + // yup, also schnell ein neues erfragen + if( pDocShell ) + { + SdDrawDocument *pNewDoc = pDocShell->GetDoc(); + + // ist ueberhaupt ein neues da? + if( pNewDoc != pDoc ) + { + pDoc = pNewDoc; + if(pDoc) + StartListening( *pDoc ); + } + } + } + } +} + +/****************************************************************************** +* * +******************************************************************************/ +SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, sal_Bool bDuplicate ) throw() +{ + sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD ); + SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); + BYTE aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); + BYTE aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); + + // Hier wird die Seite ermittelt, hinter der eingefuegt werden soll + SdPage* pPreviousStandardPage = pDoc->GetSdPage( Min( (sal_uInt16)(nPageCount - 1), nPage ), PK_STANDARD ); + + sal_uInt16 nPos = 0; + SetOfByte aVisibleLayers = pPreviousStandardPage->GetMasterPageVisibleLayers( nPos ); + sal_Bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd ); + sal_Bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj ); + + // AutoLayouts muessen fertig sein + pDoc->StopWorkStartupDelay(); + + /************************************************************** + * Es wird stets zuerst eine Standardseite und dann eine + * Notizseite erzeugt. Es ist sichergestellt, dass auf eine + * Standardseite stets die zugehoerige Notizseite folgt. + **************************************************************/ + + sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2; + SdPage* pPreviousNotesPage = (SdPage*) pDoc->GetPage( nStandardPageNum - 1 ); + sal_uInt16 nNotesPageNum = nStandardPageNum + 1; + String aStandardPageName; + String aNotesPageName; + AutoLayout eStandardLayout = pPreviousStandardPage->GetAutoLayout(); + AutoLayout eNotesLayout = pPreviousNotesPage->GetAutoLayout(); + + /************************************************************** + * Standardseite + **************************************************************/ + SdPage* pStandardPage = NULL; + + if( bDuplicate ) + pStandardPage = (SdPage*) pPreviousStandardPage->Clone(); + else + pStandardPage = (SdPage*) pDoc->AllocPage(sal_False); + + pStandardPage->SetSize( pPreviousStandardPage->GetSize() ); + pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(), + pPreviousStandardPage->GetUppBorder(), + pPreviousStandardPage->GetRgtBorder(), + pPreviousStandardPage->GetLwrBorder() ); + + pStandardPage->SetName(aStandardPageName); + + // Seite hinter aktueller Seite einfuegen + pDoc->InsertPage(pStandardPage, nStandardPageNum); + + if( !bDuplicate ) + { + // MasterPage der aktuellen Seite verwenden + sal_uInt16 nPgNum = pPreviousStandardPage->GetMasterPageNum(nPos=0); + pStandardPage->InsertMasterPage(nPgNum); + pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() ); + pStandardPage->SetAutoLayout(eStandardLayout, sal_True); + } + + aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); + aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); + aVisibleLayers.Set(aBckgrnd, bIsPageBack); + aVisibleLayers.Set(aBckgrndObj, bIsPageObj); + pStandardPage->SetMasterPageVisibleLayers(aVisibleLayers, nPos=0); + + /************************************************************** + * Notizseite + **************************************************************/ + SdPage* pNotesPage = NULL; + + if( bDuplicate ) + pNotesPage = (SdPage*) pPreviousNotesPage->Clone(); + else + pNotesPage = (SdPage*) pDoc->AllocPage(sal_False); + + pNotesPage->SetSize( pPreviousNotesPage->GetSize() ); + pNotesPage->SetBorder( pPreviousNotesPage->GetLftBorder(), + pPreviousNotesPage->GetUppBorder(), + pPreviousNotesPage->GetRgtBorder(), + pPreviousNotesPage->GetLwrBorder() ); + pNotesPage->SetName(aNotesPageName); + pNotesPage->SetPageKind(PK_NOTES); + + // Seite hinter aktueller Seite einfuegen + pDoc->InsertPage(pNotesPage, nNotesPageNum); + + if( !bDuplicate ) + { + // MasterPage der aktuellen Seite verwenden + sal_uInt16 nPgNum = pPreviousNotesPage->GetMasterPageNum(nPos=0); + pNotesPage->InsertMasterPage(nPgNum); + pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() ); + pNotesPage->SetAutoLayout(eNotesLayout, sal_True); + } + + SetModified(); + + return( pStandardPage ); +} + +void SdXImpressDocument::SetModified( sal_Bool bModified /* = sal_True */ ) throw() +{ + if( pDoc ) + pDoc->SetChanged( bModified ); +} + + +// XDrawPageDuplicator +uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XDrawPage > xDrawPage; + + if( pDoc ) + { + // pPage von xPage besorgen und dann die Id (nPos )ermitteln + SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage ); + if( pSvxPage ) + { + SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage(); + sal_uInt16 nPos = pPage->GetPageNum(); + nPos = ( nPos - 1 ) / 2; + pPage = InsertSdPage( nPos, sal_True ); + if( pPage ) + return CreateXDrawPage( pPage ); + } + } + return uno::Reference< drawing::XDrawPage >(); +} + + +// XDrawPagesSupplier +uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages() + throw(uno::RuntimeException) +{ + uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess ); + + if( !xDrawPages.is() ) + mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SdDrawPagesAccess(*this); + + return xDrawPages; +} + +// XMasterPagesSupplier +uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages() + throw(uno::RuntimeException) +{ + uno::Reference< drawing::XDrawPages > xMasterPages( mxMasterPagesAccess ); + + if( !xMasterPages.is() ) + mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this); + + return xMasterPages; +} + +// XLayerManagerSupplier +uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager( ) + throw(uno::RuntimeException) +{ + uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager ); + + if( !xLayerManager.is() ) + mxLayerManager = xLayerManager = new SdLayerManager(*this); + + return xLayerManager; +} + +// XCustomPresentationSupplier +uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations() + throw(uno::RuntimeException) +{ + uno::Reference< container::XNameContainer > xCustomPres( mxCustomPresentationAccess ); + + if( !xCustomPres.is() ) + mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this); + + return xCustomPres; +} + +// XPresentationSupplier +uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation() + throw(uno::RuntimeException) +{ + uno::Reference< presentation::XPresentation > aPresentation( mxPresentation ); + + if( !aPresentation.is() ) + mxPresentation = aPresentation = new SdXPresentation(*this); + + return aPresentation; +} + +// XMultiServiceFactory ( SvxFmMSFactory ) +uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier ) + throw(uno::Exception, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) ) + { + return SvxUnoDashTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) ) + { + return SvxUnoGradientTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) ) + { + return SvxUnoHatchTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) ) + { + return SvxUnoBitmapTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ) + { + return SvxUnoTransGradientTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) ) + { + return SvxUnoMarkerTable_createInstance( pDoc ); + } + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.NumberingRule" ) ) ) + { + return uno::Reference< uno::XInterface >( (uno::XWeak*)(new SvxUnoNumberingRules( pDoc )) ); + } + + if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.style.Style") ) ) + { + uno::Reference< style::XStyle > xStyle( new SdUnoGraphicStyle() ); + return xStyle; + } + + uno::Reference< uno::XInterface > xRet; + + const String aType( aServiceSpecifier ); + if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) ) + { + SvxShape* pShape = NULL; + + sal_uInt16 nType = OBJ_TEXT; + // create a shape wrapper + if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) ) + { + nType = OBJ_TEXT; + } + else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) ) + { + nType = OBJ_GRAF; + } + else if( aType.EqualsAscii( "PageShape", 26, 9 ) ) + { + nType = OBJ_PAGE; + } + else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "ChartShape", 26, 10 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "TableShape", 26, 10 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) ) + { + nType = OBJ_OLE2; + } + else if( aType.EqualsAscii( "NotesShape", 26, 13 ) ) + { + nType = PRESOBJ_NOTES; + } + else if( aType.EqualsAscii( "HandoutShape", 26, 13 ) ) + { + nType = PRESOBJ_HANDOUT; + } + else + { + throw lang::ServiceNotRegisteredException(); + } + + // create the API wrapper + pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor ); + + // set shape type + if( pShape ) + pShape->SetShapeType(aServiceSpecifier); + + xRet = (uno::XWeak*)pShape; + } + else + { + xRet = SvxFmMSFactory::createInstance( aServiceSpecifier ); + } + + uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY ); + if( xShape.is() ) + { + xRet.clear(); + new SdXShape( xShape, (SdXImpressDocument*)this ); + xRet = xShape; + xShape.clear(); + } + + return xRet; +} + +uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames() + throw(uno::RuntimeException) +{ + const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() ); + + if(mbImpressDoc) + { + uno::Sequence< OUString > aSNS( 11 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.Style")); + aSNS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")); + aSNS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape")); + aSNS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape")); + aSNS.getArray()[4] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape")); + aSNS.getArray()[9] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape")); + aSNS.getArray()[5] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape")); + aSNS.getArray()[6] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape")); + aSNS.getArray()[7] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape")); + aSNS.getArray()[8] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape")); + aSNS.getArray()[9] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape")); + aSNS.getArray()[10] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape")); + + return utl::concatSequences( aSNS_ORG, aSNS ); + } + else + { + uno::Sequence< OUString > aSNS( 1 ); + aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")); + + return utl::concatSequences( aSNS_ORG, aSNS ); + } +} + +// lang::XServiceInfo +OUString SAL_CALL SdXImpressDocument::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXImpressDocument")); +} + +sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException) +{ + OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument")); + uno::Sequence< OUString > aSeq( &aSN, 1 ); + + if( mbImpressDoc ) + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.PresentationDocument"); + + return aSeq; +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo( ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return aPropSet.getPropertySetInfo(); +} + +void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(pDoc==NULL) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(aPropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_MODEL_LANGUAGE: + { + lang::Locale aLocale; + if(!(aValue >>= aLocale)) + throw lang::IllegalArgumentException(); + + pDoc->SetLanguage(SvxLocaleToLanguage(aLocale)); + break; + } + case WID_MODEL_TABSTOP: + { + sal_Int32 nValue; + if(!(aValue >>= nValue) || nValue < 0 ) + throw lang::IllegalArgumentException(); + + pDoc->SetDefaultTabulator((sal_uInt16)nValue); + break; + } + default: + throw beans::UnknownPropertyException(); + break; + } + + SetModified(); +} + +uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + if( pDoc == NULL ) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = aPropSet.getPropertyMapEntry(PropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_MODEL_LANGUAGE: + { + LanguageType eLang = pDoc->GetLanguage(); + lang::Locale aLocale; + SvxLanguageToLocale( aLocale, eLang ); + aAny <<= aLocale; + break; + } + case WID_MODEL_TABSTOP: + aAny <<= (sal_Int32)pDoc->GetDefaultTabulator(); + break; + default: + throw beans::UnknownPropertyException(); + break; + } + + return aAny; +} + +void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} + +// XLinkTargetSupplier +uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks() + throw(uno::RuntimeException) +{ + return new SdDocLinkTargets( *this ); +} + +// XStyleFamiliesSupplier +uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies( ) + throw(uno::RuntimeException) +{ + uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies); + + if( !xStyles.is() ) + mxStyleFamilies = xStyles = new SdUnoStyleFamilies( this ); + + return xStyles; +} + + +//============================================================================= +// class SdDrawPagesAccess +//============================================================================= + +SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel ) throw() +: rModel(rMyModel) +{ +} + +SdDrawPagesAccess::~SdDrawPagesAccess() throw() +{ +} + +// XIndexAccess +sal_Int32 SAL_CALL SdDrawPagesAccess::getCount() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nCount = 0; + + if( rModel.pDoc ) + nCount = rModel.pDoc->GetSdPageCount( PK_STANDARD ); + + return( nCount ); +} + +uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + if( rModel.pDoc ) + { + if( (Index < 0) || (Index >= rModel.pDoc->GetSdPageCount( PK_STANDARD ) ) ) + throw lang::IndexOutOfBoundsException(); + + SdPage* pPage = rModel.pDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD ); + if( pPage ) + { + uno::Reference< drawing::XDrawPage > xDrawPage = rModel.CreateXDrawPage(pPage); + aAny <<= xDrawPage; + } + } + return aAny; +} + +// XElementAccess +uno::Type SAL_CALL SdDrawPagesAccess::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE( drawing::XDrawPage ); +} + +sal_Bool SAL_CALL SdDrawPagesAccess::hasElements() + throw(uno::RuntimeException) +{ + return getCount() > 0; +} + +// XDrawPages + +/****************************************************************************** +* Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die * +* dazugehoerige SdDrawPage zurueck. * +******************************************************************************/ +uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XDrawPage > xDrawPage; + + if( rModel.pDoc ) + { + SdPage* pPage = rModel.InsertSdPage(nIndex ); + xDrawPage = rModel.CreateXDrawPage(pPage); + } + return( xDrawPage ); +} + +/****************************************************************************** +* Entfernt die angegebenne SdDrawPage aus dem Model und aus der internen * +* Liste. Dies funktioniert nur, wenn mindestens eine *normale* Seite im Model * +* nach dem entfernen dieser Seite vorhanden ist. * +******************************************************************************/ +void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_uInt16 nPageCount = rModel.pDoc->GetSdPageCount( PK_STANDARD ); + if( nPageCount > 1 ) + { + // pPage von xPage besorgen und dann die Id (nPos )ermitteln + SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage ); + if( pSvxPage ) + { + SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage(); + if(pPage) + { + // Es duerfen nur Standardpages DIREKT geloescht werden + if( pPage->GetPageKind() == PK_STANDARD ) + { + sal_uInt16 nPage = pPage->GetPageNum(); + rModel.pDoc->RemovePage( nPage ); + + // Die darauffolgende Seite ist die dazugeoerige Notizseite + rModel.pDoc->RemovePage( nPage ); + } + } + pSvxPage->Invalidate(); + } + } + + rModel.SetModified(); +} + +//============================================================================= +// class SdMasterPagesAccess +//============================================================================= + +SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw() +: rModel(rMyModel) +{ +} + +SdMasterPagesAccess::~SdMasterPagesAccess() throw() +{ +} + +// XIndexAccess +sal_Int32 SAL_CALL SdMasterPagesAccess::getCount() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nCount = 0; + + if( rModel.pDoc ) + nCount = rModel.pDoc->GetMasterSdPageCount(PK_STANDARD); + + return( nCount ); +} + +/****************************************************************************** +* Liefert ein drawing::XDrawPage Interface fuer den Zugriff auf die Masterpage and der * +* angegebennen Position im Model. * +******************************************************************************/ +uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + if( rModel.pDoc ) + { + if( (Index < 0) || (Index >= rModel.pDoc->GetMasterSdPageCount( PK_STANDARD ) ) ) + throw lang::IndexOutOfBoundsException(); + + SdPage* pPage = rModel.pDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD ); + if( pPage ) + { + uno::Reference< drawing::XDrawPage > xDrawPage( rModel.CreateXDrawPage(pPage) ); + aAny <<= xDrawPage; + } + } + return aAny; +} + +// XElementAccess +uno::Type SAL_CALL SdMasterPagesAccess::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE(drawing::XDrawPage); +} + +sal_Bool SAL_CALL SdMasterPagesAccess::hasElements() + throw(uno::RuntimeException) +{ + return getCount() > 0; +} + +// XDrawPages +uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nIndex ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XDrawPage > xDrawPage; + + SdDrawDocument* pDoc = rModel.pDoc; + if( pDoc ) + { + // calculate internal index and check for range errors + const sal_Int32 nMPageCount = pDoc->GetMasterPageCount(); + nIndex = nIndex * 2 + 1; + if( nIndex < 0 || nIndex > nMPageCount ) + nIndex = nMPageCount; + + // now generate a unique name for the new masterpage + const String aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) ); + String aPrefix( aStdPrefix ); + + sal_Bool bUnique = sal_True; + sal_Int32 nIndex = 0; + do + { + bUnique = sal_True; + for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ ) + { + SdPage* pPage = (SdPage*)pDoc->GetMasterPage(nMaster); + if( pPage && pPage->GetName() == aPrefix ) + { + bUnique = sal_False; + break; + } + } + + if( !bUnique ) + { + nIndex++; + aPrefix = aStdPrefix; + aPrefix += sal_Unicode( ' ' ); + aPrefix += String::CreateFromInt32( nIndex ); + } + + } while( !bUnique ); + + String aLayoutName( aPrefix ); + aLayoutName += String( RTL_CONSTASCII_USTRINGPARAM("~LT~Outline1") ); + + // create styles + ((SdStyleSheetPool*)pDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix ); + + // get the first page for initial size and border settings + SdPage* pPage = rModel.pDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD ); + + // create and instert new draw masterpage + SdPage* pMPage = (SdPage*)rModel.pDoc->AllocPage(sal_True); + pMPage->SetSize( pPage->GetSize() ); + pMPage->SetBorder( pPage->GetLftBorder(), + pPage->GetUppBorder(), + pPage->GetRgtBorder(), + pPage->GetLwrBorder() ); + pDoc->InsertMasterPage(pMPage, nIndex); + pMPage->SetLayoutName( aLayoutName ); + + xDrawPage = rModel.CreateXDrawPage(pMPage); + + // create and instert new notes masterpage + SdPage* pMNotesPage = (SdPage*)rModel.pDoc->AllocPage(sal_True); + pMNotesPage->SetSize( pPage->GetSize() ); + pMNotesPage->SetBorder( pPage->GetLftBorder(), + pPage->GetUppBorder(), + pPage->GetRgtBorder(), + pPage->GetLwrBorder() ); + pDoc->InsertMasterPage(pMNotesPage, nIndex + 1); + pMNotesPage->SetLayoutName( aLayoutName ); + + rModel.SetModified(); + } + + return( xDrawPage ); +} + +/****************************************************************************** +* Entfernt die angegebenne SdMasterPage aus dem Model und aus der internen * +* Liste. Dies funktioniert nur, wenn keine *normale* Seite im Model diese * +* Seite als Masterpage benutzt. * +******************************************************************************/ +void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage ); + if(pSdPage == NULL) + return; + + SdrPage* pSdrPage = pSdPage->GetSdrPage(); + + DBG_ASSERT( pSdrPage->IsMasterPage(), "SdMasterPage is not masterpage?") + + if(rModel.pDoc->GetMasterPageUserCount(pSdrPage) > 0) + return; //Todo: hier fehlt eine uno::Exception + + sal_uInt16 nCount = rModel.pDoc->GetMasterPageCount(); + for( sal_uInt16 nPgNum = 0; nPgNum < nCount; nPgNum++ ) + { + if(rModel.pDoc->GetMasterPage(nPgNum) == pSdrPage) + { + rModel.pDoc->DeleteMasterPage(nPgNum); + break; + } + } + + pSdPage->Invalidate(); +} + +//============================================================================= +// class SdDocLinkTargets +//============================================================================= + +SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw() +: rModel( rMyModel ) +{ +} + +SdDocLinkTargets::~SdDocLinkTargets() throw() +{ +} + +// XNameAccess +uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName ) + throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdPage* pPage = FindPage( aName ); + + if( pPage == NULL ) + throw container::NoSuchElementException(); + + uno::Any aAny; + + uno::Reference< drawing::XDrawPage > aRef( SvxDrawPage::GetPageForSdrPage( pPage ) ); + if( !aRef.is() ) + { + if( pPage->IsMasterPage() ) + aRef = (presentation::XPresentationPage*)new SdMasterPage( &rModel, pPage ); + else + aRef = (drawing::XDrawPage*)(presentation::XPresentationPage*)new SdDrawPage( &rModel, pPage ); + } + + uno::Reference< beans::XPropertySet > xProps( aRef, uno::UNO_QUERY ); + + if( xProps.is() ) + aAny <<= xProps; + + return aAny; +} + +uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdDrawDocument* pDoc = rModel.GetDoc(); + if( pDoc == NULL ) + { + uno::Sequence< OUString > aSeq; + return aSeq; + } + + const sal_uInt16 nMaxPages = pDoc->GetPageCount(); + const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount(); + + uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages ); + OUString* pStr = aSeq.getArray(); + + sal_uInt16 nPage; + // standard pages + for( nPage = 0; nPage < nMaxPages; nPage++ ) + *pStr++ = ((SdPage*)pDoc->GetPage( nPage ))->GetName(); + + // master pages + for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) + *pStr++ = ((SdPage*)pDoc->GetMasterPage( nPage ))->GetName(); + + return aSeq; +} + +sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return FindPage( aName ) != NULL; +} + +// container::XElementAccess +uno::Type SAL_CALL SdDocLinkTargets::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE(beans::XPropertySet); +} + +sal_Bool SAL_CALL SdDocLinkTargets::hasElements() + throw(uno::RuntimeException) +{ + SdDrawDocument* pDoc = rModel.GetDoc(); + return pDoc != NULL; +} + +SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw() +{ + SdDrawDocument* pDoc = rModel.GetDoc(); + if( pDoc == NULL ) + return NULL; + + const sal_uInt16 nMaxPages = pDoc->GetPageCount(); + const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount(); + + sal_uInt16 nPage; + SdPage* pPage; + + const String aName( rName ); + + // standard pages + for( nPage = 0; nPage < nMaxPages; nPage++ ) + { + pPage = (SdPage*)pDoc->GetPage( nPage ); + if( pPage->GetName() == aName ) + return pPage; + } + + // master pages + for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) + { + pPage = (SdPage*)pDoc->GetMasterPage( nPage ); + if( pPage->GetName() == aName ) + return pPage; + } + + return NULL; +} + +// XServiceInfo +OUString SAL_CALL SdDocLinkTargets::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDocLinkTargets") ); +} + +sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") ); + uno::Sequence< OUString > aSeq( &aSN, 1 ); + return aSeq; +} + + diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx new file mode 100644 index 000000000000..89a79595bd5f --- /dev/null +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -0,0 +1,965 @@ +/************************************************************************* + * + * $RCSfile: unoobj.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_PRESENTATION_ANIMATIONEFFECT_HPP_ +#include <com/sun/star/presentation/AnimationEffect.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_CLICKACTION_HPP_ +#include <com/sun/star/presentation/ClickAction.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_ANIMATIONSPEED_HPP_ +#include <com/sun/star/presentation/AnimationSpeed.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif + +#ifndef _VOS_MUTEX_HXX_ +#include <vos/mutex.hxx> +#endif + +#ifndef _SFX_ITEMPROP_HXX +#include <svtools/itemprop.hxx> +#endif +#ifndef _SFXSTYLE_HXX +#include <svtools/style.hxx> +#endif + +#ifndef _SFX_BINDINGS_HXX +#include <sfx2/bindings.hxx> +#endif +#ifndef _SFXSIDS_HRC +#include <sfx2/sfxsids.hrc> +#endif + +#include <cppuhelper/extract.hxx> + +#include <svx/unoprov.hxx> +#include <svx/unoshape.hxx> +#include <svx/svditer.hxx> +#ifndef _SVDOTEXT_HXX +#include <svx/svdotext.hxx> +#endif + +#include "anminfo.hxx" +#include "unohelp.hxx" +#include "unoobj.hxx" +#include "unoprnms.hxx" +#include "unomodel.hxx" +#include "drawdoc.hxx" +#include "sdpage.hxx" +#include "unokywds.hxx" +#include "unostyls.hxx" +#include "unopsfm.hxx" +#include "unogsfm.hxx" +#include "unopstyl.hxx" +#include "helpids.h" +#include "glob.hxx" + +using namespace ::vos; +using namespace ::rtl; +using namespace ::com::sun::star; + +#define WID_EFFECT 1 +#define WID_SPEED 2 +#define WID_TEXTEFFECT 3 +#define WID_BOOKMARK 4 +#define WID_CLICKACTION 5 +#define WID_PLAYFULL 6 +#define WID_SOUNDFILE 7 +#define WID_SOUNDON 8 +#define WID_BLUESCREEN 9 +#define WID_VERB 10 +#define WID_DIMCOLOR 11 +#define WID_DIMHIDE 12 +#define WID_DIMPREV 13 +#define WID_PRESORDER 14 +#define WID_STYLE 15 + +#define WID_ISEMPTYPRESOBJ 20 +#define WID_ISPRESOBJ 21 +#define WID_MASTERDEPEND 22 + +#define WID_THAT_NEED_ANIMINFO 19 + +const SfxItemPropertyMap* ImplGetShapePropertyMap( sal_Bool bImpress ) +{ + // Achtung: Der erste Parameter MUSS sortiert vorliegen !!! + static const SfxItemPropertyMap aImpress_SdXShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMCOLOR), WID_DIMCOLOR, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMHIDE), WID_DIMHIDE, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMPREV), WID_DIMPREV, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_EFFECT), WID_EFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_ISPRESOBJ), WID_ISPRESOBJ, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_PLAYFULL), WID_PLAYFULL, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_PRESORDER), WID_PRESORDER, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE( style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_SOUNDFILE, &::getCppuType((const OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDON), WID_SOUNDON, &::getBooleanCppuType(), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_SPEED), WID_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_TEXTEFFECT), WID_TEXTEFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_BLUESCREEN), WID_BLUESCREEN, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_VERB), WID_VERB, &::getCppuType((const sal_Int32*)0), 0, 0}, + + { 0,0,0,0,0} + }; + + static const SfxItemPropertyMap aDraw_SdXShapePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE(style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0}, + { 0,0,0,0,0} + }; + + if( bImpress ) + return aImpress_SdXShapePropertyMap_Impl; + else + return aDraw_SdXShapePropertyMap_Impl; +} + +SfxItemPropertyMap aEmpty_SdXShapePropertyMap_Impl[] = +{ + { 0,0,0,0,0} +}; + +/************************************************************************* +|* +|* Vergleichsfkt. fuer QSort +|* +\************************************************************************/ +struct SortStruct +{ + SdrObject* pObj; + sal_uInt32 nOrder; +}; + +typedef SortStruct SORT; +typedef SORT* PSORT; + +extern "C" int __LOADONCALLAPI SortFunc( const void* p1, const void* p2 ); + +SdXShape::SdXShape() throw() +: maPropSet(aEmpty_SdXShapePropertyMap_Impl), + mpMap(aEmpty_SdXShapePropertyMap_Impl), + mpModel(NULL) +{ +} + +SdXShape::SdXShape(uno::Reference< drawing::XShape > & xShape, SdXImpressDocument* pModel) throw() +: maPropSet( pModel?ImplGetShapePropertyMap(pModel->IsImpressDocument()):aEmpty_SdXShapePropertyMap_Impl), + mpMap( pModel?ImplGetShapePropertyMap(pModel->IsImpressDocument()):aEmpty_SdXShapePropertyMap_Impl), + mpModel(pModel) +{ + m_refCount++; + { + uno::Any aAny( xShape->queryInterface( ITYPE( uno::XAggregation ) ) ); + xShape = NULL; + + aAny >>= mxShapeAgg; + } + + if( mxShapeAgg.is() ) + mxShapeAgg->setDelegator( (::cppu::OWeakObject*)this ); + + { + uno::Any aAny = mxShapeAgg->queryInterface( ITYPE( drawing::XShape ) ); + aAny >>= xShape; + } + + m_refCount--; +} + +SdXShape::~SdXShape() throw() +{ +} + +// XInterface +uno::Any SAL_CALL SdXShape::queryInterface( const ::com::sun::star::uno::Type & rType ) + throw(::com::sun::star::uno::RuntimeException) +{ + uno::Any aAny; + + if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ) + { + aAny <<= uno::Reference< beans::XPropertySet >(this); + } + else if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) ) + { + aAny <<= uno::Reference< lang::XServiceInfo >(this); + } + else + { + aAny = OWeakObject::queryInterface(rType); + + if(!aAny.hasValue() && mxShapeAgg.is()) + return mxShapeAgg->queryAggregation( rType ); + } + + return aAny; +} + +void SAL_CALL SdXShape::acquire() + throw(::com::sun::star::uno::RuntimeException) +{ + OWeakObject::acquire(); +} + +void SAL_CALL SdXShape::release() + throw(::com::sun::star::uno::RuntimeException) +{ + OWeakObject::release(); +} + +//XPropertySet +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo() + throw(::com::sun::star::uno::RuntimeException) +{ + uno::Reference< beans::XPropertySetInfo > aRet; + if(mxShapeAgg.is()) + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny( mxShapeAgg->queryAggregation( ITYPE( beans::XPropertySet ))); + + if( aAny >>= xPrSet ) + { + uno::Reference< beans::XPropertySetInfo > xInfo( xPrSet->getPropertySetInfo() ); + // PropertySetInfo verlaengern! + const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); + aRet = new SfxExtItemPropertySetInfo( mpMap, aPropSeq ); + } + } + if(!aRet.is()) + aRet = new SfxItemPropertySetInfo( mpMap ); + return aRet; +} + +void SAL_CALL SdXShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(!mxShapeAgg.is()) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = maPropSet.getPropertyMapEntry(aPropertyName); + + if( pMap && GetSdrObject() ) + { + SdAnimationInfo* pInfo = GetAnimationInfo((pMap->nWID <= WID_THAT_NEED_ANIMINFO)?sal_True:sal_False); + + switch(pMap->nWID) + { + case WID_EFFECT: + ::cppu::any2enum< presentation::AnimationEffect >( pInfo->eEffect, aValue ); + break; + case WID_TEXTEFFECT: + ::cppu::any2enum< presentation::AnimationEffect >( pInfo->eTextEffect, aValue); + break; + case WID_SPEED: + ::cppu::any2enum< presentation::AnimationSpeed >( pInfo->eSpeed, aValue); + break; + case WID_BOOKMARK: + { + OUString aString; + if(!(aValue >>= aString)) + throw lang::IllegalArgumentException(); + + pInfo->aBookmark = aString; + break; + } + case WID_CLICKACTION: + ::cppu::any2enum< presentation::ClickAction >( pInfo->eClickAction, aValue); + break; + case WID_PLAYFULL: + pInfo->bPlayFull = ::cppu::any2bool(aValue); + break; + case WID_SOUNDFILE: + { + OUString aString; + if(!(aValue >>= aString)) + throw lang::IllegalArgumentException(); + pInfo->aSoundFile = aString; + break; + } + case WID_SOUNDON: + pInfo->bSoundOn = ::cppu::any2bool(aValue); + break; + case WID_BLUESCREEN: + { + sal_Int32 nColor; + if(!(aValue >>= nColor)) + throw lang::IllegalArgumentException(); + + pInfo->aBlueScreen.SetColor( nColor ); + break; + } + case WID_VERB: + { + sal_Int32 nVerb; + if(!(aValue >>= nVerb)) + throw lang::IllegalArgumentException(); + + pInfo->nVerb = nVerb; + break; + } + case WID_DIMCOLOR: + { + sal_Int32 nColor; + if(!(aValue >>= nColor)) + throw lang::IllegalArgumentException(); + + pInfo->aDimColor.SetColor( (ColorData) nColor ); + break; + } + case WID_DIMHIDE: + pInfo->bDimHide = ::cppu::any2bool(aValue); + break; + case WID_DIMPREV: + pInfo->bDimPrevious = ::cppu::any2bool(aValue); + break; + case WID_PRESORDER: + { + sal_Int32 nPos; + if(!(aValue >>= nPos)) + throw lang::IllegalArgumentException(); + + SetPresentationOrderPos( nPos ); + break; + } + case WID_STYLE: + SetStyleSheet( aValue ); + break; + case WID_ISEMPTYPRESOBJ: + SetEmptyPresObj( ::cppu::any2bool(aValue) ); + break; + case WID_MASTERDEPEND: + SetMasterDepend( ::cppu::any2bool(aValue) ); + break; + } + } + else + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny(mxShapeAgg->queryAggregation( ITYPE( beans::XPropertySet ) ) ); + if( aAny >>= xPrSet) + xPrSet->setPropertyValue(aPropertyName, aValue); + } + + if( mpModel ) + mpModel->SetModified(); +} + +::com::sun::star::uno::Any SAL_CALL SdXShape::getPropertyValue( const ::rtl::OUString& PropertyName ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(!mxShapeAgg.is()) + throw uno::RuntimeException(); + + uno::Any aRet; + + const SfxItemPropertyMap* pMap = maPropSet.getPropertyMapEntry(PropertyName); + + if( pMap && GetSdrObject() ) + { + SdAnimationInfo* pInfo = GetAnimationInfo(sal_False); + + switch(pMap->nWID) + { + case WID_EFFECT: + aRet = ::cppu::enum2any< presentation::AnimationEffect >( pInfo?pInfo->eEffect:presentation::AnimationEffect_NONE ); + break; + case WID_TEXTEFFECT: + aRet = ::cppu::enum2any< presentation::AnimationEffect >( pInfo?pInfo->eTextEffect:presentation::AnimationEffect_NONE ); + break; + case WID_ISPRESOBJ: + aRet = ::cppu::bool2any(IsPresObj()); + break; + case WID_ISEMPTYPRESOBJ: + aRet = ::cppu::bool2any(IsEmptyPresObj()); + break; + case WID_MASTERDEPEND: + aRet = ::cppu::bool2any(IsMasterDepend()); + break; + case WID_SPEED: + aRet = ::cppu::enum2any< presentation::AnimationSpeed >( pInfo?pInfo->eSpeed:presentation::AnimationSpeed_MEDIUM ); + break; + case WID_BOOKMARK: + { + OUString aString; + if( pInfo ) + aString = pInfo->aBookmark ; + aRet <<= aString; + break; + } + case WID_CLICKACTION: + aRet = ::cppu::enum2any< presentation::ClickAction >( pInfo?pInfo->eClickAction:presentation::ClickAction_NONE ); + break; + case WID_PLAYFULL: + aRet = ::cppu::bool2any( pInfo && pInfo->bPlayFull ); + break; + case WID_SOUNDFILE: + { + OUString aString; + if( pInfo ) + aString = pInfo->aSoundFile ; + aRet <<= aString; + break; + } + case WID_SOUNDON: + aRet = ::cppu::bool2any( pInfo && pInfo->bSoundOn ); + break; + case WID_BLUESCREEN: + aRet <<= (sal_Int32)( pInfo?pInfo->aBlueScreen.GetColor():0x00ffffff ); + break; + case WID_VERB: + aRet <<= (sal_Int32)( pInfo?pInfo->nVerb:0 ); + break; + case WID_DIMCOLOR: + aRet <<= (sal_Int32)( pInfo?pInfo->aDimColor.GetColor():0x00ffffff ); + break; + case WID_DIMHIDE: + aRet = ::cppu::bool2any( pInfo && pInfo->bDimHide ); + break; + case WID_DIMPREV: + aRet = ::cppu::bool2any( pInfo && pInfo->bDimPrevious ); + break; + case WID_PRESORDER: + aRet <<= (sal_Int32)( GetPresentationOrderPos() ); + break; + case WID_STYLE: + aRet = GetStyleSheet(); + break; + } + } + else + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny(mxShapeAgg->queryAggregation(::getCppuType((const uno::Reference< beans::XPropertySet >*)0))); + + if( aAny >>= xPrSet) + aRet = xPrSet->getPropertyValue(PropertyName); + } + + return aRet; +} + +void SAL_CALL SdXShape::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if(mxShapeAgg.is()) + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny(mxShapeAgg->queryAggregation(::getCppuType((const uno::Reference< beans::XPropertySet >*)0))); + if( aAny >>= xPrSet) + xPrSet->addPropertyChangeListener(aPropertyName, xListener); + } + +} + +void SAL_CALL SdXShape::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if(mxShapeAgg.is()) + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny( mxShapeAgg->queryAggregation(::getCppuType((const uno::Reference< beans::XPropertySet >*)0))); + if( aAny >>= xPrSet ) + xPrSet->removePropertyChangeListener(aPropertyName, aListener); + } +} + +void SAL_CALL SdXShape::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if(mxShapeAgg.is()) + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny(mxShapeAgg->queryAggregation(::getCppuType((const uno::Reference< beans::XPropertySet >*)0))); + if( aAny >>= xPrSet ) + xPrSet->addVetoableChangeListener(PropertyName, aListener); + } +} + +void SAL_CALL SdXShape::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + if(mxShapeAgg.is()) + { + uno::Reference< beans::XPropertySet > xPrSet; + uno::Any aAny(mxShapeAgg->queryAggregation(::getCppuType((const uno::Reference< beans::XPropertySet >*)0))); + if( aAny >>= xPrSet ) + xPrSet->removeVetoableChangeListener(PropertyName, aListener); + } +} + +/** */ +SdAnimationInfo* SdXShape::GetAnimationInfo( sal_Bool bCreate ) const throw() +{ + SdAnimationInfo* pInfo = NULL; + + SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL; + if(pDoc) + { + SdrObject* pObj = GetSdrObject(); + if(pObj) + { + pInfo = pDoc->GetAnimationInfo(pObj); + if( pInfo == NULL && bCreate ) + { + pInfo = new SdAnimationInfo(pDoc); + pObj->InsertUserData( pInfo ); + } + } + } + + return pInfo; +} + +// XServiceInfo +OUString SAL_CALL SdXShape::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXShape") ); +} + +sal_Bool SAL_CALL SdXShape::supportsService( const ::rtl::OUString& ServiceName ) + throw(::com::sun::star::uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SdXShape::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq; + + uno::Reference< lang::XServiceInfo > xParentInfo; + if(mxShapeAgg.is()) + { + uno::Any aAny( mxShapeAgg->queryAggregation( ITYPE( lang::XServiceInfo ))); + if( aAny >>= xParentInfo ) + aSeq = xParentInfo->getSupportedServiceNames(); + } + + SvxServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.presentation.shape", + "com.sun.star.document.LinkTarget" ); + + SdrObject* pObj = GetSdrObject(); + if(pObj && pObj->GetObjInventor() == SdrInventor ) + { + sal_uInt32 nInventor = pObj->GetObjIdentifier(); + switch( nInventor ) + { + case OBJ_TITLETEXT: + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.TitleTextShape" ); + break; + case OBJ_OUTLINETEXT: + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.OutlinerShape" ); + break; + } + } + return aSeq; +} + + +/** returns the SdrObject of the aggregatet SvxShape + */ +SdrObject* SdXShape::GetSdrObject() const throw() +{ + if(mxShapeAgg.is()) + { + SvxShape* pShape = SvxShape::getImplementation( mxShapeAgg ); + if(pShape) + return pShape->GetSdrObject(); + } + + return NULL; +} + +/** checks if this is a presentation object + */ +sal_Bool SdXShape::IsPresObj() const throw() +{ + SdrObject* pObj = GetSdrObject(); + if(pObj) + { + SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage()); + if(pPage) + return pPage->GetPresObjKind(pObj) != PRESOBJ_NONE; + } + return sal_False; +} + +/** converts this shape to a presentation object or + a ordinary shape to a presentation object. +void SdXShape::SetPresObj( sal_Bool bPresObj ) throw() +{ + if( IsPresObj() != bPresObj ) + { + SdrObject* pObj = GetSdrObject(); + if( pObj ) + { + SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage()); + if(pPage) + { + List* pPresObjList = pPage->GetPresObjList(); + if( bPresObj ) + { + // convert a shape to a pres obj + List* pPresObjList = pPage->GetPresObjList(); + pPresObjList->Insert( pObj ); + + // check if this is now a valid pres obj + if( pPage->GetPresObjKind( pObj ) == PRESOBJ_NONE ) + { + // this is an invalid pres obj, so remove + // it from the pres obj list + pPresObjList->Remove( pObj ); + } + } + else + { + // convert a pres obj to a shape + pObj->SetUserCall( pPage ); + pPresObjList->Remove(pObj); + } + } + } + } +} + */ + +/** checks if this presentation object is empty + */ +sal_Bool SdXShape::IsEmptyPresObj() const throw() +{ + SdrObject* pObj = GetSdrObject(); + return pObj && pObj->IsEmptyPresObj(); +} + +/** sets/reset the empty status of a presentation object +*/ +void SdXShape::SetEmptyPresObj( sal_Bool bEmpty ) throw() +{ + // only possible if this actually *is* a presentation object + if( !IsPresObj() ) + return; + + SdrObject* pObj = GetSdrObject(); + if( pObj ) + { + if( pObj->IsEmptyPresObj() != bEmpty ) + { + if( bEmpty ) + { + SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage()); + if(pPage) + { + uno::Reference< text::XTextRange > xTextRange( (drawing::XShape*)this, uno::UNO_QUERY ); + if( xTextRange.is() ) + { + const OUString aEmptyStr( pPage->GetPresObjText( pPage->GetPresObjKind(pObj) ) ); + xTextRange->setString( aEmptyStr ); + } + } + } + else + { + if ( pObj->ISA(SdrTextObj) ) + ( (SdrTextObj*) pObj)->SetOutlinerParaObject(NULL); + + } + pObj->SetEmptyPresObj( bEmpty ); + } + } +} + +sal_Bool SdXShape::IsMasterDepend() const throw() +{ + SdrObject* pObj = GetSdrObject(); + return pObj && pObj->GetUserCall() != NULL; +} + +void SdXShape::SetMasterDepend( sal_Bool bDepend ) throw() +{ + if( IsMasterDepend() != bDepend ) + { + SdrObject* pObj = GetSdrObject(); + if( pObj ) + { + if( bDepend ) + { + SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage()); + pObj->SetUserCall( pPage ); + } + else + { + pObj->SetUserCall( NULL ); + } + } + } +} + +/** + */ +inline sal_Bool IsPathObj( SdrObject* pObj, SdAnimationInfo* pInfo ) +{ + // Wenn es sich um das Pfad-Objekt bei dem Effekt "An Kurve entlang" + // handelt, soll es nicht in der Tabelle aufgenommen werden + // "bInvisibleInPresentation" ist der einzige Hinweis darauf, ob + // es sich um das Pfad-Objekt handelt + + const SdrObjKind eKind = (SdrObjKind)pObj->GetObjIdentifier(); + return pInfo->bInvisibleInPresentation && + pObj->GetObjInventor() == SdrInventor && + (eKind == OBJ_LINE || eKind == OBJ_PLIN || eKind == OBJ_PATHLINE ); +} + +/** Returns the position of the given SdrObject in the Presentation order. + * This function returns -1 if the SdrObject is not in the Presentation order + * or if its the path-object. + */ +sal_Int32 SdXShape::GetPresentationOrderPos() const throw() +{ + SdrObject* pObj = GetSdrObject(); + SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL; + if(pDoc == NULL || pObj == NULL) + return -1; + + SdrObjListIter aIter( *pObj->GetPage(), IM_FLAT ); + + + SdAnimationInfo* pInfo = pDoc->GetAnimationInfo( pObj ); + if(pInfo == NULL || pInfo->bActive == sal_False || IsPathObj( pObj, pInfo ) ) + return -1; + + sal_Int32 nPos = 0; + + while( aIter.IsMore() ) + { + SdrObject* pIterObj = aIter.Next(); + if(pIterObj == pObj) + continue; + + SdAnimationInfo* pIterInfo = pDoc->GetAnimationInfo( pIterObj ); + if( pIterInfo ) + { + if( !IsPathObj(pIterObj, pIterInfo ) ) + { + if( pIterInfo->nPresOrder < pInfo->nPresOrder ) + nPos++; + } + } + } + + return nPos; +} + + +/** Sets the position of the given SdrObject in the Presentation order. + */ +void SdXShape::SetPresentationOrderPos( sal_Int32 nPos ) throw() +{ + SdrObject* pObj = GetSdrObject(); + SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL; + if(pDoc == 0 || pObj == NULL) + return; + + List aAnmList; + + // Erstmal alle animierten Objekte in eine List packen, + // ausgenommen unser eigenes + SdrObjListIter aIter( *pObj->GetPage(), IM_FLAT ); + while( aIter.IsMore()) + { + SdrObject* pIterObj = aIter.Next(); + if( pIterObj != pObj && pDoc->GetAnimationInfo( pIterObj ) ) + aAnmList.Insert(pIterObj, LIST_APPEND); + } + + const sal_Int32 nCount = aAnmList.Count(); + + if ( nCount ) + { + PSORT pSort = new SORT[ nCount ]; + sal_Int32 nOrderIndex = 0; + sal_Int32 nAppendIndex = LIST_APPEND - nCount; + + for( SdrObject* pIterObj = (SdrObject*) aAnmList.First(); pIterObj; pIterObj = (SdrObject*) aAnmList.Next() ) + { + const SdAnimationInfo* pInfo = pDoc->GetAnimationInfo( pIterObj ); + PSORT pSortTmp = &pSort[ nOrderIndex++ ]; + + pSortTmp->pObj = pIterObj; + pSortTmp->nOrder = ( pInfo->nPresOrder != LIST_APPEND ) ? pInfo->nPresOrder : nAppendIndex++; + } + + // Liste loeschen, die Information steckt jetzt im Array + aAnmList.Clear(); + + // Array nach Ordnungsnummern sortieren + qsort( pSort, nCount, sizeof( SORT ), SortFunc ); + + // Animationliste neu aufbauen + for( sal_Int32 i = 0; i < nCount; i++ ) + aAnmList.Insert( pSort[ i ].pObj, LIST_APPEND ); + + delete[] pSort; + } + + aAnmList.Insert(pObj, nPos); + + sal_Int32 nIdx = 0; + for( SdrObject* pIterObj = (SdrObject*) aAnmList.First(); pIterObj; pIterObj = (SdrObject*) aAnmList.Next() ) + { + SdAnimationInfo* pInfo = pDoc->GetAnimationInfo( pIterObj ); + pInfo->nPresOrder = nIdx++; + } +} + +void SdXShape::SetStyleSheet( const uno::Any& rAny ) throw( lang::IllegalArgumentException ) +{ + SdUnoPseudoStyle* pStyleSheet = NULL; + + if( rAny.hasValue() && rAny.getValueTypeClass() == uno::TypeClass_INTERFACE ) + pStyleSheet = SdUnoPseudoStyle::getImplementation(*(uno::Reference< uno::XInterface > *)rAny.getValue() ); + + SdrObject* pObj = GetSdrObject(); + + // check if it is a style and if its not a presentation style + if( NULL == pObj || NULL == pStyleSheet || pStyleSheet->getStyleSheet()->GetFamily() == SFX_STYLE_FAMILY_PSEUDO ) + throw lang::IllegalArgumentException(); + + // check if this is a praesentation object by checking the stylesheet + SfxStyleSheet* pOldStyleSheet = pObj->GetStyleSheet(); + + if( pOldStyleSheet && + pOldStyleSheet->GetFamily() != SFX_STYLE_FAMILY_PARA && + pOldStyleSheet->GetHelpId( String() ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS ) + throw lang::IllegalArgumentException(); + + pObj->SetStyleSheet( (SfxStyleSheet*)pStyleSheet->getStyleSheet(), sal_False ); + SFX_BINDINGS().Invalidate( SID_STYLE_FAMILY2 ); +} + +uno::Any SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException ) +{ + SdrObject* pObj = GetSdrObject(); + if( pObj == NULL ) + throw beans::UnknownPropertyException(); + + uno::Any aAny; + + SfxStyleSheet* pStyleSheet = pObj->GetStyleSheet(); + if(!pStyleSheet) + return aAny; + + // style::XStyleFamiliesSupplier + uno::Reference< container::XNameAccess > xFamilies( mpModel->getStyleFamilies() ); + + uno::Reference< style::XStyle > xStyle; + + if( pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_PARA ) + { + SdrPage* pPage = pObj->GetPage(); + if( !pPage->IsMasterPage() ) + pPage = pPage->GetMasterPage(0); + + String aLayoutName( pPage->GetLayoutName() ); + aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ) ))); + + aAny = xFamilies->getByName( aLayoutName ); + uno::Reference< container::XNameAccess > xStyleFam( *(uno::Reference< container::XNameAccess > *)aAny.getValue() ); + + SdUnoPseudoStyleFamily *pStyleFamily = SdUnoPseudoStyleFamily::getImplementation( xStyleFam ); + if( pStyleFamily ) + pStyleFamily->createStyle( pStyleSheet, xStyle ); + } + else + { + const OUString aSFN( OUString::createFromAscii( sUNO_Graphic_Style_Family_Name ) ); + aAny = xFamilies->getByName( aSFN ); + uno::Reference< container::XNameAccess > xStyleFam( *(uno::Reference< container::XNameAccess > *)aAny.getValue() ); + + SdUnoGraphicStyleFamily *pStyleFamily = SdUnoGraphicStyleFamily::getImplementation(xStyleFam); + + if( pStyleFamily ) + { + pStyleFamily->createStyle( pStyleSheet, aAny ); + return aAny; + } + } + + aAny.setValue( &xStyle, ITYPE( style::XStyle ) ); + return aAny; +} + + diff --git a/sd/source/ui/unoidl/unoobj.hxx b/sd/source/ui/unoidl/unoobj.hxx new file mode 100644 index 000000000000..30cd977b4eca --- /dev/null +++ b/sd/source/ui/unoidl/unoobj.hxx @@ -0,0 +1,141 @@ +/************************************************************************* + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNOOBJ_HXX +#define _UNOOBJ_HXX + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_ +#include <com/sun/star/drawing/XShape.hpp> +#endif + +#ifndef _SVDPOOL_HXX //autogen +#include <svx/svdpool.hxx> +#endif + +#include <svx/unoipset.hxx> + +#include <cppuhelper/implbase2.hxx> + +class SdrObject; +class SdXImpressDocument; +class SdAnimationInfo; + +class SdXShape : public ::cppu::OWeakObject, + public ::com::sun::star::beans::XPropertySet, + public ::com::sun::star::lang::XServiceInfo +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > mxShapeAgg; + SvxItemPropertySet maPropSet; + const SfxItemPropertyMap* mpMap; + SdXImpressDocument* mpModel; + + void SetStyleSheet( const ::com::sun::star::uno::Any& rAny ) throw( ::com::sun::star::lang::IllegalArgumentException ); + ::com::sun::star::uno::Any GetStyleSheet() const throw( ::com::sun::star::beans::UnknownPropertyException ); + + // Intern + SdAnimationInfo* GetAnimationInfo( sal_Bool bCreate = sal_False ) const throw(); + sal_Bool IsPresObj() const throw(); + void SetPresObj( sal_Bool bPresObj ) throw(); + + sal_Bool IsEmptyPresObj() const throw(); + void SetEmptyPresObj( sal_Bool bEmpty ) throw(); + + sal_Bool IsMasterDepend() const throw(); + void SetMasterDepend( sal_Bool bDepend ) throw(); + + SdrObject* GetSdrObject() const throw(); + sal_Int32 GetPresentationOrderPos() const throw(); + void SetPresentationOrderPos( sal_Int32 nPos ) throw(); + +public: + SdXShape() throw(); + SdXShape(::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xShape, SdXImpressDocument* pModel) throw(); + virtual ~SdXShape() throw(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + //XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); +}; + +#endif + + diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx new file mode 100644 index 000000000000..534936cccb98 --- /dev/null +++ b/sd/source/ui/unoidl/unopage.cxx @@ -0,0 +1,1762 @@ +/************************************************************************* + * + * $RCSfile: unopage.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_PRESENTATION_CLICKACTION_HPP_ +#include <com/sun/star/presentation/ClickAction.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_FADEEFFECT_HPP_ +#include <com/sun/star/presentation/FadeEffect.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_ANIMATIONEFFECT_HPP_ +#include <com/sun/star/presentation/AnimationEffect.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_PRESENTATIONRANGE_HPP_ +#include <com/sun/star/presentation/PresentationRange.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_ANIMATIONSPEED_HPP_ +#include <com/sun/star/presentation/AnimationSpeed.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_PAPERORIENTATION_HPP_ +#include <com/sun/star/view/PaperOrientation.hpp> +#endif + +#ifndef _SV_BITMAPEX_HXX +#include <vcl/bitmapex.hxx> +#endif +#ifndef _SV_METAACT_HXX +#include <vcl/metaact.hxx> +#endif +#ifndef _TOOLKIT_UNOIFACE_HXX +#include <toolkit/unohlp.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _UNOMODEL_HXX +#include <unomodel.hxx> +#endif +#ifndef _SD_UNOPAGE_HXX +#include <unopage.hxx> +#endif +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#ifndef _SFXITEMSET_HXX //autogen +#include <svtools/itemset.hxx> +#endif +#ifndef _SVDMODEL_HXX //autogen +#include <svx/svdmodel.hxx> +#endif +#ifndef _SDRESID_HXX +#include <sdresid.hxx> +#endif +#include <glob.hrc> +#ifndef _SD_PAGE_HXX //autogen +#include <sdpage.hxx> +#endif +#ifndef _SD_UNOPRNMS_HXX +#include <unoprnms.hxx> +#endif +#ifndef _SDATTR_HXX +#include <sdattr.hxx> +#endif +#ifndef _DRAWDOC_HXX +#include <drawdoc.hxx> +#endif +#ifndef _SVX_UNOSHAPE_HXX //autogen +#include <svx/unoshape.hxx> +#endif +#ifndef _COM_SUN_STAR_STYLE_XSTYLE_HPP_ +#include <com/sun/star/style/XStyle.hpp> +#endif +#ifndef _SVDORECT_HXX +#include <svx/svdorect.hxx> +#endif +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif +#include <rtl/uuid.h> +#include <rtl/memory.h> + +#include <cppuhelper/extract.hxx> + +#ifndef _SVDITER_HXX +#include <svx/svditer.hxx> +#endif +#ifndef _WMF_HXX +#include <svtools/wmf.hxx> +#endif + +#include <svx/svdview.hxx> +#include "misc.hxx" +#include "sdview.hxx" +#include "docshell.hxx" +#include "viewshel.hxx" +#include "drviewsh.hxx" +#include "unoobj.hxx" +#include "res_bmp.hrc" +#include "unokywds.hxx" +#include "unopback.hxx" +#include "unohelp.hxx" + +using namespace ::vos; +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; + +#define WID_PAGE_LEFT 0 +#define WID_PAGE_RIGHT 1 +#define WID_PAGE_TOP 2 +#define WID_PAGE_BOTTOM 3 +#define WID_PAGE_WIDTH 4 +#define WID_PAGE_HEIGHT 5 +#define WID_PAGE_EFFECT 6 +#define WID_PAGE_CHANGE 7 +#define WID_PAGE_SPEED 8 +#define WID_PAGE_NUMBER 9 +#define WID_PAGE_ORIENT 10 +#define WID_PAGE_LAYOUT 11 +#define WID_PAGE_DURATION 12 +#define WID_PAGE_LDNAME 13 +#define WID_PAGE_LDBITMAP 14 +#define WID_PAGE_BACK 15 +#define WID_PAGE_PREVIEW 16 + +const SfxItemPropertyMap* ImplGetDrawPagePropertyMap( sal_Bool bImpress ) +{ + // Achtung: Der erste Parameter MUSS sortiert vorliegen !!! + static const SfxItemPropertyMap aDrawPagePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_CHANGE), WID_PAGE_CHANGE, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_DURATION), WID_PAGE_DURATION, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_EFFECT), WID_PAGE_EFFECT, &::getCppuType((const presentation::FadeEffect*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_SPEED), WID_PAGE_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, &::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + {0,0,0,0,0} + }; + + // Achtung: Der erste Parameter MUSS sortiert vorliegen !!! + static const SfxItemPropertyMap aGraphicPagePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet), beans::PropertyAttribute::MAYBEVOID,0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, &::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, + {0,0,0,0,0} + }; + + if( bImpress ) + return aDrawPagePropertyMap_Impl; + else + return aGraphicPagePropertyMap_Impl; +} + +const SfxItemPropertyMap* ImplGetMasterPagePropertyMap() +{ + static const SfxItemPropertyMap aMasterPagePropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE(beans::XPropertySet), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, + { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, + {0,0,0,0,0} + }; + return aMasterPagePropertyMap_Impl; +} + +SfxItemPropertyMap aEmptyPropertyMap_Impl[] = +{ + {0,0,0,0,0} +}; + +/*********************************************************************** +* * +***********************************************************************/ +SdGenericDrawPage::SdGenericDrawPage( SdXImpressDocument* _pModel, SdPage* pInPage, const SfxItemPropertyMap* pMap ) throw() +: SvxFmDrawPage( (SdrPage*) pInPage ), + mpPage ( pInPage ), + mpModel ( _pModel ), + maPropSet ( (pInPage&& (pInPage->GetPageKind() != PK_STANDARD))?&pMap[1]:pMap ), + SdUnoSearchReplaceShape(this), + mbHasBackgroundObject(sal_False) +{ + mxModel = (::cppu::OWeakObject*)(SvxDrawPage*)mpModel; +} + +SdGenericDrawPage::~SdGenericDrawPage() throw() +{ +} + +// this is called whenever a SdrObject must be created for a empty api shape wrapper +SdrObject * SdGenericDrawPage::_CreateSdrObject( const uno::Reference< drawing::XShape >& xShape ) throw() +{ + if( NULL == mpPage || !xShape.is() ) + return NULL; + + String aType( xShape->getShapeType() ); + const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") ); + if(aType.CompareTo( aPrefix, aPrefix.Len() ) != 0) + return SvxFmDrawPage::_CreateSdrObject( xShape ); + + aType = aType.Copy( aPrefix.Len() ); + + PresObjKind eObjKind = PRESOBJ_NONE; + + if( aType.EqualsAscii( "TitleTextShape" ) ) + { + eObjKind = PRESOBJ_TITLE; + } + else if( aType.EqualsAscii( "OutlinerShape" ) ) + { + eObjKind = PRESOBJ_OUTLINE; + } + else if( aType.EqualsAscii( "SubtitleShape" ) ) + { + eObjKind = PRESOBJ_TEXT; + } + else if( aType.EqualsAscii( "OLE2Shape" ) ) + { + eObjKind = PRESOBJ_OBJECT; + } + else if( aType.EqualsAscii( "ChartShape" ) ) + { + eObjKind = PRESOBJ_CHART; + } + else if( aType.EqualsAscii( "TableShape" ) ) + { + eObjKind = PRESOBJ_TABLE; + } + else if( aType.EqualsAscii( "GraphicObjectShape" ) ) + { +#ifdef STARIMAGE_AVAILABLE + eObjKind = PRESOBJ_IMAGE; +#else + eObjKind = PRESOBJ_GRAPHIC; +#endif + } + else if( aType.EqualsAscii( "OrgChartShape" ) ) + { + eObjKind = PRESOBJ_ORGCHART; + } + else if( aType.EqualsAscii( "PageShape" ) ) + { + if( mpPage->GetPageKind() == PK_NOTES && mpPage->IsMasterPage() ) + eObjKind = PRESOBJ_TITLE; + else + eObjKind = PRESOBJ_PAGE; + } + else if( aType.EqualsAscii( "NotesShape" ) ) + { + eObjKind = PRESOBJ_NOTES; + } + else if( aType.EqualsAscii( "HandoutShape" ) ) + { + eObjKind = PRESOBJ_HANDOUT; + } + + Rectangle aRect( eObjKind == PRESOBJ_TITLE ? mpPage->GetTitleRect() : mpPage->GetLayoutRect() ); + + const awt::Point aPos( aRect.Left(), aRect.Top() ); + xShape->setPosition( aPos ); + + const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() ); + xShape->setSize( aSize ); + + SdrObject *pPresObj = mpPage->CreatePresObj( eObjKind, aRect, sal_True ); + + if( pPresObj ) + pPresObj->SetUserCall( mpPage ); + + return pPresObj; +} + +// XInterface +uno::Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + uno::Any aAny; + + QUERYINT( beans::XPropertySet ); + else QUERYINT( container::XNamed ); + else QUERYINT( util::XReplaceable ); + else QUERYINT( util::XSearchable ); + else QUERYINT( document::XLinkTargetSupplier ); + else QUERYINT( drawing::XShapeCombiner ); + else QUERYINT( drawing::XShapeBinder ); + else + return SvxDrawPage::queryInterface( rType ); + + return aAny; +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return maPropSet.getPropertySetInfo(); +} + +void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if( (mpPage == NULL) || (mpModel == NULL) ) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = maPropSet.getPropertyMapEntry(aPropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_PAGE_LEFT: + case WID_PAGE_RIGHT: + case WID_PAGE_TOP: + case WID_PAGE_BOTTOM: + case WID_PAGE_LAYOUT: + case WID_PAGE_DURATION: + case WID_PAGE_CHANGE: + { + sal_Int32 nValue; + if(!(aValue >>= nValue)) + throw lang::IllegalArgumentException(); + + switch( pMap->nWID ) + { + case WID_PAGE_LEFT: + mpPage->SetLftBorder(nValue); + break; + case WID_PAGE_RIGHT: + mpPage->SetRgtBorder(nValue); + break; + case WID_PAGE_TOP: + mpPage->SetUppBorder(nValue); + break; + case WID_PAGE_BOTTOM: + mpPage->SetLwrBorder(nValue); + break; + case WID_PAGE_CHANGE: + mpPage->SetPresChange( (PresChange)nValue ); + break; + case WID_PAGE_LAYOUT: + mpPage->SetAutoLayout( (AutoLayout)nValue, sal_True ); + break; + case WID_PAGE_DURATION: + mpPage->SetTime((sal_uInt32)nValue); + break; + } + break; + } + case WID_PAGE_WIDTH: + { + sal_Int32 nWidth; + if(!(aValue >>= nWidth)) + throw lang::IllegalArgumentException(); + + Size aSize( mpPage->GetSize() ); + aSize.setWidth( nWidth ); + mpPage->SetSize(aSize); + break; + } + case WID_PAGE_HEIGHT: + { + sal_Int32 nHeight; + if(!(aValue >>= nHeight)) + throw lang::IllegalArgumentException(); + + Size aSize( mpPage->GetSize() ); + aSize.setHeight(nHeight); + mpPage->SetSize(aSize); + break; + } + case WID_PAGE_ORIENT: + { + sal_Int32 nEnum; + if(!::cppu::enum2int( nEnum, aValue )) + throw lang::IllegalArgumentException(); + + view::PaperOrientation eOri = (view::PaperOrientation)nEnum; + mpPage->SetOrientation( eOri == view::PaperOrientation_PORTRAIT?ORIENTATION_PORTRAIT:ORIENTATION_LANDSCAPE ); + break; + } + case WID_PAGE_EFFECT: + { + sal_Int32 nEnum; + if(!::cppu::enum2int( nEnum, aValue )) + throw lang::IllegalArgumentException(); + + mpPage->SetFadeEffect( (presentation::FadeEffect)nEnum ); + break; + } + case WID_PAGE_BACK: + setBackground( aValue ); + break; + case WID_PAGE_SPEED: + { + sal_Int32 nEnum; + if(!::cppu::enum2int( nEnum, aValue )) + throw lang::IllegalArgumentException(); + + mpPage->SetFadeSpeed( (FadeSpeed) nEnum ); + break; + } + default: + throw beans::UnknownPropertyException(); + break; + } + + mpModel->SetModified(); +} + +/*********************************************************************** +* * +***********************************************************************/ +uno::Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + if( (mpPage == NULL) || (mpModel == NULL) ) + throw uno::RuntimeException(); + + const SfxItemPropertyMap* pMap = maPropSet.getPropertyMapEntry(PropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_PAGE_LEFT: + aAny <<= (sal_Int32)( mpPage->GetLftBorder() ); + break; + case WID_PAGE_RIGHT: + aAny <<= (sal_Int32)( mpPage->GetRgtBorder() ); + break; + case WID_PAGE_TOP: + aAny <<= (sal_Int32)( mpPage->GetUppBorder() ); + break; + case WID_PAGE_BOTTOM: + aAny <<= (sal_Int32)( mpPage->GetLwrBorder() ); + break; + case WID_PAGE_WIDTH: + aAny <<= (sal_Int32)( mpPage->GetSize().getWidth() ); + break; + case WID_PAGE_HEIGHT: + aAny <<= (sal_Int32)( mpPage->GetSize().getHeight() ); + break; + case WID_PAGE_ORIENT: + aAny = ::cppu::int2enum( (sal_Int32)((mpPage->GetOrientation() == ORIENTATION_PORTRAIT)? view::PaperOrientation_PORTRAIT: view::PaperOrientation_LANDSCAPE), ::getCppuType((const view::PaperOrientation*)0) ); + break; + case WID_PAGE_EFFECT: + aAny = ::cppu::int2enum( (sal_Int32)mpPage->GetFadeEffect(), ::getCppuType((const presentation::FadeEffect*)0) ); + break; + case WID_PAGE_CHANGE: + aAny <<= (sal_Int32)( mpPage->GetPresChange() ); + break; + case WID_PAGE_SPEED: + aAny = ::cppu::int2enum( (sal_Int32)mpPage->GetFadeSpeed(), ::getCppuType((const presentation::AnimationSpeed*)0) ); + break; + case WID_PAGE_LAYOUT: + aAny <<= (sal_Int16)( mpPage->GetAutoLayout() ); + break; + case WID_PAGE_NUMBER: + aAny <<= (sal_Int16)((sal_uInt16)((mpPage->GetPageNum()-1)>>1) + 1); + break; + case WID_PAGE_DURATION: + aAny <<= (sal_Int32)(mpPage->GetTime()); + break; + case WID_PAGE_LDNAME: + { + const OUString aName( mpPage->GetName() ); + aAny <<= aName; + break; + } + case WID_PAGE_LDBITMAP: + { + uno::Reference< awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap( BitmapEx( SdResId( BMP_PAGE ) ) ) ); + aAny <<= xBitmap; + } + break; + case WID_PAGE_BACK: + getBackground( aAny ); + break; + case WID_PAGE_PREVIEW : + { + SdDrawDocShell* pDocShell = ((SdDrawDocument*)mpPage->GetModel())->GetDocSh(); + if ( pDocShell ) + { + SdDrawDocument* pDoc = pDocShell->GetDoc(); + if ( pDoc ) + { + sal_uInt16 nPgNum = 0; + sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD ); + sal_uInt16 nPageNumber = ( (sal_uInt16)( ( mpPage->GetPageNum() - 1 ) >> 1 ) + 1 ); + while( nPgNum < nPageCount ) + { + pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber ); + nPgNum++; + } + GDIMetaFile* pMetaFile = pDocShell->GetPreviewMetaFile(); + if ( pMetaFile ) + { + Point aPoint; + Size aSize( mpPage->GetSize() ); + pMetaFile->AddAction( (MetaAction*) new MetaFillColorAction( COL_WHITE, TRUE ), 0 ); + pMetaFile->AddAction( (MetaAction*) new MetaRectAction( Rectangle( aPoint, aSize ) ), 1 ); + pMetaFile->SetPrefMapMode( MAP_100TH_MM ); + pMetaFile->SetPrefSize( aSize ); + + SvMemoryStream aDestStrm( 65535, 65535 ); + ConvertGDIMetaFileToWMF( *pMetaFile, aDestStrm, NULL, NULL, sal_False ); + uno::Sequence<sal_Int8> aSeq((sal_Int8*)aDestStrm.GetData(), aDestStrm.GetSize()); + aAny <<= aSeq; + delete pMetaFile; + } + } + } + } + break; + default: + throw beans::UnknownPropertyException(); + break; + } + return aAny; +} + +void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} + +uno::Reference< drawing::XShape > SdGenericDrawPage::_CreateShape( SdrObject *pObj ) const +{ + SvxShape* pShape = SvxShape::GetShapeForSdrObj( pObj ); + if(pShape != NULL) + return uno::Reference< drawing::XShape > (pShape); + + PresObjKind eKind = mpPage->GetPresObjKind(pObj); + + if(pObj->GetObjInventor() == SdrInventor) + { + sal_uInt32 nInventor = pObj->GetObjIdentifier(); + switch( nInventor ) + { + case OBJ_TITLETEXT: + pShape = new SvxShape( pObj ); + if( mpPage->GetPageKind() == PK_NOTES && mpPage->IsMasterPage() ) + { + // fake a empty PageShape if its a title shape on the master page + pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"))); + } + else + { + pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"))); + } + eKind = PRESOBJ_NONE; + break; + case OBJ_OUTLINETEXT: + pShape = new SvxShape( pObj ); + pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"))); + eKind = PRESOBJ_NONE; + break; + } + } + + uno::Reference< drawing::XShape > xShape( pShape ); + + if(!xShape.is()) + xShape = SvxFmDrawPage::_CreateShape( pObj ); + + + if( eKind != PRESOBJ_NONE ) + { + String aShapeType( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.")); + + switch( eKind ) + { + case PRESOBJ_TITLE: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TitleTextShape") ); + break; + case PRESOBJ_OUTLINE: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OutlinerShape") ); + break; + case PRESOBJ_TEXT: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TextShape") ); + break; + case PRESOBJ_GRAPHIC: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape") ); + break; + case PRESOBJ_OBJECT: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OLE2Shape") ); + break; + case PRESOBJ_CHART: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("ChartShape") ); + break; + case PRESOBJ_ORGCHART: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OrgChartShape") ); + break; + case PRESOBJ_TABLE: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TableShape") ); + break; + case PRESOBJ_BACKGROUND: + DBG_ASSERT( sal_False, "Danger! Someone got hold of the horrible background shape!" ); + break; + case PRESOBJ_PAGE: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("PageShape") ); + break; + case PRESOBJ_HANDOUT: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HandoutShape") ); + break; + case PRESOBJ_NOTES: + aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("NotesShape") ); + break; + } + + SvxShape* pShape = SvxShape::getImplementation( xShape ); + if( pShape ) + pShape->SetShapeType( aShapeType ); + } + + // SdXShape aggregiert SvxShape + new SdXShape( xShape, mpModel ); + return xShape; +} + +// XServiceInfo +uno::Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() ); + SvxServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.drawing.GenericDrawPage", + "com.sun.star.document.LinkTarget", + "com.sun.star.document.LinkTargetSupplier"); + return aSeq; +} + +// XLinkTargetSupplier +uno::Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( ) + throw(uno::RuntimeException) +{ + return new SdPageLinkTargets( (SdGenericDrawPage*)this ); +} + +void SdGenericDrawPage::setBackground( const uno::Any& rValue ) throw() +{ + DBG_ERROR( "Don't call me, I'm useless!" ); +} + +void SdGenericDrawPage::getBackground( uno::Any& rValue ) throw() +{ + DBG_ERROR( "Don't call me, I'm useless!" ); +} + +//---------------------------------------------------------------------- +uno::Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const uno::Reference< drawing::XShapes >& xShapes ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT(pPage,"SdrPage ist NULL! [CL]"); + DBG_ASSERT(pView, "SdrView ist NULL! [CL]"); + + uno::Reference< drawing::XShape > xShape; + if(mpPage==NULL||pView==NULL||!xShapes.is()||mpModel==NULL) + return xShape; + + SdrPageView* pPageView = pView->ShowPage( mpPage, Point() ); + + _SelectObjectsInView( xShapes, pPageView ); + + pView->CombineMarkedObjects( sal_False ); + + pView->AdjustMarkHdl(); + const SdrMarkList& rMarkList = pView->GetMarkList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + if( pObj ) + { + xShape = _CreateShape( pObj ); + } + } + + pView->HidePage(pPageView); + + mpModel->SetModified(); + + return xShape; +} + +//---------------------------------------------------------------------- +void SAL_CALL SdGenericDrawPage::split( const uno::Reference< drawing::XShape >& xGroup ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage==NULL||pView==NULL||!xGroup.is()||mpModel==NULL) + return; + + SdrPageView* pPageView = pView->ShowPage( mpPage, Point() ); + _SelectObjectInView( xGroup, pPageView ); + pView->DismantleMarkedObjects( sal_False ); + pView->HidePage(pPageView); + + mpModel->SetModified(); +} + +//---------------------------------------------------------------------- +uno::Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const uno::Reference< drawing::XShapes >& xShapes ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Reference< drawing::XShape > xShape; + if(mpPage==NULL||pView==NULL||!xShapes.is()||mpModel==NULL) + return xShape; + + SdrPageView* pPageView = pView->ShowPage( mpPage, Point() ); + + _SelectObjectsInView( xShapes, pPageView ); + + pView->CombineMarkedObjects( sal_True ); + + pView->AdjustMarkHdl(); + const SdrMarkList& rMarkList = pView->GetMarkList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetObj(); + if( pObj ) + { + xShape = _CreateShape( pObj ); + } + } + + pView->HidePage(pPageView); + + mpModel->SetModified(); + + return xShape; +} + +//---------------------------------------------------------------------- +void SAL_CALL SdGenericDrawPage::unbind( const uno::Reference< drawing::XShape >& xShape ) + throw( uno::RuntimeException ) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage==NULL||pView==NULL||!xShape.is()||mpModel==NULL) + return; + + SdrPageView* pPageView = pView->ShowPage( mpPage, Point() ); + _SelectObjectInView( xShape, pPageView ); + pView->DismantleMarkedObjects( sal_True ); + pView->HidePage(pPageView); + + mpModel->SetModified(); +} + +//======================================================================== +// SdPageLinkTargets +//======================================================================== + +SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw() +{ + mxPage = pUnoPage; + mpUnoPage = pUnoPage; +} + +SdPageLinkTargets::~SdPageLinkTargets() throw() +{ +} + + // XElementAccess +uno::Type SAL_CALL SdPageLinkTargets::getElementType() + throw(uno::RuntimeException) +{ + return ITYPE(beans::XPropertySet); +} + +sal_Bool SAL_CALL SdPageLinkTargets::hasElements() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + SdPage* mpPage = mpUnoPage->GetPage(); + if( mpPage != NULL ) + { + SdrObjListIter aIter( *mpPage, IM_DEEPWITHGROUPS ); + + while( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + String aStr( pObj->GetName() ); + if( aStr.Len() ) + return sal_True; + } + } + + return sal_False; +} + +// container::XNameAccess + +// XNameAccess +uno::Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName ) + throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + SdPage* mpPage = mpUnoPage->GetPage(); + if( mpPage != NULL ) + { + SdrObject* pObj = FindObject( aName ); + if( pObj != NULL ) + { + uno::Reference< drawing::XShape > xShape = SvxShape::GetShapeForSdrObj( pObj ); + if( !xShape.is() ) + xShape = mpUnoPage->_CreateShape( pObj ); + + uno::Reference< beans::XPropertySet > aRef( xShape, uno::UNO_QUERY ); + aAny <<= aRef; + } + } + + return aAny; +} + +uno::Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_uInt32 nObjCount = 0; + + SdPage* mpPage = mpUnoPage->GetPage(); + if( mpPage != NULL ) + { + SdrObjListIter aIter( *mpPage, IM_DEEPWITHGROUPS ); + while( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + String aStr( pObj->GetName() ); + if( aStr.Len() ) + nObjCount++; + } + } + + uno::Sequence< OUString > aSeq( nObjCount ); + if( nObjCount > 0 ) + { + OUString* pStr = aSeq.getArray(); + + SdrObjListIter aIter( *mpPage, IM_DEEPWITHGROUPS ); + while( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + String aStr( pObj->GetName() ); + if( aStr.Len() ) + *pStr++ = aStr; + } + } + + return aSeq; +} + +sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + return FindObject( aName ) != NULL; +} + +/*********************************************************************** +* * +***********************************************************************/ +SdrObject* SdPageLinkTargets::FindObject( const String& rName ) const throw() +{ + SdPage* mpPage = mpUnoPage->GetPage(); + if( mpPage == NULL ) + return NULL; + + SdrObjListIter aIter( *mpPage, IM_DEEPWITHGROUPS ); + + while( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + String aStr( pObj->GetName() ); + if( aStr.Len() && (aStr == rName) ) + return pObj; + } + + return NULL; +} + +// XServiceInfo +OUString SAL_CALL SdPageLinkTargets::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdPageLinkTargets") ); +} + +sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") ); + uno::Sequence< OUString > aSeq( &aSN, 1); + return aSeq; +} + +//======================================================================== +// SdDrawPage +//======================================================================== + +SdDrawPage::SdDrawPage( SdXImpressDocument* mpModel, SdPage* mpPage ) throw() +: SdGenericDrawPage( mpModel, mpPage, ImplGetDrawPagePropertyMap( mpModel->IsImpressDocument() ) ) +{ +} + +SdDrawPage::~SdDrawPage() throw() +{ +} + +// XInterface +uno::Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + uno::Any aAny; + if( rType == ITYPE( drawing::XMasterPageTarget ) ) + aAny <<= uno::Reference< drawing::XMasterPageTarget >( this ); + else if( mpModel && mpModel->IsImpressDocument() && + mpPage && mpPage->GetPageKind() != PK_HANDOUT && + rType == ITYPE( presentation::XPresentationPage ) ) + aAny <<= uno::Reference< presentation::XPresentationPage >( this ); + else + return SdGenericDrawPage::queryInterface( rType ); + + return aAny; +} + +void SAL_CALL SdDrawPage::acquire() throw(uno::RuntimeException) +{ + SvxDrawPage::acquire(); +} + +void SAL_CALL SdDrawPage::release() throw(uno::RuntimeException) +{ + SvxDrawPage::release(); +} + +UNO3_GETIMPLEMENTATION_IMPL( SdDrawPage ); + +// XTypeProvider +uno::Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeException) +{ + if( maTypeSequence.getLength() == 0 ) + { + sal_Bool bPresPage = mpModel && mpModel->IsImpressDocument() && mpPage && mpPage->GetPageKind() != PK_HANDOUT; + + const uno::Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() ); + const sal_Int32 nBaseTypes = aBaseTypes.getLength(); + const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); + + const sal_Int32 nOwnTypes = bPresPage ? 10 : 9; // !DANGER! Keep this updated! + + maTypeSequence.realloc( nBaseTypes + nOwnTypes ); + uno::Type* pTypes = maTypeSequence.getArray(); + + *pTypes++ = ITYPE(drawing::XDrawPage); + *pTypes++ = ITYPE(beans::XPropertySet); + *pTypes++ = ITYPE(container::XNamed); + *pTypes++ = ITYPE(drawing::XMasterPageTarget); + *pTypes++ = ITYPE(lang::XServiceInfo); + *pTypes++ = ITYPE(util::XReplaceable); + *pTypes++ = ITYPE(document::XLinkTargetSupplier); + *pTypes++ = ITYPE( drawing::XShapeCombiner ); + *pTypes++ = ITYPE( drawing::XShapeBinder ); + + if( bPresPage ) + *pTypes++ = ITYPE(presentation::XPresentationPage); + + for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) + *pTypes++ = *pBaseTypes++; + } + + return maTypeSequence; +} + +uno::Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId() throw(uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// XServiceInfo +OUString SAL_CALL SdDrawPage::getImplementationName() throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDrawPage") ); +} + +uno::Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames() throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() ); + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.DrawPage" ); + + if( mpModel && mpModel->IsImpressDocument() ) + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.DrawPage" ); + + return aSeq; +} + +sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::supportsService( ServiceName ); +} + +// XNamed +void SAL_CALL SdDrawPage::setName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT( mpPage && !mpPage->IsMasterPage(), "Don't call base implementation for masterpages!" ); + + if(mpPage && mpPage->GetPageKind() != PK_NOTES) + { + mpPage->SetName( aName ); + + SdPage* pNotesPage = mpModel->GetDoc()->GetSdPage( (mpPage->GetPageNum()-1)>>1, PK_NOTES ); + pNotesPage->SetName(mpPage->GetName()); + + // fake a mode change to repaint the page tab bar + SdDrawDocShell* pDocSh = mpModel->GetDocShell(); + SdViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL; + if( pViewSh && pViewSh->ISA( SdDrawViewShell ) ) + { + SdDrawViewShell* pDrawViewSh = (SdDrawViewShell*)pViewSh; + + EditMode eMode = pDrawViewSh->GetEditMode(); + if( eMode == EM_PAGE ) + { + BOOL bLayer = pDrawViewSh->GetLayerMode(); + + pDrawViewSh->ChangeEditMode( eMode, !bLayer ); + pDrawViewSh->ChangeEditMode( eMode, bLayer ); + } + } + + mpModel->SetModified(); + } +} + +OUString SAL_CALL SdDrawPage::getName() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage) + return mpPage->GetName(); + + return OUString(); +} + +// XMasterPageTarget +uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT(mpModel,"SdDrawPage hat kein Model??"); + if(mpModel && mpPage) + { + uno::Reference< drawing::XDrawPages > xPages( mpModel->getMasterPages() ); + return mpModel->CreateXDrawPage((SdPage*)mpPage->GetMasterPage(0)); + } + return NULL; +} + +void SAL_CALL SdDrawPage::setMasterPage( const uno::Reference< drawing::XDrawPage >& xMasterPage ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + DBG_ASSERT(mpModel,"SdDrawPage hat kein Model??"); + if(mpModel && mpPage) + { + SdMasterPage* pMasterPage = SdMasterPage::getImplementation( xMasterPage ); + if( pMasterPage && pMasterPage->isValid() ) + { + mpPage->RemoveMasterPage(0); + + SdPage* pSdPage = (SdPage*) pMasterPage->GetSdrPage(); + sal_uInt16 nPos = pSdPage->GetPageNum(); + mpPage->InsertMasterPage(nPos); + + mpModel->SetModified(); + } + + } +} + +// XPresentationPage +uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage && mpModel && mpModel->GetDoc() ) + { + SdPage* pNotesPage = mpModel->GetDoc()->GetSdPage( (mpPage->GetPageNum()-1)>>1, PK_NOTES ); + return mpModel->CreateXDrawPage(pNotesPage); + } + return NULL; +} + + +// XIndexAccess +sal_Int32 SAL_CALL SdDrawPage::getCount() + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::getCount(); +} + +uno::Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + return SdGenericDrawPage::getByIndex( Index ); +} + +// XElementAccess +uno::Type SAL_CALL SdDrawPage::getElementType() + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::getElementType(); +} + +sal_Bool SAL_CALL SdDrawPage::hasElements() + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::hasElements(); +} + +// XShapes +void SAL_CALL SdDrawPage::add( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) +{ + SdGenericDrawPage::add( xShape ); +} + +void SAL_CALL SdDrawPage::remove( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) +{ + SvxShape* pShape = SvxShape::getImplementation( xShape ); + if( pShape ) + { + SdrObject* pObj = pShape->GetSdrObject(); + if( pObj ) + mpPage->GetPresObjList()->Remove((void*) pObj); + } + + SdGenericDrawPage::remove( xShape ); +} + +void SdDrawPage::setBackground( const uno::Any& rValue ) + throw( lang::IllegalArgumentException ) +{ + if( rValue.getValue() == NULL ) + { + // the easy case, clear the background obj + mpPage->SetBackgroundObj( NULL ); + return; + } + + uno::Reference< beans::XPropertySet > xSet; + + if( !::cppu::extractInterface( xSet, rValue ) ) + throw lang::IllegalArgumentException(); + + // prepare background object + SdrObject* pObj = mpPage->GetBackgroundObj(); + if( NULL == pObj ) + { + pObj = new SdrRectObj(); + mpPage->SetBackgroundObj( pObj ); + } + + const sal_Int32 nLeft = mpPage->GetLftBorder(); + const sal_Int32 nRight = mpPage->GetRgtBorder(); + const sal_Int32 nUpper = mpPage->GetUppBorder(); + const sal_Int32 nLower = mpPage->GetLwrBorder(); + + Point aPos ( nLeft, nRight ); + Size aSize( mpPage->GetSize() ); + aSize.Width() -= nLeft + nRight - 1; + aSize.Height() -= nUpper + nLower - 1; + Rectangle aRect( aPos, aSize ); + pObj->SetLogicRect( aRect ); + + // is it our own implementation? + SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet ); + + SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILLRESERVED_LAST ); + + if( pBack ) + { + pBack->fillItemSet( aSet ); + } + else + { + SdUnoPageBackground* pBackground = new SdUnoPageBackground(); + + uno::Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); + uno::Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground ); + uno::Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() ); + + uno::Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() ); + sal_Int32 nCount = aProperties.getLength(); + beans::Property* pProp = aProperties.getArray(); + + while( nCount-- ) + { + const OUString aPropName( pProp->Name ); + if( xSetInfo->hasPropertyByName( aPropName ) ) + xDestSet->setPropertyValue( aPropName, + xSet->getPropertyValue( aPropName ) ); + + pProp++; + } + + pBackground->fillItemSet( aSet ); + } + + pObj->NbcSetAttributes( aSet, sal_False ); + mpPage->SendRepaintBroadcast(); +} + +void SdDrawPage::getBackground( uno::Any& rValue ) throw() +{ + SdrObject* pObj = mpPage->GetBackgroundObj(); + if( NULL == pObj ) + { + rValue.clear(); + } + else + { + uno::Reference< beans::XPropertySet > xSet( new SdUnoPageBackground( GetModel()->GetDoc(), pObj ) ); + rValue <<= xSet; + } +} + +//======================================================================== +// class SdMasterPage +//======================================================================== + +SdMasterPage::SdMasterPage( SdXImpressDocument* mpModel, SdPage* mpPage ) throw() +: SdGenericDrawPage( mpModel, mpPage, ImplGetMasterPagePropertyMap() ), + mpBackgroundObj(NULL) +{ + if( mpPage && mpPage->GetPageKind() == PK_STANDARD ) + { + sal_uInt32 nMasterIndex = 0; + sal_uInt32 nMasterCount = mpPage->GetPresObjList()->Count(); + + for (nMasterIndex = 0; nMasterIndex < nMasterCount; nMasterIndex++) + { + // loop over all presentation objects in the masterpage + SdrObject* pMasterObj = (SdrObject*) mpPage->GetPresObjList()->GetObject(nMasterIndex); + + if (pMasterObj && pMasterObj->GetObjInventor() == SdrInventor) + { + sal_uInt16 nId = pMasterObj->GetObjIdentifier(); + + if (nId == OBJ_RECT && pMasterObj->IsEmptyPresObj() ) + { + mpBackgroundObj = pMasterObj; + break; + } + } + } + + mbHasBackgroundObject = sal_True; + } +} + +SdMasterPage::~SdMasterPage() throw() +{ +} + +// XInterface +uno::Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType ) + throw(uno::RuntimeException) +{ + uno::Any aAny; + + if( rType == ITYPE( container::XIndexAccess ) ) + aAny <<= uno::Reference< container::XIndexAccess >((presentation::XPresentationPage*)(this)); + else if( rType == ITYPE( container::XElementAccess ) ) + aAny <<= uno::Reference< container::XElementAccess >((presentation::XPresentationPage*)(this)); + else if( rType == ITYPE( container::XNamed ) ) + aAny <<= uno::Reference< container::XNamed >(this); + else if( rType == ITYPE( presentation::XPresentationPage ) && + ( mpModel && mpModel->IsImpressDocument() && + mpPage && mpPage->GetPageKind() != PK_HANDOUT) ) + aAny <<= uno::Reference< presentation::XPresentationPage >( this ); + else + return SdGenericDrawPage::queryInterface( rType ); + + return aAny; +} + +void SAL_CALL SdMasterPage::acquire() throw(uno::RuntimeException) +{ + SvxDrawPage::acquire(); +} + +void SAL_CALL SdMasterPage::release() throw(uno::RuntimeException) +{ + SvxDrawPage::release(); +} + +UNO3_GETIMPLEMENTATION_IMPL(SdMasterPage); + +// XTypeProvider +uno::Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeException) +{ + if( maTypeSequence.getLength() == 0 ) + { + sal_Bool bPresPage = mpModel && mpModel->IsImpressDocument() && mpPage && mpPage->GetPageKind() != PK_HANDOUT; + + const uno::Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() ); + const sal_Int32 nBaseTypes = aBaseTypes.getLength(); + const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); + + const sal_Int32 nOwnTypes = bPresPage ? 9 : 8; // !DANGER! Keep this updated! + + maTypeSequence.realloc( nBaseTypes + nOwnTypes ); + uno::Type* pTypes = maTypeSequence.getArray(); + + *pTypes++ = ITYPE(drawing::XDrawPage); + *pTypes++ = ITYPE(beans::XPropertySet); + *pTypes++ = ITYPE(container::XNamed); + *pTypes++ = ITYPE(lang::XServiceInfo); + *pTypes++ = ITYPE(util::XReplaceable); + *pTypes++ = ITYPE(document::XLinkTargetSupplier); + *pTypes++ = ITYPE( drawing::XShapeCombiner ); + *pTypes++ = ITYPE( drawing::XShapeBinder ); + + if( bPresPage ) + *pTypes++ = ITYPE(presentation::XPresentationPage); + + for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) + *pTypes++ = *pBaseTypes++; + } + + return maTypeSequence; +} + +uno::Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId() throw(uno::RuntimeException) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +// XServiceInfo +OUString SAL_CALL SdMasterPage::getImplementationName() throw(uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("SdMasterPage") ); +} + +uno::Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames() throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() ); + SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.MasterPage" ); + + return aSeq; +} + +sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::supportsService( ServiceName ); +} + +// XElementAccess +sal_Bool SAL_CALL SdMasterPage::hasElements() throw(uno::RuntimeException) +{ + if( mpPage == NULL ) + return sal_False; + + return mpPage && + ( + (mpPage->GetObjCount() > 1) || + (!mbHasBackgroundObject && mpPage->GetObjCount() == 1 ) + ); +} + +uno::Type SAL_CALL SdMasterPage::getElementType() + throw(uno::RuntimeException) +{ + return SdGenericDrawPage::getElementType(); +} + +// XIndexAccess +sal_Int32 SAL_CALL SdMasterPage::getCount() + throw(uno::RuntimeException) +{ + sal_Int32 nCount = SdGenericDrawPage::getCount(); + if( mbHasBackgroundObject ) + nCount--; + + return nCount; +} + +uno::Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index ) + throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( mbHasBackgroundObject ) + Index++; + + return SdGenericDrawPage::getByIndex(Index); +} + +// intern +void SdMasterPage::setBackground( const uno::Any& rValue ) + throw( lang::IllegalArgumentException ) +{ + // we need at least an beans::XPropertySet + uno::Reference< beans::XPropertySet > xSet; + if( !::cppu::extractInterface( xSet, rValue ) ) + throw lang::IllegalArgumentException(); + + if( mpModel && mpModel->IsImpressDocument() ) + { + uno::Reference< container::XNameAccess > xFamilies = mpModel->getStyleFamilies(); + uno::Any aAny( xFamilies->getByName( getName() ) ); + + uno::Reference< container::XNameAccess > xFamily; + if( !::cppu::extractInterface( xSet, rValue ) ) + throw uno::RuntimeException(); + + OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) ); + + try + { + aAny = xFamily->getByName( aStyleName ); + + uno::Reference< style::XStyle > xStyle( *(uno::Reference< style::XStyle > *)aAny.getValue() ); + uno::Reference< beans::XPropertySet > xStyleSet( xStyle, uno::UNO_QUERY ); + if( xStyleSet.is() ) + { + uno::Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); + + const SfxItemPropertyMap* pMap = ImplGetPageBackgroundPropertyMap(); + while( pMap->pName ) + { + const OUString aPropName( OUString::createFromAscii(pMap->pName) ); + if( xSetInfo->hasPropertyByName( aPropName ) ) + xStyleSet->setPropertyValue( aPropName, + xSet->getPropertyValue( aPropName ) ); + + ++pMap; + } + } + } + catch(...) + { + // + } + } + else + { + // prepare background object + SdrObject* pObj = NULL; + if( mpPage->GetObjCount() >= 1 ) + { + pObj = mpPage->GetObj(0); + if( pObj->GetObjInventor() != SdrInventor || pObj->GetObjIdentifier() != OBJ_RECT ) + pObj = NULL; + } + + if( pObj == NULL ) + return; + + const sal_Int32 nLeft = mpPage->GetLftBorder(); + const sal_Int32 nRight = mpPage->GetRgtBorder(); + const sal_Int32 nUpper = mpPage->GetUppBorder(); + const sal_Int32 nLower = mpPage->GetLwrBorder(); + + awt::Point aPos ( nLeft, nRight ); + awt::Size aSize( mpPage->GetSize().Width(), mpPage->GetSize().Height() ); + aSize.Width -= nLeft + nRight - 1; + aSize.Height -= nUpper + nLower - 1; + Rectangle aRect( aPos.X, aPos.Y, aSize.Width, aSize.Height ); + pObj->SetLogicRect( aRect ); + + // is it our own implementation? + SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet ); + + SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILLRESERVED_LAST ); + + if( pBack ) + { + pBack->fillItemSet( aSet ); + } + else + { + SdUnoPageBackground* pBackground = new SdUnoPageBackground(); + + uno::Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); + uno::Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground ); + uno::Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() ); + + uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() ); + sal_Int32 nCount = aProperties.getLength(); + beans::Property* pProp = aProperties.getArray(); + + while( nCount-- ) + { + const OUString aPropName( pProp->Name ); + if( xSetInfo->hasPropertyByName( aPropName ) ) + xDestSet->setPropertyValue( aPropName, + xSet->getPropertyValue( aPropName ) ); + + pProp++; + } + + pBackground->fillItemSet( aSet ); + } + + pObj->NbcSetAttributes( aSet, sal_False ); + mpPage->SendRepaintBroadcast(); + } +} + +void SdMasterPage::getBackground( uno::Any& rValue ) throw() +{ + if( mpModel && mpModel->IsImpressDocument() ) + { + try + { + uno::Reference< container::XNameAccess > xFamilies( mpModel->getStyleFamilies() ); + uno::Any aAny( xFamilies->getByName( getName() ) ); + uno::Reference< container::XNameAccess > xFamily( *(uno::Reference< container::XNameAccess >*)aAny.getValue() ); + + const OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) ); + aAny = xFamily->getByName( aStyleName ); + uno::Reference< style::XStyle > xStyle( *(uno::Reference< style::XStyle > *)aAny.getValue() ); + + uno::Reference< beans::XPropertySet > xStyleSet( xStyle, uno::UNO_QUERY ); + rValue <<= xStyleSet; + } + catch(...) + { + rValue.clear(); + } + } + else + { + SdrObject* pObj = NULL; + if( mpPage->GetObjCount() >= 1 ) + { + pObj = mpPage->GetObj(0); + if( pObj->GetObjInventor() != SdrInventor || pObj->GetObjIdentifier() != OBJ_RECT ) + pObj = NULL; + } + + if( NULL == pObj ) + { + rValue.clear(); + } + else + { + uno::Reference< beans::XPropertySet > xSet( new SdUnoPageBackground( GetModel()->GetDoc(), pObj ) ); + rValue <<= xSet; + } + } +} + +// XNamed +void SAL_CALL SdMasterPage::setName( const OUString& aName ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage && mpPage->GetPageKind() != PK_NOTES) + { + String aNewName( aName ); + mpPage->SetName( aNewName ); + + if(mpModel->GetDoc()) + mpModel->GetDoc()->RenameLayoutTemplate(mpPage->GetLayoutName(), aNewName); + + // fake a mode change to repaint the page tab bar + SdDrawDocShell* pDocSh = mpModel->GetDocShell(); + SdViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL; + if( pViewSh && pViewSh->ISA( SdDrawViewShell ) ) + { + SdDrawViewShell* pDrawViewSh = (SdDrawViewShell*)pViewSh; + + EditMode eMode = pDrawViewSh->GetEditMode(); + if( eMode == EM_MASTERPAGE ) + { + BOOL bLayer = pDrawViewSh->GetLayerMode(); + + pDrawViewSh->ChangeEditMode( eMode, !bLayer ); + pDrawViewSh->ChangeEditMode( eMode, bLayer ); + } + } + + mpModel->SetModified(); + } +} + +OUString SAL_CALL SdMasterPage::getName( ) + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage) + { + String aLayoutName( mpPage->GetLayoutName() ); + aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM((SD_LT_SEPARATOR))))); + + return aLayoutName; + } + + return OUString(); +} + +// XPresentationPage +uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage() + throw(uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + if(mpPage && mpModel && mpModel->GetDoc() ) + { + SdPage* pNotesPage = mpModel->GetDoc()->GetMasterSdPage( (mpPage->GetPageNum()-1)>>1, PK_NOTES ); + return mpModel->CreateXDrawPage(pNotesPage); + } + return NULL; +} + +// XShapes +void SAL_CALL SdMasterPage::add( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) +{ + SdGenericDrawPage::add( xShape ); +} + +void SAL_CALL SdMasterPage::remove( const uno::Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException) +{ + SvxShape* pShape = SvxShape::getImplementation( xShape ); + if( pShape ) + { + SdrObject* pObj = pShape->GetSdrObject(); + if( pObj ) + mpPage->GetPresObjList()->Remove((void*) pObj); + } + + SdGenericDrawPage::remove( xShape ); +} + + diff --git a/sd/source/ui/unoidl/unopage.hxx b/sd/source/ui/unoidl/unopage.hxx new file mode 100644 index 000000000000..02c5407a7855 --- /dev/null +++ b/sd/source/ui/unoidl/unopage.hxx @@ -0,0 +1,320 @@ +/************************************************************************* + * + * $RCSfile: unopage.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:42 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SD_UNOPAGE_HXX +#define _SD_UNOPAGE_HXX + +#ifndef _COM_SUN_STAR_DOCUMENT_XLINKTARGETSUPPLIER_HPP_ +#include <com/sun/star/document/XLinkTargetSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ +#include <com/sun/star/container/XIndexAccess.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ +#include <com/sun/star/container/XNamed.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGETARGET_HPP_ +#include <com/sun/star/drawing/XMasterPageTarget.hpp> +#endif +#ifndef _COM_SUN_STAR_PRESENTATION_XPRESENTATIONPAGE_HPP_ +#include <com/sun/star/presentation/XPresentationPage.hpp> +#endif + +#ifndef _SFX_ITEMPROP_HXX +#include <svtools/itemprop.hxx> +#endif + +#ifndef _SVX_UNOWPAGE_HXX +#include <svx/unopage.hxx> +#endif +#ifndef _SVX_FMDPAGE_HXX +#include <svx/fmdpage.hxx> +#endif +#ifndef _SVDPOOL_HXX //autogen +#include <svx/svdpool.hxx> +#endif + +#include <unotools/servicehelper.hxx> + +#include "unosrch.hxx" + +class SdPage; +class SvxShape; +class SdrObject; +struct SfxItemPropertyMap; + +/*********************************************************************** +* * +***********************************************************************/ +class SdGenericDrawPage : public SvxFmDrawPage, + public SdUnoSearchReplaceShape, + public ::com::sun::star::drawing::XShapeCombiner, + public ::com::sun::star::drawing::XShapeBinder, + public ::com::sun::star::container::XNamed, + public ::com::sun::star::beans::XPropertySet, + public ::com::sun::star::document::XLinkTargetSupplier +{ +protected: + friend class SdXImpressDocument; + + SdPage* mpPage; + SvxItemPropertySet maPropSet; + SdXImpressDocument* mpModel; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxModel; + + virtual void setBackground( const ::com::sun::star::uno::Any& rValue ) throw(); + virtual void getBackground( ::com::sun::star::uno::Any& rValue ) throw(); + + sal_Bool mbHasBackgroundObject; + +public: + SdGenericDrawPage( SdXImpressDocument* pModel, SdPage* pInPage, const SfxItemPropertyMap* pMap) throw(); + virtual ~SdGenericDrawPage() throw(); + + // intern + void Invalidate() { mpPage = NULL; mpModel = NULL; mxModel = NULL; } + sal_Bool isValid() { return (mpPage != NULL) && (mpModel != NULL); } + + SdPage* GetPage() const { return mpPage; } + SdXImpressDocument* GetModel() const { return mpModel; } + + // this is called whenever a SdrObject must be created for a empty api shape wrapper + virtual SdrObject *_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(); + + // SvxFmDrawPage + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > _CreateShape( SdrObject *pObj ) const; + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + + // XShapeCombiner + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SAL_CALL combine( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL split( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xGroup ) throw(::com::sun::star::uno::RuntimeException); + + // XShapeBinder + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SAL_CALL bind( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL unbind( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XLinkTargetSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getLinks( ) throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); +}; + +#endif + +/*********************************************************************** +* * +***********************************************************************/ + +class SdDrawPage : public ::com::sun::star::drawing::XMasterPageTarget, + public ::com::sun::star::presentation::XPresentationPage, + public SdGenericDrawPage +{ +private: + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; +protected: + virtual void setBackground( const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::lang::IllegalArgumentException ); + virtual void getBackground( ::com::sun::star::uno::Any& rValue ) throw(); +public: + SdDrawPage( SdXImpressDocument* pModel, SdPage* pInPage ) throw(); + virtual ~SdDrawPage() throw(); + + UNO3_GETIMPLEMENTATION_DECL( SdDrawPage ) + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XMasterPageTarget + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL getMasterPage( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMasterPage( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xMasterPage ) throw(::com::sun::star::uno::RuntimeException); + + // XPresentationPage + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL getNotesPage( ) throw(::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); + + // XShapes + virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); +}; + +/*********************************************************************** +* * +***********************************************************************/ + +class SdMasterPage : public ::com::sun::star::presentation::XPresentationPage, + public SdGenericDrawPage +{ +private: + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence; +protected: + SdrObject* mpBackgroundObj; + + virtual void setBackground( const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::lang::IllegalArgumentException ); + virtual void getBackground( ::com::sun::star::uno::Any& rValue ) throw(); + +public: + SdMasterPage( SdXImpressDocument* pModel, SdPage* pInPage ) throw(); + virtual ~SdMasterPage() throw(); + + UNO3_GETIMPLEMENTATION_DECL(SdMasterPage) + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); + + // XPresentationPage + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL getNotesPage( ) throw(::com::sun::star::uno::RuntimeException); + + // XNamed + virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + + // XShapes + virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException); +}; + + +/*********************************************************************** +* * +***********************************************************************/ +#include <cppuhelper/implbase2.hxx> + +class SdPageLinkTargets : public ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameAccess, + ::com::sun::star::lang::XServiceInfo > +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxPage; + SdGenericDrawPage* mpUnoPage; + +public: + SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw(); + virtual ~SdPageLinkTargets() throw(); + + // intern + SdrObject* FindObject( const String& rName ) const throw(); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); +}; + + diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx new file mode 100644 index 000000000000..63c34f28650e --- /dev/null +++ b/sd/source/ui/unoidl/unopback.cxx @@ -0,0 +1,353 @@ +/************************************************************************* + * + * $RCSfile: unopback.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + +#ifndef _SFXITEMSET_HXX +#include <svtools/itemset.hxx> +#endif + +#include <cppuhelper/extract.hxx> +#include <rtl/uuid.h> +#include <rtl/memory.h> + +#ifndef _SVDOBJ_HXX +#include <svx/svdobj.hxx> +#endif +#include <svx/unoprov.hxx> + +#include "unopback.hxx" +#include "unohelp.hxx" +#include "drawdoc.hxx" +#include "unokywds.hxx" + +using namespace ::rtl; +using namespace ::vos; +using namespace ::com::sun::star; + +const SfxItemPropertyMap* ImplGetPageBackgroundPropertyMap() +{ + static const SfxItemPropertyMap aPageBackgroundPropertyMap_Impl[] = + { + FILL_PROPERTIES + {0,0,0,0,0} + }; + + return aPageBackgroundPropertyMap_Impl; +} + +UNO3_GETIMPLEMENTATION_IMPL( SdUnoPageBackground ); + +SdUnoPageBackground::SdUnoPageBackground( SdDrawDocument* pDoc /* = NULL */, SdrObject* pObj /* = NULL */ ) throw() +: maPropSet( ImplGetPageBackgroundPropertyMap() ), mpSet( NULL ) +{ + if( pObj ) + { + mpSet = new SfxItemSet( pDoc->GetPool(), XATTR_FILL_FIRST, XATTR_FILLRESERVED_LAST ); + pObj->TakeAttributes( *mpSet, sal_False, sal_False ); + } +} + +SdUnoPageBackground::~SdUnoPageBackground() throw() +{ + if( mpSet ) + delete mpSet; +} + +void SdUnoPageBackground::fillItemSet( SfxItemSet& rSet ) throw() +{ + rSet.ClearItem(); + + if( mpSet == NULL ) + { + mpSet = new SfxItemSet( *rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST ); + + if( maPropSet.AreThereOwnUsrAnys() ) + { + uno::Any* pAny; + const SfxItemPropertyMap* pMap = maPropSet.getPropertyMap(); + while( pMap->pName ) + { + pAny = maPropSet.GetUsrAnyForID( pMap->nWID ); + if( pAny ) + { + OUString aPropertyName( OUString::createFromAscii(pMap->pName)); + setPropertyValue( aPropertyName, *pAny ); + } + pMap++; + } + } + } + + rSet.Put( *mpSet ); +} + +// XServiceInfo +OUString SAL_CALL SdUnoPageBackground::getImplementationName() + throw(uno::RuntimeException) +{ + return OUString::createFromAscii( sUNO_SdUnoPageBackground ); +} + +sal_Bool SAL_CALL SdUnoPageBackground::supportsService( const OUString& ServiceName ) + throw(uno::RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL SdUnoPageBackground::getSupportedServiceNames() + throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aNameSequence( 2 ); + OUString* pStrings = aNameSequence.getArray(); + + *pStrings++ = OUString::createFromAscii( sUNO_Service_PageBackground ); + *pStrings = OUString::createFromAscii( sUNO_Service_AreaShapeDescriptor ); + + return aNameSequence; +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL SdUnoPageBackground::getPropertySetInfo() + throw(uno::RuntimeException) +{ + return maPropSet.getPropertySetInfo(); +} + +void SAL_CALL SdUnoPageBackground::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) + throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertyMap* pMap = getPropertyMapEntry( aPropertyName ); + + if( pMap == NULL ) + { + throw beans::UnknownPropertyException(); + } + else + { + if( mpSet ) + { + SfxItemPool& rPool = *mpSet->GetPool(); + SfxItemSet aSet( rPool, pMap->nWID, pMap->nWID); + aSet.Put( *mpSet ); + + if( !aSet.Count() ) + aSet.Put( rPool.GetDefaultItem( pMap->nWID ) ); + + maPropSet.setPropertyValue( pMap, aValue, aSet ); + mpSet->Put( aSet ); + } + else + { + if(pMap && pMap->nWID) + maPropSet.setPropertyValue( pMap, aValue ); + } + } +} + +uno::Any SAL_CALL SdUnoPageBackground::getPropertyValue( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + const SfxItemPropertyMap* pMap = getPropertyMapEntry(PropertyName); + + if( pMap == NULL ) + { + throw beans::UnknownPropertyException(); + } + else + { + if( mpSet ) + { + SfxItemPool& rPool = *mpSet->GetPool(); + SfxItemSet aSet( rPool, pMap->nWID, pMap->nWID); + aSet.Put( *mpSet ); + + if( !aSet.Count() ) + aSet.Put( rPool.GetDefaultItem( pMap->nWID ) ); + + // Hole Wert aus ItemSet + aAny = maPropSet.getPropertyValue( pMap, aSet ); + } + else + { + if(pMap && pMap->nWID) + aAny = maPropSet.getPropertyValue( pMap ); + } + } + return aAny; +} + +void SAL_CALL SdUnoPageBackground::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdUnoPageBackground::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdUnoPageBackground::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} +void SAL_CALL SdUnoPageBackground::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} + +// XPropertyState +beans::PropertyState SAL_CALL SdUnoPageBackground::getPropertyState( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertyMap* pMap = getPropertyMapEntry(PropertyName); + + if( pMap == NULL ) + throw beans::UnknownPropertyException(); + + if( mpSet ) + { + switch( mpSet->GetItemState( pMap->nWID, sal_False ) ) + { + case SFX_ITEM_READONLY: + case SFX_ITEM_SET: + return beans::PropertyState_DIRECT_VALUE; + case SFX_ITEM_DEFAULT: + return beans::PropertyState_DEFAULT_VALUE; + default: +// case SFX_ITEM_DONTCARE: +// case SFX_ITEM_DISABLED: + return beans::PropertyState_AMBIGUOUS_VALUE; + } + } + else + { + if( NULL == maPropSet.GetUsrAnyForID(pMap->nWID) ) + return beans::PropertyState_DEFAULT_VALUE; + else + return beans::PropertyState_DIRECT_VALUE; + } +} + +uno::Sequence< beans::PropertyState > SAL_CALL SdUnoPageBackground::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + sal_Int32 nCount = aPropertyName.getLength(); + const OUString* pNames = aPropertyName.getConstArray(); + + uno::Sequence< beans::PropertyState > aPropertyStateSequence( nCount ); + beans::PropertyState* pState = aPropertyStateSequence.getArray(); + + while( nCount-- ) + *pState++ = getPropertyState( *pNames++ ); + + return aPropertyStateSequence; +} + +void SAL_CALL SdUnoPageBackground::setPropertyToDefault( const OUString& PropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertyMap* pMap = getPropertyMapEntry(PropertyName); + + if( pMap == NULL ) + throw beans::UnknownPropertyException(); + + if( mpSet ) + mpSet->ClearItem( pMap->nWID ); +} + +uno::Any SAL_CALL SdUnoPageBackground::getPropertyDefault( const OUString& aPropertyName ) + throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertyMap* pMap = getPropertyMapEntry(aPropertyName); + if( pMap == NULL || mpSet == NULL ) + throw beans::UnknownPropertyException(); + + uno::Any aAny; + if( mpSet ) + { + SfxItemPool& rPool = *mpSet->GetPool(); + SfxItemSet aSet( rPool, pMap->nWID, pMap->nWID); + aSet.Put( rPool.GetDefaultItem( pMap->nWID ) ); + + aAny = maPropSet.getPropertyValue( pMap, aSet ); + } + return aAny; +} + +/** this is used because our property map is not sorted yet */ +const SfxItemPropertyMap* SdUnoPageBackground::getPropertyMapEntry( const OUString& rPropertyName ) const throw() +{ + const SfxItemPropertyMap *pMap = maPropSet.getPropertyMap(); + while( pMap->pName ) + { + if( rPropertyName.compareToAscii( pMap->pName ) == 0 ) + return pMap; + ++pMap; + } + + return NULL; +} + diff --git a/sd/source/ui/unoidl/unopback.hxx b/sd/source/ui/unoidl/unopback.hxx new file mode 100644 index 000000000000..dee5e614858d --- /dev/null +++ b/sd/source/ui/unoidl/unopback.hxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * $RCSfile: unopback.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SD_UNOPBACK_HXX +#define _SD_UNOPBACK_HXX + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_ +#include <com/sun/star/beans/XPropertyState.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <com/sun/star/lang/XUnoTunnel.hpp> +#endif + +#include <svx/unoshprp.hxx> +#include <svx/unoipset.hxx> + +#include <unotools/servicehelper.hxx> + +#include <cppuhelper/implbase4.hxx> + +const SfxItemPropertyMap* ImplGetPageBackgroundPropertyMap(); + +class SdrObject; +class SdDrawDocument; +class SfxItemSet; + +class SdUnoPageBackground : public ::cppu::WeakImplHelper4< + ::com::sun::star::beans::XPropertySet, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::beans::XPropertyState, + ::com::sun::star::lang::XUnoTunnel> +{ +protected: + SvxItemPropertySet maPropSet; + SfxItemSet* mpSet; + + const SfxItemPropertyMap* getPropertyMapEntry( const ::rtl::OUString& rPropertyName ) const throw(); +public: + SdUnoPageBackground( SdDrawDocument* pDoc = NULL, SdrObject* pObj = NULL ) throw(); + ~SdUnoPageBackground() throw(); + + // internal + void fillItemSet( SfxItemSet& rSet ) throw(); + + // uno helper + UNO3_GETIMPLEMENTATION_DECL( SdUnoPageBackground ) + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); +}; + +#endif + diff --git a/sd/source/ui/unoidl/unosrch.cxx b/sd/source/ui/unoidl/unosrch.cxx new file mode 100644 index 000000000000..369130e55688 --- /dev/null +++ b/sd/source/ui/unoidl/unosrch.cxx @@ -0,0 +1,934 @@ +/************************************************************************* + * + * $RCSfile: unosrch.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_SVAPP_HXX //autogen +#include <vcl/svapp.hxx> +#endif + +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif + +#ifndef SVX_UNOSHAPE_HXX +#include <svx/unoshape.hxx> +#endif + +#ifndef SVX_UNOPROV_HXX //autogen +#include <svx/unoprov.hxx> +#endif + +#ifndef _SVX_UNOTEXT_HXX +#include <svx/unotext.hxx> +#endif + +#include <cppuhelper/extract.hxx> +#include <rtl/uuid.h> +#include <rtl/memory.h> + +#include "unohelp.hxx" +#include "unoprnms.hxx" +#include "unosrch.hxx" + +using namespace ::vos; +using namespace ::rtl; +using namespace ::com::sun::star; + +#define WID_SEARCH_BACKWARDS 0 +#define WID_SEARCH_CASE 1 +#define WID_SEARCH_WORDS 2 + +const SfxItemPropertyMap* ImplGetSearchPropertyMap() +{ + static const SfxItemPropertyMap aSearchPropertyMap_Impl[] = + { + { MAP_CHAR_LEN(UNO_NAME_SEARCH_BACKWARDS), WID_SEARCH_BACKWARDS, &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_SEARCH_CASE), WID_SEARCH_CASE, &::getBooleanCppuType(), 0, 0 }, + { MAP_CHAR_LEN(UNO_NAME_SEARCH_WORDS), WID_SEARCH_WORDS, &::getBooleanCppuType(), 0, 0 }, + { 0,0,0,0,0} + }; + + return aSearchPropertyMap_Impl; +} + +class SearchContext_impl +{ + uno::Reference< drawing::XShapes > mxShapes; + sal_Int32 mnIndex; + SearchContext_impl* mpParent; + +public: + SearchContext_impl( uno::Reference< drawing::XShapes > xShapes, SearchContext_impl* pParent = NULL ) + : mxShapes( xShapes ), mnIndex( -1 ), mpParent( pParent ) {} + + + uno::Reference< drawing::XShape > firstShape() + { + mnIndex = -1; + return nextShape(); + } + + uno::Reference< drawing::XShape > nextShape() + { + uno::Reference< drawing::XShape > xShape; + mnIndex++; + if( mxShapes.is() && mxShapes->getCount() > mnIndex ) + { + uno::Any aAny( mxShapes->getByIndex( mnIndex ) ); + ::cppu::extractInterface( xShape, aAny ); + } + return xShape; + } + + SearchContext_impl* getParent() const { return mpParent; } +}; + +/* ================================================================= */ +/** this class implements a search or replace operation on a given + page or a given sdrobj + */ + +SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XDrawPage* pPage ) throw() +{ + mpPage = pPage; +} + +SdUnoSearchReplaceShape::SdUnoSearchReplaceShape( drawing::XShape* pShape ) throw() +{ + mpShape = pShape; +} + +SdUnoSearchReplaceShape::~SdUnoSearchReplaceShape() throw() +{ +} + +// util::XReplaceable +uno::Reference< util::XReplaceDescriptor > SAL_CALL SdUnoSearchReplaceShape::createReplaceDescriptor() + throw( uno::RuntimeException ) +{ + return new SdUnoSearchReplaceDescriptor(sal_True); +} + +sal_Int32 SAL_CALL SdUnoSearchReplaceShape::replaceAll( const uno::Reference< util::XSearchDescriptor >& xDesc ) + throw( uno::RuntimeException ) +{ + SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc ); + if( pDescr == NULL ) + return 0; + + sal_Int32 nFound = 0; + + uno::Reference< drawing::XShapes > xShapes; + uno::Reference< drawing::XShape > xShape; + + SearchContext_impl* pContext = NULL; + if(mpPage) + { + uno::Reference< drawing::XDrawPage > xPage( mpPage ); + + uno::Any aAny( xPage->queryInterface( ITYPE( drawing::XShapes ) ) ); + + if( (aAny >>= xShapes) && (xShapes->getCount() > 0) ) + { + pContext = new SearchContext_impl( xShapes ); + xShape = pContext->firstShape(); + } + else + { + xShapes = NULL; + } + } + else + { + xShape = mpShape; + } + + while( xShape.is() ) + { + // replace in xShape + uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); + uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY); + uno::Reference< text::XTextRange > xFound; + + while( xRange.is() ) + { + xFound = Search( xRange, pDescr ); + if( !xFound.is() ) + break; + + xFound->setString( pDescr->getReplaceString() ); + xRange = xFound->getEnd(); + nFound++; + } + // done with xShape -> get next shape + + // test if its a group + uno::Reference< drawing::XShapes > xGroupShape; + uno::Any aAny( xShape->queryInterface( ITYPE( drawing::XShapes ) ) ); + if( ( aAny >>= xGroupShape ) && ( xGroupShape->getCount() > 0 ) ) + { + pContext = new SearchContext_impl( xGroupShape, pContext ); + xShape = pContext->firstShape(); + } + else + { + if( pContext ) + xShape = pContext->nextShape(); + else + xShape = NULL; + } + + // test parent contexts for next shape if none + // is found in the current context + while( pContext && !xShape.is() ) + { + if( pContext->getParent() ) + { + SearchContext_impl* pOldContext = pContext; + pContext = pContext->getParent(); + delete pOldContext; + xShape = pContext->nextShape(); + } + else + { + delete pContext; + pContext = NULL; + xShape = NULL; + } + } + } + + return nFound; +} + +// XSearchable +uno::Reference< ::com::sun::star::util::XSearchDescriptor > SAL_CALL SdUnoSearchReplaceShape::createSearchDescriptor( ) + throw(::com::sun::star::uno::RuntimeException) +{ + return new SdUnoSearchReplaceDescriptor(sal_False); +} + +uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL SdUnoSearchReplaceShape::findAll( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) + throw(::com::sun::star::uno::RuntimeException) +{ + SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc ); + if( pDescr == NULL ) + return uno::Reference< container::XIndexAccess > (); + + + sal_Int32 nSequence = 32; + sal_Int32 nFound = 0; + + uno::Sequence < uno::Reference< uno::XInterface > > aSeq( nSequence ); + + uno::Reference< uno::XInterface > * pArray = aSeq.getArray(); + + uno::Reference< drawing::XShapes > xShapes; + uno::Reference< drawing::XShape > xShape; + + SearchContext_impl* pContext = NULL; + if(mpPage) + { + uno::Reference< drawing::XDrawPage > xPage( mpPage ); + uno::Any aAny( xPage->queryInterface( ITYPE( drawing::XShapes ) ) ); + + if( ( aAny >>= xShapes ) && xShapes->getCount() > 0 ) + { + pContext = new SearchContext_impl( xShapes ); + xShape = pContext->firstShape(); + } + else + { + xShapes = NULL; + } + } + else + { + xShape = mpShape; + } + while( xShape.is() ) + { + // find in xShape + uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); + uno::Reference< text::XTextRange > xRange(xText, uno::UNO_QUERY); + uno::Reference< text::XTextRange > xFound; + + while( xRange.is() ) + { + xFound = Search( xRange, pDescr ); + if( !xFound.is() ) + break; + + if( nFound >= nSequence ) + { + nSequence += 32; + aSeq.realloc( nSequence ); + pArray = aSeq.getArray(); + } + + pArray[nFound++] = xFound; + + xRange = xFound->getEnd(); + } + // done with shape -> get next shape + + // test if its a group + uno::Reference< drawing::XShapes > xGroupShape; + uno::Any aAny( xShape->queryInterface( ITYPE( drawing::XShapes ))); + + if( (aAny >>= xGroupShape ) && xGroupShape->getCount() > 0 ) + { + pContext = new SearchContext_impl( xGroupShape, pContext ); + xShape = pContext->firstShape(); + } + else + { + if( pContext ) + xShape = pContext->nextShape(); + else + xShape = NULL; + } + + // test parent contexts for next shape if none + // is found in the current context + while( pContext && !xShape.is() ) + { + if( pContext->getParent() ) + { + SearchContext_impl* pOldContext = pContext; + pContext = pContext->getParent(); + delete pOldContext; + xShape = pContext->nextShape(); + } + else + { + delete pContext; + pContext = NULL; + xShape = NULL; + } + } + } + + if( nFound != nSequence ) + aSeq.realloc( nFound ); + + return (container::XIndexAccess*)new SdUnoFindAllAccess( aSeq ); +} + +uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findFirst( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) + throw(::com::sun::star::uno::RuntimeException) +{ + uno::Reference< text::XTextRange > xRange( GetCurrentShape(), uno::UNO_QUERY ); + if( xRange.is() ) + return findNext( xRange, xDesc ); + + return uno::Reference< uno::XInterface > (); +} + +uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetCurrentShape() const throw() +{ + uno::Reference< drawing::XShape > xShape; + + if( mpPage ) + { + uno::Reference< drawing::XDrawPage > xPage( mpPage ); + uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY ); + if( xShapes.is() ) + { + if(xShapes->getCount() > 0) + { + uno::Any aAny( xShapes->getByIndex(0) ); + ::cppu::extractInterface( xShape, aAny ); + } + } + } + else if( mpShape ) + { + xShape = mpShape; + } + + return xShape; + +} + +uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SdUnoSearchReplaceShape::findNext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xStartAt, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XSearchDescriptor >& xDesc ) + throw(::com::sun::star::uno::RuntimeException) +{ + SdUnoSearchReplaceDescriptor* pDescr = SdUnoSearchReplaceDescriptor::getImplementation( xDesc ); + + uno::Reference< text::XTextRange > xRange( xStartAt, uno::UNO_QUERY ); + if(pDescr && xRange.is() ) + { + uno::Reference< text::XTextRange > xFound; + + uno::Reference< text::XTextRange > xCurrentRange( xStartAt, uno::UNO_QUERY ); + + uno::Reference< drawing::XShape > xCurrentShape( GetShape( xCurrentRange ) ); + + while(!xFound.is() && xRange.is()) + { + xFound = Search( xRange, pDescr ); + if(!xFound.is()) + { + // we need a new starting range now + xRange = NULL; + + if(mpPage) + { + uno::Reference< drawing::XDrawPage > xPage( mpPage ); + + // we do a page wide search, so skip to the next shape here + uno::Reference< container::XIndexAccess > xShapes( xPage, uno::UNO_QUERY ); + + // get next shape on our page + if( xShapes.is() ) + { + uno::Reference< drawing::XShape > xFound( GetNextShape( xShapes, xCurrentShape ) ); + if( xFound.is() && (xFound.get() != xCurrentShape.get()) ) + xCurrentShape = xFound; + else + xCurrentShape = NULL; + + uno::Any aAny( xCurrentShape->queryInterface( ITYPE( text::XTextRange ))); + if(!(xCurrentShape.is() && ( aAny >>= xRange))) + xRange = NULL; + } + } + else + { + // we search only in this shape, so end search if we have + // not found anything + } + } + } + + return xFound; + } + else + return uno::Reference< uno::XInterface > (); +} + +/** this method returns the shape that follows xCurrentShape in the shape collection xShapes. + It steps recursive into groupshapes and returns the xCurrentShape if it is the last + shape in this collection */ +uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetNextShape( uno::Reference< container::XIndexAccess > xShapes, uno::Reference< drawing::XShape > xCurrentShape ) throw() +{ + uno::Reference< drawing::XShape > xFound; + uno::Any aAny; + + if(xShapes.is() && xCurrentShape.is()) + { + const sal_Int32 nCount = xShapes->getCount(); + for( sal_Int32 i = 0; i < nCount; i++ ) + { + uno::Any aAny( xShapes->getByIndex(i) ); + uno::Reference< drawing::XShape > xSearchShape; + + if( ::cppu::extractInterface( xSearchShape, aAny ) ) + { + uno::Reference< container::XIndexAccess > xGroup( xSearchShape, uno::UNO_QUERY ); + + if( xCurrentShape.get() == xSearchShape.get() ) + { + if( xGroup.is() && xGroup->getCount() > 0 ) + { + aAny = xGroup->getByIndex( 0 ); + } + else + { + i++; + if( i < nCount ) + aAny = xShapes->getByIndex( i ); + else + aAny <<= xCurrentShape; + } + + ::cppu::extractInterface( xFound, aAny ); + + break; + } + else if( xGroup.is() ) + { + xFound = GetNextShape( xGroup, xCurrentShape ); + if( xFound.is() ) + { + if( xFound.get() == xCurrentShape.get() ) + { + // the current shape was found at the end of the group + i++; + if( i < nCount ) + { + aAny = xShapes->getByIndex(i); + ::cppu::extractInterface( xFound, aAny ); + } + } + break; + } + } + } + } + } + + return xFound; +} + +uno::Reference< text::XTextRange > SdUnoSearchReplaceShape::Search( uno::Reference< text::XTextRange > xText, SdUnoSearchReplaceDescriptor* pDescr ) throw() +{ + if(!xText.is()) + return uno::Reference< text::XTextRange > (); + + uno::Reference< text::XText > xParent( xText->getText() ); + + if( !xParent.is() ) + { + uno::Any aAny( xText->queryInterface( ITYPE( text::XText )) ); + aAny >>= xParent; + } + + const OUString aText( xParent->getString() ); + + const sal_Int32 nTextLen = aText.getLength(); + + sal_Int32* pConvertPos = new sal_Int32[nTextLen+2]; + sal_Int32* pConvertPara = new sal_Int32[nTextLen+2]; + + int ndbg = 0; + const sal_Unicode* pText = aText; + + sal_Int32* pPos = pConvertPos; + sal_Int32* pPara = pConvertPara; + + sal_Int32 nLastPos = 0, nLastPara = 0; + + uno::Reference< container::XEnumerationAccess > xEnumAccess( xParent, uno::UNO_QUERY ); + + if( xEnumAccess.is() ) + { + uno::Reference< container::XEnumeration > xParaEnum( xEnumAccess->createEnumeration() ); + + while(xParaEnum->hasMoreElements()) + { + uno::Reference< text::XTextContent > xParagraph; + + uno::Any aAny( xParaEnum->nextElement() ); + if( ::cppu::extractInterface( xParagraph, aAny ) ) + { + aAny = xParagraph->queryInterface( ITYPE( container::XEnumerationAccess )); + aAny >>= xEnumAccess; + } + + if( xEnumAccess.is() ) + { + uno::Reference< container::XEnumeration > xParagraph( xEnumAccess->createEnumeration() ); + + if( xParagraph.is() ) + { + + while(xParagraph->hasMoreElements()) + { + uno::Reference< text::XTextRange > xPortion; + + uno::Any aAny( xParagraph->nextElement() ); + if( ::cppu::extractInterface( xPortion, aAny ) ) + { + const OUString aPortion( xPortion->getString() ); + const sal_Int32 nLen = aPortion.getLength(); + + ESelection aStartSel( GetSelection( xPortion->getStart() ) ); + ESelection aEndSel( GetSelection( xPortion->getEnd() ) ); + + if( aStartSel.nStartPos == aEndSel.nStartPos ) + { + for( sal_Int32 i = 0; i < nLen; i++ ) + { + if( ndbg < (nTextLen+2) ) + { + *pPos++ = aStartSel.nStartPos; + *pPara++ = aStartSel.nStartPara; + + ndbg += 1; + pText++; + } + else + { + DBG_ERROR( "array overflow while searching" ); + } + } + + nLastPos = aStartSel.nStartPos; + } + else + { + for( sal_Int32 i = 0; i < nLen; i++ ) + { + if( ndbg < (nTextLen+2) ) + { + *pPos++ = aStartSel.nStartPos++; + *pPara++ = aStartSel.nStartPara; + + ndbg += 1; + pText++; + } + else + { + DBG_ERROR( "array overflow while searching" ); + } + } + + nLastPos = aStartSel.nStartPos - 1; + DBG_ASSERT( aEndSel.nStartPos == aStartSel.nStartPos, "Search is not working" ); + } + nLastPara = aStartSel.nStartPara; + } + } + } + } + + if( ndbg < (nTextLen+2) ) + { + *pPos++ = nLastPos + 1; + *pPara++ = nLastPara; + + ndbg += 1; + pText++; + } + else + { + DBG_ERROR( "array overflow while searching" ); + } + } + } + + uno::Reference< text::XText > xFound; + ESelection aSel; + + uno::Reference< text::XTextRange > xRangeRef( xText, uno::UNO_QUERY ); + if( xRangeRef.is() ) + aSel = GetSelection( xRangeRef ); + + sal_Int32 nStartPos = 0; + sal_Int32 nEndPos = 0; + for( nStartPos; nStartPos < nTextLen; nStartPos++ ) + { + if( pConvertPara[nStartPos] == aSel.nStartPara && pConvertPos[nStartPos] == aSel.nStartPos ) + break; + } + + if( Search( aText, nStartPos, nEndPos, pDescr ) ) + { + if( nStartPos <= nTextLen && nEndPos <= nTextLen ) + { + ESelection aSel( pConvertPara[nStartPos], pConvertPos[nStartPos], + pConvertPara[nEndPos], pConvertPos[nEndPos] ); + SvxUnoTextRange *pRange; + + SvxUnoText* pParent = SvxUnoText::getImplementation( xParent ); + + if(pParent) + { + pRange = new SvxUnoTextRange( *pParent ); + xFound = (text::XText*)pRange; + pRange->SetSelection(aSel); + +// pDescr->SetStartPos( nEndPos ); + } + } + else + { + DBG_ERROR("Array overflow while searching!"); + } + } + + delete pConvertPos; + delete pConvertPara; + + return uno::Reference< text::XTextRange > ( xFound, uno::UNO_QUERY ); +} + +sal_Bool SdUnoSearchReplaceShape::Search( const OUString& rText, sal_Int32& nStartPos, sal_Int32& nEndPos, SdUnoSearchReplaceDescriptor* pDescr ) throw() +{ + OUString aSearchStr( pDescr->getSearchString() ); + OUString aText( rText ); + + if( !pDescr->IsCaseSensitive() ) + { + aText.toLowerCase(); + aSearchStr.toLowerCase(); + } + + sal_Int16 nFound = aText.indexOf( aSearchStr, nStartPos ); + if( nFound != -1 ) + { + nStartPos = nFound; + nEndPos = nFound + aSearchStr.getLength(); + + if(pDescr->IsWords()) + { + if( nStartPos > 0 && aText.getStr()[nStartPos-1] > ' ' || + nEndPos < aText.getLength() && aText.getStr()[nEndPos] > ' ') + { + nStartPos++; + return Search( aText, nStartPos, nEndPos, pDescr ); + } + } + + return sal_True; + } + else + return sal_False; +} + +ESelection SdUnoSearchReplaceShape::GetSelection( uno::Reference< text::XTextRange > xTextRange ) throw() +{ + ESelection aSel; + SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( xTextRange ); + + if(pRange) + aSel = pRange->GetSelection(); + + return aSel; +} + +uno::Reference< drawing::XShape > SdUnoSearchReplaceShape::GetShape( uno::Reference< text::XTextRange > xTextRange ) throw() +{ + uno::Reference< drawing::XShape > xShape; + + if(xTextRange.is()) + { + uno::Reference< text::XText > xText( xTextRange->getText() ); + + if(xText.is()) + { + do + { + uno::Any aAny( xText->queryInterface( ITYPE( drawing::XShape ))); + if(!(aAny >>= xShape)) + { + uno::Reference< text::XText > xParent( xText->getText() ); + if(!xParent.is() || xText.get() == xParent.get()) + return xShape; + + xText = xParent; + } + } while( !xShape.is() ); + } + } + + return xShape; +} + +/* ================================================================= */ +/** this class holds the parameters and status of a search or replace + operation performed by class SdUnoSearchReplaceShape + */ + +UNO3_GETIMPLEMENTATION_IMPL( SdUnoSearchReplaceDescriptor ); + +SdUnoSearchReplaceDescriptor::SdUnoSearchReplaceDescriptor( sal_Bool bReplace ) throw() +{ + mpPropSet = new SvxItemPropertySet(ImplGetSearchPropertyMap()); + + mbBackwards = sal_False; + mbCaseSensitive = sal_False; + mbWords = sal_False; + + mbReplace = bReplace; +} + +SdUnoSearchReplaceDescriptor::~SdUnoSearchReplaceDescriptor() throw() +{ + delete mpPropSet; +} + +// XSearchDescriptor +OUString SAL_CALL SdUnoSearchReplaceDescriptor::getSearchString() + throw(::com::sun::star::uno::RuntimeException) +{ + return maSearchStr; +} + +void SAL_CALL SdUnoSearchReplaceDescriptor::setSearchString( const OUString& aString ) + throw(::com::sun::star::uno::RuntimeException) +{ + maSearchStr = aString; +} + +// XReplaceDescriptor +OUString SAL_CALL SdUnoSearchReplaceDescriptor::getReplaceString() + throw(::com::sun::star::uno::RuntimeException) +{ + return maReplaceStr; +} + +void SAL_CALL SdUnoSearchReplaceDescriptor::setReplaceString( const ::rtl::OUString& aReplaceString ) + throw(::com::sun::star::uno::RuntimeException) +{ + maReplaceStr = aReplaceString; +} + +// XPropertySet +uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdUnoSearchReplaceDescriptor::getPropertySetInfo() + throw(::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + return mpPropSet->getPropertySetInfo(); +} + +void SAL_CALL SdUnoSearchReplaceDescriptor::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + const SfxItemPropertyMap* pMap = mpPropSet->getPropertyMapEntry(aPropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_SEARCH_BACKWARDS: + mbBackwards = ::cppu::any2bool( aValue ); + break; + case WID_SEARCH_CASE: + mbCaseSensitive = ::cppu::any2bool( aValue ); + break; + case WID_SEARCH_WORDS: + mbWords = ::cppu::any2bool( aValue ); + break; + default: + throw beans::UnknownPropertyException(); + } +} + +uno::Any SAL_CALL SdUnoSearchReplaceDescriptor::getPropertyValue( const ::rtl::OUString& PropertyName ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + OGuard aGuard( Application::GetSolarMutex() ); + + uno::Any aAny; + + const SfxItemPropertyMap* pMap = mpPropSet->getPropertyMapEntry(PropertyName); + + switch( pMap ? pMap->nWID : -1 ) + { + case WID_SEARCH_BACKWARDS: + aAny = ::cppu::bool2any(mbBackwards); + break; + case WID_SEARCH_CASE: + aAny = ::cppu::bool2any(mbCaseSensitive); + break; + case WID_SEARCH_WORDS: + aAny = ::cppu::bool2any(mbWords); + break; + default: + throw beans::UnknownPropertyException(); + } + + return aAny; +} + +void SAL_CALL SdUnoSearchReplaceDescriptor::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {} +void SAL_CALL SdUnoSearchReplaceDescriptor::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {} +void SAL_CALL SdUnoSearchReplaceDescriptor::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {} +void SAL_CALL SdUnoSearchReplaceDescriptor::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) {} + + +/* ================================================================= */ + +SdUnoFindAllAccess::SdUnoFindAllAccess( uno::Sequence< uno::Reference< uno::XInterface > >& rSequence ) throw() +:maSequence( rSequence ) +{ +} + +SdUnoFindAllAccess::~SdUnoFindAllAccess() throw() +{ +} + +// XElementAccess +uno::Type SAL_CALL SdUnoFindAllAccess::getElementType() + throw(::com::sun::star::uno::RuntimeException) +{ + return ITYPE( text::XTextRange ); +} + +sal_Bool SAL_CALL SdUnoFindAllAccess::hasElements() + throw(::com::sun::star::uno::RuntimeException) +{ + return maSequence.getLength() > 0; +} + +// XIndexAccess +sal_Int32 SAL_CALL SdUnoFindAllAccess::getCount() + throw(::com::sun::star::uno::RuntimeException) +{ + return maSequence.getLength(); +} + +uno::Any SAL_CALL SdUnoFindAllAccess::getByIndex( sal_Int32 Index ) + throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + uno::Any aAny; + + if( Index < 0 || Index >= getCount() ) + throw lang::IndexOutOfBoundsException(); + + const uno::Reference< uno::XInterface > *pRefs = maSequence.getConstArray(); + if(pRefs) + aAny <<= pRefs[ Index ]; + return aAny; +} + diff --git a/sd/source/ui/unoidl/unovwcrs.cxx b/sd/source/ui/unoidl/unovwcrs.cxx new file mode 100644 index 000000000000..75cc311f325a --- /dev/null +++ b/sd/source/ui/unoidl/unovwcrs.cxx @@ -0,0 +1,275 @@ +/************************************************************************* + * + * $RCSfile: unovwcrs.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COM_SUN_STAR_TEXT_XTEXTVIEWCURSOR_HPP_ +#include <com/sun/star/text/XTextViewCursor.hpp> +#endif +#ifndef _COM_SUN_STAR_VIEW_XSCREENCURSOR_HPP_ +#include <com/sun/star/view/XScreenCursor.hpp> +#endif + +#ifndef _SFXREQUEST_HXX +#include <sfx2/request.hxx> +#endif + +#ifndef _VOS_MUTEX_HXX_ //autogen +#include <vos/mutex.hxx> +#endif + +#include "sdview.hxx" +#include "docshell.hxx" +#include "viewshel.hxx" +#include "fuslshow.hxx" + +#include <cppuhelper/implbase2.hxx> + +using namespace ::vos; +using namespace ::rtl; +using namespace ::com::sun::star; + +class SdXTextViewCursor : public ::cppu::WeakImplHelper2< + text::XTextViewCursor, + view::XScreenCursor > +{ + SdView* mpView; +public: + SdXTextViewCursor(SdView* pVw) throw(); + virtual ~SdXTextViewCursor() throw(); + + //XTextViewCursor + virtual sal_Bool SAL_CALL isVisible(void) throw( uno::RuntimeException ); + virtual void SAL_CALL setVisible(sal_Bool bVisible) throw( uno::RuntimeException ); + virtual awt::Point SAL_CALL getPosition(void) throw( uno::RuntimeException ); + + //XTextCursor + virtual void SAL_CALL collapseToStart(void) throw( uno::RuntimeException ); + virtual void SAL_CALL collapseToEnd(void) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL isCollapsed(void) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ); + virtual void SAL_CALL gotoStart(sal_Bool Expand) throw( uno::RuntimeException ); + virtual void SAL_CALL gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ); + virtual void SAL_CALL gotoRange(const uno::Reference< text::XTextRange > & rRange, sal_Bool bExpand ); + + //XTextRange + virtual uno::Reference< text::XText > SAL_CALL getText(void) throw( uno::RuntimeException ); + virtual uno::Reference< text::XTextRange > SAL_CALL getStart(void) throw( uno::RuntimeException ); + virtual uno::Reference< text::XTextRange > SAL_CALL getEnd(void) throw( uno::RuntimeException ); + virtual OUString SAL_CALL getString(void) throw( uno::RuntimeException ); + virtual void SAL_CALL setString(const OUString& aString) throw( uno::RuntimeException ); + + //XScreenCursor + virtual sal_Bool SAL_CALL screenDown(void) throw( uno::RuntimeException ); + virtual sal_Bool SAL_CALL screenUp(void) throw( uno::RuntimeException ); + + void Invalidate() { mpView = 0; } +}; + + +text::XTextViewCursor* CreateSdXTextViewCursor( SdView* mpView ) +{ + return new SdXTextViewCursor( mpView ); +} + +SdXTextViewCursor::SdXTextViewCursor(SdView* pSdView ) throw() +: mpView(pSdView) +{ + +} + +SdXTextViewCursor::~SdXTextViewCursor() throw() +{ +} + +sal_Bool SdXTextViewCursor::isVisible(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return sal_True; +} + +void SdXTextViewCursor::setVisible(sal_Bool bVisible) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + +awt::Point SdXTextViewCursor::getPosition(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return awt::Point(); +} + +void SdXTextViewCursor::collapseToStart(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + +void SdXTextViewCursor::collapseToEnd(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + +sal_Bool SdXTextViewCursor::isCollapsed(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return sal_True; + +} + +sal_Bool SdXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return sal_False; +} + +sal_Bool SdXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return sal_False; +} + +void SdXTextViewCursor::gotoRange(const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand) +{ + DBG_WARNING("not implemented") +} + +void SdXTextViewCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + +void SdXTextViewCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + +sal_Bool SdXTextViewCursor::screenDown(void) throw( uno::RuntimeException ) +{ + OGuard aGuard(Application::GetSolarMutex()); + sal_Bool bRet = sal_False; + + + if( mpView && mpView->GetDocSh() ) + { + SdViewShell* pViewSh = mpView->GetDocSh()->GetViewShell(); + if( pViewSh ) + { + FuSlideShow* pShow = pViewSh->GetSlideShow(); + if( pShow ) + { + pShow->KeyInput( KeyEvent( 32, KeyCode( KEY_SPACE ) ) ); + return sal_True; + } + } + } + return sal_False; +} + +sal_Bool SdXTextViewCursor::screenUp(void) throw( uno::RuntimeException ) +{ + OGuard aGuard(Application::GetSolarMutex()); + sal_Bool bRet = sal_False; + + if( mpView && mpView->GetDocSh() ) + { + SdViewShell* pViewSh = mpView->GetDocSh()->GetViewShell(); + if( pViewSh ) + { + FuSlideShow* pShow = pViewSh->GetSlideShow(); + if( pShow ) + { + pShow->KeyInput( KeyEvent( 32, KeyCode( KEY_BACKSPACE ) ) ); + return sal_True; + } + } + } + return sal_False; +} + +uno::Reference< text::XText > SdXTextViewCursor::getText(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return uno::Reference< text::XText > (); +} + +uno::Reference< text::XTextRange > SdXTextViewCursor::getStart(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return uno::Reference< text::XTextRange > (); +} + +uno::Reference< text::XTextRange > SdXTextViewCursor::getEnd(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return uno::Reference< text::XTextRange > (); +} + +OUString SdXTextViewCursor::getString(void) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") + return OUString(); +} + +void SdXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeException ) +{ + DBG_WARNING("not implemented") +} + + diff --git a/sd/source/ui/unoidl/unowcntr.cxx b/sd/source/ui/unoidl/unowcntr.cxx new file mode 100644 index 000000000000..bd8d8812f797 --- /dev/null +++ b/sd/source/ui/unoidl/unowcntr.cxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * $RCSfile: unowcntr.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _LIST_HXX +#include <tools/list.hxx> +#endif + +#include <unowcntr.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star; + +DECLARE_LIST( WeakRefList, uno::WeakReference< uno::XInterface >* ); + +SvUnoWeakContainer::SvUnoWeakContainer() throw() +{ + mpList = new WeakRefList; +} + +SvUnoWeakContainer::~SvUnoWeakContainer() throw() +{ + uno::WeakReference< uno::XInterface >* pRef = mpList->First(); + while( pRef ) + { + delete mpList->Remove(); + pRef = mpList->GetCurObject(); + } + delete mpList; +} + +/** inserts the given ref into this container */ +void SvUnoWeakContainer::insert( uno::WeakReference< uno::XInterface > xRef ) throw() +{ + uno::WeakReference< uno::XInterface >* pRef = mpList->First(); + while( pRef ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xTestRef( *pRef ); + if(! xTestRef.is() ) + { + delete mpList->Remove(); + pRef = mpList->GetCurObject(); + } + else + { + if( *pRef == xRef ) + return; + + pRef = mpList->Next(); + } + } + + mpList->Insert( new uno::WeakReference< uno::XInterface >( xRef ) ); +} + +/** removes the given ref from this container */ +void SvUnoWeakContainer::remove( uno::WeakReference< uno::XInterface > xRef ) throw() +{ + uno::WeakReference< uno::XInterface >* pRef = mpList->First(); + while( pRef ) + { + uno::Reference< uno::XInterface > xTestRef( *pRef ); + if(!xTestRef.is()) + { + delete mpList->Remove(); + pRef = mpList->GetCurObject(); + } + else + { + if( *pRef == xRef ) + { + delete mpList->Remove(); + break; + } + + pRef = mpList->Next(); + } + } +} + +/** searches the container for a ref that returns true on the given + search function +*/ +sal_Bool SvUnoWeakContainer::findRef( uno::WeakReference< uno::XInterface >& rRef, void* pSearchData, weakref_searchfunc pSearchFunc ) +{ + uno::WeakReference< uno::XInterface >* pRef = mpList->First(); + while( pRef ) + { + uno::Reference< ::com::sun::star::uno::XInterface > xTestRef( *pRef ); + if(!xTestRef.is()) + { + delete mpList->Remove(); + pRef = mpList->GetCurObject(); + } + else + { + if( (*pSearchFunc)( *pRef, pSearchData ) ) + { + rRef = *pRef; + return sal_True; + } + + pRef = mpList->Next(); + } + } + + return sal_False; +} + diff --git a/sd/source/ui/unoidl/unowcntr.hxx b/sd/source/ui/unoidl/unowcntr.hxx new file mode 100644 index 000000000000..7c094b673667 --- /dev/null +++ b/sd/source/ui/unoidl/unowcntr.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * $RCSfile: unowcntr.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SV_UNOWCNTR_HXX_ +#define _SV_UNOWCNTR_HXX_ + +#ifndef _CPPUHELPER_WEAKREF_HXX_ +#include <cppuhelper/weakref.hxx> +#endif + +typedef sal_Bool (*weakref_searchfunc)( ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > xRef, void* pSearchData ); + +class WeakRefList; + +class SvUnoWeakContainer +{ +private: + WeakRefList* mpList; + +public: + SvUnoWeakContainer() throw(); + ~SvUnoWeakContainer() throw(); + + /** inserts the given ref into this container */ + void insert( ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > xRef ) throw(); + + /** removes the given ref from this container */ + void remove( ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface > xRef ) throw(); + + /** searches the container for a ref that returns true on the given + search function + */ + sal_Bool findRef( ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface >& rRef, void* pSearchData, weakref_searchfunc pSearchFunc ); +}; + +#endif // _SV_UNOWCNTR_HXX_ + |