diff options
Diffstat (limited to 'sd/source')
87 files changed, 6082 insertions, 333 deletions
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx new file mode 100644 index 000000000..292abc8f4 --- /dev/null +++ b/sd/source/core/annotations/Annotation.cxx @@ -0,0 +1,448 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unopage.cxx,v $ + * $Revision: 1.96 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "osl/time.h" +#include "sal/config.h" + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/office/XAnnotation.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> + +#include <comphelper/processfactory.hxx> +#include <cppuhelper/propertysetmixin.hxx> +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include "drawdoc.hxx" +#include "sdpage.hxx" +#include "textapi.hxx" + +using ::rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::office; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::geometry; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star; + +extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const Reference< XInterface >& xSource ); + +namespace sd { + +class Annotation : private ::cppu::BaseMutex, + public ::cppu::WeakComponentImplHelper1< XAnnotation>, + public ::cppu::PropertySetMixin< XAnnotation > +{ +public: + explicit Annotation( const Reference< XComponentContext >& context, SdPage* pPage ); + + SdPage* GetPage() const { return mpPage; } + SdrModel* GetModel() { return (mpPage != 0) ? mpPage->GetModel() : 0; } + + // XInterface: + virtual Any SAL_CALL queryInterface(Type const & type) throw (RuntimeException); + virtual void SAL_CALL acquire() throw () { ::cppu::WeakComponentImplHelper1< XAnnotation >::acquire(); } + virtual void SAL_CALL release() throw () { ::cppu::WeakComponentImplHelper1< XAnnotation >::release(); } + + // ::com::sun::star::beans::XPropertySet: + virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (RuntimeException); + virtual void SAL_CALL setPropertyValue(const OUString & aPropertyName, const Any & aValue) throw (RuntimeException, UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException); + virtual Any SAL_CALL getPropertyValue(const OUString & PropertyName) throw (RuntimeException, UnknownPropertyException, WrappedTargetException); + virtual void SAL_CALL addPropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException); + virtual void SAL_CALL removePropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & aListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException); + virtual void SAL_CALL addVetoableChangeListener(const OUString & PropertyName, const Reference< XVetoableChangeListener > & aListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException); + virtual void SAL_CALL removeVetoableChangeListener(const OUString & PropertyName, const Reference< XVetoableChangeListener > & aListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException); + + // ::com::sun::star::office::XAnnotation: + virtual ::com::sun::star::uno::Any SAL_CALL getAnchor() throw (::com::sun::star::uno::RuntimeException); + virtual RealPoint2D SAL_CALL getPosition() throw (RuntimeException); + virtual void SAL_CALL setPosition(const RealPoint2D & the_value) throw (RuntimeException); + virtual ::com::sun::star::geometry::RealSize2D SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::geometry::RealSize2D& _size ) throw (::com::sun::star::uno::RuntimeException); + virtual OUString SAL_CALL getAuthor() throw (RuntimeException); + virtual void SAL_CALL setAuthor(const OUString & the_value) throw (RuntimeException); + virtual util::DateTime SAL_CALL getDateTime() throw (RuntimeException); + virtual void SAL_CALL setDateTime(const util::DateTime & the_value) throw (RuntimeException); + virtual Reference< XText > SAL_CALL getTextRange() throw (RuntimeException); + +private: + Annotation(const Annotation &); // not defined + Annotation& operator=(const Annotation &); // not defined + + // destructor is private and will be called indirectly by the release call virtual ~Annotation() {} + + void createChangeUndo(); + + // overload WeakComponentImplHelperBase::disposing() + // This function is called upon disposing the component, + // if your component needs special work when it becomes + // disposed, do it here. + virtual void SAL_CALL disposing(); + + SdPage* mpPage; + Reference< XComponentContext > m_xContext; + mutable ::osl::Mutex m_aMutex; + RealPoint2D m_Position; + RealSize2D m_Size; + OUString m_Author; + util::DateTime m_DateTime; + rtl::Reference< TextApiObject > m_TextRange; +}; + +class UndoInsertOrRemoveAnnotation : public SdrUndoAction +{ +public: + UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert ); + + virtual void Undo(); + virtual void Redo(); + +protected: + rtl::Reference< Annotation > mxAnnotation; + bool mbInsert; + int mnIndex; +}; + +struct AnnotationData +{ + RealPoint2D m_Position; + RealSize2D m_Size; + OUString m_Author; + util::DateTime m_DateTime; + + void get( const rtl::Reference< Annotation >& xAnnotation ) + { + m_Position = xAnnotation->getPosition(); + m_Size = xAnnotation->getSize(); + m_Author = xAnnotation->getAuthor(); + m_DateTime = xAnnotation->getDateTime(); + } + + void set( const rtl::Reference< Annotation >& xAnnotation ) + { + xAnnotation->setPosition(m_Position); + xAnnotation->setSize(m_Size); + xAnnotation->setAuthor(m_Author); + xAnnotation->setDateTime(m_DateTime); + } +}; + +class UndoAnnotation : public SdrUndoAction +{ +public: + UndoAnnotation( Annotation& rAnnotation ); + + virtual void Undo(); + virtual void Redo(); + +protected: + rtl::Reference< Annotation > mxAnnotation; + AnnotationData maUndoData; + AnnotationData maRedoData; +}; + +void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage ) +{ + Reference<XComponentContext> xContext (comphelper_getProcessComponentContext()); + xAnnotation.set( new Annotation(xContext, pPage) ); + pPage->addAnnotation(xAnnotation); +} + +Annotation::Annotation( const Reference< XComponentContext >& context, SdPage* pPage ) +: ::cppu::WeakComponentImplHelper1< XAnnotation >(m_aMutex) +, ::cppu::PropertySetMixin< XAnnotation >(context, static_cast< Implements >(IMPLEMENTS_PROPERTY_SET), Sequence< ::rtl::OUString >()) +, mpPage( pPage ) +{ +} + +// overload WeakComponentImplHelperBase::disposing() +// This function is called upon disposing the component, +// if your component needs special work when it becomes +// disposed, do it here. +void SAL_CALL Annotation::disposing() +{ + mpPage = 0; + if( m_TextRange.is() ) + { + m_TextRange->dispose(); + m_TextRange.clear(); + } +} + +Any Annotation::queryInterface(Type const & type) throw (RuntimeException) +{ + return ::cppu::WeakComponentImplHelper1< XAnnotation>::queryInterface(type); +} + +// com.sun.star.beans.XPropertySet: +Reference< XPropertySetInfo > SAL_CALL Annotation::getPropertySetInfo() throw (RuntimeException) +{ + return ::cppu::PropertySetMixin< XAnnotation >::getPropertySetInfo(); +} + +void SAL_CALL Annotation::setPropertyValue(const OUString & aPropertyName, const Any & aValue) throw (RuntimeException, UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException) +{ + ::cppu::PropertySetMixin< XAnnotation >::setPropertyValue(aPropertyName, aValue); +} + +Any SAL_CALL Annotation::getPropertyValue(const OUString & aPropertyName) throw (RuntimeException, UnknownPropertyException, WrappedTargetException) +{ + return ::cppu::PropertySetMixin< XAnnotation >::getPropertyValue(aPropertyName); +} + +void SAL_CALL Annotation::addPropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException) +{ + ::cppu::PropertySetMixin< XAnnotation >::addPropertyChangeListener(aPropertyName, xListener); +} + +void SAL_CALL Annotation::removePropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException) +{ + ::cppu::PropertySetMixin< XAnnotation >::removePropertyChangeListener(aPropertyName, xListener); +} + +void SAL_CALL Annotation::addVetoableChangeListener(const OUString & aPropertyName, const Reference< XVetoableChangeListener > & xListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException) +{ + ::cppu::PropertySetMixin< XAnnotation >::addVetoableChangeListener(aPropertyName, xListener); +} + +void SAL_CALL Annotation::removeVetoableChangeListener(const OUString & aPropertyName, const Reference< XVetoableChangeListener > & xListener) throw (RuntimeException, UnknownPropertyException, WrappedTargetException) +{ + ::cppu::PropertySetMixin< XAnnotation >::removeVetoableChangeListener(aPropertyName, xListener); +} + +Any SAL_CALL Annotation::getAnchor() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + Any aRet; + if( mpPage ) + { + Reference< XDrawPage > xPage( mpPage->getUnoPage(), UNO_QUERY ); + aRet <<= xPage; + } + return aRet; +} + +// ::com::sun::star::office::XAnnotation: +RealPoint2D SAL_CALL Annotation::getPosition() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_Position; +} + +void SAL_CALL Annotation::setPosition(const RealPoint2D & the_value) throw (RuntimeException) +{ + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Position")), + Any(), Any(), 0); + { + osl::MutexGuard g(m_aMutex); + createChangeUndo(); + m_Position = the_value; + } +} + +// ::com::sun::star::office::XAnnotation: +RealSize2D SAL_CALL Annotation::getSize() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_Size; +} + +void SAL_CALL Annotation::setSize(const RealSize2D & the_value) throw (RuntimeException) +{ + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size")), + Any(), Any(), 0); + { + osl::MutexGuard g(m_aMutex); + createChangeUndo(); + m_Size = the_value; + } +} + +OUString SAL_CALL Annotation::getAuthor() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_Author; +} + +void SAL_CALL Annotation::setAuthor(const OUString & the_value) throw (RuntimeException) +{ + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Author")), + Any(), Any(), 0); + { + osl::MutexGuard g(m_aMutex); + createChangeUndo(); + m_Author = the_value; + } +} + +util::DateTime SAL_CALL Annotation::getDateTime() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + return m_DateTime; +} + +void SAL_CALL Annotation::setDateTime(const util::DateTime & the_value) throw (RuntimeException) +{ + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DateTime")), + Any(), Any(), 0); + { + osl::MutexGuard g(m_aMutex); + createChangeUndo(); + m_DateTime = the_value; + } +} + +void Annotation::createChangeUndo() +{ + SdrModel* pModel = GetModel(); + if( pModel && pModel->IsUndoEnabled() ) + pModel->AddUndo( new UndoAnnotation( *this ) ); + + if( pModel ) + { + pModel->SetChanged(); + Reference< XInterface > xSource( static_cast<uno::XWeak*>( this ) ); + NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), OUString( RTL_CONSTASCII_USTRINGPARAM("OnAnnotationChanged") ), xSource ); + } +} + +Reference< XText > SAL_CALL Annotation::getTextRange() throw (RuntimeException) +{ + osl::MutexGuard g(m_aMutex); + if( !m_TextRange.is() && (mpPage != 0) ) + { + m_TextRange = TextApiObject::create( static_cast< SdDrawDocument* >( mpPage->GetModel() ) ); + } + return Reference< XText >( m_TextRange.get() ); +} + +SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert ) +{ + Annotation* pAnnotation = dynamic_cast< Annotation* >( xAnnotation.get() ); + if( pAnnotation ) + { + return new UndoInsertOrRemoveAnnotation( *pAnnotation, bInsert ); + } + else + { + return 0; + } +} + +UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert ) +: SdrUndoAction( *rAnnotation.GetModel() ) +, mxAnnotation( &rAnnotation ) +, mbInsert( bInsert ) +, mnIndex( 0 ) +{ + SdPage* pPage = rAnnotation.GetPage(); + if( pPage ) + { + Reference< XAnnotation > xAnnotation( &rAnnotation ); + + const AnnotationVector& rVec = pPage->getAnnotations(); + for( AnnotationVector::const_iterator iter = rVec.begin(); iter != rVec.end(); iter++ ) + { + if( (*iter) == xAnnotation ) + break; + + mnIndex++; + } + } +} + +void UndoInsertOrRemoveAnnotation::Undo() +{ + SdPage* pPage = mxAnnotation->GetPage(); + SdrModel* pModel = mxAnnotation->GetModel(); + if( pPage && pModel ) + { + Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); + if( mbInsert ) + { + pPage->removeAnnotation( xAnnotation ); + } + else + { + pPage->addAnnotation( xAnnotation, mnIndex ); + } + } +} + +void UndoInsertOrRemoveAnnotation::Redo() +{ + SdPage* pPage = mxAnnotation->GetPage(); + SdrModel* pModel = mxAnnotation->GetModel(); + if( pPage && pModel ) + { + Reference< XAnnotation > xAnnotation( mxAnnotation.get() ); + + if( mbInsert ) + { + pPage->addAnnotation( xAnnotation, mnIndex ); + } + else + { + pPage->removeAnnotation( xAnnotation ); + } + } +} + +UndoAnnotation::UndoAnnotation( Annotation& rAnnotation ) +: SdrUndoAction( *rAnnotation.GetModel() ) +, mxAnnotation( &rAnnotation ) +{ + maUndoData.get( mxAnnotation ); +} + +void UndoAnnotation::Undo() +{ + maRedoData.get( mxAnnotation ); + maUndoData.set( mxAnnotation ); +} + +void UndoAnnotation::Redo() +{ + maUndoData.get( mxAnnotation ); + maRedoData.set( mxAnnotation ); +} + +} // namespace sd + diff --git a/sd/source/core/annotations/AnnotationAccess.cxx b/sd/source/core/annotations/AnnotationAccess.cxx new file mode 100644 index 000000000..ffcca9796 --- /dev/null +++ b/sd/source/core/annotations/AnnotationAccess.cxx @@ -0,0 +1,59 @@ +#include "sal/config.h" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "cppuhelper/implbase1.hxx" +#include "com/sun/star/office/XAnnotationAccess.hpp" + +namespace css = ::com::sun::star; + +class AnnotationAccess: + public ::cppu::WeakImplHelper1< + css::office::XAnnotationAccess> +{ +public: + explicit AnnotationAccess(css::uno::Reference< css::uno::XComponentContext > const & context); + + // ::com::sun::star::office::XAnnotationAccess: + virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL createAndInsertAnnotation() throw (css::uno::RuntimeException); + virtual void SAL_CALL removeAnnotation(const css::uno::Reference< css::office::XAnnotation > & annotation) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException); + virtual css::uno::Reference< css::office::XAnnotationEnumeration > SAL_CALL createAnnotationEnumeration() throw (css::uno::RuntimeException); + +private: + AnnotationAccess(const AnnotationAccess &); // not defined + AnnotationAccess& operator=(const AnnotationAccess &); // not defined + + // destructor is private and will be called indirectly by the release call virtual ~AnnotationAccess() {} + + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +AnnotationAccess::AnnotationAccess(css::uno::Reference< css::uno::XComponentContext > const & context) : + m_xContext(context) +{} + +// ::com::sun::star::office::XAnnotationAccess: +css::uno::Reference< css::office::XAnnotation > SAL_CALL AnnotationAccess::createAndInsertAnnotation() throw (css::uno::RuntimeException) +{ + // TODO: Exchange the default return implementation for "createAndInsertAnnotation" !!! + // Exchange the default return implementation. + // NOTE: Default initialized polymorphic structs can cause problems because of + // missing default initialization of primitive types of some C++ compilers or + // different Any initialization in Java and C++ polymorphic structs. + return css::uno::Reference< css::office::XAnnotation >(); +} + +void SAL_CALL AnnotationAccess::removeAnnotation(const css::uno::Reference< css::office::XAnnotation > & annotation) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException) +{ + // TODO: Insert your implementation for "removeAnnotation" here. +} + +css::uno::Reference< css::office::XAnnotationEnumeration > SAL_CALL AnnotationAccess::createAnnotationEnumeration() throw (css::uno::RuntimeException) +{ + // TODO: Exchange the default return implementation for "createAnnotationEnumeration" !!! + // Exchange the default return implementation. + // NOTE: Default initialized polymorphic structs can cause problems because of + // missing default initialization of primitive types of some C++ compilers or + // different Any initialization in Java and C++ polymorphic structs. + return css::uno::Reference< css::office::XAnnotationEnumeration >(); +} + + diff --git a/sd/source/core/annotations/AnnotationEnumeration.cxx b/sd/source/core/annotations/AnnotationEnumeration.cxx new file mode 100644 index 000000000..86e42b748 --- /dev/null +++ b/sd/source/core/annotations/AnnotationEnumeration.cxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unopage.cxx,v $ + * $Revision: 1.96 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "sal/config.h" + +#include "cppuhelper/implbase1.hxx" + +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/office/XAnnotationEnumeration.hpp" + +#include "sdpage.hxx" +namespace css = ::com::sun::star; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::office; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +namespace sd { + +class AnnotationEnumeration: public ::cppu::WeakImplHelper1< css::office::XAnnotationEnumeration > +{ +public: + AnnotationEnumeration( const AnnotationVector& rAnnotations ); + + // ::com::sun::star::office::XAnnotationEnumeration: + virtual ::sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException); + virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException); + +private: + AnnotationEnumeration(const AnnotationEnumeration &); // not defined + AnnotationEnumeration& operator=(const AnnotationEnumeration &); // not defined + + // destructor is private and will be called indirectly by the release call virtual ~AnnotationEnumeration() {} + + AnnotationVector maAnnotations; + AnnotationVector::iterator maIter; +}; + +Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& rAnnotations ) +{ + return new AnnotationEnumeration( rAnnotations ); +} + +AnnotationEnumeration::AnnotationEnumeration( const AnnotationVector& rAnnotations ) +: maAnnotations(rAnnotations) +{ + maIter = maAnnotations.begin(); +} + +// ::com::sun::star::office::XAnnotationEnumeration: +::sal_Bool SAL_CALL AnnotationEnumeration::hasMoreElements() throw (css::uno::RuntimeException) +{ + return maIter != maAnnotations.end() ? sal_True : sal_False; +} + +css::uno::Reference< css::office::XAnnotation > SAL_CALL AnnotationEnumeration::nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException) +{ + if( maIter == maAnnotations.end() ) + throw css::container::NoSuchElementException(); + + return (*maIter++); +} + +} // namespace sd + diff --git a/sd/source/core/annotations/makefile.mk b/sd/source/core/annotations/makefile.mk new file mode 100644 index 000000000..0cbf57e3f --- /dev/null +++ b/sd/source/core/annotations/makefile.mk @@ -0,0 +1,53 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=annotations +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = $(SLO)$/Annotation.obj \ + $(SLO)$/AnnotationEnumeration.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 8211ff6ec..624fa6fc5 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -34,6 +34,7 @@ #include "PageListWatcher.hxx" #include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svx/forbiddencharacterstable.hxx> #include <svx/svxids.hrc> @@ -41,6 +42,8 @@ #include <svx/eeitem.hxx> #include <svx/scriptspaceitem.hxx> +#include <svtools/useroptions.hxx> + #ifndef _OFA_MISCCFG_HXX #include <svtools/misccfg.hxx> #endif @@ -222,7 +225,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) // Vorlagen existieren. SdrOutliner& rOutliner = GetDrawOutliner(); rOutliner.SetStyleSheetPool((SfxStyleSheetPool*)GetStyleSheetPool()); - rOutliner.SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); + SetCalcFieldValueHdl( &rOutliner ); // set linguistic options { @@ -230,9 +233,12 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) SvtLinguOptions aOptions; aLinguConfig.GetOptions( aOptions ); - SetLanguage( aOptions.nDefaultLanguage, EE_CHAR_LANGUAGE ); - SetLanguage( aOptions.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ); - SetLanguage( aOptions.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ); + SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, + ::com::sun::star::i18n::ScriptType::LATIN), EE_CHAR_LANGUAGE ); + SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, + ::com::sun::star::i18n::ScriptType::ASIAN), EE_CHAR_LANGUAGE_CJK ); + SetLanguage( MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, + ::com::sun::star::i18n::ScriptType::COMPLEX), EE_CHAR_LANGUAGE_CTL ); mbOnlineSpell = aOptions.bIsSpellAuto; } @@ -315,7 +321,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) SfxItemSet aSet2( pHitTestOutliner->GetEmptyItemSet() ); pHitTestOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)GetStyleSheetPool() ); - pHitTestOutliner->SetCalcFieldValueHdl( LINK(SD_MOD(), SdModule, CalcFieldValueHdl) ); + SetCalcFieldValueHdl( pHitTestOutliner ); try { @@ -1068,5 +1074,36 @@ void SdDrawDocument::MasterPageListChanged() mpMasterPageListWatcher->Invalidate(); } +void SdDrawDocument::SetCalcFieldValueHdl(::Outliner* pOutliner) +{ + pOutliner->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl)); +} + +sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const rtl::OUString& rAuthor ) +{ + // force current user to have first color + if( maAnnotationAuthors.empty() ) + { + SvtUserOptions aUserOptions; + maAnnotationAuthors.push_back( aUserOptions.GetFullName() ); + } + + sal_uInt16 idx = 0; + for( std::vector< OUString >::iterator iter( maAnnotationAuthors.begin() ); iter != maAnnotationAuthors.end(); iter++ ) + { + if( (*iter) == rAuthor ) + { + break; + } + idx++; + } + + if( idx == maAnnotationAuthors.size() ) + { + maAnnotationAuthors.push_back( rAuthor ); + } + + return idx; +} // eof diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 93e39e884..bfa87d633 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -64,6 +64,10 @@ using namespace ::sd; using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::office; + +extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const Reference< XInterface >& xSource ); /************************************************************************* |* @@ -586,3 +590,62 @@ void SdPage::setTransitionDuration ( double fTranstionDuration ) mfTransitionDuration = fTranstionDuration; ActionChanged(); } + +namespace sd { +extern void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage ); +extern SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert ); +} + +void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) +{ + sd::createAnnotation( xAnnotation, this ); +} + +void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex ) +{ + if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) ) + { + maAnnotations.push_back( xAnnotation ); + } + else + { + maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation ); + } + + if( pModel && pModel->IsUndoEnabled() ) + { + SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true ); + if( pAction ) + pModel->AddUndo( pAction ); + } + + SetChanged(); + + if( pModel ) + { + pModel->SetChanged(); + Reference< XInterface > xSource( xAnnotation, UNO_QUERY ); + NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationInserted" ) ), xSource ); + } +} + +void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation ) +{ + if( pModel && pModel->IsUndoEnabled() ) + { + SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false ); + if( pAction ) + pModel->AddUndo( pAction ); + } + + AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation ); + if( iter != maAnnotations.end() ) + maAnnotations.erase( iter ); + + if( pModel ) + { + pModel->SetChanged(); + Reference< XInterface > xSource( xAnnotation, UNO_QUERY ); + NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationRemoved" ) ), xSource ); + } +} diff --git a/sd/source/core/text/makefile.mk b/sd/source/core/text/makefile.mk new file mode 100644 index 000000000..83ad7f619 --- /dev/null +++ b/sd/source/core/text/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=text +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = $(SLO)$/textapi.obj + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx new file mode 100644 index 000000000..df2786d62 --- /dev/null +++ b/sd/source/core/text/textapi.cxx @@ -0,0 +1,325 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textapi.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include <com/sun/star/text/XTextField.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include <textapi.hxx> +#include <drawdoc.hxx> +#include <svx/eeitem.hxx> +#include <svx/editeng.hxx> +#include <svx/outlobj.hxx> +#include "Outliner.hxx" + +using ::rtl::OUString; + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; + +namespace sd { + +class UndoTextAPIChanged : public SdrUndoAction +{ +public: + UndoTextAPIChanged( SdrModel& rModel, TextApiObject* pTextObj ); + ~UndoTextAPIChanged(); + + virtual void Undo(); + virtual void Redo(); + +protected: + OutlinerParaObject* mpOldText; + OutlinerParaObject* mpNewText; + rtl::Reference< TextApiObject > mxTextObj; +}; + +UndoTextAPIChanged::UndoTextAPIChanged(SdrModel& rModel, TextApiObject* pTextObj ) +: SdrUndoAction( rModel ) +, mpOldText( pTextObj->CreateText() ) +, mpNewText( 0 ) +, mxTextObj( pTextObj ) +{ +} + +UndoTextAPIChanged::~UndoTextAPIChanged() +{ + delete mpOldText; + delete mpNewText; +} + +void UndoTextAPIChanged::Undo() +{ + if( !mpNewText ) + mpNewText = mxTextObj->CreateText(); + + mxTextObj->SetText( *mpOldText ); +} + +void UndoTextAPIChanged::Redo() +{ + if( mpNewText ) + { + mxTextObj->SetText( *mpNewText ); + } +} + +struct TextAPIEditSource_Impl +{ + // needed for "internal" refcounting + SdDrawDocument* mpDoc; + Outliner* mpOutliner; + SvxOutlinerForwarder* mpTextForwarder; + sal_Int32 mnRef; +}; + +class TextAPIEditSource : public SvxEditSource +{ + TextAPIEditSource_Impl* pImpl; + + virtual SvxEditSource* Clone() const; + virtual SvxTextForwarder* GetTextForwarder(); + virtual void UpdateData(); + explicit TextAPIEditSource( const TextAPIEditSource& rSource ); + +public: + TextAPIEditSource(SdDrawDocument* pDoc); + virtual ~TextAPIEditSource(); + + void Dispose(); + void SetText( OutlinerParaObject& rText ); + void SetString( const String& rText ); + OutlinerParaObject* CreateText(); + String GetText(); + SdDrawDocument* GetDoc() { return pImpl->mpDoc; } +}; + +const SvxItemPropertySet* ImplGetSdTextPortionPropertyMap() +{ + static const SfxItemPropertyMapEntry aSdTextPortionPropertyEntries[] = + { + SVX_UNOEDIT_CHAR_PROPERTIES, + SVX_UNOEDIT_FONT_PROPERTIES, + SVX_UNOEDIT_OUTLINER_PROPERTIES, + SVX_UNOEDIT_PARA_PROPERTIES, + {MAP_CHAR_LEN("TextField"), EE_FEATURE_FIELD, &::getCppuType((const Reference< XTextField >*)0), PropertyAttribute::READONLY, 0 }, + {MAP_CHAR_LEN("TextPortionType"), WID_PORTIONTYPE, &::getCppuType((const OUString*)0), PropertyAttribute::READONLY, 0 }, + {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const Reference< XNameContainer >*)0) , 0, 0}, + {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const Reference< XNameContainer >*)0) , 0, 0}, + {0,0,0,0,0,0} + }; + static SvxItemPropertySet aSdTextPortionPropertyMap( aSdTextPortionPropertyEntries ); + + return &aSdTextPortionPropertyMap; +} + +TextApiObject::TextApiObject( TextAPIEditSource* pEditSource ) +: SvxUnoText( pEditSource, ImplGetSdTextPortionPropertyMap(), Reference < XText >() ) +, mpSource(pEditSource) +{ +} + +TextApiObject::~TextApiObject() throw() +{ + dispose(); +} + +rtl::Reference< TextApiObject > TextApiObject::create( SdDrawDocument* pDoc ) +{ + rtl::Reference< TextApiObject > xRet( new TextApiObject( new TextAPIEditSource( pDoc ) ) ); + return xRet; +} + +void SAL_CALL TextApiObject::dispose() throw(RuntimeException) +{ + if( mpSource ) + { + mpSource->Dispose(); + delete mpSource; + mpSource = 0; + } + + // SvxUnoText::dispose(); +} + +OutlinerParaObject* TextApiObject::CreateText() +{ + return mpSource->CreateText(); +} + +void TextApiObject::SetString( const String& rText ) +{ + SdrModel* pModel = mpSource->GetDoc(); + if( pModel && pModel->IsUndoEnabled() ) + pModel->AddUndo( new UndoTextAPIChanged( *pModel, this ) ); + + mpSource->SetString( rText ); + maSelection.nStartPara = 0xffff; +} + +void TextApiObject::SetText( OutlinerParaObject& rText ) +{ + SdrModel* pModel = mpSource->GetDoc(); + if( pModel && pModel->IsUndoEnabled() ) + pModel->AddUndo( new UndoTextAPIChanged( *pModel, this ) ); + + mpSource->SetText( rText ); + maSelection.nStartPara = 0xffff; +} + +String TextApiObject::GetText() +{ + return mpSource->GetText(); +} + +TextApiObject* TextApiObject::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >& xText ) +{ + TextApiObject* pImpl = dynamic_cast< TextApiObject* >( xText.get() ); + + if( !pImpl ) + pImpl = dynamic_cast< TextApiObject* >( SvxUnoTextBase::getImplementation( xText ) ); + + return pImpl; +} + +TextAPIEditSource::TextAPIEditSource( const TextAPIEditSource& rSource ) +: SvxEditSource( *this ) +{ + // shallow copy; uses internal refcounting + pImpl = rSource.pImpl; + pImpl->mnRef++; +} + +SvxEditSource* TextAPIEditSource::Clone() const +{ + return new TextAPIEditSource( *this ); +} + +void TextAPIEditSource::UpdateData() +{ + // data is kept in outliner all the time +} + +TextAPIEditSource::TextAPIEditSource(SdDrawDocument* pDoc) +: pImpl(new TextAPIEditSource_Impl) +{ + pImpl->mpDoc = pDoc; + pImpl->mpOutliner = 0; + pImpl->mpTextForwarder = 0; + pImpl->mnRef = 1; +} + +TextAPIEditSource::~TextAPIEditSource() +{ + if (!--pImpl->mnRef) + delete pImpl; +} + +void TextAPIEditSource::Dispose() +{ + pImpl->mpDoc=0; + delete pImpl->mpTextForwarder; + pImpl->mpTextForwarder = 0; + + delete pImpl->mpOutliner; + pImpl->mpOutliner = 0; +} + +SvxTextForwarder* TextAPIEditSource::GetTextForwarder() +{ + if( !pImpl->mpDoc ) + return 0; // mpDoc == 0 can be used to flag this as disposed + + if( !pImpl->mpOutliner ) + { + //init draw model first + pImpl->mpOutliner = new Outliner( pImpl->mpDoc, OUTLINERMODE_TEXTOBJECT ); + pImpl->mpDoc->SetCalcFieldValueHdl( pImpl->mpOutliner ); + } + + if( !pImpl->mpTextForwarder ) + pImpl->mpTextForwarder = new SvxOutlinerForwarder( *pImpl->mpOutliner, 0 ); + + return pImpl->mpTextForwarder; +} + +void TextAPIEditSource::SetText( OutlinerParaObject& rText ) +{ + if ( pImpl->mpDoc ) + { + if( !pImpl->mpOutliner ) + { + //init draw model first + pImpl->mpOutliner = new Outliner( pImpl->mpDoc, OUTLINERMODE_TEXTOBJECT ); + pImpl->mpDoc->SetCalcFieldValueHdl( pImpl->mpOutliner ); + } + + pImpl->mpOutliner->SetText( rText ); + } +} + +void TextAPIEditSource::SetString( const String& rText ) +{ + if ( pImpl->mpDoc ) + { + if( !pImpl->mpOutliner ) + { + //init draw model first + pImpl->mpOutliner = new Outliner( pImpl->mpDoc, OUTLINERMODE_TEXTOBJECT ); + pImpl->mpDoc->SetCalcFieldValueHdl( pImpl->mpOutliner ); + } + else + pImpl->mpOutliner->Clear(); + pImpl->mpOutliner->Insert( rText ); + } +} + +OutlinerParaObject* TextAPIEditSource::CreateText() +{ + if ( pImpl->mpDoc && pImpl->mpOutliner ) + return pImpl->mpOutliner->CreateParaObject(); + else + return 0; +} + +String TextAPIEditSource::GetText() +{ + if ( pImpl->mpDoc && pImpl->mpOutliner ) + return pImpl->mpOutliner->GetEditEngine().GetText(); + else + return String(); +} + +} // namespace sd diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index c9cdd9240..4f29f503b 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -50,6 +50,11 @@ #include <com/sun/star/view/PaperOrientation.hpp> #include <com/sun/star/view/PaperFormat.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/office/XAnnotation.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> +#include <com/sun/star/office/XAnnotationEnumeration.hpp> +#include <com/sun/star/geometry/RealPoint2D.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <tools/zcodec.hxx> #include <svx/svxenum.hxx> #include <sot/storinfo.hxx> @@ -402,17 +407,17 @@ void PPTWriter::ImplCreateHeaderFooterStrings( SvStream& rStrm, ::com::sun::star if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ), sal_True ) ) { if ( aAny >>= aString ) - ImplWriteCString( rStrm, aString, 1 ); + PPTWriter::WriteCString( rStrm, aString, 1 ); } if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ), sal_True ) ) { if ( aAny >>= aString ) - ImplWriteCString( rStrm, aString, 2 ); + PPTWriter::WriteCString( rStrm, aString, 2 ); } if ( PropValue::GetPropertyValue( aAny, rXPagePropSet, String( RTL_CONSTASCII_USTRINGPARAM( "DateTimeText" ) ), sal_True ) ) { if ( aAny >>= aString ) - ImplWriteCString( rStrm, aString, 0 ); + PPTWriter::WriteCString( rStrm, aString, 0 ); } } } @@ -1206,6 +1211,93 @@ sal_Bool PPTWriter::ImplCreateMainNotes() // --------------------------------------------------------------------------------------------- +static rtl::OUString getInitials( const rtl::OUString& rName ) +{ + rtl::OUString sInitials; + + const sal_Unicode * pStr = rName.getStr(); + sal_Int32 nLength = rName.getLength(); + + while( nLength ) + { + // skip whitespace + while( nLength && (*pStr <= ' ') ) + { + nLength--; pStr++; + } + + // take letter + if( nLength ) + { + sInitials += rtl::OUString( *pStr ); + nLength--; pStr++; + } + + // skip letters until whitespace + while( nLength && (*pStr > ' ') ) + { + nLength--; pStr++; + } + } + + return sInitials; +} + +void ImplExportComments( uno::Reference< drawing::XDrawPage > xPage, SvMemoryStream& rBinaryTagData10Atom ) +{ + try + { + uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW ); + uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); + + sal_Int32 nIndex = 1; + + while( xAnnotationEnumeration->hasMoreElements() ) + { + EscherExContainer aComment10( rBinaryTagData10Atom, EPP_Comment10 ); + { + uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() ); + + geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() ); + MapMode aMapDest( MAP_INCH, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) ); + Point aPoint( OutputDevice::LogicToLogic( Point( static_cast< sal_Int32 >( aRealPoint2D.X * 100.0 ), + static_cast< sal_Int32 >( aRealPoint2D.Y * 100.0 ) ), MAP_100TH_MM, aMapDest ) ); + + rtl::OUString sAuthor( xAnnotation->getAuthor() ); + uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); + rtl::OUString sText( xText->getString() ); + rtl::OUString sInitials( getInitials( sAuthor ) ); + util::DateTime aDateTime( xAnnotation->getDateTime() ); + if ( sAuthor.getLength() ) + PPTWriter::WriteCString( rBinaryTagData10Atom, sAuthor, 0 ); + if ( sText.getLength() ) + PPTWriter::WriteCString( rBinaryTagData10Atom, sText, 1 ); + if ( sInitials.getLength() ) + PPTWriter::WriteCString( rBinaryTagData10Atom, sInitials, 2 ); + + sal_Int16 nMilliSeconds = aDateTime.HundredthSeconds * 10; + EscherExAtom aCommentAtom10( rBinaryTagData10Atom, EPP_CommentAtom10 ); + rBinaryTagData10Atom << nIndex++ + << aDateTime.Year + << aDateTime.Month + << aDateTime.Day // todo: day of week + << aDateTime.Day + << aDateTime.Hours + << aDateTime.Minutes + << aDateTime.Seconds + << nMilliSeconds + << static_cast< sal_Int32 >( aPoint.X() ) + << static_cast< sal_Int32 >( aPoint.Y() ); + } + } + } + catch ( uno::Exception& ) + { + } +} + +// --------------------------------------------------------------------------------------------- + sal_Bool PPTWriter::ImplCreateSlide( sal_uInt32 nPageNum ) { ::com::sun::star::uno::Any aAny; @@ -1567,6 +1659,49 @@ sal_Bool PPTWriter::ImplCreateSlide( sal_uInt32 nPageNum ) mpPptEscherEx->AddAtom( 32, EPP_ColorSchemeAtom, 0, 1 ); *mpStrm << (sal_uInt32)0xffffff << (sal_uInt32)0x000000 << (sal_uInt32)0x808080 << (sal_uInt32)0x000000 << (sal_uInt32)0x99cc00 << (sal_uInt32)0xcc3333 << (sal_uInt32)0xffcccc << (sal_uInt32)0xb2b2b2; + SvMemoryStream aBinaryTagData10Atom; + ImplExportComments( mXDrawPage, aBinaryTagData10Atom ); + if ( mbUseNewAnimations ) + { + SvMemoryStream amsofbtAnimGroup; + ppt::AnimationExporter aExporter( aSolverContainer, maSoundCollection ); + aExporter.doexport( mXDrawPage, amsofbtAnimGroup ); + sal_uInt32 nmsofbtAnimGroupSize = amsofbtAnimGroup.Tell(); + if ( nmsofbtAnimGroupSize ) + { + { + EscherExAtom aMagic2( aBinaryTagData10Atom, 0x2eeb ); + aBinaryTagData10Atom << (sal_uInt32)0x01c45df9 + << (sal_uInt32)0xe1471b30; + } + { + EscherExAtom aMagic( aBinaryTagData10Atom, 0x2b00 ); + aBinaryTagData10Atom << (sal_uInt32)0; + } + aBinaryTagData10Atom.Write( amsofbtAnimGroup.GetData(), amsofbtAnimGroup.Tell() ); + { + EscherExContainer aMagic2( aBinaryTagData10Atom, 0x2b02 ); + } + } + } + if ( aBinaryTagData10Atom.Tell() ) + { + EscherExContainer aProgTags ( *mpStrm, EPP_ProgTags ); + EscherExContainer aProgBinaryTag( *mpStrm, EPP_ProgBinaryTag ); + { + EscherExAtom aCString( *mpStrm, EPP_CString ); + *mpStrm << (sal_uInt32)0x5f005f + << (sal_uInt32)0x50005f + << (sal_uInt32)0x540050 + << (sal_uInt16)0x31 + << (sal_uInt16)0x30; + } + { + EscherExAtom aBinaryTagData( *mpStrm, EPP_BinaryTagData ); + mpStrm->Write( aBinaryTagData10Atom.GetData(), aBinaryTagData10Atom.Tell() ); + } + } +/* if ( mbUseNewAnimations ) { SvMemoryStream amsofbtAnimGroup; @@ -1605,6 +1740,7 @@ sal_Bool PPTWriter::ImplCreateSlide( sal_uInt32 nPageNum ) } } } +*/ mpPptEscherEx->CloseContainer(); // EPP_Slide return TRUE; }; @@ -1722,18 +1858,6 @@ void PPTWriter::ImplWriteBackground( ::com::sun::star::uno::Reference< ::com::su mpPptEscherEx->CloseContainer(); // ESCHER_SpContainer } -void PPTWriter::ImplWriteCString( SvStream& rSt, const String& rString, sal_uInt32 nInstance ) -{ - sal_uInt32 i, nLen = rString.Len(); - if ( nLen ) - { - rSt << (sal_uInt32)( ( nInstance << 4 ) | ( EPP_CString << 16 ) ) - << (sal_uInt32)( nLen << 1 ); - for ( i = 0; i < nLen; i++ ) - rSt << rString.GetChar( (sal_uInt16)i ); - } -} - void PPTWriter::ImplWriteVBA( SvMemoryStream* pVBA ) { if ( pVBA ) diff --git a/sd/source/filter/eppt/eppt.hxx b/sd/source/filter/eppt/eppt.hxx index 4a023f454..ed84604e9 100644 --- a/sd/source/filter/eppt/eppt.hxx +++ b/sd/source/filter/eppt/eppt.hxx @@ -775,6 +775,9 @@ class PPTWriter : public GroupTable, public PropValue, public PPTExBulletProvide sal_uInt32 ImplDocumentListContainer( SvStream* pOutStrm = NULL ); sal_uInt32 ImplMasterSlideListContainer( SvStream* pOutStrm = NULL ); + public: + static void WriteCString( SvStream&, const String&, sal_uInt32 nInstance = 0 ); + protected: sal_Bool ImplCreateDocumentSummaryInformation( sal_uInt32 nCnvrtFlags ); @@ -835,7 +838,6 @@ class PPTWriter : public GroupTable, public PropValue, public PPTExBulletProvide Rectangle ImplMapRectangle( const ::com::sun::star::awt::Rectangle& ); sal_Bool ImplCloseDocument(); // die font-, hyper-, Soundliste wird geschrieben .. - void ImplWriteCString( SvStream&, const String&, sal_uInt32 nInstance = 0 ); public: PPTWriter( SvStorageRef& rSvStorage, diff --git a/sd/source/filter/eppt/epptdef.hxx b/sd/source/filter/eppt/epptdef.hxx index aca87978e..8c4c00f51 100644 --- a/sd/source/filter/eppt/epptdef.hxx +++ b/sd/source/filter/eppt/epptdef.hxx @@ -214,6 +214,9 @@ #define EPP_GscalingAtom 10001 #define EPP_GrColorAtom 10002 #define EPP_GLPointAtom 10003 +#define EPP_Comment10 12000 +#define EPP_CommentAtom10 12001 + #define EPP_PLACEHOLDER_NONE 0 // 0 None #define EPP_PLACEHOLDER_MASTERTITLE 1 // 1 Master title diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 7bdf54eed..3c4cf0318 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -4605,11 +4605,11 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a } } if ( aControlName.Len() ) - ImplWriteCString( *mpExEmbed, aControlName, 1 ); + PPTWriter::WriteCString( *mpExEmbed, aControlName, 1 ); if ( aOleIdentifier.Len() ) - ImplWriteCString( *mpExEmbed, aOleIdentifier, 2 ); + PPTWriter::WriteCString( *mpExEmbed, aOleIdentifier, 2 ); if ( aUserName.Len() ) - ImplWriteCString( *mpExEmbed, aUserName, 3 ); + PPTWriter::WriteCString( *mpExEmbed, aUserName, 3 ); } nSize = mpExEmbed->Tell() - nOldPos; mpExEmbed->Seek( nOldPos - 4 ); @@ -5094,9 +5094,9 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a << (sal_uInt32)0 << (sal_uInt32)0x0012b600; -// ImplWriteCString( *mpExEmbed, "Photo Editor Photo", 1 ); -// ImplWriteCString( *mpExEmbed, "MSPhotoEd.3", 2 ); -// ImplWriteCString( *mpExEmbed, "Microsoft Photo Editor 3.0 Photo", 3 ); +// PPTWriter::WriteCString( *mpExEmbed, "Photo Editor Photo", 1 ); +// PPTWriter::WriteCString( *mpExEmbed, "MSPhotoEd.3", 2 ); +// PPTWriter::WriteCString( *mpExEmbed, "Microsoft Photo Editor 3.0 Photo", 3 ); nSize = mpExEmbed->Tell() - nOldPos; mpExEmbed->Seek( nOldPos - 4 ); @@ -5573,6 +5573,18 @@ void PPTWriter::ImplCreateCellBorder( const CellBorder* pCellBorder, sal_Int32 n } } +void PPTWriter::WriteCString( SvStream& rSt, const String& rString, sal_uInt32 nInstance ) +{ + sal_uInt32 i, nLen = rString.Len(); + if ( nLen ) + { + rSt << (sal_uInt32)( ( nInstance << 4 ) | ( EPP_CString << 16 ) ) + << (sal_uInt32)( nLen << 1 ); + for ( i = 0; i < nLen; i++ ) + rSt << rString.GetChar( (sal_uInt16)i ); + } +} + void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, EscherSolverContainer& aSolverContainer, EscherPropertyContainer& aPropOpt ) { diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index d3b641776..07287bdb1 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -265,6 +265,24 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXParseException& r ) { + // sax parser sends wrapped exceptions, + // try to find the original one + xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r); + sal_Bool bTryChild = sal_True; + + while( bTryChild ) + { + xml::sax::SAXException aTmp; + if ( aSaxEx.WrappedException >>= aTmp ) + aSaxEx = aTmp; + else + bTryChild = sal_False; + } + + packages::zip::ZipIOException aBrokenPackage; + if ( aSaxEx.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; @@ -295,7 +313,10 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXException& r ) { - (void)r; + packages::zip::ZipIOException aBrokenPackage; + if ( r.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; diff --git a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx index 5f86f7272..13e7dfd4f 100644 --- a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx +++ b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx @@ -33,6 +33,7 @@ #include "AccessibleDrawDocumentView.hxx" #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawView.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/frame/XController.hpp> @@ -73,12 +74,15 @@ #include "sdresid.hxx" #include <vos/mutex.hxx> -using namespace ::rtl; +using ::rtl::OUString; using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; class SfxViewFrame; +#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) + namespace accessibility { @@ -93,6 +97,7 @@ AccessibleDrawDocumentView::AccessibleDrawDocumentView ( mpChildrenManager (NULL) { OSL_TRACE ("AccessibleDrawDocumentView"); + UpdateAccessibleName(); } @@ -310,6 +315,9 @@ void SAL_CALL { OSL_TRACE (" current page changed"); + // Update the accessible name to reflect the current slide. + UpdateAccessibleName(); + // The current page changed. Update the children manager accordingly. uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); if (xView.is() && mpChildrenManager!=NULL) @@ -701,4 +709,46 @@ void SAL_CALL AccessibleDrawDocumentView::disposing (void) +void AccessibleDrawDocumentView::UpdateAccessibleName (void) +{ + OUString sNewName (CreateAccessibleName()); + sNewName += A2S(": "); + + // Add the number of the current slide. + uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); + if (xView.is()) + { + uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY); + if (xProperties.is()) + try + { + sal_Int16 nPageNumber (0); + if (xProperties->getPropertyValue(A2S("Number")) >>= nPageNumber) + { + sNewName += OUString::valueOf(sal_Int32(nPageNumber)); + } + } + catch (beans::UnknownPropertyException&) + { + } + } + + // Add the number of pages/slides. + Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY); + if (xPagesSupplier.is()) + { + Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY); + if (xPages.is()) + { + sNewName += A2S(" / "); + sNewName += OUString::valueOf(xPages->getCount()); + } + } + + SetAccessibleName (sNewName, AutomaticallyCreated); +} + + + + } // end of namespace accessibility diff --git a/sd/source/ui/accessibility/AccessiblePageShape.cxx b/sd/source/ui/accessibility/AccessiblePageShape.cxx index 6aff48bfb..e95ec4cfd 100644 --- a/sd/source/ui/accessibility/AccessiblePageShape.cxx +++ b/sd/source/ui/accessibility/AccessiblePageShape.cxx @@ -47,8 +47,12 @@ #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) namespace accessibility { @@ -342,7 +346,22 @@ void AccessiblePageShape::dispose (void) AccessiblePageShape::CreateAccessibleName (void) throw (::com::sun::star::uno::RuntimeException) { - return CreateAccessibleBaseName(); + Reference<beans::XPropertySet> xPageProperties (mxPage, UNO_QUERY); + + // Get name of the current slide. + OUString sCurrentSlideName; + try + { + if (xPageProperties.is()) + { + xPageProperties->getPropertyValue(A2S("LinkDisplayName")) >>= sCurrentSlideName; + } + } + catch (beans::UnknownPropertyException&) + { + } + + return CreateAccessibleBaseName()+A2S(": ")+sCurrentSlideName; } diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx new file mode 100644 index 000000000..e9880f9d7 --- /dev/null +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -0,0 +1,1264 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AnnotationManagerImpl.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "sddll.hxx" + +//#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/geometry/RealPoint2D.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/document/XEventBroadcaster.hpp> + +#include <vcl/menu.hxx> +#include <vcl/msgbox.hxx> + +#include <svtools/style.hxx> +#include <svtools/itempool.hxx> +#include <svtools/useroptions.hxx> +#include <svtools/syslocale.hxx> +#include <svtools/saveopt.hxx> + +#include <sfx2/imagemgr.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/app.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/imagemgr.hxx> + +#include <svx/editeng.hxx> +#include <svx/eeitem.hxx> +#include <svx/fontitem.hxx> +#include <svx/fhgtitem.hxx> +#include <svx/outlobj.hxx> +#include <svx/postitem.hxx> +#include <svx/wghtitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/crsditem.hxx> + +#include <svx/svdetc.hxx> + +#include "annotationmanager.hxx" +#include "annotationmanagerimpl.hxx" +#include "annotationwindow.hxx" +#include "annotations.hrc" + +#include "ToolBarManager.hxx" +#include "DrawDocShell.hxx" +#include "DrawViewShell.hxx" +#include "DrawController.hxx" +#include "glob.hrc" +#include "sdresid.hxx" +#include "EventMultiplexer.hxx" +#include "ViewShellManager.hxx" +#include "helpids.h" +#include "sdpage.hxx" +#include "drawdoc.hxx" +#include "textapi.hxx" +#include "optsitem.hxx" + +#define C2U(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) +using ::rtl::OUString; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::geometry; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::view; +using namespace ::com::sun::star::style; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::ui; +using namespace ::com::sun::star::task; +using namespace ::com::sun::star::office; + +namespace sd { + +// -------------------------------------------------------------------- + +extern TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation ); + +// -------------------------------------------------------------------- + +SfxItemPool* GetAnnotationPool() +{ + static SfxItemPool* mpAnnotationPool = 0; + if( mpAnnotationPool == 0 ) + { + mpAnnotationPool = EditEngine::CreatePool( sal_False ); + mpAnnotationPool->SetPoolDefaultItem(SvxFontHeightItem(423,100,EE_CHAR_FONTHEIGHT)); + + Font aAppFont( Application::GetSettings().GetStyleSettings().GetAppFont() ); + String EMPTYSTRING; + mpAnnotationPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamily(),aAppFont.GetName(), EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + } + + return mpAnnotationPool; +} + +// -------------------------------------------------------------------- + +static SfxBindings* getBindings( ViewShellBase& rBase ) +{ + if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() ) + return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings(); + else + return 0; +} + +// -------------------------------------------------------------------- + +static SfxDispatcher* getDispatcher( ViewShellBase& rBase ) +{ + if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() ) + return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher(); + else + return 0; +} + +com::sun::star::util::DateTime getCurrentDateTime() +{ + TimeValue osltime; + osl_getSystemTime( &osltime ); + oslDateTime osldt; + osl_getDateTimeFromTimeValue( &osltime, &osldt ); + return com::sun::star::util::DateTime( 0, osldt.Seconds, osldt.Minutes, osldt.Hours, osldt.Day, osldt.Month, osldt.Year ); +} + +OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotation ) +{ + OUString sRet; + if( xAnnotation.is() ) + { + const LocaleDataWrapper& rLocalData = SvtSysLocale().GetLocaleData(); + + com::sun::star::util::DateTime aDateTime( xAnnotation->getDateTime() ); + + Date aDate = Date( aDateTime.Day, aDateTime.Month, aDateTime.Year ); + if (aDate==Date()) + sRet = sRet + String(SdResId(STR_ANNOTATION_TODAY)); + else + if (aDate == Date(Date()-1)) + sRet = sRet + String(SdResId(STR_ANNOTATION_YESTERDAY)); + else + if (aDate.IsValid() ) + sRet = sRet + rLocalData.getDate(aDate); + + Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds ); + if(aTime.GetTime() != 0) + sRet = sRet + rtl::OUString::createFromAscii(" ") + rLocalData.getTime( aTime,false ); + } + return sRet; +} + +// -------------------------------------------------------------------- + +AnnotationManagerImpl::AnnotationManagerImpl( ViewShellBase& rViewShellBase ) +: AnnotationManagerImplBase( m_aMutex ) +, mrBase( rViewShellBase ) +, mpDoc( rViewShellBase.GetDocument() ) +, mbShowAnnotations( true ) +, mnUpdateTagsEvent( 0 ) +{ + SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()); + if( pOptions ) + mbShowAnnotations = pOptions->IsPreviewTransitions() == sal_True; +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::init() +{ + // get current controller and initialize listeners + try + { + addListener(); + mxView = Reference< XDrawView >::query(mrBase.GetController()); + } + catch( Exception& e ) + { + (void)e; + DBG_ERROR( "sd::AnnotationManagerImpl::AnnotationManagerImpl(), Exception caught!" ); + } + + try + { + Reference<XEventBroadcaster> xModel (mrBase.GetDocShell()->GetModel(), UNO_QUERY_THROW ); + Reference<XEventListener> xListener( this ); + xModel->addEventListener( xListener ); + } + catch( Exception& ) + { + } +} + +// -------------------------------------------------------------------- + +// WeakComponentImplHelper1 +void SAL_CALL AnnotationManagerImpl::disposing () +{ + try + { + Reference<XEventBroadcaster> xModel (mrBase.GetDocShell()->GetModel(), UNO_QUERY_THROW ); + Reference<XEventListener> xListener( this ); + xModel->removeEventListener( xListener ); + } + catch( Exception& ) + { + } + + removeListener(); + DisposeTags(); + + if( mnUpdateTagsEvent ) + { + Application::RemoveUserEvent( mnUpdateTagsEvent ); + mnUpdateTagsEvent = 0; + } + + mxView.clear(); + mxCurrentPage.clear(); +} + +// -------------------------------------------------------------------- + +// XEventListener +void SAL_CALL AnnotationManagerImpl::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException) +{ + if( aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationInserted") ) || + aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationRemoved") ) || + aEvent.EventName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OnAnnotationChanged" )) ) + { + UpdateTags(); + } +} + +void SAL_CALL AnnotationManagerImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException) +{ +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq ) +{ + switch( rReq.GetSlot() ) + { + case SID_INSERT_POSTIT: + ExecuteInsertAnnotation( rReq ); + break; + case SID_DELETE_POSTIT: + case SID_DELETEALL_POSTIT: + case SID_DELETEALLBYAUTHOR_POSTIT: + ExecuteDeleteAnnotation( rReq ); + break; + case SID_PREVIOUS_POSTIT: + case SID_NEXT_POSTIT: + SelectNextAnnotation( rReq.GetSlot() == SID_NEXT_POSTIT ); + break; + case SID_REPLYTO_POSTIT: + ExecuteReplyToAnnotation( rReq ); + break; + case SID_SHOW_POSTIT: + { + mbShowAnnotations = !mbShowAnnotations; + + SdOptions* pOptions = SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()); + if( pOptions ) + pOptions->SetShowComments( mbShowAnnotations ? sal_True : sal_False ); + + UpdateTags(); + break; + } + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::ExecuteInsertAnnotation(SfxRequest& /*rReq*/) +{ + InsertAnnotation(); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + + switch( rReq.GetSlot() ) + { + case SID_DELETEALL_POSTIT: + DeleteAllAnnotations(); + break; + case SID_DELETEALLBYAUTHOR_POSTIT: + if( pArgs ) + { + const SfxPoolItem* pPoolItem = NULL; + if( SFX_ITEM_SET == pArgs->GetItemState( SID_DELETE_POSTIT, TRUE, &pPoolItem ) ) + { + OUString sAuthor( (( const SfxStringItem* ) pPoolItem )->GetValue() ); + DeleteAnnotationsByAuthor( sAuthor ); + } + } + break; + case SID_DELETE_POSTIT: + { + Reference< XAnnotation > xAnnotation; + + if( rReq.GetSlot() == SID_DELETE_POSTIT ) + { + if( pArgs ) + { + const SfxPoolItem* pPoolItem = NULL; + if( SFX_ITEM_SET == pArgs->GetItemState( SID_DELETE_POSTIT, TRUE, &pPoolItem ) ) + ( ( const SfxUnoAnyItem* ) pPoolItem )->GetValue() >>= xAnnotation; + } + } + + if( !xAnnotation.is() ) + GetSelectedAnnotation( xAnnotation ); + + DeleteAnnotation( xAnnotation ); + } + break; + } + + UpdateTags(); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::InsertAnnotation() +{ + SdPage* pPage = GetCurrentPage(); + if( pPage ) + { + if( mpDoc->IsUndoEnabled() ) + mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_INSERT ) ) ); + + // find free space for new annotation + int y = 0, x = 0; + + AnnotationVector aAnnotations( pPage->getAnnotations() ); + if( !aAnnotations.empty() ) + { + const int page_width = pPage->GetSize().Width(); + const int width = 1000; + const int height = 800; + Rectangle aTagRect; + + while( true ) + { + Rectangle aNewRect( x, y, x + width - 1, y + height - 1 ); + bool bFree = true; + + for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) + { + RealPoint2D aPoint( (*iter)->getPosition() ); + aTagRect.nLeft = sal::static_int_cast< long >( aPoint.X * 100.0 ); + aTagRect.nTop = sal::static_int_cast< long >( aPoint.Y * 100.0 ); + aTagRect.nRight = aTagRect.nLeft + width - 1; + aTagRect.nBottom = aTagRect.nTop + height - 1; + + if( aNewRect.IsOver( aTagRect ) ) + { + bFree = false; + break; + } + } + + if( bFree == false) + { + x += width; + if( x > page_width ) + { + x = 0; + y += height; + } + } + else + { + break; + } + } + } + + Reference< XAnnotation > xAnnotation; + pPage->createAnnotation( xAnnotation ); + + // set current author to new annotation + SvtUserOptions aUserOptions; + xAnnotation->setAuthor( aUserOptions.GetFullName() ); + + // set current time to new annotation + xAnnotation->setDateTime( getCurrentDateTime() ); + + // set position + RealPoint2D aPos( ((double)x) / 100.0, ((double)y) / 100.0 ); + xAnnotation->setPosition( aPos ); + + if( mpDoc->IsUndoEnabled() ) + mpDoc->EndUndo(); + + UpdateTags(true); + SelectAnnotation( xAnnotation, true ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) +{ + Reference< XAnnotation > xAnnotation; + const SfxItemSet* pArgs = rReq.GetArgs(); + if( pArgs ) + { + const SfxPoolItem* pPoolItem = NULL; + if( SFX_ITEM_SET == pArgs->GetItemState( rReq.GetSlot(), TRUE, &pPoolItem ) ) + ( ( const SfxUnoAnyItem* ) pPoolItem )->GetValue() >>= xAnnotation; + } + + + TextApiObject* pTextApi = getTextApiObject( xAnnotation ); + if( pTextApi ) + { + std::auto_ptr< ::Outliner > pOutliner( new ::Outliner(GetAnnotationPool(),OUTLINERMODE_TEXTOBJECT) ); + + mpDoc->SetCalcFieldValueHdl( pOutliner.get() ); + pOutliner->SetUpdateMode( TRUE ); + + String aStr(SdResId(STR_ANNOTATION_REPLY)); + OUString sAuthor( xAnnotation->getAuthor() ); + if( sAuthor.getLength() == 0 ) + sAuthor = String( SdResId( STR_ANNOTATION_NOAUTHOR ) ); + + aStr.SearchAndReplaceAscii("%1", sAuthor); + + aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM(" (") ) ); + aStr.Append( String( getAnnotationDateTimeString( xAnnotation ) ) ); + aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM("): \"") ) ); + + String sQuote( pTextApi->GetText() ); + + if( sQuote.Len() == 0 ) + sQuote = String( RTL_CONSTASCII_USTRINGPARAM( "..." ) ); + aStr.Append( sQuote ); + aStr.Append( String(RTL_CONSTASCII_USTRINGPARAM("\"\n") ) ); + + USHORT nParaCount = aStr.GetTokenCount( '\n' ); + for( USHORT nPara = 0; nPara < nParaCount; nPara++ ) + pOutliner->Insert( aStr.GetToken( nPara, '\n' ), LIST_APPEND, -1 ); + + if( pOutliner->GetParagraphCount() > 1 ) + { + SfxItemSet aAnswerSet( pOutliner->GetEmptyItemSet() ); + aAnswerSet.Put(SvxPostureItem(ITALIC_NORMAL,EE_CHAR_ITALIC)); + + ESelection aSel; + aSel.nEndPara = (USHORT)pOutliner->GetParagraphCount()-2; + aSel.nEndPos = pOutliner->GetText( pOutliner->GetParagraph( aSel.nEndPara ) ).Len(); + + pOutliner->QuickSetAttribs( aAnswerSet, aSel ); + } + + std::auto_ptr< OutlinerParaObject > pOPO( pOutliner->CreateParaObject() ); + pTextApi->SetText( *pOPO.get() ); + + SvtUserOptions aUserOptions; + xAnnotation->setAuthor( aUserOptions.GetFullName() ); + + // set current time to reply + xAnnotation->setDateTime( getCurrentDateTime() ); + + UpdateTags(true); + SelectAnnotation( xAnnotation, true ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::DeleteAnnotation( Reference< XAnnotation > xAnnotation ) +{ + SdPage* pPage = GetCurrentPage(); + + if( xAnnotation.is() && pPage ) + { + if( mpDoc->IsUndoEnabled() ) + mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); + + pPage->removeAnnotation( xAnnotation ); + + if( mpDoc->IsUndoEnabled() ) + mpDoc->EndUndo(); + + UpdateTags(); + } +} + +void AnnotationManagerImpl::DeleteAnnotationsByAuthor( const rtl::OUString& sAuthor ) +{ + if( mpDoc->IsUndoEnabled() ) + mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); + + SdPage* pPage = 0; + do + { + pPage = GetNextPage( pPage, true ); + + if( pPage && !pPage->getAnnotations().empty() ) + { + AnnotationVector aAnnotations( pPage->getAnnotations() ); + for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) + { + Reference< XAnnotation > xAnnotation( *iter ); + if( xAnnotation->getAuthor() == sAuthor ) + { + if( mxSelectedAnnotation == xAnnotation ) + mxSelectedAnnotation.clear(); + pPage->removeAnnotation( xAnnotation ); + } + } + } + } while( pPage ); + + if( mpDoc->IsUndoEnabled() ) + mpDoc->EndUndo(); +} + +void AnnotationManagerImpl::DeleteAllAnnotations() +{ + if( mpDoc->IsUndoEnabled() ) + mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_DELETE ) ) ); + + SdPage* pPage = 0; + do + { + pPage = GetNextPage( pPage, true ); + + if( pPage && !pPage->getAnnotations().empty() ) + { + + AnnotationVector aAnnotations( pPage->getAnnotations() ); + for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) + { + pPage->removeAnnotation( (*iter) ); + } + } + } + while( pPage ); + + mxSelectedAnnotation.clear(); + + if( mpDoc->IsUndoEnabled() ) + mpDoc->EndUndo(); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet) +{ + SdPage* pCurrentPage = GetCurrentPage(); + + const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly(); + const bool bWrongPageKind = (pCurrentPage == 0) || (pCurrentPage->GetPageKind() != PK_STANDARD); + + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + + if( bReadOnly || bWrongPageKind || (nCurrentODFVersion != SvtSaveOptions::ODFVER_LATEST) ) + rSet.DisableItem( SID_INSERT_POSTIT ); + + rSet.Put(SfxBoolItem(SID_SHOW_POSTIT, mbShowAnnotations)); + + Reference< XAnnotation > xAnnotation; + GetSelectedAnnotation( xAnnotation ); + + if( !xAnnotation.is() || bReadOnly ) + rSet.DisableItem( SID_DELETE_POSTIT ); + + SdPage* pPage = 0; + + bool bHasAnnotations = false; + do + { + pPage = GetNextPage( pPage, true ); + + if( pPage && !pPage->getAnnotations().empty() ) + bHasAnnotations = true; + } + while( pPage && !bHasAnnotations ); + + if( !bHasAnnotations || bReadOnly ) + { + rSet.DisableItem( SID_DELETEALL_POSTIT ); + } + + if( bWrongPageKind || !bHasAnnotations ) + { + rSet.DisableItem( SID_PREVIOUS_POSTIT ); + rSet.DisableItem( SID_NEXT_POSTIT ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::SelectNextAnnotation(bool bForeward) +{ + Reference< XAnnotation > xCurrent; + GetSelectedAnnotation( xCurrent ); + SdPage* pPage = GetCurrentPage(); + if( !pPage ) + return; + + AnnotationVector aAnnotations( pPage->getAnnotations() ); + + if( bForeward ) + { + if( xCurrent.is() ) + { + for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) + { + if( (*iter) == xCurrent ) + { + iter++; + if( iter != aAnnotations.end() ) + { + SelectAnnotation( (*iter) ); + return; + } + break; + } + } + } + else if( !aAnnotations.empty() ) + { + SelectAnnotation( *(aAnnotations.begin()) ); + return; + } + } + else + { + if( xCurrent.is() ) + { + for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); iter++ ) + { + if( (*iter) == xCurrent ) + { + if( iter != aAnnotations.begin() ) + { + iter--; + SelectAnnotation( (*iter) ); + return; + + } + break; + } + } + } + else if( !aAnnotations.empty() ) + { + AnnotationVector::iterator iter( aAnnotations.end() ); + SelectAnnotation( *(--iter) ); + return; + } + } + + mxSelectedAnnotation.clear(); + do + { + do + { + pPage = GetNextPage( pPage, bForeward ); + + if( pPage && !pPage->getAnnotations().empty() ) + { + // switch to next/previous slide with annotations + ::boost::shared_ptr<DrawViewShell> pDrawViewShell(::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell())); + if (pDrawViewShell.get() != NULL) + { + pDrawViewShell->ChangeEditMode(pPage->IsMasterPage() ? EM_MASTERPAGE : EM_PAGE, FALSE); + pDrawViewShell->SwitchPage((pPage->GetPageNum() - 1) >> 1); + + SfxDispatcher* pDispatcher = getDispatcher( mrBase ); + if( pDispatcher ) + pDispatcher->Execute( bForeward ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT ); + + return; + } + } + } + while( pPage ); + + // The question text depends on the search direction. + bool bImpress = mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS; + sal_uInt16 nStringId; + if(bForeward) + nStringId = bImpress ? STR_ANNOTATION_WRAP_FORWARD : STR_ANNOTATION_WRAP_FORWARD_DRAW; + else + nStringId = bImpress ? STR_ANNOTATION_WRAP_BACKWARD : STR_ANNOTATION_WRAP_BACKWARD_DRAW; + + // Pop up question box that asks the user whether to wrap arround. + // The dialog is made modal with respect to the whole application. + QueryBox aQuestionBox ( + NULL, + WB_YES_NO | WB_DEF_YES, + String(SdResId(nStringId))); + aQuestionBox.SetImage (QueryBox::GetStandardImage()); + USHORT nBoxResult = aQuestionBox.Execute(); + if(nBoxResult != BUTTONID_YES) + break; + } + while( true ); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::onTagSelected( AnnotationTag& rTag ) +{ + mxSelectedAnnotation = rTag.GetAnnotation(); + invalidateSlots(); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::onTagDeselected( AnnotationTag& rTag ) +{ + if( rTag.GetAnnotation() == mxSelectedAnnotation ) + { + mxSelectedAnnotation.clear(); + invalidateSlots(); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit /* = FALSE */ ) +{ + mxSelectedAnnotation = xAnnotation; + + for( AnnotationTagVector::iterator iter( maTagVector.begin() ); iter != maTagVector.end(); iter++ ) + { + if( (*iter)->GetAnnotation() == xAnnotation ) + { + SmartTagReference xTag( (*iter).get() ); + mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); + (*iter)->OpenPopup( bEdit ); + break; + } + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) +{ + xAnnotation = mxSelectedAnnotation; +} + +void AnnotationManagerImpl::invalidateSlots() +{ + SfxBindings* pBindings = getBindings( mrBase ); + if( pBindings ) + { + pBindings->Invalidate( SID_INSERT_POSTIT ); + pBindings->Invalidate( SID_DELETE_POSTIT ); + pBindings->Invalidate( SID_DELETEALL_POSTIT ); + pBindings->Invalidate( SID_PREVIOUS_POSTIT ); + pBindings->Invalidate( SID_NEXT_POSTIT ); + pBindings->Invalidate( SID_UNDO ); + pBindings->Invalidate( SID_REDO ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::onSelectionChanged() +{ + if( mxView.is() && mrBase.GetDrawView() ) try + { + Reference< XAnnotationAccess > xPage( mxView->getCurrentPage(), UNO_QUERY ); + + if( xPage != mxCurrentPage ) + { + mxCurrentPage = xPage; + + UpdateTags(true); + } + } + catch( Exception& ) + { + DBG_ERROR( "sd::AnnotationManagerImpl::onSelectionChanged(), exception caught!" ); + } +} + +void AnnotationManagerImpl::UpdateTags( bool bSynchron ) +{ + if( bSynchron ) + { + if( mnUpdateTagsEvent ) + Application::RemoveUserEvent( mnUpdateTagsEvent ); + + UpdateTagsHdl(0); + } + else + { + if( !mnUpdateTagsEvent && mxView.is() ) + mnUpdateTagsEvent = Application::PostUserEvent( LINK( this, AnnotationManagerImpl, UpdateTagsHdl ) ); + } +} + +IMPL_LINK(AnnotationManagerImpl,UpdateTagsHdl, void *, EMPTYARG) +{ + mnUpdateTagsEvent = 0; + DisposeTags(); + + if( mbShowAnnotations ) + CreateTags(); + + if( mrBase.GetDrawView() ) + static_cast< ::sd::View* >( mrBase.GetDrawView() )->updateHandles(); + + invalidateSlots(); + + return 0; +} + +void AnnotationManagerImpl::CreateTags() +{ + + if( mxCurrentPage.is() && mpDoc ) try + { + int nIndex = 1; + maFont = Application::GetSettings().GetStyleSettings().GetAppFont(); + + rtl::Reference< AnnotationTag > xSelectedTag; + + Reference< XAnnotationEnumeration > xEnum( mxCurrentPage->createAnnotationEnumeration() ); + while( xEnum->hasMoreElements() ) + { + Reference< XAnnotation > xAnnotation( xEnum->nextElement() ); + Color aColor( GetColorLight( mpDoc->GetAnnotationAuthorIndex( xAnnotation->getAuthor() ) ) ); + rtl::Reference< AnnotationTag > xTag( new AnnotationTag( *this, *mrBase.GetMainViewShell()->GetView(), xAnnotation, aColor, nIndex++, maFont ) ); + maTagVector.push_back(xTag); + + if( xAnnotation == mxSelectedAnnotation ) + { + xSelectedTag = xTag; + } + } + + if( xSelectedTag.is() ) + { + SmartTagReference xTag( xSelectedTag.get() ); + mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); + } + else + { + // no tag, no selection! + mxSelectedAnnotation.clear(); + } + } + catch( Exception& ) + { + DBG_ERROR( "sd::AnnotationManagerImpl::onSelectionChanged(), exception caught!" ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::DisposeTags() +{ + if( !maTagVector.empty() ) + { + AnnotationTagVector::iterator iter = maTagVector.begin(); + do + { + (*iter++)->Dispose(); + } + while( iter != maTagVector.end() ); + + maTagVector.clear(); + } +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::addListener() +{ + Link aLink( LINK(this,AnnotationManagerImpl,EventMultiplexerListener) ); + mrBase.GetEventMultiplexer()->AddEventListener ( + aLink, + tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION + | tools::EventMultiplexerEvent::EID_CURRENT_PAGE + | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED + | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED); +} + +// -------------------------------------------------------------------- + +void AnnotationManagerImpl::removeListener() +{ + Link aLink( LINK(this,AnnotationManagerImpl,EventMultiplexerListener) ); + mrBase.GetEventMultiplexer()->RemoveEventListener( aLink ); +} + +// -------------------------------------------------------------------- + +IMPL_LINK(AnnotationManagerImpl,EventMultiplexerListener, + tools::EventMultiplexerEvent*,pEvent) +{ + switch (pEvent->meEventId) + { + case tools::EventMultiplexerEvent::EID_CURRENT_PAGE: + case tools::EventMultiplexerEvent::EID_EDIT_VIEW_SELECTION: + onSelectionChanged(); + break; + + case tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: + mxView = Reference<XDrawView>(); + onSelectionChanged(); + break; + + case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: + mxView = Reference<XDrawView>::query( mrBase.GetController() ); + onSelectionChanged(); + break; + } + return 0; +} + +OUString AnnotationManagerImpl::GetHelpText( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) +{ + OUString sRet; + if( xAnnotation.is() ) + { + OUString sAuthor( xAnnotation->getAuthor() ); + if( sAuthor.getLength() != 0 ) + { + sRet += sAuthor; + } + sRet += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); + + sRet += getAnnotationDateTimeString( xAnnotation ); + sRet += OUString( RTL_CONSTASCII_USTRINGPARAM( "]\n" ) ); + + Reference< XText > xText( xAnnotation->getTextRange() ); + if( xText.is() ) + sRet += xText->getString(); + } + + return sRet; +} + + +void AnnotationManagerImpl::ExecuteAnnotationContextMenu( Reference< XAnnotation > xAnnotation, ::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu /* = false */ ) +{ + SfxDispatcher* pDispatcher( getDispatcher( mrBase ) ); + if( !pDispatcher ) + return; + + const bool bReadOnly = mrBase.GetDocShell()->IsReadOnly(); + + AnnotationWindow* pAnnotationWindow = bButtonMenu ? 0 : dynamic_cast< AnnotationWindow* >( pParent ); + + if( bReadOnly && !pAnnotationWindow ) + return; + + std::auto_ptr< PopupMenu > pMenu( new PopupMenu( SdResId( pAnnotationWindow ? RID_ANNOTATION_CONTEXTMENU : RID_ANNOTATION_TAG_CONTEXTMENU ) ) ); + + SvtUserOptions aUserOptions; + OUString sCurrentAuthor( aUserOptions.GetFullName() ); + OUString sAuthor( xAnnotation->getAuthor() ); + + String aStr( pMenu->GetItemText( SID_DELETEALLBYAUTHOR_POSTIT ) ), aReplace( sAuthor ); + if( aReplace.Len() == 0 ) + aReplace = String( SdResId( STR_ANNOTATION_NOAUTHOR ) ); + aStr.SearchAndReplaceAscii("%1", aReplace); + pMenu->SetItemText( SID_DELETEALLBYAUTHOR_POSTIT, aStr ); + pMenu->EnableItem( SID_REPLYTO_POSTIT, (sAuthor != sCurrentAuthor) && !bReadOnly ); + pMenu->EnableItem( SID_DELETE_POSTIT, (xAnnotation.is() && !bReadOnly) ? TRUE : FALSE ); + pMenu->EnableItem( SID_DELETEALLBYAUTHOR_POSTIT, !bReadOnly ); + pMenu->EnableItem( SID_DELETEALL_POSTIT, !bReadOnly ); + + if( pAnnotationWindow ) + { + if( pAnnotationWindow->IsProtected() || bReadOnly ) + { + pMenu->EnableItem( SID_ATTR_CHAR_WEIGHT, FALSE ); + pMenu->EnableItem( SID_ATTR_CHAR_POSTURE, FALSE ); + pMenu->EnableItem( SID_ATTR_CHAR_UNDERLINE, FALSE ); + pMenu->EnableItem( SID_ATTR_CHAR_STRIKEOUT, FALSE ); + pMenu->EnableItem( SID_PASTE, FALSE ); + } + else + { + SfxItemSet aSet(pAnnotationWindow->getView()->GetAttribs()); + + if ( aSet.GetItemState( EE_CHAR_WEIGHT ) == SFX_ITEM_ON ) + { + if( ((const SvxWeightItem&)aSet.Get( EE_CHAR_WEIGHT )).GetWeight() == WEIGHT_BOLD ) + pMenu->CheckItem( SID_ATTR_CHAR_WEIGHT ); + } + + if ( aSet.GetItemState( EE_CHAR_ITALIC ) == SFX_ITEM_ON ) + { + if( ((const SvxPostureItem&)aSet.Get( EE_CHAR_ITALIC )).GetPosture() != ITALIC_NONE ) + pMenu->CheckItem( SID_ATTR_CHAR_POSTURE ); + + } + if ( aSet.GetItemState( EE_CHAR_UNDERLINE ) == SFX_ITEM_ON ) + { + if( ((const SvxUnderlineItem&)aSet.Get( EE_CHAR_UNDERLINE )).GetLineStyle() != UNDERLINE_NONE ) + pMenu->CheckItem( SID_ATTR_CHAR_UNDERLINE ); + } + + if ( aSet.GetItemState( EE_CHAR_STRIKEOUT ) == SFX_ITEM_ON ) + { + if( ((const SvxCrossedOutItem&)aSet.Get( EE_CHAR_STRIKEOUT )).GetStrikeout() != STRIKEOUT_NONE ) + pMenu->CheckItem( SID_ATTR_CHAR_STRIKEOUT ); + } + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pAnnotationWindow ) ); + pMenu->EnableItem( SID_PASTE, aDataHelper.GetFormatCount() != 0 ); + } + + pMenu->EnableItem( SID_COPY, pAnnotationWindow->getView()->HasSelection() ); + } + + USHORT nId = 0; + + // set slot images + Reference< ::com::sun::star::frame::XFrame > xFrame( mrBase.GetMainViewShell()->GetViewFrame()->GetFrame()->GetFrameInterface() ); + if( xFrame.is() ) + { + const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); + for( USHORT nPos = 0; nPos < pMenu->GetItemCount(); nPos++ ) + { + nId = pMenu->GetItemId( nPos ); + if( pMenu->IsItemEnabled( nId ) ) + { + OUString sSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); + sSlotURL += OUString::valueOf( sal_Int32( nId )); + + Image aImage( GetImage( xFrame, sSlotURL, false, bHighContrast ) ); + if( !!aImage ) + pMenu->SetItemImage( nId, aImage ); + } + } + } + + nId = pMenu->Execute( pParent, rContextRect, POPUPMENU_EXECUTE_DOWN ); + switch( nId ) + { + case SID_REPLYTO_POSTIT: + { + const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( xAnnotation ) ); + pDispatcher->Execute( SID_REPLYTO_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); + break; + } + case SID_DELETE_POSTIT: + { + const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( xAnnotation ) ); + pDispatcher->Execute( SID_DELETE_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); + break; + } + case SID_DELETEALLBYAUTHOR_POSTIT: + { + const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, sAuthor ); + pDispatcher->Execute( SID_DELETEALLBYAUTHOR_POSTIT, SFX_CALLMODE_ASYNCHRON, &aItem, 0 ); + break; + } + case SID_DELETEALL_POSTIT: + pDispatcher->Execute( SID_DELETEALL_POSTIT ); + break; + case SID_COPY: + case SID_PASTE: + case SID_ATTR_CHAR_WEIGHT: + case SID_ATTR_CHAR_POSTURE: + case SID_ATTR_CHAR_UNDERLINE: + case SID_ATTR_CHAR_STRIKEOUT: + if( pAnnotationWindow ) + pAnnotationWindow->ExecuteSlot( nId ); + break; + } +} + +// ==================================================================== + +Color AnnotationManagerImpl::GetColor(sal_uInt16 aAuthorIndex) +{ + if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + static const Color aArrayNormal[] = { + COL_AUTHOR1_NORMAL, COL_AUTHOR2_NORMAL, COL_AUTHOR3_NORMAL, + COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL, + COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL }; + + return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]); + } + else + return Color(COL_WHITE); +} + +Color AnnotationManagerImpl::GetColorLight(sal_uInt16 aAuthorIndex) +{ + if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + static const Color aArrayLight[] = { + COL_AUTHOR1_LIGHT, COL_AUTHOR2_LIGHT, COL_AUTHOR3_LIGHT, + COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT, + COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT }; + + return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]); + } + else + return Color(COL_WHITE); +} + +Color AnnotationManagerImpl::GetColorDark(sal_uInt16 aAuthorIndex) +{ + if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + static const Color aArrayAnkor[] = { + COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK, + COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, + COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; + + return Color( aArrayAnkor[ aAuthorIndex % (sizeof( aArrayAnkor ) / sizeof( aArrayAnkor[0] ))]); + } + else + return Color(COL_WHITE); +} + +SdPage* AnnotationManagerImpl::GetNextPage( SdPage* pPage, bool bForeward ) +{ + if( pPage == 0 ) + return bForeward ? GetFirstPage() : GetLastPage(); + + sal_uInt16 nPageNum = (pPage->GetPageNum() - 1) >> 1; + + // first all non master pages + if( !pPage->IsMasterPage() ) + { + if( bForeward ) + { + if( nPageNum >= mpDoc->GetSdPageCount(PK_STANDARD)-1 ) + { + // we reached end of draw pages, start with master pages (skip handout master for draw) + return mpDoc->GetMasterSdPage( (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? 0 : 1, PK_STANDARD ); + } + nPageNum++; + } + else + { + if( nPageNum == 0 ) + return 0; // we are already on the first draw page, finished + + nPageNum--; + } + return mpDoc->GetSdPage(nPageNum, PK_STANDARD); + } + else + { + if( bForeward ) + { + if( nPageNum >= mpDoc->GetMasterSdPageCount(PK_STANDARD)-1 ) + { + return 0; // we reached the end, there is nothing more to see here + } + nPageNum++; + } + else + { + if( nPageNum == (mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? 0 : 1 ) + { + // we reached beginning of master pages, start with end if pages + return mpDoc->GetSdPage( mpDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD ); + } + + nPageNum--; + } + return static_cast< SdPage* >( mpDoc->GetMasterPage(nPageNum) ); + } +} + +SdPage* AnnotationManagerImpl::GetFirstPage() +{ + // return first drawing page + return mpDoc->GetSdPage(0, PK_STANDARD ); +} + +SdPage* AnnotationManagerImpl::GetLastPage() +{ + return mpDoc->GetMasterSdPage( mpDoc->GetMasterSdPageCount(PK_STANDARD) - 1, PK_STANDARD ); +} + +SdPage* AnnotationManagerImpl::GetCurrentPage() +{ +/* + ::boost::shared_ptr<DrawViewShell> pDrawViewShell(::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell())); + if (pDrawViewShell.get() != NULL) + return pDrawViewShell->GetActualPage(); +*/ + return mrBase.GetMainViewShell()->getCurrentPage(); +} + +// ==================================================================== + +AnnotationManager::AnnotationManager( ViewShellBase& rViewShellBase ) +: mxImpl( new AnnotationManagerImpl( rViewShellBase ) ) +{ + mxImpl->init(); +} + +AnnotationManager::~AnnotationManager() +{ + mxImpl->dispose(); +} + +void AnnotationManager::ExecuteAnnotation(SfxRequest& rRequest) +{ + mxImpl->ExecuteAnnotation( rRequest ); +} + +void AnnotationManager::GetAnnotationState(SfxItemSet& rItemSet) +{ + mxImpl->GetAnnotationState(rItemSet); +} + +} diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx new file mode 100644 index 000000000..8b9e1069a --- /dev/null +++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AnnotationPanel.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SD_ANNOTATIONMANAGER_IMPL_HXX +#define _SD_ANNOTATIONMANAGER_IMPL_HXX + +#include <com/sun/star/document/XEventListener.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> + +#include <rtl/ustring.hxx> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase1.hxx> + +#include "ViewShellBase.hxx" + +#include "annotationtag.hxx" + +class SfxRequest; + +namespace sd +{ + +typedef std::vector< rtl::Reference< AnnotationTag > > AnnotationTagVector; + +namespace tools { +class EventMultiplexerEvent; +} + +typedef ::cppu::WeakComponentImplHelper1 < + com::sun::star::document::XEventListener + > AnnotationManagerImplBase; + +class AnnotationManagerImpl : private ::cppu::BaseMutex, public AnnotationManagerImplBase +{ +public: + AnnotationManagerImpl( ViewShellBase& rViewShellBase ); + + void init(); + + // WeakComponentImplHelper1 + virtual void SAL_CALL disposing (); + + // XEventListener + virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + // + void ExecuteAnnotation (SfxRequest& rRequest); + void GetAnnotationState (SfxItemSet& rItemSet); + + void ExecuteInsertAnnotation(SfxRequest& rReq); + void ExecuteDeleteAnnotation(SfxRequest& rReq); + void ExecuteReplyToAnnotation(SfxRequest& rReq); + + void SelectNextAnnotation(bool bForeward); + + void SelectAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, bool bEdit = FALSE ); + void GetSelectedAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ); + + void InsertAnnotation(); + void DeleteAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation ); + void DeleteAnnotationsByAuthor( const rtl::OUString& sAuthor ); + void DeleteAllAnnotations(); + + void ExecuteAnnotationContextMenu( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > xAnnotation, ::Window* pParent, const Rectangle& rContextRect, bool bButtonMenu = false ); + + Color GetColorDark(sal_uInt16 aAuthorIndex); + Color GetColorLight(sal_uInt16 aAuthorIndex); + Color GetColor(sal_uInt16 aAuthorIndex); + + + // callbacks + void onTagSelected( AnnotationTag& rTag ); + void onTagDeselected( AnnotationTag& rTag ); + + void onSelectionChanged(); + + rtl::OUString GetHelpText( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ); + + void addListener(); + void removeListener(); + + void invalidateSlots(); + + DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent*); + DECL_LINK(UpdateTagsHdl, void *); + + void UpdateTags(bool bSynchron = false); + void CreateTags(); + void DisposeTags(); + + SdPage* GetNextPage( SdPage* pPage, bool bForeward ); + SdPage* GetFirstPage(); + SdPage* GetLastPage(); + + SdPage* GetCurrentPage(); + + SdDrawDocument* GetDoc() { return mpDoc; } +private: + ViewShellBase& mrBase; + SdDrawDocument* mpDoc; + + AnnotationTagVector maTagVector; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawView > mxView; + ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationAccess > mxCurrentPage; + ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxSelectedAnnotation; + + bool mbShowAnnotations; + ULONG mnUpdateTagsEvent; + Font maFont; +}; + +} + +#endif // _SD_ANNOTATIONMANAGER_IMPL_HXX diff --git a/sd/source/ui/annotations/annotations.hrc b/sd/source/ui/annotations/annotations.hrc new file mode 100644 index 000000000..d0c69f43e --- /dev/null +++ b/sd/source/ui/annotations/annotations.hrc @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TableDesignPane.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SD_ANNOTATIONPANE_HRC +#define _SD_ANNOTATIONPANE_HRC + +#include "glob.hrc" + +// strings +#define STR_ANNOTATION_TODAY (RID_ANNOTATIONS_START+1) +#define STR_ANNOTATION_YESTERDAY (RID_ANNOTATIONS_START+2) +#define STR_ANNOTATION_NOAUTHOR (RID_ANNOTATIONS_START+3) +#define STR_ANNOTATION_WRAP_FORWARD (RID_ANNOTATIONS_START+4) +#define STR_ANNOTATION_WRAP_BACKWARD (RID_ANNOTATIONS_START+5) +#define STR_ANNOTATION_WRAP_FORWARD_DRAW (RID_ANNOTATIONS_START+6) +#define STR_ANNOTATION_WRAP_BACKWARD_DRAW (RID_ANNOTATIONS_START+7) +#define STR_ANNOTATION_UNDO_INSERT (RID_ANNOTATIONS_START+8) +#define STR_ANNOTATION_UNDO_DELETE (RID_ANNOTATIONS_START+9) +#define STR_ANNOTATION_UNDO_MOVE (RID_ANNOTATIONS_START+10) +#define STR_ANNOTATION_UNDO_EDIT (RID_ANNOTATIONS_START+11) +#define STR_ANNOTATION_UNDO_REPLY (RID_ANNOTATIONS_START+12) +#define STR_ANNOTATION_REPLY (RID_ANNOTATIONS_START+13) + +// menus +#define RID_ANNOTATION_CONTEXTMENU (RID_ANNOTATIONS_START+0) +#define RID_ANNOTATION_TAG_CONTEXTMENU (RID_ANNOTATIONS_START+1) + +#define BTN_NEW 1 +#define BTN_DELETE 2 +#define BTN_NEXT 3 +#define BTN_PREV 4 + +#define TBX_TOOLBAR 1 +#define FT_AUTHOR 1 +#define ED_AUTHOR 2 +#define FT_DATE 3 +#define ED_DATE 4 + +#define CT_TEXT 5 + +#endif // _SD_ANNOTATIONPANE_HRC diff --git a/sd/source/ui/annotations/annotations.src b/sd/source/ui/annotations/annotations.src new file mode 100644 index 000000000..f90446239 --- /dev/null +++ b/sd/source/ui/annotations/annotations.src @@ -0,0 +1,212 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "annotations.hrc" +#include "glob.hrc" +#include <svx/svxids.hrc> + +Menu RID_ANNOTATION_CONTEXTMENU +{ + ItemList = + { + MenuItem + { + Identifier = SID_REPLYTO_POSTIT; + HelpID = SID_REPLYTO_POSTIT ; + Text [ en-US ] = "~Reply"; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_ATTR_CHAR_WEIGHT; + HelpID = SID_ATTR_CHAR_WEIGHT ; + Text [ en-US ] = "~Bold"; + }; + MenuItem + { + Identifier = SID_ATTR_CHAR_POSTURE; + HelpID = SID_ATTR_CHAR_POSTURE; + Text [ en-US ] = "~Italic"; + }; + MenuItem + { + Identifier = SID_ATTR_CHAR_UNDERLINE; + HelpID = SID_ATTR_CHAR_UNDERLINE; + Text [ en-US ] = "~Underline"; + }; + MenuItem + { + Identifier = SID_ATTR_CHAR_STRIKEOUT; + HelpID = SID_ATTR_CHAR_STRIKEOUT; + Text [ en-US ] = "~Strikethrough"; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_COPY ; + HelpID = SID_COPY ; + Text [ en-US ] = "~Copy" ; + }; + MenuItem + { + Identifier = SID_PASTE ; + HelpID = SID_PASTE ; + Text [ en-US ] = "~Paste" ; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_DELETE_POSTIT ; + HelpID = SID_DELETE_POSTIT; + Text [ en-US ] = "~Delete Comment" ; + }; + MenuItem + { + Identifier = SID_DELETEALLBYAUTHOR_POSTIT ; + HelpID = SID_DELETEALLBYAUTHOR_POSTIT; + Text [ en-US ] = "Delete All Comments b~y %1" ; + }; + MenuItem + { + Identifier = SID_DELETEALL_POSTIT; + HelpID = SID_DELETEALL_POSTIT; + Text [ en-US ] = "Delete ~All Comments" ; + }; + }; +}; + +Menu RID_ANNOTATION_TAG_CONTEXTMENU +{ + ItemList = + { + MenuItem + { + Identifier = SID_REPLYTO_POSTIT; + HelpID = SID_REPLYTO_POSTIT; + Text [ en-US ] = "~Reply"; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + Identifier = SID_DELETE_POSTIT ; + HelpID = SID_DELETE_POSTIT ; + Text [ en-US ] = "~Delete Comment" ; + }; + MenuItem + { + Identifier = SID_DELETEALLBYAUTHOR_POSTIT ; + HelpID = SID_DELETEALLBYAUTHOR_POSTIT ; + Text [ en-US ] = "Delete All Comments ~by %1" ; + }; + MenuItem + { + Identifier = SID_DELETEALL_POSTIT; + HelpID = SID_DELETEALL_POSTIT; + Text [ en-US ] = "Delete ~All Comments" ; + }; + }; +}; + +String STR_ANNOTATION_TODAY +{ + Text [ en-US ] = "Today," ; +}; + +String STR_ANNOTATION_YESTERDAY +{ + Text [ en-US ] = "Yesterday," ; +}; + +String STR_ANNOTATION_NOAUTHOR +{ + Text [ en-US ] = "(no author)" ; +}; + +String STR_ANNOTATION_WRAP_FORWARD +{ + Text [ en-US ] = "%PRODUCTNAME Impress reached the end of the presentation. Do you want to continue at the beginning?"; +}; + +String STR_ANNOTATION_WRAP_BACKWARD +{ + Text [ en-US ] = "%PRODUCTNAME Impress reached the beginning of the presentation. Do you want to continue at the end?"; +}; + +String STR_ANNOTATION_WRAP_FORWARD_DRAW +{ + Text [ en-US ] = "%PRODUCTNAME Draw reached the end of the document. Do you want to continue at the beginning?"; +}; + +String STR_ANNOTATION_WRAP_BACKWARD_DRAW +{ + Text [ en-US ] = "%PRODUCTNAME Draw reached the beginning of the document. Do you want to continue at the end?"; +}; + +String STR_ANNOTATION_UNDO_INSERT +{ + Text [ en-US ] = "Insert Comment"; +}; + +String STR_ANNOTATION_UNDO_DELETE +{ + Text [ en-US ] = "Delete Comment(s)"; +}; + +String STR_ANNOTATION_UNDO_MOVE +{ + Text [ en-US ] = "Move Comment"; +}; + +String STR_ANNOTATION_UNDO_EDIT +{ + Text [ en-US ] = "Edit Comment"; +}; + +String STR_ANNOTATION_UNDO_REPLY +{ + Text [ en-US ] = "Reply to Comment"; +}; + +String STR_ANNOTATION_REPLY +{ + Text [ en-US ] = "Reply to %1" ; +}; diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx new file mode 100644 index 000000000..6c2ec6abc --- /dev/null +++ b/sd/source/ui/annotations/annotationtag.cxx @@ -0,0 +1,792 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: motionpathtag.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include <com/sun/star/util/XChangesNotifier.hpp> + +#include <vcl/help.hxx> +#include <vcl/svapp.hxx> + +#include <sfx2/viewfrm.hxx> +#include <sfx2/dispatch.hxx> + +#include <svx/sdr/overlay/overlaymanager.hxx> +#include <svx/sdr/overlay/overlayanimatedbitmapex.hxx> +#include <svx/sdr/overlay/overlaybitmapex.hxx> +#include <svx/svdpagv.hxx> +#include <svx/sdrpagewindow.hxx> +#include <svx/sdrpaintwindow.hxx> +#include <svx/svddrgmt.hxx> + +#include "View.hxx" +#include "sdresid.hxx" +#include "annotations.hrc" +#include "annotationmanagerimpl.hxx" +#include "annotationwindow.hxx" +#include "annotationtag.hxx" +#include "sdpage.hxx" +#include "ViewShell.hxx" +#include "app.hrc" +#include "Window.hxx" +#include "drawdoc.hxx" + +using ::rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +//using namespace ::com::sun::star::util; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::office; +using namespace ::com::sun::star::geometry; + +namespace sd +{ + +const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32; +static const int DRGPIX = 2; // Drag MinMove in Pixel + +// -------------------------------------------------------------------- + +static OUString getInitials( const OUString& rName ) +{ + OUString sInitials; + + const sal_Unicode * pStr = rName.getStr(); + sal_Int32 nLength = rName.getLength(); + + while( nLength ) + { + // skip whitespace + while( nLength && (*pStr <= ' ') ) + { + nLength--; pStr++; + } + + // take letter + if( nLength ) + { + sInitials += OUString( *pStr ); + nLength--; pStr++; + } + + // skip letters until whitespace + while( nLength && (*pStr > ' ') ) + { + nLength--; pStr++; + } + } + + return sInitials; +} + +// -------------------------------------------------------------------- + +// -------------------------------------------------------------------- + +class AnnotationDragMove : public SdrDragMove +{ +public: + AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag); + virtual bool BeginSdrDrag(); + virtual bool EndSdrDrag(bool bCopy); + virtual void MoveSdrDrag(const Point& rNoSnapPnt); + virtual void CancelSdrDrag(); + +private: + rtl::Reference <AnnotationTag > mxTag; + Point maOrigin; +}; + +AnnotationDragMove::AnnotationDragMove(SdrDragView& rNewView, const rtl::Reference <AnnotationTag >& xTag) +: SdrDragMove(rNewView) +, mxTag( xTag ) +{ +} + +bool AnnotationDragMove::BeginSdrDrag() +{ + DragStat().Ref1()=GetDragHdl()->GetPos(); + DragStat().SetShown(!DragStat().IsShown()); + + maOrigin = GetDragHdl()->GetPos(); + DragStat().SetActionRect(Rectangle(maOrigin,maOrigin)); + + return true; +} + +void AnnotationDragMove::MoveSdrDrag(const Point& rNoSnapPnt) +{ + Point aPnt(rNoSnapPnt); + + if (DragStat().CheckMinMoved(rNoSnapPnt)) + { + if (aPnt!=DragStat().GetNow()) + { + Hide(); + DragStat().NextMove(aPnt); + GetDragHdl()->SetPos( maOrigin + Point( DragStat().GetDX(), DragStat().GetDY() ) ); + Show(); + DragStat().SetActionRect(Rectangle(aPnt,aPnt)); + } + } +} + +bool AnnotationDragMove::EndSdrDrag(bool /*bCopy*/) +{ + Hide(); + if( mxTag.is() ) + mxTag->Move( DragStat().GetDX(), DragStat().GetDY() ); + return TRUE; +} + +void AnnotationDragMove::CancelSdrDrag() +{ + Hide(); +} + +// -------------------------------------------------------------------- + +class AnnotationHdl : public SmartHdl +{ +public: + AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt ); + virtual ~AnnotationHdl(); + virtual void CreateB2dIAObject(); + virtual BOOL IsFocusHdl() const; + virtual Pointer GetSdrDragPointer() const; + virtual bool isMarkable() const; + + +private: + Reference< XAnnotation > mxAnnotation; + rtl::Reference< AnnotationTag > mxTag; +}; + +// -------------------------------------------------------------------- + +AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt ) +: SmartHdl( xTag, rPnt ) +, mxAnnotation( xAnnotation ) +, mxTag( dynamic_cast< AnnotationTag* >( xTag.get() ) ) +{ +} + +// -------------------------------------------------------------------- + +AnnotationHdl::~AnnotationHdl() +{ +} + +// -------------------------------------------------------------------- + +void AnnotationHdl::CreateB2dIAObject() +{ + // first throw away old one + GetRidOfIAObject(); + + if( mxAnnotation.is() ) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + const Point aTagPos( GetPos() ); + basegfx::B2DPoint aPosition( aTagPos.X(), aTagPos.Y() ); + + const bool bFocused = IsFocusHdl() && pHdlList && (pHdlList->GetFocusHdl() == this); + + BitmapEx aBitmapEx( mxTag->CreateAnnotationBitmap(mxTag->isSelected()) ); + BitmapEx aBitmapEx2; + if( bFocused ) + aBitmapEx2 = mxTag->CreateAnnotationBitmap(!mxTag->isSelected() ); + + if(pHdlList) + { + SdrMarkView* pView = pHdlList->GetView(); + + if(pView && !pView->areMarkHandlesHidden()) + { + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(pPageView) + { + for(sal_uInt32 b = 0; b < pPageView->PageWindowCount(); b++) + { + // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b]; + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + + SdrPaintWindow& rPaintWindow = rPageWindow.GetPaintWindow(); + if(rPaintWindow.OutputToWindow() && rPageWindow.GetOverlayManager() ) + { + ::sdr::overlay::OverlayObject* pOverlayObject = 0; + + // animate focused handles + if(bFocused) + { + const sal_uInt32 nBlinkTime = sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime()); + + pOverlayObject = new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition, aBitmapEx, aBitmapEx2, nBlinkTime, 0, 0, 0, 0 ); +/* + (UINT16)(aBitmapEx.GetSizePixel().Width() - 1) >> 1, + (UINT16)(aBitmapEx.GetSizePixel().Height() - 1) >> 1, + (UINT16)(aBitmapEx2.GetSizePixel().Width() - 1) >> 1, + (UINT16)(aBitmapEx2.GetSizePixel().Height() - 1) >> 1); +*/ + } + else + { + pOverlayObject = new ::sdr::overlay::OverlayBitmapEx( aPosition, aBitmapEx, 0, 0 ); + } + + rPageWindow.GetOverlayManager()->add(*pOverlayObject); + maOverlayGroup.append(*pOverlayObject); + } + } + } + } + } + } +} + +// -------------------------------------------------------------------- + +BOOL AnnotationHdl::IsFocusHdl() const +{ + return TRUE; +} + +// -------------------------------------------------------------------- + +bool AnnotationHdl::isMarkable() const +{ + return false; +} + +// -------------------------------------------------------------------- + +Pointer AnnotationHdl::GetSdrDragPointer() const +{ + PointerStyle eStyle = POINTER_NOTALLOWED; + if( mxTag.is() ) + { + if( mxTag->isSelected() ) + { + eStyle = POINTER_MOVE; + } + else + { + eStyle = POINTER_ARROW; + + } + } + return Pointer( eStyle ); +} + +// ==================================================================== + +AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const Reference< XAnnotation >& xAnnotation, Color& rColor, int nIndex, const Font& rFont ) +: SmartTag( rView ) +, mrManager( rManager ) +, mxAnnotation( xAnnotation ) +, maColor( rColor ) +, mnIndex( nIndex ) +, mrFont( rFont ) +, mnClosePopupEvent( 0 ) +, mpListenWindow( 0 ) +{ +} + +// -------------------------------------------------------------------- + +AnnotationTag::~AnnotationTag() +{ + DBG_ASSERT( !mxAnnotation.is(), "sd::AnnotationTag::~AnnotationTag(), dispose me first!" ); + Dispose(); +} + +// -------------------------------------------------------------------- + +/** returns true if the AnnotationTag handled the event. */ +bool AnnotationTag::MouseButtonDown( const MouseEvent& rMEvt, SmartHdl& /*rHdl*/ ) +{ + if( !mxAnnotation.is() ) + return false; + + bool bRet = false; + if( !isSelected() ) + { + SmartTagReference xTag( this ); + mrView.getSmartTags().select( xTag ); + bRet = true; + } + /* + if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) ) + { + // double click; + return true; + } + else */ + if( rMEvt.IsLeft() && !rMEvt.IsRight() ) + { + Window* pWindow = mrView.GetViewShell()->GetActiveWindow(); + if( pWindow ) + { + maMouseDownPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + + if( mpListenWindow ) + mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + + mpListenWindow = pWindow; + mpListenWindow->AddEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + } + + bRet = true; + } + + return bRet; +} + +// -------------------------------------------------------------------- + +/** returns true if the SmartTag consumes this event. */ +bool AnnotationTag::KeyInput( const KeyEvent& rKEvt ) +{ + if( !mxAnnotation.is() ) + return false; + + USHORT nCode = rKEvt.GetKeyCode().GetCode(); + switch( nCode ) + { + case KEY_DELETE: + mrManager.DeleteAnnotation( mxAnnotation ); + return true; + + case KEY_DOWN: + case KEY_UP: + case KEY_LEFT: + case KEY_RIGHT: + return OnMove( rKEvt ); + + case KEY_ESCAPE: + { + SmartTagReference xThis( this ); + mrView.getSmartTags().deselect(); + return true; + } + + case KEY_TAB: + mrManager.SelectNextAnnotation(!rKEvt.GetKeyCode().IsShift()); + return true; + + case KEY_RETURN: + case KEY_SPACE: + OpenPopup( true ); + return true; + + default: + return false; + } +} + +/** returns true if the SmartTag consumes this event. */ +bool AnnotationTag::RequestHelp( const HelpEvent& /*rHEvt*/ ) +{ +/* + ::Window* pWindow = mrView.GetViewShell()->GetActiveWindow(); + if( mxAnnotation.is() && pWindow ) + { + OUString aHelpText( mrManager.GetHelpText( mxAnnotation ) ); + + RealPoint2D aPosition( mxAnnotation->getPosition() ); + Point aPos( pWindow->LogicToPixel( Point( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ) ) ); + + Rectangle aRect( aPos, maSize ); + + if (Help::IsBalloonHelpEnabled()) + Help::ShowBalloon( pWindow, aPos, aRect, aHelpText); + else if (Help::IsQuickHelpEnabled()) + Help::ShowQuickHelp( pWindow, aRect, aHelpText); + + return true; + } +*/ + return false; +} + +/** returns true if the SmartTag consumes this event. */ +bool AnnotationTag::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) + { + ::Window* pWindow = mrView.GetViewShell()->GetActiveWindow(); + if( pWindow ) + { + Rectangle aContextRect(rCEvt.GetMousePosPixel(),Size(1,1)); + mrManager.ExecuteAnnotationContextMenu( mxAnnotation, pWindow, aContextRect ); + return true; + } + } + + return false; +} + +void AnnotationTag::Move( int nDX, int nDY ) +{ + if( mxAnnotation.is() ) + { + if( mrManager.GetDoc()->IsUndoEnabled() ) + mrManager.GetDoc()->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_MOVE ) ) ); + + RealPoint2D aPosition( mxAnnotation->getPosition() ); + aPosition.X += (double)nDX / 100.0; + aPosition.Y += (double)nDY / 100.0; + mxAnnotation->setPosition( aPosition ); + + if( mrManager.GetDoc()->IsUndoEnabled() ) + mrManager.GetDoc()->EndUndo(); + + mrView.updateHandles(); + } +} + +bool AnnotationTag::OnMove( const KeyEvent& rKEvt ) +{ + long nX = 0; + long nY = 0; + + switch( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_UP: nY = -1; break; + case KEY_DOWN: nY = 1; break; + case KEY_LEFT: nX = -1; break; + case KEY_RIGHT: nX = 1; break; + default: break; + } + + if(rKEvt.GetKeyCode().IsMod2()) + { + OutputDevice* pOut = mrView.GetViewShell()->GetActiveWindow(); + Size aLogicSizeOnePixel = (pOut) ? pOut->PixelToLogic(Size(1,1)) : Size(100, 100); + nX *= aLogicSizeOnePixel.Width(); + nY *= aLogicSizeOnePixel.Height(); + } + else + { + // old, fixed move distance + nX *= 100; + nY *= 100; + } + + if( nX || nY ) + { + // move the annotation + Move( nX, nY ); + } + + return true; +} + +// -------------------------------------------------------------------- + +void AnnotationTag::CheckPossibilities() +{ +} + +// -------------------------------------------------------------------- + +ULONG AnnotationTag::GetMarkablePointCount() const +{ + return 0; +} + +// -------------------------------------------------------------------- + +ULONG AnnotationTag::GetMarkedPointCount() const +{ + return 0; +} + +// -------------------------------------------------------------------- + +BOOL AnnotationTag::MarkPoint(SdrHdl& /*rHdl*/, BOOL /*bUnmark*/ ) +{ + BOOL bRet=FALSE; + return bRet; +} + +// -------------------------------------------------------------------- + +BOOL AnnotationTag::MarkPoints(const Rectangle* /*pRect*/, BOOL /*bUnmark*/ ) +{ + BOOL bChgd=FALSE; + return bChgd; +} + +// -------------------------------------------------------------------- + +bool AnnotationTag::getContext( SdrViewContext& /*rContext*/ ) +{ + return false; +} + +// -------------------------------------------------------------------- + +void AnnotationTag::addCustomHandles( SdrHdlList& rHandlerList ) +{ + if( mxAnnotation.is() ) + { + SmartTagReference xThis( this ); + Point aPoint; + AnnotationHdl* pHdl = new AnnotationHdl( xThis, mxAnnotation, aPoint ); + pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM ); + pHdl->SetPageView( mrView.GetSdrPageView() ); + + RealPoint2D aPosition( mxAnnotation->getPosition() ); + Point aBasePos( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ); + pHdl->SetPos( aBasePos ); + + rHandlerList.AddHdl( pHdl ); + } +} + +// -------------------------------------------------------------------- + +void AnnotationTag::disposing() +{ + if( mpListenWindow ) + { + mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + } + + if( mnClosePopupEvent ) + { + Application::RemoveUserEvent( mnClosePopupEvent ); + mnClosePopupEvent = 0; + } + + mxAnnotation.clear(); + ClosePopup(); + SmartTag::disposing(); +} + +// -------------------------------------------------------------------- + +void AnnotationTag::select() +{ + SmartTag::select(); + + mrManager.onTagSelected( *this ); + + Window* pWindow = mrView.GetViewShell()->GetActiveWindow(); + if( pWindow ) + { + RealPoint2D aPosition( mxAnnotation->getPosition() ); + Point aPos( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ); + + Rectangle aVisRect( aPos, pWindow->PixelToLogic(maSize) ); + mrView.MakeVisible(aVisRect, *pWindow); + } +} + +// -------------------------------------------------------------------- + +void AnnotationTag::deselect() +{ + SmartTag::deselect(); + + ClosePopup(); + + mrManager.onTagDeselected( *this ); +} + +// -------------------------------------------------------------------- + +BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected ) +{ + VirtualDevice aVDev; + + OUString sAuthor( getInitials( mxAnnotation->getAuthor() ) ); + sAuthor += OUString( sal_Unicode( ' ' ) ); + sAuthor += OUString::valueOf( (sal_Int32)mnIndex ); + + aVDev.SetFont( mrFont ); + + const int BORDER_X = 4; // pixels + const int BORDER_Y = 4; // pixels + + maSize = Size( aVDev.GetTextWidth( sAuthor ) + 2*BORDER_X, aVDev.GetTextHeight() + 2*BORDER_Y ); + aVDev.SetOutputSizePixel( maSize, FALSE ); + + Color aBorderColor( maColor ); + + if( bSelected ) + { + aBorderColor.Invert(); + } + else + { + if( maColor.IsDark() ) + { + aBorderColor.IncreaseLuminance( 32 ); + } + else + { + aBorderColor.DecreaseLuminance( 32 ); + } + } + + Point aPos; + Rectangle aBorderRect( aPos, maSize ); + aVDev.SetLineColor(aBorderColor); + aVDev.SetFillColor(maColor); + aVDev.DrawRect( aBorderRect ); + + aVDev.SetTextColor( maColor.IsDark() ? COL_WHITE : COL_BLACK ); + aVDev.DrawText( Point( BORDER_X, BORDER_Y ), sAuthor ); + + return aVDev.GetBitmapEx( aPos, maSize ); +} + +void AnnotationTag::OpenPopup( bool bEdit ) +{ + if( !mxAnnotation.is() ) + return; + + if( !mpAnnotationWindow.get() ) + { + ::Window* pWindow = dynamic_cast< ::Window* >( getView().GetFirstOutputDevice() ); + if( pWindow ) + { + RealPoint2D aPosition( mxAnnotation->getPosition() ); + Point aPos( pWindow->OutputToScreenPixel( pWindow->LogicToPixel( Point( static_cast<long>(aPosition.X * 100.0), static_cast<long>(aPosition.Y * 100.0) ) ) ) ); + + aPos.X() += 4; // magic! + aPos.Y() += 1; + + Rectangle aRect( aPos, maSize ); + + mpAnnotationWindow.reset( new AnnotationWindow( mrManager, mrView.GetDocSh(), pWindow->GetWindow(WINDOW_FRAME) ) ); + mpAnnotationWindow->InitControls(); + mpAnnotationWindow->setAnnotation(mxAnnotation); + + USHORT nArrangeIndex = 0; + Point aPopupPos( FloatingWindow::CalcFloatingPosition( mpAnnotationWindow.get(), aRect, FLOATWIN_POPUPMODE_RIGHT, nArrangeIndex ) ); + Size aPopupSize( 320, 240 ); + + mpAnnotationWindow->SetPosSizePixel( aPopupPos, aPopupSize ); + mpAnnotationWindow->DoResize(); + + mpAnnotationWindow->Show(); + mpAnnotationWindow->GrabFocus(); + mpAnnotationWindow->AddEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + } + } + + if( bEdit && mpAnnotationWindow.get() ) + mpAnnotationWindow->StartEdit(); +} + +void AnnotationTag::ClosePopup() +{ + if( mpAnnotationWindow.get() ) + { + mpAnnotationWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + mpAnnotationWindow.reset(); + } +} + +IMPL_LINK(AnnotationTag, WindowEventHandler, VclWindowEvent*, pEvent) +{ + if( pEvent != NULL ) + { + ::Window* pWindow = pEvent->GetWindow(); + + if( pWindow ) + { + if( pWindow == mpAnnotationWindow.get() ) + { + if( pEvent->GetId() == VCLEVENT_WINDOW_DEACTIVATE ) + { + if( mnClosePopupEvent ) + Application::RemoveUserEvent( mnClosePopupEvent ); + + mnClosePopupEvent = Application::PostUserEvent( LINK( this, AnnotationTag, ClosePopupHdl ) ); + } + } + else if( pWindow == mpListenWindow ) + { + switch( pEvent->GetId() ) + { + case VCLEVENT_WINDOW_MOUSEBUTTONUP: + { + // if we stop pressing the button without a mouse move we open the popup + mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + mpListenWindow = 0; + if( mpAnnotationWindow.get() == 0 ) + OpenPopup(false); + } + break; + case VCLEVENT_WINDOW_MOUSEMOVE: + { + // if we move the mouse after a button down we wan't to start draging + mpListenWindow->RemoveEventListener( LINK(this, AnnotationTag, WindowEventHandler)); + mpListenWindow = 0; + + SdrHdl* pHdl = mrView.PickHandle(maMouseDownPos); + if( pHdl ) + { + mrView.BrkAction(); + const USHORT nDrgLog = (USHORT)pWindow->PixelToLogic(Size(DRGPIX,0)).Width(); + + rtl::Reference< AnnotationTag > xTag( this ); + + SdrDragMethod* pDragMethod = new AnnotationDragMove( mrView, xTag ); + mrView.BegDragObj(maMouseDownPos, NULL, pHdl, nDrgLog, pDragMethod ); + } + } + break; + case VCLEVENT_OBJECT_DYING: + mpListenWindow = 0; + break; + } + } + } + } + return TRUE; +} + +IMPL_LINK( AnnotationTag, ClosePopupHdl, void *, EMPTYARG ) +{ + mnClosePopupEvent = 0; + ClosePopup(); + return 0; +} + +} // end of namespace sd + diff --git a/sd/source/ui/annotations/annotationtag.hxx b/sd/source/ui/annotations/annotationtag.hxx new file mode 100644 index 000000000..c8ed3a87b --- /dev/null +++ b/sd/source/ui/annotations/annotationtag.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: motionpathtag.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SD_ANNOTATIONTAG_HXX_ +#define _SD_ANNOTATIONTAG_HXX_ + +#include <com/sun/star/office/XAnnotation.hpp> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include "smarttag.hxx" + +namespace css = ::com::sun::star; + +namespace sd { + +class View; +class AnnotationManagerImpl; +class AnnotationWindow; + +class AnnotationTag : public SmartTag +{ +public: + AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const css::uno::Reference< css::office::XAnnotation >& xAnnotation, Color& rColor, int nIndex, const Font& rFont ); + virtual ~AnnotationTag(); + + /** returns true if the SmartTag handled the event. */ + virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& ); + + /** returns true if the SmartTag consumes this event. */ + virtual bool KeyInput( const KeyEvent& rKEvt ); + + /** returns true if the SmartTag consumes this event. */ + virtual bool RequestHelp( const HelpEvent& rHEvt ); + + /** returns true if the SmartTag consumes this event. */ + virtual bool Command( const CommandEvent& rCEvt ); + + // callbacks from sdr view + virtual ULONG GetMarkablePointCount() const; + virtual ULONG GetMarkedPointCount() const; + virtual BOOL MarkPoint(SdrHdl& rHdl, BOOL bUnmark=FALSE); + virtual void CheckPossibilities(); + virtual BOOL MarkPoints(const Rectangle* pRect, BOOL bUnmark); + + void Move( int nDX, int nDY ); + bool OnMove( const KeyEvent& rKEvt ); + + // --- + + BitmapEx CreateAnnotationBitmap(bool); + + css::uno::Reference< css::office::XAnnotation > GetAnnotation() const { return mxAnnotation; } + + void OpenPopup( bool bEdit ); + void ClosePopup(); + +protected: + virtual void addCustomHandles( SdrHdlList& rHandlerList ); + virtual bool getContext( SdrViewContext& rContext ); + virtual void disposing(); + virtual void select(); + virtual void deselect(); + + DECL_LINK( WindowEventHandler, VclWindowEvent* ); + DECL_LINK( ClosePopupHdl, void* ); + +private: + AnnotationManagerImpl& mrManager; + css::uno::Reference< css::office::XAnnotation > mxAnnotation; + std::auto_ptr<AnnotationWindow> mpAnnotationWindow; + Color maColor; + int mnIndex; + const Font& mrFont; + Size maSize; + ULONG mnClosePopupEvent; + ::Window* mpListenWindow; + Point maMouseDownPos; +}; + +} // end of namespace sd + +#endif // _SD_ANNOTATIONTAG_HXX_ + diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx new file mode 100644 index 000000000..17ba21aa8 --- /dev/null +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -0,0 +1,849 @@ +/************************************************************************* * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: postit.cxx,v $ + * $Revision: 1.8.42.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_sd.hxx" + +#include <svx/fontitem.hxx> +#include <svx/eeitem.hxx> +#include <svx/fhgtitem.hxx> +#include <svx/bulitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/shdditem.hxx> +#include <svx/flditem.hxx> +#include <svx/frmdir.hxx> +#include <svx/frmdiritem.hxx> +#include <svx/langitem.hxx> +#include <svx/adjitem.hxx> +#include <svx/editview.hxx> +#include <svx/svdview.hxx> +#include <svx/sdrpaintwindow.hxx> +#include <svx/sdr/overlay/overlaymanager.hxx> +#include <svx/editstat.hxx> //EditEngine flags +#include <svx/outliner.hxx> +#include <svx/editeng.hxx> +#include <svx/editobj.hxx> +#include <svx/unolingu.hxx> +#include <svx/outlobj.hxx> +#include <svx/postitem.hxx> +#include <svx/wghtitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/crsditem.hxx> + +#include <svtools/langtab.hxx> +#include <svtools/slstitm.hxx> +#include <svtools/securityoptions.hxx> +#include <svtools/useroptions.hxx> +#include <svtools/languageoptions.hxx> +#include <svtools/zforlist.hxx> +#include <svtools/svmedit.hxx> + +#include <linguistic/lngprops.hxx> + +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/mnumgr.hxx> + +#include <vcl/vclenum.hxx> +#include <vcl/edit.hxx> +#include <vcl/help.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/button.hxx> +#include <vcl/svapp.hxx> +#include <vcl/gradient.hxx> +#include <vcl/salbtype.hxx> // FRound +#include <vcl/cursor.hxx> + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + +#include "annotations.hrc" +#include "annotationwindow.hxx" +#include "annotationmanagerimpl.hxx" + +#include "DrawDocShell.hxx" +#include "ViewShell.hxx" +#include "drawdoc.hxx" +#include "View.hxx" +#include "textapi.hxx" +#include "sdresid.hxx" + +using rtl::OUString; +using namespace ::sd; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::office; +using namespace ::com::sun::star::text; + +#define METABUTTON_WIDTH 16 +#define METABUTTON_HEIGHT 18 +#define METABUTTON_AREA_WIDTH 30 +#define POSTIT_META_HEIGHT (sal_Int32) 30 + +#define EMPTYSTRING rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")) + +namespace sd { + +extern OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotation ); +extern SfxItemPool* GetAnnotationPool(); +extern com::sun::star::util::DateTime getCurrentDateTime(); + +Color ColorFromAlphaColor(UINT8 aTransparency, Color &aFront, Color &aBack ) +{ + return Color((UINT8)(aFront.GetRed() * aTransparency/(double)255 + aBack.GetRed() * (1-aTransparency/(double)255)), + (UINT8)(aFront.GetGreen() * aTransparency/(double)255 + aBack.GetGreen() * (1-aTransparency/(double)255)), + (UINT8)(aFront.GetBlue() * aTransparency/(double)255 + aBack.GetBlue() * (1-aTransparency/(double)255))); +} + +/************ AnnotationTextWindow **********************************/ + +AnnotationTextWindow::AnnotationTextWindow( AnnotationWindow* pParent, WinBits nBits ) +: Control(pParent, nBits) +, mpOutlinerView(0) +, mpAnnotationWindow( pParent ) +{ +} + +AnnotationTextWindow::~AnnotationTextWindow() +{ +} + +void AnnotationTextWindow::Paint( const Rectangle& rRect) +{ + if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + DrawGradient(Rectangle(Point(0,0),PixelToLogic(GetSizePixel())), + Gradient(GRADIENT_LINEAR,mpAnnotationWindow->maColorLight,mpAnnotationWindow->maColor)); + } + + if( mpOutlinerView ) + mpOutlinerView->Paint( rRect ); +} + +void AnnotationTextWindow::KeyInput( const KeyEvent& rKeyEvt ) +{ + const KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); + USHORT nKey = rKeyCode.GetCode(); + + if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN))) + { + SfxDispatcher* pDispatcher = mpAnnotationWindow->DocShell()->GetViewShell()->GetViewFrame()->GetDispatcher(); + if( pDispatcher ) + pDispatcher->Execute( nKey == KEY_PAGEDOWN ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT ); + } + else if (nKey == KEY_INSERT) + { + if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2()) + mpAnnotationWindow->ToggleInsMode(); + } + else + { + long aOldHeight = mpAnnotationWindow->GetPostItTextHeight(); + bool bDone = false; + + /// HACK: need to switch off processing of Undo/Redo in Outliner + if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) + { + bool bIsProtected = mpAnnotationWindow->IsProtected(); + if (!bIsProtected || (bIsProtected && !mpAnnotationWindow->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) + + bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); + } + if (bDone) + { + mpAnnotationWindow->ResizeIfNeccessary(aOldHeight,mpAnnotationWindow->GetPostItTextHeight()); + } + else + { + Control::KeyInput(rKeyEvt); + } + } +} + +void AnnotationTextWindow::MouseMove( const MouseEvent& rMEvt ) +{ + if ( mpOutlinerView ) + { + mpOutlinerView->MouseMove( rMEvt ); + SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); + } +} + +void AnnotationTextWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + GrabFocus(); + if ( mpOutlinerView ) + mpOutlinerView->MouseButtonDown( rMEvt ); + // todo mpOutlinerView->DocView()->GetViewFrame()->GetBindings().InvalidateAll(FALSE); +} + +void AnnotationTextWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if ( mpOutlinerView ) + mpOutlinerView->MouseButtonUp( rMEvt ); +} + +void AnnotationTextWindow::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) + { + mpAnnotationWindow->Command(rCEvt); + } + else + { + if ( mpOutlinerView ) + mpOutlinerView->Command( rCEvt ); + else + Window::Command(rCEvt); + } +} + +void AnnotationTextWindow::GetFocus() +{ + Window::GetFocus(); +} + +void AnnotationTextWindow::LoseFocus() +{ +// if ( mpAnnotationWindow ) +// mpAnnotationWindow->UpdateAnnotation(); + + Window::LoseFocus(); +} + +XubString AnnotationTextWindow::GetSurroundingText() const +{ + if( mpOutlinerView ) + { + EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); + if( mpOutlinerView->HasSelection() ) + return mpOutlinerView->GetSelected(); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + XubString aStr = aEditEngine->GetText(aSelection.nStartPara); + return aStr; + } + } + else + return XubString::EmptyString(); +} + +Selection AnnotationTextWindow::GetSurroundingTextSelection() const +{ + if( mpOutlinerView ) + { + if( mpOutlinerView->HasSelection() ) + return Selection( 0, mpOutlinerView->GetSelected().Len() ); + else + { + ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); + return Selection( aSelection.nStartPos, aSelection.nEndPos ); + } + } + else + return Selection( 0, 0 ); +} + +/************** AnnotationWindow***********************************++*/ + +AnnotationWindow::AnnotationWindow( AnnotationManagerImpl& rManager, DrawDocShell* pDocShell, Window* pParent ) +: FloatingWindow(pParent, WB_SYSTEMWINDOW|WB_BORDER|WB_NEEDSFOCUS) +, mrManager( rManager ) +, mpDocShell( pDocShell ) +, mpView( pDocShell->GetViewShell()->GetView() ) +, mpDoc( pDocShell->GetDoc() ) +, mpOutlinerView(0) +, mpOutliner(0) +, mpVScrollbar(0) +, mbReadonly(pDocShell->IsReadOnly()) +, mbProtected(false) +, mbMouseOverButton(false) +, mpTextWindow(0) +, mpMeta(0) +{ +} + +AnnotationWindow::~AnnotationWindow() +{ + delete mpMeta; + delete mpOutlinerView; + delete mpOutliner; + delete mpVScrollbar; + delete mpTextWindow; +} + +void AnnotationWindow::InitControls() +{ + // actual window which holds the user text + mpTextWindow = new AnnotationTextWindow(this, WB_NODIALOGCONTROL); + mpTextWindow->SetPointer(Pointer(POINTER_TEXT)); + + // window control for author and date + mpMeta = new MultiLineEdit(this,0); + mpMeta->SetReadOnly(); + mpMeta->SetRightToLeft(Application::GetSettings().GetLayoutRTL()); + mpMeta->AlwaysDisableInput(true); + mpMeta->SetCallHandlersOnInputDisabled(true); + +// mpMeta->AddEventListener( LINK( mpPostItTxt, PostItTxt, WindowEventListener ) ); +// AddEventListener( LINK( mpTextWindow, PostItTxt, WindowEventListener ) ); + + // we should leave this setting alone, but for this we need a better layout algo + // with variable meta size height + AllSettings aSettings = mpMeta->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + Font aFont = aStyleSettings.GetFieldFont(); + aFont.SetHeight(8); + aStyleSettings.SetFieldFont(aFont); + aSettings.SetStyleSettings(aStyleSettings); + mpMeta->SetSettings(aSettings); + + mpOutliner = new ::Outliner(GetAnnotationPool(),OUTLINERMODE_TEXTOBJECT); + Doc()->SetCalcFieldValueHdl( mpOutliner ); + mpOutliner->SetUpdateMode( TRUE ); + Rescale(); + + OutputDevice* pDev = Doc()->GetRefDevice(); + if( pDev ) + { + mpOutliner->SetRefDevice( pDev ); + } + + mpOutlinerView = new OutlinerView ( mpOutliner, mpTextWindow ); + mpOutliner->InsertView(mpOutlinerView ); + mpTextWindow->SetOutlinerView(mpOutlinerView); + mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) ); + +// SfxItemSet item(DocShell()->GetPool()); +// item.Put(SvxFontHeightItem(352,100,EE_CHAR_FONTHEIGHT)); +// mpOutlinerView->SetAttribs(item); + + // TODO: ?? + EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R; + mpOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir ); + + //create Scrollbars + mpVScrollbar = new ScrollBar(this, WB_3DLOOK |WB_VSCROLL|WB_DRAG); + mpVScrollbar->EnableNativeWidget(false); + mpVScrollbar->EnableRTL( false ); + mpVScrollbar->SetScrollHdl(LINK(this, AnnotationWindow, ScrollHdl)); + mpVScrollbar->EnableDrag(); +// mpVScrollbar->AddEventListener( LINK( this, AnnotationWindow, WindowEventListener ) ); + + ULONG nCntrl = mpOutliner->GetControlWord(); + nCntrl |= EE_CNTRL_PASTESPECIAL | EE_CNTRL_AUTOCORRECT | EV_CNTRL_AUTOSCROLL | EE_CNTRL_NOCOLORS; +/* + if (pVOpt->IsFieldShadings()) + nCntrl |= EE_CNTRL_MARKFIELDS; + else + nCntrl &= ~EE_CNTRL_MARKFIELDS; + if (pVOpt->IsOnlineSpell()) + nCntrl |= EE_CNTRL_ONLINESPELLING; + else + nCntrl &= ~EE_CNTRL_ONLINESPELLING; +*/ + mpOutliner->SetControlWord(nCntrl); +// mpOutliner->SetFlatMode( TRUE ); + + Engine()->SetModifyHdl( Link() ); + Engine()->EnableUndo( FALSE ); + + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + Engine()->EnableUndo( TRUE ); + Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); + + Invalidate(); + + SetLanguage(GetLanguage()); + + mpMeta->Show(); + mpVScrollbar->Show(); + mpTextWindow->Show(); +} + +void AnnotationWindow::StartEdit() +{ + getView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF)); + getView()->ShowCursor(); +} + +void AnnotationWindow::Rescale() +{ + MapMode aMode(MAP_100TH_MM); + aMode.SetOrigin( Point() ); + //aMode.SetScaleX( aMode.GetScaleX() * Fraction( 8, 10 ) ); + //aMode.SetScaleY( aMode.GetScaleY() * Fraction( 8, 10 ) ); + mpOutliner->SetRefMapMode( aMode ); + SetMapMode( aMode ); + mpTextWindow->SetMapMode( aMode ); + if ( mpMeta ) + { + Font aFont( mpMeta->GetSettings().GetStyleSettings().GetFieldFont() ); + sal_Int32 nHeight = aFont.GetHeight(); + nHeight = nHeight * aMode.GetScaleY().GetNumerator() / aMode.GetScaleY().GetDenominator(); + aFont.SetHeight( nHeight ); + mpMeta->SetControlFont( aFont ); + } +} + +void AnnotationWindow::DoResize() +{ + unsigned long aWidth = GetSizePixel().Width(); + long aHeight = GetSizePixel().Height() - POSTIT_META_HEIGHT; + + mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; + long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); + + if( aTextHeight > aHeight ) + { // we need vertical scrollbars and have to reduce the width + aWidth -= GetScrollbarWidth(); + mpVScrollbar->Show(); + } + else + { + mpVScrollbar->Hide(); + } + + mpTextWindow->SetPosSizePixel(0,0,aWidth, aHeight); + + if( mbReadonly ) + mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width(),POSTIT_META_HEIGHT); + else + mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-METABUTTON_AREA_WIDTH,POSTIT_META_HEIGHT); + + mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; + mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); + if (!mpVScrollbar->IsVisible()) + { // if we do not have a scrollbar anymore, we want to see the complete text + mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); + } + mpVScrollbar->SetPosSizePixel( 0 + aWidth, 0, GetScrollbarWidth(), aHeight ); + mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); + mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); + mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); + SetScrollbar(); + mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); + + Point aPos( mpMeta->GetPosPixel()); + Point aBase( aPos.X() + aPos.X() + GetSizePixel().Width(), aPos.Y() ); + Point aLeft = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+5), aBase.Y()+17 ) ); + Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1), aBase.Y()+17 ) ); + Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2), aBase.Y()+20 ) ); + + maPopupTriangle.clear(); + maPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y())); + maPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y())); + maPopupTriangle.append(basegfx::B2DPoint(aBottom.X(),aBottom.Y())); + maPopupTriangle.setClosed(true); + maRectMetaButton = PixelToLogic( Rectangle( Point( + aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10), + aPos.Y()+5 ), + Size( METABUTTON_WIDTH, METABUTTON_HEIGHT ) ) ); + +} + +void AnnotationWindow::SetSizePixel( const Size& rNewSize ) +{ + Window::SetSizePixel(rNewSize); +} + +void AnnotationWindow::SetScrollbar() +{ + mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); +} + +void AnnotationWindow::ResizeIfNeccessary(long aOldHeight, long aNewHeight) +{ + if (aOldHeight != aNewHeight) + { + DoResize(); + Invalidate(); + } + else + { + SetScrollbar(); + } +} + +void AnnotationWindow::SetReadonly(bool bSet) +{ + mbReadonly = bSet; + getView()->SetReadOnly(bSet); +} + +void AnnotationWindow::SetLanguage(const SvxLanguageItem aNewItem) +{ + Engine()->SetModifyHdl( Link() ); + ESelection aOld = getView()->GetSelection(); + + ESelection aNewSelection( 0, 0, (USHORT)Engine()->GetParagraphCount()-1, USHRT_MAX ); + getView()->SetSelection( aNewSelection ); + SfxItemSet aEditAttr(getView()->GetAttribs()); + aEditAttr.Put(aNewItem); + getView()->SetAttribs( aEditAttr ); + + getView()->SetSelection(aOld); + Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); + + Invalidate(); +} + +void AnnotationWindow::ToggleInsMode() +{ + if( mpOutlinerView ) + { + SfxBindings &rBnd = mpDocShell->GetViewShell()->GetViewFrame()->GetBindings(); + rBnd.Invalidate(SID_ATTR_INSERT); + rBnd.Update(SID_ATTR_INSERT); + } +} + +long AnnotationWindow::GetPostItTextHeight() +{ + return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; +} + +IMPL_LINK(AnnotationWindow, ScrollHdl, ScrollBar*, pScroll) +{ + long nDiff = getView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); + getView()->Scroll( 0, nDiff ); + return 0; +} + +IMPL_LINK(AnnotationWindow, ModifyHdl, void*, EMPTYARG) +{ + return 0; +} + +sal_Int32 AnnotationWindow::GetScrollbarWidth() +{ + return 16; +// return mpView->GetWrtShell().GetViewOptions()->GetZoom() / 10; +} + +SvxLanguageItem AnnotationWindow::GetLanguage(void) +{ + return SvxLanguageItem( Doc()->GetLanguage( EE_CHAR_LANGUAGE ), SID_ATTR_LANGUAGE ); +} + +// -------------------------------------------------------------------- + +TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation ) +{ + if( xAnnotation.is() ) + { + Reference< XText > xText( xAnnotation->getTextRange() ); + return TextApiObject::getImplementation( xText ); + } + return 0; +} + +// -------------------------------------------------------------------- + +void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotation, bool bGrabFocus ) +{ + if( (xAnnotation != mxAnnotation) && xAnnotation.is() ) + { + mxAnnotation = xAnnotation; + + SetColor(); + + SvtUserOptions aUserOptions; + mbProtected = aUserOptions.GetFullName() != xAnnotation->getAuthor(); + + Engine()->Clear(); + TextApiObject* pTextApi = getTextApiObject( mxAnnotation ); + + if( pTextApi ) + { + std::auto_ptr< OutlinerParaObject > pOPO( pTextApi->CreateText() ); + Engine()->SetText( *pOPO.get() ); + } + + Engine()->SetModifyHdl( LINK( this, AnnotationWindow, ModifyHdl ) ); + Engine()->ClearModifyFlag(); + Engine()->GetUndoManager().Clear(); + + Invalidate(); + + OUString sMeta( xAnnotation->getAuthor() ); + OUString sDateTime( getAnnotationDateTimeString(xAnnotation) ); + + if( sDateTime.getLength() != 0 ) + { + if( sMeta.getLength() != 0 ) + sMeta += OUString( RTL_CONSTASCII_USTRINGPARAM( "\n" ) ); + + sMeta += sDateTime; + } + mpMeta->SetText(sMeta); + + if( bGrabFocus ) + GrabFocus(); + } +} + +void AnnotationWindow::SetColor() +{ + sal_uInt16 nAuthorIdx = mpDoc->GetAnnotationAuthorIndex( mxAnnotation->getAuthor() ); + + maColor = mrManager.GetColor( nAuthorIdx ); + maColorDark = mrManager.GetColorDark( nAuthorIdx ); + maColorLight = mrManager.GetColorLight( nAuthorIdx ); + + mpOutlinerView->SetBackgroundColor(maColor); + + mpMeta->SetControlBackground(maColor); + AllSettings aSettings = mpMeta->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(maColorDark); + aSettings.SetStyleSettings(aStyleSettings); + mpMeta->SetSettings(aSettings); + + AllSettings aSettings2 = mpVScrollbar->GetSettings(); + StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); + aStyleSettings2.SetButtonTextColor(Color(0,0,0)); + aStyleSettings2.SetCheckedColor(maColorLight); //hintergund + aStyleSettings2.SetShadowColor(maColorDark); + aStyleSettings2.SetFaceColor(maColor); + aSettings2.SetStyleSettings(aStyleSettings2); + mpVScrollbar->SetSettings(aSettings2); +} + +void AnnotationWindow::Deactivate() +{ + Reference< XAnnotation > xAnnotation( mxAnnotation ); +/* + // check if text is empty + Paragraph* p1stPara=Engine()->GetParagraph( 0 ); + ULONG nParaAnz=Engine()->GetParagraphCount(); + if(p1stPara==NULL) + nParaAnz=0; + + if(nParaAnz==1) + { + // if it is only one paragraph, check if that paragraph is empty + XubString aStr(Engine()->GetText(p1stPara)); + + if(!aStr.Len()) + nParaAnz = 0; + } + + if( nParaAnz == 0 ) + { + // text is empty, delete postit + DeleteAnnotation( xAnnotation ); + } + else +*/ + { + // write changed text back to annotation + if ( Engine()->IsModified() ) + { + TextApiObject* pTextApi = getTextApiObject( xAnnotation ); + + if( pTextApi ) + { + OutlinerParaObject* pOPO = Engine()->CreateParaObject(); + if( pOPO ) + { + if( mpDoc->IsUndoEnabled() ) + mpDoc->BegUndo( String( SdResId( STR_ANNOTATION_UNDO_EDIT ) ) ); + + pTextApi->SetText( *pOPO ); + delete pOPO; + + // set current time to changed annotation + xAnnotation->setDateTime( getCurrentDateTime() ); + + if( mpDoc->IsUndoEnabled() ) + mpDoc->EndUndo(); + + DocView()->GetDocSh()->SetModified(sal_True); + } + + } + } + Engine()->ClearModifyFlag(); + } + + Engine()->GetUndoManager().Clear(); +} + +void AnnotationWindow::Paint( const Rectangle& rRect) +{ + FloatingWindow::Paint( rRect ); + + if(mpMeta->IsVisible() && !mbReadonly) + { + //draw left over space + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + SetFillColor(COL_BLACK); + else + SetFillColor(maColor); + SetLineColor(); + DrawRect(PixelToLogic(Rectangle(Point(mpMeta->GetPosPixel().X()+mpMeta->GetSizePixel().Width(),mpMeta->GetPosPixel().Y()),Size(METABUTTON_AREA_WIDTH,mpMeta->GetSizePixel().Height())))); + + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + //draw rect around button + SetFillColor(COL_BLACK); + SetLineColor(COL_WHITE); + } + else + { + //draw button + Gradient aGradient; + if (mbMouseOverButton) + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(80,maColorDark,maColor),ColorFromAlphaColor(15,maColorDark,maColor)); + else + aGradient = Gradient(GRADIENT_LINEAR,ColorFromAlphaColor(15,maColorDark,maColor),ColorFromAlphaColor(80,maColorDark,maColor)); + DrawGradient(maRectMetaButton,aGradient); + //draw rect around button + SetFillColor(); + SetLineColor(ColorFromAlphaColor(90,maColorDark,maColor)); + } + DrawRect(maRectMetaButton); + + //draw arrow + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + SetFillColor(COL_WHITE); + else + SetFillColor(COL_BLACK); + SetLineColor(); + DrawPolygon(Polygon(maPopupTriangle)); + } +} + +void AnnotationWindow::MouseMove( const MouseEvent& rMEvt ) +{ + if( !mbReadonly ) + { + if (maRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel()))) + { + if (!mbMouseOverButton) + { + Invalidate(maRectMetaButton); + mbMouseOverButton = true; + } + } + else + { + if (mbMouseOverButton) + { + Invalidate(maRectMetaButton); + mbMouseOverButton = false; + } + } + } +} + +void AnnotationWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if (!mbReadonly && maRectMetaButton.IsInside(PixelToLogic(rMEvt.GetPosPixel())) && rMEvt.IsLeft()) + { + // context menu + Rectangle aRect(LogicToPixel(maRectMetaButton.BottomLeft()),LogicToPixel(maRectMetaButton.BottomLeft())); + mrManager.ExecuteAnnotationContextMenu( mxAnnotation, (::Window*)this, aRect, true ); + } +} + +void AnnotationWindow::Command( const CommandEvent& rCEvt ) +{ + if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) + { + mrManager.ExecuteAnnotationContextMenu( mxAnnotation, this, Rectangle(rCEvt.GetMousePosPixel(),Size(1,1)) ); + } + else + { + FloatingWindow::Command(rCEvt); + } +} + +void AnnotationWindow::GetFocus() +{ + if( mpTextWindow ) + mpTextWindow->GrabFocus(); + else + FloatingWindow::GetFocus(); +} + +void AnnotationWindow::ExecuteSlot( USHORT nSID ) +{ + if( nSID == SID_COPY ) + { + getView()->Copy(); + } + else if( nSID == SID_PASTE ) + { + getView()->PasteSpecial(); + DoResize(); + } + else + { + SfxItemSet aEditAttr(getView()->GetAttribs()); + SfxItemSet aNewAttr(mpOutliner->GetEmptyItemSet()); + + switch( nSID ) + { + case SID_ATTR_CHAR_WEIGHT: + { + FontWeight eFW = ( (const SvxWeightItem&) aEditAttr.Get( EE_CHAR_WEIGHT ) ).GetWeight(); + aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) ); + } + break; + case SID_ATTR_CHAR_POSTURE: + { + FontItalic eFI = ( (const SvxPostureItem&) aEditAttr.Get( EE_CHAR_ITALIC ) ).GetPosture(); + aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) ); + } + break; + case SID_ATTR_CHAR_UNDERLINE: + { + FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr. Get( EE_CHAR_UNDERLINE ) ).GetLineStyle(); + aNewAttr.Put( SvxUnderlineItem( eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE ) ); + } + break; + case SID_ATTR_CHAR_STRIKEOUT: + { + FontStrikeout eFSO = ( ( (const SvxCrossedOutItem&) aEditAttr.Get( EE_CHAR_STRIKEOUT ) ).GetStrikeout() ); + aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) ); + } + break; + } + getView()->SetAttribs( aNewAttr ); + } +} + +} diff --git a/sd/source/ui/annotations/annotationwindow.hxx b/sd/source/ui/annotations/annotationwindow.hxx new file mode 100644 index 000000000..45ebb9c87 --- /dev/null +++ b/sd/source/ui/annotations/annotationwindow.hxx @@ -0,0 +1,180 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: postit.hxx,v $ + * + * $Revision: 1.8.84.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _ANNOTATIONWINDOW_HXX +#define _ANNOTATIONWINDOW_HXX + +#include <com/sun/star/office/XAnnotation.hpp> + +#include <tools/datetime.hxx> +#include <tools/date.hxx> + +#include <vcl/ctrl.hxx> +#include <vcl/lineinfo.hxx> +#include <vcl/floatwin.hxx> + +#include <basegfx/polygon/b2dpolygon.hxx> + +#include <svx/sdr/overlay/overlayobject.hxx> +#include <svx/editstat.hxx> + +class OutlinerView; +class Outliner; +class ScrollBar; +class Edit; +class MultiLineEdit; +class PopupMenu; +class SvxLanguageItem; +class OutlinerParaObject; +class SdDrawDocument; + +namespace sd { + +class AnnotationManagerImpl; +class AnnotationWindow; +class DrawDocShell; +class View; + +class AnnotationTextWindow : public Control +{ +private: + OutlinerView* mpOutlinerView; + AnnotationWindow* mpAnnotationWindow; + +protected: + virtual void Paint( const Rectangle& rRect); + virtual void KeyInput( const KeyEvent& rKeyEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void LoseFocus(); + +public: + AnnotationTextWindow( AnnotationWindow* pParent, WinBits nBits ); + ~AnnotationTextWindow(); + + void SetOutlinerView( OutlinerView* pOutlinerView ) { mpOutlinerView = pOutlinerView; } + + virtual XubString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + + virtual void GetFocus(); +}; + + +class AnnotationWindow : public FloatingWindow +{ + private: + AnnotationManagerImpl& mrManager; + DrawDocShell* mpDocShell; + View* mpView; + SdDrawDocument* mpDoc; + + OutlinerView* mpOutlinerView; + Outliner* mpOutliner; + ScrollBar* mpVScrollbar; + ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > mxAnnotation; + bool mbReadonly; + bool mbProtected; + bool mbMouseOverButton; + AnnotationTextWindow* mpTextWindow; + MultiLineEdit* mpMeta; + Rectangle maRectMetaButton; + basegfx::B2DPolygon maPopupTriangle; + + protected: + void SetSizePixel( const Size& rNewSize ); + + DECL_LINK(ModifyHdl, void*); + DECL_LINK(ScrollHdl, ScrollBar*); + + public: + AnnotationWindow( AnnotationManagerImpl& rManager, DrawDocShell* pDocShell, ::Window* pParent ); + virtual ~AnnotationWindow(); + + void StartEdit(); + + virtual SvxLanguageItem GetLanguage(void); + + void setAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation, bool bGrabFocus = false ); + const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& getAnnotation() const { return mxAnnotation; } + + void ExecuteSlot( USHORT nSID ); + + ScrollBar* Scrollbar() { return mpVScrollbar;} + + DrawDocShell* DocShell() { return mpDocShell; } + OutlinerView* getView() { return mpOutlinerView; } + sd::View* DocView() { return mpView; } + Outliner* Engine() { return mpOutliner; } + SdDrawDocument* Doc() { return mpDoc; } + + long GetPostItTextHeight(); + + void InitControls(); + void HidePostIt(); + void DoResize(); + void ResizeIfNeccessary(long aOldHeight, long aNewHeight); + void SetScrollbar(); + + void Rescale(); + + void SetReadonly(bool bSet); + bool IsReadOnly() { return mbReadonly;} + + bool IsProtected() { return mbProtected; } + + void SetLanguage(const SvxLanguageItem aNewItem); + + sal_Int32 GetScrollbarWidth(); + + void ToggleInsMode(); + + DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*); + + virtual void Deactivate(); + virtual void Paint( const Rectangle& rRect); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void GetFocus(); + + void SetColor(); + + Color maColor; + Color maColorDark; + Color maColorLight; +}; + +} // namespace sd + +#endif diff --git a/sd/source/ui/annotations/makefile.mk b/sd/source/ui/annotations/makefile.mk new file mode 100644 index 000000000..f457474c6 --- /dev/null +++ b/sd/source/ui/annotations/makefile.mk @@ -0,0 +1,60 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PROJECTPCH=sd +PROJECTPCHSOURCE=$(PRJ)$/util$/sd +PRJNAME=sd +TARGET=uiannotations +ENABLE_EXCEPTIONS=TRUE +AUTOSEG=true + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES =\ + annotations.src + +SLOFILES = \ + $(SLO)$/annotationwindow.obj \ + $(SLO)$/annotationtag.obj \ + $(SLO)$/annotationmanager.obj + + +# --- Tagets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/sd/source/ui/app/app.src b/sd/source/ui/app/app.src index d787e526c..957cd6c25 100644 --- a/sd/source/ui/app/app.src +++ b/sd/source/ui/app/app.src @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,31 +36,3 @@ #include "misc.hxx" #include <svx/svxids.hrc> -// -// Acceleratorn -// - -// Impress -#include "accel.src" - -// Draw (Graphic) -#undef SD_ACCELERATOR -#define SD_ACCELERATOR RID_GRAPHIC_DEFAULTACCEL -#include "accel.src" - -// -// Menu -// - -// Menu (Impress) -#include "menu.src" -#include "menuportal.src" - -// Menu (Draw (Graphic)) -#undef SD_MENU -#define SD_MENU RID_GRAPHIC_DEFAULTMENU -#undef SD_MENU_PORTAL -#define SD_MENU_PORTAL RID_GRAPHIC_PORTALMENU - -#include "menu.src" -#include "menuportal.src" diff --git a/sd/source/ui/app/makefile.mk b/sd/source/ui/app/makefile.mk index f9db62ee7..82a6177a9 100644 --- a/sd/source/ui/app/makefile.mk +++ b/sd/source/ui/app/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -106,7 +106,7 @@ $(INCCOM)$/sddll0.hxx: makefile.mk .ENDIF # "$(USE_SHELL)"!="4nt" .ENDIF # "$(GUI)"=="UNX" -LOCALIZE_ME = tbxids_tmpl.src menuids2_tmpl.src accel_tmpl.src menu_tmpl.src menuids_tmpl.src menuids4_tmpl.src popup2_tmpl.src toolbox2_tmpl.src accelids_tmpl.src menuportal_tmpl.src menuids3_tmpl.src +LOCALIZE_ME = tbxids_tmpl.src menuids2_tmpl.src menu_tmpl.src menuids_tmpl.src menuids4_tmpl.src popup2_tmpl.src toolbox2_tmpl.src menuportal_tmpl.src menuids3_tmpl.src .INCLUDE : target.mk diff --git a/sd/source/ui/app/optsitem.cxx b/sd/source/ui/app/optsitem.cxx index 5c5a0e96d..7a905a588 100644 --- a/sd/source/ui/app/optsitem.cxx +++ b/sd/source/ui/app/optsitem.cxx @@ -527,6 +527,7 @@ SdOptionsMisc::SdOptionsMisc( USHORT nConfigId, BOOL bUseConfig ) : // #90356# bShowUndoDeleteWarning( TRUE ), bSlideshowRespectZOrder( TRUE ), + bShowComments( TRUE ), bPreviewNewEffects( TRUE ), bPreviewChangedEffects( FALSE ), bPreviewTransitions( TRUE ), @@ -569,6 +570,7 @@ void SdOptionsMisc::SetDefaults() SetPreviewChangedEffects(false); SetPreviewTransitions(true); SetDisplay(0); + SetShowComments(true); } // ----------------------------------------------------------------------------- @@ -601,8 +603,8 @@ BOOL SdOptionsMisc::operator==( const SdOptionsMisc& rOpt ) const IsPreviewNewEffects() == rOpt.IsPreviewNewEffects() && IsPreviewChangedEffects() == rOpt.IsPreviewChangedEffects() && IsPreviewTransitions() == rOpt.IsPreviewTransitions() && - GetDisplay() == rOpt.GetDisplay() - + GetDisplay() == rOpt.GetDisplay() && + IsShowComments() == rOpt.IsShowComments() ); } @@ -630,6 +632,8 @@ void SdOptionsMisc::GetPropNameArray( const char**& ppNames, ULONG& rCount ) con "Compatibility/PrinterIndependentLayout", + "ShowComments", + // just for impress "NewDoc/AutoPilot", "Start/CurrentPage", @@ -645,9 +649,7 @@ void SdOptionsMisc::GetPropNameArray( const char**& ppNames, ULONG& rCount ) con "Display" }; - // #90356# rCount = ( ( GetConfigId() == SDCFG_IMPRESS ) ? 15 : 12 ); - // #97016# rCount = ( ( GetConfigId() == SDCFG_IMPRESS ) ? 16 : 12 ); - rCount = ( ( GetConfigId() == SDCFG_IMPRESS ) ? 24 : 15 ); + rCount = ( ( GetConfigId() == SDCFG_IMPRESS ) ? 25 : 16 ); ppNames = aPropNames; } @@ -672,33 +674,35 @@ BOOL SdOptionsMisc::ReadData( const Any* pValues ) if( pValues[13].hasValue() ) SetDefaultObjectSizeHeight( *(sal_uInt32*) pValues[ 13 ].getValue() ); if( pValues[14].hasValue() ) SetPrinterIndependentLayout( *(sal_uInt16*) pValues[ 14 ].getValue() ); + if( pValues[15].hasValue() ) SetShowComments( *(sal_Bool*) pValues[ 11 ].getValue() ); + // just for Impress if( GetConfigId() == SDCFG_IMPRESS ) { - if( pValues[15].hasValue() ) - SetStartWithTemplate( *(sal_Bool*) pValues[ 15 ].getValue() ); if( pValues[16].hasValue() ) - SetStartWithActualPage( *(sal_Bool*) pValues[ 16 ].getValue() ); + SetStartWithTemplate( *(sal_Bool*) pValues[ 16 ].getValue() ); if( pValues[17].hasValue() ) - SetSummationOfParagraphs( *(sal_Bool*) pValues[ 17 ].getValue() ); + SetStartWithActualPage( *(sal_Bool*) pValues[ 17 ].getValue() ); + if( pValues[18].hasValue() ) + SetSummationOfParagraphs( *(sal_Bool*) pValues[ 18 ].getValue() ); // #90356# - if( pValues[18].hasValue() ) - SetShowUndoDeleteWarning( *(sal_Bool*) pValues[ 18 ].getValue() ); - - if( pValues[19].hasValue() ) - SetSlideshowRespectZOrder(*(sal_Bool*) pValues[ 19 ].getValue()); + if( pValues[19].hasValue() ) + SetShowUndoDeleteWarning( *(sal_Bool*) pValues[ 19 ].getValue() ); if( pValues[20].hasValue() ) - SetPreviewNewEffects(*(sal_Bool*) pValues[ 20 ].getValue()); + SetSlideshowRespectZOrder(*(sal_Bool*) pValues[ 20 ].getValue()); if( pValues[21].hasValue() ) - SetPreviewChangedEffects(*(sal_Bool*) pValues[ 21 ].getValue()); + SetPreviewNewEffects(*(sal_Bool*) pValues[ 21 ].getValue()); if( pValues[22].hasValue() ) - SetPreviewTransitions(*(sal_Bool*) pValues[ 22 ].getValue()); + SetPreviewChangedEffects(*(sal_Bool*) pValues[ 22 ].getValue()); if( pValues[23].hasValue() ) - SetDisplay(*(sal_Int32*) pValues[ 23 ].getValue()); + SetPreviewTransitions(*(sal_Bool*) pValues[ 23 ].getValue()); + + if( pValues[24].hasValue() ) + SetDisplay(*(sal_Int32*) pValues[ 24 ].getValue()); } return TRUE; @@ -725,22 +729,23 @@ BOOL SdOptionsMisc::WriteData( Any* pValues ) const pValues[ 12 ] <<= GetDefaultObjectSizeWidth(); pValues[ 13 ] <<= GetDefaultObjectSizeHeight(); pValues[ 14 ] <<= GetPrinterIndependentLayout(); - + pValues[ 15 ] <<= (sal_Bool)IsShowComments(); + // just for Impress if( GetConfigId() == SDCFG_IMPRESS ) { - pValues[ 15 ] <<= IsStartWithTemplate(); - pValues[ 16 ] <<= IsStartWithActualPage(); - pValues[ 17 ] <<= IsSummationOfParagraphs(); + pValues[ 16 ] <<= IsStartWithTemplate(); + pValues[ 17 ] <<= IsStartWithActualPage(); + pValues[ 18 ] <<= IsSummationOfParagraphs(); // #90356# - pValues[ 18 ] <<= IsShowUndoDeleteWarning(); - pValues[ 19 ] <<= IsSlideshowRespectZOrder(); + pValues[ 19 ] <<= IsShowUndoDeleteWarning(); + pValues[ 20 ] <<= IsSlideshowRespectZOrder(); - pValues[ 20 ] <<= IsPreviewNewEffects(); - pValues[ 21 ] <<= IsPreviewChangedEffects(); - pValues[ 22 ] <<= IsPreviewTransitions(); + pValues[ 21 ] <<= IsPreviewNewEffects(); + pValues[ 22 ] <<= IsPreviewChangedEffects(); + pValues[ 23 ] <<= IsPreviewTransitions(); - pValues[ 23 ] <<= GetDisplay(); + pValues[ 24 ] <<= GetDisplay(); } return TRUE; diff --git a/sd/source/ui/app/res_bmp.src b/sd/source/ui/app/res_bmp.src index 3c954d096..8ba709db6 100644 --- a/sd/source/ui/app/res_bmp.src +++ b/sd/source/ui/app/res_bmp.src @@ -554,3 +554,11 @@ Bitmap BMP_FADE_EFFECT_INDICATOR_H { File = "fade_effect_indicator_hc.bmp"; }; +Bitmap BMP_COMMENTS_INDICATOR +{ + File = "comments_indicator.bmp"; +}; +Bitmap BMP_COMMENTS_INDICATOR_H +{ + File = "comments_indicator_hc.bmp"; +};
\ No newline at end of file diff --git a/sd/source/ui/app/sdmod.cxx b/sd/source/ui/app/sdmod.cxx index cba8a3ce2..a51c1c9f1 100644 --- a/sd/source/ui/app/sdmod.cxx +++ b/sd/source/ui/app/sdmod.cxx @@ -131,6 +131,11 @@ SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) SdModule::~SdModule() { + // Mark the module in the global AppData structure as deleted. + SdModule** ppShellPointer = (SdModule**)GetAppData(SHL_DRAW); + if (ppShellPointer != NULL) + (*ppShellPointer) = NULL; + delete pSearchItem; if( pNumberFormatter ) diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index bff18644f..5142539f0 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -481,6 +481,9 @@ void SdTransferable::AddSupportedFormats() sal_Bool SdTransferable::GetData( const DataFlavor& rFlavor ) { + if (SD_MOD()==NULL) + return sal_False; + sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); sal_Bool bOK = sal_False; diff --git a/sd/source/ui/app/strings.src b/sd/source/ui/app/strings.src index 38e8c5b1a..90a507c78 100644 --- a/sd/source/ui/app/strings.src +++ b/sd/source/ui/app/strings.src @@ -1269,5 +1269,7 @@ String STR_SET_BACKGROUND_PICTURE { Text [ en-US ] = "Set Background Picture for Slide ..." ; }; - - +String RID_ANNOTATIONS_START +{ + Text [ en-US ] = "Comments"; +}; diff --git a/sd/source/ui/dlg/prltempl.cxx b/sd/source/ui/dlg/prltempl.cxx index ec587912f..5234db760 100644 --- a/sd/source/ui/dlg/prltempl.cxx +++ b/sd/source/ui/dlg/prltempl.cxx @@ -171,6 +171,10 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg( SfxObjectShell* pDocSh, AddTabPage( RID_SVXPAGE_CHAR_EFFECTS ); AddTabPage( RID_SVXPAGE_STD_PARAGRAPH ); AddTabPage( RID_SVXPAGE_TEXTATTR ); + AddTabPage( RID_SVXPAGE_PICK_BULLET );
+ AddTabPage( RID_SVXPAGE_PICK_SINGLE_NUM );
+ AddTabPage( RID_SVXPAGE_PICK_BMP );
+ AddTabPage( RID_SVXPAGE_NUM_OPTIONS ); AddTabPage( RID_SVXPAGE_TABULATOR ); } break; diff --git a/sd/source/ui/dlg/prltempl.src b/sd/source/ui/dlg/prltempl.src index fe1cc1599..2aafed1c0 100644 --- a/sd/source/ui/dlg/prltempl.src +++ b/sd/source/ui/dlg/prltempl.src @@ -91,6 +91,30 @@ TabDialog TAB_PRES_LAYOUT_TEMPLATE Identifier = RID_SVXPAGE_TEXTATTR ;
PageResID = RID_SVXPAGE_TEXTATTR ;
Text [ en-US ] = "Text" ;
+ }; + PageItem
+ {
+ Identifier = RID_SVXPAGE_PICK_BULLET ;
+ PageResID = RID_SVXPAGE_PICK_BULLET ;
+ Text [ en-US ] = "Bullets" ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_PICK_SINGLE_NUM ;
+ PageResID = RID_SVXPAGE_PICK_SINGLE_NUM ;
+ Text [ en-US ] = "Numbering type" ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_PICK_BMP ;
+ PageResID = RID_SVXPAGE_PICK_BMP ;
+ Text [ en-US ] = "Graphics" ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_NUM_OPTIONS ;
+ PageResID = RID_SVXPAGE_NUM_OPTIONS ;
+ Text [ en-US ] = "Customize" ;
}; PageItem { diff --git a/sd/source/ui/framework/configuration/ConfigurationController.cxx b/sd/source/ui/framework/configuration/ConfigurationController.cxx index d9f018b2d..9ca6707a8 100644 --- a/sd/source/ui/framework/configuration/ConfigurationController.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationController.cxx @@ -59,7 +59,7 @@ using rtl::OUString; using ::sd::framework::FrameworkHelper; #undef VERBOSE -//#define VERBOSE 3 +#define VERBOSE 3 namespace sd { namespace framework { diff --git a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx index 6bb84ac69..c2922eb5b 100644 --- a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx @@ -49,7 +49,7 @@ using ::rtl::OUString; using ::std::vector; #undef VERBOSE -//#define VERBOSE 2 +#define VERBOSE 2 namespace { static const sal_Int32 snShortTimeout (100); diff --git a/sd/source/ui/framework/factories/FullScreenPane.cxx b/sd/source/ui/framework/factories/FullScreenPane.cxx index a6159ebbc..65c83903d 100644 --- a/sd/source/ui/framework/factories/FullScreenPane.cxx +++ b/sd/source/ui/framework/factories/FullScreenPane.cxx @@ -36,10 +36,13 @@ #include <cppcanvas/vclfactory.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/topfrm.hxx> +#include <vcl/svapp.hxx> +#include <vcl/dialog.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/util/URL.hpp> using namespace ::com::sun::star; @@ -47,6 +50,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing::framework; using ::rtl::OUString; +#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) + namespace sd { namespace framework { FullScreenPane::FullScreenPane ( @@ -55,8 +60,13 @@ FullScreenPane::FullScreenPane ( const ::Window* pViewShellWindow) : FrameWindowPane(rxPaneId,NULL), mxComponentContext(rxComponentContext), - mpWorkWindow(new WorkWindow(NULL, 0)) + mpWorkWindow(NULL) { + ::Window* pParent = NULL; + mpWorkWindow.reset(new WorkWindow( + pParent, + 0)); // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE)); + if ( ! rxPaneId.is()) throw lang::IllegalArgumentException(); @@ -68,10 +78,18 @@ FullScreenPane::FullScreenPane ( // Create a new top-leve window that is displayed full screen. mpWorkWindow->ShowFullScreenMode(TRUE, nScreenNumber); + // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber); mpWorkWindow->SetMenuBarMode(MENUBAR_MODE_HIDE); mpWorkWindow->SetBorderStyle(WINDOW_BORDER_REMOVEBORDER); mpWorkWindow->SetBackground(Wallpaper()); - mpWorkWindow->Show(); + // Don't show the window right now in order to allow the setting of an + // accessibility object: accessibility objects are typically + // requested by AT-tools when the window is shown. Chaning it + // afterwards may or may not work. + + // Add resize listener at the work window. + Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler)); + mpWorkWindow->AddEventListener(aWindowEventHandler); // Set title and icon of the new window to those of the current window // of the view shell. @@ -87,7 +105,6 @@ FullScreenPane::FullScreenPane ( // completely. mpWindow = new ::Window(mpWorkWindow.get()); mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel()); - mpWindow->Show(); mpWindow->SetBackground(Wallpaper()); mxWindow = VCLUnoHelper::GetInterface(mpWindow); @@ -115,7 +132,13 @@ void SAL_CALL FullScreenPane::disposing (void) delete mpWindow; } - mpWorkWindow.reset(); + if (mpWorkWindow.get() != NULL) + { + Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler)); + mpWorkWindow->RemoveEventListener(aWindowEventHandler); + mpWorkWindow.reset(); + } + FrameWindowPane::disposing(); } @@ -123,8 +146,99 @@ void SAL_CALL FullScreenPane::disposing (void) +//----- XPane ----------------------------------------------------------------- + +sal_Bool SAL_CALL FullScreenPane::isVisible (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + if (mpWindow != NULL) + return mpWindow->IsReallyVisible(); + else + return false; +} + + + + +void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + if (mpWindow != NULL) + mpWindow->Show(bIsVisible); + if (mpWorkWindow != NULL) + mpWorkWindow->Show(bIsVisible); +} + + + + +Reference<accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + if (mpWorkWindow != NULL) + return mpWorkWindow->GetAccessible(FALSE); + else + return NULL; +} + + + + +void SAL_CALL FullScreenPane::setAccessible ( + const Reference<accessibility::XAccessible>& rxAccessible) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + if (mpWindow != NULL) + { + Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY); + if (xInitializable.is()) + { + ::Window* pParentWindow = mpWindow->GetParent(); + Reference<accessibility::XAccessible> xAccessibleParent; + if (pParentWindow != NULL) + xAccessibleParent = pParentWindow->GetAccessible(); + Sequence<Any> aArguments (1); + aArguments[0] = Any(xAccessibleParent); + xInitializable->initialize(aArguments); + } + GetWindow()->SetAccessible(rxAccessible); + } +} + + + + //----------------------------------------------------------------------------- +IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent*, pEvent) +{ + switch (pEvent->GetId()) + { + case VCLEVENT_WINDOW_RESIZE: + GetWindow()->SetPosPixel(Point(0,0)); + GetWindow()->SetSizePixel(Size( + mpWorkWindow->GetSizePixel().Width(), + mpWorkWindow->GetSizePixel().Height())); + break; + + case VCLEVENT_OBJECT_DYING: + mpWorkWindow.reset(); + break; + } + return 1; +} + + + + Reference<rendering::XCanvas> FullScreenPane::CreateCanvas (void) throw (RuntimeException) { diff --git a/sd/source/ui/framework/factories/FullScreenPane.hxx b/sd/source/ui/framework/factories/FullScreenPane.hxx index 480c191c0..8b68f8f48 100644 --- a/sd/source/ui/framework/factories/FullScreenPane.hxx +++ b/sd/source/ui/framework/factories/FullScreenPane.hxx @@ -35,6 +35,7 @@ #include "FrameWindowPane.hxx" #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <vcl/vclevent.hxx> #include <boost/scoped_ptr.hpp> namespace css = ::com::sun::star; @@ -69,6 +70,26 @@ public: virtual void SAL_CALL disposing (void); + //----- XPane ------------------------------------------------------------- + + virtual sal_Bool SAL_CALL isVisible (void) + throw (cssu::RuntimeException); + + virtual void SAL_CALL setVisible (sal_Bool bIsVisible) + throw (cssu::RuntimeException); + + virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL getAccessible (void) + throw (cssu::RuntimeException); + + virtual void SAL_CALL setAccessible ( + const cssu::Reference<css::accessibility::XAccessible>& rxAccessible) + throw (cssu::RuntimeException); + + + //------------------------------------------------------------------------- + + DECL_LINK(WindowEventHandler, VclWindowEvent*); + protected: virtual ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas> CreateCanvas (void) diff --git a/sd/source/ui/framework/factories/Pane.cxx b/sd/source/ui/framework/factories/Pane.cxx index 1b0388710..abfbfbc34 100644 --- a/sd/source/ui/framework/factories/Pane.cxx +++ b/sd/source/ui/framework/factories/Pane.cxx @@ -117,6 +117,63 @@ Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas (void) +//----- XPane2 ---------------------------------------------------------------- + +sal_Bool SAL_CALL Pane::isVisible (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + const ::Window* pWindow = GetWindow(); + if (pWindow != NULL) + return pWindow->IsVisible(); + else + return false; +} + + + + +void SAL_CALL Pane::setVisible (sal_Bool bIsVisible) + throw (RuntimeException) +{ + ThrowIfDisposed(); + + ::Window* pWindow = GetWindow(); + if (pWindow != NULL) + pWindow->Show(bIsVisible); +} + + + + +Reference<accessibility::XAccessible> SAL_CALL Pane::getAccessible (void) + throw (RuntimeException) +{ + ThrowIfDisposed(); + ::Window* pWindow = GetWindow(); + if (pWindow != NULL) + return pWindow->GetAccessible(FALSE); + else + return NULL; +} + + + + +void SAL_CALL Pane::setAccessible ( + const Reference<accessibility::XAccessible>& rxAccessible) + throw (RuntimeException) +{ + ThrowIfDisposed(); + ::Window* pWindow = GetWindow(); + if (pWindow != NULL) + pWindow->SetAccessible(rxAccessible); +} + + + + //----- XResource ------------------------------------------------------------- Reference<XResourceId> SAL_CALL Pane::getResourceId (void) diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx index 859d09409..777af1142 100644 --- a/sd/source/ui/func/fupoor.cxx +++ b/sd/source/ui/func/fupoor.cxx @@ -506,6 +506,9 @@ BOOL FuPoor::KeyInput(const KeyEvent& rKEvt) case KEY_PAGEUP: { + if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() ) + break; + if(mpViewShell->ISA(DrawViewShell) && !bSlideShow) { // The page-up key switches layers or pages depending on the @@ -551,6 +554,8 @@ BOOL FuPoor::KeyInput(const KeyEvent& rKEvt) case KEY_PAGEDOWN: { + if( rKEvt.GetKeyCode().IsMod1() && rKEvt.GetKeyCode().IsMod2() ) + break; if(mpViewShell->ISA(DrawViewShell) && !bSlideShow) { // The page-down key switches layers or pages depending on the diff --git a/sd/source/ui/func/smarttag.cxx b/sd/source/ui/func/smarttag.cxx index f22c71094..7b57c51b0 100644 --- a/sd/source/ui/func/smarttag.cxx +++ b/sd/source/ui/func/smarttag.cxx @@ -68,6 +68,18 @@ bool SmartTag::KeyInput( const KeyEvent& /*rKEvt*/ ) return false; } +/** returns true if the SmartTag consumes this event. */ +bool SmartTag::RequestHelp( const HelpEvent& /*rHEvt*/ ) +{ + return false; +} + +/** returns true if the SmartTag consumes this event. */ +bool SmartTag::Command( const CommandEvent& /*rCEvt*/ ) +{ + return false; +} + // -------------------------------------------------------------------- void SmartTag::addCustomHandles( SdrHdlList& /*rHandlerList*/ ) @@ -162,6 +174,7 @@ SmartTagSet::~SmartTagSet() void SmartTagSet::add( const SmartTagReference& xTag ) { maSet.insert( xTag ); + mrView.InvalidateAllWin(); } // -------------------------------------------------------------------- @@ -171,6 +184,7 @@ void SmartTagSet::remove( const SmartTagReference& xTag ) std::set< SmartTagReference >::iterator aIter( maSet.find( xTag ) ); if( aIter != maSet.end() ) maSet.erase( aIter ); + mrView.InvalidateAllWin(); } // -------------------------------------------------------------------- @@ -181,6 +195,7 @@ void SmartTagSet::Dispose() aSet.swap( maSet ); for( std::set< SmartTagReference >::iterator aIter( aSet.begin() ); aIter != aSet.end(); ) (*aIter++)->Dispose(); + mrView.InvalidateAllWin(); } // -------------------------------------------------------------------- @@ -247,8 +262,72 @@ bool SmartTagSet::KeyInput( const KeyEvent& rKEvt ) { if( mxSelectedTag.is() ) return mxSelectedTag->KeyInput( rKEvt ); + else if( rKEvt.GetKeyCode().GetCode() == KEY_SPACE ) + { + SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( mrView.GetHdlList().GetFocusHdl() ); + if( pSmartHdl ) + { + const_cast< SdrHdlList& >( mrView.GetHdlList() ).ResetFocusHdl(); + SmartTagReference xTag( pSmartHdl->getTag() ); + select( xTag ); + return true; + } + } + + + return false; +} + +// -------------------------------------------------------------------- + +bool SmartTagSet::RequestHelp( const HelpEvent& rHEvt ) +{ + Point aMDPos( mrView.GetViewShell()->GetActiveWindow()->PixelToLogic( rHEvt.GetMousePosPixel() ) ); + SdrHdl* pHdl = mrView.PickHandle(aMDPos); + + if( pHdl ) + { + // if a smart tag handle is hit, foreward event to its smart tag + SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( pHdl ); + if(pSmartHdl && pSmartHdl->getTag().is() ) + { + SmartTagReference xTag( pSmartHdl->getTag() ); + return xTag->RequestHelp( rHEvt ); + } + } + + return false; +} + +// -------------------------------------------------------------------- + +/** returns true if the SmartTag consumes this event. */ +bool SmartTagSet::Command( const CommandEvent& rCEvt ) +{ + if( rCEvt.IsMouseEvent() ) + { + Point aMDPos( mrView.GetViewShell()->GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() ) ); + SdrHdl* pHdl = mrView.PickHandle(aMDPos); + + if( pHdl ) + { + // if a smart tag handle is hit, foreward event to its smart tag + SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( pHdl ); + if(pSmartHdl && pSmartHdl->getTag().is() ) + { + SmartTagReference xTag( pSmartHdl->getTag() ); + return xTag->Command( rCEvt ); + } + } + } else - return false; + { + if( mxSelectedTag.is() ) + return mxSelectedTag->Command( rCEvt ); + + } + + return false; } // -------------------------------------------------------------------- diff --git a/sd/source/ui/inc/AccessibleDrawDocumentView.hxx b/sd/source/ui/inc/AccessibleDrawDocumentView.hxx index f1635eb2f..c6404c2c0 100644 --- a/sd/source/ui/inc/AccessibleDrawDocumentView.hxx +++ b/sd/source/ui/inc/AccessibleDrawDocumentView.hxx @@ -166,6 +166,9 @@ protected: virtual void Deactivated (void); virtual void impl_dispose (void); + +private: + void UpdateAccessibleName (void); }; } // end of namespace accessibility diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 308ce5516..542d69738 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -59,6 +59,7 @@ class DrawView; class LayerTabBar; class Ruler; class SdUnoDrawView; +class AnnotationManager; #define CHECK_RANGE(nMin, nValue, nMax) ((nValue >= nMin) && (nValue <= nMax)) @@ -231,6 +232,9 @@ public: void AttrExec (SfxRequest& rReq); void AttrState (SfxItemSet& rSet); + void ExecuteAnnotation (SfxRequest& rRequest); + void GetAnnotationState (SfxItemSet& rItemSet); + void StartRulerDrag ( const Ruler& rRuler, const MouseEvent& rMEvt); @@ -391,7 +395,6 @@ protected: static BOOL mbPipette; - DECL_LINK( ClipboardChanged, TransferableDataHelper* ); DECL_LINK( CloseHdl, Timer* pTimer ); DECL_LINK( TabSplitHdl, TabBar * ); @@ -494,6 +497,8 @@ private: const Point& rMouseLocation); using ViewShell::Notify; + + ::std::auto_ptr< AnnotationManager > mpAnnotationManager; }; diff --git a/sd/source/ui/inc/EventMultiplexer.hxx b/sd/source/ui/inc/EventMultiplexer.hxx index 395c31103..9ba6cc036 100644 --- a/sd/source/ui/inc/EventMultiplexer.hxx +++ b/sd/source/ui/inc/EventMultiplexer.hxx @@ -92,9 +92,10 @@ public: */ static const EventId EID_PANE_MANAGER_DYING = 0x00000100; - /** The edit mode of the ViewShell in the center pane has been modified. + /** Edit mode was (or is being) switched to normal mode. Find + EID_EDIT_MODE_MASTER below. */ - static const EventId EID_EDIT_MODE = 0x00000200; + static const EventId EID_EDIT_MODE_NORMAL = 0x00000200; /** One or more pages have been inserted into or deleted from the model. */ @@ -134,6 +135,10 @@ public: */ static const EventId EID_CONFIGURATION_UPDATED = 0x00040000; + /** Edit mode was (or is being) switched to master mode. + */ + static const EventId EID_EDIT_MODE_MASTER = 0x00080000; + const ViewShellBase& mrBase; EventId meEventId; const void* mpUserData; diff --git a/sd/source/ui/inc/annotationmanager.hxx b/sd/source/ui/inc/annotationmanager.hxx new file mode 100644 index 000000000..ccafd372a --- /dev/null +++ b/sd/source/ui/inc/annotationmanager.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AnnotationManager.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SD_ANNOTATIONMANAGER_HXX +#define _SD_ANNOTATIONMANAGER_HXX + +#include <com/sun/star/office/XAnnotationAccess.hpp> +#include <memory> + +#include <rtl/ref.hxx> + +namespace sd +{ + +class ViewShellBase; +class AnnotationManagerImpl; + +// -------------------------------------------------------------------- + +class AnnotationManager +{ +public: + AnnotationManager( ViewShellBase& rViewShellBase ); + ~AnnotationManager(); + + void ExecuteAnnotation (SfxRequest& rRequest); + void GetAnnotationState (SfxItemSet& rItemSet); + +private: + ::rtl::Reference< AnnotationManagerImpl > mxImpl; +}; + +} + +#endif // _SD_ANNOTATIONMANAGER_HXX diff --git a/sd/source/ui/inc/framework/Pane.hxx b/sd/source/ui/inc/framework/Pane.hxx index d65843275..da9b88a22 100644 --- a/sd/source/ui/inc/framework/Pane.hxx +++ b/sd/source/ui/inc/framework/Pane.hxx @@ -34,19 +34,24 @@ #include "MutexOwner.hxx" #include <com/sun/star/drawing/framework/XPane.hpp> +#include <com/sun/star/drawing/framework/XPane2.hpp> #include <com/sun/star/drawing/framework/TabBarButton.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase3.hxx> #include <tools/link.hxx> #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> class Window; +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + namespace { -typedef ::cppu::WeakComponentImplHelper2 < +typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::drawing::framework::XPane, + ::com::sun::star::drawing::framework::XPane2, ::com::sun::star::lang::XUnoTunnel > PaneInterfaceBase; @@ -96,22 +101,39 @@ public: */ virtual ::Window* GetWindow (void); - // XPane + + //----- XPane ------------------------------------------------------------- /** For a UNO API based implementation of a view this may the most important method of this class because the view is only interested in the window of the pane. */ - virtual ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow> + virtual cssu::Reference<css::awt::XWindow> SAL_CALL getWindow (void) - throw (::com::sun::star::uno::RuntimeException); + throw (cssu::RuntimeException); - virtual ::com::sun::star::uno::Reference<com::sun::star::rendering::XCanvas> + virtual cssu::Reference<css::rendering::XCanvas> SAL_CALL getCanvas (void) - throw (::com::sun::star::uno::RuntimeException); + throw (cssu::RuntimeException); + + //----- XPane2 ------------------------------------------------------------- - // XResource + virtual sal_Bool SAL_CALL isVisible (void) + throw (cssu::RuntimeException); + + virtual void SAL_CALL setVisible (sal_Bool bIsVisible) + throw (cssu::RuntimeException); + + virtual cssu::Reference<css::accessibility::XAccessible> SAL_CALL getAccessible (void) + throw (cssu::RuntimeException); + + virtual void SAL_CALL setAccessible ( + const cssu::Reference<css::accessibility::XAccessible>& rxAccessible) + throw (cssu::RuntimeException); + + + //----- XResource --------------------------------------------------------- virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> SAL_CALL getResourceId (void) @@ -124,11 +146,12 @@ public: throw (com::sun::star::uno::RuntimeException); - // XUnoTunnel + //----- XUnoTunnel -------------------------------------------------------- virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId) throw (com::sun::star::uno::RuntimeException); + protected: ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> mxPaneId; ::Window* mpWindow; diff --git a/sd/source/ui/inc/optsitem.hxx b/sd/source/ui/inc/optsitem.hxx index 6670a2206..ed8fd7ff6 100644 --- a/sd/source/ui/inc/optsitem.hxx +++ b/sd/source/ui/inc/optsitem.hxx @@ -276,7 +276,8 @@ private: BOOL bShowUndoDeleteWarning : 1; // Misc/ShowUndoDeleteWarning // #i75315# BOOL bSlideshowRespectZOrder : 1; // Misc/SlideshowRespectZOrder - + BOOL bShowComments : 1; // Misc/ShowComments + sal_Bool bPreviewNewEffects; sal_Bool bPreviewChangedEffects; sal_Bool bPreviewTransitions; @@ -320,6 +321,7 @@ public: BOOL IsSolidDragging() const { Init(); return (BOOL) bSolidDragging; } BOOL IsSolidMarkHdl() const { Init(); return (BOOL) bSolidMarkHdl; } BOOL IsSummationOfParagraphs() const { Init(); return bSummationOfParagraphs != 0; }; + /** Return the currently selected printer independent layout mode. @return Returns 1 for printer independent layout enabled and 0 when it @@ -372,6 +374,9 @@ public: void SetPreviewNewEffects( sal_Bool bOn ) { if( bPreviewNewEffects != bOn ) { OptionsChanged(); bPreviewNewEffects = bOn; } } void SetPreviewChangedEffects( sal_Bool bOn ) { if( bPreviewChangedEffects != bOn ) { OptionsChanged(); bPreviewChangedEffects = bOn; } } void SetPreviewTransitions( sal_Bool bOn ) { if( bPreviewTransitions != bOn ) { OptionsChanged(); bPreviewTransitions = bOn; } } + + BOOL IsShowComments() const { Init(); return bShowComments; } + void SetShowComments( BOOL bShow ) { if( bShowComments != bShow ) { OptionsChanged(); bShowComments = bShow; } } }; // ----------------------------------------------------------------------------- diff --git a/sd/source/ui/inc/res_bmp.hrc b/sd/source/ui/inc/res_bmp.hrc index 676590d91..b27252778 100644 --- a/sd/source/ui/inc/res_bmp.hrc +++ b/sd/source/ui/inc/res_bmp.hrc @@ -237,6 +237,9 @@ #define BMP_FOIL_27 RID_SD_START+336 #define BMP_FOIL_27_H RID_SD_START+337 +#define BMP_COMMENTS_INDICATOR RID_SD_START+338 +#define BMP_COMMENTS_INDICATOR_H RID_SD_START+339 + // ----------------------------------------------------------------------------- #define IMG_PIPETTE_H RID_APP_START+21 diff --git a/sd/source/ui/inc/smarttag.hxx b/sd/source/ui/inc/smarttag.hxx index 4432dad12..fac631b68 100644 --- a/sd/source/ui/inc/smarttag.hxx +++ b/sd/source/ui/inc/smarttag.hxx @@ -67,6 +67,12 @@ public: /** returns true if the SmartTag consumes this event. */ virtual bool KeyInput( const KeyEvent& rKEvt ); + /** returns true if the SmartTag consumes this event. */ + virtual bool RequestHelp( const HelpEvent& rHEvt ); + + /** returns true if the SmartTag consumes this event. */ + virtual bool Command( const CommandEvent& rCEvt ); + /** returns true if this smart tag is currently selected */ bool isSelected() const; @@ -119,6 +125,12 @@ public: /** returns true if a SmartTag consumes this event. */ bool KeyInput( const KeyEvent& rKEvt ); + /** returns true if a SmartTag consumes this event. */ + bool RequestHelp( const HelpEvent& rHEvt ); + + /** returns true if a SmartTag consumes this event. */ + bool Command( const CommandEvent& rCEvt ); + /** disposes all smart tags and clears the set */ void Dispose(); diff --git a/sd/source/ui/inc/taskpane/TitleBar.hxx b/sd/source/ui/inc/taskpane/TitleBar.hxx index 0cb0a7e42..b5271e85c 100644 --- a/sd/source/ui/inc/taskpane/TitleBar.hxx +++ b/sd/source/ui/inc/taskpane/TitleBar.hxx @@ -92,6 +92,7 @@ public: virtual void Paint (const Rectangle& rBoundingBox); virtual bool Expand (bool bFlag = true); virtual bool IsExpanded (void) const; + virtual void SetEnabledState(bool bFlag);
void SetFocus (bool bFlag); diff --git a/sd/source/ui/inc/taskpane/TitledControl.hxx b/sd/source/ui/inc/taskpane/TitledControl.hxx index b9da6a971..8103c18ea 100644 --- a/sd/source/ui/inc/taskpane/TitledControl.hxx +++ b/sd/source/ui/inc/taskpane/TitledControl.hxx @@ -135,6 +135,8 @@ public: */ virtual bool IsExpandable (void) const; + virtual void SetEnabledState(bool bFlag);
+ /** Ownership of the given data remains with the caller. The data is thus not destroyed when the destructor of this class is called. diff --git a/sd/source/ui/notes/EditWindow.cxx b/sd/source/ui/notes/EditWindow.cxx index 917bc8001..90e3f3a3c 100755 --- a/sd/source/ui/notes/EditWindow.cxx +++ b/sd/source/ui/notes/EditWindow.cxx @@ -34,6 +34,8 @@ #include "EditWindow.hxx" #include "sdmod.hxx" +#include <i18npool/mslangid.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svx/editeng.hxx> #include <svx/editview.hxx> #include <vcl/scrbar.hxx> @@ -174,9 +176,9 @@ EditEngine* EditWindow::CreateEditEngine (void) { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE, DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL } }; - aTable[0].nLang = aOpt.nDefaultLanguage; - aTable[1].nLang = aOpt.nDefaultLanguage_CJK; - aTable[2].nLang = aOpt.nDefaultLanguage_CTL; + aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN); + aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN); + aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); // for (int i = 0; i < 3; ++i) { diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx index ef898549c..1ec20a11f 100644 --- a/sd/source/ui/presenter/PresenterTextView.cxx +++ b/sd/source/ui/presenter/PresenterTextView.cxx @@ -33,6 +33,7 @@ #include "PresenterTextView.hxx" +#include <i18npool/mslangid.hxx> #include <cppcanvas/vclfactory.hxx> #include <svtools/itempool.hxx> #include <svtools/itemset.hxx> @@ -52,6 +53,8 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/rendering/XSpriteCanvas.hpp> #include <com/sun/star/util/Color.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -381,9 +384,9 @@ EditEngine* PresenterTextView::Implementation::CreateEditEngine (void) { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE, DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL } }; - aTable[0].nLang = aOpt.nDefaultLanguage; - aTable[1].nLang = aOpt.nDefaultLanguage_CJK; - aTable[2].nLang = aOpt.nDefaultLanguage_CTL; + aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN); + aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN); + aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); // for (int i = 0; i < 3; ++i) { diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 15ebffe1b..c8355752c 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -603,11 +603,8 @@ IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent) break; case VCLEVENT_WINDOW_GETFOCUS: - // Show focus but only when the focus was not set to the - // window as a result of a mouse click. if (pActiveWindow != NULL && pWindow == pActiveWindow) - if (pWindow->GetPointerState().mnState==0) - GetFocusManager().ShowFocus(); + GetFocusManager().ShowFocus(); break; case VCLEVENT_WINDOW_LOSEFOCUS: diff --git a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx index fe459abb7..9cb8c7d38 100644 --- a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx @@ -205,6 +205,9 @@ void FocusManager::FocusPage (sal_Int32 nPageIndex) FocusHider aHider (*this); mnPageIndex = nPageIndex; } + + if (HasFocus() && !IsFocusShowing()) + ShowFocus(); } diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx index f46cb0641..2eac8b757 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -252,7 +252,7 @@ bool SelectionManager::MoveSelectedPages (const sal_Int32 nTargetPageIndex) else break; } - + // Prepare to select the moved pages. SelectionCommand* pCommand = new SelectionCommand( rSelector,mrController.GetCurrentSlideManager(),mrSlideSorter.GetModel()); @@ -292,6 +292,8 @@ void SelectionManager::SelectionHasChanged (const bool bMakeSelectionVisible) pViewShell->Invalidate (SID_SUMMARY_PAGE); pViewShell->Invalidate(SID_SHOW_SLIDE); pViewShell->Invalidate(SID_HIDE_SLIDE); + pViewShell->Invalidate(SID_DELETE_PAGE); + pViewShell->Invalidate(SID_DELETE_MASTER_PAGE); // StatusBar pViewShell->Invalidate (SID_STATUS_PAGE); @@ -384,7 +386,7 @@ Size SelectionManager::MakeSelectionVisible (const SelectionHint eSelectionHint) return MakeRectangleVisible(aSelectionBox); } - + return Size(0,0); } @@ -396,7 +398,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox) ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); if (pWindow == NULL) return Size(0,0); - + Rectangle aVisibleArea (pWindow->PixelToLogic( Rectangle( Point(0,0), @@ -435,7 +437,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox) 1000 : 0 ); } - + return Size(0,aVisibleArea.Top() - nNewTop); } else @@ -454,7 +456,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox) nNewLeft = rBox.Right() - aVisibleArea.GetWidth(); // otherwise we do not modify the visible area. } - + // Make some corrections of the new visible area. Rectangle aModelArea (mrSlideSorter.GetView().GetModelArea()); if (nNewLeft + aVisibleArea.GetWidth() > aModelArea.Right()) @@ -471,7 +473,7 @@ Size SelectionManager::MakeRectangleVisible (const Rectangle& rBox) 1000 : 0 ); } - + return Size(aVisibleArea.Left() - nNewLeft, 0); } } @@ -510,7 +512,7 @@ bool SelectionManager::DoesSelectionExceedVisibleArea (const Rectangle& rSelecti ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); if (pWindow == NULL) return true; - + Rectangle aVisibleArea (pWindow->PixelToLogic( Rectangle( Point(0,0), @@ -537,7 +539,7 @@ Rectangle SelectionManager::ResolveLargeSelection ( // not modified. model::SharedPageDescriptor pRecent ( mrController.GetPageSelector().GetMostRecentlySelectedPage()); - + // Get the bounding box of the page object on which to concentrate. model::SharedPageDescriptor pRepresentative; switch (eSelectionHint) @@ -566,9 +568,9 @@ Rectangle SelectionManager::ResolveLargeSelection ( view::SlideSorterView::BBT_INFO); } - - - + + + sal_Int32 SelectionManager::GetInsertionPosition (void) const { sal_Int32 nInsertionPosition (mnInsertionPosition); diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index dff6e004a..a55e8a5c9 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -145,7 +145,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest) case SID_PAGES_PER_ROW: if (rRequest.GetArgs() != NULL) { - SFX_REQUEST_ARG(rRequest, pPagesPerRow, SfxUInt16Item, + SFX_REQUEST_ARG(rRequest, pPagesPerRow, SfxUInt16Item, SID_PAGES_PER_ROW, FALSE); if (pPagesPerRow != NULL) { @@ -164,7 +164,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest) } rRequest.Done(); break; - + case SID_SELECTALL: mrSlideSorter.GetController().GetPageSelector().SelectAllPages(); rRequest.Done(); @@ -246,7 +246,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest) SFX_REQUEST_ARG (rRequest, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, FALSE); SFX_REQUEST_ARG (rRequest, pWhatLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, FALSE); pShell->mpImpl->AssignLayout( - pDocument->GetSdPage((USHORT)pWhatPage->GetValue(), + pDocument->GetSdPage((USHORT)pWhatPage->GetValue(), mrSlideSorter.GetModel().GetPageType()), (AutoLayout)pWhatLayout->GetValue()); rRequest.Done (); @@ -266,7 +266,7 @@ void SlotManager::FuPermanent (SfxRequest& rRequest) ViewShell* pShell = mrSlideSorter.GetViewShell(); if (pShell == NULL) return; - + if(pShell->GetCurrentFunction().is()) { FunctionReference xEmpty; @@ -312,7 +312,7 @@ void SlotManager::FuSupport (SfxRequest& rRequest) case SID_STYLE_FAMILY: if (rRequest.GetArgs() != NULL) { - SdDrawDocument* pDocument + SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); if (pDocument != NULL) { @@ -442,7 +442,7 @@ void SlotManager::ExecCtrl (SfxRequest& rRequest) rRequest.Done(); break; } - + case SID_SEARCH_DLG: // We have to handle the SID_SEARCH_DLG slot explicitly because // in some cases (when the slide sorter is displayed in the @@ -477,7 +477,7 @@ void SlotManager::GetAttrState (SfxItemSet& rSet) case SID_PAGES_PER_ROW: rSet.Put ( SfxUInt16Item ( - nSlotId, + nSlotId, (USHORT)mrSlideSorter.GetView().GetLayouter().GetColumnCount() ) ); @@ -515,7 +515,7 @@ void SlotManager::GetCtrlState (SfxItemSet& rSet) // Output quality. if (rSet.GetItemState(SID_OUTPUT_QUALITY_COLOR)==SFX_ITEM_AVAILABLE ||rSet.GetItemState(SID_OUTPUT_QUALITY_GRAYSCALE)==SFX_ITEM_AVAILABLE - ||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE + ||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE ||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE) { ULONG nMode = mrSlideSorter.GetView().GetWindow()->GetDrawMode(); @@ -537,13 +537,13 @@ void SlotManager::GetCtrlState (SfxItemSet& rSet) break; } - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR, + rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR, (BOOL)(nQuality==0))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE, + rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE, (BOOL)(nQuality==1))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE, + rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE, (BOOL)(nQuality==2))); - rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST, + rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST, (BOOL)(nQuality==3))); } @@ -551,8 +551,8 @@ void SlotManager::GetCtrlState (SfxItemSet& rSet) { rSet.Put (SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, TRUE)); } -} - +} + @@ -582,7 +582,7 @@ void SlotManager::GetMenuState ( SfxItemSet& rSet) rSet.DisableItem(SID_SPELL_DIALOG); rSet.DisableItem(SID_SEARCH_DLG); } - + if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE)) { bool bDisable = true; @@ -622,7 +622,7 @@ void SlotManager::GetMenuState ( SfxItemSet& rSet) { SdPage* pPage = aSelectedPages.GetNextElement()->GetPage(); SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE); - + if (pObj!=NULL && !pObj->IsEmptyPresObj()) bDisable = false; } @@ -678,15 +678,15 @@ void SlotManager::GetMenuState ( SfxItemSet& rSet) case HideSlideFunction::MIXED: // Show both entries. break; - + case HideSlideFunction::EXCLUDED: rSet.DisableItem(SID_HIDE_SLIDE); break; - + case HideSlideFunction::INCLUDED: rSet.DisableItem(SID_SHOW_SLIDE); break; - + case HideSlideFunction::UNDEFINED: rSet.DisableItem(SID_HIDE_SLIDE); rSet.DisableItem(SID_SHOW_SLIDE); @@ -703,13 +703,13 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) SdTransferable* pTransferClip = SD_MOD()->pTransferClip; if (rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_PASTE2) == SFX_ITEM_AVAILABLE) + || rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE) { // Keine eigenen Clipboard-Daten? if ( !pTransferClip || !pTransferClip->GetDocShell() ) { rSet.DisableItem(SID_PASTE); - rSet.DisableItem(SID_PASTE2); + rSet.DisableItem(SID_PASTE_SPECIAL); } else { @@ -718,7 +718,7 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) if( !pTransferDocShell || ( (DrawDocShell*) pTransferDocShell)->GetDoc()->GetPageCount() <= 1 ) { bool bIsPastingSupported (false); - + // No or just one page. Check if there is anything that can be // pasted via a DrawViewShell. ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); @@ -739,16 +739,16 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) if ( ! bIsPastingSupported) { rSet.DisableItem(SID_PASTE); - rSet.DisableItem(SID_PASTE2); + rSet.DisableItem(SID_PASTE_SPECIAL); } } } } - // Cut, copy and paste of master pages is not yet implemented properly + // Cut, copy and paste of master pages is not yet implemented properly if (rSet.GetItemState(SID_COPY) == SFX_ITEM_AVAILABLE || rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE - || rSet.GetItemState(SID_PASTE2) == SFX_ITEM_AVAILABLE + || rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE || rSet.GetItemState(SID_CUT) == SFX_ITEM_AVAILABLE) { if (mrSlideSorter.GetModel().GetEditMode() == EM_MASTERPAGE) @@ -759,8 +759,8 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) rSet.DisableItem(SID_COPY); if (rSet.GetItemState(SID_PASTE) == SFX_ITEM_AVAILABLE) rSet.DisableItem(SID_PASTE); - if (rSet.GetItemState(SID_PASTE2) == SFX_ITEM_AVAILABLE) - rSet.DisableItem(SID_PASTE2); + if (rSet.GetItemState(SID_PASTE_SPECIAL) == SFX_ITEM_AVAILABLE) + rSet.DisableItem(SID_PASTE_SPECIAL); } } @@ -780,7 +780,7 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) rSet.DisableItem(SID_COPY); bool bDisable = false; - // The operations that lead to the deletion of a page are valid if + // The operations that lead to the deletion of a page are valid if // a) there is at least one selected page // b) deleting the selected pages leaves at least one page in the // document @@ -845,7 +845,7 @@ void SlotManager::GetStatusBarState (SfxItemSet& rSet) pPage = aSelectedPages.GetNextElement()->GetPage(); nFirstPage = pPage->GetPageNum()/2; pFirstPage = pPage; - + aPageStr += sal_Unicode(' '); aPageStr += String::CreateFromInt32( nFirstPage + 1 ); aPageStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " )); @@ -871,7 +871,7 @@ void SlotManager::ShowSlideShow( SfxRequest& rReq) if( xPresentation.is() ) { if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) ) - xPresentation->start(); + xPresentation->start(); else xPresentation->rehearseTimings(); } @@ -904,7 +904,7 @@ void SlotManager::RenameSlide (void) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); DBG_ASSERT(pFact, "Dialogdiet fail!"); AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( - mrSlideSorter.GetActiveWindow(), + mrSlideSorter.GetActiveWindow(), aPageName, aDescr, RID_SVXDLG_NAME); DBG_ASSERT(aNameDlg, "Dialogdiet fail!"); aNameDlg->SetText( aTitle ); @@ -918,7 +918,7 @@ void SlotManager::RenameSlide (void) if( ! aNewName.Equals( aPageName ) ) { #ifdef DBG_UTIL - bool bResult = + bool bResult = #endif RenameSlideFromDrawViewShell( pSelectedPage->GetPageNum()/2, aNewName ); @@ -963,9 +963,9 @@ bool SlotManager::RenameSlideFromDrawViewShell( USHORT nPageId, const String & r SdPage* pPageToRename = NULL; PageKind ePageKind = mrSlideSorter.GetModel().GetPageType(); - + SfxUndoManager* pManager = pDocument->GetDocSh()->GetUndoManager(); - + if( mrSlideSorter.GetModel().GetEditMode() == EM_PAGE ) { model::SharedPageDescriptor pDescriptor ( @@ -1121,7 +1121,7 @@ void SlotManager::InsertSlide (SfxRequest& rRequest) if (pShell != NULL) { pShell->CreateOrDuplicatePage ( - rRequest, + rRequest, mrSlideSorter.GetModel().GetPageType(), pPreviousPage); } diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx index 62a96f9ba..4d0280e43 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx @@ -194,14 +194,6 @@ void SlideSorter::Init (void) // Set view pointer of base class. SetupControls(pParentWindow); - // For accessibility we have to shortly hide the content window. - // This triggers the construction of a new accessibility object for - // the new view shell. (One is created earlier while the construtor - // of the base class is executed. At that time the correct - // accessibility object can not be constructed.) - pWindow->Hide(); - pWindow->Show(); - mbIsValid = true; } } diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx index ae92206da..1559d536c 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -185,6 +185,18 @@ void SlideSorterViewShell::Initialize (void) mpVerticalScrollBar, mpScrollBarBox); mpView = &mpSlideSorter->GetView(); + + // For accessibility we have to shortly hide the content window. + // This triggers the construction of a new accessibility object for + // the new view shell. (One is created earlier while the construtor + // of the base class is executed. At that time the correct + // accessibility object can not be constructed.) + ::Window* pWindow = mpSlideSorter->GetActiveWindow(); + if (pWindow != NULL) + { + pWindow->Hide(); + pWindow->Show(); + } } diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index 424b9c2c5..f067e879d 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -108,8 +108,6 @@ SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter) maModelBorder(), meOrientation(VERTICAL) { - maPageModel.GetItemPool().FreezeIdRanges(); - // Hide the page that contains the page objects. SetPageVisible (FALSE); diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectViewObjectContact.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectViewObjectContact.cxx index 80bcca168..a5d861a86 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectViewObjectContact.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectViewObjectContact.cxx @@ -520,6 +520,7 @@ class SdPageObjectFocusPrimitive : public SdPageObjectBasePrimitive private: /// Gap between border of page object and inside of focus rectangle. static const sal_Int32 mnFocusIndicatorOffset; + const bool mbContrastToSelected; protected: // method which is to be used to implement the local decomposition of a 2D primitive. @@ -527,7 +528,7 @@ protected: public: // constructor and destructor - SdPageObjectFocusPrimitive(const basegfx::B2DRange& rRange); + SdPageObjectFocusPrimitive(const basegfx::B2DRange& rRange, const bool bContrast); ~SdPageObjectFocusPrimitive(); // provide unique ID @@ -556,19 +557,26 @@ Primitive2DSequence SdPageObjectFocusPrimitive::createLocalDecomposition(const d // create polygon const basegfx::B2DPolygon aIndicatorPolygon(basegfx::tools::createPolygonFromRect(aFocusIndicatorRange)); - // white rectangle + const StyleSettings& rStyleSettings(Application::GetSettings().GetStyleSettings()); + + // "background" rectangle + const Color aBackgroundColor(mbContrastToSelected ? rStyleSettings.GetMenuHighlightColor() : rStyleSettings.GetWindowColor()); xRetval[0] = Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aIndicatorPolygon, Color(COL_WHITE).getBColor())); // dotted black rectangle with same geometry ::std::vector< double > aDotDashArray; - aDotDashArray.push_back(aDiscretePixel.getX()); - aDotDashArray.push_back(aDiscretePixel.getX()); + const sal_Int32 nFocusIndicatorWidth (3); + aDotDashArray.push_back(nFocusIndicatorWidth *aDiscretePixel.getX()); + aDotDashArray.push_back(nFocusIndicatorWidth * aDiscretePixel.getX()); // prepare line and stroke attributes - const drawinglayer::attribute::LineAttribute aLineAttribute(Color(COL_BLACK).getBColor()); - const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(aDotDashArray, 2.0 * aDiscretePixel.getX()); + const Color aLineColor(mbContrastToSelected ? rStyleSettings.GetMenuHighlightTextColor() : rStyleSettings.GetWindowTextColor()); + const drawinglayer::attribute::LineAttribute aLineAttribute(aLineColor.getBColor()); + const drawinglayer::attribute::StrokeAttribute aStrokeAttribute( + aDotDashArray, 2.0 * nFocusIndicatorWidth * aDiscretePixel.getX()); + xRetval[1] = Primitive2DReference( new drawinglayer::primitive2d::PolygonStrokePrimitive2D(aIndicatorPolygon, aLineAttribute, aStrokeAttribute)); @@ -576,8 +584,9 @@ Primitive2DSequence SdPageObjectFocusPrimitive::createLocalDecomposition(const d return xRetval; } -SdPageObjectFocusPrimitive::SdPageObjectFocusPrimitive(const basegfx::B2DRange& rRange) -: SdPageObjectBasePrimitive(rRange) +SdPageObjectFocusPrimitive::SdPageObjectFocusPrimitive(const basegfx::B2DRange& rRange, const bool bContrast) + : SdPageObjectBasePrimitive(rRange), + mbContrastToSelected(bContrast) { } @@ -596,12 +605,16 @@ private: /// Size of width and height of the fade effect indicator in pixels. static const sal_Int32 mnFadeEffectIndicatorOffset; + /// Size of width and height of the comments indicator in pixels. + static const sal_Int32 mnCommentsIndicatorOffset; + /// Gap between border of page object and number rectangle. static const sal_Int32 mnPageNumberOffset; - /// the FadeEffect bitmap. Static since it is usable outside this primitive + /// the indicator bitmaps. Static since it is usable outside this primitive /// for size comparisons static BitmapEx* mpFadeEffectIconBitmap; + static BitmapEx* mpCommentsIconBitmap; /// page name, number and needed infos String maPageName; @@ -611,10 +624,12 @@ private: // bitfield bool mbShowFadeEffectIcon : 1; + bool mbShowCommentsIcon : 1; bool mbExcluded : 1; // private helpers const BitmapEx& getFadeEffectIconBitmap() const; + const BitmapEx& getCommentsIconBitmap() const; protected: // method which is to be used to implement the local decomposition of a 2D primitive. @@ -629,6 +644,7 @@ public: const Font& rPageNameFont, const Size& rPageNumberAreaModelSize, bool bShowFadeEffectIcon, + bool bShowCommentsIcon, bool bExcluded); ~SdPageObjectFadeNameNumberPrimitive(); @@ -638,6 +654,7 @@ public: const Font& getPageNameFont() const { return maPageNameFont; } const Size& getPageNumberAreaModelSize() const { return maPageNumberAreaModelSize; } bool getShowFadeEffectIcon() const { return mbShowFadeEffectIcon; } + bool getShowCommentsIcon() const { return mbShowCommentsIcon; } bool getExcluded() const { return mbExcluded; } // compare operator @@ -666,6 +683,24 @@ const BitmapEx& SdPageObjectFadeNameNumberPrimitive::getFadeEffectIconBitmap() c return *mpFadeEffectIconBitmap; } +const sal_Int32 SdPageObjectFadeNameNumberPrimitive::mnCommentsIndicatorOffset(9); +BitmapEx* SdPageObjectFadeNameNumberPrimitive::mpCommentsIconBitmap = 0; + +const BitmapEx& SdPageObjectFadeNameNumberPrimitive::getCommentsIconBitmap() const +{ + if(mpCommentsIconBitmap == NULL) + { + // prepare CommentsIconBitmap on demand + const sal_uInt16 nIconId(Application::GetSettings().GetStyleSettings().GetHighContrastMode() + ? BMP_COMMENTS_INDICATOR_H + : BMP_COMMENTS_INDICATOR); + const BitmapEx aCommentsIconBitmap(IconCache::Instance().GetIcon(nIconId).GetBitmapEx()); + const_cast< SdPageObjectFadeNameNumberPrimitive* >(this)->mpCommentsIconBitmap = new BitmapEx(aCommentsIconBitmap); + } + + return *mpCommentsIconBitmap; +} + Primitive2DSequence SdPageObjectFadeNameNumberPrimitive::createLocalDecomposition(const drawinglayer::geometry::ViewInformation2D& rViewInformation) const { const xub_StrLen nTextLength(getPageName().Len()); @@ -691,15 +726,13 @@ Primitive2DSequence SdPageObjectFadeNameNumberPrimitive::createLocalDecompositio aTextLayouter.setFont(getPageNameFont()); // get font attributes - ::basegfx::B2DVector aTextSizeAttribute; - const drawinglayer::primitive2d::FontAttributes aFontAttributes(drawinglayer::primitive2d::getFontAttributesFromVclFont( - aTextSizeAttribute, - getPageNameFont(), - false, - false)); - - // prepare DXTextArray (can be empty one) - const ::std::vector< double > aDXArray; + basegfx::B2DVector aTextSizeAttribute; + const drawinglayer::primitive2d::FontAttributes aFontAttributes( + drawinglayer::primitive2d::getFontAttributesFromVclFont( + aTextSizeAttribute, + getPageNameFont(), + false, + false)); // prepare locale; this may need some more information in the future const ::com::sun::star::lang::Locale aLocale; @@ -783,16 +816,27 @@ Primitive2DSequence SdPageObjectFadeNameNumberPrimitive::createLocalDecompositio } // fill text matrix - ::basegfx::B2DHomMatrix aTextMatrix; + basegfx::B2DHomMatrix aTextMatrix; + + aTextMatrix.set(0, 0, aTextSizeAttribute.getX()); + aTextMatrix.set(1, 1, aTextSizeAttribute.getY()); + aTextMatrix.set(0, 2, fStartX); + aTextMatrix.set(1, 2, fStartY); - aTextMatrix.set(0L, 0L, aTextSizeAttribute.getX()); - aTextMatrix.set(1L, 1L, aTextSizeAttribute.getY()); - aTextMatrix.set(0L, 2L, fStartX); - aTextMatrix.set(1L, 2L, fStartY); + // prepare DXTextArray (can be empty one) + const ::std::vector< double > aDXArray; // create Text primitive and add to target - xRetval[nInsert++] = Primitive2DReference(new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - aTextMatrix, aPageName, 0, aPageName.Len(), aDXArray, aFontAttributes, aLocale, aFontColor)); + xRetval[nInsert++] = Primitive2DReference( + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aTextMatrix, + aPageName, + 0, + aPageName.Len(), + aDXArray, + aFontAttributes, + aLocale, + aFontColor)); } { @@ -813,16 +857,27 @@ Primitive2DSequence SdPageObjectFadeNameNumberPrimitive::createLocalDecompositio const double fStartY(aNumberRange.getMinY() + fTextHeight + aDiscretePixel.getX()); // fill text matrix - ::basegfx::B2DHomMatrix aTextMatrix; + basegfx::B2DHomMatrix aTextMatrix; + + aTextMatrix.set(0, 0, aTextSizeAttribute.getX()); + aTextMatrix.set(1, 1, aTextSizeAttribute.getY()); + aTextMatrix.set(0, 2, fStartX); + aTextMatrix.set(1, 2, fStartY); - aTextMatrix.set(0L, 0L, aTextSizeAttribute.getX()); - aTextMatrix.set(1L, 1L, aTextSizeAttribute.getY()); - aTextMatrix.set(0L, 2L, fStartX); - aTextMatrix.set(1L, 2L, fStartY); + // prepare DXTextArray (can be empty one) + const ::std::vector< double > aDXArray; // create Text primitive - xRetval[nInsert++] = Primitive2DReference(new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - aTextMatrix, aPageNumber, 0, nNumberLen, aDXArray, aFontAttributes, aLocale, aFontColor)); + xRetval[nInsert++] = Primitive2DReference( + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aTextMatrix, + aPageNumber, + 0, + nNumberLen, + aDXArray, + aFontAttributes, + aLocale, + aFontColor)); if(getExcluded()) { @@ -851,6 +906,7 @@ SdPageObjectFadeNameNumberPrimitive::SdPageObjectFadeNameNumberPrimitive( const Font& rPageNameFont, const Size& rPageNumberAreaModelSize, bool bShowFadeEffectIcon, + bool bShowCommentsIcon, bool bExcluded) : SdPageObjectBasePrimitive(rRange), maPageName(rPageName), @@ -858,6 +914,7 @@ SdPageObjectFadeNameNumberPrimitive::SdPageObjectFadeNameNumberPrimitive( maPageNameFont(rPageNameFont), maPageNumberAreaModelSize(rPageNumberAreaModelSize), mbShowFadeEffectIcon(bShowFadeEffectIcon), + mbShowCommentsIcon(bShowCommentsIcon), mbExcluded(bExcluded) { } @@ -965,6 +1022,7 @@ Primitive2DSequence PageObjectViewObjectContact::createPrimitive2DSequence(const sal_uInt32 nPageNumber(0); Size aPageNumberAreaModelSize; bool bShowFadeEffectIcon(false); + bool bShowCommentsIcon(false); bool bExcluded(false); if(GetPage()) @@ -976,6 +1034,8 @@ Primitive2DSequence PageObjectViewObjectContact::createPrimitive2DSequence(const { bShowFadeEffectIcon = true; } + + bShowCommentsIcon = !pPage->getAnnotations().empty(); // prepare PageName, PageNumber, font and AreaModelSize aPageName = pPage->GetName(); @@ -1030,6 +1090,7 @@ Primitive2DSequence PageObjectViewObjectContact::createPrimitive2DSequence(const aPageNameFont, aPageNumberAreaModelSize, bShowFadeEffectIcon, + bShowCommentsIcon, bExcluded)); } @@ -1042,7 +1103,7 @@ Primitive2DSequence PageObjectViewObjectContact::createPrimitive2DSequence(const if(bCreateFocused) { // add focus indicator if used - xRetval[nInsert++] = Primitive2DReference(new SdPageObjectFocusPrimitive(aInnerRange)); + xRetval[nInsert++] = Primitive2DReference(new SdPageObjectFocusPrimitive(aInnerRange, bCreateSelected)); } return xRetval; diff --git a/sd/source/ui/toolpanel/LayoutMenu.cxx b/sd/source/ui/toolpanel/LayoutMenu.cxx index 8338af084..7b479e102 100644 --- a/sd/source/ui/toolpanel/LayoutMenu.cxx +++ b/sd/source/ui/toolpanel/LayoutMenu.cxx @@ -63,6 +63,7 @@ #include <vcl/image.hxx> #include <svtools/languageoptions.hxx> #include <sfx2/app.hxx> +#include "taskpane/TitledControl.hxx"
#include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> #include <comphelper/processfactory.hxx> @@ -259,7 +260,9 @@ LayoutMenu::LayoutMenu ( | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED - | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED); + | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED + | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL + | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER); SetSmartHelpId(SmartId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS)); SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE)); @@ -418,6 +421,74 @@ bool LayoutMenu::IsResizable (void) +void LayoutMenu::UpdateEnabledState (const MasterMode eMode) +{ + bool bIsEnabled (false); + + ::boost::shared_ptr<ViewShell> pMainViewShell (mrBase.GetMainViewShell()); + if (pMainViewShell) + { + switch (pMainViewShell->GetShellType()) + { + case ViewShell::ST_NONE: + case ViewShell::ST_OUTLINE: + case ViewShell::ST_PRESENTATION: + case ViewShell::ST_TASK_PANE: + // The complete task pane is disabled for these values or + // not even visible. Disabling the LayoutMenu would be + // logical but unnecessary. The main disadvantage is that + // after re-enabling it (typically) another panel is + // expanded. + bIsEnabled = true; + break; + + case ViewShell::ST_DRAW: + case ViewShell::ST_IMPRESS: + { + switch (eMode) + { + case MM_UNKNOWN: + { + ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( + ::boost::dynamic_pointer_cast<DrawViewShell>(pMainViewShell)); + if (pDrawViewShell) + bIsEnabled = pDrawViewShell->GetEditMode() != EM_MASTERPAGE; + break; + } + case MM_NORMAL: + bIsEnabled = true; + break; + + case MM_MASTER: + bIsEnabled = false; + break; + } + break; + } + + case ViewShell::ST_HANDOUT: + case ViewShell::ST_NOTES: + case ViewShell::ST_SLIDE_SORTER: + default: + bIsEnabled = true; + break; + } + + TreeNode* pParentNode = GetParentNode(); + if (pParentNode != NULL) + { + TitledControl* pGrandParentNode + = dynamic_cast<TitledControl*>(pParentNode->GetParentNode()); + if (pGrandParentNode != NULL) + pGrandParentNode->SetEnabledState(bIsEnabled); + } + + } +} + + + + ::Window* LayoutMenu::GetWindow (void) { return this; @@ -907,12 +978,14 @@ void LayoutMenu::UpdateSelection (void) // Find the entry of the menu for to the layout. USHORT nItemCount (GetItemCount()); for (USHORT nId=1; nId<=nItemCount; nId++) + { if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) { SelectItem(nId); bItemSelected = true; break; } + } } while (false); @@ -935,6 +1008,7 @@ IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEve case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: mbIsMainViewChangePending = true; + UpdateEnabledState(MM_UNKNOWN); break; case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: @@ -949,6 +1023,14 @@ IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEve } break; + case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL: + UpdateEnabledState(MM_NORMAL); + break; + + case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER: + UpdateEnabledState(MM_MASTER); + break; + default: /* Ignored */ break; diff --git a/sd/source/ui/toolpanel/LayoutMenu.hxx b/sd/source/ui/toolpanel/LayoutMenu.hxx index aad1dd05f..f866ce46b 100644 --- a/sd/source/ui/toolpanel/LayoutMenu.hxx +++ b/sd/source/ui/toolpanel/LayoutMenu.hxx @@ -131,6 +131,18 @@ public: void Execute (SfxRequest& rRequest); void GetState (SfxItemSet& rItemSet); + /** The LayoutMenu does not support some main views. In this case the + LayoutMenu is disabled. This state is updated in this method. + @param eMode + On some occasions the edit mode is being switched when this + method is called can not (yet) be reliably detected. Luckily, + in these cases the new value is provided by some broadcaster. + On other occasions the edit mode is not modified and is also not + provided. Therefore the Unknown value. + */ + enum MasterMode { MM_NORMAL, MM_MASTER, MM_UNKNOWN }; + void UpdateEnabledState (const MasterMode eMode); + /** Call this method when the set of displayed layouts is not up-to-date anymore. It will re-assemple this set according to the current settings. diff --git a/sd/source/ui/toolpanel/TaskPaneShellManager.cxx b/sd/source/ui/toolpanel/TaskPaneShellManager.cxx index b668403c9..adb534c6e 100644 --- a/sd/source/ui/toolpanel/TaskPaneShellManager.cxx +++ b/sd/source/ui/toolpanel/TaskPaneShellManager.cxx @@ -79,8 +79,18 @@ void TaskPaneShellManager::ReleaseShell (SfxShell* ) // Nothing to do. } +// hack for annotation panel, better fix? +void TaskPaneShellManager_AddSubShell ( TaskPaneShellManager* pManager, sal_Int32 nId, SfxShell* pShell, ::Window* pWindow ) +{ + if( pManager != NULL ) + pManager->AddSubShell( (ShellId)nId, pShell, pWindow ); +} - +void TaskPaneShellManager_RemoveSubShell ( TaskPaneShellManager* pManager, const SfxShell* pShell) +{ + if( pManager != NULL ) + pManager->RemoveSubShell( pShell ); +} void TaskPaneShellManager::AddSubShell ( ShellId nId, diff --git a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx b/sd/source/ui/toolpanel/TaskPaneViewShell.cxx index df81def93..8ece51521 100644 --- a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx +++ b/sd/source/ui/toolpanel/TaskPaneViewShell.cxx @@ -107,7 +107,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using ::sd::framework::FrameworkHelper; - namespace sd { namespace toolpanel { SFX_IMPL_INTERFACE(TaskPaneViewShell, SfxShell, SdResId(STR_TASKPANEVIEWSHELL)) diff --git a/sd/source/ui/toolpanel/TitleBar.cxx b/sd/source/ui/toolpanel/TitleBar.cxx index f401371f5..85c8d0ee7 100644 --- a/sd/source/ui/toolpanel/TitleBar.cxx +++ b/sd/source/ui/toolpanel/TitleBar.cxx @@ -216,6 +216,14 @@ bool TitleBar::IsExpanded (void) const } +void TitleBar::SetEnabledState(bool bFlag)
+{
+ if(bFlag)
+ Enable();
+ else
+ Disable();
+ Invalidate ();
+}
void TitleBar::SetFocus (bool bFlag) @@ -454,15 +462,21 @@ void TitleBar::PaintText (const Rectangle& rTextBox) USHORT TitleBar::GetTextStyle (void) { - return TEXT_DRAW_LEFT - | TEXT_DRAW_TOP - | TEXT_DRAW_MULTILINE - | TEXT_DRAW_WORDBREAK; + if(IsEnabled())
+ {
+ return TEXT_DRAW_LEFT
+ | TEXT_DRAW_TOP
+ | TEXT_DRAW_MULTILINE
+ | TEXT_DRAW_WORDBREAK;
+ }
+ else
+ {
+ return TEXT_DRAW_DISABLE;
+ }
} - void TitleBar::PaintBackground (const Rectangle& rTitleBarBox) { // Fill a slightly rounded rectangle. diff --git a/sd/source/ui/toolpanel/TitledControl.cxx b/sd/source/ui/toolpanel/TitledControl.cxx index f0280967d..ccd85fc72 100644 --- a/sd/source/ui/toolpanel/TitledControl.cxx +++ b/sd/source/ui/toolpanel/TitledControl.cxx @@ -292,7 +292,7 @@ bool TitledControl::Expand (bool bExpanded) { bool bExpansionStateChanged (false); - if (IsExpandable()) + if (IsExpandable() && IsEnabled()) { if (GetTitleBar()->IsExpanded() != bExpanded) bExpansionStateChanged |= GetTitleBar()->Expand (bExpanded); @@ -338,6 +338,27 @@ bool TitledControl::IsExpanded (void) const return false; } +void TitledControl::SetEnabledState(bool bFlag)
+{
+ if (!bFlag)
+ {
+ GetParentNode()->GetControlContainer().SetExpansionState (
+ this,
+ ControlContainer::ES_COLLAPSE);
+ Disable();
+ }
+ else
+ {
+/*
+ GetParentNode()->GetControlContainer().SetExpansionState (
+ this,
+ ControlContainer::ES_EXPAND);
+*/
+ Enable();
+ }
+
+ GetTitleBar()->SetEnabledState(bFlag);
+}
@@ -406,7 +427,8 @@ IMPL_LINK(TitledControl, WindowEventListener, switch (pWindowEvent->GetId()) { case VCLEVENT_WINDOW_MOUSEBUTTONUP: - (*mpClickHandler)(*this); + if (IsEnabled()) + (*mpClickHandler)(*this); break; } } diff --git a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx index 3200e3c63..1389e62a3 100644 --- a/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx +++ b/sd/source/ui/toolpanel/controls/CurrentMasterPagesSelector.cxx @@ -74,7 +74,8 @@ CurrentMasterPagesSelector::CurrentMasterPagesSelector ( Link aLink (LINK(this,CurrentMasterPagesSelector,EventMultiplexerListener)); rBase.GetEventMultiplexer()->AddEventListener(aLink, sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE - | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE + | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL + | sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER | sd::tools::EventMultiplexerEvent::EID_PAGE_ORDER | sd::tools::EventMultiplexerEvent::EID_SHAPE_CHANGED | sd::tools::EventMultiplexerEvent::EID_SHAPE_INSERTED @@ -282,7 +283,8 @@ IMPL_LINK(CurrentMasterPagesSelector,EventMultiplexerListener, switch (pEvent->meEventId) { case sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE: - case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE: + case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL: + case sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER: case sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION: UpdateSelection(); break; diff --git a/sd/source/ui/toolpanel/controls/makefile.mk b/sd/source/ui/toolpanel/controls/makefile.mk index 4741144ca..3664e852f 100644 --- a/sd/source/ui/toolpanel/controls/makefile.mk +++ b/sd/source/ui/toolpanel/controls/makefile.mk @@ -66,7 +66,6 @@ SLOFILES = \ $(SLO)$/TableDesignPanel.obj \ $(SLO)$/AnimationSchemesPanel.obj - # --- Tagets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/sd/source/ui/tools/EventMultiplexer.cxx b/sd/source/ui/tools/EventMultiplexer.cxx index 287ac9aee..54b47f67b 100644 --- a/sd/source/ui/tools/EventMultiplexer.cxx +++ b/sd/source/ui/tools/EventMultiplexer.cxx @@ -570,7 +570,12 @@ void SAL_CALL EventMultiplexer::Implementation::propertyChange ( } else if (rEvent.PropertyName.equals(msEditModePropertyName)) { - CallListeners(EventMultiplexerEvent::EID_EDIT_MODE); + bool bIsMasterPageMode (false); + rEvent.NewValue >>= bIsMasterPageMode; + if (bIsMasterPageMode) + CallListeners(EventMultiplexerEvent::EID_EDIT_MODE_MASTER); + else + CallListeners(EventMultiplexerEvent::EID_EDIT_MODE_NORMAL); } } @@ -783,8 +788,9 @@ void EventMultiplexer::Implementation::CallListeners ( void EventMultiplexer::Implementation::CallListeners (EventMultiplexerEvent& rEvent) { - ListenerList::const_iterator iListener (maListeners.begin()); - ListenerList::const_iterator iListenerEnd (maListeners.end()); + ListenerList aCopyListeners( maListeners ); + ListenerList::iterator iListener (aCopyListeners.begin()); + ListenerList::const_iterator iListenerEnd (aCopyListeners.end()); for (; iListener!=iListenerEnd; ++iListener) { if ((iListener->second && rEvent.meEventId) != 0) diff --git a/sd/source/ui/unoidl/sddetect.cxx b/sd/source/ui/unoidl/sddetect.cxx index 0974ce6b8..7e082a514 100644 --- a/sd/source/ui/unoidl/sddetect.cxx +++ b/sd/source/ui/unoidl/sddetect.cxx @@ -244,7 +244,7 @@ SdFilterDetect::~SdFilterDetect() { // PowerPoint needs to be detected via StreamName, all other storage based formats are our own and can // be detected by the ClipboardId, so except for the PPT filter all filters must have a ClipboardId set - uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage(); + uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage( sal_False ); //TODO/LATER: move error handling to central place! (maybe even complete own filters) if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE ) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index e04a6e763..0d96cbfcc 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3030,3 +3030,14 @@ void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEvent xModel->notifyEvent(aEvent ); } } + +void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const uno::Reference< uno::XInterface >& xSource ) +{ + rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) ); + + if( xModel.is() ) + { + ::com::sun::star::document::EventObject aEvent( xSource, rEventName ); + xModel->notifyEvent(aEvent ); + } +} diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index e7a52986b..7a88d6261 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -1007,8 +1007,11 @@ sal_Bool SdXShape::IsEmptyPresObj() const throw() if( pParaObj ) { delete pParaObj; - return sal_True; } + else + { + return sal_True; + } } return sal_False; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index e703853ae..8a8880d39 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -106,6 +106,12 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::container; using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::office; + +namespace sd { +extern Reference< XAnnotation > createAnnotation( const Reference< XComponentContext >& xContext, SdPage* ); +extern Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& ); +} /* this are the ids for page properties */ enum WID_PAGE @@ -519,6 +525,10 @@ Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType ) else QUERYINT( drawing::XShapeCombiner ); else QUERYINT( drawing::XShapeBinder ); else QUERYINT( beans::XMultiPropertySet ); + else if( rType == ITYPE( office::XAnnotationAccess ) ) + { + return Any( Reference< office::XAnnotationAccess >( this ) ); + } else if( rType == ITYPE( XAnimationNodeSupplier ) ) { if( mbIsImpressDocument ) @@ -2036,7 +2046,7 @@ Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeExceptio // Collect the types of this class. ::std::vector<uno::Type> aTypes; - aTypes.reserve(11); + aTypes.reserve(13); aTypes.push_back(ITYPE(drawing::XDrawPage)); aTypes.push_back(ITYPE(beans::XPropertySet)); aTypes.push_back(ITYPE(container::XNamed)); @@ -2046,6 +2056,7 @@ Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeExceptio aTypes.push_back(ITYPE(document::XLinkTargetSupplier)); aTypes.push_back(ITYPE( drawing::XShapeCombiner )); aTypes.push_back(ITYPE( drawing::XShapeBinder )); + aTypes.push_back(ITYPE( office::XAnnotationAccess )); aTypes.push_back(ITYPE( beans::XMultiPropertySet )); if( bPresPage ) aTypes.push_back(ITYPE(presentation::XPresentationPage)); @@ -2526,6 +2537,27 @@ void SdDrawPage::setBackground( const Any& rValue ) // pPage->SendRepaintBroadcast(); } +// XAnnotationAccess: +Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() throw (RuntimeException) +{ + if( !GetPage() ) + throw DisposedException(); + + Reference< XAnnotation > xRet; + GetPage()->createAnnotation(xRet); + return xRet; +} + +void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) throw (RuntimeException, IllegalArgumentException) +{ + GetPage()->removeAnnotation(annotation); +} + +Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() throw (RuntimeException) +{ + return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() ); +} + void SdDrawPage::getBackground( Any& rValue ) throw() { SdrObject* pObj = GetPage()->GetBackgroundObj(); @@ -2698,7 +2730,7 @@ Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeExcept // Collect the types of this class. ::std::vector<uno::Type> aTypes; - aTypes.reserve(10); + aTypes.reserve(12); aTypes.push_back(ITYPE(drawing::XDrawPage)); aTypes.push_back(ITYPE(beans::XPropertySet)); aTypes.push_back(ITYPE(container::XNamed)); @@ -2707,6 +2739,7 @@ Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeExcept aTypes.push_back(ITYPE(document::XLinkTargetSupplier)); aTypes.push_back(ITYPE( drawing::XShapeCombiner )); aTypes.push_back(ITYPE( drawing::XShapeBinder )); + aTypes.push_back(ITYPE( office::XAnnotationAccess )); aTypes.push_back(ITYPE( beans::XMultiPropertySet )); if( bPresPage ) aTypes.push_back(ITYPE(presentation::XPresentationPage)); diff --git a/sd/source/ui/unoidl/unopage.hxx b/sd/source/ui/unoidl/unopage.hxx index faece948c..c5bf5b213 100644 --- a/sd/source/ui/unoidl/unopage.hxx +++ b/sd/source/ui/unoidl/unopage.hxx @@ -37,6 +37,8 @@ #include <com/sun/star/presentation/XPresentationPage.hpp> #include <com/sun/star/animations/XAnimationNodeSupplier.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/office/XAnnotationAccess.hpp> + #include <svtools/itemprop.hxx> #ifndef _SVX_UNOPAGE_HXX @@ -69,6 +71,7 @@ class SdGenericDrawPage : public SvxFmDrawPage, public ::com::sun::star::beans::XPropertySet, public ::com::sun::star::beans::XMultiPropertySet, public ::com::sun::star::animations::XAnimationNodeSupplier, + public ::com::sun::star::office::XAnnotationAccess, public ::com::sun::star::document::XLinkTargetSupplier { private: @@ -158,6 +161,11 @@ public: // XAnimationNodeSupplier virtual ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > SAL_CALL getAnimationNode( ) throw (::com::sun::star::uno::RuntimeException); + + // XAnnotationAccess: + virtual ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > SAL_CALL createAndInsertAnnotation() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAnnotation(const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation > & annotation) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotationEnumeration > SAL_CALL createAnnotationEnumeration() throw (::com::sun::star::uno::RuntimeException); }; /*********************************************************************** diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index fd4557758..d30ba6898 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -194,10 +194,8 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) setPropertyValue( aPropertyName, *pAny ); } } - else - setPropertyValue( aIt->sName, *pAny ); - } ++aIt; + } } } diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx index fe87a1cda..49a9f3640 100644 --- a/sd/source/ui/view/GraphicObjectBar.cxx +++ b/sd/source/ui/view/GraphicObjectBar.cxx @@ -173,8 +173,10 @@ void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq ) aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) ); mpView->BegUndo( aStr ); pFilteredObj->SetGraphicObject( aFilterObj ); - mpView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); - mpView->EndUndo(); + ::sd::View* const pView = mpView;
+ pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
+ pView->EndUndo();
+ return;
} } } diff --git a/sd/source/ui/view/PrintManager.cxx b/sd/source/ui/view/PrintManager.cxx index 633a50824..fc232c867 100644 --- a/sd/source/ui/view/PrintManager.cxx +++ b/sd/source/ui/view/PrintManager.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -161,6 +161,10 @@ USHORT PrintManager::SetPrinterOptDlg ( USHORT nDiffFlags, BOOL _bShowDialog) { + SfxPrinter* pOld = mrBase.GetDocShell()->GetPrinter( FALSE ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + mrBase.GetDocShell()->SetPrinter(pNewPrinter); if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION || @@ -368,12 +372,12 @@ USHORT PrintManager::Print (SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* p if( pPrintOpts->GetOptionsPrint().IsDate() ) { - aTimeDateStr += GetSdrGlobalData().pLocaleData->getDate( Date() ); + aTimeDateStr += GetSdrGlobalData().GetLocaleData()->getDate( Date() ); aTimeDateStr += (sal_Unicode)' '; } if( pPrintOpts->GetOptionsPrint().IsTime() ) - aTimeDateStr += GetSdrGlobalData().pLocaleData->getTime( Time(), FALSE, FALSE ); + aTimeDateStr += GetSdrGlobalData().GetLocaleData()->getTime( Time(), FALSE, FALSE ); if( pPrintOpts->GetOptionsPrint().IsOutline() ) bPrintOutline = TRUE; diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index a1aa60c18..56dbac92e 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -161,7 +161,7 @@ public: ~Implementation (void); void LateInit (void); - + /** Show or hide the ViewTabBar. @param bShow When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden. @@ -196,7 +196,7 @@ public: void ProcessRestoreEditingViewSlot (void); void ProcessTaskPaneSlot (SfxRequest& rRequest); - + private: ViewShellBase& mrBase; @@ -503,32 +503,7 @@ void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) } break; - case SFX_EVENT_CREATEDOC: - // mpPaneManager->InitPanes(); - break; - - case SFX_EVENT_ACTIVATEDOC: - break; - - case SFX_EVENT_STARTAPP: - case SFX_EVENT_CLOSEAPP: - case SFX_EVENT_CLOSEDOC: - case SFX_EVENT_SAVEDOC: - case SFX_EVENT_SAVEASDOC: - case SFX_EVENT_DEACTIVATEDOC: - case SFX_EVENT_PRINTDOC: - case SFX_EVENT_ONERROR: - case SFX_EVENT_LOADFINISHED: - case SFX_EVENT_SAVEFINISHED: - case SFX_EVENT_MODIFYCHANGED: - case SFX_EVENT_PREPARECLOSEDOC: - case SFX_EVENT_NEWMESSAGE: - case SFX_EVENT_TOGGLEFULLSCREENMODE: - case SFX_EVENT_SAVEDOCDONE: - case SFX_EVENT_SAVEASDOCDONE: - case SFX_EVENT_MOUSEOVER_OBJECT: - case SFX_EVENT_MOUSECLICK_OBJECT: - case SFX_EVENT_MOUSEOUT_OBJECT: + default: break; } } @@ -590,7 +565,7 @@ void ViewShellBase::Rearrange (void) { OSL_TRACE("Rearrange: window missing"); } - + GetViewFrame()->Resize(TRUE); } diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index d648b4428..ec8bf518a 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -110,7 +110,7 @@ #include <sfx2/request.hxx> #include <boost/bind.hpp> -#ifdef _MSC_VER +#ifdef _MSC_VER #if (_MSC_VER < 1400) #pragma optimize ( "", off ) #endif @@ -165,8 +165,6 @@ void DrawViewShell::Deactivate(BOOL bIsMDIActivate) void DrawViewShell::SelectionHasChanged (void) { - // Um die Performance zu steigern wird jetzt die komplette - // Shell invalidiert statt alle Slots einzeln Invalidate(); //Update3DWindow(); // 3D-Controller @@ -492,6 +490,8 @@ void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive) Invalidate( SID_PAGEMODE ); Invalidate( SID_LAYERMODE ); Invalidate( SID_MASTERPAGE ); + Invalidate( SID_DELETE_MASTER_PAGE ); + Invalidate( SID_DELETE_PAGE ); Invalidate( SID_SLIDE_MASTERPAGE ); Invalidate( SID_TITLE_MASTERPAGE ); Invalidate( SID_NOTES_MASTERPAGE ); @@ -868,7 +868,7 @@ BOOL DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) if ( !GetDocSh()->IsUIActive() ) { ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager()); - + bActivated = ViewShell::ActivateObject(pObj, nVerb); OSL_ASSERT(GetViewShell()!=NULL); @@ -919,7 +919,7 @@ BOOL DrawViewShell::SwitchPage(USHORT nSelectedPage) // when it dsplays the show in a window: When the show is stopped it // returns at one point in time SDRPAGE_NOTFOUND as current page index. // Because FuSlideShow is currently being rewritten this bug is fixed - // here. + // here. // This is not as bad a hack as it may look because making SwitchPage() // more robust with respect to invalid page numbers is a good thing // anyway. @@ -972,7 +972,7 @@ BOOL DrawViewShell::SwitchPage(USHORT nSelectedPage) { OSL_ASSERT(mpFrameView!=NULL); mpFrameView->SetSelectedPage(nSelectedPage); - + if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage) pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); @@ -1229,7 +1229,11 @@ BOOL DrawViewShell::SwitchPage(USHORT nSelectedPage) SfxBindings& rBindings = GetViewFrame()->GetBindings(); rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, TRUE, FALSE); rBindings.Invalidate(SID_STATUS_PAGE, TRUE, FALSE); + rBindings.Invalidate(SID_DELETE_MASTER_PAGE, TRUE, FALSE); + rBindings.Invalidate(SID_DELETE_PAGE, TRUE, FALSE); UpdatePreview( mpActualPage ); + + mpDrawView->AdjustMarkHdl(); } return (bOK); @@ -1249,7 +1253,7 @@ BOOL DrawViewShell::IsSwitchPageAllowed() const FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell(); if (pFormShell!=NULL && !pFormShell->PrepareClose (FALSE)) bOK = false; - + return bOK; } @@ -1356,6 +1360,7 @@ void DrawViewShell::ResetActualLayer() pLayerBar->SetCurPageId(nActiveLayer + 1); GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER ); + GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER ); } } @@ -1379,10 +1384,10 @@ IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer ) \************************************************************************/ sal_Int8 DrawViewShell::AcceptDrop ( - const AcceptDropEvent& rEvt, + const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper, - ::sd::Window* pTargetWindow, - USHORT nPage, + ::sd::Window* pTargetWindow, + USHORT nPage, USHORT nLayer ) { if( nPage != SDRPAGE_NOTFOUND ) @@ -1401,10 +1406,10 @@ sal_Int8 DrawViewShell::AcceptDrop ( \************************************************************************/ sal_Int8 DrawViewShell::ExecuteDrop ( - const ExecuteDropEvent& rEvt, + const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper, - ::sd::Window* pTargetWindow, - USHORT nPage, + ::sd::Window* pTargetWindow, + USHORT nPage, USHORT nLayer) { if( nPage != SDRPAGE_NOTFOUND ) @@ -1427,4 +1432,4 @@ sal_Int8 DrawViewShell::ExecuteDrop ( #pragma optimize ( "", on ) #endif #endif - + diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index b85a6a878..4521b3397 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -502,6 +502,9 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) if ( !IsInputLocked() ) { + if( GetView() &&GetView()->getSmartTags().Command(rCEvt) ) + return; + const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase())); if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow ) diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index e794538e9..c4864e51d 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -210,7 +210,7 @@ IMPL_LINK( DrawViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper SfxBindings& rBindings = GetViewFrame()->GetBindings(); rBindings.Invalidate( SID_PASTE ); - rBindings.Invalidate( SID_PASTE2 ); + rBindings.Invalidate( SID_PASTE_SPECIAL ); rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); } return 0; @@ -570,7 +570,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) // clipboard (paste) if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) || - SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE2 ) || + SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE_SPECIAL ) || SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) ) { if ( !mpClipEvtLstnr ) @@ -596,7 +596,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) if( !mbPastePossible ) { rSet.DisableItem( SID_PASTE ); - rSet.DisableItem( SID_PASTE2 ); + rSet.DisableItem( SID_PASTE_SPECIAL ); rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS ); } else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) ) @@ -795,7 +795,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) bDisable = FALSE; SdPage& rRefMPage = (SdPage&)(pPage->TRG_GetMasterPage()); - + if(&rRefMPage == pMPage) { // Eine Seite mit dem AutoLayout "Titel" @@ -1017,7 +1017,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) SD_MOD()->GetWaterCan() ) { rSet.DisableItem( SID_PASTE ); - rSet.DisableItem( SID_PASTE2 ); + rSet.DisableItem( SID_PASTE_SPECIAL ); rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS ); rSet.DisableItem( SID_INSERT_FLD_DATE_FIX ); @@ -1328,6 +1328,8 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) } } + // #i102735# discussed with CL: removed for performance reasons + #if 0 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_SOUND ) || SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_VIDEO ) ) { @@ -1340,6 +1342,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) if (!SvxPluginFileDlg::IsAvailable (SID_INSERT_VIDEO)) rSet.DisableItem (SID_INSERT_VIDEO); } + #endif /////////////////////////////////////////////////////////////////////// // Menuoption: Change->Convert->To Bitmap, Change->Convert->To Metafile diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx index 68a84b494..43f7d8a34 100644 --- a/sd/source/ui/view/drviews8.cxx +++ b/sd/source/ui/view/drviews8.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -167,7 +167,7 @@ void DrawViewShell::FuTemp01(SfxRequest& rReq) } break; - case SID_PASTE2: + case SID_PASTE_SPECIAL: { SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); Cancel(); @@ -194,7 +194,7 @@ void DrawViewShell::FuTemp01(SfxRequest& rReq) Invalidate(SID_DRAWTBX_INSERT); } break; - + case SID_INSERT_OBJECT: case SID_INSERT_PLUGIN: case SID_INSERT_SOUND: diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 39cee38ae..c766e94e0 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -83,6 +83,7 @@ #include "SdUnoDrawView.hxx" #include "slideshow.hxx" #include "ToolBarManager.hxx" +#include "annotationmanager.hxx" using namespace ::rtl; using namespace ::com::sun::star; @@ -138,15 +139,10 @@ void SAL_CALL ScannerEventListener::disposing( const ::com::sun::star::lang::Eve |* \************************************************************************/ -DrawViewShell::DrawViewShell ( - SfxViewFrame* pFrame, - ViewShellBase& rViewShellBase, - ::Window* pParentWindow, - PageKind ePageKind, - FrameView* pFrameViewArgument) - : ViewShell (pFrame, pParentWindow, rViewShellBase), - maTabControl(this, pParentWindow), - mbIsInSwitchPage(false) +DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument ) +: ViewShell (pFrame, pParentWindow, rViewShellBase) +, maTabControl(this, pParentWindow) +, mbIsInSwitchPage(false) { if (pFrameViewArgument != NULL) mpFrameView = pFrameViewArgument; @@ -161,13 +157,10 @@ DrawViewShell::DrawViewShell ( |* \************************************************************************/ -DrawViewShell::DrawViewShell ( - SfxViewFrame* pFrame, - ::Window* pParentWindow, - const DrawViewShell& rShell) - : ViewShell(pFrame, pParentWindow, rShell), - maTabControl(this, pParentWindow), - mbIsInSwitchPage(false) +DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ::Window* pParentWindow, const DrawViewShell& rShell ) +: ViewShell(pFrame, pParentWindow, rShell) +, maTabControl(this, pParentWindow) +, mbIsInSwitchPage(false) { mpFrameView = new FrameView(GetDoc()); Construct (GetDocSh(), PK_STANDARD); @@ -181,6 +174,8 @@ DrawViewShell::DrawViewShell ( DrawViewShell::~DrawViewShell() { + mpAnnotationManager.release(); + OSL_ASSERT (GetViewShell()!=NULL); if( mxScannerListener.is() ) @@ -422,6 +417,8 @@ void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind) ::com::sun::star::uno::UNO_QUERY ); } } + + mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) ); } @@ -859,5 +856,19 @@ void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint) } +void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest) +{ + if( mpAnnotationManager.get() ) + mpAnnotationManager->ExecuteAnnotation( rRequest ); +} + +// -------------------------------------------------------------------- + +void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet ) +{ + if( mpAnnotationManager.get() ) + mpAnnotationManager->GetAnnotationState( rItemSet ); +} + } // end of namespace sd diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 0cdb657ec..7619c5816 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -793,7 +793,7 @@ IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHel SfxBindings& rBindings = GetViewFrame()->GetBindings(); rBindings.Invalidate( SID_PASTE ); - rBindings.Invalidate( SID_PASTE2 ); + rBindings.Invalidate( SID_PASTE_SPECIAL ); rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); } return 0; @@ -2114,7 +2114,7 @@ ULONG OutlineViewShell::Read(SvStream& rInput, const String& rBaseURL, USHORT eF SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PK_STANDARD) - 1, PK_STANDARD );; SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ); SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ); - + USHORT nParaCount = (USHORT)pOutl->GetParagraphCount(); if ( nParaCount > 0 ) { @@ -2130,7 +2130,7 @@ ULONG OutlineViewShell::Read(SvStream& rInput, const String& rBaseURL, USHORT eF pOutl->SetDepth(pPara, -1); pOutl->SetParaFlag(pPara, PARAFLAG_ISPAGE); - pOutl->SetStyleSheet( nPara, pTitleSheet ); + pOutl->SetStyleSheet( nPara, pTitleSheet ); if( nPara ) // first slide already exists pOlView->InsertSlideForParagraph( pPara ); diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 365c11df3..89a503518 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -443,20 +443,21 @@ drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedP // get font attributes; use normally scaled font const basegfx::BColor aFontColor(aRGBColor); Font aVclFont; - basegfx::B2DVector aSize; + basegfx::B2DVector aTextSizeAttribute; aVclFont.SetHeight( 500 ); - const drawinglayer::primitive2d::FontAttributes aFontAttributes(drawinglayer::primitive2d::getFontAttributesFromVclFont( - aSize, - aVclFont, - false, - false)); + const drawinglayer::primitive2d::FontAttributes aFontAttributes( + drawinglayer::primitive2d::getFontAttributesFromVclFont( + aTextSizeAttribute, + aVclFont, + false, + false)); // fill text matrix basegfx::B2DHomMatrix aTextMatrix; - aTextMatrix.scale(aSize.getX(), aSize.getY()); + aTextMatrix.scale(aTextSizeAttribute.getX(), aTextSizeAttribute.getY()); aTextMatrix.shearX(fShearX); aTextMatrix.rotate(fRotate); aTextMatrix.translate(fPosX, fPosY); @@ -468,15 +469,16 @@ drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedP const ::com::sun::star::lang::Locale aLocale; // create primitive and add - const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - aTextMatrix, - aObjectString, - 0, - nTextLength, - aDXArray, - aFontAttributes, - aLocale, - aFontColor)); + const drawinglayer::primitive2d::Primitive2DReference xRef( + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aTextMatrix, + aObjectString, + 0, + nTextLength, + aDXArray, + aFontAttributes, + aLocale, + aFontColor)); drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef); } } diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 9f975f3b8..cefbf1cb2 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -798,7 +798,10 @@ BOOL ViewShell::RequestHelp(const HelpEvent& rHEvt, ::sd::Window*) if (rHEvt.GetMode()) { - if(HasCurrentFunction()) + if( GetView() ) + bReturn = GetView()->getSmartTags().RequestHelp(rHEvt); + + if(!bReturn && HasCurrentFunction()) { bReturn = GetCurrentFunction()->RequestHelp(rHEvt); } diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 8b4f9320c..9974f5829 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -665,9 +665,18 @@ void ViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT ); GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); } - else if(HasCurrentFunction()) + else { - GetCurrentFunction()->Command(rCEvt); + bool bConsumed = false; + if( GetView() ) + { + bConsumed = GetView()->getSmartTags().Command(rCEvt); + } + + if( !bConsumed && HasCurrentFunction()) + { + GetCurrentFunction()->Command(rCEvt); + } } } } |