From 6311f7ffce8f64b0773d2ad3ea7be3be683924c0 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 Oct 2018 09:02:25 +0100 Subject: move SvTreeListBox to vcl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I04a146d3d8a428ac1678827dc883525c40240a44 Reviewed-on: https://gerrit.libreoffice.org/62787 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svtools/accessiblefactory.hxx | 6 - include/svtools/brwbox.hxx | 2 +- include/svtools/embedtransfer.hxx | 2 +- include/svtools/fileview.hxx | 6 +- include/svtools/foldertree.hxx | 2 +- include/svtools/iconview.hxx | 2 +- include/svtools/imap.hxx | 138 ------ include/svtools/imapcirc.hxx | 71 --- include/svtools/imapobj.hxx | 127 ------ include/svtools/imappoly.hxx | 75 ---- include/svtools/imaprect.hxx | 69 --- include/svtools/inetimg.hxx | 60 --- include/svtools/insdlg.hxx | 2 +- include/svtools/stringtransfer.hxx | 2 +- include/svtools/svlbitm.hxx | 282 ------------ include/svtools/svtabbx.hxx | 2 +- include/svtools/transfer.hxx | 507 --------------------- include/svtools/treelist.hxx | 339 -------------- include/svtools/treelistbox.hxx | 801 ---------------------------------- include/svtools/treelistentries.hxx | 21 - include/svtools/treelistentry.hxx | 123 ------ include/svtools/viewdataentry.hxx | 84 ---- include/svx/checklbx.hxx | 2 +- include/svx/colrctrl.hxx | 2 +- include/svx/ctredlin.hxx | 6 +- include/svx/dbaexchange.hxx | 2 +- include/svx/dbaobjectex.hxx | 2 +- include/svx/fmgridcl.hxx | 2 +- include/svx/fontlb.hxx | 2 +- include/svx/galctrl.hxx | 2 +- include/svx/galmisc.hxx | 4 +- include/svx/galtheme.hxx | 2 +- include/svx/gridctrl.hxx | 2 +- include/svx/xmlexchg.hxx | 2 +- include/vcl/imap.hxx | 138 ++++++ include/vcl/imapcirc.hxx | 71 +++ include/vcl/imapobj.hxx | 127 ++++++ include/vcl/imappoly.hxx | 75 ++++ include/vcl/imaprect.hxx | 69 +++ include/vcl/inetimg.hxx | 60 +++ include/vcl/svimpbox.hxx | 413 ++++++++++++++++++ include/vcl/svlbitm.hxx | 282 ++++++++++++ include/vcl/transfer.hxx | 507 +++++++++++++++++++++ include/vcl/treelist.hxx | 339 ++++++++++++++ include/vcl/treelistbox.hxx | 800 +++++++++++++++++++++++++++++++++ include/vcl/treelistentries.hxx | 21 + include/vcl/treelistentry.hxx | 122 ++++++ include/vcl/uitest/uiobject.hxx | 50 +++ include/vcl/viewdataentry.hxx | 84 ++++ 49 files changed, 3183 insertions(+), 2728 deletions(-) delete mode 100644 include/svtools/imap.hxx delete mode 100644 include/svtools/imapcirc.hxx delete mode 100644 include/svtools/imapobj.hxx delete mode 100644 include/svtools/imappoly.hxx delete mode 100644 include/svtools/imaprect.hxx delete mode 100644 include/svtools/inetimg.hxx delete mode 100644 include/svtools/svlbitm.hxx delete mode 100644 include/svtools/transfer.hxx delete mode 100644 include/svtools/treelist.hxx delete mode 100644 include/svtools/treelistbox.hxx delete mode 100644 include/svtools/treelistentries.hxx delete mode 100644 include/svtools/treelistentry.hxx delete mode 100644 include/svtools/viewdataentry.hxx create mode 100644 include/vcl/imap.hxx create mode 100644 include/vcl/imapcirc.hxx create mode 100644 include/vcl/imapobj.hxx create mode 100644 include/vcl/imappoly.hxx create mode 100644 include/vcl/imaprect.hxx create mode 100644 include/vcl/inetimg.hxx create mode 100644 include/vcl/svimpbox.hxx create mode 100644 include/vcl/svlbitm.hxx create mode 100644 include/vcl/transfer.hxx create mode 100644 include/vcl/treelist.hxx create mode 100644 include/vcl/treelistbox.hxx create mode 100644 include/vcl/treelistentries.hxx create mode 100644 include/vcl/treelistentry.hxx create mode 100644 include/vcl/viewdataentry.hxx (limited to 'include') diff --git a/include/svtools/accessiblefactory.hxx b/include/svtools/accessiblefactory.hxx index bfd6e9a57cc9..05c5715cc0ef 100644 --- a/include/svtools/accessiblefactory.hxx +++ b/include/svtools/accessiblefactory.hxx @@ -105,12 +105,6 @@ namespace svt VCLXWindow* pVclXWindow, TextEngine& rEngine, TextView& rView ) const = 0; - virtual css::uno::Reference< css::accessibility::XAccessible > - createAccessibleTreeListBox( - SvTreeListBox& _rListBox, - const css::uno::Reference< css::accessibility::XAccessible >& _xParent - ) const = 0; - virtual css::uno::Reference< css::accessibility::XAccessible > createAccessibleBrowseBoxHeaderBar( const css::uno::Reference< css::accessibility::XAccessible >& rxParent, diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx index 3311843c658d..e300fe997fa6 100644 --- a/include/svtools/brwbox.hxx +++ b/include/svtools/brwbox.hxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svtools/embedtransfer.hxx b/include/svtools/embedtransfer.hxx index 7a6fa184b563..ca69d2b28386 100644 --- a/include/svtools/embedtransfer.hxx +++ b/include/svtools/embedtransfer.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include class Graphic; diff --git a/include/svtools/fileview.hxx b/include/svtools/fileview.hxx index 973313dadd4a..af19027a2601 100644 --- a/include/svtools/fileview.hxx +++ b/include/svtools/fileview.hxx @@ -16,8 +16,8 @@ * 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_SVTOOLS_FILEVIEW_HXX -#define INCLUDED_SVTOOLS_FILEVIEW_HXX +#ifndef INCLUDED_VCL_FILEVIEW_HXX +#define INCLUDED_VCL_FILEVIEW_HXX #include #include @@ -222,6 +222,6 @@ public: } -#endif // INCLUDED_SVTOOLS_FILEVIEW_HXX +#endif // INCLUDED_VCL_FILEVIEW_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/foldertree.hxx b/include/svtools/foldertree.hxx index 5f71cbf244b9..8f925de475ae 100644 --- a/include/svtools/foldertree.hxx +++ b/include/svtools/foldertree.hxx @@ -17,7 +17,6 @@ #include #include -#include #include @@ -25,6 +24,7 @@ #include #include +#include using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; diff --git a/include/svtools/iconview.hxx b/include/svtools/iconview.hxx index 0bc974051f0d..2281d35e94d4 100644 --- a/include/svtools/iconview.hxx +++ b/include/svtools/iconview.hxx @@ -21,7 +21,7 @@ #define INCLUDED_SVTOOLS_ICONVIEW_HXX #include -#include +#include class IconView : public SvTreeListBox { diff --git a/include/svtools/imap.hxx b/include/svtools/imap.hxx deleted file mode 100644 index 98835c15bb19..000000000000 --- a/include/svtools/imap.hxx +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- 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_SVTOOLS_IMAP_HXX -#define INCLUDED_SVTOOLS_IMAP_HXX - -#include -#include -#include -#include -#include - -class Point; -namespace tools { class Rectangle; } -class Size; -class Fraction; -class IMapObject; - -class SVT_DLLPUBLIC ImageMap final -{ -private: - - std::vector> maList; - OUString aName; - - // binary saving/loading - void ImpWriteImageMap( SvStream& rOStm ) const ; - void ImpReadImageMap( SvStream& rIStm, size_t nCount ); - - // Import/Export - void ImpWriteCERN( SvStream& rOStm ) const; - void ImpWriteNCSA( SvStream& rOStm ) const; - void ImpReadCERN( SvStream& rOStm ); - void ImpReadNCSA( SvStream& rOStm ); - - void ImpReadCERNLine( const OString& rLine ); - static Point ImpReadCERNCoords( const char** ppStr ); - static long ImpReadCERNRadius( const char** ppStr ); - static OUString ImpReadCERNURL( const char** ppStr ); - - void ImpReadNCSALine( const OString& rLine ); - static OUString ImpReadNCSAURL( const char** ppStr ); - static Point ImpReadNCSACoords( const char** ppStr ); - - static sal_uLong ImpDetectFormat( SvStream& rIStm ); - -public: - - ImageMap() {}; - ImageMap( const OUString& rName ); - ImageMap( const ImageMap& rImageMap ); - - // all IMapObjects are destroyed in the destructor - ~ImageMap(); - - ImageMap& operator=( const ImageMap& rImageMap ); - - // comparison (everything is checked for equality) - bool operator==( const ImageMap& rImageMap ); - bool operator!=( const ImageMap& rImageMap ); - - // a new IMap object is inserted at the end of the Map - void InsertIMapObject( const IMapObject& rIMapObject ); - void InsertIMapObject( std::unique_ptr rIMapObject ); - - // access to the single ImapObjects; the objects may - // not be destroyed from outside - IMapObject* GetIMapObject( size_t nPos ) const - { - return ( nPos < maList.size() ) ? maList[ nPos ].get() : nullptr; - } - - // returns the object which was hit first or NULL; - // size and position values are in 1/100mm; - // rTotalSize is the original size of the image - // rDisplaySize is the current size; - // rRelPoint relates to the display size and the upper left - // corner of the image - IMapObject* GetHitIMapObject( const Size& rOriginalSize, - const Size& rDisplaySize, - const Point& rRelHitPoint, - sal_uLong nFlags = 0 ); - - // returns the total amount of IMap objects - size_t GetIMapObjectCount() const { return maList.size(); } - - // deletes all internal objects - void ClearImageMap(); - - const OUString& GetName() const { return aName; } - void SetName( const OUString& rName ) { aName = rName; } - - // scales all objects of the ImageMap according to the given factor - void Scale( const Fraction& rFractX, const Fraction& rFracY ); - - // Import/Export - void Write ( SvStream& rOStm ) const; - void Read( SvStream& rIStm ); - - void Write( SvStream& rOStm, sal_uLong nFormat ) const; - sal_uLong Read( SvStream& rIStm, sal_uLong nFormat ); -}; - -class IMapCompat -{ - SvStream* pRWStm; - sal_uInt64 nCompatPos; - sal_uInt64 nTotalSize; - StreamMode const nStmMode; - - IMapCompat( const IMapCompat& ) = delete; - IMapCompat& operator=( const IMapCompat& ) { return *this; } - -public: - - IMapCompat( SvStream& rStm, const StreamMode nStreamMode ); - ~IMapCompat(); -}; - -#endif // INCLUDED_SVTOOLS_IMAP_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/imapcirc.hxx b/include/svtools/imapcirc.hxx deleted file mode 100644 index 92e06ed88e0c..000000000000 --- a/include/svtools/imapcirc.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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_SVTOOLS_IMAPCIRC_HXX -#define INCLUDED_SVTOOLS_IMAPCIRC_HXX - -#include -#include -#include - -class Fraction; - -class SVT_DLLPUBLIC IMapCircleObject : public IMapObject -{ - Point aCenter; - sal_Int32 nRadius; - - void ImpConstruct( const Point& rCenter, sal_uLong nRad, bool bPixel ); - -protected: - - // binary import/export - virtual void WriteIMapObject( SvStream& rOStm ) const override; - virtual void ReadIMapObject( SvStream& rIStm ) override; - -public: - - IMapCircleObject() : nRadius(0) {} - IMapCircleObject( const Point& rCenter, sal_uLong nRad, - const OUString& rURL, - const OUString& rAltText, - const OUString& rDesc, - const OUString& rTarget, - const OUString& rName, - bool bActive = true, - bool bPixelCoords = true ); - - virtual sal_uInt16 GetType() const override; - virtual bool IsHit( const Point& rPoint ) const override; - - Point GetCenter( bool bPixelCoords = true ) const; - sal_uLong GetRadius( bool bPixelCoords = true ) const; - - void Scale( const Fraction& rFractX, const Fraction& rFracY ); - - using IMapObject::IsEqual; - bool IsEqual( const IMapCircleObject& rEqObj ); - - // import/export - void WriteCERN( SvStream& rOStm ) const; - void WriteNCSA( SvStream& rOStm ) const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/imapobj.hxx b/include/svtools/imapobj.hxx deleted file mode 100644 index be3261abe5e0..000000000000 --- a/include/svtools/imapobj.hxx +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- 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_SVTOOLS_IMAPOBJ_HXX -#define INCLUDED_SVTOOLS_IMAPOBJ_HXX - -#include -#include -#include - -class Point; -namespace tools { class Rectangle; } -class SvStream; - -#define IMAP_OBJ_RECTANGLE (sal_uInt16(0x0001)) -#define IMAP_OBJ_CIRCLE (sal_uInt16(0x0002)) -#define IMAP_OBJ_POLYGON (sal_uInt16(0x0003)) -#define IMAP_OBJ_VERSION (sal_uInt16(0x0005)) - -#define IMAGE_MAP_VERSION (sal_uInt16(0x0001)) - -#define IMAPMAGIC "SDIMAP" - -#define IMAP_MIRROR_HORZ 0x00000001L -#define IMAP_MIRROR_VERT 0x00000002L - -#define IMAP_FORMAT_BIN 0x00000001L -#define IMAP_FORMAT_CERN 0x00000002L -#define IMAP_FORMAT_NCSA 0x00000004L -#define IMAP_FORMAT_DETECT 0xffffffffL - -#define IMAP_ERR_OK 0x00000000L -#define IMAP_ERR_FORMAT 0x00000001L - -class SVT_DLLPUBLIC IMapObject -{ - friend class ImageMap; - - OUString aURL; - OUString aAltText; - OUString aDesc; - OUString aTarget; - OUString aName; - SvxMacroTableDtor aEventList; - bool bActive; - -protected: - sal_uInt16 nReadVersion; - - // binary import/export - virtual void WriteIMapObject( SvStream& rOStm ) const = 0; - virtual void ReadIMapObject( SvStream& rIStm ) = 0; - - // helper methods - static void AppendCERNCoords(OStringBuffer& rBuf, const Point& rPoint100); - void AppendCERNURL(OStringBuffer& rBuf) const; - static void AppendNCSACoords(OStringBuffer& rBuf, const Point& rPoint100); - void AppendNCSAURL(OStringBuffer&rBuf) const; - -public: - - static rtl_TextEncoding nActualTextEncoding; - - IMapObject(); - IMapObject( const OUString& rURL, - const OUString& rAltText, - const OUString& rDesc, - const OUString& rTarget, - const OUString& rName, - bool bActive ); - virtual ~IMapObject() {}; - - IMapObject(IMapObject const &) = default; - IMapObject(IMapObject &&) = default; - IMapObject & operator =(IMapObject const &) = default; - IMapObject & operator =(IMapObject &&) = default; - - virtual sal_uInt16 GetType() const = 0; - virtual bool IsHit( const Point& rPoint ) const = 0; - - void Write ( SvStream& rOStm ) const; - void Read( SvStream& rIStm ); - - const OUString& GetURL() const { return aURL; } - void SetURL( const OUString& rURL ) { aURL = rURL; } - - const OUString& GetAltText() const { return aAltText; } - void SetAltText( const OUString& rAltText) { aAltText = rAltText; } - - const OUString& GetDesc() const { return aDesc; } - void SetDesc( const OUString& rDesc ) { aDesc = rDesc; } - - const OUString& GetTarget() const { return aTarget; } - void SetTarget( const OUString& rTarget ) { aTarget = rTarget; } - - const OUString& GetName() const { return aName; } - void SetName( const OUString& rName ) { aName = rName; } - - bool IsActive() const { return bActive; } - void SetActive( bool bSetActive ) { bActive = bSetActive; } - - bool IsEqual( const IMapObject& rEqObj ); - - // IMap-Events - const SvxMacroTableDtor& GetMacroTable() const { return aEventList;} - void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aEventList = rTbl; } -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/imappoly.hxx b/include/svtools/imappoly.hxx deleted file mode 100644 index 088cf9760deb..000000000000 --- a/include/svtools/imappoly.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- 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_SVTOOLS_IMAPPOLY_HXX -#define INCLUDED_SVTOOLS_IMAPPOLY_HXX - -#include -#include -#include - -class Fraction; - -class SVT_DLLPUBLIC IMapPolygonObject : public IMapObject -{ - tools::Polygon aPoly; - tools::Rectangle aEllipse; - bool bEllipse; - - SVT_DLLPRIVATE void ImpConstruct( const tools::Polygon& rPoly, bool bPixel ); - -protected: - - // binary import/export - virtual void WriteIMapObject( SvStream& rOStm ) const override; - virtual void ReadIMapObject( SvStream& rIStm ) override; - -public: - IMapPolygonObject() : bEllipse(false) {} - IMapPolygonObject( const tools::Polygon& rPoly, - const OUString& rURL, - const OUString& rAltText, - const OUString& rDesc, - const OUString& rTarget, - const OUString& rName, - bool bActive = true, - bool bPixelCoords = true ); - - virtual sal_uInt16 GetType() const override; - virtual bool IsHit( const Point& rPoint ) const override; - - tools::Polygon GetPolygon( bool bPixelCoords = true ) const; - - bool HasExtraEllipse() const { return bEllipse; } - const tools::Rectangle& GetExtraEllipse() const { return aEllipse; } - void SetExtraEllipse( const tools::Rectangle& rEllipse ); - - void Scale( const Fraction& rFractX, const Fraction& rFracY ); - - using IMapObject::IsEqual; - bool IsEqual( const IMapPolygonObject& rEqObj ); - - // import/export - void WriteCERN( SvStream& rOStm ) const; - void WriteNCSA( SvStream& rOStm ) const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/imaprect.hxx b/include/svtools/imaprect.hxx deleted file mode 100644 index 709f803cb9a4..000000000000 --- a/include/svtools/imaprect.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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_SVTOOLS_IMAPRECT_HXX -#define INCLUDED_SVTOOLS_IMAPRECT_HXX - -#include -#include -#include - -class Fraction; - -class SVT_DLLPUBLIC IMapRectangleObject : public IMapObject -{ - tools::Rectangle aRect; - - SVT_DLLPRIVATE void ImpConstruct( const tools::Rectangle& rRect, bool bPixel ); - -protected: - - // binary import/export - virtual void WriteIMapObject( SvStream& rOStm ) const override; - virtual void ReadIMapObject( SvStream& rIStm ) override; - -public: - - IMapRectangleObject() {}; - IMapRectangleObject( const tools::Rectangle& rRect, - const OUString& rURL, - const OUString& rAltText, - const OUString& rDesc, - const OUString& rTarget, - const OUString& rName, - bool bActive = true, - bool bPixelCoords = true ); - - virtual sal_uInt16 GetType() const override; - virtual bool IsHit( const Point& rPoint ) const override; - - tools::Rectangle GetRectangle( bool bPixelCoords = true ) const; - - void Scale( const Fraction& rFractX, const Fraction& rFracY ); - - using IMapObject::IsEqual; - bool IsEqual( const IMapRectangleObject& rEqObj ); - - // import/export - void WriteCERN( SvStream& rOStm ) const; - void WriteNCSA( SvStream& rOStm ) const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/inetimg.hxx b/include/svtools/inetimg.hxx deleted file mode 100644 index f173f7bc72e7..000000000000 --- a/include/svtools/inetimg.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- 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_SVTOOLS_INETIMG_HXX -#define INCLUDED_SVTOOLS_INETIMG_HXX - -#include -#include - -class SvData; -class SotDataObject; - - -class INetImage -{ - OUString aImageURL; - OUString aTargetURL; - OUString aTargetFrame; - Size aSizePixel; - -public: - INetImage( - const OUString& rImageURL, - const OUString& rTargetURL, - const OUString& rTargetFrame ) - : aImageURL( rImageURL ), - aTargetURL( rTargetURL ), - aTargetFrame( rTargetFrame ) - {} - INetImage() - {} - - const OUString& GetImageURL() const { return aImageURL; } - const OUString& GetTargetURL() const { return aTargetURL; } - const OUString& GetTargetFrame() const { return aTargetFrame; } - - // import/export - void Write( SvStream& rOStm, SotClipboardFormatId nFormat ) const; - bool Read( SvStream& rIStm, SotClipboardFormatId nFormat ); -}; - -#endif // INCLUDED_SVTOOLS_INETIMG_HXX - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/insdlg.hxx b/include/svtools/insdlg.hxx index 1c37552e87c1..9aae287249b8 100644 --- a/include/svtools/insdlg.hxx +++ b/include/svtools/insdlg.hxx @@ -26,7 +26,7 @@ #include #include -#include +#include class SvObjectServer { diff --git a/include/svtools/stringtransfer.hxx b/include/svtools/stringtransfer.hxx index a0b7f500ab43..6f65b746180b 100644 --- a/include/svtools/stringtransfer.hxx +++ b/include/svtools/stringtransfer.hxx @@ -21,7 +21,7 @@ #define INCLUDED_SVTOOLS_STRINGTRANSFER_HXX #include -#include +#include namespace svt diff --git a/include/svtools/svlbitm.hxx b/include/svtools/svlbitm.hxx deleted file mode 100644 index d0125b3a09a6..000000000000 --- a/include/svtools/svlbitm.hxx +++ /dev/null @@ -1,282 +0,0 @@ -/* -*- 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_SVTOOLS_SVLBITM_HXX -#define INCLUDED_SVTOOLS_SVLBITM_HXX - -#include -#include -#include -#include -#include -#include - -class SvTreeListEntry; - - -enum class SvBmp -{ - UNCHECKED = 0, - CHECKED = 1, - TRISTATE = 2, - HIUNCHECKED = 3, - HICHECKED = 4, - HITRISTATE = 5, - STATICIMAGE = 6 -}; - -enum class SvItemStateFlags -{ - NONE = 0x00, - UNCHECKED = 0x01, - CHECKED = 0x02, - TRISTATE = 0x04, - HILIGHTED = 0x08 -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -struct SvLBoxButtonData_Impl; - -class SVT_DLLPUBLIC SvLBoxButtonData -{ -private: - Link aLink; - long nWidth; - long nHeight; - std::unique_ptr pImpl; - bool bDataOk; - std::vector aBmps; // indices s. constants BMP_ .... - - SVT_DLLPRIVATE void SetWidthAndHeight(); - SVT_DLLPRIVATE void InitData( bool _bRadioBtn, const Control* pControlForSettings ); -public: - // include creating default images (CheckBox or RadioButton) - SvLBoxButtonData( const Control* pControlForSettings ); - SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn ); - - ~SvLBoxButtonData(); - - static SvBmp GetIndex( SvItemStateFlags nItemState ); - long Width(); - long Height(); - void SetLink( const Link& rLink) { aLink=rLink; } - bool IsRadio(); - // as buttons are not derived from LinkHdl - void CallLink(); - - void StoreButtonState( SvTreeListEntry* pEntry ); - static SvButtonState ConvertToButtonState( SvItemStateFlags nItemFlags ); - - SvTreeListEntry* GetActEntry() const; - - void SetImage(SvBmp nIndex, const Image& aImage) { aBmps[static_cast(nIndex)] = aImage; } - Image& GetImage(SvBmp nIndex) { return aBmps[static_cast(nIndex)]; } - - void SetDefaultImages( const Control* pControlForSettings ); - // set images according to the color scheme of the Control - // pControlForSettings == NULL: settings are taken from Application - bool HasDefaultImages() const; -}; - -// ********************************************************************** - -class SVT_DLLPUBLIC SvLBoxString : public SvLBoxItem -{ -protected: - OUString maText; - -public: - SvLBoxString(const OUString& rText); - SvLBoxString(); - virtual ~SvLBoxString() override; - - virtual SvLBoxItemType GetType() const override; - virtual void InitViewData(SvTreeListBox* pView, - SvTreeListEntry* pEntry, - SvViewDataItem* pViewData = nullptr) override; - - const OUString& GetText() const - { - return maText; - } - void SetText(const OUString& rText) - { - maText = rText; - } - - virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, - vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, - const SvTreeListEntry& rEntry) override; - - virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; -}; - -class SVT_DLLPUBLIC SvLBoxButton : public SvLBoxItem -{ - bool isVis; - SvLBoxButtonData* pData; - SvLBoxButtonKind const eKind; - SvItemStateFlags nItemFlags; - - static void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::RenderContext const & pRenderContext); -public: - // An SvLBoxButton can be of three different kinds: an - // enabled checkbox (the normal kind), a disabled checkbox - // (which cannot be modified via UI), or a static image - // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored - // for that kind). - SvLBoxButton( SvLBoxButtonKind eTheKind, SvLBoxButtonData* pBData ); - SvLBoxButton(); - virtual ~SvLBoxButton() override; - virtual void InitViewData(SvTreeListBox* pView, - SvTreeListEntry* pEntry, - SvViewDataItem* pViewData = nullptr) override; - - virtual SvLBoxItemType GetType() const override; - void ClickHdl( SvTreeListEntry* ); - - virtual void Paint(const Point& rPos, - SvTreeListBox& rOutDev, - vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, - const SvTreeListEntry& rEntry) override; - - virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; - - SvItemStateFlags GetButtonFlags() const - { - return nItemFlags; - } - bool IsStateChecked() const - { - return bool(nItemFlags & SvItemStateFlags::CHECKED); - } - bool IsStateUnchecked() const - { - return bool(nItemFlags & SvItemStateFlags::UNCHECKED); - } - bool IsStateTristate() const - { - return bool(nItemFlags & SvItemStateFlags::TRISTATE); - } - bool IsStateHilighted() const - { - return bool(nItemFlags & SvItemStateFlags::HILIGHTED); - } - void SetStateChecked(); - void SetStateUnchecked(); - void SetStateTristate(); - void SetStateHilighted(bool bHilight); - void SetStateInvisible(); - - SvLBoxButtonKind GetKind() const { return eKind; } - - // Check whether this button can be modified via UI - bool CheckModification() const; -}; - -inline void SvLBoxButton::SetStateChecked() -{ - nItemFlags &= SvItemStateFlags::HILIGHTED; - nItemFlags |= SvItemStateFlags::CHECKED; -} - -inline void SvLBoxButton::SetStateUnchecked() -{ - nItemFlags &= SvItemStateFlags::HILIGHTED; - nItemFlags |= SvItemStateFlags::UNCHECKED; -} -inline void SvLBoxButton::SetStateTristate() -{ - nItemFlags &= SvItemStateFlags::HILIGHTED; - nItemFlags |= SvItemStateFlags::TRISTATE; -} -inline void SvLBoxButton::SetStateHilighted( bool bHilight ) -{ - if ( bHilight ) - nItemFlags |= SvItemStateFlags::HILIGHTED; - else - nItemFlags &= ~SvItemStateFlags::HILIGHTED; -} - -struct SvLBoxContextBmp_Impl; - -class SVT_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem -{ - std::unique_ptr m_pImpl; -public: - SvLBoxContextBmp(const Image& aBmp1, - const Image& aBmp2, - bool bExpanded); - SvLBoxContextBmp(); - virtual ~SvLBoxContextBmp() override; - - virtual SvLBoxItemType GetType() const override; - virtual void InitViewData(SvTreeListBox* pView, - SvTreeListEntry* pEntry, - SvViewDataItem* pViewData = nullptr) override; - virtual void Paint(const Point& rPos, - SvTreeListBox& rOutDev, - vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, - const SvTreeListEntry& rEntry) override; - - virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; - - void SetModeImages(const Image& rBitmap1, const Image& rBitmap2); - - inline void SetBitmap1(const Image& rImage); - inline void SetBitmap2(const Image& rImage); - inline const Image& GetBitmap1() const; - inline const Image& GetBitmap2() const; - -private: - Image& implGetImageStore(bool bFirst); -}; - -inline void SvLBoxContextBmp::SetBitmap1(const Image& _rImage) -{ - implGetImageStore(true) = _rImage; -} - -inline void SvLBoxContextBmp::SetBitmap2(const Image& _rImage) -{ - implGetImageStore(false) = _rImage; -} - -inline const Image& SvLBoxContextBmp::GetBitmap1() const -{ - Image& rImage = const_cast(this)->implGetImageStore(true); - return rImage; -} - -inline const Image& SvLBoxContextBmp::GetBitmap2() const -{ - Image& rImage = const_cast(this)->implGetImageStore(false); - return rImage; -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/svtabbx.hxx b/include/svtools/svtabbx.hxx index 65277e05f372..c33ccc5993c8 100644 --- a/include/svtools/svtabbx.hxx +++ b/include/svtools/svtabbx.hxx @@ -20,7 +20,7 @@ #define INCLUDED_SVTOOLS_SVTABBX_HXX #include -#include +#include #include #include diff --git a/include/svtools/transfer.hxx b/include/svtools/transfer.hxx deleted file mode 100644 index 24ddf24be61f..000000000000 --- a/include/svtools/transfer.hxx +++ /dev/null @@ -1,507 +0,0 @@ -/* -*- 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_SVTOOLS_TRANSFER_HXX -#define INCLUDED_SVTOOLS_TRANSFER_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class BitmapEx; -class GDIMetaFile; -class Graphic; -class ImageMap; -class INetBookmark; -class INetImage; -class FileList; -class SotStorageStream; -namespace vcl { class Window; } - -// Drag&Drop defines - -#define DND_ACTION_NONE css::datatransfer::dnd::DNDConstants::ACTION_NONE -#define DND_ACTION_COPY css::datatransfer::dnd::DNDConstants::ACTION_COPY -#define DND_ACTION_MOVE css::datatransfer::dnd::DNDConstants::ACTION_MOVE -#define DND_ACTION_COPYMOVE css::datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE -#define DND_ACTION_LINK css::datatransfer::dnd::DNDConstants::ACTION_LINK - -#define DND_POINTER_NONE 0 -#define DND_IMAGE_NONE 0 - -struct TransferableObjectDescriptor -{ - SvGlobalName maClassName; - sal_uInt16 mnViewAspect; - Point maDragStartPos; - Size maSize; - OUString maTypeName; - OUString maDisplayName; - - TransferableObjectDescriptor() - : mnViewAspect(css::embed::Aspects::MSOLE_CONTENT) - {} - - SVT_DLLPUBLIC friend SvStream& WriteTransferableObjectDescriptor( SvStream& rOStm, const TransferableObjectDescriptor& rObjDesc ); -}; - -struct AcceptDropEvent -{ - sal_Int8 mnAction; - Point maPosPixel; - const css::datatransfer::dnd::DropTargetDragEvent maDragEvent; - bool mbLeaving; - bool mbDefault; - - AcceptDropEvent() : - mnAction( DND_ACTION_NONE ), - mbLeaving( false ), - mbDefault( false ) {} - - AcceptDropEvent( sal_Int8 nAction, - const Point& rPosPixel, - const css::datatransfer::dnd::DropTargetDragEvent& rDragEvent ) : - mnAction( nAction ), - maPosPixel( rPosPixel ), - maDragEvent( rDragEvent ), - mbLeaving( false ), - mbDefault( false ) {} -}; - -struct ExecuteDropEvent -{ - sal_Int8 mnAction; - Point maPosPixel; - const css::datatransfer::dnd::DropTargetDropEvent maDropEvent; - bool mbDefault; - - ExecuteDropEvent( sal_Int8 nAction, - const Point& rPosPixel, - const css::datatransfer::dnd::DropTargetDropEvent& rDropEvent ) : - mnAction( nAction ), - maPosPixel( rPosPixel ), - maDropEvent( rDropEvent ), - mbDefault( false ) {} -}; - -class SVT_DLLPUBLIC TransferableHelper : public cppu::WeakImplHelper< css::datatransfer::XTransferable2, - css::datatransfer::clipboard::XClipboardOwner, - css::datatransfer::dnd::XDragSourceListener, - css::lang::XUnoTunnel > -{ -private: - - // nested class to implement the XTerminateListener interface - class TerminateListener : public cppu::WeakImplHelper< css::frame::XTerminateListener, css::lang::XServiceInfo > - { - private: - - TransferableHelper& mrParent; - - private: - - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - - // XTerminateListener - virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override; - virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - public: - - TerminateListener( TransferableHelper& rDropTargetHelper ); - virtual ~TerminateListener() override; - }; - - friend class TransferableHelper::TerminateListener; - -private: - - css::uno::Any maAny; - OUString maLastFormat; - mutable css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; - css::uno::Reference< css::frame::XTerminateListener > mxTerminateListener; - DataFlavorExVector maFormats; - std::unique_ptr mxObjDesc; - -protected: - const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& - getOwnClipboard() const { return mxClipboard; } - -private: - - // XTransferable - virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& rFlavor ) override; - virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override; - virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& rFlavor ) override; - - // Transferable2 - virtual css::uno::Any SAL_CALL getTransferData2( - const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; - - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - - // XDragSourceListener - virtual void SAL_CALL dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override; - virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; - virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DragSourceEvent& dse ) override; - virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; - virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; - -private: - - // XClipboardOwner - virtual void SAL_CALL lostOwnership( const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& xClipboard, const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) override; - -protected: - // derivees need to access lostOwnership in case hey override it - // on windows, changing the access rights to a method gives unresolved externals, so we introduce - // this impl-method here 'til the next incompatible update - void implCallOwnLostOwnership( - const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& _rxClipboard, - const css::uno::Reference< css::datatransfer::XTransferable >& _rxTrans - ) - { - TransferableHelper::lostOwnership( _rxClipboard, _rxTrans ); - } - - -private: - - SVT_DLLPRIVATE void ImplFlush(); - -protected: - - void AddFormat( SotClipboardFormatId nFormat ); - void AddFormat( const css::datatransfer::DataFlavor& rFlavor ); - void RemoveFormat( SotClipboardFormatId nFormat ); - void RemoveFormat( const css::datatransfer::DataFlavor& rFlavor ); - bool HasFormat( SotClipboardFormatId nFormat ); - void ClearFormats(); - - bool SetAny( const css::uno::Any& rAny ); - bool SetString( const OUString& rString, const css::datatransfer::DataFlavor& rFlavor ); - bool SetBitmapEx( const BitmapEx& rBitmap, const css::datatransfer::DataFlavor& rFlavor ); - bool SetGDIMetaFile( const GDIMetaFile& rMtf ); - bool SetGraphic( const Graphic& rGraphic ); - bool SetImageMap( const ImageMap& rIMap ); - bool SetTransferableObjectDescriptor( const TransferableObjectDescriptor& rDesc ); - bool SetINetBookmark( const INetBookmark& rBmk, const css::datatransfer::DataFlavor& rFlavor ); - bool SetINetImage( const INetImage& rINtImg, const css::datatransfer::DataFlavor& rFlavor ); - bool SetObject( void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ); - -protected: - - virtual void AddSupportedFormats() = 0; - virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) = 0; - virtual bool WriteObject( tools::SvRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ); - virtual void DragFinished( sal_Int8 nDropAction ); - virtual void ObjectReleased(); - -public: - - void PrepareOLE( const TransferableObjectDescriptor& rObjDesc ); - - void CopyToClipboard( vcl::Window *pWindow ) const; - void CopyToSelection( vcl::Window *pWindow ) const; - void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, - sal_Int32 nDragPointer = DND_POINTER_NONE ); - - static void ClearSelection( vcl::Window *pWindow ); - - static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); - -public: - - virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; -}; - -struct TransferableDataHelper_Impl; - -class SVT_DLLPUBLIC TransferableDataHelper final -{ - friend class DropTargetHelper; - - css::uno::Reference< css::datatransfer::XTransferable > mxTransfer; - css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; - DataFlavorExVector maFormats; - std::unique_ptr mxObjDesc; - std::unique_ptr mxImpl; - - void InitFormats(); - -public: - - static void FillDataFlavorExVector( const css::uno::Sequence< css::datatransfer::DataFlavor >& rDataFlavorSeq, - DataFlavorExVector& rDataFlavorExVector ); - - TransferableDataHelper(); - TransferableDataHelper( const TransferableDataHelper& rDataHelper ); - TransferableDataHelper( TransferableDataHelper&& rDataHelper ); - TransferableDataHelper( const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable ); - ~TransferableDataHelper(); - - TransferableDataHelper& operator=( const TransferableDataHelper& rDataHelper ); - TransferableDataHelper& operator=( TransferableDataHelper&& rDataHelper ); - - const css::uno::Reference< css::datatransfer::XTransferable >& GetTransferable() const { return mxTransfer; } - css::uno::Reference< css::datatransfer::XTransferable > GetXTransferable() const; - - bool HasFormat( SotClipboardFormatId nFormat ) const; - bool HasFormat( const css::datatransfer::DataFlavor& rFlavor ) const; - - sal_uInt32 GetFormatCount() const; - - SotClipboardFormatId GetFormat( sal_uInt32 nFormat ) const; - css::datatransfer::DataFlavor GetFormatDataFlavor( sal_uInt32 nFormat ) const; - - const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } - - bool StartClipboardListening( ); - void StopClipboardListening( ); - - void Rebind( const css::uno::Reference< css::datatransfer::XTransferable >& _rxNewData ); - - css::uno::Any GetAny( SotClipboardFormatId nFormat, const OUString& rDestDoc ) const; - css::uno::Any GetAny( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) const; - - bool GetString( SotClipboardFormatId nFormat, OUString& rStr ); - bool GetString( const css::datatransfer::DataFlavor& rFlavor, OUString& rStr ); - - bool GetBitmapEx( SotClipboardFormatId nFormat, BitmapEx& rBmp ); - bool GetBitmapEx( const css::datatransfer::DataFlavor& rFlavor, BitmapEx& rBmp ); - - /** Return as GDI metafile. - - @param nMaxAction Allows you to limit the amount of actions; defaults to 0 which means no limit. - - When you eg. Ctrl+a in Excel, you can get the entire sheet as - metafile, with over 3 million (!) actions; which is just too large for - any reasonable handling - and you need to set a limit. - */ - bool GetGDIMetaFile( SotClipboardFormatId nFormat, GDIMetaFile& rMtf, size_t nMaxActions = 0 ); - bool GetGDIMetaFile( const css::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf ); - - bool GetGraphic( SotClipboardFormatId nFormat, Graphic& rGraphic ); - bool GetGraphic( const css::datatransfer::DataFlavor& rFlavor, Graphic& rGraphic ); - - bool GetImageMap( SotClipboardFormatId nFormat, ImageMap& rIMap ); - bool GetImageMap( const css::datatransfer::DataFlavor& rFlavor, ImageMap& rImap ); - - bool GetTransferableObjectDescriptor( SotClipboardFormatId nFormat, TransferableObjectDescriptor& rDesc ); - bool GetTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ); - - bool GetINetBookmark( SotClipboardFormatId nFormat, INetBookmark& rBmk ); - bool GetINetBookmark( const css::datatransfer::DataFlavor& rFlavor, INetBookmark& rBmk ); - - bool GetINetImage( SotClipboardFormatId nFormat, INetImage& rINtImg ); - bool GetINetImage( const css::datatransfer::DataFlavor& rFlavor, INetImage& rINtImg ); - - bool GetFileList( SotClipboardFormatId nFormat, FileList& rFileList ); - bool GetFileList( FileList& rFileList ); - - css::uno::Sequence GetSequence( SotClipboardFormatId nFormat, const OUString& rDestDoc ); - css::uno::Sequence GetSequence( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); - - bool GetSotStorageStream( SotClipboardFormatId nFormat, tools::SvRef& rStreamRef ); - bool GetSotStorageStream( const css::datatransfer::DataFlavor& rFlavor, tools::SvRef& rStreamRef ); - - css::uno::Reference GetInputStream( SotClipboardFormatId nFormat, const OUString& rDestDoc ); - css::uno::Reference GetInputStream( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); - - static TransferableDataHelper CreateFromSystemClipboard( vcl::Window * pWindow ); - static TransferableDataHelper CreateFromSelection( vcl::Window * pWindow ); - static bool IsEqual( const css::datatransfer::DataFlavor& rInternalFlavor, - const css::datatransfer::DataFlavor& rRequestFlavor ); -}; - -class SVT_DLLPUBLIC DragSourceHelper -{ -private: - - // nested class to implement the XDragGestureListener interface - class DragGestureListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDragGestureListener > - { - private: - - DragSourceHelper& mrParent; - - private: - - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - - // XDragGestureListener - virtual void SAL_CALL dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE ) override; - - public: - - DragGestureListener( DragSourceHelper& rDragSourceHelper ); - virtual ~DragGestureListener() override; - }; - - friend class DragSourceHelper::DragGestureListener; - -private: - osl::Mutex maMutex; - css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > mxDragGestureRecognizer; - - css::uno::Reference< css::datatransfer::dnd::XDragGestureListener > mxDragGestureListener; - - DragSourceHelper& operator=( const DragSourceHelper& rDragSourceHelper ) = delete; - bool operator==( const DragSourceHelper& rDragSourceHelper ) const = delete; - -public: - - // to be overridden by the application - virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); - - DragSourceHelper( vcl::Window* pWindow ); - void dispose(); - virtual ~DragSourceHelper(); -}; - -class SVT_DLLPUBLIC DropTargetHelper -{ -private: - - // nested class to implement the XDropTargetListener interface - class DropTargetListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener > - { - private: - - DropTargetHelper& mrParent; - std::unique_ptr mpLastDragOverEvent; - - // XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; - - // XDropTargetListener - virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override; - virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override; - virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override; - virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; - virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; - - public: - - DropTargetListener( DropTargetHelper& rDropTargetHelper ); - virtual ~DropTargetListener() override; - }; - - friend class DropTargetHelper::DropTargetListener; - -private: - osl::Mutex maMutex; - css::uno::Reference< css::datatransfer::dnd::XDropTarget > mxDropTarget; - - css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > mxDropTargetListener; - DataFlavorExVector maFormats; - - DropTargetHelper() = delete; - DropTargetHelper& operator=( const DropTargetHelper& rDropTargetHelper ) = delete; - bool operator==( const DropTargetHelper& rDropTargetHelper ) const = delete; - - void ImplConstruct(); - - // called by our own implementation of XDropTargetListener (DropTargetListener instance) - void ImplBeginDrag( const css::uno::Sequence< css::datatransfer::DataFlavor >& rSupportedDataFlavors ); - void ImplEndDrag(); - -public: - - // to be overridden by the application - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); - - DropTargetHelper( vcl::Window* pWindow ); - DropTargetHelper( const css::uno::Reference< css::datatransfer::dnd::XDropTarget >& rxDropTarget ); - - void dispose(); - virtual ~DropTargetHelper(); - - // typically called by the application in ::AcceptDrop and ::ExecuteDrop and (see above) - bool IsDropFormatSupported( SotClipboardFormatId nFormat ); - - const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } - -}; - -struct TransferDataContainer_Impl; - -class SVT_DLLPUBLIC TransferDataContainer : public TransferableHelper -{ - std::unique_ptr pImpl; - -protected: - - virtual void AddSupportedFormats() override; - virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; - virtual void DragFinished( sal_Int8 nDropAction ) override; - -public: - - TransferDataContainer(); - virtual ~TransferDataContainer() override; - - void CopyINetBookmark( const INetBookmark& rBkmk ); - void CopyString( const OUString& rStr ); - void CopyString( SotClipboardFormatId nFmt, const OUString& rStr ); - void CopyAny( SotClipboardFormatId nFmt, const css::uno::Any& rAny ); - - void CopyByteString( SotClipboardFormatId nFormatId, const OString& rStr ); - void CopyAnyData( SotClipboardFormatId nFormatId, const sal_Char* pData, sal_uLong nLen ); - - bool HasAnyData() const; - - using TransferableHelper::StartDrag; - void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, - const Link& rCallbck ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/treelist.hxx b/include/svtools/treelist.hxx deleted file mode 100644 index 0d190ab3a022..000000000000 --- a/include/svtools/treelist.hxx +++ /dev/null @@ -1,339 +0,0 @@ -/* -*- 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_SVTOOLS_TREELIST_HXX -#define INCLUDED_SVTOOLS_TREELIST_HXX - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -enum class SvListAction -{ - INSERTED = 1, - REMOVING = 2, - REMOVED = 3, - MOVING = 4, - MOVED = 5, - CLEARING = 6, - INSERTED_TREE = 7, - INVALIDATE_ENTRY = 8, - RESORTING = 9, - RESORTED = 10, - CLEARED = 11, - REVERSING = 12, - REVERSED = 13 -}; - -class SvTreeListEntry; -class SvListView; - -enum SvSortMode { SortAscending, SortDescending, SortNone }; - -// For the return values of Sortlink: -// See International::Compare( pLeft, pRight ) -// ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) ) -struct SvSortData -{ - const SvTreeListEntry* pLeft; - const SvTreeListEntry* pRight; -}; - -class SVT_DLLPUBLIC SvTreeList final -{ - typedef std::vector ListViewsType; - - friend class SvListView; - - ListViewsType aViewList; - sal_uLong nEntryCount; - - Link aCloneLink; - Link aCompareLink; - SvSortMode eSortMode; - - sal_uInt16 nRefCount; - - bool bAbsPositionsValid; - - bool mbEnableInvalidate; - - SvTreeListEntry* FirstVisible() const { return First(); } - SvTreeListEntry* NextVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const; - SvTreeListEntry* PrevVisible( const SvListView*,SvTreeListEntry* pEntry ) const; - SvTreeListEntry* LastVisible( const SvListView* ) const; - SvTreeListEntry* NextVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const; - SvTreeListEntry* PrevVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const; - - bool IsEntryVisible( const SvListView*,SvTreeListEntry* pEntry ) const; - SvTreeListEntry* GetEntryAtVisPos( const SvListView*,sal_uLong nVisPos ) const; - sal_uLong GetVisiblePos( const SvListView*,SvTreeListEntry const * pEntry ) const; - sal_uLong GetVisibleCount( SvListView* ) const; - sal_uLong GetVisibleChildCount( const SvListView*,SvTreeListEntry* pParent ) const; - - SvTreeListEntry* FirstSelected( const SvListView*) const; - SvTreeListEntry* NextSelected( const SvListView*,SvTreeListEntry* pEntry ) const; - SvTreeListEntry* PrevSelected( const SvListView*,SvTreeListEntry* pEntry ) const; - SvTreeListEntry* LastSelected( const SvListView*) const; - - static bool Select( SvListView*,SvTreeListEntry* pEntry, bool bSelect ); - sal_uLong GetChildSelectionCount( const SvListView*,SvTreeListEntry* pParent ) const; - - static void Expand( SvListView*,SvTreeListEntry* pParent ); - static void Collapse( SvListView*,SvTreeListEntry* pParent ); - - SVT_DLLPRIVATE void SetAbsolutePositions(); - - SVT_DLLPRIVATE void CloneChildren( - SvTreeListEntries& rDst, sal_uLong& rCloneCount, SvTreeListEntries& rSrc, SvTreeListEntry& rNewParent) const; - - /** - * Invalidate the cached position data to have them re-generated before - * the next access. - */ - SVT_DLLPRIVATE static void SetListPositions( SvTreeListEntries& rEntries ); - - // rPos is not changed for SortModeNone - SVT_DLLPRIVATE void GetInsertionPos( - SvTreeListEntry const * pEntry, - SvTreeListEntry* pParent, - sal_uLong& rPos - ); - - SVT_DLLPRIVATE void ResortChildren( SvTreeListEntry* pParent ); - SVT_DLLPRIVATE void ReverseChildren( SvTreeListEntry* pParent ); - - SvTreeList(const SvTreeList&) = delete; - SvTreeList& operator= (const SvTreeList&) = delete; - - std::unique_ptr pRootItem; - -public: - - SvTreeList(); - ~SvTreeList(); - - void InsertView( SvListView* ); - void RemoveView( SvListView const * ); - - void Broadcast( - SvListAction nActionId, - SvTreeListEntry* pEntry1=nullptr, - SvTreeListEntry* pEntry2=nullptr, - sal_uLong nPos=0 - ); - - void EnableInvalidate( bool bEnable ); - - // Notify all Listeners - void InvalidateEntry( SvTreeListEntry* ); - - sal_uLong GetEntryCount() const { return nEntryCount; } - SvTreeListEntry* First() const; - SvTreeListEntry* Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const; - SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const; - SvTreeListEntry* Last() const; - - SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; - - sal_uLong Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pPar,sal_uLong nPos = TREELIST_APPEND); - sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND ) - { return Insert(pEntry, pRootItem.get(), nRootPos ); } - - void InsertTree( SvTreeListEntry* pTree, SvTreeListEntry* pTargetParent, sal_uLong nListPos ); - - // Entries need to be in the same Model! - void Move( SvTreeListEntry* pSource, SvTreeListEntry* pTarget ); - - // Creates ChildList if needed - sal_uLong Move( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos); - sal_uLong Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos); - - bool Remove( const SvTreeListEntry* pEntry ); - void Clear(); - - bool HasChildren( const SvTreeListEntry* pEntry ) const; - bool HasParent( const SvTreeListEntry* pEntry ) const; - - bool IsChild(const SvTreeListEntry* pParent, const SvTreeListEntry* pChild) const; - SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const; - SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const; - SvTreeListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const; - - const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; - SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ); - - SvTreeListEntry* GetRootLevelParent( SvTreeListEntry* pEntry ) const; - const SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ) const; - SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ); - - std::pair - GetChildIterators(SvTreeListEntry* pParent); - - sal_uLong GetAbsPos( const SvTreeListEntry* pEntry ) const; - static sal_uLong GetRelPos( const SvTreeListEntry* pChild ); - - sal_uLong GetChildCount( const SvTreeListEntry* pParent ) const; - sal_uInt16 GetDepth( const SvTreeListEntry* pEntry ) const; - bool IsAtRootDepth( const SvTreeListEntry* pEntry ) const; - - // The Model calls the Clone Link to clone Entries. - // Thus we do not need to derive from the Model if we derive from SvTreeListEntry. - // The Handler needs to return a SvTreeListEntry* - SvTreeListEntry* Clone( SvTreeListEntry* pEntry, sal_uLong& nCloneCount ) const; - void SetCloneLink( const Link& rLink ) - { aCloneLink=rLink; } - - const Link& GetCloneLink() const - { return aCloneLink; } - - SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ) const; // Calls the Clone Link - - sal_uInt16 GetRefCount() const { return nRefCount; } - void SetRefCount( sal_uInt16 nRef ) { nRefCount = nRef; } - - void SetSortMode( SvSortMode eMode ) { eSortMode = eMode; } - SvSortMode GetSortMode() const { return eSortMode; } - sal_Int32 Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const; - void SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; } - void Resort(); - void Reverse(); -}; - -class SVT_DLLPUBLIC SvListView -{ - friend class SvTreeList; - - struct Impl; - std::unique_ptr m_pImpl; - -protected: - SvTreeList* pModel; - - void ExpandListEntry( SvTreeListEntry* pParent ) - { SvTreeList::Expand(this,pParent); } - - void CollapseListEntry( SvTreeListEntry* pParent ) - { SvTreeList::Collapse(this,pParent); } - - bool SelectListEntry( SvTreeListEntry* pEntry, bool bSelect ) - { return SvTreeList::Select(this,pEntry,bSelect); } - -public: - SvListView(); // Sets the Model to 0 - virtual ~SvListView(); - void Clear(); - virtual void SetModel( SvTreeList* ); - virtual void ModelNotification( - SvListAction nActionId, - SvTreeListEntry* pEntry1, - SvTreeListEntry* pEntry2, - sal_uLong nPos - ); - - sal_uLong GetVisibleCount() const - { return pModel->GetVisibleCount( const_cast(this) ); } - - SvTreeListEntry* FirstVisible() const - { return pModel->FirstVisible(); } - - SvTreeListEntry* NextVisible( SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const - { return pModel->NextVisible(this,pEntry,pDepth); } - - SvTreeListEntry* PrevVisible( SvTreeListEntry* pEntry ) const - { return pModel->PrevVisible(this,pEntry); } - - SvTreeListEntry* LastVisible() const - { return pModel->LastVisible(this); } - - SvTreeListEntry* NextVisible( SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const - { return pModel->NextVisible(this,pEntry,rDelta); } - - SvTreeListEntry* PrevVisible( SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const - { return pModel->PrevVisible(this,pEntry,rDelta); } - - sal_uLong GetSelectionCount() const; - - SvTreeListEntry* FirstSelected() const - { return pModel->FirstSelected(this); } - - SvTreeListEntry* NextSelected( SvTreeListEntry* pEntry ) const - { return pModel->NextSelected(this,pEntry); } - - SvTreeListEntry* PrevSelected( SvTreeListEntry* pEntry ) const - { return pModel->PrevSelected(this,pEntry); } - - SvTreeListEntry* LastSelected() const - { return pModel->LastSelected(this); } - SvTreeListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const - { return pModel->GetEntryAtAbsPos(nAbsPos); } - - SvTreeListEntry* GetEntryAtVisPos( sal_uLong nVisPos ) const - { return pModel->GetEntryAtVisPos(this,nVisPos); } - - sal_uLong GetAbsPos( SvTreeListEntry const * pEntry ) const - { return pModel->GetAbsPos(pEntry); } - - sal_uLong GetVisiblePos( SvTreeListEntry const * pEntry ) const - { return pModel->GetVisiblePos(this,pEntry); } - - sal_uLong GetVisibleChildCount(SvTreeListEntry* pParent ) const - { return pModel->GetVisibleChildCount(this,pParent); } - - sal_uLong GetChildSelectionCount( SvTreeListEntry* pParent ) const - { return pModel->GetChildSelectionCount(this,pParent); } - - bool IsEntryVisible( SvTreeListEntry* pEntry ) const - { return pModel->IsEntryVisible(this,pEntry); } - - bool IsExpanded( SvTreeListEntry* pEntry ) const; - bool IsSelected( SvTreeListEntry* pEntry ) const; - void SetEntryFocus( SvTreeListEntry* pEntry, bool bFocus ); - const SvViewDataEntry* GetViewData( const SvTreeListEntry* pEntry ) const; - SvViewDataEntry* GetViewData( SvTreeListEntry* pEntry ); - bool HasViewData() const; - - virtual std::unique_ptr CreateViewData( SvTreeListEntry* pEntry ); - virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ); - - virtual void ModelHasCleared(); - virtual void ModelHasInserted( SvTreeListEntry* pEntry ); - virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ); - virtual void ModelIsMoving( - SvTreeListEntry* pSource, - SvTreeListEntry* pTargetParent, - sal_uLong nPos - ); - virtual void ModelHasMoved( SvTreeListEntry* pSource ); - virtual void ModelIsRemoving( SvTreeListEntry* pEntry ); - virtual void ModelHasRemoved( SvTreeListEntry* pEntry ); - virtual void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx deleted file mode 100644 index c4df5127375c..000000000000 --- a/include/svtools/treelistbox.hxx +++ /dev/null @@ -1,801 +0,0 @@ -/* -*- 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_SVTOOLS_TREELISTBOX_HXX -#define INCLUDED_SVTOOLS_TREELISTBOX_HXX - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Application; -class SvTreeListBox; -class SvTreeListEntry; -struct SvViewDataItem; -class SvViewDataEntry; -class SvInplaceEdit2; -class SvLBoxString; -class SvLBoxButton; -class SvLBoxContextBmp; -class SvImpLBox; -class SvLBoxButtonData; -struct SvLBoxDDInfo; - -namespace utl { - class AccessibleStateSetHelper; -} - -enum class SvLBoxButtonKind -{ - EnabledCheckbox, - DisabledCheckbox, - StaticImage -}; - -enum class SvButtonState { Unchecked, Checked, Tristate }; - -// ********************************************************************* -// *************************** Tabulators ****************************** -// ********************************************************************* - -enum class SvLBoxTabFlags -{ - NONE = 0x0000, - DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth - ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator - ADJUST_LEFT = 0x0004, // Left margin - ADJUST_CENTER = 0x0008, // Center the item at the tabulator - ADJUST_NUMERIC = 0x0010, // Decimal point at the tabulator (strings) - - SHOW_SELECTION = 0x0040, // Visualize selection state - // Item needs to be able to return the surrounding polygon (D'n'D cursor) - EDITABLE = 0x0100, // Item editable at the tabulator - PUSHABLE = 0x0200, // Item acts like a Button - INV_ALWAYS = 0x0400, // Always delete the background - FORCE = 0x0800, // Switch off the default calculation of the first tabulator - // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on) - // The first tab's position corresponds precisely to the Flags set - // and column widths -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -#define SV_TAB_BORDER 8 - -#define SV_ENTRYHEIGHTOFFS_PIXEL 2 - -enum class SvTreeFlags -{ - CHKBTN = 0x01, - USESEL = 0x02, - MANINS = 0x04, - RECALCTABS = 0x08, - FIXEDHEIGHT = 0x10, -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -enum class SvTreeAccRoleType -{ - NONE = 0x00, - TREE = 0x02 -}; - -enum class SvLBoxItemType {String, Button, ContextBmp}; - -class SvLBoxTab -{ - long nPos; -public: - SvLBoxTab(); - SvLBoxTab( long nPos, SvLBoxTabFlags nFlags ); - SvLBoxTab( const SvLBoxTab& ); - ~SvLBoxTab(); - - SvLBoxTabFlags nFlags; - - bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); } - void SetPos( long nNewPos) { nPos = nNewPos; } - long GetPos() const { return nPos; } - long CalcOffset( long nItemLength, long nTabWidth ); - bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); } -}; - -class SVT_DLLPUBLIC SvLBoxItem -{ -public: - SvLBoxItem(); - virtual ~SvLBoxItem(); - virtual SvLBoxItemType GetType() const = 0; - const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; - static const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos); - - virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0; - - virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, - // If != 0: this Pointer must be used! - // If == 0: it needs to be retrieved via the View - SvViewDataItem* pViewData = nullptr) = 0; - // View-dependent data is not cloned - virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const = 0; -}; - -enum class DragDropMode -{ - NONE = 0x0000, - CTRL_MOVE = 0x0001, - CTRL_COPY = 0x0002, - APP_MOVE = 0x0004, - APP_COPY = 0x0008, - APP_DROP = 0x0010, - // Entries may be dropped via the uppermost Entry - // The DropTarget is 0 in that case - ENABLE_TOP = 0x0020, - ALL = 0x003f, -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -enum class SvTreeListBoxFlags -{ - NONE = 0x0000, - IN_EDT = 0x0001, - EDT_ENABLED = 0x0002, - IS_EXPANDING = 0x0004, - IS_TRAVELSELECT = 0x0008, - TARGEMPH_VIS = 0x0010, - EDTEND_CALLED = 0x0020, -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - -struct SvTreeListBoxImpl; - -class SVT_DLLPUBLIC SvTreeListBox - :public Control - ,public SvListView - ,public DropTargetHelper - ,public DragSourceHelper - ,public vcl::IMnemonicEntryList - ,public vcl::ISearchableStringList -{ - friend class SvImpLBox; - friend class IconViewImpl; - friend class TreeControlPeer; - - std::unique_ptr mpImpl; - Link aCheckButtonHdl; - Link aScrolledHdl; - Link aExpandedHdl; - Link aExpandingHdl; - Link aSelectHdl; - Link aDeselectHdl; - - Image aPrevInsertedExpBmp; - Image aPrevInsertedColBmp; - Image aCurInsertedExpBmp; - Image aCurInsertedColBmp; - - short nContextBmpWidthMax; - short nEntryHeightOffs; - short nIndent; - short nFocusWidth; - SvTreeAccRoleType nAllItemAccRoleType; - sal_uInt16 nFirstSelTab; - sal_uInt16 nLastSelTab; - long mnCheckboxItemWidth; - bool mbContextBmpExpanded; - bool mbAlternatingRowColors; - bool mbUpdateAlternatingRows; - bool mbQuickSearch; // Enables type-ahead search in the check list box. - - SvTreeListEntry* pHdlEntry; - - DragDropMode nDragDropMode; - DragDropMode nOldDragMode; - SelectionMode eSelMode; - sal_Int8 nDragOptions; - sal_Int32 nMinWidthInChars; - - SvTreeListEntry* pEdEntry; - SvLBoxItem* pEdItem; - -protected: - std::unique_ptr pImpl; - short nColumns; - short nEntryHeight; - short nEntryWidth; - bool mbCenterAndClipText; - - Link aDoubleClickHdl; - SvTreeListEntry* pTargetEntry; - SvLBoxButtonData* pCheckButtonData; - std::vector> aTabs; - SvTreeFlags nTreeFlags; - SvTreeListBoxFlags nImpFlags; - // Move/CopySelection: Position of the current Entry in SelectionList - sal_uInt16 nCurEntrySelPos; - -private: - void SetBaseModel(SvTreeList* pNewModel); - - DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void ); - DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void ); - // Handler that is called by TreeList to clone an Entry - DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* ); - - // Handler and methods for Drag - finished handler. - // The Handle retrieved by GetDragFinishedHdl can be set on the - // TransferDataContainer. This link is a callback for the DragFinished - // call. The AddBox method is called from the GetDragFinishedHdl() and the - // remove is called in the link callback and in the dtor. So it can't be - // called for a deleted object. - SVT_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB ); - SVT_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB ); - DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void ); - -protected: - - bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 ); - void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow); - void EnableSelectionAsDropTarget( bool bEnable = true ); - // Standard impl returns 0; derived classes which support D'n'D must override - using Window::GetDropTarget; - virtual SvTreeListEntry* GetDropTarget( const Point& ); - - // Invalidate children on enable/disable - virtual void StateChanged( StateChangedType eType ) override; - - virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND); - virtual sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND ); - - // In-place editing - std::unique_ptr pEdCtrl; - void EditText( const OUString&, const tools::Rectangle&,const Selection&); - void CancelTextEditing(); - bool EditingCanceled() const; - - // Return value must be derived from SvViewDataEntry! - virtual std::unique_ptr CreateViewData( SvTreeListEntry* ) override; - // InitViewData is called right after CreateViewData - // The Entry is has not yet been added to the View in InitViewData! - virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override; - // Calls InitViewData for all Items - void RecalcViewData(); - - // Handler and methods for Drag - finished handler. This link can be set - // to the TransferDataContainer. The AddBox/RemoveBox methods must be - // called before the StartDrag call. - // The Remove will be called from the handler, which then calls DragFinish. - // The Remove is also called in the DTOR of the SvTreeListBox - - // so it can't be called for a deleted object. - Link GetDragFinishedHdl() const; - - // For asynchronous D'n'D - sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView ); - - void OnCurrentEntryChanged(); - - // IMnemonicEntryList - virtual const void* FirstSearchEntry( OUString& _rEntryText ) const override; - virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const override; - virtual void SelectSearchEntry( const void* _pEntry ) override; - virtual void ExecuteSearchEntry( const void* _pEntry ) const override; - - // ISearchableStringList - virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override; - virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override; - virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override; - -public: - - SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 ); - virtual ~SvTreeListBox() override; - virtual void dispose() override; - - SvTreeList* GetModel() const - { - return pModel; - } - - using SvListView::SetModel; - - void SetModel(SvTreeList* pNewModel) override; - - sal_uLong GetEntryCount() const - { - return pModel ? pModel->GetEntryCount() : 0; - } - SvTreeListEntry* First() const - { - return pModel ? pModel->First() : nullptr; - } - SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const - { - return pModel->Next(pEntry); - } - SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const - { - return pModel->Prev(pEntry); - } - SvTreeListEntry* Last() const - { - return pModel ? pModel->Last() : nullptr; - } - - SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; - - bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget ); - bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback ); - void RemoveSelection(); - /** - * Removes the entry along with all of its descendants - */ - void RemoveEntry(SvTreeListEntry const * pEntry); - - DragDropMode GetDragDropMode() const { return nDragDropMode; } - SelectionMode GetSelectionMode() const { return eSelMode; } - - // pParent == 0 -> Root level - SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const; - SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const; - - SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const; - void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const; - - using Window::GetParent; - const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; - SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; - SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const; - - using Window::GetChildCount; - sal_uLong GetChildCount( SvTreeListEntry const * pParent ) const; - sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const; - - SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const; - SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); - const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; - - bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); } - bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); } - void EndEditing( bool bCancel = false ); - void ForbidEmptyText(); - - void Clear(); - - /** Enables or disables mnemonic characters in the entry texts. - - If mnemonics are enabled, then entries are selected and made current when - there mnemonic character is pressed. If there are multiple entries with the - same mnemonic, the selection cycles between them. - - Entries with an collapsed ancestor are not included in the calculation of - mnemonics. That is, if you press the accelerator key of an invisible - entry, then this entry is *not* selected. - - Be aware that enabling mnemonics gets more expensive as you add to the list. - */ - void EnableEntryMnemonics(); - bool IsEntryMnemonicsEnabled() const; - - bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; } - - /** Handles the given key event. - - At the moment this merely checks for accelerator keys, if entry mnemonics - are enabled. - - This method may come in handy if you want to use keyboard acceleration - while the control does not have the focus. - - If the key event describes the pressing of a shortcut for an entry, - then SelectSearchEntry resp. ExecuteSearchEntry are called. - - @see IMnemonicEntryList - @see MnemonicEngine - - @return - if the event has been consumed, otherwise. - */ - bool HandleKeyInput( const KeyEvent& rKEvt ); - - void SetSelectHdl( const Link& rNewHdl ) {aSelectHdl=rNewHdl; } - void SetDeselectHdl( const Link& rNewHdl ) {aDeselectHdl=rNewHdl; } - void SetDoubleClickHdl(const Link& rNewHdl) {aDoubleClickHdl=rNewHdl;} - const Link& GetSelectHdl() const { return aSelectHdl; } - const Link& GetDeselectHdl() const { return aDeselectHdl; } - const Link& GetDoubleClickHdl() const { return aDoubleClickHdl; } - void SetExpandingHdl(const Link& rNewHdl){aExpandingHdl=rNewHdl;} - void SetExpandedHdl(const Link& rNewHdl){aExpandedHdl=rNewHdl;} - - virtual void ExpandedHdl(); - virtual bool ExpandingHdl(); - virtual void SelectHdl(); - virtual void DeselectHdl(); - virtual bool DoubleClickHdl(); - SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; } - - // Is called for an Entry that gets expanded with the Flag - // ENTRYFLAG_CHILDREN_ON_DEMAND set. - virtual void RequestingChildren( SvTreeListEntry* pParent ); - - // Drag & Drop - // New D'n'D API - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; - virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; - virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, - SvTreeListEntry* ); - virtual void DragFinished( sal_Int8 nDropAction ); - virtual bool NotifyAcceptDrop( SvTreeListEntry* ); - - void SetDragOptions( sal_Int8 nOptions ) { nDragOptions = nOptions; } - - virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ); - virtual SvTreeListEntry* CreateEntry() const; // To create new Entries - - // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry - virtual TriState NotifyMoving( - SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() - SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel() - SvTreeListEntry*& rpNewParent, // New TargetParent - sal_uLong& rNewChildPos); // The TargetParent's position in Childlist - - // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry - virtual TriState NotifyCopying( - SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() - SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel() - SvTreeListEntry*& rpNewParent, // New TargetParent - sal_uLong& rNewChildPos); // The TargetParent's position in Childlist - - // ACCESSIBILITY ========================================================== - - /** Creates and returns the accessible object of the Box. */ - virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; - - /** Fills the StateSet of one entry. */ - void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const; - - /** Calculate and return the bounding rectangle of an entry. - @param pEntry - The entry. - @return The bounding rectangle of an entry. */ - tools::Rectangle GetBoundingRect( SvTreeListEntry* pEntry ); - - /** Enables, that one cell of a tablistbox entry can be focused */ - void EnableCellFocus(); - - // For overwriting accessible role for all entries - normally 0, so each entry can be different - void SetAllEntriesAccessibleRoleType( SvTreeAccRoleType n ) { nAllItemAccRoleType = n; } - SvTreeAccRoleType GetAllEntriesAccessibleRoleType() const { return nAllItemAccRoleType; } - - SvTreeFlags GetTreeFlags() const {return nTreeFlags;} - - static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry); - virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const; - virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const; - - void set_min_width_in_chars(sal_Int32 nChars); - - virtual bool set_property(const OString &rKey, const OUString &rValue) override; - -protected: - - SVT_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry ); - SVT_DLLPRIVATE void AdjustEntryHeight( const Image& rBmp ); - SVT_DLLPRIVATE void AdjustEntryHeight(); - - SVT_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry ); - SVT_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, long nLine, vcl::RenderContext& rRenderContext ); - - SVT_DLLPRIVATE void InitTreeView(); - SVT_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab ); - SVT_DLLPRIVATE void ImplInitStyle(); - - void SetupDragOrigin(); - void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem, - const Selection& ); - void EditedText(const OUString&); - - // Recalculate all tabs depending on TreeListStyle and Bitmap sizes - // Is called automatically when inserting/changing Bitmaps, changing the Model etc. - virtual void SetTabs(); - void AddTab( long nPos, SvLBoxTabFlags nFlags ); - sal_uInt16 TabCount() const { return aTabs.size(); } - SvLBoxTab* GetFirstDynamicTab() const; - SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const; - SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); - void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); - SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const; - void ClearTabList(); - - virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind); - - virtual void NotifyEndScroll(); - virtual void NotifyScrolled(); - void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; } - long GetXOffset() const { return GetMapMode().GetOrigin().X(); } - - virtual void Command( const CommandEvent& rCEvt ) override; - - virtual void RequestHelp( const HelpEvent& rHEvt ) override; - virtual void PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry& rEntry); - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; - - void InitSettings(); - - virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; - - bool IsCellFocusEnabled() const; - bool SetCurrentTabPos( sal_uInt16 _nNewPos ); - sal_uInt16 GetCurrentTabPos() const; - void CallImplEventListeners(VclEventId nEvent, void* pData); - - void ImplEditEntry( SvTreeListEntry* pEntry ); - - bool AreChildrenTransient() const; - void SetChildrenNotTransient(); - - void AdjustEntryHeightAndRecalc(); -public: - - void SetNoAutoCurEntry( bool b ); - - void EnableCheckButton( SvLBoxButtonData* ); - void SetCheckButtonData( SvLBoxButtonData* ); - void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp ); - - /** Returns the default image which clients should use for expanded nodes, to have a consistent user - interface experience in the whole product. - */ - static const Image& GetDefaultExpandedNodeImage( ); - - /** Returns the default image which clients should use for expanded nodes, to have a consistent user - interface experience in the whole product. - */ - static const Image& GetDefaultCollapsedNodeImage( ); - - /** Sets default bitmaps for collapsed and expanded nodes. - */ - void SetNodeDefaultImages( ) - { - SetNodeBitmaps( - GetDefaultCollapsedNodeImage( ), - GetDefaultExpandedNodeImage( ) - ); - } - - virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, - bool bChildrenOnDemand = false, - sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr, - SvLBoxButtonKind eButtonKind = SvLBoxButtonKind::EnabledCheckbox ); - - virtual SvTreeListEntry* InsertEntry( const OUString& rText, - const Image& rExpandedEntryBmp, - const Image& rCollapsedEntryBmp, - SvTreeListEntry* pParent = nullptr, - bool bChildrenOnDemand = false, - sal_uLong nPos = TREELIST_APPEND, void* pUserData = nullptr, - SvLBoxButtonKind eButtonKind = SvLBoxButtonKind::EnabledCheckbox ); - - const Image& GetDefaultExpandedEntryBmp( ) const; - const Image& GetDefaultCollapsedEntryBmp( ) const; - - void SetDefaultExpandedEntryBmp( const Image& rBmp ); - void SetDefaultCollapsedEntryBmp( const Image& rBmp ); - - void SetCheckButtonState( SvTreeListEntry*, SvButtonState ); - void SetCheckButtonInvisible( SvTreeListEntry* ); - SvButtonState GetCheckButtonState( SvTreeListEntry* ) const; - - void SetEntryText(SvTreeListEntry*, const OUString& ); - void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); - void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); - - virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const; - static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ); - static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ); - - void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; } - const Link& GetCheckButtonHdl() const { return aCheckButtonHdl; } - virtual void CheckButtonHdl(); - - void SetSublistOpenWithReturn(); // open/close sublist with return/enter - void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right - void SetSublistDontOpenWithDoubleClick( bool bDontOpen ); // set mouse double click open/close sublist behavior - - void EnableInplaceEditing( bool bEnable ); - // Edits the Entry's first StringItem, 0 == Cursor - void EditEntry( SvTreeListEntry* pEntry ); - virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& ); - virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ); - - virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; - virtual void MouseMove( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Resize() override; - virtual void GetFocus() override; - virtual void LoseFocus() override; - void SetUpdateMode( bool ); - - virtual void ModelHasCleared() override; - virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override; - virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override; - virtual void ModelIsMoving(SvTreeListEntry* pSource, - SvTreeListEntry* pTargetParent, sal_uLong nChildPos ) override; - virtual void ModelHasMoved(SvTreeListEntry* pSource ) override; - virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override; - virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override; - void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override; - - void ScrollOutputArea( short nDeltaEntries ); - - short GetColumnsCount() const { return nColumns; } - short GetEntryHeight() const { return nEntryHeight; } - void SetEntryHeight( short nHeight, bool bForce = false ); - short GetEntryWidth() const { return nEntryWidth; } - void SetEntryWidth( short nWidth ); - Size GetOutputSizePixel() const; - short GetIndent() const { return nIndent; } - void SetIndent( short nIndent ); - // Place the expander checkitem at the optimal indent for hierarchical lists - void SetOptimalImageIndent() { SetIndent(12); } - void SetSpaceBetweenEntries( short nSpace ); - short GetSpaceBetweenEntries() const {return nEntryHeightOffs;} - Point GetEntryPosition( SvTreeListEntry* ) const; - void MakeVisible( SvTreeListEntry* pEntry ); - void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop ); - - void SetCollapsedNodeBmp( const Image& ); - void SetExpandedNodeBmp( const Image& ); - Image const & GetExpandedNodeBmp( ) const; - - void SetFont( const vcl::Font& rFont ); - - using Window::SetCursor; - void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false ); - - SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const; - - virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nLine ); - // Respects indentation - virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ); - void InvalidateEntry( SvTreeListEntry* ); - SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab); - SvLBoxItem* GetItem( SvTreeListEntry*, long nX ); - - void SetDragDropMode( DragDropMode ); - void SetSelectionMode( SelectionMode ); - - virtual bool Expand( SvTreeListEntry* pParent ); - virtual bool Collapse( SvTreeListEntry* pParent ); - virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ); - sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect ); - void SelectAll( bool bSelect, bool bPaint = true ); - - void SetCurEntry( SvTreeListEntry* _pEntry ); - SvTreeListEntry* GetCurEntry() const; - - using Window::Invalidate; - virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override; - virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override; - - void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff); - - // A Parent's Children are turned into Children of the Parent which comes next in hierarchy - void RemoveParentKeepChildren( SvTreeListEntry* pParent ); - - DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 ); - virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1, - SvTreeListEntry* pEntry2, sal_uLong nPos ) override; - - void EndSelection(); - ScrollBar* GetVScroll(); - ScrollBar* GetHScroll(); - void EnableAsyncDrag( bool b ); - - SvTreeListEntry* GetFirstEntryInView() const; - SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const; - SvTreeListEntry* GetPrevEntryInView(SvTreeListEntry*) const; - SvTreeListEntry* GetLastEntryInView() const; - void ScrollToAbsPos( long nPos ); - - void ShowFocusRect( const SvTreeListEntry* pEntry ); - void InitStartEntry(); - - virtual VclPtr CreateContextMenu(); - virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); - - void EnableContextMenuHandling(); - - void EnableList( bool _bEnable ); - - long getPreferredDimensions(std::vector &rWidths) const; - - virtual Size GetOptimalSize() const override; - - void SetAlternatingRowColors( const bool bEnable ); - - // Enables type-ahead search in the check list box. - void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; } - - void SetForceMakeVisible(bool bEnable); - - virtual FactoryFunction GetUITestFactory() const override; -}; - -class SvInplaceEdit2 -{ - Link const aCallBackHdl; - Accelerator aAccReturn; - Accelerator aAccEscape; - Idle aIdle; - VclPtr pEdit; - bool bCanceled; - bool bAlreadyInCallBack; - - void CallCallBackHdl_Impl(); - DECL_LINK( Timeout_Impl, Timer *, void ); - DECL_LINK( ReturnHdl_Impl, Accelerator&, void ); - DECL_LINK( EscapeHdl_Impl, Accelerator&, void ); - -public: - SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize, - const OUString& rData, const Link& rNotifyEditEnd, - const Selection& ); - ~SvInplaceEdit2(); - bool KeyInput( const KeyEvent& rKEvt ); - void LoseFocus(); - bool EditingCanceled() const { return bCanceled; } - OUString GetText() const; - OUString const & GetSavedValue() const; - void StopEditing( bool bCancel ); - void Hide(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/treelistentries.hxx b/include/svtools/treelistentries.hxx deleted file mode 100644 index a7880f87d237..000000000000 --- a/include/svtools/treelistentries.hxx +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- 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/. - */ - -#ifndef INCLUDED_SVTOOLS_TREELISTENTRIES_HXX -#define INCLUDED_SVTOOLS_TREELISTENTRIES_HXX - -#include -#include - -class SvTreeListEntry; -typedef std::vector> SvTreeListEntries; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/treelistentry.hxx b/include/svtools/treelistentry.hxx deleted file mode 100644 index 303ebb55d643..000000000000 --- a/include/svtools/treelistentry.hxx +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- 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_SVTOOLS_TREELISTENTRY_HXX -#define INCLUDED_SVTOOLS_TREELISTENTRY_HXX - -#include -#include -#include -#include -#include - -#include -#include - -// flags related to the model -enum class SvTLEntryFlags -{ - NONE = 0x0000, - CHILDREN_ON_DEMAND = 0x0001, - DISABLE_DROP = 0x0002, - IN_USE = 0x0004, - // is set if RequestingChildren has not set any children - NO_NODEBMP = 0x0008, - // entry had or has children - HAD_CHILDREN = 0x0010, - SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps -}; -namespace o3tl -{ - template<> struct typed_flags : is_typed_flags {}; -} - - -class SVT_DLLPUBLIC SvTreeListEntry -{ - friend class SvTreeList; - friend class SvListView; - friend class SvTreeListBox; - - typedef std::vector> ItemsType; - - SvTreeListEntry* pParent; - SvTreeListEntries m_Children; - sal_uLong nAbsPos; - sal_uLong nListPos; - ItemsType m_Items; - void* pUserData; - SvTLEntryFlags nEntryFlags; - Color maBackColor; - -private: - void ClearChildren(); - void SetListPositions(); - void InvalidateChildrensListPositions(); - - SvTreeListEntry(const SvTreeListEntry& r) = delete; - void operator=(SvTreeListEntry const&) = delete; - -public: - static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE; - - SvTreeListEntry(); - virtual ~SvTreeListEntry(); - - bool HasChildren() const; - bool HasChildListPos() const; - sal_uLong GetChildListPos() const; - - SvTreeListEntries& GetChildEntries() { return m_Children; } - const SvTreeListEntries& GetChildEntries() const { return m_Children; } - - void Clone(SvTreeListEntry* pSource); - - size_t ItemCount() const; - - // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO - // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED - // FOR THE ITEM! - void AddItem(std::unique_ptr pItem); - void ReplaceItem(std::unique_ptr pNewItem, size_t nPos); - const SvLBoxItem& GetItem( size_t nPos ) const; - SvLBoxItem& GetItem( size_t nPos ); - const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const; - SvLBoxItem* GetFirstItem(SvLBoxItemType eType); - size_t GetPos( const SvLBoxItem* pItem ) const; - void* GetUserData() const { return pUserData;} - void SetUserData( void* pPtr ); - void EnableChildrenOnDemand( bool bEnable=true ); - bool HasChildrenOnDemand() const; - bool HasInUseEmphasis() const; - - SvTLEntryFlags GetFlags() const { return nEntryFlags;} - void SetFlags( SvTLEntryFlags nFlags ); - - void SetBackColor( const Color& aColor ) { maBackColor = aColor; } - const Color& GetBackColor() const { return maBackColor; } - SvTreeListEntry* GetParent() const { return pParent; } - - SvTreeListEntry* NextSibling() const; - SvTreeListEntry* PrevSibling() const; - SvTreeListEntry* LastSibling() const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/viewdataentry.hxx b/include/svtools/viewdataentry.hxx deleted file mode 100644 index 1a61b3f6c13a..000000000000 --- a/include/svtools/viewdataentry.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- 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_SVTOOLS_VIEWDATAENTRY_HXX -#define INCLUDED_SVTOOLS_VIEWDATAENTRY_HXX - -#include -#include -#include - -#include - -struct SvViewDataItem -{ - Size maSize; -}; - -/** - * View-dependent data for a tree list entry created in the virtual function - * SvTreeListBox::CreateViewData(). The item array contains the same number - * of items as that of the items in its corresponding tree list entry. - * - * When an entry is selected, it is logically selected and visually - * highlighted. When an entry is only highlighted, it looks visually - * highlighted, but not logically selected. - */ -class SVT_DLLPUBLIC SvViewDataEntry -{ - friend class SvTreeList; - - std::vector maItems; - sal_uLong nVisPos; - bool mbSelected:1; - bool mbHighlighted:1; - bool mbExpanded:1; - bool mbFocused:1; - bool mbSelectable:1; - tools::Rectangle maPaintRectangle; - -public: - SvViewDataEntry(); - SvViewDataEntry( const SvViewDataEntry& ); - ~SvViewDataEntry(); - - bool IsSelected() const { return mbSelected;} - bool IsHighlighted() const { return mbHighlighted;} - bool IsExpanded() const { return mbExpanded;} - bool HasFocus() const { return mbFocused;} - bool IsSelectable() const { return mbSelectable;} - void SetFocus( bool bFocus ); - void SetSelected( bool bSelected ); - void SetHighlighted( bool bHighlighted ); - void SetExpanded( bool bExpanded ); - void SetSelectable( bool bSelectable ); - - void Init(size_t nSize); - - const SvViewDataItem& GetItem(size_t nPos) const; - SvViewDataItem& GetItem(size_t nPos); - - void SetPaintRectangle(tools::Rectangle aRectangle); - const tools::Rectangle& GetPaintRectangle() const; - -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/checklbx.hxx b/include/svx/checklbx.hxx index b9eb98e36071..c4fdf21cf341 100644 --- a/include/svx/checklbx.hxx +++ b/include/svx/checklbx.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/svx/colrctrl.hxx b/include/svx/colrctrl.hxx index dd7a179da93e..66addcee31c5 100644 --- a/include/svx/colrctrl.hxx +++ b/include/svx/colrctrl.hxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx index c6c15baf5148..72cfe2024123 100644 --- a/include/svx/ctredlin.hxx +++ b/include/svx/ctredlin.hxx @@ -24,10 +24,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include #include diff --git a/include/svx/dbaexchange.hxx b/include/svx/dbaexchange.hxx index 7d905d2d5841..ffae51c0849a 100644 --- a/include/svx/dbaexchange.hxx +++ b/include/svx/dbaexchange.hxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/svx/dbaobjectex.hxx b/include/svx/dbaobjectex.hxx index 533b53624f96..e9410ea65632 100644 --- a/include/svx/dbaobjectex.hxx +++ b/include/svx/dbaobjectex.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_SVX_DBAOBJECTEX_HXX #define INCLUDED_SVX_DBAOBJECTEX_HXX -#include +#include #include #include #include diff --git a/include/svx/fmgridcl.hxx b/include/svx/fmgridcl.hxx index d85c639a46c1..39cb7c77c894 100644 --- a/include/svx/fmgridcl.hxx +++ b/include/svx/fmgridcl.hxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/include/svx/fontlb.hxx b/include/svx/fontlb.hxx index 876c22fc32af..8cb9fedc90fc 100644 --- a/include/svx/fontlb.hxx +++ b/include/svx/fontlb.hxx @@ -21,7 +21,7 @@ #define INCLUDED_SVX_FONTLB_HXX #include -#include +#include #include #include diff --git a/include/svx/galctrl.hxx b/include/svx/galctrl.hxx index 9bae181fb115..16eda958e21c 100644 --- a/include/svx/galctrl.hxx +++ b/include/svx/galctrl.hxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svx/galmisc.hxx b/include/svx/galmisc.hxx index 6a2d05a95655..2c21b09ae822 100644 --- a/include/svx/galmisc.hxx +++ b/include/svx/galmisc.hxx @@ -22,9 +22,9 @@ #include #include -#include +#include #include -#include +#include #include #include #include diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx index be0ef9ec2be9..28d73582a091 100644 --- a/include/svx/galtheme.hxx +++ b/include/svx/galtheme.hxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx index 278db98ab41d..56bf87726d6b 100644 --- a/include/svx/gridctrl.hxx +++ b/include/svx/gridctrl.hxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svx/xmlexchg.hxx b/include/svx/xmlexchg.hxx index 371dd5a833e3..ac4070fa3d11 100644 --- a/include/svx/xmlexchg.hxx +++ b/include/svx/xmlexchg.hxx @@ -21,7 +21,7 @@ #define INCLUDED_SVX_XMLEXCHG_HXX #include -#include +#include #include namespace com { diff --git a/include/vcl/imap.hxx b/include/vcl/imap.hxx new file mode 100644 index 000000000000..bba9ebe6b84c --- /dev/null +++ b/include/vcl/imap.hxx @@ -0,0 +1,138 @@ +/* -*- 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_VCL_IMAP_HXX +#define INCLUDED_VCL_IMAP_HXX + +#include +#include +#include +#include +#include + +class Point; +namespace tools { class Rectangle; } +class Size; +class Fraction; +class IMapObject; + +class VCL_DLLPUBLIC ImageMap final +{ +private: + + std::vector> maList; + OUString aName; + + // binary saving/loading + void ImpWriteImageMap( SvStream& rOStm ) const ; + void ImpReadImageMap( SvStream& rIStm, size_t nCount ); + + // Import/Export + void ImpWriteCERN( SvStream& rOStm ) const; + void ImpWriteNCSA( SvStream& rOStm ) const; + void ImpReadCERN( SvStream& rOStm ); + void ImpReadNCSA( SvStream& rOStm ); + + void ImpReadCERNLine( const OString& rLine ); + static Point ImpReadCERNCoords( const char** ppStr ); + static long ImpReadCERNRadius( const char** ppStr ); + static OUString ImpReadCERNURL( const char** ppStr ); + + void ImpReadNCSALine( const OString& rLine ); + static OUString ImpReadNCSAURL( const char** ppStr ); + static Point ImpReadNCSACoords( const char** ppStr ); + + static sal_uLong ImpDetectFormat( SvStream& rIStm ); + +public: + + ImageMap() {}; + ImageMap( const OUString& rName ); + ImageMap( const ImageMap& rImageMap ); + + // all IMapObjects are destroyed in the destructor + ~ImageMap(); + + ImageMap& operator=( const ImageMap& rImageMap ); + + // comparison (everything is checked for equality) + bool operator==( const ImageMap& rImageMap ); + bool operator!=( const ImageMap& rImageMap ); + + // a new IMap object is inserted at the end of the Map + void InsertIMapObject( const IMapObject& rIMapObject ); + void InsertIMapObject( std::unique_ptr rIMapObject ); + + // access to the single ImapObjects; the objects may + // not be destroyed from outside + IMapObject* GetIMapObject( size_t nPos ) const + { + return ( nPos < maList.size() ) ? maList[ nPos ].get() : nullptr; + } + + // returns the object which was hit first or NULL; + // size and position values are in 1/100mm; + // rTotalSize is the original size of the image + // rDisplaySize is the current size; + // rRelPoint relates to the display size and the upper left + // corner of the image + IMapObject* GetHitIMapObject( const Size& rOriginalSize, + const Size& rDisplaySize, + const Point& rRelHitPoint, + sal_uLong nFlags = 0 ); + + // returns the total amount of IMap objects + size_t GetIMapObjectCount() const { return maList.size(); } + + // deletes all internal objects + void ClearImageMap(); + + const OUString& GetName() const { return aName; } + void SetName( const OUString& rName ) { aName = rName; } + + // scales all objects of the ImageMap according to the given factor + void Scale( const Fraction& rFractX, const Fraction& rFracY ); + + // Import/Export + void Write ( SvStream& rOStm ) const; + void Read( SvStream& rIStm ); + + void Write( SvStream& rOStm, sal_uLong nFormat ) const; + sal_uLong Read( SvStream& rIStm, sal_uLong nFormat ); +}; + +class IMapCompat +{ + SvStream* pRWStm; + sal_uInt64 nCompatPos; + sal_uInt64 nTotalSize; + StreamMode const nStmMode; + + IMapCompat( const IMapCompat& ) = delete; + IMapCompat& operator=( const IMapCompat& ) { return *this; } + +public: + + IMapCompat( SvStream& rStm, const StreamMode nStreamMode ); + ~IMapCompat(); +}; + +#endif // INCLUDED_VCL_IMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imapcirc.hxx b/include/vcl/imapcirc.hxx new file mode 100644 index 000000000000..f021f7ddffde --- /dev/null +++ b/include/vcl/imapcirc.hxx @@ -0,0 +1,71 @@ +/* -*- 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_VCL_IMAPCIRC_HXX +#define INCLUDED_VCL_IMAPCIRC_HXX + +#include +#include +#include + +class Fraction; + +class VCL_DLLPUBLIC IMapCircleObject : public IMapObject +{ + Point aCenter; + sal_Int32 nRadius; + + void ImpConstruct( const Point& rCenter, sal_uLong nRad, bool bPixel ); + +protected: + + // binary import/export + virtual void WriteIMapObject( SvStream& rOStm ) const override; + virtual void ReadIMapObject( SvStream& rIStm ) override; + +public: + + IMapCircleObject() : nRadius(0) {} + IMapCircleObject( const Point& rCenter, sal_uLong nRad, + const OUString& rURL, + const OUString& rAltText, + const OUString& rDesc, + const OUString& rTarget, + const OUString& rName, + bool bActive = true, + bool bPixelCoords = true ); + + virtual sal_uInt16 GetType() const override; + virtual bool IsHit( const Point& rPoint ) const override; + + Point GetCenter( bool bPixelCoords = true ) const; + sal_uLong GetRadius( bool bPixelCoords = true ) const; + + void Scale( const Fraction& rFractX, const Fraction& rFracY ); + + using IMapObject::IsEqual; + bool IsEqual( const IMapCircleObject& rEqObj ); + + // import/export + void WriteCERN( SvStream& rOStm ) const; + void WriteNCSA( SvStream& rOStm ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imapobj.hxx b/include/vcl/imapobj.hxx new file mode 100644 index 000000000000..1e5ab2e5c18c --- /dev/null +++ b/include/vcl/imapobj.hxx @@ -0,0 +1,127 @@ +/* -*- 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_VCL_IMAPOBJ_HXX +#define INCLUDED_VCL_IMAPOBJ_HXX + +#include +#include +#include + +class Point; +namespace tools { class Rectangle; } +class SvStream; + +#define IMAP_OBJ_RECTANGLE (sal_uInt16(0x0001)) +#define IMAP_OBJ_CIRCLE (sal_uInt16(0x0002)) +#define IMAP_OBJ_POLYGON (sal_uInt16(0x0003)) +#define IMAP_OBJ_VERSION (sal_uInt16(0x0005)) + +#define IMAGE_MAP_VERSION (sal_uInt16(0x0001)) + +#define IMAPMAGIC "SDIMAP" + +#define IMAP_MIRROR_HORZ 0x00000001L +#define IMAP_MIRROR_VERT 0x00000002L + +#define IMAP_FORMAT_BIN 0x00000001L +#define IMAP_FORMAT_CERN 0x00000002L +#define IMAP_FORMAT_NCSA 0x00000004L +#define IMAP_FORMAT_DETECT 0xffffffffL + +#define IMAP_ERR_OK 0x00000000L +#define IMAP_ERR_FORMAT 0x00000001L + +class VCL_DLLPUBLIC IMapObject +{ + friend class ImageMap; + + OUString aURL; + OUString aAltText; + OUString aDesc; + OUString aTarget; + OUString aName; + SvxMacroTableDtor aEventList; + bool bActive; + +protected: + sal_uInt16 nReadVersion; + + // binary import/export + virtual void WriteIMapObject( SvStream& rOStm ) const = 0; + virtual void ReadIMapObject( SvStream& rIStm ) = 0; + + // helper methods + static void AppendCERNCoords(OStringBuffer& rBuf, const Point& rPoint100); + void AppendCERNURL(OStringBuffer& rBuf) const; + static void AppendNCSACoords(OStringBuffer& rBuf, const Point& rPoint100); + void AppendNCSAURL(OStringBuffer&rBuf) const; + +public: + + static rtl_TextEncoding nActualTextEncoding; + + IMapObject(); + IMapObject( const OUString& rURL, + const OUString& rAltText, + const OUString& rDesc, + const OUString& rTarget, + const OUString& rName, + bool bActive ); + virtual ~IMapObject() {}; + + IMapObject(IMapObject const &) = default; + IMapObject(IMapObject &&) = default; + IMapObject & operator =(IMapObject const &) = default; + IMapObject & operator =(IMapObject &&) = default; + + virtual sal_uInt16 GetType() const = 0; + virtual bool IsHit( const Point& rPoint ) const = 0; + + void Write ( SvStream& rOStm ) const; + void Read( SvStream& rIStm ); + + const OUString& GetURL() const { return aURL; } + void SetURL( const OUString& rURL ) { aURL = rURL; } + + const OUString& GetAltText() const { return aAltText; } + void SetAltText( const OUString& rAltText) { aAltText = rAltText; } + + const OUString& GetDesc() const { return aDesc; } + void SetDesc( const OUString& rDesc ) { aDesc = rDesc; } + + const OUString& GetTarget() const { return aTarget; } + void SetTarget( const OUString& rTarget ) { aTarget = rTarget; } + + const OUString& GetName() const { return aName; } + void SetName( const OUString& rName ) { aName = rName; } + + bool IsActive() const { return bActive; } + void SetActive( bool bSetActive ) { bActive = bSetActive; } + + bool IsEqual( const IMapObject& rEqObj ); + + // IMap-Events + const SvxMacroTableDtor& GetMacroTable() const { return aEventList;} + void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aEventList = rTbl; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imappoly.hxx b/include/vcl/imappoly.hxx new file mode 100644 index 000000000000..a285085e8a69 --- /dev/null +++ b/include/vcl/imappoly.hxx @@ -0,0 +1,75 @@ +/* -*- 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_VCL_IMAPPOLY_HXX +#define INCLUDED_VCL_IMAPPOLY_HXX + +#include +#include +#include + +class Fraction; + +class VCL_DLLPUBLIC IMapPolygonObject : public IMapObject +{ + tools::Polygon aPoly; + tools::Rectangle aEllipse; + bool bEllipse; + + VCL_DLLPRIVATE void ImpConstruct( const tools::Polygon& rPoly, bool bPixel ); + +protected: + + // binary import/export + virtual void WriteIMapObject( SvStream& rOStm ) const override; + virtual void ReadIMapObject( SvStream& rIStm ) override; + +public: + IMapPolygonObject() : bEllipse(false) {} + IMapPolygonObject( const tools::Polygon& rPoly, + const OUString& rURL, + const OUString& rAltText, + const OUString& rDesc, + const OUString& rTarget, + const OUString& rName, + bool bActive = true, + bool bPixelCoords = true ); + + virtual sal_uInt16 GetType() const override; + virtual bool IsHit( const Point& rPoint ) const override; + + tools::Polygon GetPolygon( bool bPixelCoords = true ) const; + + bool HasExtraEllipse() const { return bEllipse; } + const tools::Rectangle& GetExtraEllipse() const { return aEllipse; } + void SetExtraEllipse( const tools::Rectangle& rEllipse ); + + void Scale( const Fraction& rFractX, const Fraction& rFracY ); + + using IMapObject::IsEqual; + bool IsEqual( const IMapPolygonObject& rEqObj ); + + // import/export + void WriteCERN( SvStream& rOStm ) const; + void WriteNCSA( SvStream& rOStm ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imaprect.hxx b/include/vcl/imaprect.hxx new file mode 100644 index 000000000000..49fabcff5147 --- /dev/null +++ b/include/vcl/imaprect.hxx @@ -0,0 +1,69 @@ +/* -*- 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_VCL_IMAPRECT_HXX +#define INCLUDED_VCL_IMAPRECT_HXX + +#include +#include +#include + +class Fraction; + +class VCL_DLLPUBLIC IMapRectangleObject : public IMapObject +{ + tools::Rectangle aRect; + + VCL_DLLPRIVATE void ImpConstruct( const tools::Rectangle& rRect, bool bPixel ); + +protected: + + // binary import/export + virtual void WriteIMapObject( SvStream& rOStm ) const override; + virtual void ReadIMapObject( SvStream& rIStm ) override; + +public: + + IMapRectangleObject() {}; + IMapRectangleObject( const tools::Rectangle& rRect, + const OUString& rURL, + const OUString& rAltText, + const OUString& rDesc, + const OUString& rTarget, + const OUString& rName, + bool bActive = true, + bool bPixelCoords = true ); + + virtual sal_uInt16 GetType() const override; + virtual bool IsHit( const Point& rPoint ) const override; + + tools::Rectangle GetRectangle( bool bPixelCoords = true ) const; + + void Scale( const Fraction& rFractX, const Fraction& rFracY ); + + using IMapObject::IsEqual; + bool IsEqual( const IMapRectangleObject& rEqObj ); + + // import/export + void WriteCERN( SvStream& rOStm ) const; + void WriteNCSA( SvStream& rOStm ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/inetimg.hxx b/include/vcl/inetimg.hxx new file mode 100644 index 000000000000..374a2122dfc6 --- /dev/null +++ b/include/vcl/inetimg.hxx @@ -0,0 +1,60 @@ +/* -*- 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_VCL_INETIMG_HXX +#define INCLUDED_VCL_INETIMG_HXX + +#include +#include + +class SvData; +class SotDataObject; + + +class INetImage +{ + OUString aImageURL; + OUString aTargetURL; + OUString aTargetFrame; + Size aSizePixel; + +public: + INetImage( + const OUString& rImageURL, + const OUString& rTargetURL, + const OUString& rTargetFrame ) + : aImageURL( rImageURL ), + aTargetURL( rTargetURL ), + aTargetFrame( rTargetFrame ) + {} + INetImage() + {} + + const OUString& GetImageURL() const { return aImageURL; } + const OUString& GetTargetURL() const { return aTargetURL; } + const OUString& GetTargetFrame() const { return aTargetFrame; } + + // import/export + void Write( SvStream& rOStm, SotClipboardFormatId nFormat ) const; + bool Read( SvStream& rIStm, SotClipboardFormatId nFormat ); +}; + +#endif // INCLUDED_VCL_INETIMG_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/svimpbox.hxx b/include/vcl/svimpbox.hxx new file mode 100644 index 000000000000..1ce5681f398b --- /dev/null +++ b/include/vcl/svimpbox.hxx @@ -0,0 +1,413 @@ +/* -*- 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_VCL_SOURCE_INC_SVIMPBOX_HXX +#define INCLUDED_VCL_SOURCE_INC_SVIMPBOX_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +class SvTreeListBox; +class Point; +class SvTreeList; +class SvImpLBox; +class SvTreeListEntry; +class SvLBoxTab; +namespace comphelper +{ + namespace string + { + class NaturalStringSorter; + } +} + +class ImpLBSelEng : public FunctionSet +{ + SvImpLBox* pImp; + VclPtr pView; + +public: + ImpLBSelEng( SvImpLBox* pImp, SvTreeListBox* pView ); + virtual ~ImpLBSelEng() override; + void BeginDrag() override; + void CreateAnchor() override; + void DestroyAnchor() override; + void SetCursorAtPoint( const Point& rPoint, + bool bDontSelectAtCursor=false ) override; + bool IsSelectionAtPoint( const Point& rPoint ) override; + void DeselectAtPoint( const Point& rPoint ) override; + void DeselectAll() override; +}; + +// Flags for nFlag +enum class LBoxFlags { + NONE = 0x0000, + InScrolling = 0x0001, + DeselectAll = 0x0002, + StartEditTimer = 0x0004, // MAC only + IgnoreSelect = 0x0008, + InResize = 0x0010, + RemovedEntryInvisible = 0x0020, + RemovedRecalcMostRight = 0x0040, + IgnoreChangedTabs = 0x0080, + InPaint = 0x0100, + EndScrollSetVisSize = 0x0200, + Filling = 0x0400, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +#define NODE_BMP_TABDIST_NOTVALID -2000000 +#define FIRST_ENTRY_TAB 1 + +class VCL_DLLPUBLIC SvImpLBox +{ +friend class ImpLBSelEng; +friend class SvTreeListBox; +friend class IconView; +private: + SvTreeList* pTree; + SvTreeListEntry* pAnchor; + SvTreeListEntry* pMostRightEntry; + SvLBoxButton* pActiveButton; + SvTreeListEntry* pActiveEntry; + SvLBoxTab* pActiveTab; + + VclPtr aHorSBar; + VclPtr aScrBarBox; + + static Image* s_pDefCollapsed; + static Image* s_pDefExpanded; + static oslInterlockedCount s_nImageRefCount; /// When 0 all static images will be destroyed + + // Node Bitmaps + enum class ImageType + { + NodeExpanded = 0, // node is expanded ( usually a bitmap showing a minus ) + NodeCollapsed, // node is collapsed ( usually a bitmap showing a plus ) + NodeDontKnow, // don't know the node state + EntryDefExpanded, // default for expanded entries + EntryDefCollapsed, // default for collapsed entries + LAST = EntryDefCollapsed + }; + + // all our images + o3tl::enumarray + m_aNodeAndEntryImages; + + ImpLBSelEng aFctSet; + Idle aAsyncBeginDragIdle; + Point aAsyncBeginDragPos; + + long nNodeBmpWidth; + long nMostRight; + short nHorSBarHeight, nVerSBarWidth; + sal_uInt16 nCurTabPos; + + bool bUpdateMode : 1; + bool bAsyncBeginDrag : 1; + bool bSubLstOpRet : 1; // open/close sublist with return/enter, defaulted with false + bool bSubLstOpLR : 1; // open/close sublist with cursor left/right, defaulted with false + bool bSubLstOpDblClick : 1; // open/close sublist with mouse double click, defaulted with true + bool bContextMenuHandling : 1; + bool bIsCellFocusEnabled : 1; + bool bAreChildrenTransient; + bool mbForceMakeVisible; + + Point aEditClickPos; + Idle aEditIdle; + + std::unique_ptr m_pStringSorter; + + std::vector< short > aContextBmpWidthVector; + + DECL_LINK(EditTimerCall, Timer *, void); + + DECL_LINK( BeginDragHdl, Timer*, void ); + + void InvalidateEntriesFrom( long nY ) const; + bool IsLineVisible( long nY ) const; + void KeyLeftRight( long nDiff ); + + void DrawNet(vcl::RenderContext& rRenderContext); + + // ScrollBar-Handler + DECL_LINK( ScrollUpDownHdl, ScrollBar*, void ); + DECL_LINK( ScrollLeftRightHdl, ScrollBar*, void ); + DECL_LINK( EndScrollHdl, ScrollBar*, void ); + + void SetNodeBmpWidth( const Image& ); + void SetNodeBmpTabDistance(); + + // Selection-Engine + SvTreeListEntry* MakePointVisible( const Point& rPoint ); + + void SetAnchorSelection( SvTreeListEntry* pOld, + SvTreeListEntry* pNewCursor ); + void BeginDrag(); + bool ButtonDownCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry* pEntry ); + bool MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry const * pEntry ); + bool ButtonUpCheckCtrl( const MouseEvent& rMEvt ); + bool ButtonDownCheckExpand( const MouseEvent&, SvTreeListEntry* ); + + bool EntryReallyHit(SvTreeListEntry* pEntry, const Point& rPos, long nLine); + void InitScrollBarBox(); + SvLBoxTab* NextTab( SvLBoxTab const * ); + + bool SetMostRight( SvTreeListEntry* pEntry ); + void FindMostRight( SvTreeListEntry* pParent, SvTreeListEntry* EntryToIgnore ); + void FindMostRight_Impl( SvTreeListEntry* pParent,SvTreeListEntry* EntryToIgnore ); + void NotifyTabsChanged(); + + // if element at cursor can be expanded in general + bool IsExpandable() const; + + static void implInitDefaultNodeImages(); + + void UpdateStringSorter(); + + short UpdateContextBmpWidthVector( SvTreeListEntry const * pEntry, short nWidth ); + void UpdateContextBmpWidthMax( SvTreeListEntry const * pEntry ); + void UpdateContextBmpWidthVectorFromMovedEntry( SvTreeListEntry* pEntry ); + + void CalcCellFocusRect( SvTreeListEntry const * pEntry, tools::Rectangle& rRect ); + + bool AreChildrenTransient() const { return bAreChildrenTransient; } + void SetChildrenNotTransient() { bAreChildrenTransient = false; } + +protected: + VclPtr pView; + VclPtr aVerSBar; + SvTreeListEntry* pCursor; + SvTreeListEntry* pStartEntry; + ImplSVEvent* nCurUserEvent; + Size aOutputSize; + LBoxFlags nFlags; + WinBits m_nStyle; + bool mbNoAutoCurEntry; // disable the behavior of automatically selecting a "CurEntry" upon painting the control + SelectionEngine aSelEng; + sal_uLong nVisibleCount; // Number of lines in control + bool bInVScrollHdl : 1; + bool bSimpleTravel : 1; // is true if SelectionMode::Single + long nNextVerVisSize; + long nNodeBmpTabDistance; // typical smaller than 0 + + virtual long GetEntryLine( SvTreeListEntry* pEntry ) const; + virtual void CursorDown(); + virtual void CursorUp(); + virtual void PageDown( sal_uInt16 nDelta ); + virtual void PageUp( sal_uInt16 nDelta ); + // set Thumb to FirstEntryToDraw + virtual void SyncVerThumb(); + virtual void AdjustScrollBars( Size& rSize ); + virtual void InvalidateEntry( long nY ) const; + + tools::Rectangle GetVisibleArea() const; + void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false ); + void BeginScroll(); + void EndScroll(); + void PositionScrollBars( Size& rOSize, sal_uInt16 nMask ); + void FindMostRight( SvTreeListEntry const * EntryToIgnore ); + void FillView(); + void ShowVerSBar(); + void StopUserEvent(); + + DECL_LINK( MyUserEvent, void*, void); + +public: + SvImpLBox( SvTreeListBox* pView, SvTreeList*, WinBits nWinStyle ); + virtual ~SvImpLBox(); + + void Clear(); + void SetStyle( WinBits i_nWinStyle ); + void SetNoAutoCurEntry( bool b ); + void SetModel( SvTreeList* pModel ) { pTree = pModel;} + + void EntryInserted( SvTreeListEntry*); + void RemovingEntry( SvTreeListEntry* pEntry ); + void EntryRemoved(); + void MovingEntry( SvTreeListEntry* pEntry ); + void EntryMoved( SvTreeListEntry* pEntry ); + void TreeInserted( SvTreeListEntry* pEntry ); + + void EntryExpanded( SvTreeListEntry* pEntry ); + void EntryCollapsed( SvTreeListEntry* pEntry ); + void CollapsingEntry( SvTreeListEntry* pEntry ); + void EntrySelected( SvTreeListEntry* pEntry, bool bSelect ); + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + void MouseButtonDown( const MouseEvent& ); + void MouseButtonUp( const MouseEvent& ); + void MouseMove( const MouseEvent&); + virtual bool KeyInput( const KeyEvent& ); + void Resize(); + void GetFocus(); + void LoseFocus(); + virtual void UpdateAll( bool bInvalidateCompleteView ); + void SetEntryHeight(); + void InvalidateEntry( SvTreeListEntry* ); + void RecalcFocusRect(); + + void SelectEntry( SvTreeListEntry* pEntry, bool bSelect ); + void SetDragDropMode( DragDropMode eDDMode ); + void SetSelectionMode( SelectionMode eSelMode ); + + SvTreeListEntry* GetCurrentEntry() const { return pCursor; } + virtual bool IsEntryInView( SvTreeListEntry* pEntry ) const; + virtual SvTreeListEntry* GetEntry( const Point& rPos ) const; + // returns last entry, if Pos below last entry + virtual SvTreeListEntry* GetClickedEntry( const Point& ) const; + SvTreeListEntry* GetCurEntry() const { return pCursor; } + void SetCurEntry( SvTreeListEntry* ); + virtual Point GetEntryPosition( SvTreeListEntry* ) const; + void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop = false ); + void ScrollToAbsPos( long nPos ); + + void PaintDDCursor( SvTreeListEntry* ); + + // Images + inline Image& implGetImageLocation( const ImageType _eType ); + + inline void SetExpandedNodeBmp( const Image& _rImg ); + inline void SetCollapsedNodeBmp( const Image& _rImg ); + + inline const Image& GetExpandedNodeBmp( ); + inline const Image& GetCollapsedNodeBmp( ); + inline const Image& GetDontKnowNodeBmp( ); + + inline void SetDefaultEntryExpBmp( const Image& _rImg ); + inline void SetDefaultEntryColBmp( const Image& _rImg ); + inline const Image& GetDefaultEntryExpBmp( ); + inline const Image& GetDefaultEntryColBmp( ); + + static const Image& GetDefaultExpandedNodeImage( ); + static const Image& GetDefaultCollapsedNodeImage( ); + + const Size& GetOutputSize() const { return aOutputSize;} + virtual void KeyUp( bool bPageUp ); + virtual void KeyDown( bool bPageDown ); + void Command( const CommandEvent& rCEvt ); + + void Invalidate(); + void DestroyAnchor() { pAnchor=nullptr; aSelEng.Reset(); } + void SelAllDestrAnch( bool bSelect, bool bDestroyAnchor = true, bool bSingleSelToo = false ); + void ShowCursor( bool bShow ); + + bool RequestHelp( const HelpEvent& rHEvt ); + void EndSelection(); + bool IsNodeButton( const Point& rPosPixel, SvTreeListEntry* pEntry ) const; + void EnableAsyncDrag( bool b ) { bAsyncBeginDrag = b; } + void SetUpdateMode( bool bMode ); + bool GetUpdateMode() const { return bUpdateMode; } + tools::Rectangle GetClipRegionRect() const; + bool HasHorScrollBar() const { return aHorSBar->IsVisible(); } + void ShowFocusRect( const SvTreeListEntry* pEntry ); + void CallEventListeners( VclEventId nEvent, void* pData = nullptr ); + + /** Enables, that one cell of a tablistbox entry can be focused */ + bool IsCellFocusEnabled() const { return bIsCellFocusEnabled; } + void EnableCellFocus() { bIsCellFocusEnabled = true; } + bool SetCurrentTabPos( sal_uInt16 _nNewPos ); + sal_uInt16 GetCurrentTabPos() const { return nCurTabPos; } + + bool IsSelectable( const SvTreeListEntry* pEntry ); + void SetForceMakeVisible(bool bEnable) { mbForceMakeVisible = bEnable; } +}; + +inline Image& SvImpLBox::implGetImageLocation( const ImageType _eType ) +{ + return m_aNodeAndEntryImages[_eType]; +} + +inline void SvImpLBox::SetExpandedNodeBmp( const Image& rImg ) +{ + implGetImageLocation( ImageType::NodeExpanded ) = rImg; + SetNodeBmpWidth( rImg ); +} + +inline void SvImpLBox::SetCollapsedNodeBmp( const Image& rImg ) +{ + implGetImageLocation( ImageType::NodeCollapsed ) = rImg; + SetNodeBmpWidth( rImg ); +} + +inline const Image& SvImpLBox::GetDontKnowNodeBmp( ) +{ + return implGetImageLocation( ImageType::NodeDontKnow ); +} + +inline const Image& SvImpLBox::GetExpandedNodeBmp( ) +{ + return implGetImageLocation( ImageType::NodeExpanded ); +} + +inline const Image& SvImpLBox::GetCollapsedNodeBmp( ) +{ + return implGetImageLocation( ImageType::NodeCollapsed ); +} + +inline void SvImpLBox::SetDefaultEntryExpBmp( const Image& _rImg ) +{ + implGetImageLocation( ImageType::EntryDefExpanded ) = _rImg; +} + +inline void SvImpLBox::SetDefaultEntryColBmp( const Image& _rImg ) +{ + implGetImageLocation( ImageType::EntryDefCollapsed ) = _rImg; +} + +inline const Image& SvImpLBox::GetDefaultEntryExpBmp( ) +{ + return implGetImageLocation( ImageType::EntryDefExpanded ); +} + +inline const Image& SvImpLBox::GetDefaultEntryColBmp( ) +{ + return implGetImageLocation( ImageType::EntryDefCollapsed ); +} + +inline Point SvImpLBox::GetEntryPosition( SvTreeListEntry* pEntry ) const +{ + return Point( 0, GetEntryLine( pEntry ) ); +} + +inline bool SvImpLBox::IsLineVisible( long nY ) const +{ + bool bRet = true; + if ( nY < 0 || nY >= aOutputSize.Height() ) + bRet = false; + return bRet; +} + +inline void SvImpLBox::TreeInserted( SvTreeListEntry* pInsTree ) +{ + EntryInserted( pInsTree ); +} + +#endif // INCLUDED_VCL_SOURCE_INC_SVIMPBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/svlbitm.hxx b/include/vcl/svlbitm.hxx new file mode 100644 index 000000000000..854c4666d50e --- /dev/null +++ b/include/vcl/svlbitm.hxx @@ -0,0 +1,282 @@ +/* -*- 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_VCL_SVLBITM_HXX +#define INCLUDED_VCL_SVLBITM_HXX + +#include +#include +#include +#include +#include +#include + +class SvTreeListEntry; + + +enum class SvBmp +{ + UNCHECKED = 0, + CHECKED = 1, + TRISTATE = 2, + HIUNCHECKED = 3, + HICHECKED = 4, + HITRISTATE = 5, + STATICIMAGE = 6 +}; + +enum class SvItemStateFlags +{ + NONE = 0x00, + UNCHECKED = 0x01, + CHECKED = 0x02, + TRISTATE = 0x04, + HILIGHTED = 0x08 +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +struct SvLBoxButtonData_Impl; + +class VCL_DLLPUBLIC SvLBoxButtonData +{ +private: + Link aLink; + long nWidth; + long nHeight; + std::unique_ptr pImpl; + bool bDataOk; + std::vector aBmps; // indices s. constants BMP_ .... + + VCL_DLLPRIVATE void SetWidthAndHeight(); + VCL_DLLPRIVATE void InitData( bool _bRadioBtn, const Control* pControlForSettings ); +public: + // include creating default images (CheckBox or RadioButton) + SvLBoxButtonData( const Control* pControlForSettings ); + SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn ); + + ~SvLBoxButtonData(); + + static SvBmp GetIndex( SvItemStateFlags nItemState ); + long Width(); + long Height(); + void SetLink( const Link& rLink) { aLink=rLink; } + bool IsRadio(); + // as buttons are not derived from LinkHdl + void CallLink(); + + void StoreButtonState( SvTreeListEntry* pEntry ); + static SvButtonState ConvertToButtonState( SvItemStateFlags nItemFlags ); + + SvTreeListEntry* GetActEntry() const; + + void SetImage(SvBmp nIndex, const Image& aImage) { aBmps[static_cast(nIndex)] = aImage; } + Image& GetImage(SvBmp nIndex) { return aBmps[static_cast(nIndex)]; } + + void SetDefaultImages( const Control* pControlForSettings ); + // set images according to the color scheme of the Control + // pControlForSettings == NULL: settings are taken from Application + bool HasDefaultImages() const; +}; + +// ********************************************************************** + +class VCL_DLLPUBLIC SvLBoxString : public SvLBoxItem +{ +protected: + OUString maText; + +public: + SvLBoxString(const OUString& rText); + SvLBoxString(); + virtual ~SvLBoxString() override; + + virtual SvLBoxItemType GetType() const override; + virtual void InitViewData(SvTreeListBox* pView, + SvTreeListEntry* pEntry, + SvViewDataItem* pViewData = nullptr) override; + + const OUString& GetText() const + { + return maText; + } + void SetText(const OUString& rText) + { + maText = rText; + } + + virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, + vcl::RenderContext& rRenderContext, + const SvViewDataEntry* pView, + const SvTreeListEntry& rEntry) override; + + virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; +}; + +class VCL_DLLPUBLIC SvLBoxButton : public SvLBoxItem +{ + bool isVis; + SvLBoxButtonData* pData; + SvLBoxButtonKind const eKind; + SvItemStateFlags nItemFlags; + + static void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::RenderContext const & pRenderContext); +public: + // An SvLBoxButton can be of three different kinds: an + // enabled checkbox (the normal kind), a disabled checkbox + // (which cannot be modified via UI), or a static image + // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored + // for that kind). + SvLBoxButton( SvLBoxButtonKind eTheKind, SvLBoxButtonData* pBData ); + SvLBoxButton(); + virtual ~SvLBoxButton() override; + virtual void InitViewData(SvTreeListBox* pView, + SvTreeListEntry* pEntry, + SvViewDataItem* pViewData = nullptr) override; + + virtual SvLBoxItemType GetType() const override; + void ClickHdl( SvTreeListEntry* ); + + virtual void Paint(const Point& rPos, + SvTreeListBox& rOutDev, + vcl::RenderContext& rRenderContext, + const SvViewDataEntry* pView, + const SvTreeListEntry& rEntry) override; + + virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; + + SvItemStateFlags GetButtonFlags() const + { + return nItemFlags; + } + bool IsStateChecked() const + { + return bool(nItemFlags & SvItemStateFlags::CHECKED); + } + bool IsStateUnchecked() const + { + return bool(nItemFlags & SvItemStateFlags::UNCHECKED); + } + bool IsStateTristate() const + { + return bool(nItemFlags & SvItemStateFlags::TRISTATE); + } + bool IsStateHilighted() const + { + return bool(nItemFlags & SvItemStateFlags::HILIGHTED); + } + void SetStateChecked(); + void SetStateUnchecked(); + void SetStateTristate(); + void SetStateHilighted(bool bHilight); + void SetStateInvisible(); + + SvLBoxButtonKind GetKind() const { return eKind; } + + // Check whether this button can be modified via UI + bool CheckModification() const; +}; + +inline void SvLBoxButton::SetStateChecked() +{ + nItemFlags &= SvItemStateFlags::HILIGHTED; + nItemFlags |= SvItemStateFlags::CHECKED; +} + +inline void SvLBoxButton::SetStateUnchecked() +{ + nItemFlags &= SvItemStateFlags::HILIGHTED; + nItemFlags |= SvItemStateFlags::UNCHECKED; +} +inline void SvLBoxButton::SetStateTristate() +{ + nItemFlags &= SvItemStateFlags::HILIGHTED; + nItemFlags |= SvItemStateFlags::TRISTATE; +} +inline void SvLBoxButton::SetStateHilighted( bool bHilight ) +{ + if ( bHilight ) + nItemFlags |= SvItemStateFlags::HILIGHTED; + else + nItemFlags &= ~SvItemStateFlags::HILIGHTED; +} + +struct SvLBoxContextBmp_Impl; + +class VCL_DLLPUBLIC SvLBoxContextBmp : public SvLBoxItem +{ + std::unique_ptr m_pImpl; +public: + SvLBoxContextBmp(const Image& aBmp1, + const Image& aBmp2, + bool bExpanded); + SvLBoxContextBmp(); + virtual ~SvLBoxContextBmp() override; + + virtual SvLBoxItemType GetType() const override; + virtual void InitViewData(SvTreeListBox* pView, + SvTreeListEntry* pEntry, + SvViewDataItem* pViewData = nullptr) override; + virtual void Paint(const Point& rPos, + SvTreeListBox& rOutDev, + vcl::RenderContext& rRenderContext, + const SvViewDataEntry* pView, + const SvTreeListEntry& rEntry) override; + + virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const override; + + void SetModeImages(const Image& rBitmap1, const Image& rBitmap2); + + inline void SetBitmap1(const Image& rImage); + inline void SetBitmap2(const Image& rImage); + inline const Image& GetBitmap1() const; + inline const Image& GetBitmap2() const; + +private: + Image& implGetImageStore(bool bFirst); +}; + +inline void SvLBoxContextBmp::SetBitmap1(const Image& _rImage) +{ + implGetImageStore(true) = _rImage; +} + +inline void SvLBoxContextBmp::SetBitmap2(const Image& _rImage) +{ + implGetImageStore(false) = _rImage; +} + +inline const Image& SvLBoxContextBmp::GetBitmap1() const +{ + Image& rImage = const_cast(this)->implGetImageStore(true); + return rImage; +} + +inline const Image& SvLBoxContextBmp::GetBitmap2() const +{ + Image& rImage = const_cast(this)->implGetImageStore(false); + return rImage; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx new file mode 100644 index 000000000000..7539048d18f6 --- /dev/null +++ b/include/vcl/transfer.hxx @@ -0,0 +1,507 @@ +/* -*- 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_VCL_TRANSFER_HXX +#define INCLUDED_VCL_TRANSFER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class BitmapEx; +class GDIMetaFile; +class Graphic; +class ImageMap; +class INetBookmark; +class INetImage; +class FileList; +class SotStorageStream; +namespace vcl { class Window; } + +// Drag&Drop defines + +#define DND_ACTION_NONE css::datatransfer::dnd::DNDConstants::ACTION_NONE +#define DND_ACTION_COPY css::datatransfer::dnd::DNDConstants::ACTION_COPY +#define DND_ACTION_MOVE css::datatransfer::dnd::DNDConstants::ACTION_MOVE +#define DND_ACTION_COPYMOVE css::datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE +#define DND_ACTION_LINK css::datatransfer::dnd::DNDConstants::ACTION_LINK + +#define DND_POINTER_NONE 0 +#define DND_IMAGE_NONE 0 + +struct TransferableObjectDescriptor +{ + SvGlobalName maClassName; + sal_uInt16 mnViewAspect; + Point maDragStartPos; + Size maSize; + OUString maTypeName; + OUString maDisplayName; + + TransferableObjectDescriptor() + : mnViewAspect(css::embed::Aspects::MSOLE_CONTENT) + {} + + VCL_DLLPUBLIC friend SvStream& WriteTransferableObjectDescriptor( SvStream& rOStm, const TransferableObjectDescriptor& rObjDesc ); +}; + +struct AcceptDropEvent +{ + sal_Int8 mnAction; + Point maPosPixel; + const css::datatransfer::dnd::DropTargetDragEvent maDragEvent; + bool mbLeaving; + bool mbDefault; + + AcceptDropEvent() : + mnAction( DND_ACTION_NONE ), + mbLeaving( false ), + mbDefault( false ) {} + + AcceptDropEvent( sal_Int8 nAction, + const Point& rPosPixel, + const css::datatransfer::dnd::DropTargetDragEvent& rDragEvent ) : + mnAction( nAction ), + maPosPixel( rPosPixel ), + maDragEvent( rDragEvent ), + mbLeaving( false ), + mbDefault( false ) {} +}; + +struct ExecuteDropEvent +{ + sal_Int8 mnAction; + Point maPosPixel; + const css::datatransfer::dnd::DropTargetDropEvent maDropEvent; + bool mbDefault; + + ExecuteDropEvent( sal_Int8 nAction, + const Point& rPosPixel, + const css::datatransfer::dnd::DropTargetDropEvent& rDropEvent ) : + mnAction( nAction ), + maPosPixel( rPosPixel ), + maDropEvent( rDropEvent ), + mbDefault( false ) {} +}; + +class VCL_DLLPUBLIC TransferableHelper : public cppu::WeakImplHelper< css::datatransfer::XTransferable2, + css::datatransfer::clipboard::XClipboardOwner, + css::datatransfer::dnd::XDragSourceListener, + css::lang::XUnoTunnel > +{ +private: + + // nested class to implement the XTerminateListener interface + class TerminateListener : public cppu::WeakImplHelper< css::frame::XTerminateListener, css::lang::XServiceInfo > + { + private: + + TransferableHelper& mrParent; + + private: + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XTerminateListener + virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + public: + + TerminateListener( TransferableHelper& rDropTargetHelper ); + virtual ~TerminateListener() override; + }; + + friend class TransferableHelper::TerminateListener; + +private: + + css::uno::Any maAny; + OUString maLastFormat; + mutable css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; + css::uno::Reference< css::frame::XTerminateListener > mxTerminateListener; + DataFlavorExVector maFormats; + std::unique_ptr mxObjDesc; + +protected: + const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& + getOwnClipboard() const { return mxClipboard; } + +private: + + // XTransferable + virtual css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& rFlavor ) override; + virtual css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors() override; + virtual sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& rFlavor ) override; + + // Transferable2 + virtual css::uno::Any SAL_CALL getTransferData2( + const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XDragSourceListener + virtual void SAL_CALL dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override; + virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DragSourceEvent& dse ) override; + virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + +private: + + // XClipboardOwner + virtual void SAL_CALL lostOwnership( const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& xClipboard, const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) override; + +protected: + // derivees need to access lostOwnership in case hey override it + // on windows, changing the access rights to a method gives unresolved externals, so we introduce + // this impl-method here 'til the next incompatible update + void implCallOwnLostOwnership( + const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& _rxClipboard, + const css::uno::Reference< css::datatransfer::XTransferable >& _rxTrans + ) + { + TransferableHelper::lostOwnership( _rxClipboard, _rxTrans ); + } + + +private: + + VCL_DLLPRIVATE void ImplFlush(); + +protected: + + void AddFormat( SotClipboardFormatId nFormat ); + void AddFormat( const css::datatransfer::DataFlavor& rFlavor ); + void RemoveFormat( SotClipboardFormatId nFormat ); + void RemoveFormat( const css::datatransfer::DataFlavor& rFlavor ); + bool HasFormat( SotClipboardFormatId nFormat ); + void ClearFormats(); + + bool SetAny( const css::uno::Any& rAny ); + bool SetString( const OUString& rString, const css::datatransfer::DataFlavor& rFlavor ); + bool SetBitmapEx( const BitmapEx& rBitmap, const css::datatransfer::DataFlavor& rFlavor ); + bool SetGDIMetaFile( const GDIMetaFile& rMtf ); + bool SetGraphic( const Graphic& rGraphic ); + bool SetImageMap( const ImageMap& rIMap ); + bool SetTransferableObjectDescriptor( const TransferableObjectDescriptor& rDesc ); + bool SetINetBookmark( const INetBookmark& rBmk, const css::datatransfer::DataFlavor& rFlavor ); + bool SetINetImage( const INetImage& rINtImg, const css::datatransfer::DataFlavor& rFlavor ); + bool SetObject( void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ); + +protected: + + virtual void AddSupportedFormats() = 0; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) = 0; + virtual bool WriteObject( tools::SvRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ); + virtual void DragFinished( sal_Int8 nDropAction ); + virtual void ObjectReleased(); + +public: + + void PrepareOLE( const TransferableObjectDescriptor& rObjDesc ); + + void CopyToClipboard( vcl::Window *pWindow ) const; + void CopyToSelection( vcl::Window *pWindow ) const; + void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, + sal_Int32 nDragPointer = DND_POINTER_NONE ); + + static void ClearSelection( vcl::Window *pWindow ); + + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); + +public: + + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; +}; + +struct TransferableDataHelper_Impl; + +class VCL_DLLPUBLIC TransferableDataHelper final +{ + friend class DropTargetHelper; + + css::uno::Reference< css::datatransfer::XTransferable > mxTransfer; + css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; + DataFlavorExVector maFormats; + std::unique_ptr mxObjDesc; + std::unique_ptr mxImpl; + + void InitFormats(); + +public: + + static void FillDataFlavorExVector( const css::uno::Sequence< css::datatransfer::DataFlavor >& rDataFlavorSeq, + DataFlavorExVector& rDataFlavorExVector ); + + TransferableDataHelper(); + TransferableDataHelper( const TransferableDataHelper& rDataHelper ); + TransferableDataHelper( TransferableDataHelper&& rDataHelper ); + TransferableDataHelper( const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable ); + ~TransferableDataHelper(); + + TransferableDataHelper& operator=( const TransferableDataHelper& rDataHelper ); + TransferableDataHelper& operator=( TransferableDataHelper&& rDataHelper ); + + const css::uno::Reference< css::datatransfer::XTransferable >& GetTransferable() const { return mxTransfer; } + css::uno::Reference< css::datatransfer::XTransferable > GetXTransferable() const; + + bool HasFormat( SotClipboardFormatId nFormat ) const; + bool HasFormat( const css::datatransfer::DataFlavor& rFlavor ) const; + + sal_uInt32 GetFormatCount() const; + + SotClipboardFormatId GetFormat( sal_uInt32 nFormat ) const; + css::datatransfer::DataFlavor GetFormatDataFlavor( sal_uInt32 nFormat ) const; + + const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } + + bool StartClipboardListening( ); + void StopClipboardListening( ); + + void Rebind( const css::uno::Reference< css::datatransfer::XTransferable >& _rxNewData ); + + css::uno::Any GetAny( SotClipboardFormatId nFormat, const OUString& rDestDoc ) const; + css::uno::Any GetAny( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) const; + + bool GetString( SotClipboardFormatId nFormat, OUString& rStr ); + bool GetString( const css::datatransfer::DataFlavor& rFlavor, OUString& rStr ); + + bool GetBitmapEx( SotClipboardFormatId nFormat, BitmapEx& rBmp ); + bool GetBitmapEx( const css::datatransfer::DataFlavor& rFlavor, BitmapEx& rBmp ); + + /** Return as GDI metafile. + + @param nMaxAction Allows you to limit the amount of actions; defaults to 0 which means no limit. + + When you eg. Ctrl+a in Excel, you can get the entire sheet as + metafile, with over 3 million (!) actions; which is just too large for + any reasonable handling - and you need to set a limit. + */ + bool GetGDIMetaFile( SotClipboardFormatId nFormat, GDIMetaFile& rMtf, size_t nMaxActions = 0 ); + bool GetGDIMetaFile( const css::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf ); + + bool GetGraphic( SotClipboardFormatId nFormat, Graphic& rGraphic ); + bool GetGraphic( const css::datatransfer::DataFlavor& rFlavor, Graphic& rGraphic ); + + bool GetImageMap( SotClipboardFormatId nFormat, ImageMap& rIMap ); + bool GetImageMap( const css::datatransfer::DataFlavor& rFlavor, ImageMap& rImap ); + + bool GetTransferableObjectDescriptor( SotClipboardFormatId nFormat, TransferableObjectDescriptor& rDesc ); + bool GetTransferableObjectDescriptor( TransferableObjectDescriptor& rDesc ); + + bool GetINetBookmark( SotClipboardFormatId nFormat, INetBookmark& rBmk ); + bool GetINetBookmark( const css::datatransfer::DataFlavor& rFlavor, INetBookmark& rBmk ); + + bool GetINetImage( SotClipboardFormatId nFormat, INetImage& rINtImg ); + bool GetINetImage( const css::datatransfer::DataFlavor& rFlavor, INetImage& rINtImg ); + + bool GetFileList( SotClipboardFormatId nFormat, FileList& rFileList ); + bool GetFileList( FileList& rFileList ); + + css::uno::Sequence GetSequence( SotClipboardFormatId nFormat, const OUString& rDestDoc ); + css::uno::Sequence GetSequence( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); + + bool GetSotStorageStream( SotClipboardFormatId nFormat, tools::SvRef& rStreamRef ); + bool GetSotStorageStream( const css::datatransfer::DataFlavor& rFlavor, tools::SvRef& rStreamRef ); + + css::uno::Reference GetInputStream( SotClipboardFormatId nFormat, const OUString& rDestDoc ); + css::uno::Reference GetInputStream( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); + + static TransferableDataHelper CreateFromSystemClipboard( vcl::Window * pWindow ); + static TransferableDataHelper CreateFromSelection( vcl::Window * pWindow ); + static bool IsEqual( const css::datatransfer::DataFlavor& rInternalFlavor, + const css::datatransfer::DataFlavor& rRequestFlavor ); +}; + +class VCL_DLLPUBLIC DragSourceHelper +{ +private: + + // nested class to implement the XDragGestureListener interface + class DragGestureListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDragGestureListener > + { + private: + + DragSourceHelper& mrParent; + + private: + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XDragGestureListener + virtual void SAL_CALL dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE ) override; + + public: + + DragGestureListener( DragSourceHelper& rDragSourceHelper ); + virtual ~DragGestureListener() override; + }; + + friend class DragSourceHelper::DragGestureListener; + +private: + osl::Mutex maMutex; + css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > mxDragGestureRecognizer; + + css::uno::Reference< css::datatransfer::dnd::XDragGestureListener > mxDragGestureListener; + + DragSourceHelper& operator=( const DragSourceHelper& rDragSourceHelper ) = delete; + bool operator==( const DragSourceHelper& rDragSourceHelper ) const = delete; + +public: + + // to be overridden by the application + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); + + DragSourceHelper( vcl::Window* pWindow ); + void dispose(); + virtual ~DragSourceHelper(); +}; + +class VCL_DLLPUBLIC DropTargetHelper +{ +private: + + // nested class to implement the XDropTargetListener interface + class DropTargetListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener > + { + private: + + DropTargetHelper& mrParent; + std::unique_ptr mpLastDragOverEvent; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XDropTargetListener + virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override; + virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override; + virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override; + virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; + virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; + + public: + + DropTargetListener( DropTargetHelper& rDropTargetHelper ); + virtual ~DropTargetListener() override; + }; + + friend class DropTargetHelper::DropTargetListener; + +private: + osl::Mutex maMutex; + css::uno::Reference< css::datatransfer::dnd::XDropTarget > mxDropTarget; + + css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > mxDropTargetListener; + DataFlavorExVector maFormats; + + DropTargetHelper() = delete; + DropTargetHelper& operator=( const DropTargetHelper& rDropTargetHelper ) = delete; + bool operator==( const DropTargetHelper& rDropTargetHelper ) const = delete; + + void ImplConstruct(); + + // called by our own implementation of XDropTargetListener (DropTargetListener instance) + void ImplBeginDrag( const css::uno::Sequence< css::datatransfer::DataFlavor >& rSupportedDataFlavors ); + void ImplEndDrag(); + +public: + + // to be overridden by the application + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); + + DropTargetHelper( vcl::Window* pWindow ); + DropTargetHelper( const css::uno::Reference< css::datatransfer::dnd::XDropTarget >& rxDropTarget ); + + void dispose(); + virtual ~DropTargetHelper(); + + // typically called by the application in ::AcceptDrop and ::ExecuteDrop and (see above) + bool IsDropFormatSupported( SotClipboardFormatId nFormat ); + + const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } + +}; + +struct TransferDataContainer_Impl; + +class VCL_DLLPUBLIC TransferDataContainer : public TransferableHelper +{ + std::unique_ptr pImpl; + +protected: + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + virtual void DragFinished( sal_Int8 nDropAction ) override; + +public: + + TransferDataContainer(); + virtual ~TransferDataContainer() override; + + void CopyINetBookmark( const INetBookmark& rBkmk ); + void CopyString( const OUString& rStr ); + void CopyString( SotClipboardFormatId nFmt, const OUString& rStr ); + void CopyAny( SotClipboardFormatId nFmt, const css::uno::Any& rAny ); + + void CopyByteString( SotClipboardFormatId nFormatId, const OString& rStr ); + void CopyAnyData( SotClipboardFormatId nFormatId, const sal_Char* pData, sal_uLong nLen ); + + bool HasAnyData() const; + + using TransferableHelper::StartDrag; + void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, + const Link& rCallbck ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/treelist.hxx b/include/vcl/treelist.hxx new file mode 100644 index 000000000000..fb2aa3333adc --- /dev/null +++ b/include/vcl/treelist.hxx @@ -0,0 +1,339 @@ +/* -*- 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_VCL_TREELIST_HXX +#define INCLUDED_VCL_TREELIST_HXX + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +enum class SvListAction +{ + INSERTED = 1, + REMOVING = 2, + REMOVED = 3, + MOVING = 4, + MOVED = 5, + CLEARING = 6, + INSERTED_TREE = 7, + INVALIDATE_ENTRY = 8, + RESORTING = 9, + RESORTED = 10, + CLEARED = 11, + REVERSING = 12, + REVERSED = 13 +}; + +class SvTreeListEntry; +class SvListView; + +enum SvSortMode { SortAscending, SortDescending, SortNone }; + +// For the return values of Sortlink: +// See International::Compare( pLeft, pRight ) +// ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) ) +struct SvSortData +{ + const SvTreeListEntry* pLeft; + const SvTreeListEntry* pRight; +}; + +class VCL_DLLPUBLIC SvTreeList final +{ + typedef std::vector ListViewsType; + + friend class SvListView; + + ListViewsType aViewList; + sal_uLong nEntryCount; + + Link aCloneLink; + Link aCompareLink; + SvSortMode eSortMode; + + sal_uInt16 nRefCount; + + bool bAbsPositionsValid; + + bool mbEnableInvalidate; + + SvTreeListEntry* FirstVisible() const { return First(); } + SvTreeListEntry* NextVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const; + SvTreeListEntry* PrevVisible( const SvListView*,SvTreeListEntry* pEntry ) const; + SvTreeListEntry* LastVisible( const SvListView* ) const; + SvTreeListEntry* NextVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const; + SvTreeListEntry* PrevVisible( const SvListView*,SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const; + + bool IsEntryVisible( const SvListView*,SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetEntryAtVisPos( const SvListView*,sal_uLong nVisPos ) const; + sal_uLong GetVisiblePos( const SvListView*,SvTreeListEntry const * pEntry ) const; + sal_uLong GetVisibleCount( SvListView* ) const; + sal_uLong GetVisibleChildCount( const SvListView*,SvTreeListEntry* pParent ) const; + + SvTreeListEntry* FirstSelected( const SvListView*) const; + SvTreeListEntry* NextSelected( const SvListView*,SvTreeListEntry* pEntry ) const; + SvTreeListEntry* PrevSelected( const SvListView*,SvTreeListEntry* pEntry ) const; + SvTreeListEntry* LastSelected( const SvListView*) const; + + static bool Select( SvListView*,SvTreeListEntry* pEntry, bool bSelect ); + sal_uLong GetChildSelectionCount( const SvListView*,SvTreeListEntry* pParent ) const; + + static void Expand( SvListView*,SvTreeListEntry* pParent ); + static void Collapse( SvListView*,SvTreeListEntry* pParent ); + + VCL_DLLPRIVATE void SetAbsolutePositions(); + + VCL_DLLPRIVATE void CloneChildren( + SvTreeListEntries& rDst, sal_uLong& rCloneCount, SvTreeListEntries& rSrc, SvTreeListEntry& rNewParent) const; + + /** + * Invalidate the cached position data to have them re-generated before + * the next access. + */ + VCL_DLLPRIVATE static void SetListPositions( SvTreeListEntries& rEntries ); + + // rPos is not changed for SortModeNone + VCL_DLLPRIVATE void GetInsertionPos( + SvTreeListEntry const * pEntry, + SvTreeListEntry* pParent, + sal_uLong& rPos + ); + + VCL_DLLPRIVATE void ResortChildren( SvTreeListEntry* pParent ); + VCL_DLLPRIVATE void ReverseChildren( SvTreeListEntry* pParent ); + + SvTreeList(const SvTreeList&) = delete; + SvTreeList& operator= (const SvTreeList&) = delete; + + std::unique_ptr pRootItem; + +public: + + SvTreeList(); + ~SvTreeList(); + + void InsertView( SvListView* ); + void RemoveView( SvListView const * ); + + void Broadcast( + SvListAction nActionId, + SvTreeListEntry* pEntry1=nullptr, + SvTreeListEntry* pEntry2=nullptr, + sal_uLong nPos=0 + ); + + void EnableInvalidate( bool bEnable ); + + // Notify all Listeners + void InvalidateEntry( SvTreeListEntry* ); + + sal_uLong GetEntryCount() const { return nEntryCount; } + SvTreeListEntry* First() const; + SvTreeListEntry* Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const; + SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const; + SvTreeListEntry* Last() const; + + SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; + + sal_uLong Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pPar,sal_uLong nPos = TREELIST_APPEND); + sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND ) + { return Insert(pEntry, pRootItem.get(), nRootPos ); } + + void InsertTree( SvTreeListEntry* pTree, SvTreeListEntry* pTargetParent, sal_uLong nListPos ); + + // Entries need to be in the same Model! + void Move( SvTreeListEntry* pSource, SvTreeListEntry* pTarget ); + + // Creates ChildList if needed + sal_uLong Move( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos); + sal_uLong Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos); + + bool Remove( const SvTreeListEntry* pEntry ); + void Clear(); + + bool HasChildren( const SvTreeListEntry* pEntry ) const; + bool HasParent( const SvTreeListEntry* pEntry ) const; + + bool IsChild(const SvTreeListEntry* pParent, const SvTreeListEntry* pChild) const; + SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const; + SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const; + SvTreeListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const; + + const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ); + + SvTreeListEntry* GetRootLevelParent( SvTreeListEntry* pEntry ) const; + const SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ) const; + SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ); + + std::pair + GetChildIterators(SvTreeListEntry* pParent); + + sal_uLong GetAbsPos( const SvTreeListEntry* pEntry ) const; + static sal_uLong GetRelPos( const SvTreeListEntry* pChild ); + + sal_uLong GetChildCount( const SvTreeListEntry* pParent ) const; + sal_uInt16 GetDepth( const SvTreeListEntry* pEntry ) const; + bool IsAtRootDepth( const SvTreeListEntry* pEntry ) const; + + // The Model calls the Clone Link to clone Entries. + // Thus we do not need to derive from the Model if we derive from SvTreeListEntry. + // The Handler needs to return a SvTreeListEntry* + SvTreeListEntry* Clone( SvTreeListEntry* pEntry, sal_uLong& nCloneCount ) const; + void SetCloneLink( const Link& rLink ) + { aCloneLink=rLink; } + + const Link& GetCloneLink() const + { return aCloneLink; } + + SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ) const; // Calls the Clone Link + + sal_uInt16 GetRefCount() const { return nRefCount; } + void SetRefCount( sal_uInt16 nRef ) { nRefCount = nRef; } + + void SetSortMode( SvSortMode eMode ) { eSortMode = eMode; } + SvSortMode GetSortMode() const { return eSortMode; } + sal_Int32 Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const; + void SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; } + void Resort(); + void Reverse(); +}; + +class VCL_DLLPUBLIC SvListView +{ + friend class SvTreeList; + + struct Impl; + std::unique_ptr m_pImpl; + +protected: + SvTreeList* pModel; + + void ExpandListEntry( SvTreeListEntry* pParent ) + { SvTreeList::Expand(this,pParent); } + + void CollapseListEntry( SvTreeListEntry* pParent ) + { SvTreeList::Collapse(this,pParent); } + + bool SelectListEntry( SvTreeListEntry* pEntry, bool bSelect ) + { return SvTreeList::Select(this,pEntry,bSelect); } + +public: + SvListView(); // Sets the Model to 0 + virtual ~SvListView(); + void Clear(); + virtual void SetModel( SvTreeList* ); + virtual void ModelNotification( + SvListAction nActionId, + SvTreeListEntry* pEntry1, + SvTreeListEntry* pEntry2, + sal_uLong nPos + ); + + sal_uLong GetVisibleCount() const + { return pModel->GetVisibleCount( const_cast(this) ); } + + SvTreeListEntry* FirstVisible() const + { return pModel->FirstVisible(); } + + SvTreeListEntry* NextVisible( SvTreeListEntry* pEntry, sal_uInt16* pDepth=nullptr ) const + { return pModel->NextVisible(this,pEntry,pDepth); } + + SvTreeListEntry* PrevVisible( SvTreeListEntry* pEntry ) const + { return pModel->PrevVisible(this,pEntry); } + + SvTreeListEntry* LastVisible() const + { return pModel->LastVisible(this); } + + SvTreeListEntry* NextVisible( SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const + { return pModel->NextVisible(this,pEntry,rDelta); } + + SvTreeListEntry* PrevVisible( SvTreeListEntry* pEntry, sal_uInt16& rDelta ) const + { return pModel->PrevVisible(this,pEntry,rDelta); } + + sal_uLong GetSelectionCount() const; + + SvTreeListEntry* FirstSelected() const + { return pModel->FirstSelected(this); } + + SvTreeListEntry* NextSelected( SvTreeListEntry* pEntry ) const + { return pModel->NextSelected(this,pEntry); } + + SvTreeListEntry* PrevSelected( SvTreeListEntry* pEntry ) const + { return pModel->PrevSelected(this,pEntry); } + + SvTreeListEntry* LastSelected() const + { return pModel->LastSelected(this); } + SvTreeListEntry* GetEntryAtAbsPos( sal_uLong nAbsPos ) const + { return pModel->GetEntryAtAbsPos(nAbsPos); } + + SvTreeListEntry* GetEntryAtVisPos( sal_uLong nVisPos ) const + { return pModel->GetEntryAtVisPos(this,nVisPos); } + + sal_uLong GetAbsPos( SvTreeListEntry const * pEntry ) const + { return pModel->GetAbsPos(pEntry); } + + sal_uLong GetVisiblePos( SvTreeListEntry const * pEntry ) const + { return pModel->GetVisiblePos(this,pEntry); } + + sal_uLong GetVisibleChildCount(SvTreeListEntry* pParent ) const + { return pModel->GetVisibleChildCount(this,pParent); } + + sal_uLong GetChildSelectionCount( SvTreeListEntry* pParent ) const + { return pModel->GetChildSelectionCount(this,pParent); } + + bool IsEntryVisible( SvTreeListEntry* pEntry ) const + { return pModel->IsEntryVisible(this,pEntry); } + + bool IsExpanded( SvTreeListEntry* pEntry ) const; + bool IsSelected( SvTreeListEntry* pEntry ) const; + void SetEntryFocus( SvTreeListEntry* pEntry, bool bFocus ); + const SvViewDataEntry* GetViewData( const SvTreeListEntry* pEntry ) const; + SvViewDataEntry* GetViewData( SvTreeListEntry* pEntry ); + bool HasViewData() const; + + virtual std::unique_ptr CreateViewData( SvTreeListEntry* pEntry ); + virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ); + + virtual void ModelHasCleared(); + virtual void ModelHasInserted( SvTreeListEntry* pEntry ); + virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ); + virtual void ModelIsMoving( + SvTreeListEntry* pSource, + SvTreeListEntry* pTargetParent, + sal_uLong nPos + ); + virtual void ModelHasMoved( SvTreeListEntry* pSource ); + virtual void ModelIsRemoving( SvTreeListEntry* pEntry ); + virtual void ModelHasRemoved( SvTreeListEntry* pEntry ); + virtual void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx new file mode 100644 index 000000000000..464b9d30f864 --- /dev/null +++ b/include/vcl/treelistbox.hxx @@ -0,0 +1,800 @@ +/* -*- 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_VCL_TREELISTBOX_HXX +#define INCLUDED_VCL_TREELISTBOX_HXX + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Application; +class SvTreeListBox; +class SvTreeListEntry; +struct SvViewDataItem; +class SvViewDataEntry; +class SvInplaceEdit2; +class SvLBoxString; +class SvLBoxButton; +class SvLBoxContextBmp; +class SvImpLBox; +class SvLBoxButtonData; +struct SvLBoxDDInfo; + +namespace utl { + class AccessibleStateSetHelper; +} + +enum class SvLBoxButtonKind +{ + EnabledCheckbox, + DisabledCheckbox, + StaticImage +}; + +enum class SvButtonState { Unchecked, Checked, Tristate }; + +// ********************************************************************* +// *************************** Tabulators ****************************** +// ********************************************************************* + +enum class SvLBoxTabFlags +{ + NONE = 0x0000, + DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth + ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator + ADJUST_LEFT = 0x0004, // Left margin + ADJUST_CENTER = 0x0008, // Center the item at the tabulator + ADJUST_NUMERIC = 0x0010, // Decimal point at the tabulator (strings) + + SHOW_SELECTION = 0x0040, // Visualize selection state + // Item needs to be able to return the surrounding polygon (D'n'D cursor) + EDITABLE = 0x0100, // Item editable at the tabulator + PUSHABLE = 0x0200, // Item acts like a Button + INV_ALWAYS = 0x0400, // Always delete the background + FORCE = 0x0800, // Switch off the default calculation of the first tabulator + // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on) + // The first tab's position corresponds precisely to the Flags set + // and column widths +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +#define SV_TAB_BORDER 8 + +#define SV_ENTRYHEIGHTOFFS_PIXEL 2 + +enum class SvTreeFlags +{ + CHKBTN = 0x01, + USESEL = 0x02, + MANINS = 0x04, + RECALCTABS = 0x08, + FIXEDHEIGHT = 0x10, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +enum class SvTreeAccRoleType +{ + NONE = 0x00, + TREE = 0x02 +}; + +enum class SvLBoxItemType {String, Button, ContextBmp}; + +class VCL_DLLPUBLIC SvLBoxTab +{ + long nPos; +public: + SvLBoxTab(); + SvLBoxTab( long nPos, SvLBoxTabFlags nFlags ); + SvLBoxTab( const SvLBoxTab& ); + ~SvLBoxTab(); + + SvLBoxTabFlags nFlags; + + bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); } + void SetPos( long nNewPos) { nPos = nNewPos; } + long GetPos() const { return nPos; } + long CalcOffset( long nItemLength, long nTabWidth ); + bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); } +}; + +class VCL_DLLPUBLIC SvLBoxItem +{ +public: + SvLBoxItem(); + virtual ~SvLBoxItem(); + virtual SvLBoxItemType GetType() const = 0; + const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; + static const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos); + + virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0; + + virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, + // If != 0: this Pointer must be used! + // If == 0: it needs to be retrieved via the View + SvViewDataItem* pViewData = nullptr) = 0; + // View-dependent data is not cloned + virtual std::unique_ptr Clone(SvLBoxItem const * pSource) const = 0; +}; + +enum class DragDropMode +{ + NONE = 0x0000, + CTRL_MOVE = 0x0001, + CTRL_COPY = 0x0002, + APP_MOVE = 0x0004, + APP_COPY = 0x0008, + APP_DROP = 0x0010, + // Entries may be dropped via the uppermost Entry + // The DropTarget is 0 in that case + ENABLE_TOP = 0x0020, + ALL = 0x003f, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +enum class SvTreeListBoxFlags +{ + NONE = 0x0000, + IN_EDT = 0x0001, + EDT_ENABLED = 0x0002, + IS_EXPANDING = 0x0004, + IS_TRAVELSELECT = 0x0008, + TARGEMPH_VIS = 0x0010, + EDTEND_CALLED = 0x0020, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +struct SvTreeListBoxImpl; +class SalInstanceTreeView; + +class VCL_DLLPUBLIC SvTreeListBox + :public Control + ,public SvListView + ,public DropTargetHelper + ,public DragSourceHelper + ,public vcl::IMnemonicEntryList + ,public vcl::ISearchableStringList +{ + friend class SvImpLBox; + friend class IconViewImpl; + friend class TreeControlPeer; + friend class SalInstanceTreeView; + + std::unique_ptr mpImpl; + Link aCheckButtonHdl; + Link aScrolledHdl; + Link aExpandedHdl; + Link aExpandingHdl; + Link aSelectHdl; + Link aDeselectHdl; + + Image aPrevInsertedExpBmp; + Image aPrevInsertedColBmp; + Image aCurInsertedExpBmp; + Image aCurInsertedColBmp; + + short nContextBmpWidthMax; + short nEntryHeightOffs; + short nIndent; + short nFocusWidth; + SvTreeAccRoleType nAllItemAccRoleType; + sal_uInt16 nFirstSelTab; + sal_uInt16 nLastSelTab; + long mnCheckboxItemWidth; + bool mbContextBmpExpanded; + bool mbAlternatingRowColors; + bool mbUpdateAlternatingRows; + bool mbQuickSearch; // Enables type-ahead search in the check list box. + + SvTreeListEntry* pHdlEntry; + + DragDropMode nDragDropMode; + DragDropMode nOldDragMode; + SelectionMode eSelMode; + sal_Int8 nDragOptions; + sal_Int32 nMinWidthInChars; + + SvTreeListEntry* pEdEntry; + SvLBoxItem* pEdItem; + +protected: + std::unique_ptr pImpl; + short nColumns; + short nEntryHeight; + short nEntryWidth; + bool mbCenterAndClipText; + + Link aDoubleClickHdl; + SvTreeListEntry* pTargetEntry; + SvLBoxButtonData* pCheckButtonData; + std::vector> aTabs; + SvTreeFlags nTreeFlags; + SvTreeListBoxFlags nImpFlags; + // Move/CopySelection: Position of the current Entry in SelectionList + sal_uInt16 nCurEntrySelPos; + +private: + void SetBaseModel(SvTreeList* pNewModel); + + DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void ); + DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void ); + // Handler that is called by TreeList to clone an Entry + DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* ); + + // Handler and methods for Drag - finished handler. + // The Handle retrieved by GetDragFinishedHdl can be set on the + // TransferDataContainer. This link is a callback for the DragFinished + // call. The AddBox method is called from the GetDragFinishedHdl() and the + // remove is called in the link callback and in the dtor. So it can't be + // called for a deleted object. + VCL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB ); + VCL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB ); + DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void ); + +protected: + + bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 ); + void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow); + void EnableSelectionAsDropTarget( bool bEnable = true ); + // Standard impl returns 0; derived classes which support D'n'D must override + using Window::GetDropTarget; + virtual SvTreeListEntry* GetDropTarget( const Point& ); + + // Invalidate children on enable/disable + virtual void StateChanged( StateChangedType eType ) override; + + virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND); + virtual sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND ); + + // In-place editing + std::unique_ptr pEdCtrl; + void EditText( const OUString&, const tools::Rectangle&,const Selection&); + void CancelTextEditing(); + bool EditingCanceled() const; + + // Return value must be derived from SvViewDataEntry! + virtual std::unique_ptr CreateViewData( SvTreeListEntry* ) override; + // InitViewData is called right after CreateViewData + // The Entry is has not yet been added to the View in InitViewData! + virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override; + // Calls InitViewData for all Items + void RecalcViewData(); + + // Handler and methods for Drag - finished handler. This link can be set + // to the TransferDataContainer. The AddBox/RemoveBox methods must be + // called before the StartDrag call. + // The Remove will be called from the handler, which then calls DragFinish. + // The Remove is also called in the DTOR of the SvTreeListBox - + // so it can't be called for a deleted object. + Link GetDragFinishedHdl() const; + + // For asynchronous D'n'D + sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView ); + + void OnCurrentEntryChanged(); + + // IMnemonicEntryList + virtual const void* FirstSearchEntry( OUString& _rEntryText ) const override; + virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const override; + virtual void SelectSearchEntry( const void* _pEntry ) override; + virtual void ExecuteSearchEntry( const void* _pEntry ) const override; + + // ISearchableStringList + virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override; + virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override; + virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override; + +public: + + SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 ); + virtual ~SvTreeListBox() override; + virtual void dispose() override; + + SvTreeList* GetModel() const + { + return pModel; + } + + using SvListView::SetModel; + + void SetModel(SvTreeList* pNewModel) override; + + sal_uLong GetEntryCount() const + { + return pModel ? pModel->GetEntryCount() : 0; + } + SvTreeListEntry* First() const + { + return pModel ? pModel->First() : nullptr; + } + SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const + { + return pModel->Next(pEntry); + } + SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const + { + return pModel->Prev(pEntry); + } + SvTreeListEntry* Last() const + { + return pModel ? pModel->Last() : nullptr; + } + + SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; + + bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget ); + bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback ); + void RemoveSelection(); + /** + * Removes the entry along with all of its descendants + */ + void RemoveEntry(SvTreeListEntry const * pEntry); + + DragDropMode GetDragDropMode() const { return nDragDropMode; } + SelectionMode GetSelectionMode() const { return eSelMode; } + + // pParent == 0 -> Root level + SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const; + SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const; + + SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const; + void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const; + + using Window::GetParent; + const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; + SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const; + + using Window::GetChildCount; + sal_uLong GetChildCount( SvTreeListEntry const * pParent ) const; + sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const; + + SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const; + SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); + const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; + + bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); } + bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); } + void EndEditing( bool bCancel = false ); + void ForbidEmptyText(); + + void Clear(); + + /** Enables or disables mnemonic characters in the entry texts. + + If mnemonics are enabled, then entries are selected and made current when + there mnemonic character is pressed. If there are multiple entries with the + same mnemonic, the selection cycles between them. + + Entries with an collapsed ancestor are not included in the calculation of + mnemonics. That is, if you press the accelerator key of an invisible + entry, then this entry is *not* selected. + + Be aware that enabling mnemonics gets more expensive as you add to the list. + */ + void EnableEntryMnemonics(); + bool IsEntryMnemonicsEnabled() const; + + bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; } + + /** Handles the given key event. + + At the moment this merely checks for accelerator keys, if entry mnemonics + are enabled. + + This method may come in handy if you want to use keyboard acceleration + while the control does not have the focus. + + If the key event describes the pressing of a shortcut for an entry, + then SelectSearchEntry resp. ExecuteSearchEntry are called. + + @see IMnemonicEntryList + @see MnemonicEngine + + @return + if the event has been consumed, otherwise. + */ + bool HandleKeyInput( const KeyEvent& rKEvt ); + + void SetSelectHdl( const Link& rNewHdl ) {aSelectHdl=rNewHdl; } + void SetDeselectHdl( const Link& rNewHdl ) {aDeselectHdl=rNewHdl; } + void SetDoubleClickHdl(const Link& rNewHdl) {aDoubleClickHdl=rNewHdl;} + const Link& GetSelectHdl() const { return aSelectHdl; } + const Link& GetDeselectHdl() const { return aDeselectHdl; } + const Link& GetDoubleClickHdl() const { return aDoubleClickHdl; } + void SetExpandingHdl(const Link& rNewHdl){aExpandingHdl=rNewHdl;} + void SetExpandedHdl(const Link& rNewHdl){aExpandedHdl=rNewHdl;} + + virtual void ExpandedHdl(); + virtual bool ExpandingHdl(); + virtual void SelectHdl(); + virtual void DeselectHdl(); + virtual bool DoubleClickHdl(); + SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; } + + // Is called for an Entry that gets expanded with the Flag + // ENTRYFLAG_CHILDREN_ON_DEMAND set. + virtual void RequestingChildren( SvTreeListEntry* pParent ); + + // Drag & Drop + // New D'n'D API + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; + virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, + SvTreeListEntry* ); + virtual void DragFinished( sal_Int8 nDropAction ); + virtual bool NotifyAcceptDrop( SvTreeListEntry* ); + + void SetDragOptions( sal_Int8 nOptions ) { nDragOptions = nOptions; } + + virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ); + virtual SvTreeListEntry* CreateEntry() const; // To create new Entries + + // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry + virtual TriState NotifyMoving( + SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() + SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel() + SvTreeListEntry*& rpNewParent, // New TargetParent + sal_uLong& rNewChildPos); // The TargetParent's position in Childlist + + // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry + virtual TriState NotifyCopying( + SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() + SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel() + SvTreeListEntry*& rpNewParent, // New TargetParent + sal_uLong& rNewChildPos); // The TargetParent's position in Childlist + + // ACCESSIBILITY ========================================================== + + /** Fills the StateSet of one entry. */ + void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const; + + /** Calculate and return the bounding rectangle of an entry. + @param pEntry + The entry. + @return The bounding rectangle of an entry. */ + tools::Rectangle GetBoundingRect( SvTreeListEntry* pEntry ); + + /** Enables, that one cell of a tablistbox entry can be focused */ + void EnableCellFocus(); + + // For overwriting accessible role for all entries - normally 0, so each entry can be different + void SetAllEntriesAccessibleRoleType( SvTreeAccRoleType n ) { nAllItemAccRoleType = n; } + SvTreeAccRoleType GetAllEntriesAccessibleRoleType() const { return nAllItemAccRoleType; } + + SvTreeFlags GetTreeFlags() const {return nTreeFlags;} + + static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry); + virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const; + virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const; + + void set_min_width_in_chars(sal_Int32 nChars); + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + +protected: + + VCL_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry ); + void AdjustEntryHeight( const Image& rBmp ); + VCL_DLLPRIVATE void AdjustEntryHeight(); + + VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry ); + VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, long nLine, vcl::RenderContext& rRenderContext ); + + VCL_DLLPRIVATE void InitTreeView(); + VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab ); + VCL_DLLPRIVATE void ImplInitStyle(); + + void SetupDragOrigin(); + void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem, + const Selection& ); + void EditedText(const OUString&); + + // Recalculate all tabs depending on TreeListStyle and Bitmap sizes + // Is called automatically when inserting/changing Bitmaps, changing the Model etc. + virtual void SetTabs(); + void AddTab( long nPos, SvLBoxTabFlags nFlags ); + sal_uInt16 TabCount() const { return aTabs.size(); } + SvLBoxTab* GetFirstDynamicTab() const; + SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const; + SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); + void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); + SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const; + void ClearTabList(); + + virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind); + + virtual void NotifyEndScroll(); + virtual void NotifyScrolled(); + void SetScrolledHdl( const Link& rLink ) { aScrolledHdl = rLink; } + long GetXOffset() const { return GetMapMode().GetOrigin().X(); } + + virtual void Command( const CommandEvent& rCEvt ) override; + + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry& rEntry); + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void InitSettings(); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + bool IsCellFocusEnabled() const; + bool SetCurrentTabPos( sal_uInt16 _nNewPos ); + sal_uInt16 GetCurrentTabPos() const; + void CallImplEventListeners(VclEventId nEvent, void* pData); + + void ImplEditEntry( SvTreeListEntry* pEntry ); + + bool AreChildrenTransient() const; + void SetChildrenNotTransient(); + + void AdjustEntryHeightAndRecalc(); +public: + + void SetNoAutoCurEntry( bool b ); + + void EnableCheckButton( SvLBoxButtonData* ); + void SetCheckButtonData( SvLBoxButtonData* ); + void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp ); + + /** Returns the default image which clients should use for expanded nodes, to have a consistent user + interface experience in the whole product. + */ + static const Image& GetDefaultExpandedNodeImage( ); + + /** Returns the default image which clients should use for expanded nodes, to have a consistent user + interface experience in the whole product. + */ + static const Image& GetDefaultCollapsedNodeImage( ); + + /** Sets default bitmaps for collapsed and expanded nodes. + */ + void SetNodeDefaultImages( ) + { + SetNodeBitmaps( + GetDefaultCollapsedNodeImage( ), + GetDefaultExpandedNodeImage( ) + ); + } + + virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, + bool bChildrenOnDemand = false, + sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr, + SvLBoxButtonKind eButtonKind = SvLBoxButtonKind::EnabledCheckbox ); + + virtual SvTreeListEntry* InsertEntry( const OUString& rText, + const Image& rExpandedEntryBmp, + const Image& rCollapsedEntryBmp, + SvTreeListEntry* pParent = nullptr, + bool bChildrenOnDemand = false, + sal_uLong nPos = TREELIST_APPEND, void* pUserData = nullptr, + SvLBoxButtonKind eButtonKind = SvLBoxButtonKind::EnabledCheckbox ); + + const Image& GetDefaultExpandedEntryBmp( ) const; + const Image& GetDefaultCollapsedEntryBmp( ) const; + + void SetDefaultExpandedEntryBmp( const Image& rBmp ); + void SetDefaultCollapsedEntryBmp( const Image& rBmp ); + + void SetCheckButtonState( SvTreeListEntry*, SvButtonState ); + void SetCheckButtonInvisible( SvTreeListEntry* ); + SvButtonState GetCheckButtonState( SvTreeListEntry* ) const; + + void SetEntryText(SvTreeListEntry*, const OUString& ); + void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); + void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); + + virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const; + static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ); + static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ); + + void SetCheckButtonHdl( const Link& rLink ) { aCheckButtonHdl=rLink; } + const Link& GetCheckButtonHdl() const { return aCheckButtonHdl; } + virtual void CheckButtonHdl(); + + void SetSublistOpenWithReturn(); // open/close sublist with return/enter + void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right + void SetSublistDontOpenWithDoubleClick( bool bDontOpen ); // set mouse double click open/close sublist behavior + + void EnableInplaceEditing( bool bEnable ); + // Edits the Entry's first StringItem, 0 == Cursor + void EditEntry( SvTreeListEntry* pEntry ); + virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& ); + virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ); + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + void SetUpdateMode( bool ); + + virtual void ModelHasCleared() override; + virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override; + virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override; + virtual void ModelIsMoving(SvTreeListEntry* pSource, + SvTreeListEntry* pTargetParent, sal_uLong nChildPos ) override; + virtual void ModelHasMoved(SvTreeListEntry* pSource ) override; + virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override; + virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override; + void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override; + + void ScrollOutputArea( short nDeltaEntries ); + + short GetColumnsCount() const { return nColumns; } + short GetEntryHeight() const { return nEntryHeight; } + void SetEntryHeight( short nHeight, bool bForce = false ); + short GetEntryWidth() const { return nEntryWidth; } + void SetEntryWidth( short nWidth ); + Size GetOutputSizePixel() const; + short GetIndent() const { return nIndent; } + void SetIndent( short nIndent ); + // Place the expander checkitem at the optimal indent for hierarchical lists + void SetOptimalImageIndent() { SetIndent(12); } + void SetSpaceBetweenEntries( short nSpace ); + short GetSpaceBetweenEntries() const {return nEntryHeightOffs;} + Point GetEntryPosition( SvTreeListEntry* ) const; + void MakeVisible( SvTreeListEntry* pEntry ); + void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop ); + + void SetCollapsedNodeBmp( const Image& ); + void SetExpandedNodeBmp( const Image& ); + Image const & GetExpandedNodeBmp( ) const; + + void SetFont( const vcl::Font& rFont ); + + using Window::SetCursor; + void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false ); + + SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const; + + virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nLine ); + // Respects indentation + virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ); + void InvalidateEntry( SvTreeListEntry* ); + SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab); + SvLBoxItem* GetItem( SvTreeListEntry*, long nX ); + + void SetDragDropMode( DragDropMode ); + void SetSelectionMode( SelectionMode ); + + virtual bool Expand( SvTreeListEntry* pParent ); + virtual bool Collapse( SvTreeListEntry* pParent ); + virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ); + sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect ); + void SelectAll( bool bSelect, bool bPaint = true ); + + void SetCurEntry( SvTreeListEntry* _pEntry ); + SvTreeListEntry* GetCurEntry() const; + + using Window::Invalidate; + virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override; + virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override; + + void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff); + + // A Parent's Children are turned into Children of the Parent which comes next in hierarchy + void RemoveParentKeepChildren( SvTreeListEntry* pParent ); + + DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 ); + virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1, + SvTreeListEntry* pEntry2, sal_uLong nPos ) override; + + void EndSelection(); + ScrollBar* GetVScroll(); + ScrollBar* GetHScroll(); + void EnableAsyncDrag( bool b ); + + SvTreeListEntry* GetFirstEntryInView() const; + SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const; + SvTreeListEntry* GetPrevEntryInView(SvTreeListEntry*) const; + SvTreeListEntry* GetLastEntryInView() const; + void ScrollToAbsPos( long nPos ); + + void ShowFocusRect( const SvTreeListEntry* pEntry ); + void InitStartEntry(); + + virtual VclPtr CreateContextMenu(); + virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); + + void EnableContextMenuHandling(); + + void EnableList( bool _bEnable ); + + long getPreferredDimensions(std::vector &rWidths) const; + + virtual Size GetOptimalSize() const override; + + void SetAlternatingRowColors( const bool bEnable ); + + // Enables type-ahead search in the check list box. + void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; } + + void SetForceMakeVisible(bool bEnable); + + virtual FactoryFunction GetUITestFactory() const override; +}; + +class SvInplaceEdit2 +{ + Link const aCallBackHdl; + Accelerator aAccReturn; + Accelerator aAccEscape; + Idle aIdle; + VclPtr pEdit; + bool bCanceled; + bool bAlreadyInCallBack; + + void CallCallBackHdl_Impl(); + DECL_LINK( Timeout_Impl, Timer *, void ); + DECL_LINK( ReturnHdl_Impl, Accelerator&, void ); + DECL_LINK( EscapeHdl_Impl, Accelerator&, void ); + +public: + SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize, + const OUString& rData, const Link& rNotifyEditEnd, + const Selection& ); + ~SvInplaceEdit2(); + bool KeyInput( const KeyEvent& rKEvt ); + void LoseFocus(); + bool EditingCanceled() const { return bCanceled; } + OUString GetText() const; + OUString const & GetSavedValue() const; + void StopEditing( bool bCancel ); + void Hide(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/treelistentries.hxx b/include/vcl/treelistentries.hxx new file mode 100644 index 000000000000..ffe0cb571c55 --- /dev/null +++ b/include/vcl/treelistentries.hxx @@ -0,0 +1,21 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_TREELISTENTRIES_HXX +#define INCLUDED_VCL_TREELISTENTRIES_HXX + +#include +#include + +class SvTreeListEntry; +typedef std::vector> SvTreeListEntries; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/treelistentry.hxx b/include/vcl/treelistentry.hxx new file mode 100644 index 000000000000..c734729174ce --- /dev/null +++ b/include/vcl/treelistentry.hxx @@ -0,0 +1,122 @@ +/* -*- 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_VCL_TREELISTENTRY_HXX +#define INCLUDED_VCL_TREELISTENTRY_HXX + +#include +#include +#include +#include +#include + +#include +#include + +// flags related to the model +enum class SvTLEntryFlags +{ + NONE = 0x0000, + CHILDREN_ON_DEMAND = 0x0001, + DISABLE_DROP = 0x0002, + IN_USE = 0x0004, + // is set if RequestingChildren has not set any children + NO_NODEBMP = 0x0008, + // entry had or has children + HAD_CHILDREN = 0x0010, + SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} + +class VCL_DLLPUBLIC SvTreeListEntry +{ + friend class SvTreeList; + friend class SvListView; + friend class SvTreeListBox; + + typedef std::vector> ItemsType; + + SvTreeListEntry* pParent; + SvTreeListEntries m_Children; + sal_uLong nAbsPos; + sal_uLong nListPos; + ItemsType m_Items; + void* pUserData; + SvTLEntryFlags nEntryFlags; + Color maBackColor; + +private: + void ClearChildren(); + void SetListPositions(); + void InvalidateChildrensListPositions(); + + SvTreeListEntry(const SvTreeListEntry& r) = delete; + void operator=(SvTreeListEntry const&) = delete; + +public: + static const size_t ITEM_NOT_FOUND = SAL_MAX_SIZE; + + SvTreeListEntry(); + virtual ~SvTreeListEntry(); + + bool HasChildren() const; + bool HasChildListPos() const; + sal_uLong GetChildListPos() const; + + SvTreeListEntries& GetChildEntries() { return m_Children; } + const SvTreeListEntries& GetChildEntries() const { return m_Children; } + + void Clone(SvTreeListEntry* pSource); + + size_t ItemCount() const; + + // MAY ONLY BE CALLED IF THE ENTRY HAS NOT YET BEEN INSERTED INTO + // THE MODEL, AS OTHERWISE NO VIEW-DEPENDENT DATA ARE ALLOCATED + // FOR THE ITEM! + void AddItem(std::unique_ptr pItem); + void ReplaceItem(std::unique_ptr pNewItem, size_t nPos); + const SvLBoxItem& GetItem( size_t nPos ) const; + SvLBoxItem& GetItem( size_t nPos ); + const SvLBoxItem* GetFirstItem(SvLBoxItemType eType) const; + SvLBoxItem* GetFirstItem(SvLBoxItemType eType); + size_t GetPos( const SvLBoxItem* pItem ) const; + void* GetUserData() const { return pUserData;} + void SetUserData( void* pPtr ); + void EnableChildrenOnDemand( bool bEnable=true ); + bool HasChildrenOnDemand() const; + bool HasInUseEmphasis() const; + + SvTLEntryFlags GetFlags() const { return nEntryFlags;} + void SetFlags( SvTLEntryFlags nFlags ); + + void SetBackColor( const Color& aColor ) { maBackColor = aColor; } + const Color& GetBackColor() const { return maBackColor; } + SvTreeListEntry* GetParent() const { return pParent; } + + SvTreeListEntry* NextSibling() const; + SvTreeListEntry* PrevSibling() const; + SvTreeListEntry* LastSibling() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx index 0b673774dc75..e56801af17f4 100644 --- a/include/vcl/uitest/uiobject.hxx +++ b/include/vcl/uitest/uiobject.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -404,6 +405,55 @@ protected: virtual OUString get_name() const override; }; +class UITEST_DLLPUBLIC TreeListUIObject : public WindowUIObject +{ +public: + TreeListUIObject(const VclPtr& xTreeList); + + virtual StringMap get_state() override; + + static std::unique_ptr create(vcl::Window* pWindow); + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr get_child(const OUString& rID) override; + + virtual std::set get_children() const override; + +protected: + + virtual OUString get_name() const override; + +private: + + VclPtr mxTreeList; +}; + +class UITEST_DLLPUBLIC TreeListEntryUIObject : public UIObject +{ +public: + + TreeListEntryUIObject(const VclPtr& xTreeList, SvTreeListEntry* pEntry); + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr get_child(const OUString& rID) override; + + virtual std::set get_children() const override; + + virtual OUString get_type() const override; + +private: + + VclPtr mxTreeList; + + SvTreeListEntry* const mpEntry; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/viewdataentry.hxx b/include/vcl/viewdataentry.hxx new file mode 100644 index 000000000000..1277b75edf29 --- /dev/null +++ b/include/vcl/viewdataentry.hxx @@ -0,0 +1,84 @@ +/* -*- 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_VCL_VIEWDATAENTRY_HXX +#define INCLUDED_VCL_VIEWDATAENTRY_HXX + +#include +#include +#include + +#include + +struct SvViewDataItem +{ + Size maSize; +}; + +/** + * View-dependent data for a tree list entry created in the virtual function + * SvTreeListBox::CreateViewData(). The item array contains the same number + * of items as that of the items in its corresponding tree list entry. + * + * When an entry is selected, it is logically selected and visually + * highlighted. When an entry is only highlighted, it looks visually + * highlighted, but not logically selected. + */ +class VCL_DLLPUBLIC SvViewDataEntry +{ + friend class SvTreeList; + + std::vector maItems; + sal_uLong nVisPos; + bool mbSelected:1; + bool mbHighlighted:1; + bool mbExpanded:1; + bool mbFocused:1; + bool mbSelectable:1; + tools::Rectangle maPaintRectangle; + +public: + SvViewDataEntry(); + SvViewDataEntry( const SvViewDataEntry& ); + ~SvViewDataEntry(); + + bool IsSelected() const { return mbSelected;} + bool IsHighlighted() const { return mbHighlighted;} + bool IsExpanded() const { return mbExpanded;} + bool HasFocus() const { return mbFocused;} + bool IsSelectable() const { return mbSelectable;} + void SetFocus( bool bFocus ); + void SetSelected( bool bSelected ); + void SetHighlighted( bool bHighlighted ); + void SetExpanded( bool bExpanded ); + void SetSelectable( bool bSelectable ); + + void Init(size_t nSize); + + const SvViewDataItem& GetItem(size_t nPos) const; + SvViewDataItem& GetItem(size_t nPos); + + void SetPaintRectangle(tools::Rectangle aRectangle); + const tools::Rectangle& GetPaintRectangle() const; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit