11d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 31d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 41d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 51d2dbeb0SAndrew Rist * distributed with this work for additional information 61d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 71d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 81d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 91d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 111d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 131d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 141d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 151d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 171d2dbeb0SAndrew Rist * specific language governing permissions and limitations 181d2dbeb0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 201d2dbeb0SAndrew Rist *************************************************************/ 211d2dbeb0SAndrew Rist 221d2dbeb0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _BOOKMRK_HXX 25cdf0e10cSrcweir #define _BOOKMRK_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppuhelper/weakref.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <sfx2/Metadatable.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 32cdf0e10cSrcweir #include <boost/noncopyable.hpp> 33cdf0e10cSrcweir #include <map> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <IMark.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace com { namespace sun { namespace star { 39cdf0e10cSrcweir namespace text { class XTextContent; } 40cdf0e10cSrcweir } } } 41cdf0e10cSrcweir 42cdf0e10cSrcweir struct SwPosition; // fwd Decl. wg. UI 43cdf0e10cSrcweir class SwDoc; 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace sw { namespace mark 46cdf0e10cSrcweir { 47cdf0e10cSrcweir class MarkBase 48cdf0e10cSrcweir : virtual public IMark 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir //getters GetMarkPos() const52*5b9fe260SOliver-Rainer Wittmann virtual const SwPosition& GetMarkPos() const 53cdf0e10cSrcweir { return *m_pPos1; } GetName() const54cdf0e10cSrcweir virtual const ::rtl::OUString& GetName() const 55cdf0e10cSrcweir { return m_aName; } 56cdf0e10cSrcweir virtual bool IsCoveringPosition(const SwPosition& rPos) const; GetOtherMarkPos() const57*5b9fe260SOliver-Rainer Wittmann virtual const SwPosition& GetOtherMarkPos() const 58cdf0e10cSrcweir { 59cdf0e10cSrcweir OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." ); 60cdf0e10cSrcweir return *m_pPos2; 61cdf0e10cSrcweir } GetMarkStart() const62*5b9fe260SOliver-Rainer Wittmann virtual const SwPosition& GetMarkStart() const 63cdf0e10cSrcweir { 64cdf0e10cSrcweir if( !IsExpanded() ) return GetMarkPos( ); 65cdf0e10cSrcweir if ( GetMarkPos( ) < GetOtherMarkPos( ) ) 66cdf0e10cSrcweir return GetMarkPos(); 67cdf0e10cSrcweir else 68cdf0e10cSrcweir return GetOtherMarkPos( ); 69cdf0e10cSrcweir } GetMarkEnd() const70*5b9fe260SOliver-Rainer Wittmann virtual const SwPosition& GetMarkEnd() const 71cdf0e10cSrcweir { 72cdf0e10cSrcweir if( !IsExpanded() ) return GetMarkPos(); 73cdf0e10cSrcweir if ( GetMarkPos( ) > GetOtherMarkPos( ) ) 74cdf0e10cSrcweir return GetMarkPos( ); 75cdf0e10cSrcweir else 76cdf0e10cSrcweir return GetOtherMarkPos( ); 77cdf0e10cSrcweir } IsExpanded() const78cdf0e10cSrcweir virtual bool IsExpanded() const 790ca1f900SHerbert Dürr { return (m_pPos2.get() != NULL); } 80cdf0e10cSrcweir 81cdf0e10cSrcweir //setters SetName(const::rtl::OUString & rName)82cdf0e10cSrcweir virtual void SetName(const ::rtl::OUString& rName) 83cdf0e10cSrcweir { m_aName = rName; } 84cdf0e10cSrcweir virtual void SetMarkPos(const SwPosition& rNewPos); 85cdf0e10cSrcweir virtual void SetOtherMarkPos(const SwPosition& rNewPos); ClearOtherMarkPos()86cdf0e10cSrcweir virtual void ClearOtherMarkPos() 87cdf0e10cSrcweir { m_pPos2.reset(); } 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual rtl::OUString ToString( ) const; 90cdf0e10cSrcweir Swap()91cdf0e10cSrcweir virtual void Swap() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir if(m_pPos2) 94cdf0e10cSrcweir m_pPos1.swap(m_pPos2); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir InitDoc(SwDoc * const)97cdf0e10cSrcweir virtual void InitDoc(SwDoc* const) 98cdf0e10cSrcweir {} 99cdf0e10cSrcweir 100cdf0e10cSrcweir virtual ~MarkBase(); 101cdf0e10cSrcweir 102cdf0e10cSrcweir const ::com::sun::star::uno::WeakReference< GetXBookmark() const103cdf0e10cSrcweir ::com::sun::star::text::XTextContent> & GetXBookmark() const 104cdf0e10cSrcweir { return m_wXBookmark; } SetXBookmark(::com::sun::star::uno::Reference<::com::sun::star::text::XTextContent> const & xBkmk)105cdf0e10cSrcweir void SetXBookmark(::com::sun::star::uno::Reference< 106cdf0e10cSrcweir ::com::sun::star::text::XTextContent> const& xBkmk) 107cdf0e10cSrcweir { m_wXBookmark = xBkmk; } 108cdf0e10cSrcweir 109cdf0e10cSrcweir protected: 110cdf0e10cSrcweir // SwClient 111cdf0e10cSrcweir virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir MarkBase(const SwPaM& rPaM, 114cdf0e10cSrcweir const ::rtl::OUString& rName); 115cdf0e10cSrcweir ::boost::scoped_ptr<SwPosition> m_pPos1; 116cdf0e10cSrcweir ::boost::scoped_ptr<SwPosition> m_pPos2; 117cdf0e10cSrcweir ::rtl::OUString m_aName; 118cdf0e10cSrcweir static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix); 119cdf0e10cSrcweir 120cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< 121cdf0e10cSrcweir ::com::sun::star::text::XTextContent> m_wXBookmark; 122cdf0e10cSrcweir }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir class NavigatorReminder 125cdf0e10cSrcweir : public MarkBase 126cdf0e10cSrcweir { 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir NavigatorReminder(const SwPaM& rPaM); 129cdf0e10cSrcweir private: 130cdf0e10cSrcweir static const ::rtl::OUString our_sNamePrefix; 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir 133cdf0e10cSrcweir class UnoMark 134cdf0e10cSrcweir : public MarkBase 135cdf0e10cSrcweir { 136cdf0e10cSrcweir public: 137cdf0e10cSrcweir UnoMark(const SwPaM& rPaM); 138cdf0e10cSrcweir private: 139cdf0e10cSrcweir static const ::rtl::OUString our_sNamePrefix; 140cdf0e10cSrcweir }; 141cdf0e10cSrcweir 142cdf0e10cSrcweir class DdeBookmark 143cdf0e10cSrcweir : public MarkBase 144cdf0e10cSrcweir { 145cdf0e10cSrcweir public: 146cdf0e10cSrcweir DdeBookmark(const SwPaM& rPaM); 147cdf0e10cSrcweir 148cdf0e10cSrcweir //getters GetRefObject() const149cdf0e10cSrcweir const SwServerObject* GetRefObject() const 150cdf0e10cSrcweir { return &m_aRefObj; } GetRefObject()151cdf0e10cSrcweir SwServerObject* GetRefObject() 152cdf0e10cSrcweir { return &m_aRefObj; } 153cdf0e10cSrcweir IsServer() const154cdf0e10cSrcweir bool IsServer() const 155cdf0e10cSrcweir { return m_aRefObj.Is(); } 156cdf0e10cSrcweir 157cdf0e10cSrcweir //setters 158cdf0e10cSrcweir void SetRefObject( SwServerObject* pObj ); 159cdf0e10cSrcweir 160cdf0e10cSrcweir void DeregisterFromDoc(SwDoc* const pDoc); 161cdf0e10cSrcweir virtual ~DdeBookmark(); IsInDestruction() const162b0b7a757SOliver-Rainer Wittmann inline bool IsInDestruction() const 163b0b7a757SOliver-Rainer Wittmann { 164b0b7a757SOliver-Rainer Wittmann return mbInDestruction; 165b0b7a757SOliver-Rainer Wittmann } 166cdf0e10cSrcweir private: 167cdf0e10cSrcweir SwServerObjectRef m_aRefObj; 168b0b7a757SOliver-Rainer Wittmann bool mbInDestruction; 169cdf0e10cSrcweir static const ::rtl::OUString our_sNamePrefix; 170cdf0e10cSrcweir }; 171cdf0e10cSrcweir 172cdf0e10cSrcweir class Bookmark 173cdf0e10cSrcweir : virtual public IBookmark 174cdf0e10cSrcweir , public DdeBookmark 175cdf0e10cSrcweir , public ::sfx2::Metadatable 176cdf0e10cSrcweir { 177cdf0e10cSrcweir public: 178cdf0e10cSrcweir Bookmark(const SwPaM& rPaM, 179cdf0e10cSrcweir const KeyCode& rCode, 180cdf0e10cSrcweir const ::rtl::OUString& rName, 181cdf0e10cSrcweir const ::rtl::OUString& rShortName); 182cdf0e10cSrcweir virtual void InitDoc(SwDoc* const io_Doc); 183cdf0e10cSrcweir GetShortName() const184cdf0e10cSrcweir virtual const ::rtl::OUString& GetShortName() const 185cdf0e10cSrcweir { return m_sShortName; } GetKeyCode() const186cdf0e10cSrcweir virtual const KeyCode& GetKeyCode() const 187cdf0e10cSrcweir { return m_aCode; } SetShortName(const::rtl::OUString & rShortName)188cdf0e10cSrcweir virtual void SetShortName(const ::rtl::OUString& rShortName) 189cdf0e10cSrcweir { m_sShortName = rShortName; } SetKeyCode(const KeyCode & rCode)190cdf0e10cSrcweir virtual void SetKeyCode(const KeyCode& rCode) 191cdf0e10cSrcweir { m_aCode = rCode; } 192cdf0e10cSrcweir 193cdf0e10cSrcweir // ::sfx2::Metadatable 194cdf0e10cSrcweir virtual ::sfx2::IXmlIdRegistry& GetRegistry(); 195cdf0e10cSrcweir virtual bool IsInClipboard() const; 196cdf0e10cSrcweir virtual bool IsInUndo() const; 197cdf0e10cSrcweir virtual bool IsInContent() const; 198cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 199cdf0e10cSrcweir ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); 200cdf0e10cSrcweir 201cdf0e10cSrcweir private: 202cdf0e10cSrcweir KeyCode m_aCode; 203cdf0e10cSrcweir ::rtl::OUString m_sShortName; 204cdf0e10cSrcweir }; 205cdf0e10cSrcweir 206cdf0e10cSrcweir class Fieldmark 207cdf0e10cSrcweir : virtual public IFieldmark 208cdf0e10cSrcweir , public MarkBase 209cdf0e10cSrcweir { 210cdf0e10cSrcweir public: 211cdf0e10cSrcweir Fieldmark(const SwPaM& rPaM); 212cdf0e10cSrcweir 213cdf0e10cSrcweir // getters GetFieldname() const214cdf0e10cSrcweir virtual ::rtl::OUString GetFieldname() const 215cdf0e10cSrcweir { return m_aFieldname; } GetFieldHelptext() const216cdf0e10cSrcweir virtual ::rtl::OUString GetFieldHelptext() const 217cdf0e10cSrcweir { return m_aFieldHelptext; } 218cdf0e10cSrcweir GetParameters()219cdf0e10cSrcweir virtual IFieldmark::parameter_map_t* GetParameters() 220cdf0e10cSrcweir { return &m_vParams; } 221cdf0e10cSrcweir GetParameters() const222cdf0e10cSrcweir virtual const IFieldmark::parameter_map_t* GetParameters() const 223cdf0e10cSrcweir { return &m_vParams; } 224cdf0e10cSrcweir 225cdf0e10cSrcweir // setters SetFieldname(const::rtl::OUString & aFieldname)226cdf0e10cSrcweir virtual void SetFieldname(const ::rtl::OUString& aFieldname) 227cdf0e10cSrcweir { m_aFieldname = aFieldname; } SetFieldHelptext(const::rtl::OUString & aFieldHelptext)228cdf0e10cSrcweir virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext) 229cdf0e10cSrcweir { m_aFieldHelptext = aFieldHelptext; } 230cdf0e10cSrcweir 231*5b9fe260SOliver-Rainer Wittmann void SetMarkStartPos( const SwPosition& rNewStartPos ); 232*5b9fe260SOliver-Rainer Wittmann void SetMarkEndPos( const SwPosition& rNewEndPos ); 233*5b9fe260SOliver-Rainer Wittmann 234cdf0e10cSrcweir virtual void Invalidate(); 235cdf0e10cSrcweir virtual rtl::OUString ToString() const; 236cdf0e10cSrcweir private: 237cdf0e10cSrcweir ::rtl::OUString m_aFieldname; 238cdf0e10cSrcweir ::rtl::OUString m_aFieldHelptext; 239cdf0e10cSrcweir IFieldmark::parameter_map_t m_vParams; 240cdf0e10cSrcweir 241cdf0e10cSrcweir static const ::rtl::OUString our_sNamePrefix; 242cdf0e10cSrcweir }; 243cdf0e10cSrcweir 244cdf0e10cSrcweir class TextFieldmark 245cdf0e10cSrcweir : public Fieldmark 246cdf0e10cSrcweir { 247cdf0e10cSrcweir public: 248cdf0e10cSrcweir TextFieldmark(const SwPaM& rPaM); 249cdf0e10cSrcweir virtual void InitDoc(SwDoc* const io_pDoc); 2503b32dd21SOliver-Rainer Wittmann void ReleaseDoc(SwDoc* const pDoc); 251cdf0e10cSrcweir }; 252cdf0e10cSrcweir 253cdf0e10cSrcweir class CheckboxFieldmark 254cdf0e10cSrcweir : virtual public ICheckboxFieldmark 255cdf0e10cSrcweir , public Fieldmark 256cdf0e10cSrcweir { 257cdf0e10cSrcweir public: 258cdf0e10cSrcweir CheckboxFieldmark(const SwPaM& rPaM); 259cdf0e10cSrcweir virtual void InitDoc(SwDoc* const io_pDoc); 260cdf0e10cSrcweir bool IsChecked() const; 261cdf0e10cSrcweir void SetChecked(bool checked); 262cdf0e10cSrcweir }; 263cdf0e10cSrcweir 264cdf0e10cSrcweir }} 265cdf0e10cSrcweir #endif 266