/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_SW_INC_SECTION_HXX #define INCLUDED_SW_INC_SECTION_HXX #include #include #include #include #include #include #include namespace com { namespace sun { namespace star { namespace text { class XTextSection; } } } } class SwSectionFormat; class SwDoc; class SwSection; class SwSectionNode; class SwTOXBase; class SwServerObject; typedef std::vector SwSections; enum SectionType { CONTENT_SECTION, TOX_HEADER_SECTION, TOX_CONTENT_SECTION, DDE_LINK_SECTION = OBJECT_CLIENT_DDE, FILE_LINK_SECTION = OBJECT_CLIENT_FILE }; enum LinkCreateType { CREATE_NONE, // Do nothing. CREATE_CONNECT, // Connect created link. CREATE_UPDATE // Connect created link and update it. }; class SW_DLLPUBLIC SwSectionData { private: SectionType m_eType; OUString m_sSectionName; OUString m_sCondition; OUString m_sLinkFileName; OUString m_sLinkFilePassword; // Must be changed to Sequence. css::uno::Sequence m_Password; /// It seems this flag caches the current final "hidden" state. bool m_bHiddenFlag : 1; /// Flags that correspond to attributes in the format: /// may have different value than format attribute: /// format attr has value for this section, while flag is /// effectively ORed with parent sections! bool m_bProtectFlag : 1; // Edit in readonly sections. bool m_bEditInReadonlyFlag : 1; bool m_bHidden : 1; // All paragraphs hidden? bool m_bCondHiddenFlag : 1; // Hiddenflag for condition. bool m_bConnectFlag : 1; // Connected to server? public: SwSectionData(SectionType const eType, OUString const& rName); explicit SwSectionData(SwSection const&); SwSectionData(SwSectionData const&); SwSectionData & operator=(SwSectionData const&); bool operator==(SwSectionData const&) const; const OUString& GetSectionName() const { return m_sSectionName; } void SetSectionName(OUString const& rName){ m_sSectionName = rName; } SectionType GetType() const { return m_eType; } void SetType(SectionType const eNew) { m_eType = eNew; } bool IsHidden() const { return m_bHidden; } void SetHidden(bool const bFlag) { m_bHidden = bFlag; } bool IsHiddenFlag() const { return m_bHiddenFlag; } SAL_DLLPRIVATE void SetHiddenFlag(bool const bFlag) { m_bHiddenFlag = bFlag; } bool IsProtectFlag() const { return m_bProtectFlag; } SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag) { m_bProtectFlag = bFlag; } bool IsEditInReadonlyFlag() const { return m_bEditInReadonlyFlag; } void SetEditInReadonlyFlag(bool const bFlag) { m_bEditInReadonlyFlag = bFlag; } void SetCondHidden(bool const bFlag) { m_bCondHiddenFlag = bFlag; } bool IsCondHidden() const { return m_bCondHiddenFlag; } const OUString& GetCondition() const { return m_sCondition; } void SetCondition(OUString const& rNew) { m_sCondition = rNew; } const OUString& GetLinkFileName() const { return m_sLinkFileName; } void SetLinkFileName(OUString const& rNew) { m_sLinkFileName = rNew; } const OUString& GetLinkFilePassword() const { return m_sLinkFilePassword; } void SetLinkFilePassword(OUString const& rS){ m_sLinkFilePassword = rS; } css::uno::Sequence const& GetPassword() const { return m_Password; } void SetPassword(css::uno::Sequence const& rNew) { m_Password = rNew; } bool IsLinkType() const { return (DDE_LINK_SECTION == m_eType) || (FILE_LINK_SECTION == m_eType); } bool IsConnectFlag() const { return m_bConnectFlag; } void SetConnectFlag(bool const bFlag){ m_bConnectFlag = bFlag; } static OUString CollapseWhiteSpaces(const OUString& sName); }; class SW_DLLPUBLIC SwSection : public SwClient { // In order to correctly maintain the flag when creating/deleting frames. friend class SwSectionNode; // The "read CTOR" of SwSectionFrame have to change the Hiddenflag. friend class SwSectionFrame; private: mutable SwSectionData m_Data; tools::SvRef m_RefObj; // Set if DataServer. tools::SvRef m_RefLink; SAL_DLLPRIVATE void ImplSetHiddenFlag( bool const bHidden, bool const bCondition); protected: virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; public: SwSection(SectionType const eType, OUString const& rName, SwSectionFormat & rFormat); virtual ~SwSection() override; bool DataEquals(SwSectionData const& rCmp) const; void SetSectionData(SwSectionData const& rData); OUString GetSectionName() const { return m_Data.GetSectionName(); } void SetSectionName(OUString const& rName){ m_Data.SetSectionName(rName); } SectionType GetType() const { return m_Data.GetType(); } void SetType(SectionType const eType) { return m_Data.SetType(eType); } inline SwSectionFormat* GetFormat(); inline SwSectionFormat const * GetFormat() const; // Set hidden/protected -> update the whole tree! // (Attributes/flags are set/get.) bool IsHidden() const { return m_Data.IsHidden(); } void SetHidden (bool const bFlag = true); bool IsProtect() const; void SetProtect(bool const bFlag = true); bool IsEditInReadonly() const; void SetEditInReadonly(bool const bFlag = true); // Get internal flags (state including parents, not what is // currently set at section!). bool IsHiddenFlag() const { return m_Data.IsHiddenFlag(); } bool IsProtectFlag() const { return m_Data.IsProtectFlag(); } bool IsEditInReadonlyFlag() const { return m_Data.IsEditInReadonlyFlag(); } void SetCondHidden(bool const bFlag); bool IsCondHidden() const { return m_Data.IsCondHidden(); } // Query (also for parents) if this section is to be hidden. bool CalcHiddenFlag() const; inline SwSection* GetParent() const; OUString GetCondition() const { return m_Data.GetCondition(); } void SetCondition(OUString const& rNew) { m_Data.SetCondition(rNew); } OUString GetLinkFileName() const; void SetLinkFileName(OUString const& rNew); // Password of linked file (only valid during runtime!) OUString GetLinkFilePassword() const { return m_Data.GetLinkFilePassword(); } void SetLinkFilePassword(OUString const& rS) { m_Data.SetLinkFilePassword(rS); } // Get / set password of this section css::uno::Sequence const& GetPassword() const { return m_Data.GetPassword(); } // Data server methods. void SetRefObject( SwServerObject* pObj ); const SwServerObject* GetObject() const { return m_RefObj.get(); } SwServerObject* GetObject() { return m_RefObj.get(); } bool IsServer() const { return m_RefObj.Is(); } // Methods for linked ranges. SfxLinkUpdateMode GetUpdateType() const { return m_RefLink->GetUpdateMode(); } void SetUpdateType(SfxLinkUpdateMode nType ) { m_RefLink->SetUpdateMode(nType); } bool IsConnected() const { return m_RefLink.Is(); } void UpdateNow() { m_RefLink->Update(); } void Disconnect() { m_RefLink->Disconnect(); } const ::sfx2::SvBaseLink& GetBaseLink() const { return *m_RefLink; } ::sfx2::SvBaseLink& GetBaseLink() { return *m_RefLink; } void CreateLink( LinkCreateType eType ); static void MakeChildLinksVisible( const SwSectionNode& rSectNd ); bool IsLinkType() const { return m_Data.IsLinkType(); } // Flags for UI. Did connection work? bool IsConnectFlag() const { return m_Data.IsConnectFlag(); } void SetConnectFlag(bool const bFlag = true) { m_Data.SetConnectFlag(bFlag); } // Return the TOX base class if the section is a TOX section const SwTOXBase* GetTOXBase() const; void BreakLink(); }; // #i117863# class SwSectionFrameMoveAndDeleteHint : public SfxHint { public: SwSectionFrameMoveAndDeleteHint( const bool bSaveContent ) : SfxHint( SFX_HINT_DYING ) , mbSaveContent( bSaveContent ) {} virtual ~SwSectionFrameMoveAndDeleteHint() override {} bool IsSaveContent() const { return mbSaveContent; } private: const bool mbSaveContent; }; enum SectionSort { SORTSECT_NOT, SORTSECT_NAME, SORTSECT_POS }; class SW_DLLPUBLIC SwSectionFormat : public SwFrameFormat , public ::sfx2::Metadatable { friend class SwDoc; /** Why does this exist in addition to the m_wXObject in SwFrameFormat? in case of an index, both a SwXDocumentIndex and a SwXTextSection register at this SwSectionFormat, so we need to have two refs. */ css::uno::WeakReference m_wXTextSection; SAL_DLLPRIVATE void UpdateParent(); // Parent has been changed. protected: SwSectionFormat( SwFrameFormat* pDrvdFrame, SwDoc *pDoc ); virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; public: virtual ~SwSectionFormat() override; // Deletes all Frames in aDepend (Frames are recognized via dynamic_cast). virtual void DelFrames() override; // Creates views. virtual void MakeFrames() override; // Get information from Format. virtual bool GetInfo( SfxPoolItem& ) const override; SwSection* GetSection() const; inline SwSectionFormat* GetParent() const; inline SwSection* GetParentSection() const; // All sections that are derived from this one: // - sorted according to name or position or unsorted // - all of them or only those that are in the normal Nodes-array. void GetChildSections( SwSections& rArr, SectionSort eSort = SORTSECT_NOT, bool bAllSections = true ) const; // Query whether section is in Nodes-array or in UndoNodes-array. bool IsInNodesArr() const; SwSectionNode* GetSectionNode(); const SwSectionNode* GetSectionNode() const { return const_cast(this) ->GetSectionNode(); } // Is section a valid one for global document? const SwSection* GetGlobalDocSection() const; SAL_DLLPRIVATE css::uno::WeakReference const& GetXTextSection() const { return m_wXTextSection; } SAL_DLLPRIVATE void SetXTextSection(css::uno::Reference const& xTextSection) { m_wXTextSection = xTextSection; } // sfx2::Metadatable virtual ::sfx2::IXmlIdRegistry& GetRegistry() override; virtual bool IsInClipboard() const override; virtual bool IsInUndo() const override; virtual bool IsInContent() const override; virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override; void dumpAsXml(struct _xmlTextWriter* pWriter) const; }; SwSectionFormat* SwSection::GetFormat() { return static_cast(GetRegisteredIn()); } SwSectionFormat const * SwSection::GetFormat() const { return static_cast(GetRegisteredIn()); } inline SwSection* SwSection::GetParent() const { SwSectionFormat const * pFormat = GetFormat(); SwSection* pRet = nullptr; if( pFormat ) pRet = pFormat->GetParentSection(); return pRet; } inline SwSectionFormat* SwSectionFormat::GetParent() const { SwSectionFormat* pRet = nullptr; if( GetRegisteredIn() ) pRet = const_cast(dynamic_cast< const SwSectionFormat* >( GetRegisteredIn() )); return pRet; } inline SwSection* SwSectionFormat::GetParentSection() const { SwSectionFormat* pParent = GetParent(); SwSection* pRet = nullptr; if( pParent ) { pRet = pParent->GetSection(); } return pRet; } #endif /* _ INCLUDED_SW_INC_SECTION_HXX */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /cib_contract3197 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-04-27Fix OSL_ENSURE invocations.Michael Meeks
Change-Id: Ic217a75276956f200eaa539da0f5c06475106d0a Reviewed-on: https://gerrit.libreoffice.org/53540 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
2018-04-26Use async dialog path for format columns.Michael Meeks
Change-Id: I7097abd68b5921697d1d5f39f5e81ac961b61226 Reviewed-on: https://gerrit.libreoffice.org/53539 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-12-18convert SFX_VISIBILITY constants to scoped enumNoel Grandin
* split the position and the flags information * remove unused DESKTOP constant Change-Id: Ibfccb44c7567e89d4527bfd36b3915a73682e6e2 (cherry picked from commit 5af0071d42e5962ed849261134ef0630c7ec3b45) (cherry picked from commit 82577130d5a1e40396053e86fd0d7beb14170fbd)
2016-10-28ScopedVclPtr vs std::unique_ptr for VclAbstractDialog derivativesCaolán McNamara
Change-Id: I5e43312b6f42ce0c63946f366eaf1e6dcb9629b2 Reviewed-on: https://gerrit.libreoffice.org/30344 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-10-28convert std::unique_ptr<VclAbstractDialog> to VclPtrNoel Grandin
Change-Id: Ifdd2a0599efd701def02b4a4d2a1c489cb1b27fa
2016-10-27Fix insert special character crashMaxim Monastirsky
Change-Id: Id75567f5f6689d15d62f88ed0907c296434b8f0a
2016-10-05convert MapUnit to scoped enumNoel Grandin
I left a prefix on the names "Map" so that I would not have to re-arrange each name too much, since I can't start identifiers with digits like "100thMM" And remove RSC_EXTRAMAPUNIT, which doesn't seem to be doing anything anymore. Change-Id: I5187824aa87e30caf5357b51b5384b5ab919d224 Reviewed-on: https://gerrit.libreoffice.org/29096 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-08-12tdf#91832: ensure GETLINK reports proper contents for reverse selections tooBjoern Michaelsen
Change-Id: I4e77a55de012b5edd0d922b5e534e4dd6bb714b6 Reviewed-on: https://gerrit.libreoffice.org/28077 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2016-06-28Convert Bitmap tab to Pattern tabRishabh Kumar
Change-Id: I5cf02f1889090539f7adb826483c91a1ef3c3925 Reviewed-on: https://gerrit.libreoffice.org/26015 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
2016-06-27GSoC notebookbar: switching tabs depending on contextSzymon Kłos
+ sfx2::sidebar::EnumContext moved to the vcl module + TabPage contains vector with context values + vcl builder reads control's contexts from the "class" mark + ContextTabControl shows tabs depending on context Change-Id: I661b0d3f35d46ace2a2e8eb1d374148f0c60017d Reviewed-on: https://gerrit.libreoffice.org/26447 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-05-27tdf#34465 remove calls to SfxItemSet::Put(const SfxPoolItem&, sal_uInt16)Noel Grandin
and put an assert in SfxPoolItem::SetWhich() so nothing new creeps in. Change-Id: I6497650fa61ffb2b6941ffff2d471c8f117be1df Reviewed-on: https://gerrit.libreoffice.org/24324 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-22Convert HYPERDLG_EVENT to scoped enumNoel Grandin
Change-Id: I8a0248bb91ee67596aa44d11ca862d2e127a65ad Reviewed-on: https://gerrit.libreoffice.org/25197 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>