1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX 29*cdf0e10cSrcweir #define FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "rtattributes.hxx" 32*cdf0e10cSrcweir #include <rtl/ref.hxx> 33*cdf0e10cSrcweir #include <editeng/svxenum.hxx> 34*cdf0e10cSrcweir #include <editeng/frmdir.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir class SfxItemSet; 37*cdf0e10cSrcweir class SfxPoolItem; 38*cdf0e10cSrcweir class SfxItemPool; 39*cdf0e10cSrcweir //........................................................................ 40*cdf0e10cSrcweir namespace frm 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir //........................................................................ 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir //==================================================================== 45*cdf0e10cSrcweir //= ReferenceBase 46*cdf0e10cSrcweir //==================================================================== 47*cdf0e10cSrcweir class ReferenceBase : public ::rtl::IReference 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir protected: 50*cdf0e10cSrcweir oslInterlockedCount m_refCount; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir public: 53*cdf0e10cSrcweir // IReference 54*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire(); 55*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release(); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir protected: 58*cdf0e10cSrcweir virtual ~ReferenceBase(); 59*cdf0e10cSrcweir }; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //==================================================================== 62*cdf0e10cSrcweir //= IAttributeHandler 63*cdf0e10cSrcweir //==================================================================== 64*cdf0e10cSrcweir class IAttributeHandler : public ::rtl::IReference 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir public: 67*cdf0e10cSrcweir virtual AttributeId getAttributeId( ) const = 0; 68*cdf0e10cSrcweir virtual AttributeState getState( const SfxItemSet& _rAttribs ) const = 0; 69*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0; 70*cdf0e10cSrcweir }; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir //==================================================================== 73*cdf0e10cSrcweir //= AttributeHandler 74*cdf0e10cSrcweir //==================================================================== 75*cdf0e10cSrcweir class AttributeHandler :public ReferenceBase 76*cdf0e10cSrcweir ,public IAttributeHandler 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir private: 79*cdf0e10cSrcweir AttributeId m_nAttribute; 80*cdf0e10cSrcweir WhichId m_nWhich; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir protected: 83*cdf0e10cSrcweir AttributeId getAttribute() const { return m_nAttribute; } 84*cdf0e10cSrcweir WhichId getWhich() const { return m_nWhich; } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir public: 87*cdf0e10cSrcweir AttributeHandler( AttributeId _nAttributeId, WhichId _nWhichId ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // IAttributeHandler 90*cdf0e10cSrcweir virtual AttributeId getAttributeId( ) const; 91*cdf0e10cSrcweir virtual AttributeState getState( const SfxItemSet& _rAttribs ) const; 92*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const = 0; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir protected: 95*cdf0e10cSrcweir /// helper method calling implGetCheckState 96*cdf0e10cSrcweir AttributeCheckState getCheckState( const SfxItemSet& _rAttribs ) const; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir /// helper method putting an item into a set, respecting a script type 99*cdf0e10cSrcweir void putItemForScript( SfxItemSet& _rAttribs, const SfxPoolItem& _rItem, ScriptType _nForScriptType ) const; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // pseudo-abstract 102*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // disambiguate IReference 105*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire(); 106*cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir protected: 109*cdf0e10cSrcweir virtual ~AttributeHandler(); 110*cdf0e10cSrcweir }; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir //==================================================================== 113*cdf0e10cSrcweir //= AttributeHandlerFactory 114*cdf0e10cSrcweir //==================================================================== 115*cdf0e10cSrcweir class AttributeHandlerFactory 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir public: 118*cdf0e10cSrcweir static ::rtl::Reference< IAttributeHandler > getHandlerFor( AttributeId _nAttributeId, const SfxItemPool& _rEditEnginePool ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir AttributeHandlerFactory(); // never implemented 122*cdf0e10cSrcweir AttributeHandlerFactory( const AttributeHandlerFactory& ); // never implemented 123*cdf0e10cSrcweir AttributeHandlerFactory& operator=( const AttributeHandlerFactory& ); // never implemented 124*cdf0e10cSrcweir ~AttributeHandlerFactory(); // never implemented 125*cdf0e10cSrcweir }; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir //==================================================================== 128*cdf0e10cSrcweir //= ParaAlignmentHandler 129*cdf0e10cSrcweir //==================================================================== 130*cdf0e10cSrcweir class ParaAlignmentHandler : public AttributeHandler 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir private: 133*cdf0e10cSrcweir SvxAdjust m_eAdjust; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir public: 136*cdf0e10cSrcweir ParaAlignmentHandler( AttributeId _nAttributeId ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir public: 139*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 140*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 141*cdf0e10cSrcweir }; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir //==================================================================== 144*cdf0e10cSrcweir //= LineSpacingHandler 145*cdf0e10cSrcweir //==================================================================== 146*cdf0e10cSrcweir class LineSpacingHandler : public AttributeHandler 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir private: 149*cdf0e10cSrcweir sal_uInt16 m_nLineSpace; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir public: 152*cdf0e10cSrcweir LineSpacingHandler( AttributeId _nAttributeId ); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir public: 155*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 156*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 157*cdf0e10cSrcweir }; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir //==================================================================== 160*cdf0e10cSrcweir //= EscapementHandler 161*cdf0e10cSrcweir //==================================================================== 162*cdf0e10cSrcweir class EscapementHandler : public AttributeHandler 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir private: 165*cdf0e10cSrcweir SvxEscapement m_eEscapement; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir public: 168*cdf0e10cSrcweir EscapementHandler( AttributeId _nAttributeId ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir public: 171*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 172*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 173*cdf0e10cSrcweir }; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //==================================================================== 176*cdf0e10cSrcweir //= SlotHandler 177*cdf0e10cSrcweir //==================================================================== 178*cdf0e10cSrcweir class SlotHandler : public AttributeHandler 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir private: 181*cdf0e10cSrcweir bool m_bScriptDependent; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir public: 184*cdf0e10cSrcweir SlotHandler( AttributeId _nAttributeId, WhichId _nWhichId ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir public: 187*cdf0e10cSrcweir virtual AttributeState getState( const SfxItemSet& _rAttribs ) const; 188*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 189*cdf0e10cSrcweir }; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir //==================================================================== 192*cdf0e10cSrcweir //= BooleanHandler 193*cdf0e10cSrcweir //==================================================================== 194*cdf0e10cSrcweir class BooleanHandler : public AttributeHandler 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir public: 197*cdf0e10cSrcweir BooleanHandler( AttributeId _nAttributeId, WhichId _nWhichId ); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir public: 200*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 201*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 202*cdf0e10cSrcweir }; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir //==================================================================== 205*cdf0e10cSrcweir //= FontSizeHandler 206*cdf0e10cSrcweir //==================================================================== 207*cdf0e10cSrcweir class FontSizeHandler : public AttributeHandler 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir public: 210*cdf0e10cSrcweir FontSizeHandler( AttributeId _nAttributeId, WhichId _nWhichId ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir public: 213*cdf0e10cSrcweir virtual AttributeState getState( const SfxItemSet& _rAttribs ) const; 214*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 215*cdf0e10cSrcweir }; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir //==================================================================== 218*cdf0e10cSrcweir //= ParagraphDirectionHandler 219*cdf0e10cSrcweir //==================================================================== 220*cdf0e10cSrcweir class ParagraphDirectionHandler : public AttributeHandler 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir private: 223*cdf0e10cSrcweir SvxFrameDirection m_eParagraphDirection; 224*cdf0e10cSrcweir SvxAdjust m_eDefaultAdjustment; 225*cdf0e10cSrcweir SvxAdjust m_eOppositeDefaultAdjustment; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir public: 228*cdf0e10cSrcweir ParagraphDirectionHandler( AttributeId _nAttributeId ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir public: 231*cdf0e10cSrcweir virtual AttributeCheckState implGetCheckState( const SfxPoolItem& _rItem ) const; 232*cdf0e10cSrcweir virtual void executeAttribute( const SfxItemSet& _rCurrentAttribs, SfxItemSet& _rNewAttribs, const SfxPoolItem* _pAdditionalArg, ScriptType _nForScriptType ) const; 233*cdf0e10cSrcweir }; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir //........................................................................ 236*cdf0e10cSrcweir } // namespace frm 237*cdf0e10cSrcweir //........................................................................ 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir #endif // FORMS_SOURCE_COMPONENT_RTATTRIBUTEHANDLER_HXX 240*cdf0e10cSrcweir 241