/* -*- 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_UNOCRSR_HXX #define INCLUDED_SW_INC_UNOCRSR_HXX #include "swcrsr.hxx" #include #include #include namespace sw { struct SW_DLLPUBLIC UnoCursorHint final : public SfxHint { UnoCursorHint() : SfxHint(SfxHintId::SwUnoCursorHint) {} virtual ~UnoCursorHint() override; }; } class SAL_DLLPUBLIC_RTTI SwUnoCursor : public virtual SwCursor { private: bool m_bRemainInSection : 1; bool m_bSkipOverHiddenSections : 1; bool m_bSkipOverProtectSections : 1; public: SfxBroadcaster m_aNotifier; SwUnoCursor( const SwPosition &rPos ); virtual ~SwUnoCursor() override; protected: virtual const SwContentFrame* DoSetBidiLevelLeftRight( bool & io_rbLeft, bool bVisualAllowed, bool bInsertCursor) override; virtual void DoSetBidiLevelUpDown() override; public: // Does a selection of content exist in table? // Return value indicates if the cursor remains at its old position. virtual bool IsSelOvr( SwCursorSelOverFlags eFlags = SwCursorSelOverFlags::CheckNodeSection | SwCursorSelOverFlags::Toggle | SwCursorSelOverFlags::ChangePos ) override; virtual bool IsReadOnlyAvailable() const override; bool IsRemainInSection() const { return m_bRemainInSection; } void SetRemainInSection( bool bFlag ) { m_bRemainInSection = bFlag; } virtual bool IsSkipOverProtectSections() const override { return m_bSkipOverProtectSections; } void SetSkipOverProtectSections( bool bFlag ) { m_bSkipOverProtectSections = bFlag; } virtual bool IsSkipOverHiddenSections() const override { return m_bSkipOverHiddenSections; } void SetSkipOverHiddenSections( bool bFlag ) { m_bSkipOverHiddenSections = bFlag; } }; class SwUnoTableCursor final : public virtual SwUnoCursor, public virtual SwTableCursor { // The selection has the same order as the table boxes, i.e. // if something is deleted from the one array at a certain position // it has also to be deleted from the other! SwCursor m_aTableSel; using SwTableCursor::MakeBoxSels; public: SwUnoTableCursor( const SwPosition& rPos ); virtual ~SwUnoTableCursor() override; // Does a selection of content exist in table? // Return value indicates if the cursor remains at its old position. virtual bool IsSelOvr( SwCursorSelOverFlags eFlags = SwCursorSelOverFlags::CheckNodeSection | SwCursorSelOverFlags::Toggle | SwCursorSelOverFlags::ChangePos ) override; void MakeBoxSels(); SwCursor& GetSelRing() { return m_aTableSel; } const SwCursor& GetSelRing() const { return m_aTableSel; } }; namespace sw { class UnoCursorPointer final : public SfxListener { public: UnoCursorPointer() {} UnoCursorPointer(std::shared_ptr pCursor) : m_pCursor(std::move(pCursor)) { StartListening(m_pCursor->m_aNotifier); } UnoCursorPointer(const UnoCursorPointer& rOther) : SfxListener() , m_pCursor(rOther.m_pCursor) { if(m_pCursor) StartListening(m_pCursor->m_aNotifier); } virtual ~UnoCursorPointer() override { if(m_pCursor) EndListening(m_pCursor->m_aNotifier); } virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override { if(m_pCursor) { if(rHint.GetId() == SfxHintId::SwUnoCursorHint) EndListening(rBC); } if(!GetBroadcasterCount()) m_pCursor.reset(); }; SwUnoCursor* get() const { return m_pCursor.get(); } SwUnoCursor* operator->() const { return get(); } SwUnoCursor& operator*() const { return *get(); } UnoCursorPointer& operator=(UnoCursorPointer aOther) { if (m_pCursor) { EndListening(m_pCursor->m_aNotifier); } if(aOther.m_pCursor) StartListening(aOther.m_pCursor->m_aNotifier); m_pCursor = aOther.m_pCursor; return *this; } explicit operator bool() const { return static_cast(m_pCursor); } void reset(const std::shared_ptr& pNew) { if(pNew) StartListening(pNew->m_aNotifier); if (m_pCursor) EndListening(m_pCursor->m_aNotifier); m_pCursor = pNew; } private: std::shared_ptr m_pCursor; }; } #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +backports'>distro/lhm/libreoffice-5-2+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-06-25tdf#94677 Calc is slow opening large CSV, improve tools::FractionNoel Grandin
Flatten the tools::Fraction class. Shaves 1s off a load time of 49s Change-Id: I7cbee9892831a1e47704a283351fa97eda262343 Reviewed-on: https://gerrit.libreoffice.org/74639 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-10-26tools: print some FractionsMichael Stahl
Change-Id: Idc4668cba7412d0b4a3e486a8629c7f95a701091
2017-10-16-Werror,-Wtautological-constant-compare (Clang 6)Stephan Bergmann
...making Fraction::HasOverflowValue() always return false on all platforms, regardless of size of long, since 331e2e5ed3bf4e0b2c1fab3b7bca836170317827 "long->sal_Int32 in Fraction" changed Fraction::Impl::value from boost::rational<sal_Int64> to boost::rational<sal_Int32>, and changed the limits to compare with in Fraction::HasOverflowValue from long to sal_Int32. Change-Id: I226ca240d6092ac803a1f65a363b1384903da17a
2017-09-27check for NaN in FractionNoel Grandin
which can result from division by zero in earlier code, rather assert explicitly than suffer from weird very large sal_Int64 values (which is what NaN converts to, if we let it do the implicit conversion) Change-Id: Id059b84906bbc90a4fa51489ca96dc0267bb9342 Reviewed-on: https://gerrit.libreoffice.org/42798 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-15long->sal_Int32 in FractionNoel Grandin
because long is 32bits on Windows and 64bits on Linux. Reasoning: (a) all the users of Fraction used to be 32bit in the past (b) this makes the Linux code behave the same as the Windows code (c) changing it to 64bits would be dangerous because then call sites could see silent truncation. Change-Id: I2a36200623a3cf2e7d62ccad030a20614e1798fb Reviewed-on: https://gerrit.libreoffice.org/42200 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-13Fraction: make conversion operators and constructor explicitNoel Grandin
and simplify some of the calculations that needed to be changed. Which resulted in one unit test needing to change by one pixel, let's hope not an indication of a real problem. Change-Id: Ie56434f35f4e58d21ee6f671392e93dc7542fca3 Reviewed-on: https://gerrit.libreoffice.org/42240 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-09-05drop default param from Fraction::FractionNoel Grandin
because if I make call-sites use the default, I get warnings about ambiguous functional conversions Change-Id: Ifd452c946832d0f9d62a10a46d90fe1ea3e79945
2016-08-29cid#1371160 Missing move assignment operatorNoel Grandin
Change-Id: Ifcddd08cd1ec6bfb7679ee0433524c4bd68803dd
2016-07-13loplugin:constparams in toolsNoel Grandin
Change-Id: Iea05efbb90a0a95fefd18ae9673095a31422f06c Reviewed-on: https://gerrit.libreoffice.org/27137 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>